Пример #1
0
        public void TestAuthenticateNegative()
        {
            string UserName = "******";
            string Password = "******";
            string result   = WebApiCaller.GetUserToken(UserName, Password);

            Assert.IsTrue(string.IsNullOrEmpty(result));
        }
Пример #2
0
        public void TestGetProducts()
        {
            string UserName = "******";
            string Password = "******";
            string result   = WebApiCaller.GetUserToken(UserName, Password);

            Product[] products = WebApiCaller.GetProducts(result);
            Assert.IsNotNull(products);
        }
Пример #3
0
        public ActionResult UpdateFlight(FlightModel model)
        {
            if (ModelState.IsValid)
            {
                string postBody = JsonConvert.SerializeObject(model);
                var    response = WebApiCaller.CallSyncStatement(Config.RessourceEndPoint, WebApiRoutes.UpdateFlightListActionName, postBody);
            }

            return(RedirectToAction("index", "Flight"));
        }
Пример #4
0
        /// <summary>
        /// Get countries from webapi
        /// </summary>
        /// <returns></returns>
        private List <CountryModel> GetCountriesList()
        {
            var response = WebApiCaller.RunGetSyncStatement(Config.RessourceEndPoint, WebApiRoutes.GetAllCountriesListActionName);
            List <CountryModel> countriesList = new List <CountryModel>();

            if (response.IsSuccessStatusCode)
            {
                string responseString = response.Content.ReadAsStringAsync().Result;
                countriesList = JsonConvert.DeserializeObject <List <CountryModel> >(responseString);
            }
            return(countriesList);
        }
Пример #5
0
 public ActionResult ListProduct()
 {
     if (System.Web.HttpContext.Current.Session["access_token"] != null)
     {
         string    token    = (string)System.Web.HttpContext.Current.Session["access_token"];
         Product[] products = WebApiCaller.GetProducts(token);
         return(View(products));
     }
     else
     {
         return(View("ViewProduct"));
     }
 }
Пример #6
0
        /// <summary>
        /// Get detail flight by Id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        private FlightModel GetFlightById(int id)
        {
            var response = WebApiCaller.RunGetSyncStatement(Config.RessourceEndPoint, WebApiRoutes.GetFlightByIdActionName + id.ToString());

            FlightModel flight = new FlightModel();

            if (response.IsSuccessStatusCode)
            {
                string responseString = response.Content.ReadAsStringAsync().Result;
                flight = JsonConvert.DeserializeObject <FlightModel>(responseString);
            }
            return(flight);
        }
Пример #7
0
        public ActionResult Login(string username, string password)
        {
            string access_token = WebApiCaller.GetUserToken(username, password);

            if (!string.IsNullOrEmpty(access_token))
            {
                System.Web.HttpContext.Current.Session["access_token"] = access_token;
                return(RedirectToAction("ViewProduct", "Home"));
            }
            else
            {
                return(RedirectToAction("Login", "Home"));
            }
        }
Пример #8
0
        public async Task <ObservableCollection <ProjectLocation> > RetrieveProjectList()
        {
            //网络请求
            string result = await Task.Run(() =>
                                           WebApiCaller.HttpGet(ServiceConfig.BaseURL + string.Format(ServiceConfig.ProjectListFormat)));

            //
            JObject obj  = JObject.Parse(result);
            string  data = obj["data"].ToString();
            //
            ObservableCollection <ProjectLocation> _obj = JsonConvert.DeserializeObject <ObservableCollection <ProjectLocation> >(data);

            return(_obj);
        }
        public async Task <DGObject> Retrieve(int key)
        {
            //网络请求
            string result = await Task.Run(() =>
                                           WebApiCaller.HttpGet(ServiceConfig.BaseURL +
                                                                string.Format(ServiceConfig.DGObjectByIDFormat, domainType.ToLower(), dgobjectName.ToLower(), projectID, key)));

            //
            JObject obj  = JObject.Parse(result);
            string  data = obj["data"].ToString();
            //
            DGObject objHelper =
                ObjectHelper.CreateDGObjectFromSubclassName(dgobjectName);
            var _obj = JsonConvert.DeserializeObject(data, objHelper.GetType());

            return(_obj as DGObject);
        }
Пример #10
0
        //获取对象列表
        public async Task <List <DGObject> > GetAllByObjs(string filter)
        {
            //网络请求
            string result = await Task.Run(() =>
                                           WebApiCaller.HttpGet(ServiceConfig.BaseURL +
                                                                string.Format(ServiceConfig.DGObjectListFormat, domainType.ToLower(), dgobjectName.ToLower(), projectID, iS3.Core.APIMessageConverter.EnCode(filter))));

            //
            JObject obj     = JObject.Parse(result);
            string  data    = obj["data"].ToString();
            JArray  objList = JArray.Parse(data);

            //
            if (subclasses == null)
            {
                subclasses =
                    from assembly in AppDomain.CurrentDomain.GetAssemblies()
                    from type in assembly.GetTypes()
                    where type.IsSubclassOf(typeof(DGObject))
                    select type;
            }

            // match the subclassName with full name at first
            Type t = subclasses.FirstOrDefault(x => x.FullName == dgobjectName);

            // if not found, match the subclassName with name
            if (t == null)
            {
                t = subclasses.FirstOrDefault(x => x.Name == dgobjectName);
            }

            List <DGObject> list = new List <DGObject>();

            foreach (JToken token in objList)
            {
                var _obj = JsonConvert.DeserializeObject(token.ToString(), t);
                list.Add(_obj as DGObject);
            }
            return(list);
        }
Пример #11
0
 public ClientiController()
 {
     strUri = $"http//localhost:52244/api/";
     caller = new WebApiCaller();
 }
Пример #12
0
 public TestControllerCaller(WebApiCaller webApiCaller)
 {
     _caller = webApiCaller;
 }
Пример #13
0
 public TestControllerCaller(string apiUrl, DataFormat dataFormat = DataFormat.Json)
 {
     _caller = new WebApiCaller(apiUrl, dataFormat);
 }
Пример #14
0
 static Program()
 {
     _webApiCaller = new WebApiCaller(Url);
 }
Пример #15
0
        private static void GoRankCollector(int pEndPage)
        {
            // 1. BJ 수집
            int endPage            = pEndPage;
            var categoryRankParser = new CategoryRankParser();
            var resultBjModels     = new List <RankBjModel>();

            foreach (RankingType rankingType in Enum.GetValues(typeof(RankingType)))
            {
                for (int i = 1; i <= endPage; i++)
                {
                    var bjModels = categoryRankParser.GetData(rankingType, i);

                    if (resultBjModels.Count <= 0)
                    {
                        resultBjModels.AddRange(bjModels);
                        continue;
                    }

                    foreach (var bj in bjModels)
                    {
                        //기존 BJ 없다면 새로 추가
                        if (!resultBjModels.Any(b => b.BjID == bj.BjID))
                        {
                            resultBjModels.Add(bj);
                            continue;
                        }

                        // 기존 BJ 있으면 기존 BJ에 담고 해당 랭크만 채우기
                        foreach (var resultBjModel in resultBjModels)
                        {
                            if (resultBjModel.BjID != bj.BjID)
                            {
                                continue;
                            }

                            categoryRankParser.SetTargetRank(bj, resultBjModel, rankingType);
                        }
                    }
                }
            }

            // 2. 사용자 수집
            var bjPagePaser     = new BjPagePaser();
            var resultUserModel = new List <RankUserModel>();
            var resultBjInfo    = new List <BjInfoModel>();

            // BJ 수집 리스트 루프 돌기
            foreach (var BjModel in resultBjModels)
            {
                // BJ 정보
                var BjInfo = bjPagePaser.GetBjInfo(BjModel);
                resultBjInfo.AddRange(BjInfo);

                // 열혈팬 Top20
                var bigFans = bjPagePaser.GetBigFans(BjModel.BjID);
                resultUserModel.AddRange(bigFans);

                // 서포터 Top20
                var supporters = bjPagePaser.GetSupporters(BjModel.BjID);
                resultUserModel.AddRange(supporters);
            }

            ;

            var bizSettings = new BizRankCollectorSettings();
            var Settings    = bizSettings.GetSettings();

            var bizBjRank = new BizBjRank(Settings);

            bizBjRank.SetInitBjValues();
            bizBjRank.SetBjModels(resultBjModels);

            foreach (var userModel in resultUserModel)
            {
                var bjModel = resultBjModels.Find(b => b.BjID == userModel.BjID);
                userModel.BjNic = bjModel.BjNick;
            }

            var bizUserRank = new BizUserRank(Settings);

            bizUserRank.SetInitUserValues();
            bizUserRank.SetUserModels(resultUserModel);
            bizUserRank.SetInitBjInfoValues();
            bizUserRank.SetBjInfoModels(resultBjInfo);

            bizSettings.SetAferSettings();
            ;

            var jsonModel = new JsonModel()
            {
                Text = "rfsStart"
            };
            var webApiCaller = new WebApiCaller();
            var result       = webApiCaller.RefreshAsync(jsonModel).ConfigureAwait(true);
        }