Example #1
0
 public void addSentence(string strSentence)
 {
     if (CommonHelper.checkUnicode(strSentence))
     {
         if (db.A_Sentence.Where(s => s.Sentence == strSentence).ToList().Count == 0)
         {
             SentenceDao senDao = new SentenceDao();
             senDao.Insert(new A_Sentence()
             {
                 Sentence = strSentence, SenSearch = strSentence
             });
         }
         long senId = db.A_Sentence.Where(s => s.Sentence == strSentence).FirstOrDefault().SentenceId;
         if (db.A_Sen_Mean.Where(s => s.SentenceId == senId).ToList().Count == 0)
         {
             senMeanDao.Insert(new A_Sen_Mean()
             {
                 SentenceId = senId
             });
         }
     }
     else
     {
         if (db.A_Mean.Where(s => s.MeanContent == strSentence).ToList().Count == 0)
         {
             MeanDao senDao           = new MeanDao();
             String  strContentSearch = CommonHelper.convertToUnSign3(strSentence);
             strContentSearch += ",";
             strContentSearch += strSentence;
             senDao.Insert(new A_Mean()
             {
                 MeanContent = strSentence, ContentSearch = strContentSearch
             });
         }
         long meanId = db.A_Mean.Where(s => s.MeanContent == strSentence).FirstOrDefault().MeanId;
         if (db.A_Sen_Mean.Where(s => s.MeanId == meanId).ToList().Count == 0)
         {
             senMeanDao.Insert(new A_Sen_Mean()
             {
                 MeanId = meanId
             });
         }
     }
 }
Example #2
0
        public A_Sen_Mean nextSentence(A_Sen_Mean tblSenMean, int intCountry)
        {
            //lay thong tin SentenceId va MeanId tu man hinh
            var tblSenMeanSearch = db.A_Sen_Mean.Find(tblSenMean.SenMeanId);

            if (intCountry == 0)
            {
                //cap nhat lai ngay Mean
                MeanDao meanDao = new MeanDao();
                meanDao.UpdateTime(meanDao.FindById(tblSenMeanSearch.MeanId.Value));

                return(senMeanDao.getListSortByMeanUpdateTime().FirstOrDefault());
            }
            else
            {
                //cap nhat lai ngay Sentence
                SentenceDao senDao = new SentenceDao();
                senDao.UpdateTime(senDao.FindById(tblSenMeanSearch.SentenceId.Value));

                return(senMeanDao.getListSortBySenUpdateTime().FirstOrDefault());
            }
        }
Example #3
0
        public void addSentenceTrans(A_Sen_Mean tblSenMean, string ctrSentenceTrans, int strCountry)
        {
            SentenceDao senDao  = new SentenceDao();
            MeanDao     meanDao = new MeanDao();

            if (strCountry == 0)
            {
                if (db.A_Sentence.Where(s => s.Sentence == ctrSentenceTrans && s.ActiveFlag == 1).ToList().Count == 0)
                {
                    senDao.Insert(new A_Sentence()
                    {
                        Sentence = ctrSentenceTrans, SenSearch = ctrSentenceTrans
                    });
                }

                //lay thong tin SentenceId va MeanId tu man hinh
                var tblSenMeanSearch = db.A_Sen_Mean.Find(tblSenMean.SenMeanId);

                //lay thong tin SentenceId vua insert
                long senId = db.A_Sentence.Where(s => s.Sentence == ctrSentenceTrans && s.ActiveFlag == 1).FirstOrDefault().SentenceId;
                if (db.A_Sen_Mean.Where(s => s.SentenceId == senId && s.MeanId == tblSenMeanSearch.MeanId).FirstOrDefault() == null)
                {
                    tblSenMean = senMeanDao.FindById(tblSenMean.SenMeanId);
                    if (db.A_Sen_Mean.Find(tblSenMean.SenMeanId).SentenceId == null)
                    {
                        tblSenMean.SentenceId = senId;
                        senMeanDao.Update(tblSenMean);
                    }
                    else
                    {
                        senMeanDao.Insert(new A_Sen_Mean()
                        {
                            MeanId = tblSenMean.MeanId, SentenceId = senId
                        });
                    }
                }
            }
            else
            {
                if (db.A_Mean.Where(s => s.MeanContent == ctrSentenceTrans && s.ActiveFlag == 1).ToList().Count == 0)
                {
                    String strContentSearch = CommonHelper.convertToUnSign3(ctrSentenceTrans);
                    strContentSearch += ",";
                    strContentSearch += ctrSentenceTrans;
                    meanDao.Insert(new A_Mean()
                    {
                        ContentSearch = strContentSearch, MeanContent = ctrSentenceTrans
                    });
                }

                //lay thong tin SentenceId va MeanId tu man hinh
                var tblSenMeanSearch = db.A_Sen_Mean.Find(tblSenMean.SenMeanId);

                //lay thong tin SentenceId vua insert
                long meanId = db.A_Mean.Where(s => s.MeanContent == ctrSentenceTrans && s.ActiveFlag == 1).FirstOrDefault().MeanId;
                if (db.A_Sen_Mean.Where(s => s.SentenceId == tblSenMeanSearch.SentenceId && s.MeanId == meanId).FirstOrDefault() == null)
                {
                    tblSenMean = senMeanDao.FindById(tblSenMean.SenMeanId);
                    if (db.A_Sen_Mean.Find(tblSenMean.SenMeanId).MeanId == null)
                    {
                        tblSenMean.MeanId = meanId;
                        senMeanDao.Update(tblSenMean);
                    }
                    else
                    {
                        senMeanDao.Insert(new A_Sen_Mean()
                        {
                            MeanId = meanId, SentenceId = tblSenMean.SentenceId
                        });
                    }
                }
            }
        }