protected void btnUpload_Click(object sender, EventArgs e) { WordFileToRead.SaveAs(Server.MapPath(WordFileToRead.FileName)); object filename = Server.MapPath(WordFileToRead.FileName); Microsoft.Office.Interop.Word.ApplicationClass AC = new Microsoft.Office.Interop.Word.ApplicationClass(); Microsoft.Office.Interop.Word.Document doc = new Microsoft.Office.Interop.Word.Document(); object readOnly = false; object isVisible = true; object missing = System.Reflection.Missing.Value; try { doc = AC.Documents.Open(ref filename, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref isVisible, ref missing, ref missing, ref missing); StringReader sr = new StringReader(doc.Content.Text); string[] NameSurname1 = doc.Content.Text.Split('\r'); string fullname = NameSurname1[0]; string[] name = fullname.Split(); if (name.Length == 3) { txtFname.Text = name[0]; txtLname.Text = name[2]; } else { txtFname.Text = name[0]; txtLname.Text = name[1]; } const string MatchPhonePattern = @"\(?\d{3}\)?-? *\d{3}-? *-?\d{4}"; Regex rx = new Regex(MatchPhonePattern, RegexOptions.Compiled | RegexOptions.IgnoreCase); // Find matches. MatchCollection matches = rx.Matches(doc.Content.Text); // Report the number of matches found. int noOfMatches = matches.Count; // Report on each match. // string tempPhoneNumbers = ""; foreach (Match match in matches) { txtphoneNo.Text = txtphoneNo.Text + match.Value.ToString(); } const string MatchEmailPattern = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"; Regex rx1 = new Regex(MatchEmailPattern, RegexOptions.Compiled | RegexOptions.IgnoreCase); // Find matches. MatchCollection matches1 = rx1.Matches(doc.Content.Text); // Report the number of matches found. int noOfMatches1 = matches1.Count; // Report on each match. string tempemail = ""; foreach (Match match1 in matches1) { txtEmail.Text = txtEmail.Text + match1.Value.ToString(); } const string Zipcode = @"\d{5}"; Regex rxzipcode = new Regex(Zipcode, RegexOptions.Compiled | RegexOptions.IgnoreCase); // Find matches. MatchCollection matcheszip = rxzipcode.Matches(doc.Content.Text); // Report the number of matches found. int mat = matcheszip.Count; // Report on each match. foreach (Match match2 in matcheszip) { txtZip.Text = txtZip.Text + match2.Value.ToString(); } } catch (Exception ex) { } }
public void btnUpload_Click(object sender, EventArgs e) { try { WordFileToRead.SaveAs(Server.MapPath(WordFileToRead.FileName)); object filename = Server.MapPath(WordFileToRead.FileName); Word.Application AC = new Word.Application(); Word.Document doc = new Word.Document(); object missing = System.Reflection.Missing.Value; doc = AC.Documents.Open(ref filename); foreach (Word.Paragraph objParagraph in doc.Paragraphs) { data1.Add(objParagraph.Range.Text.Trim()); //Tez yazı stili fontFamly.Add(objParagraph.Range.Font.Name); } ListBox1.Items.Add(SayfaBoyut(doc)); ListBox1.Items.Add(sayfaKenarBosluklari(doc)); ((Word.Document)doc).Close(); ((Word.Application)AC).Quit(); for (int i = 0; i < data1.Count; i++) { if (data1[i].ToString() != "" && data1[i].ToString() != " " && data1[i].ToString() != "" && data1[i].ToString() != "/" && data1[i].ToString() != "/r") { data.Add(data1[i].ToString().Trim()); } } //Fontfamly listboxa yazdırma string[] font = fontFamly.Distinct().ToArray(); for (int i = 0; i < font.Length; i++) { ListBox1.Items.Add("Tezde bu yazı fontları kullanılmıştır: " + font[i]); } string karakter = null; string tektirnak = null; string[] duzen = { "ÖNSÖZ", "İÇİNDEKİLER", "ÖZET", "ABSTRACT", "1.GİRİŞ", "5.BULGULAR VE TARTIŞMA", "6.SONUÇLAR", "KAYNAKLAR", "ÖZGEÇMİŞ" }; //İçindekiler tablosu ListBox1.Items.Add(Icindekiler(data)); ListBox1.Items.Add(KaynakcaSiralamaKontrolu(data).ToString()); ListBox1.Items.Add(OnaylananTezBaslikKontrolu(data)); ListBox1.Items.Add(TezJuriCheck(data)); ListBox1.Items.Add(TablolarListesi(data, "ŞEKİLLER LİSTESİ", "TABLOLAR LİSTESİ", "Şekil")); ListBox1.Items.Add(TablolarListesi(data, "TABLOLAR LİSTESİ", "EKLER LİSTESİ", "Tablo")); ListBox1.Items.Add(TablolarListesi(data, "EKLER LİSTESİ", "SİMGELER VE KISALTMALAR", "Ek")); ListBox1.Items.Add(tezDuzenKontrol(data, duzen)); ListBox1.Items.Add(AnahtarKelimeAra(data)); ListBox1.Items.Add(KeywordsCheck(data)); //Karakter ara char[] chr = { '{', '}', '(', ')', '[', ']' }; for (int a = 0; a < chr.Length; a += 2) { for (int i = 0; i < data.Count; i++) { karakter = karakterAra(data[i], chr[a], chr[a + 1]); if (karakter != null) { ListBox1.Items.Add(karakter); } } } //Tektırnak ara for (int i = 0; i < data.Count; i++) { tektirnak = tirnakKontrolu(data[i], '"'); if (tektirnak != null) { ListBox1.Items.Add(tektirnak); } } ListBox1.Items.Add(KeywordsCheck(data)); ListBox1.Items.Add(onsozKontrol(data)); ListBox1.Items.Add(tirnakKelime(data)); ListBox1.Items.Add(kaynakAtıf(data)); } catch (Exception) { ListBox1.Items.Add("Bir hata meydana geldi sayfayı yenileyip tekrar deneyiniz!!!"); } }