Ejemplo n.º 1
0
        public static PhrasesExistRetriever PhrasesExist(string languageText, IList <string> phraseTexts)
        {
            var criteria  = new Criteria.PhraseTextsCriteria(languageText, phraseTexts);
            var retriever = PhrasesExistRetriever.CreateNew(criteria);

            return(retriever);
        }
Ejemplo n.º 2
0
        public void DataPortal_Create(Criteria.PhraseTextsCriteria phraseTextsCriteria)
        {
#if DEBUG
            var sep = " ||| ";
            var msg = DateTime.Now.ToShortTimeString() +
                      "PhraseList.DP_Create" + sep +
                      "ThreadID = " +
                      System.Threading.Thread.CurrentThread.ManagedThreadId.ToString() + sep +
                      "PhraseTexts.Count = " + phraseTextsCriteria.PhraseTexts.Count.ToString() + sep +
                      "1st Phrase = " + phraseTextsCriteria.PhraseTexts[0];
            System.Diagnostics.Trace.WriteLine(msg);
            //Services.Log(msg, LogPriority.Low, LogCategory.Information);
#endif


            if (phraseTextsCriteria.PhraseTexts.Count == 0)
            {
                throw new ArgumentException("phraseTextsCriteria");
            }
            using (var dalManager = DalFactory.GetDalManager())
            {
                var languageText = phraseTextsCriteria.LanguageText;
                var language     = DataPortal.FetchChild <LanguageEdit>(languageText);

                //WE NOW HAVE OUR LANGUAGEEDIT THAT WILL BE USED FOR ALL PHRASE TEXTS.
                var phraseDal = dalManager.GetProvider <IPhraseDal>();

                //PhraseList newPhraseList = PhraseList.NewPhraseList();
                for (int i = 0; i < phraseTextsCriteria.PhraseTexts.Count; i++)
                {
                    //foreach (var phraseText in phraseTextsCriteria.PhraseTexts)
                    var phraseText = phraseTextsCriteria.PhraseTexts[i];
                    if (string.IsNullOrEmpty(phraseText))
                    {
                        continue;
                    }
                    PhraseEdit phraseEdit = DataPortal.CreateChild <PhraseEdit>();
                    phraseEdit.Language = language;
                    phraseEdit.Text     = phraseText;
                    Add(phraseEdit);
                }
            }
        }
Ejemplo n.º 3
0
        public void DataPortal_Create(Criteria.PhraseTextsCriteria criteria)
        {
            RetrieverId = Guid.NewGuid();
            if (ExistenceDictionary == null)
            {
                ExistenceDictionary = new MobileDictionary <string, bool>();
            }

            PhraseList allPhrases           = PhraseList.GetAll();
            var        allPhrasesInLanguage = (from phrase in allPhrases
                                               where phrase.Language.Text == criteria.LanguageText
                                               select phrase);

            var phraseTextsNoDuplicates = criteria.PhraseTexts.Distinct();

            foreach (var phraseText in phraseTextsNoDuplicates)
            {
                var count = (from phrase in allPhrasesInLanguage
                             where phrase.Text == phraseText
                             select phrase).Count();
                var exists = count > 0;
                ExistenceDictionary.Add(phraseText, exists);
            }
        }
Ejemplo n.º 4
0
        public static async Task <PhraseList> NewPhraseListAsync(Criteria.PhraseTextsCriteria phraseTextsCriteria)
        {
            var result = await DataPortal.CreateAsync <PhraseList>(phraseTextsCriteria);

            return(result);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates a new existence object, filling ExistenceDictionary with key=phraseText, value=Exists entries.
 /// THIS IS NOT OPTIMIZED, AND IT DOES MOST OF THE WORK ON THE SERVER SIDE.  I MIGHT SHOULD TURN THIS INTO A COMMAND OBJECT
 /// AND HAVE THIS DONE ON THE CLIENT SIDE, ESPECIALLY SINCE CURRENTLY IT IS JUST USING PHRASELIST.GETALL() AND THEN
 /// WORKING OFF OF THAT ANYWAY.
 /// </summary>
 /// <param name="criteria">phrase texts to be checked for existence in data store.</param>
 public static PhrasesExistRetriever CreateNew(Criteria.PhraseTextsCriteria criteria)
 {
     return(DataPortal.Create <PhrasesExistRetriever>(criteria));
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates a new existence object, filling ExistenceDictionary with key=phraseText, value=Exists entries.
        /// THIS IS NOT OPTIMIZED, AND IT DOES MOST OF THE WORK ON THE SERVER SIDE.  I MIGHT SHOULD TURN THIS INTO A COMMAND OBJECT
        /// AND HAVE THIS DONE ON THE CLIENT SIDE, ESPECIALLY SINCE CURRENTLY IT IS JUST USING PHRASELIST.GETALL() AND THEN
        /// WORKING OFF OF THAT ANYWAY.
        /// </summary>
        /// <param name="criteria">phrase texts to be checked for existence in data store.</param>
        public static async Task <PhrasesExistRetriever> CreateNewAsync(Criteria.PhraseTextsCriteria criteria)
        {
            var result = await DataPortal.CreateAsync <PhrasesExistRetriever>(criteria);

            return(result);
        }