/// <summary> /// Demo regime /// </summary> private void TerminalRefreshDemo() { Config cConf = new Config(); arrInfoLine = new ArrayList(); String strLine; String[] arrLine; string DirPath = cConf.getappSettings(Config.SettingField.DataSyncDir.ToString()); CFile FileDemo = new CFile(DirPath+"/demo_act.txt"); CFile FileDemoNew = new CFile(DirPath + "/demo_act.txt"); arrLineDemo = FileDemo.Read(); /* Прогресс */ statusProgress.Visible = true; statusProgress.Value = 0; TermFile cFileObj = new TermFile(); int c_count = arrLineDemo.Count; int c_Rand; Random fixRand = new Random(); c_Rand = fixRand.Next(1, 7); for (int i = 0; i < c_count; i++) { Thread.Sleep(1000); statusProgress.Step = (80 / c_count); statusProgress.PerformStep(); //arrInfoLine.Add(arrLineDemo[i]); strLine = arrLineDemo[i]; //strLine = strLine.Replace(".", ","); arrLine = strLine.Split(';'); strLine = ""; double dd; int idd; int l_count = arrLine.Length; for (int a = 0; a < l_count; a++) { if (a == 2) { arrLine[a] = DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second; } //if (a == 13 || a==14 ||a==15) if (a >10 && Char.IsDigit(Convert.ToChar(arrLine[a].Substring(0,1)))) { try { dd = Convert.ToDouble(arrLine[a]); dd = dd + (dd / 100 * 0.5); arrLine[a] = dd.ToString(); } catch { idd = Convert.ToInt16(arrLine[a]); idd = idd + (idd / 100 * l_count); arrLine[a] = idd.ToString(); } } } strLine = String.Join(";", arrLine); strLine = strLine.Replace(",", "."); if (i <= c_Rand-1) { cFileObj.AddLine(strLine); } FileDemoNew.AddLine(strLine); } cFileObj.Write(); FileDemoNew.Write(false); _tCount++; LogFileSave(arrInfoLine); statusProgress.Visible = false; lblTCount.Text = _tCount.ToString(); lblError.Text = _tError.ToString(); }
private void ShowProp() { string strFilePath; String strLine; String[] arrLine; DataTable DT = new DataTable("Table"); DT.Columns.Add("c_prop", System.Type.GetType("System.String")); DT.Columns.Add("c_value", System.Type.GetType("System.String")); DataRow NewRows; ArrayList arrProtocol; String[] strFiles; String[] strLines; strFilePath = cConfig.getappSettings(Config.SettingField.DataSyncDir.ToString()); strFiles = Directory.GetFiles(strFilePath, "act_*.txt"); int c_count; c_count = strFiles.GetLength(0); if (c_count >0) { Array.Sort(strFiles); foreach (String fname in strFiles) { strFilePath = fname; } CFile FileData = new CFile(strFilePath); List<String> arrLines = FileData.Read(); //strLines = File.ReadAllLines(strFilePath); for (int i = 0; i < arrLines.Count; i++) { strLine = arrLines[i]; //strLine = strLine.Replace(".", ","); arrLine = strLine.Split(';'); if (arrLine[0].ToString() == _arrListIndex[lstProp.SelectedIndex].ToString()) { arrProtocol = cConfig.getObjectProtocol(lstProp.SelectedItem.ToString(), Convert.ToInt16(arrLine[1].ToString())); int mapIndex = 3; foreach (Config.SysObjectProtocolMap Protocol in arrProtocol) { NewRows = DT.NewRow(); NewRows["c_prop"] = Protocol.Description; NewRows["c_value"] = arrLine[mapIndex + Protocol.Index]; DT.Rows.Add(NewRows); } grdProp.DataSource = DT; grdProp.Columns["c_prop"].HeaderText = "Параметр"; grdProp.Columns["c_value"].HeaderText = "Значение"; grdProp.Columns["c_prop"].Width = 200; } strLine = ""; } } }