public void CobolTable_SumAllTableFields() { var table = new CobolTable <MyRow>(); var row1 = new MyRow() { A = 10, B = 2 }; table.AddRow(row1); var row2 = new MyRow() { A = 1000, B = 1000 }; table.AddRow(row2); int tableTotal = 0; foreach (MyRow row in table.Rows) { tableTotal += row.A + row.B; } tableTotal.ShouldBe(2012, "Incorrect tableTotal"); }
/// <summary> /// 从DataTable读取 /// </summary> /// <param name="dt">The dt.</param> public static MyDataTable ReadFromDataTable(DataTable dt) { MyDataTable myDt = new MyDataTable(); foreach (DataColumn Column in dt.Columns) { myDt.AddColumn(Column.ColumnName); } long N = dt.Rows.Count; //计算总量 int counter = 0; //计数器 using (var pb = new ConsoleProgressBar.ProgressBar()) { System.Console.WriteLine("从DataTable读取"); for (int i = 0; i < dt.Rows.Count; i++) { MyRow myRow = myDt.NewRow();//新建一行 for (int j = 0; j < dt.Columns.Count; j++) { string ColumnName = myDt.ColumnNames[j]; myRow[ColumnName] = dt.Rows[i][j]; } myDt.AddRow(myRow); counter++; double progress = counter / (double)N; pb.Progress.Report(progress, "正在加载数据");//更新UI } } return(myDt); }
public MyRow GetNextRow() { if (counter > lastfetched) { if (sdr.Read()) { lastfetched = counter; counter++; currentrow = new MyRow(); currentrow.ID = sdr["ID"].ToString(); currentrow.ParentID = sdr["ParentID"].ToString(); currentrow.TreeKey = sdr["TreeKey"].ToString(); currentrow.Data = sdr["Data"].ToString(); return(currentrow); } else { return(null); } } else if (counter == lastfetched) { counter++; } return(currentrow); }
static void Main() { var list = new List <MyRow>(); FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read); //1. Reading from a binary Excel file ('97-2003 format; *.xls) IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(stream); //... //2. Reading from a OpenXml Excel file (2007 format; *.xlsx) IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream); //5. Data Reader methods while (excelReader.Read()) { var obj = new MyRow { Cell1 = excelReader.GetString(0), Cell2 = excelReader.GetString(1), Cell3 = excelReader.GetString(2), } list.Add(obj); } //6. Free resources (IExcelDataReader is IDisposable) excelReader.Close(); var json = new JavaScriptSerializer().Serialize(list); Console.WriteLine(json); }
public static void Mainly() { MyRow row = new MyRow(); row.Add(new MyElement("Gumby")); row.Add(new MyElement("Pokey")); Console.WriteLine("Initial value"); Console.WriteLine("{0}", row); // write to binary, read it back using (Stream streamWrite = File.Create("MyRow.bin")) { BinaryFormatter binaryWrite = new BinaryFormatter(); binaryWrite.Serialize(streamWrite, row); } MyRow rowBinary = null; using (Stream streamRead = File.OpenRead("MyRow.bin")) { BinaryFormatter binaryRead = new BinaryFormatter(); rowBinary = (MyRow)binaryRead.Deserialize(streamRead); } Console.WriteLine("Values after binary serialization"); Console.WriteLine("{0}", rowBinary); }
public override void GridInsertRow <T>( SourceGrid.Grid grid, T item, Func <T, Color, mySourceGridTools.GridCellController> newCellController = null, int Index = -1) { int index = Index < 0 ? grid.RowsCount : Index; grid.Rows.Insert(index); grid.Rows[index].Tag = item; Type itemType = item.GetType(); SourceGrid.Cells.Controllers.IController CellController = (newCellController == null ? new GridCellController(Color.LightBlue) : CellController = newCellController(item, Color.LightBlue) ); if (itemType == typeof(MyRow)) { MyRow row = item as MyRow; for (int i = 0; i < row.Count; i++) { grid[index, i] = newCell(row, row[Fields[i]], CellController); } return; } { grid[index, 0] = newCell(item, item, CellController); } }
public void CobolTable_WrapsExistingTable_WithSameColumnNamesAsPropertyNames() { var dataTable = new DataTable(); dataTable.Columns.Add("A", typeof(int)); dataTable.Columns.Add("B", typeof(int)); System.Data.DataRow newRow = dataTable.NewRow(); newRow["A"] = 1; newRow["B"] = 2; dataTable.Rows.Add(newRow); var typedTable = new CobolTable <MyRow>(dataTable); typedTable.Rows.Count.ShouldBe(1, "Incorrect number of rows"); // Check first row MyRow row = typedTable.Rows[0]; row.A.ShouldBe(1, "Incorrect rows[0].A"); row.B.ShouldBe(2, "Incorrect rows[0].B"); // Assign new value vie DataRow dataTable.Rows[0]["A"] = 10; typedTable.Rows[0].A.ShouldBe(10, "Incorrect rows[0].A after assignment"); }
public void loadData(DataTable dt) { foreach (DataRow row in dt.Rows) { MyRow myRow = new MyRow(row); Add(myRow); } }
public override bool Equals(object o) { MyRow r = o as MyRow; if (ReferenceEquals(r, null)) { return(false); } return(r.StringValue == this.StringValue && r.DoubleValue == this.DoubleValue); }
/// <summary> /// (基于MyDataTable的列结构)创建1个空行 /// </summary> public MyRow NewRow() { MyRow row = new MyRow(); foreach (var ColumnName in ColumnNames) { row.Add(ColumnName, null); } return(row); }
/// <summary> /// 增加MyRow /// </summary> /// <param name="row">The row.</param> public void AddRow(MyRow row) { foreach (var item in row) { string ColumnName = item.Key; object value = item.Value; MyColumn myColumn = this[ColumnName]; myColumn.Add(value); } }
private void btnAdd_Click(object sender, EventArgs e) { MyRow row = new MyRow(textBox1.Text, textBox2.Text); //row.id = textBox1.Text; //row.name = textBox2.Text; RowsInfo.Instance().add(row); RowsInfo.Instance().save(); reloadListView(); }
/// <summary> /// 获取某行(行索引) /// </summary> /// <param name="RowIndex">Index of the row.</param> /// <returns>MyRow.</returns> public MyRow GetRow(int RowIndex) { MyRow row = new MyRow(); //提取某行的所有列,构成MyRow foreach (var ColumnName in ColumnNames) { row.Add(ColumnName, this[RowIndex, ColumnName]); } return(row); }
private IRestResponse <ApiResponse> RequestApi(ApiRow api, MyRow row) { var client = new RestClient(new Uri(api.ApiUrl)); var request = new RestRequest(); request.AddParameter("appkey", api.AppKey); request.AddParameter("name", row.Name); request.AddParameter("cardno", row.CardNo); var result = client.Execute <ApiResponse>(request); return(result); }
public override async Task <int> CardPlayEffect(bool isSpying, bool isReveal) { var damagePoint = Game.GameRowEffect[AnotherPlayer][MyRow.MyRowToIndex()].RowStatus == RowStatus.BitingFrost ? 3 : 2; var selectCard = await Game.GetSelectPlaceCards(Card, 3, selectMode : SelectModeType.EnemyRow, filter : x => x.Status.CardRow != Card.Status.CardRow); foreach (var target in selectCard) { await target.Effect.Move(new CardLocation(Card.Status.CardRow, int.MaxValue), Card); } foreach (var target in selectCard) { await target.Effect.Damage(damagePoint, Card); } return(0); }
public static void Main() { MyRow row = new MyRow(); row.Add(new MyElement("Gumby")); row.Add(new MyElement("Pokey")); Console.WriteLine("Initial value"); Console.WriteLine("{0}", row); // write to binary, read it back Stream streamWrite = File.Create("MyRow.bin"); BinaryFormatter binaryWrite = new BinaryFormatter(); binaryWrite.Serialize(streamWrite, row); streamWrite.Close(); Stream streamRead = File.OpenRead("MyRow.bin"); BinaryFormatter binaryRead = new BinaryFormatter(); MyRow rowBinary = (MyRow)binaryRead.Deserialize(streamRead); streamRead.Close(); Console.WriteLine("Values after binary serialization"); Console.WriteLine("{0}", rowBinary); // write to SOAP (XML), read it back streamWrite = File.Create("MyRow.xml"); SoapFormatter soapWrite = new SoapFormatter(); soapWrite.Serialize(streamWrite, row); streamWrite.Close(); streamRead = File.OpenRead("MyRow.xml"); SoapFormatter soapRead = new SoapFormatter(); MyRow rowSoap = (MyRow)soapRead.Deserialize(streamRead); streamRead.Close(); Console.WriteLine("Values after SOAP serialization"); Console.WriteLine("{0}", rowSoap); }
public void CobolTable_AddRow_AddsCorrectNumberOfRows() { var table = new CobolTable <MyRow>(); var row1 = new MyRow() { A = 10, B = 2 }; table.AddRow(row1); var row2 = new MyRow() { A = 1000, B = 1000 }; table.AddRow(row2); table.Rows.Count.ShouldBe(2, "Incorrect table.Rows.Count"); }
public override void GridUpdateRow( SourceGrid.Grid grid, object item, int Index) { grid.Rows[Index].Tag = item; Type itemType = item.GetType(); if (itemType == typeof(MyRow)) { MyRow row = item as MyRow; for (int i = 0; i < row.Count; i++) { grid[Index, 0].Value = row[Fields[i]]; grid[Index, i].Tag = row; } return; } { grid[Index, 0].Value = item; } }
public override bool Equals(object obj) { bool ret = false; if (obj is MyRow) { MyRow row = (MyRow)obj; if ((this.Year == row.Year) && (this.Location.Equals(row.Location)) && (this.CategoryNumber.Equals(row.CategoryNumber)) && (this.FileType.Equals(row.FileType)) && (this.Deadline.Equals(row.Deadline)) ) { ret = true; } return(ret); } else { return(ret); } }
private void AddWareGroups() { DataTable MyTable = DBase.GetWareGroups(); foreach (DataRow MyRow in MyTable.Rows) { string ItemDescription = MyRow.Field<string>(1); string ItemKey = MyRow.Field<string>(2); MyItem NewItem = new MyItem(); NewItem.Header = ItemKey + " - " + ItemDescription; if (ItemKey.Length == 1) { this.Items.Add(NewItem); } else if (ItemKey.Length == 2 || ItemKey.Length == 5 || ItemKey.Length == 6) { IterateSubItems(1, NewItem, ItemKey, this.Items); } else // if (ItemKey.Length == 4 || ItemKey.Length == 8) { IterateSubItems(2, NewItem, ItemKey, this.Items); } } }
public bool MainSort() { ChooseDiagMore diag = new ChooseDiagMore(); diag.ShowDialog(); // Indicator if there were any error while parsing input xls file. int errors = 0; if (diag.result != DialogResult.OK) { return(false); } for (int rowIndex = sheet.Cells.FirstRowIndex + 1; rowIndex <= sheet.Cells.LastRowIndex; rowIndex++) { try { Row row = new Row(); row = sheet.Cells.GetRow(rowIndex); int _yearForSort = 0; string _year = row.GetCell(diag.year).StringValue; _year = _year.Trim(); if (yearRangeReg.IsMatch(_year)) { _year = yearRangeReg.Match(_year).ToString(); char[] stringSeparator = new char[] { '-' }; Regex.Replace(_year, " ", ""); Regex.Replace(_year, ".", ""); string[] tokens = _year.Split(stringSeparator); try { _yearForSort = Int32.Parse(tokens[tokens.Length - 1]); } catch (Exception e) { errors++; logFile.WriteLine("Red " + (rowIndex + 1).ToString() + " nije mogao da bude obradjen."); } } else if (yearManyReg.IsMatch(_year)) { _year = yearManyReg.Match(_year).ToString(); char[] stringSeparator = new char[] { '.' }; Regex.Replace(_year, " ", ""); string[] tokens = _year.Split(stringSeparator); if (!tokens[tokens.Length - 2].Equals("")) { try { _yearForSort = Int32.Parse(tokens[tokens.Length - 2]); } catch (Exception e) { errors++; logFile.WriteLine("Red " + (rowIndex + 1).ToString() + " nije mogao da bude obradjen."); } } else { _yearForSort = Int32.Parse(tokens[0]); } } else if (yearReg.IsMatch(_year)) { _yearForSort = Int32.Parse(_year); _year += "."; } else { errors++; logFile.WriteLine("Red " + (rowIndex + 1).ToString() + " nije mogao da bude obradjen.\nProgram nije mogao da prepozna godinu u tom redu."); } string _categoryNumber = row.GetCell(diag.categoryNum).StringValue; string _fileType = row.GetCell(diag.fileType).StringValue; string _location = row.GetCell(diag.location).StringValue; int _deadline = 0; string _deadlineTmp = row.GetCell(diag.deadline).StringValue; _deadlineTmp.TrimEnd(); _deadlineTmp.TrimStart(); _deadlineTmp.Trim(); if (trajnoReg.IsMatch(_deadlineTmp)) { _deadline = 999999; } else { _deadline = Int32.Parse(_deadlineTmp); } string _categoryName = row.GetCell(diag.categoryName).StringValue; string _fileNumber = row.GetCell(diag.fileNum).StringValue; MyRow tmpRow = new MyRow(_yearForSort, _year, _categoryNumber, _fileType, _location, _categoryName, _deadline, _fileNumber); rows.Add(tmpRow); } catch (Exception e) { errors++; logFile.WriteLine("Postoji greska u redu: " + (rowIndex + 1).ToString()); continue; } } rows.Sort(); Form1.getInstance().progressBar.Minimum = 1; Form1.getInstance().progressBar.Maximum = rows.Count; List <MyRow> deletedRows = new List <MyRow>(); for (int i = 0; i < rows.Count; i++) { if (deletedRows.Contains(rows[i])) { continue; } try { Form1.getInstance().progressBar.Value++; } catch (Exception e) { } int fileAmount = 1; for (int j = 0; j < rows.Count; j++) { if (i != j) { if (rows[i].Equals(rows[j])) { outputSheet2.Cells[curRowOutput2, curColOutput2++] = new Cell(archiveNumber.ToString()); outputSheet2.Cells[curRowOutput2++, curColOutput2++] = new Cell(rows[j].FileNumber); curColOutput2 = 0; fileAmount++; deletedRows.Add(rows[j]); //rows.RemoveAt(j); Form1.getInstance().progressBar.Maximum--; } } } outputSheet2.Cells[curRowOutput2, curColOutput2++] = new Cell(archiveNumber.ToString()); outputSheet2.Cells[curRowOutput2++, curColOutput2++] = new Cell(rows[i].FileNumber); curColOutput2 = 0; outputSheet1.Cells[curRowOutput1, curColOutput1++] = new Cell((archiveNumber++).ToString()); outputSheet1.Cells[curRowOutput1, curColOutput1++] = new Cell(rows[i].Year); outputSheet1.Cells[curRowOutput1, curColOutput1++] = new Cell(rows[i].CategoryNumber); outputSheet1.Cells[curRowOutput1, curColOutput1++] = new Cell(rows[i].CategoryName); int _deadLine = rows[i].Deadline; if (_deadLine == 999999) { outputSheet1.Cells[curRowOutput1, curColOutput1++] = new Cell("trajno"); } else { outputSheet1.Cells[curRowOutput1, curColOutput1++] = new Cell(_deadLine.ToString()); } outputSheet1.Cells[curRowOutput1, curColOutput1++] = new Cell(rows[i].FileType); outputSheet1.Cells[curRowOutput1, curColOutput1++] = new Cell(fileAmount.ToString()); outputSheet1.Cells[curRowOutput1++, curColOutput1++] = new Cell(rows[i].Location); curColOutput1 = 0; deletedRows.Add(rows[i]); //rows.RemoveAt(i); Form1.getInstance().progressBar.Maximum--; } if (errors > 0) { MessageBox.Show("Postojale su greske tokom obrade ulaznog fajla, proverite log!"); } return(true); }
public ExcelImportResponse ExcelImport(IUnitOfWork uow, MyExcelImportRequest request) { request.CheckNotNull(); Check.NotNullOrWhiteSpace(request.FileName, "filename"); UploadHelper.CheckFileNameSecurity(request.FileName); if (request.ApiId == 0) { throw new ArgumentOutOfRangeException("filename"); } if (!request.FileName.StartsWith("temporary/")) { throw new ArgumentOutOfRangeException("filename"); } ExcelPackage ep = new ExcelPackage(); using (var fs = new FileStream(UploadHelper.DbFilePath(request.FileName), FileMode.Open, FileAccess.Read)) ep.Load(fs); var p = MyRow.Fields; var response = new ExcelImportResponse { ErrorList = new List <string>() }; if (ep.Workbook.Worksheets.Count == 0) { response.ErrorList.Add("The Excel file doesn't cantain any sheet"); return(response); } var orderSheet = ep.Workbook.Worksheets[1]; //先遍历获取所有的订单明细信息 var idCards = new List <MyRow>(); for (var row = 2; row <= orderSheet.Dimension.End.Row; row++) { var name = Convert.ToString(orderSheet.Cells[row, 1].Value ?? string.Empty); var cardNo = Convert.ToString(orderSheet.Cells[row, 2].Value ?? string.Empty); if (name.IsTrimmedEmpty() || cardNo.IsTrimmedEmpty()) { continue; } var tmpRow = new MyRow { Name = name, CardNo = cardNo }; idCards.Add(tmpRow); } var idCardRepository = new IdCardRepository(); var apiRepository = new ApiRepository(); var apiEntity = apiRepository.Retrieve(uow.Connection, new RetrieveRequest { EntityId = request.ApiId }); if (apiEntity == null || apiEntity.Entity == null) { throw new ArgumentOutOfRangeException("API接口不存在"); } var api = apiEntity.Entity; foreach (var idCard in idCards) { //验证是否已经存在于数据库中,如果存在则直接用数据库中 var lst = idCardRepository.List(uow.Connection, new ListRequest { Criteria = new Criteria("Name") == idCard.Name & new Criteria("CardNo") == idCard.CardNo }); if (lst != null && lst.Entities != null && lst.Entities.Count > 0) { var first = lst.Entities.First(); //继续重复利用数据中已经存在的数据 if (api.ReuseCount > first.ReusedCount) { first.RequestIp = Request.UserHostAddress; first.RequestDate = DateTime.Now; first.Price = api.Price; first.ReusedCount = first.ReusedCount + 1; //更新数据库 idCardRepository.Update(uow, new SaveRequest <MyRow> { Entity = first, EntityId = first.Id }); response.Updated = response.Updated + 1; } else { //去调用API接口进行验证 更新本地的数据 var result = RequestApi(api, first); if (result.Data.Isok == 1) { if (result.Data.Data.Err == 0) { first.AuthenticationType = "实名认证"; first.CheckResult = GetMessage(result.Data.Code); first.RequestDate = DateTime.Now; first.RequestIp = Request.UserHostAddress; first.Price = api.Price; first.ReusedCount = 0; //更新数据库 idCardRepository.Update(uow, new SaveRequest <IdCardRow> { Entity = first, EntityId = first.Id }); response.Updated = response.Updated + 1; } else { //这种情况由于会存在个别身份证格式不正确的情况,所有一个有错误,后面的还是可以继续进行的 response.ErrorList.Add($"{idCard.Name} 验证失败, {GetMessage(result.Data.Code)}"); } } else { //在这种情况就说明之后的验证也不会通过,那么就直接退出,没有必要进行后面的验证 response.ErrorList.Add($"验证失败, {GetMessage(result.Data.Code)}"); break; } } } else { //去调用API接口进行验证 新增本地的数据,因为不存在 var result = RequestApi(api, idCard); if (result.Data.Isok == 1) { if (result.Data.Data.Err == 0) { idCard.AuthenticationType = "实名认证"; idCard.CheckResult = GetMessage(result.Data.Code); idCard.RequestDate = DateTime.Now; idCard.RequestIp = Request.UserHostAddress; idCard.Price = api.Price; idCard.ReusedCount = 0; //更新数据库 idCardRepository.Create(uow, new SaveRequest <IdCardRow> { Entity = idCard }); response.Inserted = response.Inserted + 1; } else { //这种情况由于会存在个别身份证格式不正确的情况,所有一个有错误,后面的还是可以继续进行的 response.ErrorList.Add($"{idCard.Name} 验证失败, {GetMessage(result.Data.Code)}"); } } else { //在这种情况就说明之后的验证也不会通过,那么就直接退出,没有必要进行后面的验证 response.ErrorList.Add($"验证失败, {GetMessage(result.Data.Code)}"); break; } } } return(response); }
public ExcelImportResponse ExcelImport(IUnitOfWork uow, ExcelImportRequest request) { request.CheckNotNull(); Check.NotNullOrWhiteSpace(request.FileName, "filename"); UploadHelper.CheckFileNameSecurity(request.FileName); if (!request.FileName.StartsWith("temporary/")) { throw new ArgumentOutOfRangeException("filename"); } if (Path.GetExtension(request.FileName) != ".xlsx") { throw new Exception("文件格式不对,只支持Excel2007及以上版本"); } ExcelPackage ep = new ExcelPackage(); using (var fs = new FileStream(UploadHelper.DbFilePath(request.FileName), FileMode.Open, FileAccess.Read)) { ep.Load(fs); } var p = MyRow.Fields; var response = new ExcelImportResponse(); response.ErrorList = new List <string>(); var worksheet = ep.Workbook.Worksheets[1]; bool isCreat = false; var user = (UserDefinition)Authorization.UserDefinition; for (var row = 2; row <= worksheet.Dimension.End.Row; row++) { try { // every circulation should reset the flag isCreat = false; // check the productno is empty or not var masterNo = worksheet.Cells[row, 2].GetValue <string>(); var no = worksheet.Cells[row, 3].GetValue <string>(); if (masterNo.IsTrimmedEmpty() || no.IsTrimmedEmpty()) { continue; } // search the productno whether existes in the database no = no.Trim(); masterNo = masterNo.Trim(); var yundan = uow.Connection.TryFirst <MyRow>(q => q .Select(p.SubAwb, p.MasterAwb, p.Id) .Where(p.SubAwb == no && p.MasterAwb == masterNo && p.TenantId == user.TenantId)); if (yundan == null) { yundan = new MyRow { SubAwb = no, MasterAwb = masterNo }; isCreat = true; } else { isCreat = false; } //yundan.ApplicationUnit = worksheet.Cells[row, 1].GetValue<string>(); yundan.Flight = worksheet.Cells[row, 1].GetValue <string>(); int.TryParse(worksheet.Cells[row, 4].GetValue <string>(), out int amount); yundan.Amount = amount; double.TryParse(worksheet.Cells[row, 5].GetValue <string>(), out double weight); yundan.Weight = weight; yundan.Description = worksheet.Cells[row, 6].GetValue <string>(); yundan.Status = worksheet.Cells[row, 7].GetValue <string>(); yundan.IsChecked = Entities.StateKind.NoChecked; //yundan.TenantId = user.TenantId; if (isCreat) { new DeclarationDataRepository().Create(uow, new SaveRequest <MyRow> { Entity = yundan }); response.Inserted = response.Inserted + 1; } else { new DeclarationDataRepository().Update(uow, new SaveRequest <MyRow> { Entity = yundan, EntityId = yundan.Id }); response.Updated = response.Updated + 1; } } catch (Exception ex) { ex.Log(); response.ErrorList.Add("Exception on Row " + row + ": " + ex.Message); } } return(response); }
private void Form1_Load(object sender, EventArgs e) { MyRows result = new MyRows(); for (int i = 0; i < Items.Count; i++) { result.Fields.Add(Items[i].Name); } result.Fields.Add("Сума"); List <KeyValuePair <string, IComparer> > gridHeaders = new List <KeyValuePair <string, IComparer> >(); for (int i = 0; i < result.Fields.Count; i++) { gridHeaders.Add(new KeyValuePair <string, IComparer>(result.Fields[i], null)); } Fill fill = new Fill(result.Fields); string bVariantCount = ""; for (int i = 0; i < Items.Count; i++) { bVariantCount += "1"; } int count = Convert.ToInt32(bVariantCount, 2); for (int i = 0; i <= count; i++) { //https://stackoverflow.com/questions/6758196/convert-int-to-a-bit-array-in-net string s = Convert.ToString(i, 2); //Convert to binary in a string int[] bits = s.PadLeft(Items.Count, '0') // Add 0's from left .Select(c => int.Parse(c.ToString())) // convert each char to int .ToArray(); // Convert IEnumerable from select to Array MyRow row = new MyRow(); double sum = 0; int trueCount = 0; for (int j = 0; j < Items.Count; j++) { double price; int cell = bits[j]; if (cell != 0) { trueCount++; price = Items[j].Price; } else { price = 0; } price = (cell == 0 ? 0 : Items[j].Price); sum += price; row.Add(result.Fields[j], price); } row.Add("Сума", sum); if (trueItemsCount == 0 || trueCount == trueItemsCount) { result.Rows.Add(row); } } tssl_Count.Text = result.Rows.Count.ToString(); fill.GridFill(sg_Result, result.Rows, null, gridHeaders); }
/// <summary> /// Batch preprocessing of image files for ML.Net image classification /// </summary> public static void Process(string path) { #region CopyImagesToFolder System.Console.WriteLine($"directory of realizations is : {path}"); var filePaths = DirHelper.GetFileNames(path, "*.jpg", false); FileHelper.SortByName(ref filePaths); Dictionary <string, List <string> > prefix_filePaths = new Dictionary <string, List <string> >(); for (int i = 0; i < filePaths.Length; i++) { string filePath = filePaths[i]; string fileName = FileHelper.GetFileName(filePaths[i]); if (fileName.IndexOf("_") < 0) { continue; } string Prefix = fileName.Substring(0, fileName.IndexOf("_")); if (prefix_filePaths.ContainsKey(Prefix)) { prefix_filePaths[Prefix].Add(filePath); } else { prefix_filePaths.Add(Prefix, new List <string>() { filePath }); } } Dictionary <int, string> idx_prefix = new Dictionary <int, string>(); System.Console.WriteLine(); System.Console.WriteLine("list of prefixs(column name:1 - serial number;2 - parameter value;3 - realizations number)"); int counter = 1; foreach (var item in prefix_filePaths) { idx_prefix.Add(counter, item.Key); System.Console.WriteLine($"{counter}\t{item.Key}\t{item.Value.Count}"); counter++; } System.Console.WriteLine("Select two adjacent serial numbers (for example, 1 2 or 4 5) from the prefix list."); string selected = System.Console.ReadLine(); List <int> ids = selected.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(a => int.Parse(a)).ToList(); System.Console.WriteLine("How many realizations are sampled at a time(one sampling experiments)?"); System.Console.WriteLine("If the number of realizations is 300, it is recommended to take 50~100"); int k = int.Parse(System.Console.ReadLine()); System.Console.WriteLine("How many sampling experiments need to be done?"); System.Console.WriteLine("it is recommended to take value in range of 30~80"); int N = int.Parse(System.Console.ReadLine()); Program.SamplingNumber = N; System.Console.WriteLine(); System.Console.WriteLine("Clean up the previous data"); if (!DirHelper.IsExistDirectory(Program.SavePath)) { DirHelper.CreateDir(Program.SavePath); } else { DirHelper.ClearDirectory(Program.SavePath); } System.Threading.Thread.Sleep(100); System.Console.WriteLine(); System.Console.WriteLine("Copy data file"); //Take samples from the realizations for (int i = 0; i < N; i++) { string SamplingPath = @$ "{Program.SavePath}\train{i}"; Directory.CreateDirectory(SamplingPath); counter = 0; using (var pb = new ProgressBar()) { foreach (var idx in ids) { pb.Progress.Report(counter / ids.Count, "Copying now"); string prefix = idx_prefix[idx]; List <string> filePaths1 = prefix_filePaths[prefix]; filePaths1 = SortHelper.RandomSelect(filePaths1, k, new Random()); foreach (var filePath in filePaths1) { string filePath_new = string.Format("{0}\\{1}", SamplingPath, FileHelper.GetFileName(filePath)); File.Copy(filePath, filePath_new); } } } #region MakeTagFile var filePaths_temp = DirHelper.GetFileNames(SamplingPath); FileHelper.SortByName(ref filePaths_temp); MyDataTable myDT = new MyDataTable(); myDT.AddColumn("FileName"); myDT.AddColumn("Label"); for (int j = 0; j < filePaths_temp.Length; j++) { MyRow row = myDT.NewRow(); string fileName = FileHelper.GetFileName(filePaths_temp[j]); if (fileName.IndexOf("_") < 0) { continue; } row["FileName"] = fileName; row["Label"] = fileName.Substring(0, fileName.IndexOf("_")); myDT.AddRow(row); } string TagFilePath = $"{Program.SavePath}\\train_tags{i}.tsv"; myDT.WriteToTxt(TagFilePath, "\t", false); #endregion } #endregion }
NestedRow(int x, int y, int z) { this.z = z; this.r = new MyRow(x,y); }
private void Add(MyRow myRow) { list.Add(myRow); }
/// <summary> /// ARCHIVO LL /// </summary> /// <param name="Str_Turno_block"></param> /// <param name="FechaInicio"></param> /// <param name="IdPlazaCobro"></param> /// <param name="CabeceraTag"></param> /// <param name="Tramo"></param> /// <returns></returns> public void Registro_usuarios_telepeaje(string Str_Turno_block, DateTime FechaInicio, string IdPlazaCobro, string CabeceraTag, string Tramo, string Conexion) { string StrQuerys; string Cabecera; string Nombre_archivo = string.Empty; int Int_turno = 0; string H_inicio_turno = string.Empty; string H_fin_turno = string.Empty; string No_registros = string.Empty; string Str_detalle = string.Empty; double Dbl_registros; string StrClaseExcedente; string Tag_iag; string LenText; int KeyAscii; bool Validar = false; List <string> Val = new List <string>(); DataTable dataTableCa = new DataTable(); EnumerableRowCollection <DataRow> dataRows; var IdCarril = string.Empty; var NumCarril = string.Empty; var NumPlaza = string.Empty; var NumTramo = string.Empty; OracleConnection ConexionDim = new OracleConnection(Conexion); MetodosGlbRepository MtGlb = new MetodosGlbRepository(); try { if (Str_Turno_block.Substring(0, 2) == "06") { Int_turno = 5; H_inicio_turno = FechaInicio.ToString("MM/dd/yyyy") + " 06:00:00"; H_fin_turno = FechaInicio.ToString("MM/dd/yyyy") + " 13:59:59"; } else if (Str_Turno_block.Substring(0, 2) == "14") { Int_turno = 6; H_inicio_turno = FechaInicio.ToString("MM/dd/yyyy") + " 14:00:00"; H_fin_turno = FechaInicio.ToString("MM/dd/yyyy") + " 21:59:59"; } else if (Str_Turno_block.Substring(0, 2) == "22") { Int_turno = 4; H_inicio_turno = FechaInicio.AddDays(-1).ToString("MM/dd/yyyy") + " 22:00:00"; H_fin_turno = FechaInicio.ToString("MM/dd/yyyy") + " 05:59:59"; } if (IdPlazaCobro.Length == 3) { if (IdPlazaCobro == "108") { Nombre_archivo = "0001"; } else if (IdPlazaCobro == "109") { Nombre_archivo = "001B"; } else if (IdPlazaCobro == "107") { Nombre_archivo = "0107"; } else if (IdPlazaCobro == "061") { Nombre_archivo = "061B"; } else if (IdPlazaCobro == "086" || IdPlazaCobro == "083" || IdPlazaCobro == "027") { Nombre_archivo = "01" + IdPlazaCobro.Substring(1, 2); } else { Nombre_archivo = "0" + IdPlazaCobro; } } Nombre_archivo = Nombre_archivo + FechaInicio.ToString("MM") + FechaInicio.ToString("dd") + "." + Int_turno + "II"; System.IO.StreamWriter Osw = new System.IO.StreamWriter(Carpeta + Nombre_archivo); System.IO.StreamWriter Osw2 = new System.IO.StreamWriter(Carpeta2 + Nombre_archivo); Archivo_5 = Nombre_archivo; Cabecera = CabeceraTag; if (IdPlazaCobro.Length == 3) { if (IdPlazaCobro == "108") { Cabecera = Cabecera + "0001"; } else if (IdPlazaCobro == "109") { Cabecera = Cabecera + "001B"; } else if (IdPlazaCobro == "107") { Cabecera = Cabecera + "0107"; } else if (IdPlazaCobro == "061") { Cabecera = Cabecera + "061B"; } else if (IdPlazaCobro == "086" || IdPlazaCobro == "083" || IdPlazaCobro == "027") { Cabecera = Cabecera + "01" + IdPlazaCobro.Substring(1, 2); } else { Cabecera = Cabecera + "0" + IdPlazaCobro; } } Cabecera = Cabecera + FechaInicio.ToString("MM") + FechaInicio.ToString("dd") + "." + Int_turno + "II" + FechaInicio.ToString("dd/MM/yyyy") + Int_turno; //CABECERA INICIO REGISTROS //CABECERA FIN //inicio detalle DateTime _H_inicio_turno = DateTime.ParseExact(H_inicio_turno, "MM/dd/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); DateTime _H_fin_turno = DateTime.ParseExact(H_fin_turno, "MM/dd/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); /*****************************************************************************/ MtGlb.ConnectionOpen(ConexionDim); /*****************************************************************************/ StrQuerys = "SELECT DATE_TRANSACTION, VOIE, EVENT_NUMBER, FOLIO_ECT, Version_Tarif, ID_PAIEMENT, " + "TAB_ID_CLASSE, TYPE_CLASSE.LIBELLE_COURT1 AS CLASE_MARCADA, NVL(TRANSACTION.Prix_Total,0) as MONTO_MARCADO, " + "ACD_CLASS, TYPE_CLASSE_ETC.LIBELLE_COURT1 AS CLASE_DETECTADA, NVL(TRANSACTION.transaction_CPT1 / 100, 0) as MONTO_DETECTADO, CONTENU_ISO, CODE_GRILLE_TARIF, ID_OBS_MP, ID_OBS_TT, ISSUER_ID " + "FROM TRANSACTION " + "JOIN TYPE_CLASSE ON TAB_ID_CLASSE = TYPE_CLASSE.ID_CLASSE " + "LEFT JOIN TYPE_CLASSE TYPE_CLASSE_ETC ON ACD_CLASS = TYPE_CLASSE_ETC.ID_CLASSE " + "WHERE " + "(DATE_DEBUT_POSTE >= TO_DATE('" + _H_inicio_turno.ToString("yyyyMMddHHmmss") + "','YYYYMMDDHH24MISS')) AND (DATE_DEBUT_POSTE <= TO_DATE('" + _H_fin_turno.ToString("yyyyMMddHHmmss") + "','YYYYMMDDHH24MISS')) " + " AND (ID_PAIEMENT = 15 or ID_OBS_MP = 30) " + "AND (TRANSACTION.Id_Voie = '1' " + "OR TRANSACTION.Id_Voie = '2' " + "OR TRANSACTION.Id_Voie = '3' " + "OR TRANSACTION.Id_Voie = '4' " + "OR TRANSACTION.Id_Voie = 'X') AND (MODE_REGLEMENT = 'IAV ') " + "ORDER BY DATE_TRANSACTION"; if (MtGlb.QueryDataSet(StrQuerys, "TRANSACTION", ConexionDim)) { Dbl_registros = 0; /***********************************************************************/ //Connection.Open(); //string Query = @"SELECT t.idTramo, t.nomTramo, p.idPlaza, p.nomPlaza, c.idCarril, c.numCarril, c.numTramo // FROM TYPE_PLAZA p // INNER JOIN TYPE_TRAMO t ON t.idenTramo = p.idTramo // INNER JOIN TYPE_CARRIL c ON c.idPlaza = p.idenPlaza // WHERE t.idTramo = @tramo and p.idPlaza = @plaza"; //string Query = @"SELECT d.ID_Delegacion, d.Nom_Delegacion, p.ID_Plaza, p.Nom_Plaza, c.Num_Gea, c.num_Capufe, c.Num_Tramo " + // "FROM TYPE_PLAZA p " + // "INNER JOIN TYPE_TRAMO d on d.ID_Delegacion = d.ID_Delegacion " + // "INNER JOIN TYPE_CARRIL c on c.ID_Plaza = p.ID_Plaza " + // "WHERE d.ID_Delegacion = @tramo and p.ID_Plaza = @plaza"; //using (SqlCommand Cmd = new SqlCommand(Query, Connection)) //{ // Cmd.Parameters.Add(new SqlParameter("tramo", Tramo)); // Cmd.Parameters.Add(new SqlParameter("plaza", IdPlazaCobro)); // //Cmd.Parameters.Add(new SqlParameter("plaza", IdPlazaCobro.Substring(1, 2))); // //Cmd.Parameters.Add(new SqlParameter("carril", MtGlb.oDataRow["Voie"].ToString().Substring(1, 2))); // try // { // SqlDataAdapter Da = new SqlDataAdapter(Cmd); // Da.Fill(dataTableCa); // } // catch (Exception ex) // { // Message = ex.Message + " " + ex.StackTrace; // } // finally // { // Cmd.Dispose(); // Connection.Close(); // } //} var props = typeof(Type_Carril).GetProperties(); DataTable dt = new DataTable("Type_Carril"); var idpla = IdPlazaCobro.Substring(1, 2); var Carriles_Tramos = db.Type_Plaza.GroupJoin(db.Type_Carril, pla => pla.Id_Plaza, car => car.Plaza_Id, (pla, car) => new { pla, car }).Where(x => x.pla.Num_Plaza == idpla).ToList(); dt.Columns.AddRange( props.Select(p => new DataColumn(p.Name, p.PropertyType)).ToArray() ); Carriles_Tramos.FirstOrDefault().car.ToList().ForEach( i => dt.Rows.Add(props.Select(p => p.GetValue(i, null)).ToArray()) ); ///***********************************************************************/ foreach (DataRow item in MtGlb.Ds.Tables["TRANSACTION"].Rows) { if (item["ID_OBS_MP"].ToString() == "00" || item["ID_OBS_MP"].ToString() == "30") { Str_detalle = string.Empty; Str_detalle = Convert.ToDateTime(item["DATE_TRANSACTION"]).ToString("dd/MM/yyyy") + ","; /****************/ dataRows = from MyRow in dt.AsEnumerable() // where MyRow.Field<string>("idCarril") == item["Voie"].ToString().Substring(1, 2) where MyRow.Field <string>("Num_Gea") == item["Voie"].ToString().Substring(1, 2) select MyRow; foreach (DataRow value in dataRows) { //NumCarril = value["numCarril"].ToString(); //NumTramo = value["numTramo"].ToString(); //NumPlaza = value["idPlaza"].ToString(); NumCarril = value["Num_Capufe"].ToString(); NumTramo = value["Num_Tramo"].ToString(); NumPlaza = value.Field <Type_Plaza>("Type_Plaza").Num_Plaza.ToString(); } /****************/ if (dataRows.Count() != 0) { Str_detalle = Str_detalle + NumTramo + ","; Str_detalle = Str_detalle + NumCarril + ","; } else { Str_detalle = Str_detalle + ",,"; } //Cuerpo Caracter X(1) Str_detalle = Str_detalle + item["Voie"].ToString().Substring(0, 1) + ","; //Hora de evento Caracter hhmmss Str_detalle = Str_detalle + Convert.ToDateTime(item["DATE_TRANSACTION"]).ToString("HHmmss") + ","; //numero tarjeta iave Validar = true; Tag_iag = MtGlb.IIf(item["CONTENU_ISO"].ToString().Trim() == "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "", item["CONTENU_ISO"].ToString().TrimStart()); if (Tag_iag.Length != 8) //Tag 00000000 { Tag_iag = Tag_iag.Substring(0, 14).Trim(); } if (Tag_iag.Length == 13 && Tag_iag.Substring(0, 3) == "009") { Tag_iag = Tag_iag.Substring(0, 3) + Tag_iag.Substring(5, 8); } LenText = Tag_iag.Length.ToString(); for (int c = 0; c < Convert.ToInt32(LenText); c++) { KeyAscii = (int)Convert.ToChar(Tag_iag.Substring(c, 1)); if ((KeyAscii >= 33) && (KeyAscii <= 47) || (KeyAscii >= 58) && (KeyAscii <= 64) || (KeyAscii >= 91) && (KeyAscii <= 96) || (KeyAscii >= 123) && (KeyAscii <= 126)) { Validar = false; KeyAscii = 8; } } Str_detalle = Str_detalle + Tag_iag.Trim() + ","; //situacion tarjeta iave if (Convert.ToInt32(item["ID_PAIEMENT"]) == 15) { Str_detalle = Str_detalle + "V" + ","; } else { Str_detalle = Str_detalle + "I" + ","; } //clave transportsta iave Str_detalle = Str_detalle + ","; //clase vehiculo iave Str_detalle = Str_detalle + ","; //importe usuario iave Str_detalle = Str_detalle + item["MONTO_DETECTADO"] + ","; //numero de evento ect Str_detalle = Str_detalle + item["EVENT_NUMBER"] + ","; //Número de turno Entero 9 Str_detalle = Str_detalle + Int_turno + ","; //numero de ejes segun ect if (!DBNull.Value.Equals(item["CLASE_DETECTADA"])) { StrClaseExcedente = string.Empty; if (item["CLASE_DETECTADA"].ToString() == "T01A") { Str_detalle = Str_detalle + "2" + ","; Str_detalle = Str_detalle + "L"; } else if (item["CLASE_DETECTADA"].ToString() == "T01M") { Str_detalle = Str_detalle + "2" + ","; Str_detalle = Str_detalle + "L"; } else if (item["CLASE_DETECTADA"].ToString() == "T01T") { Str_detalle = Str_detalle + "2" + ","; Str_detalle = Str_detalle + "L"; } else if (item["CLASE_DETECTADA"].ToString() == "T02B") { Str_detalle = Str_detalle + "2" + ","; Str_detalle = Str_detalle + "P"; } else if (item["CLASE_DETECTADA"].ToString() == "T03B") { Str_detalle = Str_detalle + "3" + ","; Str_detalle = Str_detalle + "P"; } else if (item["CLASE_DETECTADA"].ToString() == "T04B") { Str_detalle = Str_detalle + "4" + ","; Str_detalle = Str_detalle + "P"; } else if (item["CLASE_DETECTADA"].ToString() == "T02C") { Str_detalle = Str_detalle + "2" + ","; Str_detalle = Str_detalle + "P"; } else if (item["CLASE_DETECTADA"].ToString() == "T03C") { Str_detalle = Str_detalle + "3" + ","; Str_detalle = Str_detalle + "P"; } else if (item["CLASE_DETECTADA"].ToString() == "T04C") { Str_detalle = Str_detalle + "4" + ","; Str_detalle = Str_detalle + "P"; } else if (item["CLASE_DETECTADA"].ToString() == "T05C") { Str_detalle = Str_detalle + "5" + ","; Str_detalle = Str_detalle + "P"; } else if (item["CLASE_DETECTADA"].ToString() == "T06C") { Str_detalle = Str_detalle + "6" + ","; Str_detalle = Str_detalle + "P"; } else if (item["CLASE_DETECTADA"].ToString() == "T07C") { Str_detalle = Str_detalle + "7" + ","; Str_detalle = Str_detalle + "P"; } else if (item["CLASE_DETECTADA"].ToString() == "T08C") { Str_detalle = Str_detalle + "8" + ","; Str_detalle = Str_detalle + "P"; } else if (item["CLASE_DETECTADA"].ToString() == "T09C") { Str_detalle = Str_detalle + "9" + ","; Str_detalle = Str_detalle + "P"; } else if (item["CLASE_DETECTADA"].ToString() == "TL01A") { Str_detalle = Str_detalle + "2" + ","; Str_detalle = Str_detalle + "P"; } else if (item["CLASE_DETECTADA"].ToString() == "TL02A") { Str_detalle = Str_detalle + "2" + ","; Str_detalle = Str_detalle + "P"; } else if (item["CLASE_DETECTADA"].ToString() == "TLnnA") { Str_detalle = Str_detalle + item["ID_OBS_TT"] + ","; Str_detalle = Str_detalle + "L"; } else if (item["CLASE_DETECTADA"].ToString() == "T01P") { Str_detalle = Str_detalle + "1" + ","; Str_detalle = Str_detalle + "L"; } else if (item["CLASE_DETECTADA"].ToString() == "TP01C") { Str_detalle = Str_detalle + "9" + ","; Str_detalle = Str_detalle + "L"; } else if (item["CLASE_DETECTADA"].ToString() == "TPnnC") { Str_detalle = Str_detalle + item["ID_OBS_TT"] + ","; Str_detalle = Str_detalle + "P"; } else { Str_detalle = Str_detalle + "No detectada" + ",0,"; } } else { Str_detalle = Str_detalle + "0,"; } } /****************************************************************/ else { //inicio clase detectada StrQuerys = "SELECT DATE_TRANSACTION, VOIE, EVENT_NUMBER, FOLIO_ECT, Version_Tarif, ID_PAIEMENT, " + "TAB_ID_CLASSE, TYPE_CLASSE.LIBELLE_COURT1 AS CLASE_MARCADA, NVL(TRANSACTION.Prix_Total,0) as MONTO_MARCADO, " + "ACD_CLASS, TYPE_CLASSE_ETC.LIBELLE_COURT1 AS CLASE_DETECTADA, NVL(TRANSACTION.transaction_CPT1 / 100, 0) as MONTO_DETECTADO, CONTENU_ISO, CODE_GRILLE_TARIF, ID_OBS_MP, ID_OBS_TT, ISSUER_ID " + "FROM TRANSACTION " + "JOIN TYPE_CLASSE ON TAB_ID_CLASSE = TYPE_CLASSE.ID_CLASSE " + "LEFT JOIN TYPE_CLASSE TYPE_CLASSE_ETC ON ACD_CLASS = TYPE_CLASSE_ETC.ID_CLASSE " + "WHERE " + "(DATE_DEBUT_POSTE >= TO_DATE('" + _H_inicio_turno.ToString("yyyyMMddHHmmss") + "','YYYYMMDDHH24MISS')) AND (DATE_DEBUT_POSTE <= TO_DATE('" + _H_fin_turno.ToString("yyyyMMddHHmmss") + "','YYYYMMDDHH24MISS')) " + "AND VOIE = '" + item["VOIE"] + "' " + "AND ID_OBS_SEQUENCE <> '7777' " + "AND EVENT_NUMBER = " + item["EVENT_NUMBER"] + " " + "AND (TRANSACTION.Id_Voie = '1' " + "OR TRANSACTION.Id_Voie = '2' " + "OR TRANSACTION.Id_Voie = '3' " + "OR TRANSACTION.Id_Voie = '4' " + "OR TRANSACTION.Id_Voie = 'X') " + "ORDER BY DATE_TRANSACTION desc"; if (MtGlb.QueryDataSet3(StrQuerys, "TRANSACTION", ConexionDim)) { Str_detalle = Convert.ToDateTime(MtGlb.oDataRow3["DATE_TRANSACTION"]).ToString("dd/MM/yyyy") + ","; /****************/ dataRows = from MyRow in dt.AsEnumerable() //where MyRow.Field<string>("idCarril") == MtGlb.oDataRow3["Voie"].ToString().Substring(1, 2) where MyRow.Field <string>("Num_Carril") == MtGlb.oDataRow3["Voie"].ToString().Substring(1, 2) select MyRow; foreach (DataRow value in dataRows) { //NumCarril = value["numCarril"].ToString(); //NumTramo = value["numTramo"].ToString(); //NumPlaza = value["idPlaza"].ToString(); NumCarril = value["Num_Capufe"].ToString(); NumTramo = value["Num_Tramo"].ToString(); NumPlaza = value.Field <Type_Plaza>("Type_Plaza").Num_Plaza.ToString(); } /***************/ if (dataRows.Count() != 0) { Str_detalle = Str_detalle + NumTramo + ","; Str_detalle = Str_detalle + NumCarril + ","; } else { Str_detalle = Str_detalle + ",,"; } //Cuerpo Caracter X(1) Str_detalle = Str_detalle + MtGlb.oDataRow3["Voie"].ToString().Substring(0, 1) + ","; //Hora de evento Caracter hhmmss Str_detalle = Str_detalle + Convert.ToDateTime(MtGlb.oDataRow3["DATE_TRANSACTION"]).ToString("HHmmss") + ","; //numero tarjeta iave Validar = true; Tag_iag = MtGlb.IIf(MtGlb.oDataRow3["CONTENU_ISO"].ToString().Trim() == "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "", MtGlb.oDataRow3["CONTENU_ISO"].ToString().TrimStart()); if (Tag_iag.Length != 8) //Tag 00000000 { Tag_iag = Tag_iag.Substring(0, 14).Trim(); } if (Tag_iag.Length == 13 && Tag_iag.Substring(0, 3) == "009") { Tag_iag = Tag_iag.Substring(0, 3) + Tag_iag.Substring(5, 8); } LenText = Tag_iag.Length.ToString(); for (int c = 0; c < Convert.ToInt32(LenText); c++) { KeyAscii = (int)Convert.ToChar(Tag_iag.Substring(c, 1)); if ((KeyAscii >= 33) && (KeyAscii <= 47) || (KeyAscii >= 58) && (KeyAscii <= 64) || (KeyAscii >= 91) && (KeyAscii <= 96) || (KeyAscii >= 123) && (KeyAscii <= 126)) { Validar = false; KeyAscii = 8; } } Str_detalle = Str_detalle + Tag_iag.Trim() + ","; //situacion tarjeta iave if (Convert.ToInt32(MtGlb.oDataRow3["ID_PAIEMENT"]) == 15) { Str_detalle = Str_detalle + "V" + ","; } else { Str_detalle = Str_detalle + "I" + ","; } //clave transportsta iave Str_detalle = Str_detalle + ","; //clase vehiculo iave Str_detalle = Str_detalle + ","; //importe usuario iave Str_detalle = Str_detalle + item["MONTO_DETECTADO"] + ","; //numero de evento ect Str_detalle = Str_detalle + MtGlb.oDataRow3["EVENT_NUMBER"] + ","; //Número de turno Entero 9 Str_detalle = Str_detalle + Int_turno + ","; //numero de ejes segun ect if (!DBNull.Value.Equals(MtGlb.oDataRow3["CLASE_DETECTADA"])) { StrClaseExcedente = string.Empty; if (MtGlb.oDataRow3["CLASE_DETECTADA"].ToString() == "T01A") { Str_detalle = Str_detalle + "2" + ","; Str_detalle = Str_detalle + "L"; } else if (MtGlb.oDataRow3["CLASE_DETECTADA"].ToString() == "T01M") { Str_detalle = Str_detalle + "2" + ","; Str_detalle = Str_detalle + "L"; } else if (MtGlb.oDataRow3["CLASE_DETECTADA"].ToString() == "T01T") { Str_detalle = Str_detalle + "2" + ","; Str_detalle = Str_detalle + "L"; } else if (MtGlb.oDataRow3["CLASE_DETECTADA"].ToString() == "T02B") { Str_detalle = Str_detalle + "2" + ","; Str_detalle = Str_detalle + "P"; } else if (MtGlb.oDataRow3["CLASE_DETECTADA"].ToString() == "T03B") { Str_detalle = Str_detalle + "3" + ","; Str_detalle = Str_detalle + "P"; } else if (MtGlb.oDataRow3["CLASE_DETECTADA"].ToString() == "T04B") { Str_detalle = Str_detalle + "4" + ","; Str_detalle = Str_detalle + "P"; } else if (MtGlb.oDataRow3["CLASE_DETECTADA"].ToString() == "T02C") { Str_detalle = Str_detalle + "2" + ","; Str_detalle = Str_detalle + "P"; } else if (MtGlb.oDataRow3["CLASE_DETECTADA"].ToString() == "T03C") { Str_detalle = Str_detalle + "3" + ","; Str_detalle = Str_detalle + "P"; } else if (MtGlb.oDataRow3["CLASE_DETECTADA"].ToString() == "T04C") { Str_detalle = Str_detalle + "4" + ","; Str_detalle = Str_detalle + "P"; } else if (MtGlb.oDataRow3["CLASE_DETECTADA"].ToString() == "T05C") { Str_detalle = Str_detalle + "5" + ","; Str_detalle = Str_detalle + "P"; } else if (MtGlb.oDataRow3["CLASE_DETECTADA"].ToString() == "T06C") { Str_detalle = Str_detalle + "6" + ","; Str_detalle = Str_detalle + "P"; } else if (MtGlb.oDataRow3["CLASE_DETECTADA"].ToString() == "T07C") { Str_detalle = Str_detalle + "7" + ","; Str_detalle = Str_detalle + "P"; } else if (MtGlb.oDataRow3["CLASE_DETECTADA"].ToString() == "T08C") { Str_detalle = Str_detalle + "8" + ","; Str_detalle = Str_detalle + "P"; } else if (MtGlb.oDataRow3["CLASE_DETECTADA"].ToString() == "T09C") { Str_detalle = Str_detalle + "9" + ","; Str_detalle = Str_detalle + "P"; } else if (MtGlb.oDataRow3["CLASE_DETECTADA"].ToString() == "TL01A") { Str_detalle = Str_detalle + "2" + ","; Str_detalle = Str_detalle + "P"; } else if (MtGlb.oDataRow3["CLASE_DETECTADA"].ToString() == "TL02A") { Str_detalle = Str_detalle + "2" + ","; Str_detalle = Str_detalle + "P"; } else if (MtGlb.oDataRow3["CLASE_DETECTADA"].ToString() == "TLnnA") { Str_detalle = Str_detalle + MtGlb.oDataRow3["ID_OBS_TT"] + ","; Str_detalle = Str_detalle + "L"; } else if (MtGlb.oDataRow3["CLASE_DETECTADA"].ToString() == "T01P") { Str_detalle = Str_detalle + "1" + ","; Str_detalle = Str_detalle + "L"; } else if (MtGlb.oDataRow3["CLASE_DETECTADA"].ToString() == "TP01C") { Str_detalle = Str_detalle + "9" + ","; Str_detalle = Str_detalle + "L"; } else if (MtGlb.oDataRow3["CLASE_DETECTADA"].ToString() == "TPnnC") { Str_detalle = Str_detalle + MtGlb.oDataRow3["ID_OBS_TT"] + ","; Str_detalle = Str_detalle + "P"; } else { Str_detalle = Str_detalle + "No detectada" + ",0,"; } } else { Str_detalle = Str_detalle + "0,"; } } } //II Fin //fin clase detectada if (Validar) { Dbl_registros = Dbl_registros + 1; Val.Add(Str_detalle); //oSW.WriteLine(str_detalle) //---------------------- } } if (Convert.ToString(Dbl_registros).Length == 1) { No_registros = "0000" + Dbl_registros; } else if (Convert.ToString(Dbl_registros).Length == 2) { No_registros = "000" + Dbl_registros; } else if (Convert.ToString(Dbl_registros).Length == 3) { No_registros = "00" + Dbl_registros; } else if (Convert.ToString(Dbl_registros).Length == 4) { No_registros = "0" + Dbl_registros; } else if (Convert.ToString(Dbl_registros).Length == 5) { No_registros = Dbl_registros.ToString(); } Cabecera = Cabecera + No_registros; Osw.WriteLine(Cabecera); Osw2.WriteLine(Cabecera); // CABECERA FIN } else { Cabecera = Cabecera + "00000"; Osw.WriteLine(Cabecera); Osw2.WriteLine(Cabecera); } //fin detalle /*********************/ MtGlb.ConnectionOpen(ConexionDim); foreach (var item in Val) { Osw.WriteLine(item); Osw2.WriteLine(item); } Osw.Flush(); Osw.Close(); Osw2.Flush(); Osw2.Close(); Message = "Todo bien"; } catch (Exception ex) { Message = ex.Message + " " + ex.StackTrace; Message = Message.Replace(System.Environment.NewLine, " "); } }