public ActionResult PreviewMultiple(Guid UN) { IEWSList ilist = new BsEWSList(); IWord iword = new BsWord(); CurrentList = ilist.GetList(UN, GetCurrentUser().ID, true); foreach (var item in CurrentList.EWSListWord) { if (item.EWSWord.Description == null) { EWSWord word = new EWSWord(); Translator t = new Translator(); string TranslateText = item.EWSWord.WordBody.Trim(); string result = t.Translate(TranslateText, "English", "Turkish"); word.UN = item.EWSWord.UN; word.UserID = item.EWSWord.UserID; word.Description = result; word.WordBody = item.EWSWord.WordBody; item.EWSWord.Description = result; word = iword.WordSave(word); } item.EWSWord.CurrentSequence = CurrentSequence; } return(PartialView(CurrentList)); }
public ActionResult NewWordAsListMember(string wordbody, string description, Guid ListUN) { IWord iword = new BsWord(); ViewBag.Title = "New Word"; //kelime var mı kontrol et.varsa ekleme. EWSWord word = iword.GetWordByBody(wordbody); if (word != null) { return(Script("Message('Bu Kelime Zaten Var.','info');")); } EWSWord wrd = new EWSWord() { UN = new Guid(), Description = description, WordBody = wordbody, UserID = GetCurrentUser().ID, }; EWSListWord listWord = new EWSListWord() { UN = Guid.NewGuid(), isPublic = false, ListUN = ListUN, WordUN = wrd.UN }; iword.WordSaveAsListMember(wrd, listWord); return(Script("Message('Kelime Eklendi','success');")); }
public ActionResult UploadSozluk() { if (Request.Files.Count > 0) { HttpFileCollectionBase files = Request.Files; string filename = Path.GetFileName(Request.Files[0].FileName); HttpPostedFileBase file = files[0]; string fname; if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER") { string[] testfiles = file.FileName.Split(new char[] { '\\' }); fname = testfiles[testfiles.Length - 1]; } else { fname = file.FileName; } List <EWSWord> listOfWord = new List <EWSWord>(); if ((file != null) && (file.ContentLength > 0) && !string.IsNullOrEmpty(file.FileName)) { string fileName = file.FileName; string fileContentType = file.ContentType; byte[] fileBytes = new byte[file.ContentLength]; var data = file.InputStream.Read(fileBytes, 0, Convert.ToInt32(file.ContentLength)); using (var package = new ExcelPackage(file.InputStream)) { var currentSheet = package.Workbook.Worksheets; ExcelWorksheet workSheet = currentSheet.First(); var noOfCol = workSheet.Dimension.End.Column; var noOfRow = workSheet.Dimension.End.Row; string word; string mean; for (int rowIterator = 2; rowIterator <= noOfRow; rowIterator++) { word = (workSheet.Cells[rowIterator, 1].Value == null) ? "" : workSheet.Cells[rowIterator, 1].Value.ToString(); mean = ((workSheet.Cells[rowIterator, 2].Value == null) ? "" : workSheet.Cells[rowIterator, 2].Value.ToString()).ToUpper(); EWSWord w = new EWSWord(); w.WordBody = word.ToLowerInvariant(); w.Description = mean.ToLowerInvariant(); listOfWord.Add(w); } // for end } //using end } //if end IWord iWord = new BsWord(); iWord.SaveWordMultiple(listOfWord, "", GetCurrentUser().ID); } return(Script("Message('Sözlük Kayıt Edildi','success');")); }
public ActionResult TranslateText(string TranslateText) { IWord iword = new BsWord(); Translator t = new Translator(); TranslateText = TranslateText.Trim(); TranslateText = TranslateText.Replace("\n", ""); TranslateText = TranslateText.Replace("\r", ""); string result = t.Translate(TranslateText, "English", "Turkish"); //varsa kelimeyi getir. Yoksa yeni yaratıp gönder. EWSWord word = iword.GetWordByBody(TranslateText); if (word != null) { //word.Description = result; return(PartialView("WordDetail", word)); } EWSWord w = new EWSWord() { Description = result, WordBody = TranslateText, }; return(PartialView("WordDetail", w)); }
public JsonResult TranslateTextJson(string TranslateText) { IWord iword = new BsWord(); Translator t = new Translator(); TranslateText = TranslateText.Trim(); TranslateText = TranslateText.Replace("\n", ""); TranslateText = TranslateText.Replace("\r", ""); string result = t.Translate(TranslateText, "English", "Turkish"); EWSWord w = new EWSWord(); //varsa kelimeyi getir. Yoksa yeni yaratıp gönder. EWSWord word = iword.GetWordByBody(TranslateText); if (word != null) { w.UN = word.UN; w.WordBody = word.WordBody; w.Description = result; } else { w.Description = result; w.WordBody = TranslateText; } return(Json(w, JsonRequestBehavior.AllowGet)); }
public JsonResult GetWordByListID(Guid listID, int rownumber, string type) { IWord iword = new BsWord(); EWSWord w = iword.GetWordByEWSListWordID(listID, rownumber, type, GetCurrentUser().ID); return(Json(w, JsonRequestBehavior.AllowGet)); }
public ActionResult GetWordByUN(Guid UN) { IWord iword = new BsWord(); EWSWord w = iword.GetWordById(UN, GetCurrentUser().ID, false); return(PartialView("Word", w)); }
public JsonResult GetListWordBySequenceNo(string leftright) { try { IWord iword = new BsWord(); if (leftright == "") { CurrentSequence = 1; } if (leftright == "left") { CurrentSequence--; } else if (leftright == "right") { CurrentSequence++; } if (CurrentSequence <= 0) { CurrentSequence++; // eski değerine getir return(null); } if (CurrentSequence > CurrentList.EWSListWord.Count()) { CurrentSequence--; // eski değerine getir return(null); } EWSWord word = iword.GetWordById(((Guid)CurrentList.EWSListWord.Where(p => p.Number == CurrentSequence).FirstOrDefault().WordUN), GetCurrentUser().ID, false); if (word != null) { if (word.Description == null) { Translator t = new Translator(); string TranslateText = word.WordBody.Trim(); string result = t.Translate(TranslateText, "English", "Turkish"); word.Description = result; word = iword.WordSave(word); } word.CurrentSequence = CurrentSequence; } return(Json(word, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { throw ex; } }
public ActionResult RemoveIWillLearn(Guid wordID) { IEWSList ilist = new BsEWSList(); ilist.RemoveIWillLearn(wordID, GetCurrentUser().ID); IWord iword = new BsWord(); EWSWord w = iword.GetWordById(wordID, GetCurrentUser().ID, false); ViewBag.FromDetail = true; return(PartialView("../EWSWords/Word", w)); }
public ActionResult UpdateWord(Guid UN, string wordbody, string description) { IWord iword = new BsWord(); EWSWord wrd = new EWSWord() { UN = UN, Description = description, //WordBody = wordbody, }; wrd = iword.WordSave(wrd); return(Script("Message('Kelime Güncellendi','success');")); }
public EWSWord GetWordByBody(string wordBody) { IRepositoryBase <EWSWord> _rep = new RepositoryBase <EWSWord>(); IRepositoryBase <EWSKnownWords> _repKnown = new RepositoryBase <EWSKnownWords>(); EWSWord word = _rep.Get(p => p.WordBody == wordBody); if (word != null) { EWSKnownWords known = _repKnown.Get(p => p.WordUN == word.UN); if (known != null) { word.Known = true; } } return(word); }
public ActionResult GetWordDetailByUN(Guid UN) { IWord iword = new BsWord(); EWSWord word = iword.GetWordById(UN, GetCurrentUser().ID); if (word.Description == null) { Translator t = new Translator(); string TranslateText = word.WordBody.Trim(); string result = t.Translate(TranslateText, "English", "Turkish"); word.Description = result; //word = iword.WordSave(word); } return(PartialView("WordDetail", word)); }
public EWSWord WordSave(EWSWord word) { RepositoryBase <EWSWord> _rep = new RepositoryBase <EWSWord>(); if (word.UN == new Guid()) { word.UN = Guid.NewGuid(); word.CreatedDate = DateTime.Now; return(_rep.Add(word)); } else { EWSWord w = _rep.Get(p => p.UN == word.UN); w.Description = word.Description; return(_rep.Update(w)); } }
/// <summary> /// Gets word by ID /// </summary> /// <param name="ID"></param> /// <returns></returns> public EWSWord GetWordById(Guid ID, int userID, bool ProxyCreationEnabled = true) { RepositoryBase <EWSWord> _rep = new RepositoryBase <EWSWord>(ProxyCreationEnabled); RepositoryBase <EWSSampleSentence> _repSen = new RepositoryBase <EWSSampleSentence>(ProxyCreationEnabled); RepositoryBase <EWSKnownWords> _repKnown = new RepositoryBase <EWSKnownWords>(false); RepositoryBase <EWSWillLearn> _repWillLearn = new RepositoryBase <EWSWillLearn>(false); EWSWord wrd = _rep.Get(p => p.UN == ID); //bilinenler listesinde var mı kontrol et. EWSKnownWords known = _repKnown.Get(p => p.WordUN == wrd.UN && p.UserID == userID); if (known != null) { wrd.Known = true; wrd.WillLearn = false; } else { wrd.Known = false; } if (wrd.Known == false) { //bilinenler listesinde var mı kontrol et. EWSWillLearn willLearn = _repWillLearn.Get(p => p.WordUN == wrd.UN && p.UserID == userID); if (willLearn != null) { wrd.WillLearn = true; } else { wrd.WillLearn = false; } } //EWSSampleSentence sample = wrd.EWSSampleSentence.FirstOrDefault(); //sample.WordUN = wrd.UN; //_repSen.Add(sample); return(_rep.Get(p => p.UN == ID)); }
public void WordSaveAsListMember(EWSWord word, EWSListWord listWord) { RepositoryBase <EWSWord> _rep = new RepositoryBase <EWSWord>(); RepositoryBase <EWSListWord> _repListWord = new RepositoryBase <EWSListWord>(); if (word.UN == new Guid()) { word.UN = Guid.NewGuid(); word = _rep.Add(word); } else { word = _rep.Update(word); } listWord.WordUN = word.UN; _repListWord.Add(listWord); }
public ActionResult WordSave(string wordbody, string description) { IWord iword = new BsWord(); ViewBag.Title = "New Word"; //kelime var mı kontrol et.varsa ekleme. EWSWord wrd = iword.GetWordByBody(wordbody); if (wrd != null) { wrd.WordBody = wordbody; wrd.Description = description; ViewBag.Message = "Kelime zaten kayıtlıydı Güncellendi."; ViewBag.MessageType = "info"; return(PartialView()); } if (wrd == null) { wrd = new EWSWord() { UN = new Guid(), Description = description, WordBody = wordbody, UserID = GetCurrentUser().ID, AddType = 2 } } ; iword.WordSave(wrd); ViewBag.Message = "Kelime Kayıt Edildi"; ViewBag.MessageType = "success"; return(PartialView()); }
public ActionResult SetIKnow(Guid wordID) { IEWSList ilist = new BsEWSList(); IWord iword = new BsWord(); ilist.SetIKnowWord(wordID, GetCurrentUser().ID); EWSWord word = iword.GetWordById(wordID, GetCurrentUser().ID); if (word.Description == null) { Translator t = new Translator(); string TranslateText = word.WordBody.Trim(); string result = t.Translate(TranslateText, "English", "Turkish"); word.Description = result; //word = iword.WordSave(word); } ViewBag.FromDetail = true; return(PartialView("../EWSWords/Word", word)); }
public ActionResult NewWord(string wordbody, string description) { IWord iword = new BsWord(); ViewBag.Title = "New Word"; //kelime var mı kontrol et.varsa ekleme. EWSWord word = iword.GetWordByBody(wordbody); if (word != null) { return(Script("Message('Bu Kelime Zaten Var.','info');")); } EWSWord wrd = new EWSWord() { UN = new Guid(), Description = description, WordBody = wordbody, UserID = GetCurrentUser().ID, }; //EWSSampleSentence sentence = new EWSSampleSentence() //{ // Sentence = samplesentence, // WordUN=wrd.UN, // UserID=CurrentUser.ID, // SentenceMean=samplesentenceMean, //}; //wrd.EWSSampleSentence.Add(sentence); wrd = iword.WordSave(wrd); return(Script("Message('Kelime Eklendi','success');")); }
public void SaveReadPart(string fileName, int UserID, string fullText, string html) { IRepositoryBase <EWSReadPart> _repReadPart = new RepositoryBase <EWSReadPart>(); IRepositoryBase <EWSList> _repList = new RepositoryBase <EWSList>(); IRepositoryBase <EWSWord> _repWord = new RepositoryBase <EWSWord>(); IRepositoryBase <EWSListWord> _repListWord = new RepositoryBase <EWSListWord>(); string textLine = string.Empty; string FullBody = string.Empty; string preFixFile = string.Empty; if (fileName.Contains(".")) { string[] preFileName = fileName.Split('.'); if (preFileName != null && preFileName.Count() > 0) { preFixFile = preFileName[0]; } } else { preFixFile = fileName; } //önce listeyi kaydet. EWSList list = new EWSList() { Name = preFixFile, UN = Guid.NewGuid(), UserID = UserID, }; list = _repList.Add(list); //read part kaydet EWSReadPart readPart = new EWSReadPart() { UN = Guid.NewGuid(), ListUN = list.UN, UserID = UserID, ReadPart = fullText, Name = preFixFile, ReadPartHtml = html }; readPart = _repReadPart.Add(readPart); string desen = @"([A-z])\w+"; var matches = Regex.Matches(fullText, desen); foreach (var item in matches) { string w = item.ToString(); // önce sorgula. varsa ekleme.yoksa ekle. EWSWord word = _repWord.Get(p => p.WordBody == w); if (word == null) { word = new EWSWord() { UN = Guid.NewGuid(), UserID = UserID, WordBody = item.ToString(), }; Translator t = new Translator(); string TranslateText = word.WordBody.Trim(); string result = t.Translate(TranslateText, "English", "Turkish"); word.Description = result; //if (word.WordBody != word.Description) word = _repWord.Add(word); } //varsa ekleme EWSListWord listWord = _repListWord.Get(p => p.ListUN == list.UN && p.WordUN == word.UN); // list word kaydet if (listWord == null) { EWSListWord lWord = new EWSListWord() { UN = Guid.NewGuid(), isPublic = false, ListUN = list.UN, WordUN = word.UN, }; _repListWord.Add(lWord); } } }
public void SaveWordMultiple(List <EWSWord> listOfWord, string listName, int userID) { IRepositoryBase <EWSWord> _rep = new RepositoryBase <EWSWord>(); IRepositoryBase <EWSSampleSentence> _repSamp = new RepositoryBase <EWSSampleSentence>(); IRepositoryBase <EWSList> _repList = new RepositoryBase <EWSList>(); IRepositoryBase <EWSListWord> _repListWord = new RepositoryBase <EWSListWord>(); string lName = ""; if (listName.Contains(".")) { string[] preFileName = listName.Split('.'); if (preFileName != null && preFileName.Count() > 0) { lName = preFileName[0]; } } else { lName = listName; } if (listOfWord == null || listOfWord.Count == 0) { return; } List <EWSWord> wordList = new List <EWSWord>(); EWSList list = new EWSList() { UN = Guid.NewGuid(), Name = lName, UserID = userID, }; if (userID == 1) { list.UserID = null; } list = _repList.Add(list); Translator t = new Translator(); foreach (var item in listOfWord) { EWSWord w = _rep.Get(p => p.WordBody == item.WordBody); if (w == null) { if (item.WordBody != null || item.Description == "") { string TranslateText = item.WordBody.Trim(); string result = t.Translate(TranslateText, "English", "Turkish"); item.Description = result; } w = new EWSWord() { UN = Guid.NewGuid(), WordBody = item.WordBody, UserID = userID, Description = item.Description }; w = _rep.Add(w); wordList.Add(w); foreach (var itemSamp in item.EWSSampleSentence) { if (itemSamp.Sentence != "" && itemSamp.SentenceMean == "") { itemSamp.Sentence = itemSamp.Sentence.Replace("\\n", ""); itemSamp.Sentence = itemSamp.Sentence.Replace("\\r", ""); string TranslateText = itemSamp.Sentence.Trim(); string result = t.Translate(TranslateText, "English", "Turkish"); itemSamp.SentenceMean = result; } EWSSampleSentence samp = new EWSSampleSentence() { Sentence = itemSamp.Sentence, UserID = itemSamp.UserID, SentenceMean = itemSamp.SentenceMean, UN = Guid.NewGuid(), WordUN = w.UN, }; _repSamp.Add(samp); } } else if (item.EWSSampleSentence != null) { wordList.Add(w); foreach (var itemSamp in item.EWSSampleSentence) { EWSSampleSentence samp = new EWSSampleSentence() { Sentence = itemSamp.Sentence, UserID = itemSamp.UserID, SentenceMean = itemSamp.SentenceMean, UN = Guid.NewGuid(), WordUN = w.UN, }; _repSamp.Add(samp); } } } foreach (var item in wordList) { EWSListWord listWrd = _repListWord.Get(p => p.WordUN == item.UN && p.ListUN == list.UN); if (listWrd != null) { continue; } listWrd = new EWSListWord() { UN = Guid.NewGuid(), WordUN = item.UN, ListUN = list.UN, isPublic = false, }; _repListWord.Add(listWrd); } }
public EWSWord GetWordByEWSListWordID(Guid listID, int rownumber, string type, int userID) { rownumber--; RepositoryBase <EWSWord> _rep = new RepositoryBase <EWSWord>(false); RepositoryBase <EWSListWord> _repListWord = new RepositoryBase <EWSListWord>(false); RepositoryBase <EWSKnownWords> _repListKnow = new RepositoryBase <EWSKnownWords>(false); RepositoryBase <EWSWillLearn> _repListLearn = new RepositoryBase <EWSWillLearn>(false); RepositoryBase <EWSSampleSentence> _repSampleSentence = new RepositoryBase <EWSSampleSentence>(false); List <EWSListWord> lists = null; List <EWSKnownWords> listKnown = null; List <EWSWillLearn> listLearn = null; Guid wID = new Guid(); if (type == "all") { lists = _repListWord.GetList(p => p.ListUN == listID); wID = (Guid)lists[rownumber].WordUN; } if (type == "known") { listKnown = _repListKnow.GetList(p => p.UserID == userID); wID = (Guid)listKnown[rownumber].WordUN; } if (type == "willlearn") { listLearn = _repListLearn.GetList(p => p.UserID == userID); wID = (Guid)listLearn[rownumber].WordUN; } EWSWord word = _rep.Get(p => p.UN == wID); //kelimenin kullanıcı tarafından bilinip bilinmediğini kontrol et. EWSKnownWords lstKnown = _repListKnow.Get(p => p.WordUN == word.UN && p.UserID == userID); if (lstKnown != null) { word.Known = true; } else { word.Known = false; } EWSWillLearn lstLearn = _repListLearn.Get(p => p.WordUN == word.UN && p.UserID == userID); if (lstLearn != null) { word.WillLearn = true; } else { word.WillLearn = false; } //word.EWSSampleSentence = _repSampleSentence.GetList(p => p.WordUN == word.UN && p.UserID == userID); return(word); }