public void process_data_row(query q,row row,bool noLinks) { int len=0; if(noLinks) { foreach(query.column c in q.columns) { core.column mc=this.data_schema.Find(x=>x.name==c.name); if(null!=mc && mc.export) len++; } } else len=q.columns.Count; string[] data_columns=new string[len]; int index=0; foreach(query.column c in q.columns) { titan.core.column p; string data=""; int cI=this.data_schema.FindIndex(x=>x.name==c.name); if(cI>=0) p =this.data_schema[cI]; else p=new titan.core.column(c.name,"number",0,true); if(p.visible|| p.export) { if(!row.ContainsKey(p.name)) { data_columns[index]="*"; index++; continue; } //skip bad structure? if(null==row[p.name]) data=""; else data=row[p.name].ToString(); if(noLinks && !p.export) continue; data_columns[index]=this.data_types.transform_data(p.type,data,c); //does the conversion of types String to whatever is in the data types table for that type. index++; }//end p visible }//end for each columns this.results.rows.Add(data_columns); }
public static IEnumerable <row> GetContent(string str) { string tmpStr = string.Format("<tbody[^>]*?>(?<Text>[^*]*)</tbody>"); //get the value in input label string trStr = string.Format("<tr[^>]*?>(?<Text>[^*]*?)</tr>"); //get the value in tr label List <string> languageName = new List <string>(); List <row> text = new List <row>(); MatchCollection tbodyCollection = Regex.Matches(str, tmpStr, RegexOptions.IgnoreCase); foreach (Match match in tbodyCollection) { result = match.Groups["Text"].Value; } if (string.IsNullOrEmpty(result)) { throw new FileNotFoundException("no result for your search"); //make sure the result exists } else { //Console.WriteLine(result); MatchCollection trCollection = Regex.Matches(result, trStr, RegexOptions.IgnoreCase); foreach (Match match in trCollection) { string temp = match.Groups["Text"].Value; string row_ = Regex.Replace(temp, @"<td><\/td>", "No."); //replace space to No row_ = Regex.Replace(row_, @"<sup>([^*]*?)<\/sup>", ""); //delete sup label row_ = Regex.Replace(row_, @"<[^*]*?>", "."); //delete all labels string[] each_row = Regex.Split(row_, @"\.+"); each_row = each_row.Where(x => !string.IsNullOrEmpty(x)).ToArray(); //Console.WriteLine(each_row[0]); row row_line = new row(); if (each_row.Length == 6) //make sure there is no out of index error { row_line.TranslatorLanguages = each_row[0]; row_line.NeuralTranslation = Judge(each_row[1]); row_line.Customization = Judge(each_row[2]); row_line.Transliteration = Judge(each_row[3]); row_line.Dictionary = Judge(each_row[4]); row_line.SpeechTranslation = Judge(each_row[5]); text.Add(row_line); } else { continue; } } } return(text); }
public center(int n_r,int n_s,int n_u,int n_p,int n_se){ n_row=n_r; n_slot=n_s; n_unvaliable=n_u; n_pool=n_p; n_server=n_se; rows=new List<row> (); servers=new List <server>(); for(int i=0;i<n_row;i++){ row r=new row(n_slot); rows.Add(r); } }
public center(String s){ String[] substrings = s.Split(' '); n_row=Int32.Parse(substrings[0]); n_slot=Int32.Parse(substrings[1]); n_unvaliable=Int32.Parse(substrings[2]); n_pool=Int32.Parse(substrings[3]); n_server=Int32.Parse(substrings[4]); rows=new List <row> (); servers=new List <server>(); for(int i=0;i<n_row;i++){ row r=new row(n_slot); rows.Add(r); } }
public void CoreFunction(){ for(int i=0;i<n_row;i++){ row r=rows[i]; int i=0; while(i<=n_row){ int final=r.nextPivot(i); server s=chooseServer(final-i); String ID=s.getID(); if((r.Enter(ID,i,final)==true){ s.choose(); } i=i+final+1; } } }
public bool load() { parameters q_param=generate_crud_parameters(); string query=String.Format("SELECT TOP 1 * FROM {0} WHERE {1} ",this._table,this.get_pk()); data_set res=db.fetch("titan",query,q_param); if (null!=res && null!=res.Keys && res.Keys.Length>0) { foreach (String field_name in res.Keys) { row r=res[0]; object val=r[field_name]; this.set_property(field_name,val); }//loop through all keys return true; }//if it exist return false; }//if it exist
public static void getRowGrouped(row Row, XmlWriter XWriter) { XWriter.WriteStartElement("row"); for (int x = 0; x < Row.AnyAttr.Count; x++) { XWriter.WriteAttributeString(Row.AnyAttr[x].Name, Row.AnyAttr[x].Value.ToString()); } if (Row.Any != null) { foreach (var elm in Row.Any) { XWriter.WriteRaw(elm.OuterXml); } } XWriter.WriteEndElement(); }
public table(string file_path, table_config config) { this.config = config; string[] rows = System.IO.File.ReadAllLines(file_path); int index = 0; foreach (string row in rows) { row processed_row = new row(row, config, index); items.Add(processed_row); ++index; } populate_min_max(); derive_columns(); derive_array(); derive_column_data(); }//end constructor
public IActionResult DetaljiPolaznik(int id) { List <detaljiPolaznikVM> model = db.Pohadja.Where(a => a.Polaznik_FK_ID.PolaznikID == id).Select(x => new detaljiPolaznikVM { Broj_Obnavljanja = x.Broj_Obnavljanja, kraj = x.Kraj, Obnavlja = x.Obnavlja, pocetak = x.Pocetak, kurs = db.Kurs.Where(v => v.KursID == x.KursID_FK).Select(o => o.Naziv).SingleOrDefault(), pohadjaID = x.PohadjaID }).ToList(); row model2 = new row { rows = model }; ViewData["polaznik"] = db.Polaznik.Where(y => y.PolaznikID == id).Select(c => c.Ime + " " + c.Prezime).SingleOrDefault(); ViewData["polaznikID"] = id; return(PartialView(model2)); }
//随机生成三列 //0空白,1砖块,2金币砖块,3特殊,4坚固砖块 void GenerateBrickRandom() { int spaceIndex = Random.Range(0, 4); int[] line = { 1, 1, 1, 1 }; //随机金币行 if (zyf.IfItWins(6)) { int index = Random.Range(0, 4); line[index] = 2; } //空行 line[spaceIndex] = 0; //行数据加入链表 row newRow = new row(line); rows.Enqueue(newRow); GenerateBrickLine(newRow); }
//根据数组生成方块行 void GenerateBrickLine(row _row) { for (int i = 0; i < GameManager.Instance().rowCount; i++) { int rowIndex = rowBricks.Count; //非空砖块 if (_row.types[i] > 0) { StartCoroutine(GenerateBrick(i, _row.types[i])); } } //加入方块数列 rowBricks.Enqueue(brickTemp); brickTemp = new GameObject[4]; //for (int i = 0; i < GameManager.Instance().rowCount; i++) //{ // brickTemp[i] = null; //} }
private static parts_layout_template from_string(string s) { settings_as_string sett = new settings_as_string(s); string rows = sett.get("rows"), parts = sett.get("parts"); parts_layout_template layout = new parts_layout_template(); foreach (var row_data in rows.Split(';')) { var cur_row = row_data.Split(','); Debug.Assert(cur_row.Length == 3); row r = new row(); r.label_width_ = int.Parse(cur_row[0]); r.row_width_ = int.Parse(cur_row[1]); int count = int.Parse(cur_row[2]); layout.rows_.Add(r); } foreach (var part_data in parts.Split(';')) { if (part_data == "") { continue; } var cur_part = part_data.Split(','); Debug.Assert(cur_part.Length == 6); row r = layout.rows_[int.Parse(cur_part[0])]; part p = new part(); p.type = (info_type)int.Parse(cur_part[1]); p.visible = cur_part[2] == "1"; p.multi_line = cur_part[3] == "1"; p.auto_resize = cur_part[4] == "1"; p.line_count = int.Parse(cur_part[5]); r.parts_.Add(p); } layout.name_ = sett.get("name"); return(layout); }
/// <summery> /// <typeparam name=""></typeparam> row /// <typeparam name=""></typeparam> userID /// <returns></returns> string /// </summery> public static function getActivityHTML(row, userID){ ob_start(); user = User.getUserBasicInfo(row["userID"]); owner = User.getUserBasicInfo(row["poster"]); pagePostFlag = false; if (row["pageID"] != Post.INDEPENDENT_POST_PAGE_ID) { pageIns = new Page(); pageData = pageIns.getPageByID(row["pageID"]); } if (isset(pageData)) { pagePostFlag = true; } if(pagePostFlag){ objectLink = "/page.php?pid=" + row["pageID"] + "&post=" + row["objectID"]; authorLink = "/page.php?pid=" + row["pageID"]; }else{ objectLink = "/posts.php?user="******"poster"] + "&post=" + row["objectID"]; authorLink = "/profile.php?user="******"poster"]; } if(row["activityType"] == "like"){
public ActionResult Create(FormCollection collection, HttpPostedFileBase file) { if (Session["Ad_TenDangNhap"] == null) { return(RedirectToAction("Login", "Account", null)); } string type = collection["types"]; string idtype = collection["type"]; string title = collection["title"]; string idcat = collection["cat"]; string publtime = collection["publtime"]; string code = collection["code"]; string number = collection["number"]; string from_org = collection["from_org"]; string to_org = collection["to_org"]; string de_cat = collection["de_cat"]; string de = collection["de"]; string name_signer = collection["name_signer"]; string name_initial = collection["name_initial"]; string date_iss = collection["date_iss"]; string date_first = collection["date_first"]; string date_die = collection["date_die"]; string abtract = collection["abtract"]; string note = collection["note"]; string level_important = collection["level_important"]; row data = new row(); if (file != null && file.ContentLength > 0) { // extract only the filename var fileName = Path.GetFileName(file.FileName); // store the file inside ~/App_Data/uploads folder var path = Path.Combine(Server.MapPath("~/uploads"), fileName); file.SaveAs(path); data.attach_file = fileName; } // string file = "heb"; data.title = title; data.idtype = Int32.Parse(idtype); data.type = Int32.Parse(type); data.idcat = Int32.Parse(idcat); if (publtime != "") { data.publtime = DateTime.Parse(publtime); } data.number_dispatch = code; data.number_text_come = number; data.from_org = from_org; data.to_org = to_org; data.dep_catid = Int32.Parse(de_cat); data.to_depid = Int32.Parse(de); data.name_signer = name_signer; data.name_initial = name_initial; if (date_first != "") { data.date_first = DateTime.Parse(date_first); } if (date_die != "") { data.date_die = DateTime.Parse(date_die); } data._abstract = abtract; data.note = note; data.level_important = Int32.Parse(level_important); try { db.rows.Add(data); db.SaveChanges(); return(RedirectToAction("List")); } catch (Exception e) { string x = e.InnerException.ToString(); return(RedirectToAction("Index")); } }
set => SetValue(row, value);
set => SetValue(row, col, value);
get => GetValue(row, col);
get => ValueOf(row, col);
public ActionResult Upload(HttpPostedFileBase file) { string path = Server.MapPath("~/Areas/Admin/Files/" + file.FileName); string ext = System.IO.Path.GetExtension(file.FileName); string[] nameFielCV = file.FileName.Split('.'); if (String.Compare(ext.ToLower(), "pdf") == 0) { @ViewBag.Path = "Bạn chỉ có thể tải lên file PDF"; } else { file.SaveAs(path); @ViewBag.Path = path; //@ViewBag.Path = "Test"+ExtractTextFromPdf(path); Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(path); int pageNum = pdfDoc.Pages.Count; // Response.Write("Hello--" + pageNum); XImage[] image = new XImage[pageNum]; String NoiSoanCV, SoCV, TieuDeCV, NoiDungCV, NoiNhanCV, ChuKyCV, filePath; NoiSoanCV = SoCV = TieuDeCV = NoiDungCV = NoiNhanCV = ChuKyCV = filePath = ""; Color c; for (int i = 1; i <= pageNum; i++) { Bitmap bt; UnmanagedImage sourceimage; BitmapData cloneBitmapCopyC; filePath = rootPath + file.FileName + nameFielCV[0] + i + ".bmp"; if (!System.IO.File.Exists(filePath)) { using (FileStream imageStream = new FileStream(rootPath + nameFielCV[0] + i + ".bmp", FileMode.Create)) { // Create Resolution object Resolution resolution = new Resolution(300); // Create JPEG device with specified attributes (Width, Height, Resolution, Quality) // where Quality [0-100], 100 is Maximum JpegDevice jpegDevice = new JpegDevice(resolution, 100); // Convert a particular page and save the image to stream jpegDevice.Process(pdfDoc.Pages[i], imageStream); // Close stream imageStream.Close(); } // Thao tác với bt bt = (Bitmap)Bitmap.FromFile((rootPath + nameFielCV[0] + i + ".bmp")); bt.SetResolution(192f, 192f); cloneBitmapCopyC = bt.LockBits(new System.Drawing.Rectangle(0, 114, bt.Width, bt.Height - 114), System.Drawing.Imaging.ImageLockMode.ReadWrite, bt.PixelFormat); sourceimage = new UnmanagedImage(cloneBitmapCopyC); // chuyển thành ảnh cấp xám xong Nhi Phan (Đen thành đen , Trắng Thành Trắng) for (int m = 0; m < sourceimage.Width; m++) { for (int j = 0; j < sourceimage.Height; j++) { c = sourceimage.GetPixel(m, j); //c.R = 0; // màu đen int grayScale = (int)((c.R * 0.3) + (c.G * 0.59) + (c.B * 0.11)); sourceimage.SetPixel(m, j, Color.FromArgb(c.A, grayScale, grayScale, grayScale)); if (c.R < 140) { sourceimage.SetPixel(m, j, Color.Black); } else { sourceimage.SetPixel(m, j, Color.White); } } } bt = sourceimage.ToManagedImage(); bt = Crop(bt); filePath = rootPath + nameFielCV[0] + "output_grayCV" + i + ".bmp"; if (!System.IO.File.Exists(filePath)) { FileStream output_gray = new FileStream((rootPath + nameFielCV[0] + "output_grayCV" + i + ".bmp"), FileMode.Create); bt.Save(output_gray, System.Drawing.Imaging.ImageFormat.Jpeg); output_gray.Dispose(); output_gray.Close(); } } else { // Thao tác với bt bt = (Bitmap)Bitmap.FromFile((rootPath + nameFielCV[0] + "output_grayCV" + i + ".bmp")); cloneBitmapCopyC = bt.LockBits(new System.Drawing.Rectangle(0, 0, bt.Width, bt.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, bt.PixelFormat); sourceimage = new UnmanagedImage(cloneBitmapCopyC); } sourceimage = UnmanagedImage.FromManagedImage(bt); String nameFile = ""; if (i == 1) { int ht, hs; ht = hs = 0; //Cắt tiêu đề nameFile = nameFielCV[0] + "donviSoanCV"; Dictionary <string, int> dictionaryheightDV = CropImgae(cloneBitmapCopyC, bt, sourceimage, ht, nameFile); ht = dictionaryheightDV["height"] + (int)1.3 * dictionaryheightDV["heighd"]; Bitmap dvCV = (Bitmap)Bitmap.FromFile((rootPath + nameFile + ".bmp")); NoiSoanCV = GetText(dvCV); //cắt số công văn nameFile = nameFielCV[0] + "soCV"; Dictionary <string, int> dictionaryheightSoCV = CropImgae(cloneBitmapCopyC, bt, sourceimage, ht, nameFile); ht = ht + dictionaryheightSoCV["height"]; Bitmap soCV = (Bitmap)Bitmap.FromFile((rootPath + nameFile + ".bmp")); SoCV = GetText(soCV); //cắt tiêu đề công văn nameFile = nameFielCV[0] + "TieuDeCV"; Dictionary <string, int> dictionaryheightTieuDeCV = CropImgae(cloneBitmapCopyC, bt, sourceimage, ht, nameFile); Bitmap TieuDeCVBit = (Bitmap)Bitmap.FromFile((rootPath + nameFile + ".bmp")); ht = ht + dictionaryheightTieuDeCV["height"]; if (ht > 460) { ht = ht + (int)(2 * dictionaryheightTieuDeCV["heighd"]); } TieuDeCV = GetText(TieuDeCVBit); //cắt nội dung nameFile = nameFielCV[0] + "NoiDungCV"; BitmapData cloneBitmapNoiDungCV = bt.LockBits(new System.Drawing.Rectangle(0, ht, sourceimage.Width, sourceimage.Height - ht), System.Drawing.Imaging.ImageLockMode.ReadWrite, bt.PixelFormat); UnmanagedImage titileImage = new UnmanagedImage(cloneBitmapNoiDungCV); Bitmap imgTitile = titileImage.ToManagedImage(); filePath = rootPath + nameFile + ".bmp"; if (!System.IO.File.Exists(filePath)) { FileStream output_title = new FileStream((rootPath + nameFile + ".bmp"), FileMode.Create); imgTitile.Save(output_title, System.Drawing.Imaging.ImageFormat.Jpeg); output_title.Dispose(); output_title.Close(); } Bitmap NoiDungCVBit = (Bitmap)Bitmap.FromFile((rootPath + nameFile + ".bmp")); NoiDungCV = GetText(NoiDungCVBit); } if (i == pageNum) { //cắt nơi nhận, chữ ký bool kt = false; for (int k = (int)(0.98 * bt.Height); k < bt.Height; k++) { c = sourceimage.GetPixel((int)(0.5 * bt.Width), k); if (c.R == 0) { kt = true; break; } } if (kt) { BitmapData cloneBitmapPageEnd = bt.LockBits(new System.Drawing.Rectangle(0, 0, bt.Width, bt.Height - 114), System.Drawing.Imaging.ImageLockMode.ReadWrite, bt.PixelFormat); sourceimage = new UnmanagedImage(cloneBitmapPageEnd); bt = sourceimage.ToManagedImage(); bt = Crop(bt); nameFile = nameFielCV[0] + "PageEndCV"; filePath = rootPath + nameFile + ".bmp"; if (!System.IO.File.Exists(filePath)) { FileStream PageEndCV = new FileStream((rootPath + nameFile + ".bmp"), FileMode.Create); bt.Save(PageEndCV, System.Drawing.Imaging.ImageFormat.Jpeg); PageEndCV.Dispose(); PageEndCV.Close(); } sourceimage = UnmanagedImage.FromManagedImage(bt); //bt.UnlockBits(cloneBitmapPageEnd); } //cắt chữ ký nameFile = nameFielCV[0] + "ChuKyCV"; BitmapData cloneBitmapChuKyCV = bt.LockBits(new System.Drawing.Rectangle((int)(0.5 * sourceimage.Width), (int)(0.9 * sourceimage.Height), (int)(0.4 * sourceimage.Width), sourceimage.Height - (int)(0.9 * sourceimage.Height)), System.Drawing.Imaging.ImageLockMode.ReadWrite, bt.PixelFormat); UnmanagedImage ChuKyImage = new UnmanagedImage(cloneBitmapChuKyCV); Bitmap ChuKyTitile = ChuKyImage.ToManagedImage(); ChuKyTitile = Crop(ChuKyTitile); filePath = rootPath + nameFile + ".bmp"; if (!System.IO.File.Exists(filePath)) { FileStream output_ChuKy = new FileStream((rootPath + nameFile + ".bmp"), FileMode.Create, FileAccess.ReadWrite); ChuKyTitile.Save(output_ChuKy, System.Drawing.Imaging.ImageFormat.Jpeg); output_ChuKy.Dispose(); output_ChuKy.Close(); } bt.UnlockBits(cloneBitmapChuKyCV); Bitmap ChuKyCVBit = (Bitmap)Bitmap.FromFile((rootPath + nameFile + ".bmp")); ChuKyCV = GetText(ChuKyCVBit); // cắt nơi nhận nameFile = nameFielCV[0] + "NoiNhanCV"; BitmapData cloneBitmapNoiNhanCV; if (!kt) { cloneBitmapNoiNhanCV = bt.LockBits(new System.Drawing.Rectangle(0, (int)(0.8 * (sourceimage.Height)), (int)(0.5 * sourceimage.Width), sourceimage.Height - (int)(0.8 * sourceimage.Height) - 50), System.Drawing.Imaging.ImageLockMode.ReadWrite, bt.PixelFormat); } else { cloneBitmapNoiNhanCV = bt.LockBits(new System.Drawing.Rectangle(0, (int)(0.6 * (sourceimage.Height - 10)), (int)(0.5 * sourceimage.Width), sourceimage.Height - (int)(0.6 * sourceimage.Height) - 50), System.Drawing.Imaging.ImageLockMode.ReadWrite, bt.PixelFormat); } UnmanagedImage NoiNhanImage = new UnmanagedImage(cloneBitmapNoiNhanCV); Bitmap NoiNhanTitile = NoiNhanImage.ToManagedImage(); NoiNhanTitile = Crop(NoiNhanTitile); filePath = rootPath + nameFile + ".bmp"; if (!System.IO.File.Exists(filePath)) { FileStream output_NoiNhan = new FileStream((rootPath + nameFile + ".bmp"), FileMode.Create); NoiNhanTitile.Save(output_NoiNhan, System.Drawing.Imaging.ImageFormat.Jpeg); output_NoiNhan.Dispose(); output_NoiNhan.Close(); } Bitmap NoiNhanCVBit = (Bitmap)Bitmap.FromFile((rootPath + nameFile + ".bmp")); NoiNhanCV = GetText(NoiNhanCVBit); bt.UnlockBits(cloneBitmapChuKyCV); } } //Lưu thông tin vừa cắt vào cơ sở dữ liệu row data = new row(); //NoiSoanCV, SoCV, TieuDeCV, NoiDungCV, NoiNhanCV, ChuKyCV; data.from_org = NoiSoanCV; data.number_dispatch = SoCV; data.title = TieuDeCV; data._abstract = NoiDungCV; data.to_org = NoiNhanCV; data.name_signer = ChuKyCV; data.attach_file = file.FileName; try { db.rows.Add(data); db.SaveChanges(); return(RedirectToAction("List", "CongVan")); } catch (Exception e) { string x = e.InnerException.ToString(); return(RedirectToAction("Index")); } } return(View()); }
get => GetMatrixValue(new MatrixLocation(row, column));
set => SetValue(row, column, value);
get => GetValue(row, column);
if (IsFree(row, col)) {
/// <summary>Initializes a new instance of the <see cref="Identifier" /> class.</summary> /// <param name="row">Row to create to create identifier for.</param> /// <param name="fields">The fields to use for the itentifier.</param> public Identifier(Row row, params int[] fields) => data = GetData(row, fields);
set => SetPixel(row, column, value);
private static parts_layout_template from_string(string s) { settings_as_string sett = new settings_as_string(s); string rows = sett.get("rows"), parts = sett.get("parts"); parts_layout_template layout = new parts_layout_template(); foreach (var row_data in rows.Split(';')) { var cur_row = row_data.Split(','); Debug.Assert(cur_row.Length == 3); row r = new row(); r.label_width_ = int.Parse(cur_row[0]); r.row_width_ = int.Parse(cur_row[1]); int count = int.Parse(cur_row[2]); layout.rows_.Add(r); } foreach (var part_data in parts.Split(';')) { if (part_data == "") continue; var cur_part = part_data.Split(','); Debug.Assert(cur_part.Length == 6); row r = layout.rows_[int.Parse(cur_part[0]) ]; part p = new part(); p.type = (info_type) int.Parse(cur_part[1]); p.visible = cur_part[2] == "1"; p.multi_line = cur_part[3] == "1"; p.auto_resize = cur_part[4] == "1"; p.line_count = int.Parse(cur_part[5]); r.parts_.Add(p); } layout.name_ = sett.get("name"); return layout; }
/// <summary>Initializes a new instance of the <see cref="Identifier" /> class.</summary> /// <param name="row">Row to create to create identifier for.</param> /// <param name="fields">The fields to use for the itentifier.</param> public Identifier(Row row, IEnumerable <int> fields) => data = GetData(row, fields);
SetPerTcp6ConnectionEStats(row, type, (IntPtr)mem, 0, (uint)mem.Size, 0);
public async void CSVParse() { // button1.Enabled = false; string[] csvtext = { "" }; int listid = 0; string fname = ""; if (csvfiles.Count > 0) { foreach (string csv in csvfiles) { bool expl = false; bool nocombi = true; int cmbmin = 0; int cmbmax = 0; fname = Path.GetFileName(csv); //listid = listBox1.FindString(fname); // datagrid foreach (DataGridViewRow rrow in dataGridView1.Rows) { if (rrow.Cells[1].Value.ToString().Equals(fname)) { listid = rrow.Index; break; } } dataGridView1.Rows[listid].Cells[4].Value = "working..."; //listBox1.Items[listid] = fname + " - working..."; try { await Task.Run(() => { csvtext = System.IO.File.ReadAllLines(csv); }); } catch { dataGridView1.Rows[listid].Cells[4].Value = "read file error."; //listBox1.Items[listid] = fname + " - read file error."; } if (csvtext.Length > 0) { row[] rows = new row[csvtext.Length]; int j = 0; int tmpi = 0; double tmpj = 1; //fill array from parsed file await Task.Run(() => { for (int i = 18; i < csvtext.Length; i++) { String pattern = @"[/;]"; String[] elements = Regex.Split(csvtext[i], pattern); // 0 - стержень 1 - сочетание 12 - минимум по мезусу 13 - максимум 16 - data rows[j] = new row(); if (int.TryParse(elements[0], out tmpi)) { rows[j].rod = tmpi; } else { rows[j].rod = 0; } if (int.TryParse(elements[1], out tmpi)) { rows[j].comb = tmpi; } else { rows[j].comb = 0; } if (double.TryParse(elements[12], out tmpj)) { rows[j].minstress = tmpj; } else { rows[j].minstress = 0; } if (double.TryParse(elements[13], out tmpj)) { rows[j].maxstress = tmpj; } else { rows[j].maxstress = 0; } if (elements[16] != null) { rows[j].data = elements[16]; } else { rows[j].data = ""; } j++; } }); //search max //LINQ //var query = from row tmprow in rows where tmprow.rod == 7 select tmprow; //double max =rows.Max(a => a.maxstress); //chek combi if (dataGridView1.Rows[listid].Cells[2].Value.ToString().Contains('-')) { try { string[] strrange = dataGridView1.Rows[listid].Cells[2].Value.ToString().Split('-'); int.TryParse(strrange[0].ToString(), out cmbmin); int.TryParse(strrange[1].ToString(), out cmbmax); nocombi = false; } catch { } } else { nocombi = true; } //chek explosion expl = (bool)dataGridView1.Rows[listid].Cells[3].Value; bool noresult = true; int ccrod = rows[0].rod; double maxvalue = rows[0].maxstress; int maxind = 0; maxlist = new List <string>(); for (int i = 0; i < rows.Length; i++) { if (rows[i] != null) { if (nocombi == true) { if (ccrod != rows[i].rod) { maxlist.Add(rows[maxind].rod.ToString() + ";" + rows[maxind].comb.ToString() + ";" + rows[maxind].minstress.ToString() + ";" + rows[maxind].maxstress.ToString() + ";" + rows[maxind].data); ccrod = rows[i].rod; maxvalue = rows[i].maxstress; maxind = i; } if (maxvalue < rows[i].maxstress) { maxvalue = rows[i].maxstress; maxind = i; } } else { if (rows[i].comb >= cmbmin & rows[i].comb <= cmbmax) { noresult = false; if (ccrod != rows[i].rod) { maxlist.Add(rows[maxind].rod.ToString() + ";" + rows[maxind].comb.ToString() + ";" + rows[maxind].minstress.ToString() + ";" + rows[maxind].maxstress.ToString() + ";" + rows[maxind].data); ccrod = rows[i].rod; maxvalue = rows[i].maxstress; maxind = i; } if (maxvalue < rows[i].maxstress) { maxvalue = rows[i].maxstress; maxind = i; } } } } } if (nocombi == true | noresult == false) { maxlist.Add(rows[maxind].rod.ToString() + ";" + rows[maxind].comb.ToString() + ";" + rows[maxind].minstress.ToString() + ";" + rows[maxind].maxstress.ToString() + ";" + rows[maxind].data); } //save results if (maxlist.Count > 0) { dataGridView1.Rows[listid].Cells[4].Value = "save."; //listBox1.Items[listid] = fname + " - save."; try { await Task.Run(() => { System.IO.File.WriteAllLines(Path.GetFileName(csv) + "_result.csv", maxlist); }); //excel save /* * // Загрузить Excel, затем создать новую пустую рабочую книгу * Excel.Application excelApp = new Excel.Application(); * * // Сделать приложение Excel видимым * excelApp.Visible = true; * excelApp.Workbooks.Add(); * Excel._Worksheet workSheet = excelApp.ActiveSheet; * // Установить заголовки столбцов в ячейках * workSheet.Cells[1, "A"] = "NameCompany"; * workSheet.Cells[1, "B"] = "Site"; * workSheet.Cells[1, "C"] = "Cost"; * int row = 1; * foreach (Price c in vPices) * { * row++; * workSheet.Cells[row, "A"] = c.Name; * workSheet.Cells[row, "B"] = c.Site; * workSheet.Cells[row, "C"] = c.Cost; * } * // Сохранить файл, выйти из Excel * * // убрать предупреждения!!! нужно для перезаписи * excelApp.DisplayAlerts = false; * workSheet.SaveAs(string.Format(@"{0}\Price.xlsx", Environment.CurrentDirectory)); * * excelApp.Quit(); */ } catch { dataGridView1.Rows[listid].Cells[4].Value = "save result file error."; //listBox1.Items[listid] = fname + " - save result file error."; } } else { dataGridView1.Rows[listid].Cells[4].Value = "No result."; } } } } button1.Enabled = true; }
direction(row, col)) .FirstOrDefaultTransform(x => board[x.i, x.j] is not '.', x => board[x.i, x.j], '.');
var(row, column) = tuple;