internal void SaveResourceTranslatedCompare(GetWordForTranslate_Result data, CallBankService objectT)
        {
            var ob = new WordTranslateCompare {
                WordID = data.WordID,

                LanguageId = data.LangId,
                Translated = objectT.Text,
                AllWords   = objectT.All.Aggregate((x, y) => x + ", " + y).Trim(' ', ','),
                AllData    = data.Translated,
                CreateDate = DateTime.Now
            };
            var ret = TranslatorServiceCompare.ProcessTranslateFiles(ob.Translated, ob);

            ob.Translated = ret.First;
            ob.AllWords   = ret.AllWords;

            entity.WordTranslateCompares.Add(ob);
            entity.SaveChanges();
            try
            {
                if (entity.WordTranslateCompares.Count(x => x.WordID == data.WordID) == 1)
                {
                    ;//entity.Languages.Count())
                }
                {
                    entity.AllWordFromPaymonCompares.Where(x => x.ID == data.WordID)
                    .UpdateFromQuery(x => new AllWordFromPaymonCompare {
                        Translated = true
                    });
                }
            } catch
            {
            }
        }
        public static WordProcessed ProcessTranslateFiles(string word, WordTranslateCompare allData)
        {
            bool   Verified = false;
            string First    = "";

            Console.WriteLine("Processing...");

            var dicAll = new List <string>();

            var objectT = JsonConvert.DeserializeObject <CallBankService>(allData.AllData);
            var body    = JsonConvert.DeserializeObject <JArray>(objectT.Raw);

            if (body.Count > 0)
            {
                var first = body.First <JToken>();
                var item  = first.FirstOrDefault();
                if (item != null)
                {
                    Verified = item[4].Value <int>() == 1;
                    First    = item[0].Value <string>();
                }
            }


            if (body.Count > 5 && body[5].HasValues && !Verified)
            {
                var item = body[5].FirstOrDefault();
                if (item != null && item[3].HasValues && item[2].HasValues && item[3].Any())
                {
                    var googleWord = item[0].Value <string>().ToLower();
                    var myword     = word.ToLower();
                    if (googleWord != myword)
                    {
                        File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "\\DeffWords.txt",
                                           "\r\n" + myword + "\t" + googleWord);
                    }
                    var goodRank = item[3][0].Values <int>().Select((r, i) => new
                    {
                        Index = i,
                        Rank  = r,
                    }).OrderByDescending(x => x.Rank).FirstOrDefault();
                    if (goodRank != null)
                    {
                        if (item[2].Count() > goodRank.Index)
                        {
                            First = item[2][goodRank.Index][0].Value <string>();
                        }
                        else
                        {
                            First = item[2].FirstOrDefault()?[0].Value <string>();
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(First) && First.Length > 0)
            {
                dicAll.Add(First.Trim());
            }

            if (body.Count > 1 && body[1].HasValues)
            {
                foreach (var v in body[1])
                {
                    if (v.HasValues && v.Count() > 1)
                    {
                        var dic = v[1].Select(x => x.Value <string>()).ToList();
                        dicAll.AddRange(dic);
                    }
                }
            }

            dicAll = dicAll.Distinct().ToList();
            var proceessd = dicAll.Aggregate((x, y) => x + ", " + y).Trim(' ', ',');

            return(new WordProcessed
            {
                AllWords = proceessd,
                First = First
            });

            //  entity.WordTranslates.Where(x => x.WordID == result1.WordId && x.LanguageId == result1.LanId)
            //    .UpdateFromQuery(x => new WordTranslate { AllWords = proceessd, Translated = result1.First, Proccessed = true });

            //    Console.WriteLine($"Update {result1.WordId}\t{result1.LanId}\t{result1.Word}");
        }