public async static Task <DictionaryQueryModel> QueryWordAsync(string _word)
        {
            DictionaryQueryModel result = new DictionaryQueryModel();

            try
            {
                var preresult = await SQLManager.QueryWordAsync(_word);

                result.Result.Word = preresult.word;

                var preresult_mean = await SQLManager.QueryMeanAsync(preresult.ID);

                List <Pos_OfflineSource1> preresult_POS = new List <Pos_OfflineSource1>();
                foreach (var item in preresult_mean)
                {
                    var pos = await SQLManager.QueryPosAsync(item.posID);

                    var newdefinition = new Definition();
                    newdefinition.PartOfSpeech = pos.name;
                    newdefinition.Meanings.Add(item.meanings);
                    result.Result.Definitions.Add(newdefinition);
                }
            }
            catch
            {
                result.ResultStatus = ResultStatus.WordCantFind;
            }
            return(result);
        }
Esempio n. 2
0
        public static DictionaryQueryModel QueryResultFromWebAPI_C2E(string word)
        {
            DictionaryQueryModel result = new DictionaryQueryModel();

            try
            {
                WebRequest   webRequest  = HttpWebRequest.Create(APIHeader + word + APITail);
                WebResponse  webResponse = webRequest.GetResponse();
                Stream       stream      = webResponse.GetResponseStream();
                StreamReader sr          = new StreamReader(stream);
                var          jsonstring  = sr.ReadToEnd();
                try
                {
                    var aicibamodel = Json.Deserialize <AiCiBaC2E_Model>(jsonstring);
                    result.Result = GetWordModelFromAiCiBaC2E(aicibamodel);
                }
                catch
                {
                    var aicibamodel = Json.Deserialize <AiCiBaC2E_Model2>(jsonstring);
                    result.Result = GetWordModelFromAiCiBaC2E2(aicibamodel);
                }
                result.ResultStatus = ResultStatus.Succuss;
            }
            catch
            {
                result.ResultStatus = ResultStatus.WordCantFind;
            }
            return(result);
        }
Esempio n. 3
0
        public async override Task <DictionaryQueryModel> GetDictionaryQueryModelAsync(string word)
        {
            var str = await ParentExtension.InvokeAndGetJSON(word, LanguageHelper.ConvertToLangCode(SourceLanguage), LanguageHelper.ConvertToLangCode(TargetLanguage));

            var preresult = Json.Deserialize <DictionaryQueryModelFromExtension>(str);
            DictionaryQueryModel result = new DictionaryQueryModel()
            {
                QueryWord      = preresult.QueryWord,
                SourceLanguage = preresult.SourceLanguage,
                TargetLanguage = preresult.TargetLanguage,
                QueryStatus    = preresult.QueryStatus,
                Result         = GetWordModel(preresult.Result),
                ResultStatus   = ResultStatus.Succuss
            };

            return(ResultModel = result);
        }
Esempio n. 4
0
        public static DictionaryQueryModel QueryResultFromWebAPI_E2C(string word)
        {
            DictionaryQueryModel result = new DictionaryQueryModel();

            try
            {
                bool         IsIncorrectWord = AutoFix(ref word);
                WebRequest   webRequest      = HttpWebRequest.Create(APIHeader + word + APITail);
                WebResponse  webResponse     = webRequest.GetResponse();
                Stream       stream          = webResponse.GetResponseStream();
                StreamReader sr          = new StreamReader(stream);
                var          jsonstring  = sr.ReadToEnd();
                var          aicibamodel = Json.Deserialize <AiCiBaE2C_Model>(jsonstring);
                result.Result       = GetWordModelFromAiCiBaE2C(aicibamodel);
                result.ResultStatus = ResultStatus.Succuss;
            }
            catch
            {
                result.ResultStatus = ResultStatus.FailedWithUnknownReason;
            }
            return(result);
        }