示例#1
0
        public bool TestCreateCustomer(string baseURI)
        {
            HttpResponseMessage jResponse = null;

            try
            {
                CallService oWebAPICall = new CallService();

                jResponse = oWebAPICall.Call(baseURI, "CreateCustomer/" + CustomerId + "/" + Title + "/" + FirstName + "/" + LastName);
                string     jsonResponse = jResponse.Content.ReadAsAsync <string>().Result;
                ResultBool rt           = JsonConvert.DeserializeObject <ResultBool>(jsonResponse);

                jResponse.Dispose();

                return(rt.Value);
            }
            catch (Exception e)
            {
                Console.Write("Test failed with exception: " + e.Message);
                return(false);
            }
            finally
            {
                jResponse.Dispose();
            }
        }
 /// <summary>
 ///     获取文件夹id,如果文件夹不存在则新建文件夹并返回文件夹id
 /// </summary>
 /// <param name="token">token凭证</param>
 /// <param name="parentFolderId">父文件夹id</param>
 /// <param name="folderName">文件夹名称</param>
 /// <returns>文件夹id</returns>
 public static int GetFolder(string token, int parentFolderId, string folderName)
 {
     try
     {
         var documentApiProvider = new DocumentApiProvider();
         folderName = folderName.Trim();
         ResultBool resultBool = documentApiProvider.ExistsFolder(token, parentFolderId, folderName);
         if (resultBool.ResultValue)
         {
             return(resultBool.Result);
         }
         ResultInt resultInt = CreateFolder(token, parentFolderId, folderName);
         return(resultInt.ResultValue);
     }
     catch (Exception ex)
     {
         throw new Exception("GetFolder出现异常,exMessage=" + ex.Message);
     }
 }
        public bool TestReadCustomer(string baseURI)
        {
            try
            {
                CallService oWebAPICall = new CallService();

                HttpResponseMessage jResponse = oWebAPICall.Call(baseURI, "ReadCustomer/1");
                string     jsonResponse       = jResponse.Content.ReadAsAsync <string>().Result;
                ResultBool rt = JsonConvert.DeserializeObject <ResultBool>(jsonResponse);

                jResponse.Dispose();

                return(rt.Value);
            }
            catch (Exception e)
            {
                Console.Write("Test failed with exception: " + e.Message);
                return(false);
            }
        }
示例#4
0
        public async void GetAll()
        {
            var PreguntasBool   = new ResultBool();
            var PreguntasChoise = new ResultChoise();
            var rest            = new RestClient();
            var rptaBool        = new ResultBool();
            var rptaChoise      = new ResultChoise();

            ((App)Application.Current).ListaPreguntasBool   = new ObservableCollection <QuestionBool>();
            ((App)Application.Current).ListaPreguntasChoise = new ObservableCollection <QuestionChoise>();
            this.ListaPreguntasBool   = new ObservableCollection <QuestionBool>();
            this.ListaPreguntasChoise = new ObservableCollection <QuestionChoise>();

            //Consulta por modo de juego
            if (((App)Application.Current).ModeGame == 0)
            {
                rptaBool = await rest.Get <ResultBool>();

                if (rptaBool != null)
                {
                    PreguntasBool = rptaBool;
                }

                foreach (var pregunta in PreguntasBool.results)
                {
                    this.ListaPreguntasBool.Add(new QuestionBool()
                    {
                        category          = pregunta.category,
                        type              = pregunta.type,
                        difficulty        = pregunta.difficulty,
                        question          = HttpUtility.HtmlDecode(pregunta.question),
                        correct_answer    = pregunta.correct_answer,
                        incorrect_answers = pregunta.incorrect_answers
                    });
                }

                ((App)Application.Current).ListaPreguntasBool = this.ListaPreguntasBool;
            }
            else
            {
                rptaChoise = await rest.Get <ResultChoise>();

                if (rptaChoise != null)
                {
                    PreguntasChoise = rptaChoise;
                }

                foreach (var pregunta in PreguntasChoise.results)
                {
                    this.ListaPreguntasChoise.Add(new QuestionChoise()
                    {
                        category          = pregunta.category,
                        type              = pregunta.type,
                        difficulty        = pregunta.difficulty,
                        question          = HttpUtility.HtmlDecode(pregunta.question),
                        correct_answer    = HttpUtility.HtmlDecode(pregunta.correct_answer),
                        incorrect_answers = pregunta.incorrect_answers
                    });
                }

                ((App)Application.Current).ListaPreguntasChoise = this.ListaPreguntasChoise;
            }
        }