Exemplo n.º 1
0
        public void PatchStringMakeContentStatusCode()
        {
            var content = WebServiceUtils.MakeStringContent("Test", Encoding.UTF8, "text/plain");
            var result  = this.WebServiceDriver.PatchWithResponse("/api/String/Patch/1", "text/plain", content, true);

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
        }
Exemplo n.º 2
0
        public void PutStringWithMakeStreamContent()
        {
            StreamContent content = WebServiceUtils.MakeStreamContent("Test", Encoding.UTF8, "text/plain");
            var           result  = this.WebServiceDriver.Put("/api/String/Put/1", "text/plain", content, true);

            Assert.AreEqual(string.Empty, result);
        }
Exemplo n.º 3
0
        public void PatchStreamWithMakeContent()
        {
            var content = WebServiceUtils.MakeStreamContent("Test", Encoding.UTF8, "text/plain");
            var result  = this.WebServiceDriver.Patch("/api/String/Patch/1", "text/plain", content, true);

            Assert.AreEqual("\"Patched\"", result);
        }
Exemplo n.º 4
0
        public void GetResponseAndDeserializeJsonM()
        {
            HttpResponseMessage message = this.WebServiceDriver.GetWithResponse("/api/XML_JSON/GetAllProducts", MediaType.AppJson);
            List <ProductJson>  result  = WebServiceUtils.DeserializeJson <List <ProductJson> >(message);

            Assert.AreEqual(3, result.Count, "Expected 3 products to be returned");
        }
Exemplo n.º 5
0
        public void GetResponseAndDeserializeXml()
        {
            HttpResponseMessage message = this.WebServiceDriver.GetWithResponse("/api/XML_JSON/GetAllProducts", MediaType.AppXml);
            ArrayOfProduct      result  = WebServiceUtils.DeserializeXmlDocument <ArrayOfProduct>(message);

            Assert.AreEqual(3, result.Product.Length, "Expected 3 products to be returned");
        }
Exemplo n.º 6
0
        public ActionResult GetProductForSiteArea(String siteArea)
        {
            ProductService serv = WebServiceUtils.GetEndpointService <ProductService>(ProductServiceInfo.ENDPOINT_NAME);
            SiteArea       area = serv.ProductsForSiteArea(siteArea);

            ViewBag.siteArea = area;
            return(View());
        }
Exemplo n.º 7
0
        public ActionResult GetSiteAreas()
        {
            ProductService  serv      = WebServiceUtils.GetEndpointService <ProductService>(ProductServiceInfo.ENDPOINT_NAME);
            List <SiteArea> siteAreas = serv.SiteAreasForStoreCode(SessionAdapter.getInstance().GetCurrentStore(this.Request));

            ViewBag.siteAreas = siteAreas;
            return(View());
        }
Exemplo n.º 8
0
        public void PatchStringWithoutBaseTest()
        {
            WebServiceDriver client = new WebServiceDriver(new Uri(url));
            var content             = WebServiceUtils.MakeStringContent("Test", Encoding.UTF8, "text/plain");
            var result = client.Patch("/api/String/Patch/1", "text/plain", content, true);

            Assert.AreEqual("\"Patched\"", result);
        }
Exemplo n.º 9
0
        public void CustomVerbFiveArguments()
        {
            WebServiceDriver client = new WebServiceDriver(new Uri(url));

            var content = WebServiceUtils.MakeStringContent("ZEDTest", Encoding.UTF8, "text/plain");
            var result  = client.Custom("ZED", "/api/ZED", "text/plain", content, true);

            Assert.AreEqual("\"ZEDTest\"", result.ToString());
        }
Exemplo n.º 10
0
        public ActionResult ProductsForCategory(String id)
        {
            ProductService  serv = WebServiceUtils.GetEndpointService <ProductService>(ProductServiceInfo.ENDPOINT_NAME);
            ProductCategory cat  = serv.ProductCategoryForGuid(id);

            cat = serv.ProductsForCategory(cat);
            ViewBag.category = cat;
            return(View());
        }
Exemplo n.º 11
0
        public void WebServiceUtilsDeserializeResponseThrownException()
        {
            StringContent       content  = WebServiceUtils.MakeStringContent <ProductJson>(Product, Encoding.UTF8, "application/json");
            HttpResponseMessage response = this.WebServiceDriver.PutWithResponse("/api/XML_JSON/GetAnErrorPLZ", "application/json", content, false);

            WebServiceUtils.DeserializeResponse <ProductJson>(response, new List <MediaTypeFormatter> {
                new CustomXmlMediaTypeFormatter("image/gif", typeof(ProductJson))
            });
        }
Exemplo n.º 12
0
        public ActionResult GetKitchenCategories()
        {
            ProductService serv = WebServiceUtils.GetEndpointService <ProductService>(ProductServiceInfo.ENDPOINT_NAME);
            RoomsCategory  room = new RoomsCategory();

            room.Name = "kitchen";
            RoomsCategory cats = serv.CategoriesForRoomsCategory(room);

            ViewBag.cats = cats;
            return(View());
        }
Exemplo n.º 13
0
        public ActionResult GetUser()
        {
            SalesAdvisorSharedClasses.Models.User user;
            UserService client = WebServiceUtils.GetEndpointService <UserService>(UserServiceInfo.ENDPOINT_NAME);

            user = client.GetUserByUsername("Foobarbaz");
            List <User> list = client.GetUsersByStoreCode("10004");

            ViewBag.username = String.Format("List of users count: {0}", list.Count);
            return(View());
        }
 /// <summary>
 /// WebService登录
 /// </summary>
 /// <returns></returns>
 public string[] UserLogin(DAConfig config)
 {
     //当系统配置为空时,返回错误信息
     if (config == null)
     {
         return("0|系统配置信息获取失败".Split('|'));
     }
     //登录
     string[] objLogin = new string[] { config.Sitecode, config.Username, config.Password, "医院LIS服务" };
     return(WebServiceUtils.ExecuteMethod("Login", objLogin).Split('|'));
 }
Exemplo n.º 15
0
        //开始服务
        private void btnStart_Click(object sender, EventArgs e)
        {
            decimal cid = DefaultConfig.DACONFIGID;

            decimal.TryParse(ConfigurationManager.AppSettings["DaConfigID"], out cid);
            //读取默认配置
            config = new DAConfigBLL().SelectyDAConfigInfo(cid);
            if (config == null)
            {
                SetTB("没有维护配置文件!"); return;
            }

            //设置间隔时间
            timer.Interval = config.IntervalToDouble;

            double dInterval = 0;
            //获取配置时间间隔,设置logtimer间隔时间 fenghp
            string sss = ConfigurationManager.AppSettings["ErrorLogInterval"].ToString();

            double.TryParse(ConfigurationManager.AppSettings["ErrorLogInterval"].ToString(), out dInterval);

            logtimer.Interval  = dInterval * 1000 * 60;
            sendtimer.Interval = dInterval * 1000 * 60;

            //查询admin信息
            user.Usercode = "admin";
            user          = new DADictuserBLL().GetDADictuserInfoByUserCode(user);

            //开启
            timer.Start();
            logtimer.Start();
            SetTB("服务开启!");

            btnStart.Enabled = false;
            btnStop.Enabled  = true;
            btnStop.Focus();

            //更新webservice
            WebServiceUtils.SetIsUpdate(config.Address);

            DownResult();

            // UploadLog();

            //自动上传订单
            string issend = ConfigurationManager.AppSettings["IsSend"];

            if (issend == "1")
            {
                sendtimer.Start();
                sendOrders();
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// 下载结果
        /// </summary>
        void DownResult()
        {
            Control.CheckForIllegalCrossThreadCalls = false;
            ThreadPool.QueueUserWorkItem((o) =>
            {
                //每次获取 重新更新一次
                WebServiceUtils.SetIsUpdate(config.Address);

                CoreHandle();
                GC.Collect();
            });
        }
Exemplo n.º 17
0
        public void PostWithExpectedStatus()
        {
            ProductJson p = new ProductJson();

            p.Category = "ff";
            p.Id       = 4;
            p.Name     = "ff";
            p.Price    = 3.25f;
            var req = WebServiceUtils.MakeStringContent <ProductJson>(p, Encoding.UTF8, "application/json");
            var res = this.WebServiceDriver.Post("/api/XML_JSON/Post", "application/json", req, HttpStatusCode.OK);

            Assert.IsNotNull(res);
        }
Exemplo n.º 18
0
        public void PatchXMLSerializedVerifyStatusCode()
        {
            Product p = new Product();

            p.Category = "ff";
            p.Id       = 4;
            p.Name     = "ff";
            p.Price    = 3.25f;
            var content = WebServiceUtils.MakeStringContent <Product>(p, Encoding.UTF8, "application/xml");
            var result  = this.WebServiceDriver.PatchWithResponse("/api/XML_JSON/Patch/1", "application/xml", content);

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
        }
Exemplo n.º 19
0
        public void PostJSONStreamSerializedVerifyStatusCode()
        {
            ProductJson p = new ProductJson();

            p.Category = "ff";
            p.Id       = 4;
            p.Name     = "ff";
            p.Price    = 3.25f;
            var content = WebServiceUtils.MakeStreamContent <ProductJson>(p, Encoding.UTF8, "application/json");
            var result  = this.WebServiceDriver.PostWithResponse("/api/XML_JSON/Post", "application/json", content, true);

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
        }
Exemplo n.º 20
0
        public void PostXMLSerializedVerifyEmptyString()
        {
            Product p = new Product();

            p.Category = "ff";
            p.Id       = 4;
            p.Name     = "ff";
            p.Price    = 3.25f;
            var content = WebServiceUtils.MakeStringContent <Product>(p, Encoding.UTF8, "application/xml");
            var result  = this.WebServiceDriver.Post("/api/XML_JSON/Post", "application/xml", content, true);

            Assert.AreEqual(string.Empty, result);
        }
Exemplo n.º 21
0
        public void PostWithJson()
        {
            ProductJson p = new ProductJson();

            p.Category = "ff";
            p.Id       = 4;
            p.Name     = "ff";
            p.Price    = 3.25f;
            var content = WebServiceUtils.MakeStreamContent <ProductJson>(p, Encoding.UTF8, "application/json");
            var result  = this.WebServiceDriver.Post <ProductJson>("/api/XML_JSON/Post", "application/json", content, true);

            Assert.IsTrue(result == null);
        }
Exemplo n.º 22
0
        public void PutWithResponseWithExpectedStatus()
        {
            ProductJson p = new ProductJson
            {
                Category = "ff",
                Id       = 4,
                Name     = "ff",
                Price    = 3.25f
            };
            var req = WebServiceUtils.MakeStringContent <ProductJson>(p, Encoding.UTF8, "application/json");
            var res = this.WebServiceDriver.PutWithResponse("/api/XML_JSON/Put/1", "application/json", req, HttpStatusCode.OK);

            Assert.IsNotNull(res);
        }
Exemplo n.º 23
0
        public void PutStreamWithMakeStreamContent()
        {
            MemoryStream stream = new MemoryStream();
            StreamWriter writer = new StreamWriter(stream, Encoding.UTF8);

            writer.Write("TestStream");
            writer.Flush();
            stream.Position = 0;

            StreamContent content = WebServiceUtils.MakeStreamContent(stream, "text/plain");
            var           result  = this.WebServiceDriver.Put("/api/String/Put/1", "text/plain", content, true);

            Assert.AreEqual(string.Empty, result);
        }
Exemplo n.º 24
0
        public void PutJSONSerializedVerifyStatusCode()
        {
            ProductJson p = new ProductJson
            {
                Category = "ff",
                Id       = 4,
                Name     = "ff",
                Price    = 3.25f
            };
            var content = WebServiceUtils.MakeStringContent <ProductJson>(p, Encoding.UTF8, "application/json");
            var result  = this.WebServiceDriver.PutWithResponse("/api/XML_JSON/Put/1", "application/json", content, true);

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
        }
        public void VerifyPutContent()
        {
            Product p = new Product
            {
                Category = "ff",
                Id = 4,
                Name = "ff",
                Price = 3.25f
            };
            var content = WebServiceUtils.MakeStringContent<Product>(p, Encoding.UTF8, "application/xml");
            var result = CallContentWithResponse(WebServiceVerb.Put, "/api/XML_JSON/Put/1", "application/xml", content);

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
        }
Exemplo n.º 26
0
        public void PutJSONWithType()
        {
            ProductJson p = new ProductJson
            {
                Category = "ff",
                Id       = 4,
                Name     = "ff",
                Price    = 3.25f
            };
            var content = WebServiceUtils.MakeStringContent <ProductJson>(p, Encoding.UTF8, "application/json");
            var result  = this.WebServiceDriver.Put <ProductJson>("/api/XML_JSON/Put/1", "application/json", content, true);

            Assert.AreEqual(null, result);
        }
Exemplo n.º 27
0
            public SiteInfoResponseType GetSiteInfo(string locationParameter)
            {
                string siteId = locationParameter.Substring(locationParameter.LastIndexOf(":") + 1);

                SiteInfoResponseType resp = new SiteInfoResponseType();

                resp.site    = new SiteInfoResponseTypeSite[1];
                resp.site[0] = new SiteInfoResponseTypeSite();
                resp.site[0] = WebServiceUtils.GetSiteFromDb(siteId, true);

                resp.queryInfo = CuahsiBuilder.CreateQueryInfoType("GetSiteInfo", new string[] { locationParameter }, null, null, null, null);

                return(resp);
            }
Exemplo n.º 28
0
        public void PatchJSONWithoutBaseTest()
        {
            WebServiceDriver client = new WebServiceDriver(new Uri(url));
            ProductJson      p      = new ProductJson();

            p.Category = "ff";
            p.Id       = 4;
            p.Name     = "ff";
            p.Price    = 3.25f;
            var content = WebServiceUtils.MakeStringContent <ProductJson>(p, Encoding.UTF8, "application/json");
            var result  = client.PatchWithResponse("/api/XML_JSON/Patch/1", "application/json", content, true);

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
        }
Exemplo n.º 29
0
        public void PostXMLStreamSerializedVerifyStatusCode()
        {
            Product p = new Product
            {
                Category = "ff",
                Id       = 4,
                Name     = "ff",
                Price    = 3.25f
            };
            var content = WebServiceUtils.MakeStreamContent <Product>(p, Encoding.UTF8, "application/xml");
            var result  = this.WebServiceDriver.PostWithResponse("/api/XML_JSON/Post", "application/xml", content, true);

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
        }
Exemplo n.º 30
0
        /// <summary>
        /// Get a valid request message
        /// </summary>
        /// <returns>A valid request message</returns>
        private HttpRequestMessage GetValidRequestMessageWithContent()
        {
            Product product = new Product
            {
                Category = "ff",
                Id       = 4,
                Name     = "ff",
                Price    = 3.25f
            };

            return(new HttpRequestMessage(new HttpMethod(WebServiceVerb.Post), "/api/XML_JSON/Post")
            {
                Content = WebServiceUtils.MakeStreamContent(product, Encoding.UTF8, MediaType.AppXml)
            });
        }