static void Main(string[] args) { if (args.Length < 2) { Console.WriteLine("Usage: ResourceTool.exe -i/e sample.xlsx"); return; } switch (args[0]) { case "-i": { var doc = new SLDocument(args[1]); doc.SelectWorksheet("Translations"); var stat = doc.GetWorksheetStatistics(); var languages = new List<string>(); for (var i = 3; i <= stat.EndColumnIndex; i++) { var lang = doc.GetCellValueAsString(2, i); var resxName = lang == "en-US" ? "Resources.resx" : string.Format("Resources.{0}.resx", lang); languages.Add(resxName); } for (var j = 0; j < languages.Count; j++) { var language = languages[j]; var resxFile = Path.Combine(RootPath, "Properties", language); var resx = new XmlDocument(); resx.Load(resxFile); for (var i = 3; i <= stat.EndRowIndex; i++) { var key = doc.GetCellValueAsString(i, 1); Console.WriteLine("{0} {1} {2}", i, key, language); var value = doc.GetCellValueAsString(i, j + 3); var node = resx.SelectSingleNode(string.Format(".//data[@name='{0}']", key)); if (node == null) { node = resx.CreateElement("data"); var name = resx.CreateAttribute("name"); name.Value = key; node.Attributes.Append(name); var xmlspace = resx.CreateAttribute("xml:space"); xmlspace.Value = "preserve"; node.Attributes.Append(xmlspace); resx.DocumentElement.AppendChild(node); var valueNode = resx.CreateElement("value"); valueNode.InnerText = value; node.AppendChild(valueNode); } else { var valueNode = node.SelectSingleNode("value"); if (valueNode == null) { valueNode = resx.CreateElement("value"); node.AppendChild(valueNode); } valueNode.InnerText = value; } } resx.Save(resxFile); } } break; case "-e": { if (File.Exists(args[1])) File.Delete(args[1]); var r = new Regex(@"Resources\.([a-z]{2}-[A-Z]{2})?\.?resx"); var doc = new SLDocument(); doc.AddWorksheet("Translations"); doc.DeleteWorksheet("Sheet1"); doc.SelectWorksheet("Translations"); doc.SetCellValue(1, 1, "Key"); doc.SetCellValue(1, 2, "Comment"); var headerStyle = doc.CreateStyle(); headerStyle.Font.Bold = true; headerStyle.SetPatternFill(PatternValues.Solid, System.Drawing.Color.LightBlue, System.Drawing.Color.LightBlue); doc.SetCellStyle(1, 1, headerStyle); doc.SetCellStyle(1, 2, headerStyle); var resxFiles = Directory.GetFiles(Path.Combine(RootPath, "Properties"), "*.resx"); var columnIndex = 3; var keys = new List<string>(); var files = resxFiles.OrderBy(n => { var l = r.Match(Path.GetFileName(n)).Groups[1].Value; return string.IsNullOrEmpty(l) ? null : n; }); foreach (var resx in files) { var lang = r.Match(Path.GetFileName(resx)).Groups[1].Value; var english = false; if (string.IsNullOrEmpty(lang)) { lang = "en-US"; english = true; } var ci = CultureInfo.GetCultureInfo(lang); doc.SetCellValue(1, columnIndex, ci.EnglishName); doc.SetCellValue(2, columnIndex, ci.Name); doc.SetCellStyle(1, columnIndex, headerStyle); doc.SetColumnWidth(columnIndex, 100); var rr = new ResXResourceReader(resx); if (english) { rr.UseResXDataNodes = true; var rowIndex = 3; foreach (DictionaryEntry entry in rr) { var key = (string) entry.Key; var node = (ResXDataNode) entry.Value; keys.Add(key); doc.SetCellValue(rowIndex, 1, key); doc.SetCellValue(rowIndex, 2, node.Comment); doc.SetCellValue(rowIndex, columnIndex, node.GetValue((ITypeResolutionService) null).ToString()); rowIndex++; } } else { rr.UseResXDataNodes = true; foreach (DictionaryEntry entry in rr) { var key = (string) entry.Key; var node = (ResXDataNode) entry.Value; var index = keys.IndexOf(key); int rowIndex; if (index == -1) { rowIndex = keys.Count; keys.Add(key); doc.SetCellValue(rowIndex, 1, key); } else { rowIndex = index + 3; } doc.SetCellValue(rowIndex, columnIndex, node.GetValue((ITypeResolutionService) null).ToString()); } } columnIndex++; } doc.AutoFitColumn(1, 2); doc.SaveAs(args[1]); } break; default: Console.WriteLine("Unknown switch {0}", args[0]); return; } }
private void button7_Click(object sender, EventArgs e) { if (listView2.Items.Count > 0) { SLDocument exc = new SLDocument(); SLStyle st = exc.CreateStyle(); st.SetFontBold(true); exc.SetCellValue("A1", "İlan ID"); exc.SetCellStyle("A1", st); exc.SetCellValue("B1", "Adı"); exc.SetCellStyle("B1", st); exc.SetCellValue("C1", "İş Telefonu"); exc.SetCellStyle("C1", st); exc.SetCellValue("D1", "Cep Telefonu"); exc.SetCellStyle("D1", st); exc.SetCellValue("E1", "Adresi"); exc.SetCellStyle("E1", st); exc.SetCellValue("F1", "Tarihi"); exc.SetCellStyle("F1", st); int ex_sira = 2; foreach (ListViewItem itemRow in listView2.Items) { string i_no = itemRow.SubItems[0].Text; string adi = itemRow.SubItems[1].Text; string istel = itemRow.SubItems[2].Text; string ceptel = itemRow.SubItems[3].Text; string adres = itemRow.SubItems[4].Text; string tarih = itemRow.SubItems[5].Text; exc.SetCellValue("A" + ex_sira, i_no); exc.SetCellValue("B" + ex_sira, adi); exc.SetCellValue("C" + ex_sira, istel); exc.SetCellValue("D" + ex_sira, ceptel); exc.SetCellValue("E" + ex_sira, adres); exc.SetCellValue("F" + ex_sira, tarih); ex_sira++; } FolderBrowserDialog fbd = new FolderBrowserDialog(); DialogResult result = fbd.ShowDialog(); string a = fbd.SelectedPath + "\\excel_çıktısı.xlsx"; exc.SaveAs(a); MessageBox.Show("Dosyanız " + a + " olarak kayıt edildi."); } else { MessageBox.Show("Çıktı Alabilecek Bilgiler Görüntülenmemiş!.."); } }
private void asdasda1() { //ilanlar tablosu ilan_id sütunu önceki işlem görmüş ilanlar eklenecek. if (listBox1.Items.Count == 0) { MessageBox.Show("Ana Menüden Aranacak Kelime Ekleyin.."); return; } sTime = DateTime.Now; AppendText(richTextBox1, Color.DarkViolet, "İşlemler Başladı.. " + sTime.ToString()); a.Clear(); button1.Enabled = false; button2.Enabled = false; textBox1.Enabled = false; for (int i = 0; i < listBox1.Items.Count; i++) { bool varmı = false; int var_adet = 0; listView1.Items.Clear(); listView3.Items.Clear(); bool adt = false; if (listBox1.Items[i].ToString().Contains("http://www.sahibinden.com/")) { stlbl.Text = "Başladı.. Aranan Sayfa: " + listBox1.Items[i].ToString(); listBox1.SetSelected(i, true); for (int ss = 0; ss <= 980; ss += 20) { string html = getHTML(listBox1.Items[i].ToString() + "?pagingOffset=" + ss); if (html.Equals("yok")) { MessageBox.Show("Bağlantıda Bir Sorun Oluştu. Alınan Tüm Bilgiler, Database'ye ve ayarları yaptıysanız Excel'e yazıldı. Tekrar Çalıştırın. Hatalı Bölüm: 1 - Giriş Seviyesi"); string exc_isim = ""; if (listBox1.Items[i].ToString().Contains("http://www.sahibinden.com/")) exc_isim = DateTime.Now.ToShortDateString() + "_" + listBox1.Items[i].ToString().Substring(listBox1.Items[i].ToString().LastIndexOf('/'), listBox1.Items[i].ToString().Length - 1) + ".xlsx"; else exc_isim = DateTime.Now.ToString().Replace(' ', '_').Replace(':', '-').Replace('/', '-') + "_" + listBox1.Items[i].ToString() + ".xlsx"; emergencySituation(exc_isim); reLoad(); return; } if (!html.Contains("<td class=\"searchResultsFirstColumn\">")) break; if (!adt) { string[] adet = html.Split(new string[] { "<div class=\"infoSearchResults\"> <div>" }, StringSplitOptions.None); string[] adet1 = adet[1].Split(new string[] { "</div>" }, StringSplitOptions.None); AppendText(richTextBox1, Color.Red, StripHTML(adet1[0]) + " " + DateTime.Now.ToString()); adt = true; } int syf = (ss / 20); syf++; AppendText(richTextBox1, Color.Red, "\"" + listBox1.Items[i].ToString() + "\" adlı sayfanın " + syf + ". sayfası işlemek için sıraya alınıyor.." + DateTime.Now.ToString()); string[] link = html.Split(new string[] { "<a class=\"classifiedTitle\" href=\"" }, StringSplitOptions.None); for (int j = 1; j < link.Length; j++) { string[] lst = link[j].Split('"'); string[] iid = lst[0].Split('-'); string[] iid1 = iid[iid.Length - 1].Split('/'); if (KontrolID(iid1[0])) { a.Add(iid1[0]); } } } } else { stlbl.Text = "Başladı.. Aranan Kelime: " + listBox1.Items[i].ToString(); listBox1.SetSelected(i, true); if (listBox1.Items[i].ToString().Contains(' ')) listBox1.Items[i].ToString().Replace(' ', '+'); for (int ss = 0; ss <= 980; ss += 20) { string html = getHTML("http://www.sahibinden.com/arama?query_text=" + listBox1.Items[i].ToString() + "&pagingOffset=" + ss); if (html.Equals("yok")) { MessageBox.Show("Bağlantıda Bir Sorun Oluştu. Alınan Tüm Bilgiler, Database'ye ve ayarları yaptıysanız Excel'e yazıldı. Tekrar Çalıştırın. Hatalı Bölüm: 1 - Giriş Seviyesi"); string exc_isim = ""; if (listBox1.Items[i].ToString().Contains("http://www.sahibinden.com/")) exc_isim = DateTime.Now.ToShortDateString() + "_" + listBox1.Items[i].ToString().Substring(listBox1.Items[i].ToString().LastIndexOf('/'), listBox1.Items[i].ToString().Length - 1) + ".xlsx"; else exc_isim = DateTime.Now.ToString().Replace(' ', '_').Replace(':', '-').Replace('/', '-') + "_" + listBox1.Items[i].ToString() + ".xlsx"; emergencySituation(exc_isim); reLoad(); return; } if (!html.Contains("<td class=\"searchResultsFirstColumn\">")) break; if (!adt) { string[] adet = html.Split(new string[] { "<div><h1>" }, StringSplitOptions.None); string[] adet1 = adet[1].Split(new string[] { "</div>" }, StringSplitOptions.None); AppendText(richTextBox1, Color.Red, StripHTML(adet1[0]) + " " + DateTime.Now.ToString()); adt = true; } int syf = (ss / 20); syf++; AppendText(richTextBox1, Color.Red, "\"" + listBox1.Items[i].ToString() + "\" adlı kelimenin " + syf + ". sayfası işlemek için sıraya alınıyor.." + DateTime.Now.ToString()); string[] link = html.Split(new string[] { "<a class=\"classifiedTitle\" href=\"" }, StringSplitOptions.None); for (int j = 1; j < link.Length; j++) { string[] lst = link[j].Split('"'); string[] iid = lst[0].Split('-'); string[] iid1 = iid[iid.Length - 1].Split('/'); if (KontrolID(iid1[0])) { a.Add(iid1[0]); } } } } MessageBox.Show(a[5].ToString()); foreach (string aa in a) { string ad = "Yok", ist = "Yok", cept = "Yok", adres = "Yok"; string info = getHTML("http://www.sahibinden.com/search.php?b%5Bsearch_text%5D=" + aa); if (info.Equals("yok")) { MessageBox.Show("Bağlantıda Bir Sorun Oluştu. Alınan Tüm Bilgiler, Database'ye ve ayarları yaptıysanız Excel'e yazıldı. Tekrar Çalıştırın. Hatalı Bölüm: 2 - ID Aramaları"); string exc_isim = ""; if (listBox1.Items[i].ToString().Contains("http://www.sahibinden.com/")) exc_isim = DateTime.Now.ToShortDateString() + "_" + listBox1.Items[i].ToString().Substring(listBox1.Items[i].ToString().LastIndexOf('/'), listBox1.Items[i].ToString().Length - 1) + ".xlsx"; else exc_isim = DateTime.Now.ToString().Replace(' ', '_').Replace(':', '-').Replace('/', '-') + "_" + listBox1.Items[i].ToString() + ".xlsx"; emergencySituation(exc_isim); reLoad(); return; } giris_say++; listBox2.Items.Add(giris_say.ToString()); if (info.Contains("<td class=\"searchResultsSmallThumbnail\">") || info.Contains("18 yaş altı kişilerin girmesi yasaktır.")) { AppendText(richTextBox1, Color.DarkBlue, "hatalı ilan"); continue; } if (info.Contains("Güvenlik Kontrolü")) { /*AppendText(richTextBox1, Color.Red, "Güvenlik Protokolü. Modeminizi Yeniden Başlatın. Captcha Kontrolü Başladı."); string exc_isim = ""; if (listBox1.Items[i].ToString().Contains("http://www.sahibinden.com/")) exc_isim = DateTime.Now.ToShortDateString() + "_" + listBox1.Items[i].ToString().Substring(listBox1.Items[i].ToString().LastIndexOf('/'), listBox1.Items[i].ToString().Length - 1) + ".xlsx"; else exc_isim = DateTime.Now.ToString().Replace(' ', '_').Replace(':', '-').Replace('/', '-') + "_" + listBox1.Items[i].ToString() + ".xlsx"; emergencySituation(exc_isim); return;*/ Process.Start("IExplore.exe", "http://www.sahibinden.com/ilan/emlak-konut-satilik-sahibinden-katta-tek-deniz-manzarali-3-plus1-ici-sifir-130-m2-161857851/detay/"); MessageBox.Show("Güvenlik Kontrolü Çıktı. Explorer'dan Giriş Yaptıktan Sonra Tamam'a Basın."); } if (info.Contains("<ul class=\"userContactInfo\">")) { string[] d1 = info.Split(new string[] { "</ul>" }, StringSplitOptions.None); string[] dd = info.Split(new string[] { "<span>" }, StringSplitOptions.None); for (int t = 1; t < dd.Length; t++) { string[] dd1 = dd[t].Split('<'); if (dd1[0].Contains("0 (5")) cept = dd1[0]; else ist = dd1[0]; } } if (info.Contains("classifiedUserContent")) { string[] dd = info.Split(new string[] { "<h5>" }, StringSplitOptions.None); string[] dd1 = dd[1].Split('<'); ad = dd1[0]; } string[] adr = info.Split(new string[] { "<div class=\"classifiedInfo\">" }, StringSplitOptions.None); string[] adr1 = adr[1].Split(new string[] { "<ul class=\"classifiedInfoList\">" }, StringSplitOptions.None); string[] adr2 = adr1[0].Split(new string[] { "\">" }, StringSplitOptions.None); string adres_tut = ""; for (int s = 1; s < adr2.Length; s++) { string[] cc = adr2[s].Split('<'); cc[0] = cc[0].Trim(); if (s != adr2.Length - 1) adres_tut += cc[0] + " / "; else adres_tut += cc[0]; } adres = adres_tut; bool yeni_kisi = false; MessageBox.Show(ist + " - " + cept + " - " + adres_tut + " - " + ad); if (!ist.Equals("Yok") && !cept.Equals("Yok")) { OleDbCommand sorgu = new OleDbCommand("SELECT * from sh where ceptel ='" + cept + "' or istel='" + ist + "'", conn); conn.Open(); if (sorgu.ExecuteScalar() == null) yeni_kisi = true; conn.Close(); } if (ist.Equals("Yok") && !cept.Equals("Yok")) { OleDbCommand sorgu = new OleDbCommand("SELECT * from sh where ceptel ='" + cept + "'", conn); conn.Open(); if (sorgu.ExecuteScalar() == null) yeni_kisi = true; conn.Close(); } if (!ist.Equals("Yok") && cept.Equals("Yok")) { OleDbCommand sorgu = new OleDbCommand("SELECT * from sh where istel ='" + ist + "'", conn); conn.Open(); if (sorgu.ExecuteScalar() == null) yeni_kisi = true; conn.Close(); } if (yeni_kisi) { varmı = true; var_adet++; listView1.Items.Add(new ListViewItem(new string[] { aa, ad, ist, cept, adres })); listView3.Items.Add(new ListViewItem(new string[] { ad, cept })); AppendText(richTextBox1, Color.DarkBlue, StripHTML(aa) + " ID'li ilandaki " + ad.ToUpper() + " isimli kişi veritabanına eklendi."); ilanIDEkle(aa); Ekle(aa, ad, ist, cept, adres, listBox1.Items[i].ToString()); data_say++; toolStripStatusLabel5.Text = "Toplam " + data_say.ToString() + " adet yeni data işlendi."; } } if (!varmı) AppendText(richTextBox1, Color.DarkGreen, "\"" + listBox1.Items[i].ToString() + "\" adlı kelimede yeni ilan yok."); else AppendText(richTextBox1, Color.DarkGreen, "\"" + listBox1.Items[i].ToString() + "\" adlı kelimede yeni " + var_adet + " ilan bulundu."); //tamamen bittiğinde bu satırdayız. //excele kaydet vsvs bool tarih = false, id = false, badi = false, bistel = false, bceptel = false, badres = false; if (varmı)//yeni ilan varsa işle if (checkBox1.Checked) { SLDocument exc = new SLDocument(); SLStyle st = exc.CreateStyle(); st.SetFontBold(true); if (checkBox7.Checked) { tarih = true; exc.SetCellValue("A1", "İlan Tarihi"); exc.SetCellStyle("A1", st); } if (checkBox2.Checked) { id = true; exc.SetCellValue("B1", "İlan ID"); exc.SetCellStyle("B1", st); } if (checkBox3.Checked) { badi = true; exc.SetCellValue("C1", "Adı"); exc.SetCellStyle("C1", st); } if (checkBox4.Checked) { bistel = true; exc.SetCellValue("D1", "İş Telefonu"); exc.SetCellStyle("D1", st); } if (checkBox5.Checked) { bceptel = true; exc.SetCellValue("E1", "Cep Telefonu"); exc.SetCellStyle("E1", st); } if (checkBox6.Checked) { badres = true; exc.SetCellValue("F1", "Adresi"); exc.SetCellStyle("F1", st); } int ex_sira = 2; foreach (ListViewItem itemRow in listView1.Items) { string i_no = itemRow.SubItems[0].Text; string adi = itemRow.SubItems[1].Text; string istel = itemRow.SubItems[2].Text; string ceptel = itemRow.SubItems[3].Text; string adres = itemRow.SubItems[4].Text; if (tarih) exc.SetCellValue("A" + ex_sira, DateTime.Now.ToShortDateString()); if (id) exc.SetCellValue("B" + ex_sira, i_no); if (badi) exc.SetCellValue("C" + ex_sira, adi); if (bistel) exc.SetCellValue("D" + ex_sira, istel); if (bceptel) exc.SetCellValue("E" + ex_sira, ceptel); if (badres) exc.SetCellValue("F" + ex_sira, adres); ex_sira++; } if (exc.GetCellValueAsString("A1") == "") exc.HideColumn("A"); if (exc.GetCellValueAsString("B1") == "") exc.HideColumn("B"); if (exc.GetCellValueAsString("C1") == "") exc.HideColumn("C"); if (exc.GetCellValueAsString("D1") == "") exc.HideColumn("D"); if (exc.GetCellValueAsString("E1") == "") exc.HideColumn("E"); string exc_isim = ""; if (listBox1.Items[i].ToString().Contains("http://www.sahibinden.com/")) exc_isim = DateTime.Now.ToShortDateString() + "_" + listBox1.Items[i].ToString().Substring(listBox1.Items[i].ToString().LastIndexOf('/'), listBox1.Items[i].ToString().Length - 1) + ".xlsx"; else exc_isim = DateTime.Now.ToString().Replace(' ', '_').Replace(':', '-').Replace('/', '-') + "_" + listBox1.Items[i].ToString() + ".xlsx"; exc.SaveAs(exc_isim); AppendText(richTextBox1, Color.DarkOrange, "\"" + listBox1.Items[i].ToString() + "\" adlı kelimenin sonuçları " + exc_isim + " adlı excel dosyasına yazıldı."); } } button1.Enabled = true; button2.Enabled = true; textBox1.Enabled = true; stlbl.Text = "İşlemler Tamamlandı. Beklemede.."; AppendText(richTextBox1, Color.DarkSlateBlue, "Toplam " + data_say.ToString() + " adet data işlemden geçti."); AppendText(richTextBox1, Color.DarkViolet, calcTimeDiff(sTime, DateTime.Now).ToString()); ts_adet.Text = getAdet().ToString() + " Adet Kayıt Bulunmaktadır."; listBox2.Items.Add(giris_say.ToString()); }
private void emergencySituation(string dadi) { AppendText(richTextBox1, Color.DarkSlateBlue, "Toplam " + data_say.ToString() + " adet data işlemden geçti."); ts_adet.Text = getAdet().ToString() + " Adet Kayıt Bulunmaktadır."; if (checkBox1.Checked && listView1.Items.Count > 0) { bool tarih = false, id = false, badi = false, bistel = false, bceptel = false, badres = false; SLDocument exc = new SLDocument(); SLStyle st = exc.CreateStyle(); st.SetFontBold(true); if (checkBox7.Checked) { tarih = true; exc.SetCellValue("A1", "İlan Tarihi"); exc.SetCellStyle("A1", st); } if (checkBox2.Checked) { id = true; exc.SetCellValue("B1", "İlan ID"); exc.SetCellStyle("B1", st); } if (checkBox3.Checked) { badi = true; exc.SetCellValue("C1", "Adı"); exc.SetCellStyle("C1", st); } if (checkBox4.Checked) { bistel = true; exc.SetCellValue("D1", "İş Telefonu"); exc.SetCellStyle("D1", st); } if (checkBox5.Checked) { bceptel = true; exc.SetCellValue("E1", "Cep Telefonu"); exc.SetCellStyle("E1", st); } if (checkBox6.Checked) { badres = true; exc.SetCellValue("F1", "Adresi"); exc.SetCellStyle("F1", st); } int ex_sira = 2; foreach (ListViewItem itemRow in listView1.Items) { string i_no = itemRow.SubItems[0].Text; string adi = itemRow.SubItems[1].Text; string istel = itemRow.SubItems[2].Text; string ceptel = itemRow.SubItems[3].Text; string adres = itemRow.SubItems[4].Text; if (tarih) exc.SetCellValue("A" + ex_sira, DateTime.Now.ToShortDateString()); if (id) exc.SetCellValue("B" + ex_sira, i_no); if (badi) exc.SetCellValue("C" + ex_sira, adi); if (bistel) exc.SetCellValue("D" + ex_sira, istel); if (bceptel) exc.SetCellValue("E" + ex_sira, ceptel); if (badres) exc.SetCellValue("F" + ex_sira, adres); ex_sira++; } if (exc.GetCellValueAsString("A1") == "") exc.HideColumn("A"); if (exc.GetCellValueAsString("B1") == "") exc.HideColumn("B"); if (exc.GetCellValueAsString("C1") == "") exc.HideColumn("C"); if (exc.GetCellValueAsString("D1") == "") exc.HideColumn("D"); if (exc.GetCellValueAsString("E1") == "") exc.HideColumn("E"); string exc_isim = dadi + ".xlsx"; exc.SaveAs(exc_isim); } }