Exemplo n.º 1
0
        public void ShowBackgroudImage(string key)
        {
            HttpContext.Response.ContentType = "image/jpeg";
            try
            {
                using (EquipmentLayoutServiceClient client = new EquipmentLayoutServiceClient())
                {
                    MethodReturnResult <EquipmentLayout> result = client.Get(key);

                    if (result.Code == 0 && result.Data != null && result.Data.BackgroundImage != null)
                    {
                        HttpContext.Response.BinaryWrite(result.Data.BackgroundImage);
                    }
                    else
                    {
                        System.Drawing.Bitmap backgroudImage = new Bitmap(10, 10);

                        Graphics g = Graphics.FromImage(backgroudImage);
                        g.FillRectangle(new SolidBrush(Color.FromArgb(25, 221, 237, 247)), new Rectangle(0, 0, 10, 10));
                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
                        backgroudImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                        HttpContext.Response.BinaryWrite(ms.ToArray());
                    }
                }
            }
            catch
            {
                System.Drawing.Bitmap  backgroudImage = new Bitmap(10, 10);
                System.IO.MemoryStream ms             = new System.IO.MemoryStream();
                backgroudImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                HttpContext.Response.BinaryWrite(ms.ToArray());
            }
            HttpContext.Response.End();
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Query(EquipmentLayoutQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (EquipmentLayoutServiceClient client = new EquipmentLayoutServiceClient())
                {
                    await Task.Run(() =>
                    {
                        StringBuilder where = new StringBuilder();
                        if (model != null)
                        {
                            if (!string.IsNullOrEmpty(model.Name))
                            {
                                where.AppendFormat(" {0} Key LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.Name);
                            }
                        }
                        PagingConfig cfg = new PagingConfig()
                        {
                            OrderBy = "Key",
                            Where   = where.ToString()
                        };
                        MethodReturnResult <IList <EquipmentLayout> > result = client.Get(ref cfg);

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
Exemplo n.º 3
0
        //
        // GET: /FMM/EquipmentLayout/
        public async Task <ActionResult> Index()
        {
            using (EquipmentLayoutServiceClient client = new EquipmentLayoutServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        OrderBy = "Key"
                    };
                    MethodReturnResult <IList <EquipmentLayout> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            return(View(new EquipmentLayoutQueryViewModel()));
        }
Exemplo n.º 4
0
        public IEnumerable <SelectListItem> GetLayoutList()
        {
            using (EquipmentLayoutServiceClient client = new EquipmentLayoutServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false
                };

                MethodReturnResult <IList <EquipmentLayout> > result = client.Get(ref cfg);
                if (result.Code <= 0)
                {
                    IEnumerable <SelectListItem> lst = from item in result.Data
                                                       select new SelectListItem()
                    {
                        Text  = item.Key,
                        Value = item.Key
                    };
                    return(lst);
                }
            }
            return(new List <SelectListItem>());
        }
Exemplo n.º 5
0
        public async Task <ActionResult> PagingQuery(string where, string orderBy, int?currentPageNo, int?currentPageSize)
        {
            if (ModelState.IsValid)
            {
                int pageNo   = currentPageNo ?? 0;
                int pageSize = currentPageSize ?? 20;
                if (Request["PageNo"] != null)
                {
                    pageNo = Convert.ToInt32(Request["PageNo"]);
                }
                if (Request["PageSize"] != null)
                {
                    pageSize = Convert.ToInt32(Request["PageSize"]);
                }

                using (EquipmentLayoutServiceClient client = new EquipmentLayoutServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <EquipmentLayout> > result = client.Get(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }