示例#1
0
        private void GetImgWidth(ZentCloud.BLLJIMP.Model.Slide item)
        {
            try
            {
                using (System.Net.WebClient webClient = new System.Net.WebClient())
                {
                    string imgUrl = item.ImageUrl;
                    if (!imgUrl.ToLower().StartsWith("http"))
                    {
                        imgUrl = "http://comeoncloud.comeoncloud.net" + imgUrl;
                    }
                    System.Uri   uri            = new Uri(imgUrl);
                    byte[]       b              = webClient.DownloadData(uri);
                    MemoryStream mes_keleyi_com = new MemoryStream(b);
                    Image        image          = Image.FromStream(mes_keleyi_com);
                    item.Width  = image.Width;
                    item.Height = image.Height;

                    if (bll.Update(new ZentCloud.BLLJIMP.Model.Slide(),
                                   string.Format("Width='{0}',Height='{1}'", item.Width, item.Height),
                                   string.Format("AutoID={0}", item.AutoID)) > 0)
                    {
                        SetTextErrorMessage(item.Width + " " + item.Height + " " + item.AutoID);
                    }
                    else
                    {
                        SetTextErrorMessage("出错" + item.AutoID);
                    }
                }
            }
            catch (Exception ex)
            {
                SetTextErrorMessage("出错" + item.AutoID);
            }
        }
示例#2
0
文件: Get.ashx.cs 项目: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            string slideId = context.Request["slide_id"];

            if (string.IsNullOrEmpty(slideId))
            {
                resp.errmsg  = "slide_id 为必填项,请检查";
                resp.errcode = 1;
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            ZentCloud.BLLJIMP.Model.Slide slide = bll.Get <ZentCloud.BLLJIMP.Model.Slide>(string.Format(" AutoID={0} AND WebsiteOwner='{1}' ", slideId, bll.WebsiteOwner));
            if (slide == null)
            {
                resp.errmsg  = "没有找到广告,请检查";
                resp.errcode = 1;
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            RequestModel requestModel = new RequestModel();

            requestModel.img_url    = slide.ImageUrl;
            requestModel.link       = slide.Link;
            requestModel.link_text  = slide.LinkText;
            requestModel.slide_sort = slide.Sort;
            requestModel.slide_type = slide.Type;
            context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(requestModel));
            return;
        }
示例#3
0
文件: Update.ashx.cs 项目: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string       data = context.Request["data"];
            RequestModel requestModel;

            try
            {
                requestModel = ZentCloud.Common.JSONHelper.JsonToModel <RequestModel>(context.Request["data"]);
            }
            catch (Exception)
            {
                resp.errcode = -1;
                resp.errmsg  = "json格式错误,请检查";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            if (requestModel.slide_id <= 0)
            {
                resp.errcode = -1;
                resp.errmsg  = "slide_id 为必填项,请检查";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            if (string.IsNullOrEmpty(requestModel.img_url))
            {
                resp.errcode = -1;
                resp.errmsg  = "img_url 为必填项,请检查";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            if (string.IsNullOrEmpty(requestModel.link))
            {
                resp.errcode = -1;
                resp.errmsg  = "link 为必填项,请检查";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            if (string.IsNullOrEmpty(requestModel.link_text))
            {
                resp.errcode = -1;
                resp.errmsg  = "link_text 为必填项,请检查";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            if (string.IsNullOrEmpty(requestModel.slide_type))
            {
                resp.errcode = -1;
                resp.errmsg  = "slide_type 为必填项,请检查";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            ZentCloud.BLLJIMP.Model.Slide slide = bll.Get <ZentCloud.BLLJIMP.Model.Slide>(string.Format(" WebsiteOwner='{0}' AND AutoID={1} ", bll.WebsiteOwner, requestModel.slide_id));
            if (slide == null)
            {
                resp.errmsg  = "没有找到记录";
                resp.errcode = 1;
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            slide.ImageUrl     = requestModel.img_url;
            slide.Link         = requestModel.link;
            slide.LinkText     = requestModel.link_text;
            slide.Type         = requestModel.slide_type;
            slide.Sort         = requestModel.slide_sort;
            slide.WebsiteOwner = bll.WebsiteOwner;
            if (bll.Update(slide))
            {
                resp.errcode   = 0;
                resp.errmsg    = "ok";
                resp.isSuccess = true;
            }
            else
            {
                resp.errmsg  = "修改广告出错";
                resp.errcode = 1;
            }
            context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
        }