Creating an application to read excel (.xls) file.
I am able to read the file but it is showing only count of data.
But not able to get the data from file.
Microsoft.Office.Interop.Excel.Application xlApp = new Excel.Application();
Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(#"C:\Landingfolder\file.xls");
Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1];
Excel.Range xlRange = xlWorksheet.UsedRange;
int rowCount = xlRange.Rows.Count;
int colCount = xlRange.Columns.Count;
for (int i = 1; i <= rowCount; i++)
{
for (int j = 1; j <= colCount; j++)
{
//new line
if (j == 1)
Console.Write("\r\n");
//write the value to the console
if (xlRange.Cells[i, j] != null && xlRange.Cells[i, j].Value2 != null)
Console.Write(xlRange.Cells[i, j].Value2.ToString() + "\t");
Console.ReadLine();
}
}
Please let me know the right process.
Use this Code
using System.Data.OleDb;
using System.IO;
using System.Data;
public class Employee
{
public string Name { get; set; }
public string Designation { get; set; }
public int? Experience { get; set; }
}
/// <summary>
/// Open Connection
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
private OleDbConnection OpenConnection(string path)
{
OleDbConnectio n oledbConn = null;
try
{
if (Path.GetExtension(path) == ".xls")
oledbConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + path +
"; Extended Properties= \"Excel 8.0;HDR=Yes;IMEX=2\"");
else if (Path.GetExtension(path) == ".xlsx")
oledbConn = new OleDbConnection(#"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" +
path + "; Extended Properties='Excel 12.0;HDR=YES;IMEX=1;';");
oledbConn.Open();
}
catch (Exception ex)
{
//Error
}
return oledbConn;
}
/// <summary>
/// Extract 'Service Information' sheet
/// </summary>
/// <param name="oledbConn"></param>
private IList<Employee> ExtractEmployeeExcel(OleDbConnection oledbConn)
{
OleDbCommand cmd = new OleDbCommand (); ;
OleDbDataAdapter oleda = new OleDbDataAdapter();
DataSet dsEmployeeInfo = new DataSet ();
cmd.Connection = oledbConn;
cmd.CommandT ype = CommandType.Text;
cmd.CommandT ext = "SELECT * FROM [Employee$]"; //Excel Sheet Name ( Employee )
oleda = new OleDbDataAdapter(cmd);
oleda.Fill (dsEmployeeInfo, "Employee");
var dsEm ployeeInfoList = dsEmployeeInfo.Tables[0].AsEnumerable().Select (s => new Employee
{
Name = Convert.ToString(s["Name"] ! = DBNull.Value ? s["Name"] : ""),
Designation = Convert.ToString(s["Designation"] ! = DBNull.Value ? s["Designation"] : ""),
Experience = Convert.ToInt32(s["Experience"])
}).ToList ();
return dsEmployeeInfoList;
}
/// <summary>
/// Read excel sheet with the user path
/// </summary>
/// <param name="path"></param>
public IList<Employee> ReadExcel(string path)
{
IList<Employ ee> objEmployeeInfo = new List<Employee>();
try
{
OleDbConnection oledbConn = OpenConnection(path);
if (oledbConn.State == ConnectionState.Open)
{
objEmployeeInfo = ExtractEmployeeExcel (oledbConn);
oledbConn.Close();
}
}
catch (Exception ex)
{
// Error
}
return objEmployeeInfo;
}
Use of Code:
Here calling the ReadExcel() method to get the excel content.
string path = #"D:\Employee.xls";
IList<Employee> objExcelCon = ReadExcel(path);
Related
My View consists of multiple tables, and I am looking to Export multiple tables from View in Excel file. My current function only helps me to export 1 table.
Can any one help me to complete this code so that multiple tables can be exported?
Report VM
public class ReportVM
{
public string ScenName { get; set; }
public int Count { get; set; }
public string CreateTickYes { get; set; }
public int TickYes { get; set; }
public string RegionName { get; set; }
public int RegionCount { get; set; }
public string UserName { get; set; }
public int ChatCountUser { get; set; }
}
Action Method to export
public FileContentResult DownloadReport(DateTime start, DateTime end)
{
//var uName = User.Identity.Name;
var fileDownloadName = String.Format("Report.xlsx");
const string contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
// Pass your ef data to method
ExcelPackage package = GenerateExcelFile(db.Chats.Where(x => System.Data.Entity.DbFunctions.TruncateTime(x.ChatCreateDateTime) >= start && System.Data.Entity.DbFunctions.TruncateTime(x.ChatCreateDateTime) <= end)
.GroupBy(a => a.ScenarioList).Select(b => new ReportVM()
{
ScenName = b.Key,
Count = b.Count()
}).ToList());
var fsr = new FileContentResult(package.GetAsByteArray(), contentType);
fsr.FileDownloadName = fileDownloadName;
return fsr;
}
private static ExcelPackage GenerateExcelFile(IEnumerable<ReportVM> datasource)
{
ExcelPackage pck = new ExcelPackage();
//Create the worksheet
ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Sheet 1");
// Sets Headers
ws.Cells[1, 1].Value = "Scenario";
ws.Cells[1, 2].Value = "No.Of Chats";
// Inserts Data
for (int i = 0; i < datasource.Count(); i++)
{
ws.Cells[i + 2, 1].Value = datasource.ElementAt(i).ScenName;
ws.Cells[i + 2, 2].Value = datasource.ElementAt(i).Count;
}
//Sheet2
// Format Header of Table
using (ExcelRange rng = ws.Cells["A1:B1"])
{
rng.Style.Font.Bold = true;
rng.Style.Fill.PatternType = ExcelFillStyle.Solid; //Set Pattern for the background to Solid
rng.Style.Fill.BackgroundColor.SetColor(Color.Gold); //Set color to DarkGray
rng.Style.Font.Color.SetColor(Color.Black);
}
return pck;
}
So, now it export data for Table GroubBy = ScenarioList. I want to also include another column in groupBy = Username. So when Export data, Excel file should contain 2 Sheets. 1 for Table ScenarioList, and 2nd for Table Username.
Help is much appreciated. Thank you in advance.
You need create div/table under which put all tables and then by using below javascript function. Please call this javascript function on button click on same page which have all data. This is working for me which I already used in my project.
function DownloadToExcel() {
var htmls = $("#compareBodyContent")[0].innerHTML; // this main element under which
//all you data
var uri = 'data:application/vnd.ms-excel;base64,';
var template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>';
var base64 = function (s) {
return window.btoa(unescape(encodeURIComponent(s)))
};
var format = function (s, c) {
return s.replace(/{(\w+)}/g, function (m, p) {
return c[p];
})
};
var ctx = {
worksheet: 'Worksheet',
table: '<table>' + htmls + '</table>'
}
var compareLink = document.createElement("a");
compareLink.download = "Compare_Test.xls";
compareLink.href = uri + base64(format(template, ctx));
compareLink.click();
}
Hope this will help you. Let me know if you have any question on this.
I'm trying to get the filters of a table in order to reapply them after some modifications. Everything is ok, but the trouble begins when the filter is on a Date column. This is the way I'm doing it:
for (int i = 1; i <= filters.Count; i++)
{
FilterTemp f = new FilterTemp();
f.On = filters[i].On;
if (f.On)
{
f.Field = i;
try
{
f.Criteria1 = filters[i].Criteria1;
}
catch { }
f.Operator = (int)filters[i].Operator;
try
{
f.Criteria2 = filters[i].Criteria2;
}
catch { }
}
fs.Add(f);
}
When the filter is on a text or number column, everything works beautifully, but when a date column is filtered by year, month or day, I get an exception on line 5 when trying to get the "Criteria1".
I tried to change the operator to xlFilterDynamic, as mentioned on an answer of this MSDN post: https://social.msdn.microsoft.com/Forums/vstudio/en-US/15ec8d69-3e6f-450d-82c0-ca53e63c8f64/getting-data-of-list-object-filters-for-date-column?forum=vsto
Something like this:
for (int i = 1; i <= filters.Count; i++)
{
FilterCache f = new FilterCache();
f.On = filters[i].On;
if (f.On)
{
f.Field = i;
try
{
f.Criteria1 = filters[i].Criteria1;
}
catch
{
filters[i].Operator = XlAutoFilterOperator.xlFilterDynamic;
f.Criteria1 = filters[i].Criteria1;
}
f.Operator = (int)filters[i].Operator;
if (f.Operator == 0)
f.Operator = (int)XlAutoFilterOperator.xlAnd;
try
{
f.Criteria2 = filters[i].Criteria2;
}
catch { }
}
fs.Add(f);
}
No success. The filters[i].Criteria1 is now returning 1 forever, it doesn't matter the filter I use on that date column.
In order to simulate this issue, it is necessary to create a table on an Excel worksheet and then put some random dates in a column. Then, filter this column selecting at least 3 different dates. Run the code.
There's already a post about this on stackoverflow: Excel VSTO - accessing AutoFilter's Array Criteria throws exceptions
Also at: https://social.msdn.microsoft.com/Forums/office/en-US/281fdbc5-6535-497f-b427-f69f4b092e24/excel-vsto-accessing-autofilters-array-criteria-throws-exceptions
... But there are no satisfactory answers or maybe it is a little bit difficult to understand the question.
FilterTemp class:
public class FilterTemp
{
public bool On;
public object Field;
public object Criteria1;
public int Operator;
public object Criteria2;
}
So this is just an idea The ultimate goal is to return the date back to client in a way that it can be re-applied via AutoFilter like here
string[] FilterList = new string[] { "10/31/2013", "5/4/2013" };
visibleCells.AutoFilter(1, FilterList.Length > 0 ? FilterList.ToArray() : Type.Missing, Excel.XlAutoFilterOperator.xlFilterValues, Type.Missing, true);
Hopefully this will give you a hint how to continue. I'll try to finalize it some day.
All code with example on GitHub
using System;
using System.Collections.Generic;
using System.Linq;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using Excel = Microsoft.Office.Interop.Excel;
using System.IO;
namespace AutoFilterRetriever
{
/// <summary>
/// An example class how to get AutoFilter criteria from internal XML representation
/// </summary>
public class CriteriaFilterRetriever : IDisposable
{
private readonly Excel.Worksheet wks;
private readonly string filePath;
private Stream docStream;
private SpreadsheetDocument openXmlDoc;
private WorkbookPart wkb;
public CriteriaFilterRetriever(Excel.Worksheet sheet)
{
wks = sheet;
filePath = sheet.Application.ActiveWorkbook.FullName;
if (!filePath.Contains("\\"))
{
throw new FileLoadException("Save the file in order to get autofilter criteria");
}
}
/// <summary>
/// This can be changed to a complex object instead of just list of strings
/// </summary>
public List<string> FilterCriteria { get; private set; }
public void GetFilterCriteria()
{
if (!OpenFile()) throw new FileLoadException($"Couldn't open the file - {filePath}");
if (wks.AutoFilter == null) return;
// here we get sheet in the workbook.xml (Equals don't work here)
var sheetInWkb = wkb.Workbook.Descendants<Sheet>().Where(s => s.Name == wks.Name).FirstOrDefault();
// get a reference to the worksheet part. Imagine part as the folder in the zip structure
WorksheetPart wsPart = (WorksheetPart)(wkb.GetPartById(sheetInWkb.Id));
// finally get the xml file e.g. sheet1.xml
var sheet = wsPart.Worksheet;
// there should be just one autofilter per sheet
var filter = sheet.Descendants<AutoFilter>().First();
if (filter == null) throw new InvalidOperationException($"Couldn't get autofilter data from the {wks.Name} sheet.");
ManageFilterData(filter);
}
private void ManageFilterData(AutoFilter filter)
{
FilterCriteria = new List<string>();
// this is always the first element in AutoFilter
foreach (FilterColumn filterCol in filter)
{
// here we get the filters data
var filters = filterCol.FirstChild;
if (filters is Filters)
{
foreach (var item in filters)
{
if (item is DateGroupItem)
{
FilterCriteria.Add(GetDateFilterCriteria(item as DateGroupItem));
}
else if (item is Filter)
{
FilterCriteria.Add(((Filter)item).Val);
}
else
{
throw new Exception("Not sure what to do here");
}
}
}
else if (filters is CustomFilters)
{
// if custom filter is applied (more than one criteria it falls to this category
foreach (var item in filters)
{
if (item is CustomFilter)
{
var tmp = item as CustomFilter;
FilterCriteria.Add($"{tmp.Operator}, {tmp.Val}");
}
else
{
throw new Exception("Not sure what to do here");
}
}
}
}
}
private string GetDateFilterCriteria(DateGroupItem criteria)
{
if (criteria.DateTimeGrouping == DateTimeGroupingValues.Year)
{
return criteria.Year.ToString();
}
else if (criteria.DateTimeGrouping == DateTimeGroupingValues.Month)
{
return $"{criteria.Year.ToString()}-{criteria.Month.ToString()}";
}
else if (criteria.DateTimeGrouping == DateTimeGroupingValues.Day)
{
return $"{criteria.Year.ToString()}-{criteria.Month.ToString()}-{criteria.Day.ToString()}";
}
else if (criteria.DateTimeGrouping == DateTimeGroupingValues.Hour)
{
return $"{criteria.Year.ToString()}-{criteria.Month.ToString()}-{criteria.Day.ToString()} {criteria.Hour.ToString()}:00:00";
}
else if (criteria.DateTimeGrouping == DateTimeGroupingValues.Minute)
{
return $"{criteria.Year.ToString()}-{criteria.Month.ToString()}-{criteria.Day.ToString()} {criteria.Hour.ToString()}:{criteria.Minute.ToString()}:00";
}
else
{
return $"{criteria.Year.ToString()}-{criteria.Month.ToString()}-{criteria.Day.ToString()} " +
$"{criteria.Hour.ToString()}:{criteria.Minute.ToString()}:{criteria.Second.ToString()}";
}
}
/// <summary> Opens the given file via the DocumentFormat package </summary>
/// <returns></returns>
private bool OpenFile()
{
try
{
docStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
openXmlDoc = SpreadsheetDocument.Open(docStream, false);
wkb = openXmlDoc.WorkbookPart;
return true;
}
catch (Exception)
{
return false;
}
}
public void Dispose()
{
openXmlDoc?.Close();
docStream?.Close();
}
}
}
I am new to threading and I have currently used Tasks to perform multi threading. As you can see in the code, one set of tasks perform a series of extraction from an Excel and the Task.WaitAll() is working as expected.
But for the second set of tasks, the Task.WaitAll() is not working as expected. The control is going directly to the next method outside the task pool instead of waiting for the tasks to complete.
I am using the first set of tasks to extract from an Excel and the next set of tasks to store the values in objects.
Thanks in advance.
//MainClass.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace ConsoleApplication2
{
/// <summary>
/// class to call the methods to extract values and assign values using multithreading
/// </summary>
public class MainClass : ExtractValues
{
public static int size;
static void Main(string[] args)
{
ExtractValues objectOfExtractValues = new ExtractValues();
Values objectOfValues = new Values();
size = objectOfExtractValues.initialize();
List<int> Range = new List<int>();
Range = objectOfExtractValues.cellRangeFinder();
//creating a new task to call methods to extract details from the excel to run parallelly
Task[] task = new Task[6];
{
task[0] = Task.Factory.StartNew(() => objectOfExtractValues.thread1(Range[0]));
task[1] = Task.Factory.StartNew(() => objectOfExtractValues.thread2(Range[0], Range[1]));
task[2] = Task.Factory.StartNew(() => objectOfExtractValues.thread3(Range[2], Range[3]));
task[3] = Task.Factory.StartNew(() => objectOfExtractValues.thread4(Range[4], Range[5]));
task[4] = Task.Factory.StartNew(() => objectOfExtractValues.thread5(Range[6], Range[7]));
task[5] = Task.Factory.StartNew(() => objectOfExtractValues.thread6(Range[8], Range[9]));
}
Task.WaitAll(task);
objectOfValues.init();
Task tasknew1 = Task.Factory.StartNew(() => objectOfValues.assignValues1());
Task tasknew2 = Task.Factory.StartNew(() => objectOfValues.assignValues2());
Task tasknew3 = Task.Factory.StartNew(() => objectOfValues.assignValues3());
Task tasknew4 = Task.Factory.StartNew(() => objectOfValues.assignValues4());
Task tasknew5 = Task.Factory.StartNew(() => objectOfValues.assignValues5());
Task tasknew6 = Task.Factory.StartNew(() => objectOfValues.assignValues6());
Task tasknew7 = Task.Factory.StartNew(() => objectOfValues.assignValues7());
Task.WaitAll(tasknew1, tasknew2, tasknew3, tasknew4, tasknew5, tasknew6, tasknew7);
//Task.WhenAll();
//Task.WaitAll();
//calling method to initialize the object array
// creating another task to call methods to assign details stored in the list to objects parallelly
objectOfExtractValues.endProcess();
// wait
Console.ReadLine();
objectOfValues.show();
}
}
}
** ExtractValue.cs**
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Excel = Microsoft.Office.Interop.Excel;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Threading;
namespace ConsoleApplication2
{
/// <summary>
/// class containing methods to extract values from the excel
/// </summary>
public class ExtractValues
{
public int rowCount;
public int colCount;
//lists to store values from different sections of the excel
public static List<int> rangeList = new List<int>();
public static List<string> tempList = new List<string>();
public static List<string> tempList2 = new List<string>();
public static List<string> tempList3 = new List<string>();
public static List<string> tempList4 = new List<string>();
public static List<string> tempList5 = new List<string>();
public static List<string> tempList6 = new List<string>();
public static List<string> tempList7 = new List<string>();
string path = System.Reflection.Assembly.GetExecutingAssembly().Location;
Excel.Application xlApp;
Excel.Workbook xlWorkbook;
Excel._Worksheet xlWorksheet;
Excel.Range xlRange;
int start, end;
/// <summary>
/// method to initaialize the excel and get the column and row count
/// </summary>
public int initialize()
{
var dir = System.IO.Path.GetDirectoryName(path);
string location = dir + "\\some.xlsx";
xlApp = new Excel.Application();
xlWorkbook = xlApp.Workbooks.Open(location);
xlWorksheet = xlWorkbook.Sheets[1];
xlRange = xlWorksheet.UsedRange;
rowCount = xlWorksheet.UsedRange.Rows.Count;
colCount = xlWorksheet.Columns.CurrentRegion.EntireColumn.Count;
return colCount;
}
/// <summary>
/// method to read from the excel file and print it. method reads the rows until the count passed to it.
/// </summary>
/// <param name="count"></param>
public void thread1(int count)
{
for (int i = 2; i <colCount; i++)
{
for (int j = 1; j < count; j++)
{
if (xlRange.Cells[j, i].Value == null && xlRange.Cells[j + 1, i].Value != null)
{
tempList.Add(" ");
}
if (xlRange.Cells[j, i] != null && xlRange.Cells[j, i].Value != null )
tempList.Add(xlRange.Cells[j, i].Value.ToString());
}
}
// for loop to read the cardpan row
for (int i = 2; i <= colCount; i++)
{
for (int j = 12; j <= 12; j++)
{
if (xlRange.Cells[j, i] != null && xlRange.Cells[j, i].Value != null)
tempList7.Add(xlRange.Cells[j, i].Value.ToString());
}
}
}
/// <summary>
/// method to read from the excel file and print it. method reads the rows from and until the count passed to it.
/// </summary>
public void thread2(int count1, int count2)
{
for (int i = 2; i <= colCount; i++)
{
for (int j = count1; j <=count2; j++)
{
if (xlRange.Cells[j, i] != null && xlRange.Cells[j, i].Value != null)
tempList2.Add(xlRange.Cells[j, i].Value.ToString());
}
}
}
/// <summary>
/// method to read from the excel file and print it. method reads the rows from and until the count passed to it.
/// </summary>
/// <param name="count1"></param>
/// <param name="count2"></param>
public void thread3(int count1, int count2)
{
for (int i = 2; i <= colCount; i++)
{
for (int j = count1; j <= count2; j++)
{
if (xlRange.Cells[j, i] != null && xlRange.Cells[j, i].Value != null)
tempList3.Add(xlRange.Cells[j, i].Value.ToString());
}
}
}
/// <summary>
/// method to read from the excel file and print it. method reads the rows from and until the count passed to it.
/// </summary>
/// <param name="count1"></param>
/// <param name="count2"></param>
public void thread4(int count1, int count2)
{
for (int i = 2; i <= colCount; i++)
{
for (int j = count1; j <= count2; j++)
{
if (xlRange.Cells[j, i].Value == null && xlRange.Cells[j + 1, i].Value == null)
{
tempList4.Add(" ");
break;
}
if (xlRange.Cells[j, i] != null && xlRange.Cells[j, i].Value != null)
tempList4.Add(xlRange.Cells[j, i].Value.ToString());
}
}
}
/// <summary>
/// method to read from the excel file and print it. Method reads the rows from and until the count passed to it.
/// </summary>
/// <param name="count1"></param>
/// <param name="count2"></param>
public void thread5(int count1, int count2)
{
for (int i = 2; i <= colCount; i++)
{
for (int j = count1; j <= count2; j++)
{
if (xlRange.Cells[j, i].Value == null && xlRange.Cells[j + 1, i].Value == null)
{
tempList5.Add(" ");
break;
}
if (xlRange.Cells[j, i] != null && xlRange.Cells[j, i].Value != null)
tempList5.Add(xlRange.Cells[j, i].Value.ToString());
//add useful things here!
}
}
}
/// <summary>
/// method to read from the excel file and print it. method reads the rows from and till the count passed to it.
/// </summary>
/// <param name="count1"></param>
/// <param name="count2"></param>
public void thread6(int count1, int count2)
{
for (int i = 2; i <= colCount; i++)
{
for (int j = count1; j <= count2; j++)
{
if (xlRange.Cells[j, i].Value == null && xlRange.Cells[j + 1, i].Value == null)
{
tempList6.Add(" ");
break;
}
if (xlRange.Cells[j, i] != null && xlRange.Cells[j, i].Value != null)
tempList6.Add(xlRange.Cells[j, i].Value.ToString());
}
}
}
/// <summary>
/// method to end the excel file operations
/// </summary>
public void endProcess()
{
xlWorkbook.Close();
GC.Collect();
GC.WaitForPendingFinalizers();
Marshal.ReleaseComObject(xlRange);
Marshal.ReleaseComObject(xlWorksheet);
//close and release
Marshal.ReleaseComObject(xlWorkbook);
//quit and release
xlApp.Quit();
Marshal.ReleaseComObject(xlApp);
}
/// <summary>
/// method to find the merged cells in the excel and store their starting and ending cell values in a list
/// </summary>
/// <returns></returns>
public List<int> cellRangeFinder()
{
for (int i = 1; i <= rowCount; i++)
{
for (int k = 1; k <=1 ; k++)
{
if (xlRange.Cells[i, k] != null && xlRange.Cells[i+1, k].Value == null)
{
start = i;
int tempCounter = i + 1;
while(xlRange.Cells[tempCounter, k].Value == null && (tempCounter<=rowCount+3))
{
tempCounter++;
}
end = tempCounter-1;
rangeList.Add(start);
rangeList.Add(end);
i = tempCounter-1;
}
}
}
return rangeList;
}
}
}
Values.cs
enter code here
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
/// <summary>
/// Class to store the values in the objects
/// </summary>
public class Values : MainClass
{
// Variables to store the values of each object
public int ID { get; set; }
public string tType { get; set; }
public string cType { get; set; }
public string tName { get; set; }
public string SNumber { get; set; }
public string title { get; set; }
public string objective { get; set; }
public string reference { get; set; }
public string prerequisite { get; set; }
public string procedure { get; set; }
public string cPan { get; set; }
public string amount { get; set; }
public string pHost { get; set; }
public string pCard { get; set; }
public string cSlip { get; set; }
// Declaring the Values' class object array
Values[] list;
/// <summary>
/// method to set the size of the array object
/// </summary>
public void init()
{
list= new Values[size];
}
/// <summary>
/// Method to assign the values of the first temp list into the object array
/// </summary>
/// <param name="size"> size varaible is to check the creating of new objects</param>
public void assignValues1()
{
int m = 0;
list[m] = new Values();
for (int i = 0; i < tempList.Count();)
{
list[m].ID = Convert.ToInt32(tempList[i]);
list[m].tType = tempList[i + 1];
list[m].cType = tempList[i + 2];
list[m].tName = tempList[i + 3];
list[m].SNumber = tempList[i + 4];
list[m].title = tempList[i + 5];
list[m].objective = tempList[i + 6];
list[m].reference = tempList[i + 7];
list[m].prerequisite = tempList[i + 8];
i = i + 9;
m++;
if (m < size)
list[m] = new Values();
else
break;
}
}
/// <summary>
/// Method to assign the values of the sevent temp list into the object array which contains Card Pan
/// </summary>
public void assignValues2()
{
int m = 0;
list[m] = new Values();
for (int i = 0; i < tempList7.Count();)
{
list[m].cPan = tempList7[i];
i = i + 1;
m++;
if (m < size)
list[m] = new Values();
else
break;
}
}
/// <summary>
/// Method to assign the values of the second temp list into the object array which contains the procedure
/// </summary>
/// <param name="size"> size varaible is to check the creating of new objects</param>
public void assignValues3()
{
int m = 0;
list[m] = new Values();
for (int i = 0; i < tempList2.Count();)
{
list[m].procedure = tempList2[i] + tempList2[i+1];
i = i + 2;
m++;
if (m < size)
list[m] = new Values();
else
break;
}
}
/// <summary>
/// Method to assign the values of the amount temp list into the object array which contains amount values
/// </summary>
/// <param name="size"> size varaible is to check the creating of new objects</param>
public void assignValues4()
{
int m = 0;
list[m] = new Values();
for (int i = 0; i < tempList3.Count();)
{
list[m].amount = tempList3[i];
i = i + 1;
m++;
if (m < size)
list[m] = new Values();
else
break;
}
}
/// <summary>
/// Method to assign the values of the fourth list into the object array which contains phost values
/// </summary>
/// <param name="size"> size varaible is to check the creating of new objects</param>
public void assignValues5()
{
int m = 0;
int i = 0;
list[m] = new Values();
for (i = 0; i < tempList4.Count();i++)
{
while (tempList4[i] != " " )
{
list[m].pHost = tempList4[i];
i++;
}
if (tempList4[i] == " " && i + 1 < tempList5.Count() && tempList4[i + 1] == " ")
{
m++;
i++;
list[m] = new Values();
list[m].pHost = tempList4[i];
}
m++;
if (m < size)
list[m] = new Values();
else
break;
}
}
/// <summary>
/// Method to assign the values of the fifth temp list into the object array which contains pCard values
/// </summary>
/// <param name="size"> size varaible is to check the creating of new objects</param>
public void assignValues6()
{
int m = 0;
int m2 = 0;
list[m] = new Values();
for (int i = 0; i < tempList5.Count() ; i++)
{
while (tempList5[i] != " ")
{
list[m].pCard = tempList5[i];
i++;
}
if (tempList5[i] == " " && i + 1 < tempList5.Count() && tempList5[i + 1] == " ")
{
if (m == m2 && m + 1 < size)
{
m++;
m2 = m;
}
list[m] = new Values();
list[m].pCard = " ";
m++;
if (m < size)
continue;
else
break;
}
m++;
m2 = m;
if (m < size)
list[m] = new Values();
else
break;
}
}
/// <summary>
/// Method to assign the values of the sixth temp list into the object array which contains the cslip details
/// </summary>
/// <param name="size"> size varaible is to check the creating of new objects</param>
public void assignValues7()
{
int m = 0;
int m2 = 0;
list[m] = new Values();
for (int i = 0; i < tempList6.Count();)
{
while (tempList6[i] != " ")
{
list[m].cslip = tempList6[i];
i++;
}
if (tempList6[i] == " " && i + 1 < tempList6.Count() && tempList6[i + 1] == " ")
{
if (m == m2 && m + 1 < size)
{
m++;
m2 = m;
}
list[m].cSlip = " ";
m++;
if (m < size)
continue;
else
break;
}
m++;
m2 = m;
if (m < size)
list[m] = new Values();
else
break;
}
}
public void show()
{
for(int i=0; i<size; i++)
{
Console.WriteLine(list[i].ID + " " + list[i].tName);
}
Console.ReadKey();
}
}
}
Your code is written OK, it seems that there is an issue with the thread that waits for all your tasks to be done ( Task.WaitAll call on tasks/tasknew arrays).
For instance, if you'll run your code from ConsoleApplciation in Main function, your process will end way before your tasks. So, simple Console.ReadLine call will solve your issue in this specific case.
Something like this:
Task[] task = new Task[6];
{
///...
Task.WaitAll(task);
Task[] tasknew = new Task[7];
{
//...
}
Task.WaitAll(tasknew);
//This will prevant you process to be closed, since it will wait for keyboard input.
Console.ReadKey();
I am working in a cross platform project, where we need to connect to Azure Notification Hub from Unity 3d.
We are trying to use the REST API, but we are having a problem with the generation of the SAS token. When trying to write to the stream we get an exception "Error writing request: The authentication or decryption has failed."
I think the generation of the SaS token has something wrong since it had to be modified to be cross platform and work within Unity.
Here is the code so far
using UnityEngine;
using System.Collections;
using System;
using System.Net;
using System.IO;
using System.Text;
/// <summary>
/// check https://msdn.microsoft.com/en-us/library/azure/dn495627.aspx
/// check also http://piotrwalat.net/hmac-authentication-in-asp-net-web-api/
/// </summary>
public class AzureNotificationHub : MonoBehaviour
{
public string CloudServiceNotificationHubPath = "cloudservicechat";
public string CloudServiceNotificationHubConnectionString =
"{CONNSTRINGHERE}";
public string NotificationHubUrl = "{HUBURLHERE}";
private ConnectionStringUtility objConnectionStringUtility = null;
public string SasToken;
public TextAsset CreateRegistrationTemplate = null;
// Use this for initialization
void Start()
{
this.objConnectionStringUtility = new ConnectionStringUtility(CloudServiceNotificationHubConnectionString);
this.SasToken = this.objConnectionStringUtility.getSaSToken(this.NotificationHubUrl, 10);
}
// Update is called once per frame
void Update()
{
}
private string atomContentType = "application/atom+xml;type=entry;charset=utf-8";
public void CreateRegistration()
{
string methodUrl = string.Format("{0}/{1}", this.NotificationHubUrl, "registrations/?api-version=2015-01");
string result = HttpPost(methodUrl);
}
/// <summary>
/// check http://stackoverflow.com/questions/9153181/adding-a-body-to-a-httpwebrequest-that-is-being-used-with-the-azure-service-mgmt
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
string HttpGet(string url)
{
HttpWebRequest req = WebRequest.Create(url)
as HttpWebRequest;
req.Headers.Add("Content-Type", this.atomContentType);
req.Headers.Add("Authorization", this.SasToken);
req.Headers.Add("x-ms-version", "2015-01");
req.Method = WebRequestMethods.Http.Get;
string result = null;
//writeStream.Write
using (HttpWebResponse resp = req.GetResponse()
as HttpWebResponse)
{
StreamReader reader =
new StreamReader(resp.GetResponseStream());
result = reader.ReadToEnd();
}
return result;
}
string HttpPost(string url)
{
string result = null;
string tokenForUrl = this.objConnectionStringUtility.getSaSToken(url, 10);
try
{
string body = this.CreateRegistrationTemplate.text;
body = body.Replace("{tags}", string.Empty);
body = body.Replace("{ChannelUri}", this.NotificationHubUrl);
byte[] bodyArray = System.Text.Encoding.UTF8.GetBytes(body);
HttpWebRequest req = WebRequest.Create(url)
as HttpWebRequest;
req.ContentType = this.atomContentType;
//req.Headers.Add(HttpRequestHeader.Authorization, this.SasToken);
req.Headers.Add(HttpRequestHeader.Authorization, tokenForUrl);
req.Headers.Add("x-ms-version", "2015-01");
req.Method = WebRequestMethods.Http.Post;
Stream writeStream = req.GetRequestStream();
writeStream.Write(bodyArray, 0, bodyArray.Length);
writeStream.Flush();
writeStream.Close();
using (HttpWebResponse resp = req.GetResponse()
as HttpWebResponse)
{
StreamReader reader =
new StreamReader(resp.GetResponseStream());
result = reader.ReadToEnd();
}
}
catch (Exception ex)
{
result = ex.Message;
}
return result;
}
}
public partial class ConnectionStringUtility
{
public string Endpoint { get; private set; }
public string SasKeyName { get; private set; }
public string SasKeyValue { get; private set; }
private string sasTokenn { get; set; }
public ConnectionStringUtility(string connectionString)
{
//Parse Connectionstring
char[] separator = { ';' };
string[] parts = connectionString.Split(separator);
for (int i = 0; i < parts.Length; i++)
{
if (parts[i].StartsWith("Endpoint"))
Endpoint = "https" + parts[i].Substring(11);
if (parts[i].StartsWith("SharedAccessKeyName"))
SasKeyName = parts[i].Substring(20);
if (parts[i].StartsWith("SharedAccessKey"))
SasKeyValue = parts[i].Substring(16);
}
}
/// <summary>
/// check http://buchananweb.co.uk/security01i.aspx
/// </summary>
/// <param name="uri"></param>
/// <param name="minUntilExpire"></param>
/// <returns></returns>
public string getSaSToken(string uri, int minUntilExpire)
{
string targetUri = Uri.EscapeDataString(uri.ToLower()).ToLower();
// Add an expiration in seconds to it.
long expiresOnDate = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
expiresOnDate += minUntilExpire * 60 * 1000;
long expires_seconds = expiresOnDate / 1000;
String toSign = targetUri + "\n" + expires_seconds;
HmacSignatureCalculator hmacSigner = new HmacSignatureCalculator();
System.Security.Cryptography.SHA256Managed crypto = new System.Security.Cryptography.SHA256Managed();
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
var messageBuffer = ConvertStringToBinary(toSign, encoding);
var keyBuffer = ConvertStringToBinary(SasKeyValue, encoding);
var hmacKey = CreateKey(keyBuffer);
var signedMessage = Sign(hmacKey, messageBuffer);
string signature = Uri.EscapeDataString(signedMessage);
return "SharedAccessSignature sr=" + targetUri + "&sig=" + signature + "&se=" + expires_seconds + "&skn=" + SasKeyName;
}
private byte[] CreateKey(byte[] keyBuffer)
{
System.Security.Cryptography.SHA256Managed crypto = new System.Security.Cryptography.SHA256Managed();
var computedHash = crypto.ComputeHash(keyBuffer);
return computedHash;
}
public string Sign(byte[] hmacKey, byte[] messageBuffer)
{
using (System.Security.Cryptography.SHA256Managed crypto = new System.Security.Cryptography.SHA256Managed())
{
var hash = crypto.ComputeHash(hmacKey);
var signature = Convert.ToBase64String(hash);
return signature;
}
}
public byte[] ConvertStringToBinary(string value, Encoding encoding)
{
//Requires.NotNull(value, "value");
//Requires.NotNull(encoding, "encoding");
return encoding.GetBytes(value);
}
}
Any ideas what I should do?
Thanks for the help.
I'm trying to use a third party dll called ASPTokenInputLib in my sharepoint2013 webpart .
It was working for a while when I loaded it in the bin directory but when I tried to move it to the GAC it won't work and it's stopped working if I load it in the bin now as well.
The error I get is object reference not set to an instance of an object. The sharepoint logs shows
System.NullReferenceException: Object reference not set to an instance of an object. at ASPTokenInputLib.ASPTokenInput.OnLoad(EventArgs e)
My package manifest file includes
<Assemblies>
<Assembly Location="ASPTokenInputLib.dll" DeploymentTarget="GlobalAssemblyCache" />
<Assembly Location="BidSearchWebPart.dll" DeploymentTarget="GlobalAssemblyCache">
<SafeControls>
<SafeControl Assembly="BidSearchWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=59049686a9425568" Namespace="BidSearchWebPart.VisualWebPart1" TypeName="*" />
</SafeControls>
</Assembly>
If I remove any ASPTokenInput controls in the webpart the webpart loads correctly so I don't think there's a problem finding the control in the gac (I've used process monitor and it is looking in the correct place in the GAC to find the control). For some reason though it can't load the dll.
Any help would be much appreciated. Thanks!
My ascx.cs files is
using System;
using System.Diagnostics;
using System.ComponentModel;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using System.Web.Script.Serialization;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using ASPTokenInputLib;
namespace BidSearchWebPart.VisualWebPart1
{
[ToolboxItemAttribute(false)]
public partial class BidSearchWebPart : WebPart
{
private enum Columns
{
BidRef, BidName, Client, Area, TeamLead
}
private string TeamLeadsData, ExecLeadsData, StagesData, SectorsData, ServicesData, GradesData, CostCentresData, ClientsData, AreasData;
public BidSearchWebPart()
{
TeamLeadsData = RunSP("uspSelectTeamLeads", "TeamLead", "Name", ConnectionString());
ExecLeadsData = RunSP("uspSelectExecTechLeads", "ExecutiveTechnicalLead", "Name", ConnectionString());
StagesData = RunSP("uspSelectStages", "StageID", "StageDescSearch", ConnectionString());
SectorsData = RunSP("spSelectMarketSectors", "SectorID", "MktSector", CCDConnectionString());
ServicesData = RunSP("spSelectAllServices", "ServiceID", "Service", CCDConnectionString());
GradesData = RunSP("uspSelectGrades", "GradeID", "GradeDesc", ConnectionString());
CostCentresData = RunSP("uspSelectCostCentres", "CostCentre", "Name", ConnectionString());
ClientsData = RunSP("spSelectAllClients", "CompanyRef", "CoName", CCDConnectionString());
AreasData = RunSP("uspSelectAreas", "AreaID", "AreaName", ConnectionString());
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
InitializeControl();
}
protected void Page_Load(object sender, EventArgs e)
{
List<string> ddValues = new List<string>();
if (!Page.IsPostBack)
{
ddValues.Add("Greater than");
ddValues.Add("Less than");
ddCC.DataSource = ddValues;
ddFV.DataSource = ddValues;
ddCC.DataBind();
ddFV.DataBind();
}
btnSearch.Click += btnSearch_Click;
gvSearchResults.RowDataBound += gvSearchResults_RowDataBound;
tiTeamLead.DataSource = ASPTokenInput.DataSourceType.DataSet;
tiTeamLead.DataSet = TeamLeadsData;
tiExecTechLead.DataSource = ASPTokenInput.DataSourceType.DataSet;
tiExecTechLead.DataSet = ExecLeadsData;
tiStage.DataSource = ASPTokenInput.DataSourceType.DataSet;
tiStage.DataSet = StagesData;
tiSector.DataSource = ASPTokenInput.DataSourceType.DataSet;
tiSector.DataSet = SectorsData;
tiService.DataSource = ASPTokenInput.DataSourceType.DataSet;
tiService.DataSet = ServicesData;
tiGrade.DataSource = ASPTokenInput.DataSourceType.DataSet;
tiGrade.DataSet = GradesData;
tiCostCentre.DataSource = ASPTokenInput.DataSourceType.DataSet;
tiCostCentre.DataSet = CostCentresData;
tiClient.DataSource = ASPTokenInput.DataSourceType.DataSet;
tiClient.DataSet = ClientsData;
tiArea.DataSource = ASPTokenInput.DataSourceType.DataSet;
tiArea.DataSet = AreasData;
}
void btnSearch_Click(object sender, EventArgs e)
{
//if (string.IsNullOrEmpty(txtProjectNo.Text) && string.IsNullOrEmpty(txtProjectName.Text) && string.IsNullOrEmpty(txtClient.Text) && string.IsNullOrEmpty(txtKeyword.Text)) // Do nothing if search text boxes are blank
//{
// return;
//} else {
gvSearchResults.PageIndex = 0;
DoSearch();
//}
}
protected void gvSearchResults_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvSearchResults.PagerTemplate = null;
gvSearchResults.PageIndex = e.NewPageIndex;
DoSearch();
}
public void DoSearch()
{
DataTable dt = new DataTable();
string where = GetWhereClause();
if (!string.IsNullOrEmpty(where))
{
dt = FillTable("spSelectBidSearchResults", where);
}
gvSearchResults.DataSource = dt;
gvSearchResults.PageSize = 10;
gvSearchResults.PagerTemplate = null;
gvSearchResults.DataBind();
}
private DataTable FillTable(string storedProc, string where)
{
SqlConnection conn = new SqlConnection(ConnectionString());
conn.Open();
SqlCommand cmdProject = new SqlCommand(storedProc, conn);
cmdProject.CommandType = CommandType.StoredProcedure;
cmdProject.Parameters.AddWithValue("#whereclause", where);
SqlDataAdapter da = new SqlDataAdapter(cmdProject);
DataTable dt = new DataTable();
da.Fill(dt);
da.Dispose();
conn.Close();
return dt;
}
private string Symbol(string ddText)
{
if (ddText.Equals("Greater than"))
{
return ">";
}
else
{
return "<";
}
}
private string GetWhereClause()
{
string where = "";
where = GetWhereForCol(txtBidName.Text, "", "BidName", "like", where);
where = GetWhereForCol(txtDescription.Text, "", "Description", "like", where);
where = GetWhereForCol(GetTokens(tiTeamLead), "", "TeamLead", "token", where);
where = GetWhereForCol(GetTokens(tiExecTechLead), "", "ExecutiveTechnicalLead", "token", where);
where = GetWhereForCol(txtConstructionCost.Text, ddCC.Text, "ConstructionCost", "numeric", where);
where = GetWhereForCol(txtFeeValue.Text, ddFV.Text, "FeeValue", "numeric", where);
where = GetWhereForCol(GetTokens(tiStage), "", "Stage", "token", where);
where = GetWhereForCol(GetTokens(tiSector), "", "PrimarySector", "token", where, "SecondarySector");
where = GetWhereForCol(GetTokens(tiService), "", "PrimaryService", "token", where);
where = GetWhereForCol(GetTokens(tiGrade), "", "Grade", "token", where);
where = GetWhereForCol(GetTokens(tiCostCentre), "", "PrimaryCostCentre", "token", where);
where = GetWhereForCol(GetTokens(tiClient), "", "ClientRef", "token", where);
where = GetWhereForCol(GetTokens(tiArea), "", "Area", "token", where);
return where;
}
private string GetWhereForCol(string text, string ddText, string colName, string colType, string where, string otherCol = "")
{
if (!string.IsNullOrEmpty(text))
{
if (colType.Equals("like"))
{
where = AddToWhere(where, colName + " LIKE '%" + text + "%'");
}
else if (colType.Equals("numeric"))
{
string symbl = Symbol(ddText);
where = AddToWhere(where, colName + " " + symbl + " " + text);
}
else if (colType.Equals("token"))
{
if (!string.IsNullOrEmpty(otherCol))
{
where = AddToWhere(where, "(" + colName + " in (" + text + ")");
where += " OR " + otherCol + " in (" + text + "))";
}
else
{
where = AddToWhere(where, colName + " in (" + text + ")");
}
}
}
return where;
}
private string AddToWhere(string where, string clause)
{
if (!string.IsNullOrEmpty(clause))
{
if (string.IsNullOrEmpty(where))
{
where = clause;
}
else
{
where += " AND " + clause;
}
}
return where;
}
private string GetTokens(ASPTokenInput ti)
{
StringBuilder strTokens = new StringBuilder();
List<ASPTokenInput.Item> items = ti.SelectedItems;
foreach (ASPTokenInput.Item item in items)
{
if (strTokens.Length > 0)
{
strTokens.Append(", ");
}
strTokens.AppendFormat("'{0}'", item.id);
}
return strTokens.ToString();
}
public string GetSPSingleValue(string spName, string spParamName, string spParamVal, string connectionStr)
{
try
{
SqlConnection conn = new SqlConnection(connectionStr);
SqlCommand cmd = new SqlCommand(spName, conn);
cmd.Parameters.AddWithValue(spParamName, spParamVal);
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
string result = cmd.ExecuteScalar().ToString();
conn.Close();
return result;
}
catch
{
return "";
}
}
void gvSearchResults_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label l;
DataRowView rowView = (DataRowView)e.Row.DataItem;
string bidRef = rowView["BidRef"].ToString();
string teamLeadID = rowView["TeamLead"].ToString();
string teamLeadName = GetSingleRecord("uspSelectTeamLeadByID", ConnectionString(), "#TeamLead", teamLeadID);
l = (Label)e.Row.Cells[(int)Columns.TeamLead].FindControl("lblTeamLead");
l.Text = teamLeadName;
if (siteCollectionExists(bidRef))
{
l = (Label)e.Row.Cells[(int)Columns.BidRef].FindControl("lblBidRef");
HyperLink hl = new HyperLink();
hl.NavigateUrl = "http://bidstore.gleeds.net/bids/" + bidRef;
hl.Text = bidRef;
e.Row.Cells[(int)Columns.BidRef].Controls.Add(hl);
l.Text = "";
}
}
}
//Check if site collection exists at given web application
private static bool siteCollectionExists(string bidNr)
{
bool returnVal = false;
var r = SPContext.Current.Site.WebApplication.Sites.Where(site => site.Url.Contains(bidNr));
foreach (SPSite s in r)
{
returnVal = true;
}
return returnVal;
}
public string TeamLeads()
{
return TeamLeadsData;
}
public string ExecutiveTechnicalLeads()
{
return ExecLeadsData;
}
public string Stages()
{
return StagesData;
}
public string Sectors()
{
return SectorsData;
}
public string Services()
{
return ServicesData;
}
public string Grades()
{
return GradesData;
}
public string CostCentres()
{
return CostCentresData;
}
public string Clients()
{
return ClientsData;
}
public string Areas()
{
return AreasData;
}
public string GetSingleRecord(string spName, string connectionStr, string param, string value)
{
SqlConnection conn = new SqlConnection();
SqlCommand command = new SqlCommand(spName, conn);
conn = new SqlConnection(connectionStr);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue(param, value);
command.Connection = conn;
conn.Open();
string result = command.ExecuteScalar().ToString();
conn.Close();
return result;
}
public string RunSP(string spName, string idCol, string nameCol, string connectionStr)
{
ArrayList data = new ArrayList();
SqlConnection conn = new SqlConnection();
SqlCommand command = new SqlCommand(spName, conn);
conn = new SqlConnection(connectionStr);
command.CommandType = CommandType.StoredProcedure;
command.Connection = conn;
conn.Open();
SqlDataReader dr = command.ExecuteReader();
while (dr.Read())
{
data.Add(new TokenInputRow(dr[idCol].ToString(), dr[nameCol].ToString()));
}
conn.Close();
return Serialize(data);
}
private static string Serialize(object obj)
{
JavaScriptSerializer ser = new JavaScriptSerializer();
return ser.Serialize(obj);
}
private string ConnectionString()
{
return "Data Source=10.2.40.17;Initial Catalog=BidOpening;Persist Security Info=True;User ID=GTL_BidOpening_User;Password=G#rd3n12";
}
private string CCDConnectionString()
{
return "Data Source=10.2.40.17;Initial Catalog=CCDLive;Persist Security Info=True;User ID=GTL_CCDLive_User;Password=G#rd3n";
}
}
public class TokenInputRow
{
public string id;
public string name;
public TokenInputRow(string _id, string _name)
{
id = _id;
name = _name;
}
}
}
I am able to step through the page load, but I can't step into the ASPTokenInput dll. The code fails after the page load has finished.
The ti controls are included in my .ascx file as so %# Register TagPrefix="ati" Assembly="ASPTokenInputLib" Namespace="ASPTokenInputLib" %> ati:ASPTokenInput ID="tiTeamLead" runat="server" HintText="Start typing TeamLead..." />