public string AddPatientFamilyPlanningMethod(int patientId, string PatientFPId, int userId)
        {
            try
            {
                patientId            = Convert.ToInt32(HttpContext.Current.Session["PatientPK"]);
                patientMasterVisitId = Convert.ToInt32(HttpContext.Current.Session["PatientmasterVisitId"]);

                var fpMethod             = new PatientFamilyPlanningMethodManager();
                int familyPlanningStatus = Convert.ToInt32(Session["FamilyPlanningStatus"].ToString());
                //var familyPlanningMethods = JsonConvert.DeserializeObject<IEnumerable<object>>(PatientFPId);
                var familyPlanningMethods = new JavaScriptSerializer().Deserialize <IEnumerable <object> >(PatientFPId);

                int count = familyPlanningMethods.Count();
                if (count > 0)
                {
                    foreach (var iteMethod in familyPlanningMethods)
                    {
                        result      = fpMethod.AddFamilyPlanningMethod(patientId, familyPlanningStatus, Convert.ToInt32(iteMethod.ToString()), Convert.ToInt32(HttpContext.Current.Session["AppUserId"]));
                        jsonMessage = (result > 0) ? "family planning status addedd successfully" : "";
                    }
                }
            }
            catch (Exception e)
            {
                jsonMessage = e.Message;
            }
            return(jsonMessage);
        }
        public void ShouldGetRecomendations()
        {
            // Arrange
            var controller = new ProductsController(
                new StubIProductRepository(),
                new StubIProductRecommendationRepository
            {
                GetProductRecommendationsInt32 = (id) => new List <RecommendedProduct>
                {
                    new RecommendedProduct {
                        ProductId = 2
                    },
                    new RecommendedProduct {
                        ProductId = 3
                    }
                }
            });

            SetupControllerForTests(controller);

            // Act
            var result          = controller.GetRecommendations(1);
            var recommendations = new JavaScriptSerializer().Deserialize <IEnumerable <Recommendation> >(result.Content.ReadAsStringAsync().Result);

            // Assert
            Assert.AreEqual(result.StatusCode, HttpStatusCode.OK);
            Assert.AreEqual(2, recommendations.Count());
        }
Esempio n. 3
0
        public HttpResponseMessage DeleteMulti(HttpRequestMessage request, string selectedProductCategories)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;

                if (ModelState.IsValid)
                {
                    var productCategories = new JavaScriptSerializer().Deserialize <List <int> >(selectedProductCategories);
                    foreach (var item in productCategories)
                    {
                        _productCategoryService.Delete(item);
                    }
                    _productCategoryService.SaveChanges();

                    response = request.CreateResponse(HttpStatusCode.OK, productCategories.Count());
                }
                else
                {
                    response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
                }

                return response;
            }));
        }
        public HttpResponseMessage DeleteMulti(HttpRequestMessage request, string checkProductCategories)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    return response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    var listProductCategory = new JavaScriptSerializer().Deserialize <List <int> >(checkProductCategories);
                    foreach (var item in listProductCategory)
                    {
                        _productCategoryService.Delete(item);
                    }

                    _productCategoryService.Save();

                    response = request.CreateResponse(HttpStatusCode.Created, listProductCategory.Count());
                }

                return response;
            }));
        }
        public ActionResult RestfulAPI(int?pageNumber)
        {
            StudentModel model = new StudentModel();

            model.PageNumber = (pageNumber == null ? 1 : Convert.ToInt32(pageNumber));
            model.PageSize   = 4;


            var url        = "http://localhost:52228/EADRestService.svc/FetchAllStudents";
            var webrequest = (HttpWebRequest)System.Net.WebRequest.Create(url);

            using (var response = webrequest.GetResponse())
                using (var reader = new StreamReader(response.GetResponseStream()))
                {
                    var             result = reader.ReadToEnd();
                    IList <Student> studentsFromRestAPI = new JavaScriptSerializer()
                                                          .Deserialize <IList <Student> >(Convert.ToString(result));


                    if (model.Students != null)
                    {
                        model.Students = studentsFromRestAPI.OrderBy(x => x.StudentID)
                                         .Skip(model.PageSize * (model.PageNumber - 1))
                                         .Take(model.PageSize).ToList();

                        model.TotalCount = studentsFromRestAPI.Count();
                        var page = (model.TotalCount / model.PageSize) - (model.TotalCount % model.PageSize == 0 ? 1 : 0);
                        model.PagerCount = page + 1;
                    }
                }
            return(View(model));
        }
Esempio n. 6
0
        // View client profile with last 5 created tickets
        public ActionResult Profile()
        {
            try
            {
                //Authentication
                var client = Connector.GetHttpClient();
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(scheme: "Bearer",
                                                                                           parameter: Session["TokenNumber"].ToString() + ":" + Session["UserName"]);
                client = GetHttpClientWithSession();

                //handle if this is null == user does not have access
                var httpResponse        = client.GetAsync($"Ticket/getClientTickets/{GetUserID()}").Result;
                var httpResponseContent = httpResponse.Content.ReadAsStringAsync().Result;
                var tickets             = new JavaScriptSerializer().Deserialize <IEnumerable <TicketSave> >(httpResponseContent);
                var clientTicket        = new ClientTicketView()
                {
                    Tickets = tickets.ToList(),
                    Client  = GetClient()
                };
                if (tickets.Count() == 0)
                {
                    ViewBag.Message = "You don't have any ticket yet";
                    return(View("Profile", clientTicket));
                }
                return(View("Profile", clientTicket));
            }
            catch (Exception ex)
            {
                GlobalVariable.log.Write(LogLevel.Error, ex);
            }
            return(HttpNotFound());
        }
Esempio n. 7
0
        public String getRandomTrivia()
        {
            var    trivia          = "";
            var    foodTrivias     = new JavaScriptSerializer().Deserialize <List <FoodTrivia> >(foodTriviaServiceClient.GetFoodTrivia());
            var    numberDistance1 = foodTrivias.Count();
            Random random          = new Random();
            int    randomnum1      = random.Next(numberDistance1);

            trivia = foodTrivias.ElementAt(randomnum1).Food_trivia;
            return(trivia);
        }
Esempio n. 8
0
        public HttpResponseMessage CreateUpdate(HttpRequestMessage request)
        {
            return(CreateHttpResponse(request, () => {
                HttpResponseMessage response = null;
                bool result = true;
                var botSetting = System.Web.HttpContext.Current.Request.Unvalidated.Form["bot-setting"];
                if (botSetting == null)
                {
                    result = false;
                    response = request.CreateResponse(HttpStatusCode.NoContent, result);
                    return response;
                }
                var botSettingVm = new JavaScriptSerializer {
                    MaxJsonLength = Int32.MaxValue, RecursionLimit = 100
                }.Deserialize <BotSettingViewModel>(botSetting);

                var botSystem = System.Web.HttpContext.Current.Request.Unvalidated.Form["bot-systemconfig"];
                if (botSystem == null)
                {
                    result = false;
                    response = request.CreateResponse(HttpStatusCode.NoContent, result);
                    return response;
                }
                var botSystemVm = new JavaScriptSerializer {
                    MaxJsonLength = Int32.MaxValue, RecursionLimit = 100
                }.Deserialize <List <SystemConfig> >(botSystem);

                Setting settingDb = new Setting();
                settingDb.UpdateSetting(botSettingVm);
                _settingService.Update(settingDb);
                _settingService.Save();

                if (botSystemVm.Count() != 0)
                {
                    _settingService.DeleteConfigByBotID(settingDb.BotID);
                    foreach (var item in botSystemVm)
                    {
                        SystemConfig sys = new SystemConfig();
                        sys.BotID = item.BotID;
                        sys.Code = item.Code;
                        sys.ValueString = item.ValueString;
                        sys.ValueInt = item.ValueInt;
                        _settingService.CreateKeyConfig(sys);
                    }
                }
                _settingService.Save();

                response = request.CreateResponse(HttpStatusCode.OK, result);
                return response;
            }));
        }
Esempio n. 9
0
        private async Task <List <Tweet> > GetURI(Uri u, DateTime end, string url)
        {
            try
            {
                var          response = string.Empty;
                List <Tweet> tweets   = new List <Tweet>();

                using (var client = new HttpClient())
                {
                    HttpResponseMessage result = await client.GetAsync(u);

                    if (result.IsSuccessStatusCode)
                    {
                        response = await result.Content.ReadAsStringAsync();

                        var jsonParse = new JavaScriptSerializer().Deserialize <List <Tweet> >(response);
                        tweets = jsonParse;

                        while (jsonParse.Count == MAX_RECORDS_RETURNED)
                        {
                            //change querystring with updated daterange
                            //This new date is identical to the last value in the previously parsed list.
                            //This is incase there are more tweets with the same datetime stamp.
                            var newStartDate = DateTime.Parse(jsonParse[jsonParse.Count() - 1].stamp);

                            UriBuilder newUri = BuildQueryString(newStartDate.ToString(), end.ToString(), url);

                            result = await client.GetAsync(newUri.ToString());

                            response = await result.Content.ReadAsStringAsync();

                            jsonParse = new JavaScriptSerializer().Deserialize <List <Tweet> >(response);

                            tweets.AddRange(jsonParse);
                        }
                    }
                    else
                    {
                        //some error resulted here.  The API call doesn't exaclty return a code.
                        throw new Exception(result.ReasonPhrase);
                    }
                }

                return(tweets);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 10
0
        // GET: Tweet
        public ActionResult Tweets()
        {
            var webClient = new System.Net.WebClient();

            webClient.QueryString.Add("startDate", startDate.ToString());
            webClient.QueryString.Add("endDate", endDate.ToString());
            string results = webClient.DownloadString(apiUrl);

            List <Tweet> tweets = new List <Tweet>();

            var jsonParse = new JavaScriptSerializer().Deserialize <List <Tweet> >(results);

            tweets = jsonParse;

            while (jsonParse.Count() == MAX_RECORDS_RETURNED)
            {
                //This new date is identical to the last value in the previously parsed list.
                //This is incase there are more tweets with the same datetime stamp.
                var newStartDate = DateTime.Parse(jsonParse[jsonParse.Count() - 1].stamp);

                webClient = new System.Net.WebClient();
                webClient.QueryString.Add("startDate", newStartDate.ToString());
                webClient.QueryString.Add("endDate", endDate.ToString());
                results = webClient.DownloadString(apiUrl);

                jsonParse = new JavaScriptSerializer().Deserialize <List <Tweet> >(results);

                tweets.AddRange(jsonParse);
            }

            List <Tweet> updatedListOfTweets = RemoveDuplicates(tweets);

            ViewBag.StartDate = startDate;
            ViewBag.EndDate   = endDate;

            return(View(updatedListOfTweets));
        }
Esempio n. 11
0
        public HttpResponseMessage DeleteMulti(HttpRequestMessage request, string jsonlistId)
        {
            HttpResponseMessage response = null;

            if (!ModelState.IsValid)
            {
                response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
            }
            else
            {
                List <int> listId = new JavaScriptSerializer().Deserialize <List <int> >(jsonlistId);

                IDictionary <string, object> dic = new Dictionary <string, object>();
                dic.Add("lstCategoryID", listId);

                List <int> lstCategoryID = productCategoryService.Search(dic)
                                           .Select(x => x.Categories.CategoryID).Distinct().ToList();

                if (lstCategoryID.Count > 0)
                {
                    dic["lstCategoryID"] = lstCategoryID;
                    List <Category> lstCategory = categoryService.Search(dic).ToList();
                    string          name        = string.Empty;
                    for (int i = 0; i < lstCategory.Count; i++)
                    {
                        if (i < lstCategory.Count - 1)
                        {
                            name += lstCategory[i].CategoryName + ", ";
                        }
                        else if (i == lstCategory.Count - 1)
                        {
                            name += lstCategory[i].CategoryName;
                        }
                    }

                    string msgError = string.Format("Xóa thất bại! Danh mục {0} đã được khai báo. Vui lòng kiểm tra lại", name);
                    response = request.CreateResponse(HttpStatusCode.BadGateway, msgError);
                    return(response);
                }

                foreach (var item in listId)
                {
                    categoryService.Delete(item);
                }
                categoryService.SaveChanges();
                response = request.CreateResponse(HttpStatusCode.OK, listId.Count());
            }
            return(response);
        }
Esempio n. 12
0
 public HttpResponseMessage DeleteMutile(HttpRequestMessage request, string listProductId)
 {
     return(CreateHttpResponse(request, () =>
     {
         HttpResponseMessage response = null;
         var listId = new JavaScriptSerializer().Deserialize <List <int> >(listProductId);
         foreach (var item in listId)
         {
             _productService.Delete(item);
         }
         _productService.SaveChange();
         response = request.CreateResponse(HttpStatusCode.OK, listId.Count());
         return response;
     }));
 }
Esempio n. 13
0
        public JsonResult ImportDetail(string list)
        {
            var          json            = new JavaScriptSerializer().Deserialize <List <Inventory> >(list);
            var          accDocDetailDao = new AccDocDetailDao();
            AccDocDetail accDocDetail    = new AccDocDetail();
            var          inventoryDao    = new InventoryDao();
            Inventory    inventory       = new Inventory();

            if (json.Count() > 0)
            {
                accDocDetailDao.RemoveDetail(json[0].DocNo);
                inventoryDao.RemoveDetail(json[0].DocNo);
                foreach (var item in json)
                {
                    //Insert detail vào bảng AccDocDetail
                    accDocDetail.DocCode     = item.DocCode;
                    accDocDetail.DocNo       = item.DocNo;
                    accDocDetail.WarehouseID = item.WarehouseID;
                    accDocDetail.ProductID   = item.ProductID;
                    accDocDetail.Quantity    = item.Quantity;
                    if (accDocDetailDao.CheckExist(accDocDetail.DocCode, accDocDetail.DocNo, accDocDetail.WarehouseID, accDocDetail.ProductID) == true)
                    {
                        accDocDetailDao.UpdateQuantity(accDocDetail.DocCode, accDocDetail.DocNo, accDocDetail.WarehouseID, accDocDetail.ProductID, (int)accDocDetail.Quantity);
                    }
                    else
                    {
                        accDocDetailDao.Insert(accDocDetail);
                    }

                    //Insert detail vào bảng Inventory
                    if (inventoryDao.CheckExist(accDocDetail.DocCode, accDocDetail.DocNo, accDocDetail.WarehouseID, accDocDetail.ProductID) == true)
                    {
                        inventoryDao.UpdateQuantity(accDocDetail.DocCode, accDocDetail.DocNo, accDocDetail.WarehouseID, accDocDetail.ProductID, (int)item.Quantity);
                    }
                    else
                    {
                        inventoryDao.Insert(item);
                    }
                }
            }

            return(Json(new
            {
                status = true
            }));
        }
Esempio n. 14
0
        public void DisplayGrid(object sender, EventArgs e)
        {
            var client = new WebClient();

            string name = txtSearch.Text;

            if (name != "")
            {
                url = url + String.Format("/{0}", name);
            }

            var result = client.DownloadString(url); //URI

            Console.WriteLine(Environment.NewLine + result);

            CustomerTable[] customers;
            try
            {
                //more than one element in json
                //deserialize to an array
                customers = new JavaScriptSerializer().Deserialize <CustomerTable[]>(result);
                if (customers.Count() == 1)
                {
                    txtCustomerID.Text = customers[0].CustomerID.ToString();
                    txtName.Text       = customers[0].Name;
                    txtAge.Text        = customers[0].Age.ToString();
                }
                gvSimpleTable.DataSource = customers;
            }
            catch (Exception ex)
            {
                //one element in json
                //deserialize to an object
                //add to a list
                CustomerTable        c1   = new JavaScriptSerializer().Deserialize <CustomerTable>(result);
                List <CustomerTable> list = new List <CustomerTable>();
                list.Add(c1);
                gvSimpleTable.DataSource = list;
                txtCustomerID.Text       = c1.CustomerID.ToString();
                txtName.Text             = c1.Name;
                txtAge.Text = c1.Age.ToString();
            }

            gvSimpleTable.DataBind();
        }
Esempio n. 15
0
        public void GetCitiesTest()
        {
            var connectionString = GetConnectionString();
            var url  = GetBaseUrl() + "/api/cities";
            var r    = Get(url);
            var list = new JavaScriptSerializer().Deserialize <List <City> >(r);

            using (var context = new RaterPriceContext())
            {
                var cities = context.Cities.Select(c => c);
                Assert.AreEqual(list.Count(), cities.Count());
                foreach (var c in cities)
                {
                    var id   = c.Id;
                    var name = c.Name;
                    Assert.AreEqual(list.Any(x => x.Name == name && x.Id == id), true);
                }
            }
        }
Esempio n. 16
0
        public HttpResponseMessage DeleteMulti(HttpRequestMessage request, string jsonlistId)
        {
            HttpResponseMessage response = null;

            if (!ModelState.IsValid)
            {
                response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
            }
            else
            {
                var listContracts = new JavaScriptSerializer().Deserialize <List <int> >(jsonlistId);

                foreach (var item in listContracts)
                {
                    contractsService.DeleteContracts(item);
                }
                response = request.CreateResponse(HttpStatusCode.OK, listContracts.Count());
            }
            return(response);
        }
Esempio n. 17
0
        public HttpResponseMessage deleteMulti(HttpRequestMessage request, string listID)
        {
            HttpResponseMessage response = null;

            try
            {
                var ids = new JavaScriptSerializer().Deserialize <List <int> >(listID);
                foreach (var item in ids)
                {
                    _productCategoryService.Delete(item);
                }
                _productCategoryService.Save();
                response = request.CreateResponse(HttpStatusCode.OK, ids.Count());
            }
            catch (Exception ex)
            {
                response = request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
            }
            return(response);
        }
Esempio n. 18
0
        public HttpResponseMessage DeleteMulti(HttpRequestMessage request, string jsonlistId)
        {
            HttpResponseMessage response = null;

            if (!ModelState.IsValid)
            {
                response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
            }
            else
            {
                List <int> listId = new JavaScriptSerializer().Deserialize <List <int> >(jsonlistId);

                foreach (var item in listId)
                {
                    productCategoryService.Delete(item);
                }
                productCategoryService.SaveChanges();
                response = request.CreateResponse(HttpStatusCode.OK, listId.Count());
            }
            return(response);
        }
Esempio n. 19
0
        public void GetDomainsFromRest()
        {
            //must make sure the data is not already processed for mask 4 for the test to pass
            string result = string.Empty;

            requestGet = (HttpWebRequest)WebRequest.Create("http://localhost/BIdataApi/api/domains?count=5&mask=4");
            requestGet.UseDefaultCredentials = true;

            // Get response
            using (HttpWebResponse response = requestGet.GetResponse() as HttpWebResponse)
            {
                StreamReader reader = new StreamReader(response.GetResponseStream());
                result = reader.ReadToEnd();
                Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            }

            List <Domain> domainList = new JavaScriptSerializer().Deserialize <List <Domain> >(result);

            Assert.IsNotNull(domainList);
            Assert.AreEqual(5, domainList.Count());
        }
        public void ShouldGetStates()
        {
            // Arrange
            var controller = new StatesController(new StubIStateProvinceRepository
            {
                GetStateProvinces = () => new List <StateProvince> {
                    new StateProvince {
                        StateProvinceId = 1
                    }
                }
            });

            SetupControllerForTests(controller);

            // Act
            var result = controller.Get();
            var states = new JavaScriptSerializer().Deserialize <IEnumerable <StateProvince> >(result.Content.ReadAsStringAsync().Result);

            // Assert
            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
            Assert.AreEqual(1, states.Count());
        }
Esempio n. 21
0
        public void GetShopsTest()
        {
            var          connectionString = GetConnectionString();
            const int    cityId           = 8;
            const string querySearch      = "О";
            var          url  = GetBaseUrl() + $"api/shops/search?cityId={cityId}&querySearch={querySearch}";
            var          r    = Get(url);
            var          list = new JavaScriptSerializer().Deserialize <List <Shop> >(r);

            using (RaterPriceContext context = RaterPriceContext.Create())
            {
                var shops = context.Shops.Where(s => s.CityId == cityId && s.Name.IndexOf(querySearch) > -1).Select(s => s);
                Assert.AreEqual(list.Count(), shops.Count());
                foreach (var s in shops)
                {
                    var shopId     = s.Id;
                    var shopCityId = s.CityId;
                    var shopName   = s.Name;
                    Assert.AreEqual(list.Any(x => x.Name == shopName && x.Id == shopId && x.CityId == shopCityId), true);
                }
            }
        }
Esempio n. 22
0
        public ActionResult Query(PageInfoModel pgingModel, ACHDViewModel model)
        {
            string         result      = string.Empty;
            IndexViewModel outputModel = new IndexViewModel();

            try
            {
                List <ACHD> queryResult = new JavaScriptSerializer().Deserialize <List <ACHD> >(this.QueryACHD(pgingModel, model));
                //outputModel

                if (queryResult != null && queryResult.Count() > 0)
                {
                    //this.QueryACBD
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(Json(new { data = result }, JsonRequestBehavior.AllowGet));
            //return View("Index", outputModel);
        }
Esempio n. 23
0
        public void GetFacebookAllPagesFromRest()
        {
            requestGet                       = (HttpWebRequest)WebRequest.Create("http://localhost/BIdataApi/api/facebook/");
            requestGet.Method                = "GET";
            requestGet.ContentType           = "application/json";
            requestGet.UseDefaultCredentials = true;

            string result = string.Empty;

            // Get response
            using (HttpWebResponse response = requestGet.GetResponse() as HttpWebResponse)
            {
                StreamReader reader = new StreamReader(response.GetResponseStream());
                result = reader.ReadToEnd();
                Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            }

            List <Page> pList = new JavaScriptSerializer().Deserialize <List <Page> >(result);

            Assert.IsNotNull(pList);
            Assert.AreNotEqual(0, pList.Count());
        }
Esempio n. 24
0
        public HttpResponseMessage DeleteMulti(HttpRequestMessage request, string checkedProducts)
        {
            Func <HttpResponseMessage> Func = () =>
            {
                HttpResponseMessage response = null;
                if (ModelState.IsValid)
                {
                    var           listProduct = new JavaScriptSerializer().Deserialize <List <int> >(checkedProducts);
                    List <string> listPath    = new List <string>()
                    {
                    };

                    foreach (var productID in listProduct)
                    {
                        List <ProductImage> listProductImage = _productImageService.GetProductImageByProdutID(productID);
                        for (int i = 0; i < listProductImage.Count(); i++)
                        {
                            listPath.Add(listProductImage[i].Path);
                        }
                        _productService.Delete(productID);
                    }
                    _productService.SaveChanges();
                    for (int i = 0; i < listPath.Count(); i++)
                    {
                        DeleteElementImage(listPath[i]);
                    }

                    response = request.CreateResponse(HttpStatusCode.Created, listProduct.Count());
                }
                else
                {
                    response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
                }
                return(response);
            };

            return(CreateHttpResponse(request, Func));
        }
Esempio n. 25
0
        public void GetTwitterMentionsPagedFromRest()
        {
            requestGet                       = (HttpWebRequest)WebRequest.Create("http://localhost/BIdataApi/api/twitter/mentions?page=5");
            requestGet.Method                = "GET";
            requestGet.ContentType           = "application/json";
            requestGet.UseDefaultCredentials = true;

            string result = string.Empty;

            // Get response
            using (HttpWebResponse response = requestGet.GetResponse() as HttpWebResponse)
            {
                StreamReader reader = new StreamReader(response.GetResponseStream());
                result = reader.ReadToEnd();
                Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            }

            List <KeywordStatus> statusList = new JavaScriptSerializer().Deserialize <List <KeywordStatus> >(result);

            Assert.IsNotNull(statusList);
            Assert.AreNotEqual(0, statusList.Count());
            Assert.AreEqual(10, statusList[0].StatusList.Count());
        }
Esempio n. 26
0
        public void ShouldGetOrdersHistoryForCustomer()
        {
            // Arrange
            var targetTrackingId = Guid.NewGuid();
            var personGuid       = Guid.NewGuid();

            var controller = new OrdersController(
                new StubIOrderHistoryRepository
            {
                GetOrdersHistoriesInt32 = id => id.Equals(101)
                        ? new List <OrderHistory>
                {
                    new OrderHistory()
                }
                        : null
            },
                null,
                new StubIPersonRepository
            {
                GetPersonGuid = id => id.Equals(personGuid) ? new Person {
                    Id = 101
                } : null
            },
                null,
                null,
                null);

            SetupControllerForTests(controller);

            // Act
            var response = controller.GetHistory(personGuid.ToString());
            var orders   = new JavaScriptSerializer().Deserialize <IEnumerable <OrderHistoryInfo> >(response.Content.ReadAsStringAsync().Result);

            // Assert
            Assert.IsNotNull(orders);
            Assert.AreEqual(1, orders.Count());
        }
Esempio n. 27
0
        public ActionResult SaveLayout(string portletsSerializedJson, int portalID)
        {
            try
            {
                using (var unit = GetUnitOfWork())
                {
                    var portlets = new JavaScriptSerializer().Deserialize <List <PortletViewModel> >(portletsSerializedJson);

                    if (portlets.Count() == 0)
                    {
                        unit.Service <UserPortalPortlet>().Delete(x => x.UserID == Client.User.UserID && x.PortalID == portalID);
                    }

                    List <UserPortalPortlet> layoutData = new List <UserPortalPortlet>();
                    portlets.ForEach((portlet) =>
                    {
                        layoutData.Add(new UserPortalPortlet()
                        {
                            UserID    = Client.User.UserID,
                            PortalID  = portalID,
                            PortletID = portlet.PortletID,
                            Column    = portlet.Column,
                            Row       = portlet.Row
                        });
                    });

                    ((IPortalService)unit.Service <Portal>()).SaveLayout(layoutData);

                    unit.Save();
                }
                return(Success("Portal layout saved"));
            }
            catch (Exception e)
            {
                return(Failure("Something went wrong : ", e));
            }
        }
Esempio n. 28
0
        public HttpResponseMessage Delete(HttpRequestMessage request, string checkedDaoTaoLienTucIds)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (ModelState.IsValid)
                {
                    var listDaoTaoLienTucIds = new JavaScriptSerializer().Deserialize <List <int> >(checkedDaoTaoLienTucIds);
                    foreach (var item in listDaoTaoLienTucIds)
                    {
                        _daoTaoLienTucService.Delete(item);
                    }

                    _daoTaoLienTucService.SaveChanges();

                    response = request.CreateResponse(HttpStatusCode.OK, listDaoTaoLienTucIds.Count());
                }
                else
                {
                    request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
                }
                return response;
            }));
        }
Esempio n. 29
0
        protected void exportPDF_Click(object sender, EventArgs e)
        {
            //grab the json panel data from the hidden field
            List <ButtonPanel> buttonPanels = new JavaScriptSerializer().Deserialize <List <ButtonPanel> >(panelData.Value);

            //make a new pdf sharp doc and related drawing tools
            orderForm            = new PdfDocument();
            orderForm.Info.Title = "Helvar Button Panels";

            XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);

            Arial20Bold     = new XFont("Arial", 20, XFontStyle.Bold, options);
            Arial12Regular  = new XFont("Arial", 12, XFontStyle.Regular, options);
            Arial10Regular  = new XFont("Arial", 10, XFontStyle.Regular, options);
            Arial10RegularU = new XFont("Arial", 10, XFontStyle.Underline, options);
            Arial8Regular   = new XFont("Arial", 8, XFontStyle.Regular, options);

            pen         = new XPen(new XColor());
            BorderWidth = XUnit.FromMillimeter(10);

            //get button images
            string buttonImagePath  = null;
            XImage buttonLeftImage  = null;
            XImage buttonRightImage = null;

            try
            {
                buttonImagePath  = HttpContext.Current.Server.MapPath("~/images/button_left.png");
                buttonLeftImage  = XImage.FromFile(buttonImagePath);
                buttonImagePath  = HttpContext.Current.Server.MapPath("~/images/button_right.png");
                buttonRightImage = XImage.FromFile(buttonImagePath);
            }
            catch (Exception exception)
            {
                Console.Write(exception.ToString());
                Response.Clear();
                Response.ContentType = "text/html";
                Response.Write(exception.ToString());
                Response.End();
                return;
            }

            //set a few page variables
            int numberOfPanels = buttonPanels.Count();
            int numberOfPages  = (int)Math.Ceiling((double)numberOfPanels / 2);
            int currentPage    = 1;
            int currentPanel   = 0;
            int panelsOnPage   = 0;

            //start drawing the actual pages
            while (currentPage <= numberOfPages)
            {
                page             = orderForm.AddPage();
                page.Orientation = PageOrientation.Portrait;
                page.Width       = XUnit.FromMillimeter(210);
                page.Height      = XUnit.FromMillimeter(297);

                LineHeight12 = page.Height / 50;
                LineHeight10 = page.Height / 60;

                gfx = XGraphics.FromPdfPage(page);

                tf = new XTextFormatter(gfx);

                //make a rectangle at the top of the page and draw the helvar logo and customer details
                rect = new XRect(BorderWidth, BorderWidth, XUnit.FromMillimeter(180), LineHeight12);

                string imagePath = HttpContext.Current.Server.MapPath("~/images/helvarPrint.png");
                XImage image     = XImage.FromFile(imagePath);
                gfx.DrawImage(image, rect.Left, rect.Top);

                tf.Alignment = XParagraphAlignment.Center;
                tf.DrawString("Button Panel Specification", Arial20Bold, XBrushes.Black, rect, XStringFormats.TopLeft);

                rect.Offset(0, XUnit.FromMillimeter(15));

                bool customLabelFound = false;
                foreach (ButtonPanel panel in buttonPanels)
                {
                    foreach (Button button in panel.buttons)
                    {
                        if (button != null && button.code.ToUpper() == "CUSTOM")
                        {
                            tf.DrawString("NB custom panel requiring new artwork!", new XFont("Arial", 14, XFontStyle.Bold, options), XBrushes.Red, rect, XStringFormats.TopLeft);
                            customLabelFound = true;
                            break;
                        }
                    }

                    if (customLabelFound == true)
                    {
                        break;
                    }
                }

                rect.Offset(0, XUnit.FromMillimeter(15));
                tf.Alignment = XParagraphAlignment.Left;
                XRect footer = new XRect(BorderWidth * 2, page.Height - (BorderWidth * 2) - LineHeight12, page.Width, LineHeight12);
                tf.DrawString("Page " + currentPage + " of " + numberOfPages, Arial12Regular, XBrushes.Black, footer, XStringFormats.TopLeft);

                column1 = new XRect(rect.Left, rect.Top, rect.Width / 2, LineHeight12);
                column2 = new XRect(rect.Left + (rect.Width / 2), rect.Top, rect.Width / 2, LineHeight12);

                XRect column1a = new XRect(column1.Left, column1.Top, column1.Width / 2, LineHeight12);
                XRect column1b = new XRect(column1.Left + (column1.Width / 2), column1.Top, column1.Width / 2, LineHeight12);

                XRect column2a = new XRect(column2.Left, column2.Top, column2.Width / 2, LineHeight12);
                XRect column2b = new XRect(column2.Left + (column2.Width / 2), column2.Top, column2.Width / 2, LineHeight12);

                tf.Alignment = XParagraphAlignment.Right;
                tf.DrawString("Customer Name:  ", Arial12Regular, XBrushes.Black, column1a, XStringFormats.TopLeft);
                column1a.Offset(0, LineHeight12);
                tf.DrawString("Company Name:  ", Arial12Regular, XBrushes.Black, column1a, XStringFormats.TopLeft);
                column1a.Offset(0, LineHeight12);
                tf.DrawString("Contact Number:  ", Arial12Regular, XBrushes.Black, column1a, XStringFormats.TopLeft);
                column1a.Offset(0, LineHeight12);
                tf.DrawString("Email Address:  ", Arial12Regular, XBrushes.Black, column1a, XStringFormats.TopLeft);
                column1a.Offset(0, LineHeight12);
                tf.DrawString("Project Name:  ", Arial12Regular, XBrushes.Black, column2a, XStringFormats.TopLeft);
                column2a.Offset(0, LineHeight12);
                tf.DrawString("Customer Order Num:  ", Arial12Regular, XBrushes.Black, column2a, XStringFormats.TopLeft);
                column2a.Offset(0, LineHeight12);
                tf.DrawString("Helvar Order Num:  ", Arial12Regular, XBrushes.Black, column2a, XStringFormats.TopLeft);

                tf.Alignment = XParagraphAlignment.Left;
                tf.DrawString(custNameInp.Text, Arial12Regular, XBrushes.Blue, column1b, XStringFormats.TopLeft);
                column1b.Offset(0, LineHeight12);
                tf.DrawString(compNameInp.Text, Arial12Regular, XBrushes.Blue, column1b, XStringFormats.TopLeft);
                column1b.Offset(0, LineHeight12);
                tf.DrawString(contNumInp.Text, Arial12Regular, XBrushes.Blue, column1b, XStringFormats.TopLeft);
                column1b.Offset(0, LineHeight12);
                tf.DrawString(emailAddInp.Text, Arial12Regular, XBrushes.Blue, column1b, XStringFormats.TopLeft);
                column1b.Offset(0, LineHeight12);
                tf.DrawString(projNameInp.Text, Arial12Regular, XBrushes.Blue, column2b, XStringFormats.TopLeft);
                column2b.Offset(0, LineHeight12);
                tf.DrawString(ordNumInp.Text, Arial12Regular, XBrushes.Blue, column2b, XStringFormats.TopLeft);
                column2b.Offset(0, LineHeight12);
                tf.DrawString(helvarOrdNumInp.Text, Arial12Regular, XBrushes.Blue, column2b, XStringFormats.TopLeft);

                panelsOnPage = 0;

                // now loop through the panels drawing each one in turn
                while (currentPanel < numberOfPanels && panelsOnPage < 2)
                {
                    ButtonPanel bp = buttonPanels[currentPanel];
                    //draw the background panel
                    try
                    {
                        string panelImagePath = HttpContext.Current.Server.MapPath("~/images/" + bp.style + "_1to1.png");
                        XImage panelImage     = XImage.FromFile(panelImagePath);

                        //STARTING_LEFT_POS = (page.Width / 2) - (panelImage.PointWidth / 2);
                        STARTING_LEFT_POS = BorderWidth * 2;
                        STARTING_TOP_POS  = (panelsOnPage == 0) ? 70.0 : 160.0;
                        gfx.DrawImage(panelImage, STARTING_LEFT_POS, XUnit.FromMillimeter(STARTING_TOP_POS));
                    }
                    catch (Exception exception)
                    {
                        Console.Write(exception.ToString());
                        Response.Clear();
                        Response.ContentType = "text/html";
                        Response.Write(exception.ToString());
                        Response.End();
                        return;
                    }

                    //use the second column to write the part numbers and product code etc
                    //column2a.Offset(0, LineHeight12 * 3);
                    //column2b.Offset(0, LineHeight12 * 3);
                    column2a.Y   = XUnit.FromMillimeter(STARTING_TOP_POS);
                    column2b.Y   = XUnit.FromMillimeter(STARTING_TOP_POS);
                    tf.Alignment = XParagraphAlignment.Right;
                    tf.DrawString("Part No:  ", Arial10Regular, XBrushes.Black, column2a, XStringFormats.TopLeft);
                    tf.Alignment = XParagraphAlignment.Left;
                    tf.DrawString(bp.SAP.ToUpper(), Arial10Regular, XBrushes.Blue, column2b, XStringFormats.TopLeft);
                    column2a.Offset(0, LineHeight12);
                    column2b.Offset(0, LineHeight12);
                    tf.Alignment = XParagraphAlignment.Right;
                    tf.DrawString("Quantity:  ", Arial10Regular, XBrushes.Black, column2a, XStringFormats.TopLeft);
                    tf.Alignment = XParagraphAlignment.Left;
                    tf.DrawString(bp.quantity.ToUpper(), Arial10Regular, XBrushes.Blue, column2b, XStringFormats.TopLeft);
                    column2a.Offset(0, LineHeight12);
                    column2b.Offset(0, LineHeight12);
                    tf.Alignment = XParagraphAlignment.Right;
                    tf.DrawString("Notes:  ", Arial10Regular, XBrushes.Black, column2a, XStringFormats.TopLeft);
                    tf.Alignment = XParagraphAlignment.Left;
                    column2b     = new XRect(column2b.Left, column2b.Top, column2b.Width, LineHeight12 * 4);
                    tf.DrawString(bp.notes, Arial10Regular, XBrushes.Blue, column2b, XStringFormats.TopLeft);

                    //draw the buttons
                    double buttonTop     = column2b.Top + (LineHeight12 * 4);
                    XRect  buttonColumn1 = new XRect(column2.Left, buttonTop, column2.Width / 3, LineHeight12);
                    XRect  buttonColumn2 = new XRect(buttonColumn1.Left + buttonColumn1.Width, buttonTop, buttonColumn1.Width, LineHeight12);
                    XRect  buttonColumn3 = new XRect(buttonColumn2.Left + buttonColumn1.Width, buttonTop, buttonColumn1.Width, LineHeight12);

                    tf.Alignment = XParagraphAlignment.Center;
                    tf.DrawString("BUTTONS", Arial10RegularU, XBrushes.Black, buttonColumn2, XStringFormats.TopLeft);

                    buttonTop = buttonTop + LineHeight12;
                    buttonColumn1.Offset(0, buttonTop);
                    buttonColumn2.Offset(0, buttonTop);
                    buttonColumn3.Offset(0, buttonTop);

                    foreach (Button btn in bp.buttons)
                    {
                        if (btn != null)
                        {
                            //line a rectangle up with the panel image, then offest the buttons/labels from that point
                            rect     = new XRect(STARTING_LEFT_POS, XUnit.FromMillimeter(STARTING_TOP_POS), XUnit.FromMillimeter(BUTTUN_RECT_WIDTH), XUnit.FromMillimeter(BUTTON_RECT_HEIGHT));
                            iconRect = new XRect(STARTING_LEFT_POS, XUnit.FromMillimeter(STARTING_TOP_POS), XUnit.FromMillimeter(10), XUnit.FromMillimeter(10));

                            XBrush textColour = (btn.code.ToUpper() == "CUSTOM") ? XBrushes.Red : XBrushes.Black;

                            switch (btn.location)
                            {
                            case "LEFT_1":
                                tf.Alignment    = XParagraphAlignment.Right;
                                buttonColumn1.Y = buttonTop;
                                tf.DrawString("Left 1: " + btn.code, Arial10Regular, textColour, buttonColumn1, XStringFormats.TopLeft);

                                rect.Offset(XUnit.FromMillimeter(20.5), XUnit.FromMillimeter(20.5));
                                gfx.DrawImage(buttonLeftImage, rect.Left, rect.Top);
                                iconRect.Offset(XUnit.FromMillimeter(27), XUnit.FromMillimeter(21.25));
                                rect.Offset(XUnit.FromMillimeter(3.5), XUnit.FromMillimeter(2));
                                break;

                            case "LEFT_2":
                                tf.Alignment    = XParagraphAlignment.Right;
                                buttonColumn1.Y = buttonTop + LineHeight12;
                                tf.DrawString("Left 2: " + btn.code, Arial10Regular, textColour, buttonColumn1, XStringFormats.TopLeft);

                                rect.Offset(XUnit.FromMillimeter(20.5), XUnit.FromMillimeter(29.5));
                                gfx.DrawImage(buttonLeftImage, rect.Left, rect.Top);
                                iconRect.Offset(XUnit.FromMillimeter(27), XUnit.FromMillimeter(30.25));
                                rect.Offset(XUnit.FromMillimeter(3.5), XUnit.FromMillimeter(2));
                                break;

                            case "LEFT_3":
                                tf.Alignment    = XParagraphAlignment.Right;
                                buttonColumn1.Y = buttonTop + (LineHeight12 * 2);
                                tf.DrawString("Left 3: " + btn.code, Arial10Regular, textColour, buttonColumn1, XStringFormats.TopLeft);

                                rect.Offset(XUnit.FromMillimeter(20.5), XUnit.FromMillimeter(38.5));
                                gfx.DrawImage(buttonLeftImage, rect.Left, rect.Top);
                                iconRect.Offset(XUnit.FromMillimeter(27), XUnit.FromMillimeter(39.25));
                                rect.Offset(XUnit.FromMillimeter(3.5), XUnit.FromMillimeter(2));
                                break;

                            case "LEFT_4":
                                tf.Alignment    = XParagraphAlignment.Right;
                                buttonColumn1.Y = buttonTop + (LineHeight12 * 3);
                                tf.DrawString("Left 4: " + btn.code, Arial10Regular, textColour, buttonColumn1, XStringFormats.TopLeft);

                                rect.Offset(XUnit.FromMillimeter(20.5), XUnit.FromMillimeter(48));
                                gfx.DrawImage(buttonLeftImage, rect.Left, rect.Top);
                                iconRect.Offset(XUnit.FromMillimeter(27), XUnit.FromMillimeter(48.75));
                                rect.Offset(XUnit.FromMillimeter(3.5), XUnit.FromMillimeter(2));
                                break;

                            case "LEFT_5":
                                tf.Alignment    = XParagraphAlignment.Right;
                                buttonColumn1.Y = buttonTop + (LineHeight12 * 4);
                                tf.DrawString("Left 5: " + btn.code, Arial10Regular, textColour, buttonColumn1, XStringFormats.TopLeft);

                                rect.Offset(XUnit.FromMillimeter(20.5), XUnit.FromMillimeter(57));
                                gfx.DrawImage(buttonLeftImage, rect.Left, rect.Top);
                                iconRect.Offset(XUnit.FromMillimeter(27), XUnit.FromMillimeter(57.75));
                                rect.Offset(XUnit.FromMillimeter(3.5), XUnit.FromMillimeter(2));
                                break;

                            case "CENTER_1":
                                tf.Alignment    = XParagraphAlignment.Center;
                                buttonColumn2.Y = buttonTop;
                                tf.DrawString("Center 1: " + btn.code, Arial10Regular, textColour, buttonColumn2, XStringFormats.TopLeft);

                                rect.Offset(XUnit.FromMillimeter(33.5), XUnit.FromMillimeter(20.5));
                                gfx.DrawImage(buttonLeftImage, rect.Left, rect.Top);
                                iconRect.Offset(XUnit.FromMillimeter(40), XUnit.FromMillimeter(21.25));
                                rect.Offset(XUnit.FromMillimeter(3.5), XUnit.FromMillimeter(2));
                                break;

                            case "CENTER_2":
                                tf.Alignment    = XParagraphAlignment.Center;
                                buttonColumn2.Y = buttonTop + LineHeight12;
                                tf.DrawString("Center 2: " + btn.code, Arial10Regular, textColour, buttonColumn2, XStringFormats.TopLeft);

                                rect.Offset(XUnit.FromMillimeter(33.5), XUnit.FromMillimeter(29.5));
                                gfx.DrawImage(buttonLeftImage, rect.Left, rect.Top);
                                iconRect.Offset(XUnit.FromMillimeter(40), XUnit.FromMillimeter(30.25));
                                rect.Offset(XUnit.FromMillimeter(3.5), XUnit.FromMillimeter(2));
                                break;

                            case "CENTER_3":
                                tf.Alignment    = XParagraphAlignment.Center;
                                buttonColumn2.Y = buttonTop + (LineHeight12 * 2);
                                tf.DrawString("Center 3: " + btn.code, Arial10Regular, textColour, buttonColumn2, XStringFormats.TopLeft);

                                rect.Offset(XUnit.FromMillimeter(33.5), XUnit.FromMillimeter(38.5));
                                gfx.DrawImage(buttonLeftImage, rect.Left, rect.Top);
                                iconRect.Offset(XUnit.FromMillimeter(40), XUnit.FromMillimeter(39.25));
                                rect.Offset(XUnit.FromMillimeter(3.5), XUnit.FromMillimeter(2));
                                break;

                            case "CENTER_4":
                                tf.Alignment    = XParagraphAlignment.Center;
                                buttonColumn2.Y = buttonTop + (LineHeight12 * 3);
                                tf.DrawString("Center 4: " + btn.code, Arial10Regular, textColour, buttonColumn2, XStringFormats.TopLeft);

                                rect.Offset(XUnit.FromMillimeter(33.5), XUnit.FromMillimeter(48));
                                gfx.DrawImage(buttonLeftImage, rect.Left, rect.Top);
                                iconRect.Offset(XUnit.FromMillimeter(40), XUnit.FromMillimeter(48.75));
                                rect.Offset(XUnit.FromMillimeter(3.5), XUnit.FromMillimeter(2));
                                break;

                            case "CENTER_5":
                                tf.Alignment    = XParagraphAlignment.Center;
                                buttonColumn2.Y = buttonTop + (LineHeight12 * 4);
                                tf.DrawString("Center 5: " + btn.code, Arial10Regular, textColour, buttonColumn2, XStringFormats.TopLeft);

                                rect.Offset(XUnit.FromMillimeter(33.5), XUnit.FromMillimeter(57));
                                gfx.DrawImage(buttonLeftImage, rect.Left, rect.Top);
                                iconRect.Offset(XUnit.FromMillimeter(40), XUnit.FromMillimeter(57.75));
                                rect.Offset(XUnit.FromMillimeter(3.5), XUnit.FromMillimeter(2));
                                break;

                            case "RIGHT_1":
                                tf.Alignment    = XParagraphAlignment.Right;
                                buttonColumn3.Y = buttonTop;
                                tf.DrawString("Right 1: " + btn.code, Arial10Regular, textColour, buttonColumn3, XStringFormats.TopLeft);

                                rect.Offset(XUnit.FromMillimeter(46), XUnit.FromMillimeter(20.5));
                                gfx.DrawImage(buttonRightImage, rect.Left, rect.Top);
                                iconRect.Offset(XUnit.FromMillimeter(52), XUnit.FromMillimeter(21.25));
                                rect.Offset(XUnit.FromMillimeter(1.5), XUnit.FromMillimeter(2));
                                break;

                            case "RIGHT_2":
                                tf.Alignment    = XParagraphAlignment.Right;
                                buttonColumn3.Y = buttonTop + LineHeight12;
                                tf.DrawString("Right 2: " + btn.code, Arial10Regular, textColour, buttonColumn3, XStringFormats.TopLeft);

                                rect.Offset(XUnit.FromMillimeter(46), XUnit.FromMillimeter(29.5));
                                gfx.DrawImage(buttonRightImage, rect.Left, rect.Top);
                                iconRect.Offset(XUnit.FromMillimeter(52), XUnit.FromMillimeter(30.25));
                                rect.Offset(XUnit.FromMillimeter(1.5), XUnit.FromMillimeter(2));
                                break;

                            case "RIGHT_3":
                                tf.Alignment    = XParagraphAlignment.Right;
                                buttonColumn3.Y = buttonTop + (LineHeight12 * 2);
                                tf.DrawString("Right 3: " + btn.code, Arial10Regular, textColour, buttonColumn3, XStringFormats.TopLeft);

                                rect.Offset(XUnit.FromMillimeter(46), XUnit.FromMillimeter(38.5));
                                gfx.DrawImage(buttonRightImage, rect.Left, rect.Top);
                                iconRect.Offset(XUnit.FromMillimeter(52), XUnit.FromMillimeter(39.25));
                                rect.Offset(XUnit.FromMillimeter(1.5), XUnit.FromMillimeter(2));
                                break;

                            case "RIGHT_4":
                                tf.Alignment    = XParagraphAlignment.Right;
                                buttonColumn3.Y = buttonTop + (LineHeight12 * 3);
                                tf.DrawString("Right 4: " + btn.code, Arial10Regular, textColour, buttonColumn3, XStringFormats.TopLeft);

                                rect.Offset(XUnit.FromMillimeter(46), XUnit.FromMillimeter(48));
                                gfx.DrawImage(buttonRightImage, rect.Left, rect.Top);
                                iconRect.Offset(XUnit.FromMillimeter(52), XUnit.FromMillimeter(48.75));
                                rect.Offset(XUnit.FromMillimeter(1.5), XUnit.FromMillimeter(2));
                                break;

                            case "RIGHT_5":
                                tf.Alignment    = XParagraphAlignment.Right;
                                buttonColumn3.Y = buttonTop + (LineHeight12 * 4);
                                tf.DrawString("Right 5: " + btn.code, Arial10Regular, textColour, buttonColumn3, XStringFormats.TopLeft);

                                rect.Offset(XUnit.FromMillimeter(46), XUnit.FromMillimeter(57));
                                gfx.DrawImage(buttonRightImage, rect.Left, rect.Top);
                                iconRect.Offset(XUnit.FromMillimeter(52), XUnit.FromMillimeter(57.75));
                                rect.Offset(XUnit.FromMillimeter(1.5), XUnit.FromMillimeter(2));
                                break;
                            }

                            if (null == btn.label)
                            {
                                try
                                {
                                    string iconImagePath = HttpContext.Current.Server.MapPath("~/images/icons/" + btn.icon + ".png");
                                    XImage iconImage     = XImage.FromFile(iconImagePath);

                                    gfx.DrawImage(iconImage, iconRect.Left, iconRect.Top);
                                }
                                catch (Exception exception)
                                {
                                    Console.Write(exception.ToString());
                                }
                            }
                            else
                            {
                                tf.Alignment = XParagraphAlignment.Left;
                                tf.DrawString(checkStringLength(btn.label), Arial8Regular, XBrushes.White, rect, XStringFormats.TopLeft);
                            }
                        }
                    }

                    currentPanel++;
                    panelsOnPage++;
                }

                currentPage++;
            }

            //******************************************************************************************
            //******************************************************************************************

            MemoryStream ms = new MemoryStream();

            orderForm.Save(ms, false);

            HttpContext.Current.Response.Buffer = true;
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.ClearHeaders();
            HttpContext.Current.Response.ContentType = "application/pdf";
            HttpContext.Current.Response.AddHeader("content-length", ms.Length.ToString());
            HttpContext.Current.Response.BinaryWrite(ms.ToArray());
            HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=\"" + HttpContext.Current.Server.UrlEncode("HelvarButtonPanel.pdf") + "\"");
            HttpContext.Current.Response.Flush();
            ms.Close();
            HttpContext.Current.Response.End();
        }
Esempio n. 30
0
        public ActionResult MoveDownTable(string questionGroupStr, int seq)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("Down Table").ToInputLogString());

            try
            {
                var tableModel = new TableViewModel();
                tableModel.QuestionGroupTableList = new List <QuestionGroupTableViewModel>();
                var questionGroupDataList = new JavaScriptSerializer().Deserialize <QuestionGroupTableViewModel[]>(questionGroupStr);

                for (int i = 0; i < questionGroupDataList.Count(); i++)
                {
                    var model = new QuestionGroupTableViewModel();

                    if (i == 0)
                    {
                        if (questionGroupDataList[i].QuestionSeq == seq)
                        {
                            model.QuestionGroupId         = questionGroupDataList[i + 1].QuestionGroupId;
                            model.QuestionGroupName       = questionGroupDataList[i + 1].QuestionGroupName;
                            model.QuestionGroupNo         = questionGroupDataList[i + 1].QuestionGroupNo;
                            model.QuestionGroupPassAmount = questionGroupDataList[i + 1].QuestionGroupPassAmount;
                            model.QuestionSeq             = questionGroupDataList[i + 1].QuestionSeq;
                        }
                        else
                        {
                            model.QuestionGroupId         = questionGroupDataList[i].QuestionGroupId;
                            model.QuestionGroupName       = questionGroupDataList[i].QuestionGroupName;
                            model.QuestionGroupNo         = questionGroupDataList[i].QuestionGroupNo;
                            model.QuestionGroupPassAmount = questionGroupDataList[i].QuestionGroupPassAmount;
                            model.QuestionSeq             = questionGroupDataList[i].QuestionSeq;
                        }
                    }
                    else
                    {
                        if (questionGroupDataList[i].QuestionSeq == seq)
                        {
                            model.QuestionGroupId         = questionGroupDataList[i + 1].QuestionGroupId;
                            model.QuestionGroupName       = questionGroupDataList[i + 1].QuestionGroupName;
                            model.QuestionGroupNo         = questionGroupDataList[i + 1].QuestionGroupNo;
                            model.QuestionGroupPassAmount = questionGroupDataList[i + 1].QuestionGroupPassAmount;
                            model.QuestionSeq             = questionGroupDataList[i + 1].QuestionSeq;
                        }
                        else if (questionGroupDataList[i - 1].QuestionSeq == seq)
                        {
                            model.QuestionGroupId         = questionGroupDataList[i - 1].QuestionGroupId;
                            model.QuestionGroupName       = questionGroupDataList[i - 1].QuestionGroupName;
                            model.QuestionGroupNo         = questionGroupDataList[i - 1].QuestionGroupNo;
                            model.QuestionGroupPassAmount = questionGroupDataList[i - 1].QuestionGroupPassAmount;
                            model.QuestionSeq             = questionGroupDataList[i - 1].QuestionSeq;
                        }
                        else
                        {
                            model.QuestionGroupId         = questionGroupDataList[i].QuestionGroupId;
                            model.QuestionGroupName       = questionGroupDataList[i].QuestionGroupName;
                            model.QuestionGroupNo         = questionGroupDataList[i].QuestionGroupNo;
                            model.QuestionGroupPassAmount = questionGroupDataList[i].QuestionGroupPassAmount;
                            model.QuestionSeq             = questionGroupDataList[i].QuestionSeq;
                        }
                    }

                    tableModel.QuestionGroupTableList.Add(model);
                }


                return(PartialView("~/Views/MappingProductType/_QuestionGroupCreateList.cshtml", tableModel));
            }
            catch (Exception ex)
            {
                Logger.Info(_logMsg.Clear().SetPrefixMsg("Down Table").ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }