public void SetColumnsOrderFailsWithNullThis() { var e = Assert.Throws <ArgumentNullException>(() => DataTableExtensions.SetColumnsOrder(null, new DataColumn[0])); Assert.Equal("table", e.ParamName); }
public void FindColumnsWithNullThis() { var e = Assert.Throws <ArgumentNullException>(() => DataTableExtensions.FindColumns(null, new string[0])); Assert.Equal("table", e.ParamName); }
public DataTablesResult <SubjectListViewModel> GetSubjects(DataTablesParam dataTableParam) { var searchString = dataTableParam.GetSearchString(); var subjects = ApplicationService <ISubjectManagementService>().GetSubjectsLecturer(WebSecurity.CurrentUserId, pageInfo: dataTableParam.ToPageInfo(), searchString: searchString); return(DataTableExtensions.GetResults(subjects.Items.Select(_GetSubjectRow), dataTableParam, subjects.TotalCount)); }
public void TestReadFlatFile_DataTableNull_Throws() { SeparatedValueSchema schema = new SeparatedValueSchema(); schema.AddColumn(new Int32Column("id")) .AddColumn(new StringColumn("name")) .AddColumn(new DateTimeColumn("created") { InputFormat = "MM/dd/yyyy" }) .AddColumn(new DecimalColumn("avg")); SeparatedValueOptions options = new SeparatedValueOptions() { IsFirstRecordSchema = true }; using (MemoryStream stream = new MemoryStream()) { using (SeparatedValueWriter builder = new SeparatedValueWriter(stream, schema, options)) { builder.Write(new object[] { 123, "Bob", new DateTime(2012, 12, 31), 3.14159m }); } stream.Position = 0; DataTable table = null; IReader parser = new SeparatedValueReader(stream, options); DataTableExtensions.ReadFlatFile(table, parser); } }
static void Main(string[] args) { //Variable definition var connectionString = "Data Source=172.16.0.6;Initial Catalog=AO2017;Persist Security Info=True;User ID=sa;Password=BQ3$ervice"; var generalFilePath = @"\\canydocs\archives\Users\Missing Dates Report\"; var reportName = "RFP"; var fileName = reportName.Replace(" ", "_") + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".csv"; var filePath = generalFilePath + reportName + @"\" + fileName; var selectStatement = @"EXECUTE dbo.Missing_Dates_RFP_Report"; //Execution start //Instansiate a new SqlActions object var sqlActions = new SqlActions(connectionString); //Execute the selectStatement and store the results in a list of strings var dt = sqlActions.SelectToDataTable(selectStatement); //Create file to write to File.Create(filePath).Dispose(); //Instansiate a new DataTableExtensions object var dataTableExtensions = new DataTableExtensions(); //Write the data from the data table to the file dataTableExtensions.WriteToCsvFile(dt, filePath); }
public void DataTableTest() { var nonSerializableClasseDataTable = GeneralHelper.CopyToDataTable(NonSerializableClass.GenerateList()); TestSerialize(nonSerializableClasseDataTable); TestSerialize(nonSerializableClasseDataTable.DefaultView); var serializableClassDataTable = GeneralHelper.CopyToDataTable(SerializableClass.GenerateList()); TestSerialize(serializableClassDataTable); TestSerialize(serializableClassDataTable.DefaultView); var dt = new DataSet(); var addressTypeEntityCollection = MetaSingletons.MetaData.AddressType.ToEntityCollection(); addressTypeEntityCollection.CreateHierarchicalProjection(dt); TestSerialize(dt.Tables[0]); TestSerialize(dt.Tables[0].DefaultView); var addressTypeDataTable = GeneralHelper.CopyToDataTable(MetaSingletons.MetaData.AddressType); TestSerialize(addressTypeDataTable); TestSerialize(addressTypeDataTable.DefaultView); var enumerableRowCollection = addressTypeDataTable.AsEnumerable(); TestSerialize(enumerableRowCollection); TestSerialize(DataTableExtensions.CopyToDataTable(enumerableRowCollection)); }
public DataTable GetXYData(DataTable mydt) //, string xvar, string yvar, string mytitle, Color mycolor, string colorsby) { List <string> othervars = new List <string>(); if (_settings.colorvar != "none") { othervars.Add(_settings.colorvar); } if (_settings.panevar != "none") { othervars.Add(_settings.panevar); } othervars = othervars.Distinct().ToList(); othervars.Remove(null); DataTable dataxy = DataTableExtensions.SelectColumnXY(mydt, _settings.xaxisvar, _settings.yaxisvar, othervars); if (dataxy.Rows.Count > 0) { _corrs = new Corrs(dataxy, _settings.xaxisvar, _settings.yaxisvar, _settings.digits_corr); Jitter(dataxy, _settings.xaxisvar, _settings.yaxisvar); } return(dataxy); }
public void TestReadFlatFile_DataTableNull_Throws() { DataTable table = null; StringReader stringReader = new StringReader(String.Empty); IReader parser = new SeparatedValueReader(stringReader); Assert.ThrowsException <ArgumentNullException>(() => DataTableExtensions.ReadFlatFile(table, parser)); }
public void GenerateGetAssertHasValue_WithRowNull() { //Arrange var dataTable = new DataTable(); // Action DataTableExtensions.GenerateGetAssertHasValue(dataTable); }
public void AddValueAddsRowWhenDataTableIsEmpty() { var fake = Substitute.For <SAPbouiCOM.DataTable>(); DataTableExtensions.AddValue(fake, new TestClass()); fake.Received().Rows.Add(); }
public void GenerateGetAssertHasValue_WithDataTableNull() { //Arrange DataTable dataTable = null; // Action DataTableExtensions.GenerateGetAssertHasValue(dataTable); }
public void GetCondition_WithDataTableNull() { //Arrange DataTable dataTable = null; int pageNumber = 0; int pageSize = 0; // Action DataTableExtensions.GetCondition(dataTable, pageNumber, pageSize); }
public void GetCondition_WithPageNumberIntMinValue() { //Arrange var dataTable = new DataTable(); int pageNumber = int.MinValue; int pageSize = 0; // Action DataTableExtensions.GetCondition(dataTable, pageNumber, pageSize); }
public void AddValueUsesLastRowWhenDataTableIsNotEmpty() { var fake = Substitute.For <SAPbouiCOM.DataTable>(); fake.Rows.Count.Returns(1); DataTableExtensions.AddValue(fake, new TestClass()); fake.Rows.DidNotReceive().Add(); }
public DataTablesResult <GroupViewModel> GetCollectionGroups(DataTablesParam dataTableParam) { var searchString = dataTableParam.GetSearchString(); ViewBag.EditActionLink = "/Administration/EditGroup"; ViewBag.DeleteActionLink = "/Administration/DeleteGroup"; var groups = GroupManagementService.GetGroupsPageable(pageInfo: dataTableParam.ToPageInfo(), searchString: searchString); return(DataTableExtensions.GetResults(groups.Items.Select(g => GroupViewModel.FormGroup(g, PartialViewToString("_EditGlyphLinks", g.Id))), dataTableParam, groups.TotalCount)); }
public DataTablesResult <StudentViewModel> GetCollectionStudents(DataTablesParam dataTableParam) { var searchString = dataTableParam.GetSearchString(); ViewBag.EditActionLink = "/Administration/EditStudent"; ViewBag.DeleteActionLink = "/Administration/DeleteStudent"; ViewBag.StatActionLink = "/Administration/Attendance"; var students = StudentManagementService.GetStudentsPageable(pageInfo: dataTableParam.ToPageInfo(), searchString: searchString); return(DataTableExtensions.GetResults(students.Items.Select(s => StudentViewModel.FromStudent(s, PartialViewToString("_EditGlyphLinks", s.Id))), dataTableParam, students.TotalCount)); }
public void GenerateGetAssertHasValue_WithEmptyValue() { //Arrange var dataTable = DataTableFactory.GetDataTableWithOneColumnAndOneRow(string.Empty); // Action var actual = DataTableExtensions.GenerateGetAssertHasValue(dataTable); // Assert Assert.AreEqual($"// Empty values\r\n//row.AssertHasValue<String>(\"{dataTable.Columns[0].ColumnName}\");\r\n", actual); }
public DataTablesResult <LecturerViewModel> GetCollectionLecturers(DataTablesParam dataTableParam) { var searchString = dataTableParam.GetSearchString(); ViewBag.EditActionLink = "/Administration/EditProfessor"; ViewBag.DeleteActionLink = "/Administration/DeleteLecturer"; ViewBag.StatActionLink = "/Administration/Attendance"; var lecturers = LecturerManagementService.GetLecturersPageable(pageInfo: dataTableParam.ToPageInfo(), searchString: searchString); return(DataTableExtensions.GetResults(lecturers.Items.Select(l => LecturerViewModel.FormLecturers(l, PartialViewToString("_EditGlyphLinks", l.Id))), dataTableParam, lecturers.TotalCount)); }
public DataTablesResult <ProjectListViewModel> GetProjects(DataTablesParam dataTableParam) { var searchString = dataTableParam.GetSearchString(); var projects = ProjectManagementService.GetProjects(pageInfo: dataTableParam.ToPageInfo(), searchString: searchString); if (User.IsInRole("lector")) { return(DataTableExtensions.GetResults(projects.Items.Select(model => FromProject(model, PartialViewToString("_ProjectsGridActions", FromProject(model)))).Where(e => e.IsAssigned), dataTableParam, projects.TotalCount)); } return(DataTableExtensions.GetResults(projects.Items.Select(FromProject).Where(e => e.IsAssigned), dataTableParam, projects.TotalCount)); }
public DataTablesResult <ProjectUserListViewModel> GetProjectUsers(DataTablesParam dataTablesParam) { var searchString = dataTablesParam.GetSearchString(); var projectUsers = ProjectManagementService.GetProjectUsers(pageInfo: dataTablesParam.ToPageInfo(), searchString: searchString); var projectId = int.Parse(Request.QueryString["projectId"]); if (User.IsInRole("lector") && ProjectManagementService.GetProject(projectId).CreatorId == WebSecurity.CurrentUserId) { return(DataTableExtensions.GetResults(projectUsers.Items.Select(model => FromProjectUser(model, PartialViewToString("_ProjectUsersGridActions", FromProjectUser(model)))).Where(e => e.ProjectId == projectId && e.UserName != GetProjectCreatorName(projectId)), dataTablesParam, projectUsers.TotalCount)); } return(DataTableExtensions.GetResults(projectUsers.Items.Select(FromProjectUser).Where(e => e.ProjectId == projectId && e.UserName != GetProjectCreatorName(projectId)), dataTablesParam, projectUsers.TotalCount)); }
public void TestReadFlatFile_DataTableNull_Throws() { const string text = @"id,name,created,avg 123,Bob,12/31/2012,3.14159"; SeparatedValueParserOptions options = new SeparatedValueParserOptions() { IsFirstRecordSchema = true }; Stream stream = new MemoryStream(Encoding.Default.GetBytes(text)); DataTable table = null; IParser parser = new SeparatedValueParser(stream, options); DataTableExtensions.ReadFlatFile(table, parser); }
public void GetCondition_WithReturnFalseValue() { //Arrange var expectedValue = Guid.NewGuid().ToString(); var dataTable = DataTableFactory.GetDataTableWithOneColumnAndOneRow(expectedValue); int pageNumber = 2; int pageSize = 2; // Action var actual = DataTableExtensions.GetCondition(dataTable, pageNumber, pageSize); // Assert Assert.IsFalse(actual); }
public void GetPagedResult_WithReturnZeroRows() { //Arrange var expectedValue = Guid.NewGuid().ToString(); var dataTable = DataTableFactory.GetDataTableWithOneColumnAndOneRow(expectedValue); int pageNumber = 2; int pageSize = 2; // Action var actual = DataTableExtensions.GetPagedResult(dataTable, pageNumber, pageSize); // Assert Assert.IsTrue(actual.Rows.Count == 0); }
public DataTable getLiqsHalls() { try { DataTable dt = (DataTable)this.Session[this._nameSessionData]; if (dt == null || dt.Rows.Count == 0) { return(new DataTable()); } return(DataTableExtensions.CopyToDataTable <DataRow>((IEnumerable <DataRow>)EnumerableRowCollectionExtensions.Where <DataRow>(DataTableExtensions.AsEnumerable(dt), (Func <DataRow, bool>)(x => !DataRowExtensions.Field <string>(x, "lhv_status").Equals("PM"))))); } catch { return(new DataTable()); } }
/// <summary> /// 使用調整單的品號去,找退料檔裡面出現幾次,並產生免安裝執行檔 /// </summary> private void btnCheckExcelData() { if (ddlExcelSheets.Items.Count == 0) { MessageBox.Show("Please Choose Excel File", "Info"); } if (ddlExcelSheets.Items.Count > 0) { ImportFileService importFileService = new ImportFileService(); ExportFileService exportFileService = new ExportFileService(); try { //調整單 DataTable dtRevision = new DataTable(); dtRevision = importFileService.ExcelToDataTable(txtFilePath.Text, 0, 104); //退料單 DataTable dtReturn = new DataTable(); dtReturn = importFileService.ExcelToDataTable(txtFilePath.Text, 1, 5); var result = DataTableExtensions.ToList <Material>(dtReturn).ToList(); List <Material> returnList = result as List <Material>; //Compare excel data DataTable dt = importFileService.CompareRevisionAndReturn(dtRevision, returnList); ResponseMessage response = exportFileService.DataTableToExcelFile(dt, txtFilePath.Text); if (response.Success) { MessageBox.Show("檢查成功,已將Excel匯出到選擇檔案的路徑", "Info"); } else { MessageBox.Show(response.ErrorMsg, "error"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "error"); } } }
public PagingModel GetReceipts(string zhang, string qu, DateTime da, int page = 1, int limit = 10) { DataTable dt = bll.GetReceipts(zhang, qu, da); string json = JsonConvert.SerializeObject(dt); List <ReceiptsModel> list = JsonConvert.DeserializeObject <List <ReceiptsModel> >(json); int n = list.Count; list = list.Skip(limit * (page - 1)).Take(limit).ToList(); DataTable dts = DataTableExtensions.ToDataTable(list, c => new object[] { list }); PagingModel pag = new PagingModel() { code = 0, msg = "", count = n, data = dts }; return(pag); }
static void Main() { //Variable definition var connectionString = "Data Source=172.16.0.6;Initial Catalog=AO2017;Persist Security Info=True;User ID=sa;Password=BQ3$ervice"; var generalFilePath = @"\\canydocs\archives\Users\BVI Reports\Team Billing Reports\"; List <string> teamList = new List <string>(); teamList.Add("Team Red"); teamList.Add("Team Blue"); teamList.Add("Team Green"); teamList.Add("Team Silver"); teamList.Add("Black Team"); teamList.Add("Team Platinum"); teamList.Add("Team Magenta"); teamList.Add("Team White"); teamList.Add("Misc"); foreach (var team in teamList) { var reportName = "BVA - " + team; var fileName = reportName.Replace(" ", "_") + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".csv"; var filePath = generalFilePath + team + @"\" + fileName; var selectStatement = @"EXECUTE dbo.Budget_vs_Actual_Report '" + team + "'"; //Execution start //Instansiate a new SqlActions object var sqlActions = new SqlActions(connectionString); //Execute the selectStatement and store the results in a list of strings var dt = sqlActions.SelectToDataTable(selectStatement); //Create file to write to File.Create(filePath).Dispose(); //Instansiate a new DataTableExtensions object var dataTableExtensions = new DataTableExtensions(); //Write the data from the data table to the file dataTableExtensions.WriteToCsvFile(dt, filePath); } }
public DxLineplot(DxLineplotSettings settings, DataTable mydt) //, string xvar, string yvar, string titleinput, string colorsby) { _settings = settings; Color col = _settings.color(0); _markers = new DxMarkerKinds(); //Need to stack the data because variable is within the plot if ((_settings.xaxisvar == "variable" || _settings.colorvar == "variable") & _settings.xaxisvar != _settings.colorvar) { List <string> idvars = new List <string>() { "id" }; if (_settings.xaxisvar != "none" & _settings.xaxisvar != "variable" & !idvars.Contains(_settings.xaxisvar)) { idvars.Add(_settings.xaxisvar); } if (_settings.colorvar != "none" & _settings.colorvar != "variable" & !idvars.Contains(_settings.colorvar)) { idvars.Add(_settings.colorvar); } if (_settings.panelvar != "none" & _settings.panelvar != "variable" & !idvars.Contains(_settings.panelvar)) { idvars.Add(_settings.panelvar); } DataTable dt_stacked = DataTableExtensions.StackData(mydt, idvars, _settings.numvars); _settings.seriesby = "id"; //_settings.xaxisvar = "variable"; _settings.yaxisvar = "value"; CreateLineplot(dt_stacked); } else { CreateLineplot(mydt); } }
public DataTable getLigsPick() { DataTable dt1; try { DataTable dt = (DataTable)this.Session[this._nameSessionData]; if (dt == null || dt.Rows.Count == 0) { return(new DataTable()); } dt1 = DataTableExtensions.CopyToDataTable <DataRow>((IEnumerable <DataRow>)EnumerableRowCollectionExtensions.Where <DataRow>(DataTableExtensions.AsEnumerable(dt), (Func <DataRow, bool>)(x => DataRowExtensions.Field <string>(x, "liq_estid").Equals("PM") || DataRowExtensions.Field <string>(x, "liq_estid").Equals("PF")))); return(dt1); //return DataTableExtensions.CopyToDataTable<DataRow>((IEnumerable<DataRow>)EnumerableRowCollectionExtensions.Where<DataRow>(DataTableExtensions.AsEnumerable(dt), (Func<DataRow, bool>)(x => DataRowExtensions.Field<string>(x, "liq_estid").Equals("PF")))); } catch { return(new DataTable()); } }
public DataTablesResult <BugListViewModel> GetAllBugs(DataTablesParam dataTableParam) { var searchString = dataTableParam.GetSearchString(); var bugs = BugManagementService.GetAllBugs(pageInfo: dataTableParam.ToPageInfo(), searchString: searchString); if (User.IsInRole("lector")) { if (_currentProjectId != 0) { return(DataTableExtensions.GetResults(bugs.Items.Select(model => FromBug(model, PartialViewToString("_BugsGridActions", FromBug(model)))).Where(e => e.ProjectId == _currentProjectId), dataTableParam, bugs.TotalCount)); } return(DataTableExtensions.GetResults(bugs.Items.Select(model => FromBug(model, PartialViewToString("_BugsGridActions", FromBug(model)))).Where(e => e.IsAssigned), dataTableParam, bugs.TotalCount)); } if (_currentProjectId != 0) { return(DataTableExtensions.GetResults(bugs.Items.Select(FromBug).Where(e => e.ProjectId == _currentProjectId), dataTableParam, bugs.TotalCount)); } return(DataTableExtensions.GetResults(bugs.Items.Select(FromBug).Where(e => e.IsAssigned), dataTableParam, bugs.TotalCount)); }