public DataBase(SqlConnection conn, DataRow dataRow) { Name = DataTableTools.GetValue <string>(dataRow["name"]); ID = DataTableTools.GetValue <int>(dataRow["database_id"]); GetTables(conn); }
public static DataTable AnalysisReturnsDataTable(int iter, FileInfo fiSegmentOfSourceFile, Dictionary <string, string> configDict, DirectoryInfo diOutputDir) { string opFileName = "temp.wav"; //###################################################################### var results = Analysis(fiSegmentOfSourceFile, configDict, diOutputDir, opFileName, TimeSpan.Zero); //###################################################################### if (results == null) { return(null); } var sonogram = results.Item1; var hits = results.Item2; var scores = results.Item3; var predictedEvents = results.Item4; var recordingTimeSpan = results.Item5; double segmentDuration = double.Parse(configDict[key_SEGMENT_DURATION]); double segmentStartMinute = segmentDuration * iter; DataTable dataTable = null; if ((predictedEvents == null) || (predictedEvents.Count == 0)) { LoggedConsole.WriteLine("############ WARNING: No acoustic events were returned from the analysis."); } else { string analysisName = configDict[key_ANALYSIS_NAME]; string fName = Path.GetFileNameWithoutExtension(fiSegmentOfSourceFile.Name); foreach (AcousticEvent ev in predictedEvents) { ev.FileName = fName; //ev.Name = analysisName; //name is the periodicity ev.SegmentDurationSeconds = recordingTimeSpan.TotalSeconds; } //write events to a data table to return. dataTable = WriteEvents2DataTable(segmentStartMinute, recordingTimeSpan, predictedEvents); string sortString = key_START_ABS + " ASC"; dataTable = DataTableTools.SortTable(dataTable, sortString); //sort by start time before returning } //draw images of sonograms int DRAW_SONOGRAMS = int.Parse(configDict[key_DRAW_SONOGRAMS]); // options to draw sonogram bool saveSonogram = false; if ((DRAW_SONOGRAMS == 2) || ((DRAW_SONOGRAMS == 1) && (predictedEvents.Count > 0))) { saveSonogram = true; } if (saveSonogram) { double eventThreshold = 0.1; string imagePath = Path.Combine(diOutputDir.FullName, Path.GetFileNameWithoutExtension(fiSegmentOfSourceFile.FullName) + "_" + (int)segmentStartMinute + "min.png"); Image image = DrawSonogram(sonogram, hits, scores, predictedEvents, eventThreshold); image.Save(imagePath, ImageFormat.Png); } return(dataTable); }
public Table(SqlConnection conn, DataRow row, DataBase dataBase, Dictionary <string, List <int> > primaryKeys, Dictionary <string, List <int> > uniqueColumns) { FullName = DataTableTools.GetValue <string>($"{row["full_name"]}"); Name = DataTableTools.GetValue <string>(row["name"]); ID = DataTableTools.GetValue <int>(row["id"]); GetColumns(conn); Database = dataBase; if (primaryKeys.ContainsKey(FullName)) { foreach (int primaryKeyId in primaryKeys[FullName]) { Columns[primaryKeyId].IsPrimaryKey = true; } } if (uniqueColumns.ContainsKey(FullName)) { foreach (int uniqueColumnId in uniqueColumns[FullName]) { Columns[uniqueColumnId].IsUnique = true; } } }
/// <summary> /// 加载订单内容数据 /// </summary> private void LoadDataSourceDetails() { try { int iManualID = 0; string strBooksNo = string.Empty; if (this.myDataGridViewHead.CurrentRowNew != null) { iManualID = (int)this.myDataGridViewHead.Rows[this.myDataGridViewHead.CurrentRowNew.Index].Cells["手册id"].Value; } IDataAccess dataAccess = DataAccessFactory.CreateDataAccess(DataAccessEnum.DataAccessName.DataAccessName_Uniquegrade); dataAccess.Open(); string strSQL = string.Format("exec 出口成品表录入查询 {0}" + Environment.NewLine, iManualID); strSQL += string.Format("exec 进口料件表录入查询 {0}", iManualID); DataSet ds = dataAccess.GetDataSet(strSQL, null); dataAccess.Close(); DataTable dtDetails = ds.Tables[0]; DataTable dtDetails2 = ds.Tables[1]; DataTableTools.AddEmptyRow(dtDetails); DataTableTools.AddEmptyRow(dtDetails2); this.myDataGridViewDetails.DataSource = dtDetails; this.myDataGridViewDetailsInput.DataSource = dtDetails2; } catch (Exception ex) { SysMessage.ErrorMsg(string.Format("加载【InvoiceOut】出错,错误信息如下:{0}{1}", Environment.NewLine, ex.Message)); } }
/// <summary> /// Converts a DataTable of events to a datatable where one row = one minute of indices /// </summary> /// <param name="dt"></param> /// <returns></returns> public DataTable ConvertEvents2Indices(DataTable dt, TimeSpan unitTime, TimeSpan sourceDuration, double scoreThreshold) { double units = sourceDuration.TotalSeconds / unitTime.TotalSeconds; int unitCount = (int)(units / 1); //get whole minutes if (units % 1 > 0.0) { unitCount += 1; //add fractional minute } int[] eventsPerUnitTime = new int[unitCount]; //to store event counts int[] bigEvsPerUnitTime = new int[unitCount]; //to store counts of high scoring events foreach (DataRow ev in dt.Rows) { double eventStart = (double)ev[AnalysisKeys.EventStartSec]; double eventScore = (double)ev[AnalysisKeys.EventNormscore]; int timeUnit = (int)(eventStart / unitTime.TotalSeconds); eventsPerUnitTime[timeUnit]++; if (eventScore > scoreThreshold) { bigEvsPerUnitTime[timeUnit]++; } } string[] headers = { AnalysisKeys.KeyStartMinute, AnalysisKeys.EventTotal, ("#Ev>" + scoreThreshold) }; Type[] types = { typeof(int), typeof(int), typeof(int) }; var newtable = DataTableTools.CreateTable(headers, types); for (int i = 0; i < eventsPerUnitTime.Length; i++) { int unitID = (int)(i * unitTime.TotalMinutes); newtable.Rows.Add(unitID, eventsPerUnitTime[i], bigEvsPerUnitTime[i]); } return(newtable); }
/// <summary> /// 加载订单内容数据 /// </summary> private void LoadDataSourceDetails() { try { int iOrderID = 0; string strBooksNo = string.Empty; if (this.myDataGridViewHead.CurrentRowNew != null) { if (this.myDataGridViewHead.Rows[this.myDataGridViewHead.CurrentRowNew.Index].Cells["Pid"].Value != DBNull.Value) { iOrderID = (int)this.myDataGridViewHead.Rows[this.myDataGridViewHead.CurrentRowNew.Index].Cells["Pid"].Value; } } IDataAccess dataAccess = DataAccessFactory.CreateDataAccess(DataAccessEnum.DataAccessName.DataAccessName_Uniquegrade); dataAccess.Open(); string strSQL = string.Format("exec 出口装箱单录入查询 {0}", iOrderID); DataTable dtDetails = dataAccess.GetTable(strSQL, null); dataAccess.Close(); DataTableTools.AddEmptyRow(dtDetails); this.myDataGridViewDetails.DataSource = dtDetails; } catch (Exception ex) { SysMessage.ErrorMsg(string.Format("加载【PACKING LIST】出错,错误信息如下:{0}{1}", Environment.NewLine, ex.Message)); } }
private void FormMaterialsOutQueryList_CheckQueryList_Load(object sender, EventArgs e) { string strSQL = string.Empty; if (InOutvalue == 1) { strSQL = string.Format("报关进口料件数量转换统计 @id={0},@电子帐册号='{1}',@类别={2}", InId, ManualCode, passvalue); } else { strSQL = string.Format("报关出口料件数量转换统计 @id={0},@电子帐册号='{1}',@类别={2}", InId, ManualCode, passvalue); } IDataAccess dataAccess = DataAccessFactory.CreateDataAccess(DataAccessEnum.DataAccessName.DataAccessName_Manufacture); dataAccess.Open(); DataTable dtData = dataAccess.GetTable(strSQL, null); dataAccess.Close(); DataTableTools.AddEmptyRow(dtData); this.myDataGridView1.DataSource = dtData; foreach (DataGridViewTextBoxColumn textBoxColumn in this.myDataGridView1.Columns) { textBoxColumn.ContextMenuStrip = this.myContextMenuStripCell1; } }
/// <summary> /// 加载订单内容数据 /// </summary> private void LoadDataSourceDetails() { try { int iOrderID = 0; string strBooksNo = string.Empty; if (this.myDataGridViewHead.CurrentRowNew != null) { if (this.myDataGridViewHead.Rows[this.myDataGridViewHead.CurrentRowNew.Index].Cells["料件出库表id"].Value != DBNull.Value) { iOrderID = (int)this.myDataGridViewHead.Rows[this.myDataGridViewHead.CurrentRowNew.Index].Cells["料件出库表id"].Value; strBooksNo = this.myDataGridViewHead.CurrentRowNew.Cells["电子帐册号"].Value.ToString(); } } IDataAccess dataAccess = DataAccessFactory.CreateDataAccess(DataAccessEnum.DataAccessName.DataAccessName_Manufacture); dataAccess.Open(); //string strSQL = string.Format("select * from 报关预先订单明细表 where 订单id={0}", iOrderID); string strSQL = string.Format("exec 进口料件出库修改查询 {0},{1}", iOrderID, StringTools.SqlQ(strBooksNo)); DataTable dtDetails = dataAccess.GetTable(strSQL, null); dataAccess.Close(); DataTableTools.AddEmptyRow(dtDetails); this.myDataGridViewDetails.DataSource = dtDetails; } catch (Exception ex) { SysMessage.ErrorMsg(string.Format("加载【出库单明细】出错,错误信息如下:{0}{1}", Environment.NewLine, ex.Message)); } }
/// <summary> /// 加载表头数据 /// </summary> private void LoadDataSourceHead() { try { IDataAccess dataAccess = DataAccessFactory.CreateDataAccess(DataAccessEnum.DataAccessName.DataAccessName_Manufacture); dataAccess.Open(); string strSQL = string.Format("select * FROM 归并后料件清单 where 电子帐册号={0} ORDER BY 序号", StringTools.SqlQ(gstrManualNo)); DataTable dtHead = dataAccess.GetTable(strSQL, null); dataAccess.Close(); bTriggerGridViewHead_SelectionChanged = false; DataTableTools.AddEmptyRow(dtHead); this.myDataGridViewHead.DataSource = dtHead; bTriggerGridViewHead_SelectionChanged = true; //if (this.dataGridViewHead.RowCount > 0) //{ // this.dataGridViewHead.CurrentCell = this.dataGridViewHead.Rows[0].Cells["电子帐册号"]; // this.dataGridViewHead.Rows[0].Selected = true; //} this.myDataGridViewHead_SelectionChanged(null, null); } catch (Exception ex) { SysMessage.ErrorMsg(string.Format("加载数据出错LoadDataSourceHead,错误信息如下:{0}{1}", Environment.NewLine, ex.Message)); } }
} //DrawSonogram() public static DataTable WriteEvents2DataTable(double segmentStartMinute, TimeSpan tsSegmentDuration, List <AcousticEvent> predictedEvents) { if ((predictedEvents == null) || (predictedEvents.Count == 0)) { return(null); } GetTableHeadersAndTypesForEvents(); var dataTable = DataTableTools.CreateTable(EVENT_HEADERS, EVENT_COL_TYPES); //int count = 0; foreach (var ev in predictedEvents) { int segmentStartSec = (int)(segmentStartMinute * 60); int eventStartAbsoluteSec = (int)(segmentStartSec + ev.TimeStart); int eventStartMin = eventStartAbsoluteSec / 60; int eventStartSec = eventStartAbsoluteSec % 60; string segmentDuration = DataTools.Time_ConvertSecs2Mins(tsSegmentDuration.TotalSeconds); DataRow row = dataTable.NewRow(); row[key_START_ABS] = eventStartAbsoluteSec; //EvStartAbsolute - from start of source ifle row[key_START_MIN] = eventStartMin; //EvStartMin row[key_START_SEC] = eventStartSec; //EvStartSec row[key_SEGMENT_DURATION] = tsSegmentDuration.TotalSeconds; //segment Duration in seconds row[key_CALL_DENSITY] = predictedEvents.Count; //Density row[key_CALL_SCORE] = ev.Score; //Score dataTable.Rows.Add(row); // count++; } return(dataTable); }
public static DataTable MergeAdjacentPredictions(DataTable dt) { //DataTable newTable = DataTableTools.CreateTable(dt); string sortString = AnalysisKeys.EventStartAbs + " ASC"; dt = DataTableTools.SortTable(dt, sortString); int rowCount = dt.Rows.Count; // work from end to beginning for (int i = rowCount - 2; i >= 0; i--) { DataRow row1 = dt.Rows[i]; DataRow row2 = dt.Rows[i + 1]; string name1 = (string)row1[AnalysisKeys.EventName]; string name2 = (string)row2[AnalysisKeys.EventName]; string predictedSex1; if (name1.EndsWith("(m)")) { predictedSex1 = "M"; } else if (name1.EndsWith("(f)")) { predictedSex1 = "F"; } else { predictedSex1 = null; } string predictedSex2; if (name2.EndsWith("(m)")) { predictedSex2 = "M"; } else if (name2.EndsWith("(f)")) { predictedSex2 = "F"; } else { predictedSex2 = null; } double start1 = (double)row1[AnalysisKeys.EventStartAbs]; double start2 = (double)row2[AnalysisKeys.EventStartAbs]; if (start2 - start1 < 15.0 && predictedSex1 == predictedSex2) { dt.Rows.Remove(row2); } } return(dt); }
public DataTable GetData() { List <string[]> list = new List <string[]>(); var siteNamesList = _localWebSites.GetLocalWebsitesName(); foreach (string name in siteNamesList) { list.Add(new string[] { name, "" }); } return(DataTableTools.ConvertListToDataTable(list)); }
public static void Execute(Arguments arguments) { if (arguments == null) { arguments = Dev(); } string opFName = ANALYSIS_NAME + ".txt"; FileInfo opPath = arguments.Output.CombineFile(opFName); string audioFileName = arguments.Source.Name; Log.Verbosity = 1; string title = "# FOR DETECTION OF ACOUSTIC EVENTS HAVING A GRID OR GRATING STRUCTURE"; string date = "# DATE AND TIME: " + DateTime.Now; LoggedConsole.WriteLine(title); LoggedConsole.WriteLine(date); LoggedConsole.WriteLine("# Output folder: " + arguments.Output); LoggedConsole.WriteLine("# Recording file: " + arguments.Source.Name); FileTools.WriteTextFile(opPath.FullName, date + "\n# Recording file: " + audioFileName); //READ PARAMETER VALUES FROM INI FILE var configuration = new ConfigDictionary(arguments.Config); Dictionary <string, string> configDict = configuration.GetTable(); Dictionary <string, string> .KeyCollection keys = configDict.Keys; int startMinute = 5; //dummy value var fiSegmentOfSourceFile = arguments.Source; var diOutputDir = arguments.Output; //############################################################################################################################################# DataTable dt = AnalysisReturnsDataTable(startMinute, fiSegmentOfSourceFile, configDict, diOutputDir); //############################################################################################################################################# if (dt == null) { Log.WriteLine("\n\n\n##############################\n WARNING! No events returned."); } else { //LoggedConsole.WriteLine("\tRecording Duration: {0:f2}seconds", recordingTimeSpan.TotalSeconds); LoggedConsole.WriteLine("# Event count for minute {0} = {1}", startMinute, dt.Rows.Count); DataTableTools.WriteTable2Console(dt); } LoggedConsole.WriteLine("# Finished recording:- " + arguments.Source.FullName); }
} //DrawSonogram() public static DataTable WriteEvents2DataTable(List <AcousticEvent> predictedEvents) { if (predictedEvents == null) { return(null); } string[] headers = { AudioAnalysisTools.Keys.EVENT_COUNT, AudioAnalysisTools.Keys.EVENT_START_MIN, AudioAnalysisTools.Keys.EVENT_START_SEC, AudioAnalysisTools.Keys.EVENT_START_ABS, AudioAnalysisTools.Keys.SEGMENT_TIMESPAN, AudioAnalysisTools.Keys.EVENT_DURATION, AudioAnalysisTools.Keys.EVENT_INTENSITY, AudioAnalysisTools.Keys.EVENT_NAME, LSKiwiHelper.key_BANDWIDTH_SCORE, LSKiwiHelper.key_DELTA_SCORE, LSKiwiHelper.key_PEAKS_SNR_SCORE, LSKiwiHelper.key_PEAKS_STD_SCORE, AudioAnalysisTools.Keys.EVENT_SCORE, AudioAnalysisTools.Keys.EVENT_NORMSCORE }; // 1 2 3 4 5 6 7 8 Type[] types = { typeof(double), typeof(double), typeof(double), typeof(double), typeof(double), typeof(double), typeof(double), typeof(string), typeof(double), typeof(double), typeof(double), typeof(double), typeof(double), typeof(double) }; var dataTable = DataTableTools.CreateTable(headers, types); if (predictedEvents.Count == 0) { return(dataTable); } foreach (var ev in predictedEvents) { DataRow row = dataTable.NewRow(); row[AudioAnalysisTools.Keys.EVENT_START_ABS] = (double)ev.TimeStart; //Set now - will overwrite later row[AudioAnalysisTools.Keys.EVENT_START_SEC] = (double)ev.TimeStart; //EvStartSec row[AudioAnalysisTools.Keys.EVENT_DURATION] = (double)ev.Duration; //duratio in seconds row[AudioAnalysisTools.Keys.EVENT_INTENSITY] = (double)ev.kiwi_intensityScore; // row[AudioAnalysisTools.Keys.EVENT_NAME] = (string)ev.Name; // row[LSKiwiHelper.key_BANDWIDTH_SCORE] = (double)ev.kiwi_bandWidthScore; row[LSKiwiHelper.key_DELTA_SCORE] = (double)ev.kiwi_deltaPeriodScore; row[LSKiwiHelper.key_PEAKS_SNR_SCORE] = (double)ev.kiwi_snrScore; row[LSKiwiHelper.key_PEAKS_STD_SCORE] = (double)ev.kiwi_sdPeakScore; row[AudioAnalysisTools.Keys.EVENT_NORMSCORE] = (double)ev.ScoreNormalised; row[AudioAnalysisTools.Keys.EVENT_SCORE] = (double)ev.Score; //Score dataTable.Rows.Add(row); } return(dataTable); }
private void FormMaterialSheet_Load(object sender, EventArgs e) { StringBuilder strBuilder = new StringBuilder(); strBuilder.AppendLine(string.Format(@"select ltrim(case when PATINDEX('%-%',项号)=0 then 项号 else SUBSTRING(项号,1,PATINDEX('%-%',项号)-1) end) as 项号,left(ltrim(料号),3) as 料号, max(商品编码) as 商品编码, max(商品名称) as 商品名称, max(商品规格) as 商品规格, 单位, rtrim(str(sum(数量),10,5)) as 数量 FROM 装箱单料件明细表 where left(ltrim(料号),1)='A' and idv='{0}' group by ltrim(case when PATINDEX('%-%',项号)=0 then 项号 else SUBSTRING(项号,1,PATINDEX('%-%',项号)-1) end) , left(ltrim(料号),3), 单位 ORDER BY 项号", idvalue)); strBuilder.AppendLine(string.Format(@"select ltrim(case when PATINDEX('%-%',项号)=0 then 项号 else SUBSTRING(项号,1,PATINDEX('%-%',项号)-1) end) as 项号, left(ltrim(料号),5) as 料号, max(商品编码) as 商品编码, max(商品名称) as 商品名称, max(商品规格) as 商品规格, 单位, rtrim(str(sum(数量),10,5)) as 数量 FROM 装箱单料件明细表 where left(ltrim(料号),1)='A' and idv='{0}' group by ltrim(case when PATINDEX('%-%',项号)=0 then 项号 else SUBSTRING(项号,1,PATINDEX('%-%',项号)-1) end) , left(ltrim(料号),5),单位 ORDER BY 项号", idvalue)); strBuilder.AppendLine(string.Format(@"select ltrim(case when PATINDEX('%-%',项号)=0 then 项号 else SUBSTRING(项号,1,PATINDEX('%-%',项号)-1) end) as 项号, 料件编号, 料号, 料件名, max(商品编码) as 商品编码, max(商品名称) as 商品名称, max(商品规格) as 商品规格, 单位, rtrim(str(sum(数量),10,5)) as 数量 FROM 装箱单料件明细表 where left(ltrim(料号),1)='A' and idv='{0}' group by ltrim(case when PATINDEX('%-%',项号)=0 then 项号 else SUBSTRING(项号,1,PATINDEX('%-%',项号)-1) end) , 料件编号, 料号, 料件名, 单位 ORDER BY 项号", idvalue)); strBuilder.AppendLine(string.Format("DELETE FROM 装箱单料件明细表 where idv='{0}'", idvalue)); IDataAccess dataAccess = DataAccessFactory.CreateDataAccess(DataAccessEnum.DataAccessName.DataAccessName_Manufacture); dataAccess.Open(); DataSet ds = dataAccess.GetDataSet(strBuilder.ToString(), null); dataAccess.Close(); DataTable dt1 = ds.Tables[0]; DataTableTools.AddEmptyRow(dt1); DataTable dt2 = ds.Tables[1]; DataTableTools.AddEmptyRow(dt2); DataTable dt3 = ds.Tables[2]; DataTableTools.AddEmptyRow(dt3); this.myDataGridView1.DataSource = dt1; this.myDataGridView2.DataSource = dt2; this.myDataGridView3.DataSource = dt3; foreach (DataGridViewTextBoxColumn textBoxColumn in this.myDataGridView1.Columns) { textBoxColumn.ContextMenuStrip = this.myContextMenuStripCell1; } foreach (DataGridViewTextBoxColumn textBoxColumn in this.myDataGridView2.Columns) { textBoxColumn.ContextMenuStrip = this.myContextMenuStripCell2; } foreach (DataGridViewTextBoxColumn textBoxColumn in this.myDataGridView3.Columns) { textBoxColumn.ContextMenuStrip = this.myContextMenuStripCell3; } }
private void LoadDataSource() { IDataAccess dataAccess = DataAccessFactory.CreateDataAccess(DataAccessEnum.DataAccessName.DataAccessName_Uniquegrade); dataAccess.Open(); dtData = dataAccess.GetTable(string.Format("出口料件统计 {0}", mstrFilterString), null); dataAccess.Close(); if (!mstrFilterString.Contains("类别")) { this.myDataGridViewHead.Columns["成品名称及商编"].Visible = false; } DataTableTools.AddEmptyRow(dtData); this.myDataGridViewHead.DataSource = dtData; setTool1Enabled(); }
/// <summary> /// 加载订单内容数据 /// </summary> private void LoadDataSourceDetails() { //bool bShow = false; //if (formBaseLoading == null) //{ // formBaseLoading = new FormBaseLoading(); // bShow = true; // formBaseLoading.strLoadText =string.Format("加载【{0}】数据,请稍等。。。。。。", this.tabPage1.Text); // formBaseLoading.Show(); // formBaseLoading.Refresh(); //} try { int iOrderID = 0; if (this.myDataGridViewHead.CurrentRowNew != null && this.myDataGridViewHead.CurrentRowNew.Index >= 0) { if (this.myDataGridViewHead.Rows[this.myDataGridViewHead.CurrentRowNew.Index].Cells["归并后料件id"].Value != DBNull.Value) { iOrderID = (int)this.myDataGridViewHead.Rows[this.myDataGridViewHead.CurrentRowNew.Index].Cells["归并后料件id"].Value; } } IDataAccess dataAccess = DataAccessFactory.CreateDataAccess(DataAccessEnum.DataAccessName.DataAccessName_Manufacture); dataAccess.Open(); string strSQL = string.Format("exec 商品归并表录入查询 {0}", iOrderID); DataTable dtDetails = dataAccess.GetTable(strSQL, null); dataAccess.Close(); DataTableTools.AddEmptyRow(dtDetails); bTriggerGridViewDetails_SelectionChanged = false; this.myDataGridViewDetails.DataSource = dtDetails; bTriggerGridViewDetails_SelectionChanged = true; this.myDataGridViewDetails_SelectionChanged(null, null); } catch (Exception ex) { SysMessage.ErrorMsg(string.Format("加载数据出错LoadDataSourceDetails,错误信息如下:{0}{1}", Environment.NewLine, ex.Message)); } //finally //{ // if (bShow && formBaseLoading != null) // { // formBaseLoading.Close(); // formBaseLoading.Dispose(); // formBaseLoading = null; // } //} }
/// <summary> /// 加载订单内容数据 /// </summary> private void LoadDataSourceDetails() { //bool bShow = false; //if (formBaseLoading == null) //{ // formBaseLoading = new FormBaseLoading(); // bShow = true; // formBaseLoading.strLoadText =string.Format("加载【{0}】数据,请稍等。。。。。。", this.tabPage1.Text); // formBaseLoading.Show(); // formBaseLoading.Refresh(); //} try { int iOrderID = 0; string str手册编号 = string.Empty; if (this.dataGridViewHead.CurrentRowNew.Index >= 0) { if (this.dataGridViewHead.Rows[this.dataGridViewHead.CurrentRowNew.Index].Cells["制造通知单id"].Value != DBNull.Value) { iOrderID = (int)this.dataGridViewHead.Rows[this.dataGridViewHead.CurrentRowNew.Index].Cells["制造通知单id"].Value; str手册编号 = this.dataGridViewHead.Rows[this.dataGridViewHead.CurrentRowNew.Index].Cells["手册编号"].Value.ToString(); } } IDataAccess dataAccess = DataAccessFactory.CreateDataAccess(DataAccessEnum.DataAccessName.DataAccessName_Manufacture); dataAccess.Open(); //string strSQL = string.Format("select * from 报关预先订单明细表 where 订单id={0}", iOrderID); string strSQL = string.Format("exec 报关制造通知单录入查询 {0}", iOrderID); DataTable dtDetails = dataAccess.GetTable(strSQL, null); dataAccess.Close(); DataTableTools.AddEmptyRow(dtDetails); this.dataGridViewDetails.DataSource = dtDetails; } catch (Exception ex) { SysMessage.ErrorMsg(string.Format("加载【{0}】数据出错,错误信息如下:{1}{2}", this.tabPage1.Text, Environment.NewLine, ex.Message)); } //finally //{ // if (bShow && formBaseLoading != null) // { // formBaseLoading.Close(); // formBaseLoading.Dispose(); // formBaseLoading = null; // } //} }
/// <summary> /// 加载归并后材料总用量表 /// </summary> private void LoadDataSourceMergeAfterSumCount() { //bool bShow = false; //if (formBaseLoading == null) //{ // formBaseLoading = new FormBaseLoading(); // bShow = true; // formBaseLoading.strLoadText = string.Format("加载【{0}】数据,请稍等。。。。。。", this.tabPage2.Text); // formBaseLoading.Show(); // formBaseLoading.Refresh(); //} try { int iOrderID = 0; string strBooksNo = string.Empty; if (this.dataGridViewHead.CurrentRowNew.Index >= 0) { if (this.dataGridViewHead.Rows[this.dataGridViewHead.CurrentRowNew.Index].Cells["订单id"].Value != DBNull.Value) { iOrderID = (int)this.dataGridViewHead.Rows[this.dataGridViewHead.CurrentRowNew.Index].Cells["订单id"].Value; strBooksNo = this.dataGridViewHead.CurrentRowNew.Cells["手册编号"].Value.ToString(); } } IDataAccess dataAccess = DataAccessFactory.CreateDataAccess(DataAccessEnum.DataAccessName.DataAccessName_Manufacture); dataAccess.Open(); string strSQL = string.Format("exec 预先订单用量明细 {0},{1}", iOrderID, strBooksNo); DataTable dtMergeAfterSumCount = dataAccess.GetTable(strSQL, null); dataAccess.Close(); DataTableTools.AddEmptyRow(dtMergeAfterSumCount); this.dataGridViewMergeAfterSumCount.DataSource = dtMergeAfterSumCount; //this.dataGridViewMergeAfterSumCount.Columns["单耗"].Visible = false; } catch (Exception ex) { SysMessage.ErrorMsg(string.Format("加载【{0}】数据出错,错误信息如下:{1}{2}", this.tabPage2.Text, Environment.NewLine, ex.Message)); } //finally //{ // if (bShow && formBaseLoading != null) // { // formBaseLoading.Close(); // formBaseLoading.Dispose(); // formBaseLoading = null; // } //} }
private void GetRolePermissionlist() { DataSet ds = currentRole.Permissions; if (!DataSetTools.DataSetIsNull(ds)) { rolePermissionlist = new List <int>(); DataTable dt = ds.Tables["Permissions"]; if (!DataTableTools.DataTableIsNull(dt)) { foreach (DataRow dr in dt.Rows) { rolePermissionlist.Add(Convert.ToInt32(dr["PermissionID"])); } } } }
/// <summary> /// 加载表头数据 /// </summary> private void LoadDataSourceHead() { //bool bShow = false; //if (formBaseLoading == null) //{ // formBaseLoading = new FormBaseLoading(); // bShow = true; // formBaseLoading.strLoadText = "加载【预先订单录入】数据,请稍等。。。。。。"; // formBaseLoading.Show(); // formBaseLoading.Refresh(); //} try { IDataAccess dataAccess = DataAccessFactory.CreateDataAccess(DataAccessEnum.DataAccessName.DataAccessName_Manufacture); dataAccess.Open(); string strSQL = @"SELECT 报关制造通知单表.*,case when 进口料件出库表.制造通知单号 is null then '' else '已导' end as 导单 FROM 报关制造通知单表 left outer join 进口料件出库表 on 报关制造通知单表.制造通知单号=进口料件出库表.制造通知单号 " + (gstrWhere.Length > 0 ? " where " : "") + gstrWhere + "ORDER BY 录入日期 DESC"; DataTable dtHead = dataAccess.GetTable(strSQL, null); dataAccess.Close(); bTriggerGridViewHead_SelectionChanged = false; DataTableTools.AddEmptyRow(dtHead); this.dataGridViewHead.DataSource = dtHead; bTriggerGridViewHead_SelectionChanged = true; //if (this.dataGridViewHead.RowCount > 0) //{ // this.dataGridViewHead.CurrentCell = this.dataGridViewHead.Rows[0].Cells["订单号码"]; // this.dataGridViewHead.Rows[0].Selected = true; //} this.dataGridViewHead_SelectionChanged(null, null); } catch (Exception ex) { SysMessage.ErrorMsg(string.Format("加载【制造通知单】数据出错,错误信息如下:{0}{1}", Environment.NewLine, ex.Message)); } //finally //{ // if (bShow && formBaseLoading != null) // { // formBaseLoading.Close(); // formBaseLoading.Dispose(); // formBaseLoading = null; // } //} }
} //DrawSonogram() public static DataTable WriteEvents2DataTable(List <AcousticEvent> predictedEvents) { if (predictedEvents == null) { return(null); } string[] headers = { AnalysisKeys.EventCount, //1 AnalysisKeys.EventStartMin, //2 AnalysisKeys.EventStartSec, //3 AnalysisKeys.EventStartAbs, //4 AnalysisKeys.KeySegmentDuration, //5 AnalysisKeys.EventDuration, //6 //AudioAnalysisTools.Keys.EVENT_INTENSITY, AnalysisKeys.EventName, //7 AnalysisKeys.DominantFrequency, AnalysisKeys.OscillationRate, AnalysisKeys.EventScore, AnalysisKeys.EventNormscore, }; // 1 2 3 4 5 6 7 8 Type[] types = { typeof(int), typeof(double), typeof(double), typeof(double), typeof(double), typeof(double), typeof(string), typeof(double), typeof(double), typeof(double), typeof(double) }; var dataTable = DataTableTools.CreateTable(headers, types); if (predictedEvents.Count == 0) { return(dataTable); } foreach (var ev in predictedEvents) { DataRow row = dataTable.NewRow(); row[AnalysisKeys.EventStartAbs] = (double)ev.TimeStart; //Set now - will overwrite later row[AnalysisKeys.EventStartSec] = (double)ev.TimeStart; //EvStartSec row[AnalysisKeys.EventDuration] = (double)ev.EventDurationSeconds; //duration in seconds //row[AudioAnalysisTools.Keys.EVENT_INTENSITY] = (double)ev.kiwi_intensityScore; // row[AnalysisKeys.EventName] = (string)ev.Name; // row[AnalysisKeys.DominantFrequency] = (double)ev.DominantFreq; row[AnalysisKeys.OscillationRate] = 1 / (double)ev.Periodicity; row[AnalysisKeys.EventScore] = (double)ev.Score; //Score row[AnalysisKeys.EventNormscore] = (double)ev.ScoreNormalised; dataTable.Rows.Add(row); } return(dataTable); }
public Column(DataRow row, Table table) { ID = (int)row["COLUMN_ID"]; Name = row["COLUMN_NAME"] as string; Ordinal = (short)(int)row["ORDINAL_POSITION"]; IsNullable = ((string)row["IS_NULLABLE"]).Equals("YES"); DataType = (SqlDataType)Enum.Parse(typeof(SqlDataType), (string)row["DATA_TYPE"], true); CharacterMaxLength = DataTableTools.GetValue <int>(row["CHARACTER_MAXIMUM_LENGTH"]); Precision = DataTableTools.GetValue <byte>(row["NUMERIC_PRECISION"]); PrecisionRadix = DataTableTools.GetValue <short>(row["NUMERIC_PRECISION_RADIX"]); Scale = DataTableTools.GetValue <int>(row["NUMERIC_SCALE"]); DateTimePrecision = DataTableTools.GetValue <short>(row["DATETIME_PRECISION"]); CharacterSetCatalog = DataTableTools.GetValue <string>(row["CHARACTER_SET_CATALOG"]); CharacterSetSchema = DataTableTools.GetValue <string>(row["CHARACTER_SET_SCHEMA"]); CharacterSetName = DataTableTools.GetValue <string>(row["CHARACTER_SET_NAME"]); Table = table; }
public static void d1() { DataSet ds = new DataSet(); DataTable dt1 = DataTableTools.DataTable32(); DataTable dt2 = DataTableTools.DataTable32("tb2", 2, 2); DataTable dt3 = DataTableTools.DataTable32("tb3", 3, 3); ds.Tables.Add(dt1); ds.Tables.Add(dt2); ds.Tables.Add(dt3); byte[] xml = Serialize.SerializeObject(ds); int ixml = xml.Length; DataSet ds2 = (DataSet)Serialize.DeserializeObject(xml); string json = JsonTools.ToJSON(ds); int ijson = json.Length; DataSet ds3 = JsonTools.FromJSON <DataSet>(json); }
/// <summary> /// 加载表头数据 /// </summary> private void LoadDataSourceHead() { try { IDataAccess dataAccess = DataAccessFactory.CreateDataAccess(DataAccessEnum.DataAccessName.DataAccessName_Manufacture); dataAccess.Open(); string strSQL = "SELECT * from 进口料件出库表 " + (gstrWhere.Length > 0 ? " where " : "") + gstrWhere + " ORDER BY 出库时间 DESC"; DataTable dtHead = dataAccess.GetTable(strSQL, null); dataAccess.Close(); bTriggerGridViewHead_SelectionChanged = false; this.myDataGridViewHead.DataSource = dtHead; DataTableTools.AddEmptyRow(dtHead); bTriggerGridViewHead_SelectionChanged = true; this.myDataGridViewHead_SelectionChanged(null, null); } catch (Exception ex) { SysMessage.ErrorMsg(string.Format("加载【料件出库单】数据出错,错误信息如下:{0}{1}", Environment.NewLine, ex.Message)); } }
/// <summary> /// 加载表头数据 /// </summary> private void LoadDataSourceHead() { try { IDataAccess dataAccess = DataAccessFactory.CreateDataAccess(DataAccessEnum.DataAccessName.DataAccessName_Uniquegrade); dataAccess.Open(); string strSQL = string.Format("select * FROM 手册资料表 {0}{1} ORDER BY 手册编号", gstrWhere.Length > 0 ? " where " : "", gstrWhere); DataTable dtHead = dataAccess.GetTable(strSQL, null); dataAccess.Close(); bTriggerGridViewHead_SelectionChanged = false; this.myDataGridViewHead.DataSource = dtHead; DataTableTools.AddEmptyRow(dtHead); bTriggerGridViewHead_SelectionChanged = true; this.myDataGridViewHead_SelectionChanged(null, null); } catch (Exception ex) { SysMessage.ErrorMsg(string.Format("加载【InvoiceOut】数据出错,错误信息如下:{0}{1}", Environment.NewLine, ex.Message)); } }
public void GetLobbyList() { WebClient wc = new WebClient(); try { string sResponse = wc.DownloadString(Globals.LobbyDataURL); Console.WriteLine(sResponse); ParseJSON(sResponse); } catch (Exception ex) { Console.WriteLine(ex.Message); } DataTable dt = DataTableTools.ConvertToDatatable(Entries); TableEvent te = new TableEvent(dt); MMessageBus.LobbyLoaded(this, te); }
} //DrawSonogram() public static DataTable WriteEvents2DataTable(List <AcousticEvent> predictedEvents) { if (predictedEvents == null) { return(null); } string[] headers = { AnalysisKeys.EventCount, AnalysisKeys.EventStartMin, AnalysisKeys.EventStartSec, AnalysisKeys.EventStartAbs, AnalysisKeys.KeySegmentDuration, AnalysisKeys.EventDuration, AnalysisKeys.EventIntensity, AnalysisKeys.EventName, AnalysisKeys.EventScore, AnalysisKeys.EventNormscore, }; // 1 2 3 4 5 6 7 8 Type[] types = { typeof(int), typeof(double), typeof(double), typeof(double), typeof(double), typeof(double), typeof(double), typeof(string), typeof(double), typeof(double) }; var dataTable = DataTableTools.CreateTable(headers, types); if (predictedEvents.Count == 0) { return(dataTable); } foreach (var ev in predictedEvents) { DataRow row = dataTable.NewRow(); row[AnalysisKeys.EventStartAbs] = (double)ev.TimeStart; //Set now - will overwrite later row[AnalysisKeys.EventStartSec] = (double)ev.TimeStart; //EvStartSec row[AnalysisKeys.EventDuration] = (double)ev.EventDurationSeconds; //duratio in seconds row[AnalysisKeys.EventIntensity] = (double)ev.kiwi_intensityScore; // row[AnalysisKeys.EventName] = (string)ev.Name; // row[AnalysisKeys.EventNormscore] = (double)ev.ScoreNormalised; row[AnalysisKeys.EventScore] = (double)ev.Score; //Score dataTable.Rows.Add(row); } return(dataTable); }
} // ProcessCsvFile() /// <summary> /// takes a data table of indices and normalises column values to values in [0,1]. /// </summary> /// <param name="dt"></param> /// <returns></returns> public static DataTable NormaliseColumnsOfDataTable(DataTable dt) { string[] headers = DataTableTools.GetColumnNames(dt); string[] newHeaders = new string[headers.Length]; List <double[]> newColumns = new List <double[]>(); for (int i = 0; i < headers.Length; i++) { double[] values = DataTableTools.Column2ArrayOfDouble(dt, headers[i]); //get list of values if ((values == null) || (values.Length == 0)) { continue; } double min = 0; double max = 1; if (headers[i].Equals(Keys.AV_AMPLITUDE)) { min = -50; max = -5; newColumns.Add(DataTools.NormaliseInZeroOne(values, min, max)); newHeaders[i] = headers[i] + " (-50..-5dB)"; } else //default is to normalise in [0,1] { newColumns.Add(DataTools.normalise(values)); //normalise all values in [0,1] newHeaders[i] = headers[i]; } } //for loop //convert type int to type double due to normalisation Type[] types = new Type[newHeaders.Length]; for (int i = 0; i < newHeaders.Length; i++) { types[i] = typeof(double); } var processedtable = DataTableTools.CreateTable(newHeaders, types, newColumns); return(processedtable); }
/// <summary> /// 加载资料 /// </summary> public virtual void LoadDataSource() { if (!this.DesignMode) { try { IDataAccess dataAccess = DataAccessFactory.CreateDataAccess(dataAccessName); dataAccess.Open(); dtHead = dataAccess.GetTable(string.Format(gstrSQL, (gstrWhere.Length > 0 ? " where " : "") + gstrWhere), null); dataAccess.Close(); DataTableTools.AddEmptyRow(dtHead); this.myDataGridViewHead.DataSource = dtHead; setTool1Enabled(); } catch (Exception ex) { SysMessage.ErrorMsg(string.Format("加载数据出错LoadDataSource,错误信息如下:{0}{1}", Environment.NewLine, ex.Message)); } } setToolStripStatusLabel2(); }