public JsonResult GetReadinPartByUNJson(Guid UN) { IEWSReadingPart iReadPart = new BSReadingPart(); EWSReadPart readPart = iReadPart.GetReadingPart(UN, false); return(Json(readPart, JsonRequestBehavior.AllowGet)); }
public ActionResult SelectReadingPart(Guid UN) { IEWSReadingPart iReadPart = new BSReadingPart(); EWSReadPart readPart = iReadPart.GetReadingPart(UN); if (readPart.ReadPartHtml == null) { readPart.ReadPartHtml = readPart.ReadPart; } return(View("ReadingPart", readPart)); }
public EWSReadPart GetReadingPart(Guid UN, bool getRelations = true) { IRepositoryBase <EWSReadPart> _rep = new RepositoryBase <EWSReadPart>(getRelations); IRepositoryBase <EWSListWord> _repListWord = new RepositoryBase <EWSListWord>(true); EWSReadPart readingPart = _rep.Get(p => p.UN == UN); //string desen = @"([A-z])\w+"; //var matches = Regex.Matches(readingPart.ReadPart, 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 = null; // listWord = _repListWord.Get(p => p.ListUN == list.UN && p.WordUN == word.UN); // // list word kaydet // if (listWord == null) // { // listWord = new EWSListWord(); // listWord.ListUN = list.UN; // listWord.UN = Guid.NewGuid(); // listWord.WordUN = word.UN; // listWord.isPublic = false; // _repListWord.Add(listWord); // } //} //List<EWSListWord> listWords = _repListWord.GetList(p => p.ListUN == readingPart.ListUN); //foreach (var item in listWords) //{ // readingPart.ReadPart =readingPart.ReadPart.Replace(item.EWSWord.WordBody, "<a href='javascript:void(0)'>" + item.EWSWord.WordBody + "</a>"); //} readingPart.ReadPart = readingPart.ReadPart.Replace("\n", "<br \\>"); return(readingPart); }
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); } } }