示例#1
0
        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');"));
        }
示例#2
0
        public void ListedenCikar(Guid UN)
        {
            IRepositoryBase <EWSListWord> _rep = new RepositoryBase <EWSListWord>();

            EWSListWord w = _rep.Get(p => p.UN == UN);

            _rep.Remove(w);
        }
示例#3
0
        public void AddWordToList(Guid ListUN, Guid wordUN)
        {
            IRepositoryBase <EWSListWord> _rep = new RepositoryBase <EWSListWord>();

            //get , add if doesn't exists
            EWSListWord w = _rep.Get(p => p.ListUN == ListUN && p.WordUN == wordUN);

            if (w == null)
            {
                EWSListWord listWord = new EWSListWord()
                {
                    UN       = Guid.NewGuid(),
                    isPublic = false,
                    ListUN   = ListUN,
                    WordUN   = wordUN,
                };

                _rep.Add(listWord);
            }
        }
示例#4
0
        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);
        }
示例#5
0
        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);
            }
        }
示例#6
0
        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);
                }
            }
        }