コード例 #1
0
        public ActionResult Detail(int Id)
        {
            var             auto    = AutoService.GetCar(Id);
            AutoDetailModel detail  = new AutoDetailModel();
            List <ImgModel> imgs    = new List <ImgModel>();
            var             imglist = auto.Img.Where(i => i.Type == ImgType.Temp).ToList();

            imglist.ForEach(i =>
            {
                var img  = new ImgModel();
                img.Id   = i.ID;
                img.Name = i.Name;
                img.Url  = i.Address;
                img.Type = i.Type;
            });
            detail.AutoId  = auto.ID;
            detail.Brand   = auto.Brand.Name;
            detail.Maker   = auto.Maker.Name;
            detail.Mileage = auto.Mileage;
            detail.img     = imgs;
            detail.Price   = auto.Price;
            detail.Sort    = auto.Sort;
            detail.Style   = auto.BodyStyle;
            detail.Desc    = auto.Description;
            detail.Engine  = auto.Engine;
            detail.Trans   = auto.Transmission;
            return(View(detail));
        }
コード例 #2
0
        public async Task <ActionResult> HandleCreateImg(HttpPostedFileBase postedFile)
        {
            try
            {
                IApiSvc  apiSvc = new ApiSvc.ApiSvc();
                ImgModel model  = new ImgModel()
                {
                    ImgName      = Request.Params[0],
                    CategoryName = Request.Params[1],
                    UploadBy     = Session["User"].ToString()
                };

                model.ImgURL = "IMG" + "_" + DateTime.Now.Ticks + Path.GetExtension(postedFile.FileName);
                var flag = await apiSvc.PostImg(model);

                if (flag)
                {
                    for (int i = 0; i < Request.Files.Count; i++)
                    {
                        HttpPostedFileBase file = Request.Files[i];
                        await apiSvc.UploadImg(file, model.ImgURL.Split('.')[0]);
                    }
                }
                else
                {
                    TempData["IsSuccess"] = false;
                }
            }
            catch
            {
                TempData["IsSuccess"] = false;
            }
            return(RedirectToAction("Upload"));
        }
コード例 #3
0
ファイル: RepairAdd.aspx.cs プロジェクト: Jyf524/Repair
        protected void rauFiles_FileUploaded(object sender, FileUploadedEventArgs e)
        {
            string filepath = "";

            if (ImgList.Count >= 5)
            {
                RadAjaxManager1.Alert("最多上传5张图!");
                return;
            }
            if (rauFiles.UploadedFiles.Count > 0)
            {
                foreach (UploadedFile file in rauFiles.UploadedFiles)
                {
                    string uploadPath = "/UpLoad/" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + "/";
                    if (!Directory.Exists(uploadPath))
                    {
                        Directory.CreateDirectory(Server.MapPath(uploadPath));
                    }
                    string name = DateTime.Now.ToString("yyyyMMddHHmmssff") + ".png";
                    filepath = Server.MapPath(uploadPath) + name;
                    file.SaveAs(filepath);
                    ImgModel img = new ImgModel();
                    img.ID     = ImgList.Count + 1;
                    img.imgUrl = uploadPath + name;
                    ImgList.Add(img);
                    RadListView1.Rebind();
                }
                //imgPic.ImageUrl = uploadPath + name;
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: yinxuequn/Loreal-ImageDemo
        static void Main(string[] args)
        {
            _baseDirectory = Environment.CurrentDirectory;
            _imgModel      = CreateImgModel();

            Image destImg = ReadDestImage();

            InitParameters(destImg.Width);
            //绘制文字图片
            System.Drawing.Bitmap fontBmp = DrawFontImage();

            System.Drawing.Bitmap blankBmp = new Bitmap(destImg.Width, _currentHeight + _lineHeight + destImg.Height);

            System.Drawing.Graphics graph = System.Drawing.Graphics.FromImage(blankBmp);
            graph.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
            //设置高质量,低速度呈现平滑程度
            graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            //合并图片
            //放置文字图片
            graph.DrawImage(fontBmp, 0, 0, fontBmp.Width, fontBmp.Height);
            //DrawImage(img, 照片与相框的左边距, 照片与相框的上边距, 照片宽, 照片高);
            graph.DrawImage(destImg, 0, _currentHeight + _lineHeight, destImg.Width, destImg.Height);
            //保存处理后的图片
            SaveDestImag(blankBmp);
        }
コード例 #5
0
 public async Task <HttpStatusCode> PostImg([FromBody] ImgModel value)
 {
     if (await services.CreateImg(value))
     {
         return(HttpStatusCode.OK);
     }
     return(HttpStatusCode.BadRequest);
 }
コード例 #6
0
        public ActionResult Test()
        {
            var model = new ImgModel();

            model.Img = "http://photocdn.sohu.com/20160629/Img456995877.jpeg";

            return(View(model));
        }
コード例 #7
0
ファイル: ImgApiSvc.cs プロジェクト: BugInTheAir/ImgGallery
 public async Task <bool> CreateImg(ImgModel md)
 {
     if (md.CategoryName == null || md.CategoryName == "" ||
         md.ImgName == null || md.CategoryName == "")
     {
         return(false);
     }
     return(await bll.CreateImg(md));
 }
コード例 #8
0
ファイル: BaseSpider.cs プロジェクト: shenghai3711/Crawler
        /// <summary>
        /// 上传图片
        /// </summary>
        /// <param name="base64Array"></param>
        /// <returns></returns>
        protected List <string> UploadImgs(params string[] base64Array)
        {
            var imgList = new List <string>();

            if (base64Array == null || base64Array.Length == 0)
            {
                return(imgList);
            }
            var imgModels = new ImgModel[base64Array.Length];

            for (int i = 0; i < base64Array.Length; i++)
            {
                string md5 = Encrypt.ToMd5(base64Array[i], Encoding.UTF8);
                //string uploadedUrl = RedisClient.GetValueFromHash(nameof(ImgModel), md5);
                var model = ImgList.FirstOrDefault(i => i.MD5Key == md5);//await this.Context.ImgModels.FirstOrDefaultAsync(i => i.MD5Key == md5);
                imgModels[i] = model ?? new ImgModel
                {
                    MD5Key = md5,
                    Base64 = base64Array[i]
                };
            }
            var uploadList = imgModels.Where(i => string.IsNullOrEmpty(i.UploadedUrl)).ToList();

            if (uploadList.Count == 0)
            {
                return(imgModels.Select(i => i.UploadedUrl).ToList());
            }
            var client  = HttpClientFactory.Create();
            var dataDic = new Dictionary <string, string>
            {
                { "action", "upfileImages" },
                { "merchantID", this.MerchantID },
                { "imgDataJson", JsonConvert.SerializeObject(uploadList.Select(u => u.Base64)) }
            };
            string postData = string.Join("&", dataDic.Select(d => $"{d.Key}={d.Value.ToUrlEncode()}"));
            string result   = client.Request(this.ImportMaterialHost, HttpMethod.POST, postData, Encoding.UTF8, "application/x-www-form-urlencoded");
            var    root     = JToken.Parse(result);

            if (root.Value <bool>("OK"))
            {
                int count = 0;
                foreach (var item in root["Message"].Values <string>())
                {
                    uploadList[count].UploadedUrl = item;
                    ImgList.Add(new ImgModel
                    {
                        UploadedUrl = item,
                        MD5Key      = uploadList[count].MD5Key
                    });
                    //RedisClient.SetEntryInHash(nameof(ImgModel), uploadList[count].MD5Key, uploadList[count].UploadedUrl);
                    count++;
                }
                imgList.AddRange(imgModels.Select(i => i.UploadedUrl));
            }
            return(imgList);
        }
コード例 #9
0
ファイル: RepairAdd.aspx.cs プロジェクト: Jyf524/Repair
        protected void RadListView1_ItemCommand(object sender, RadListViewCommandEventArgs e)
        {
            int id = Convert.ToInt32(e.CommandArgument.ToString());

            if (e.CommandName.ToString() == "Delete")
            {
                ImgModel img = new ImgModel();
                img = ImgList.Where(x => x.ID == id).SingleOrDefault();
                ImgList.Remove(img);
                RadListView1.Rebind();
            }
        }
コード例 #10
0
        public bool UploadIOImage(ImgModel imgmodel)
        {
            string root   = SystemInfo.ImgPath;
            bool   result = false;

            try
            {
                string   str     = root;
                string[] strpath = imgmodel.ImgPath.Split(new string[] { "\\" }, StringSplitOptions.RemoveEmptyEntries);
                if (strpath.Length > 0)
                {
                    for (int i = 0; i < strpath.Length - 1; i++)
                    {
                        str += "\\" + strpath[i];
                        try
                        {
                            if (!Directory.Exists(str))
                            {
                                Directory.CreateDirectory(str);
                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Fatal("上传图片到服务器异常!UploadIOImage()" + ex.Message + str + "\r\n");
                        }
                    }

                    try
                    {
                        MemoryStream stream = new MemoryStream(Convert.FromBase64String(imgmodel.ImgStream));
                        using (FileStream outputStream = new FileStream(root + "\\" + imgmodel.ImgPath, FileMode.Create, FileAccess.Write))
                        {
                            stream.CopyTo(outputStream);
                            outputStream.Flush();
                        }
                        stream.Close();
                        stream.Dispose();
                        System.Threading.Thread.Sleep(100);
                        result = true;
                    }
                    catch (Exception ex)
                    {
                        logger.Fatal("上传图片到服务器异常!UploadIOImage()" + ex.Message + root + "\\" + imgmodel.ImgPath + "\r\n");
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Fatal("上传图片到服务器异常!UploadIOImage()" + ex.Message + "\r\n");
            }

            return(result);
        }
コード例 #11
0
        public string Upload(ImgModel model)
        {
            string Result = string.Empty;

            try
            {
                Result = CharConversion.SaveImg(model.ImgIp, model.ImgDisk, model.ImgRoot, model.UserAccount, model.ImgAttribute, model.ImgUpLoadDate, model.ImgName, model.ImgString);
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex.ToString());
            }
            return(Result);
        }
コード例 #12
0
ファイル: ApiSvc.cs プロジェクト: BugInTheAir/ImgGallery
        public async Task <bool> PostImg(ImgModel model)
        {
            using (var client = new HttpClient())
            {
                List <CategoryModel> ls = new List <CategoryModel>();
                var uri           = new Uri(PathConfig.API_PATH + "img");
                var json          = JsonConvert.SerializeObject(model);
                var stringContent = new StringContent(json, Encoding.UTF8, "application/json");
                var response      = await client.PostAsync(uri, stringContent);

                if (response.IsSuccessStatusCode)
                {
                    return(true);
                }
                return(false);
            }
        }
コード例 #13
0
 /// <summary>
 /// 获得进场图片
 /// </summary>
 /// <param name="imgpath">进场图片路径</param>
 /// <returns></returns>
 public JsonResult GetEntranceImages(string ImagePathEntrance)
 {
     try
     {
         if (string.IsNullOrEmpty(ImagePathEntrance))
         {
             throw new Exception("图片为空");
         }
         ImgModel img  = new ImgModel();
         string   path = System.IO.Path.Combine(ImagePath, ImagePathEntrance);
         img.ImgBig   = GetPic(path);
         path         = path.Replace("Big", "Small");
         img.ImgSmall = GetPic(path);
         if (img.ImgSmall.Length == 0)
         {
             img.ImgSmall = LoadingPic(false);
         }
         if (img.ImgBig.Length == 0)
         {
             img.ImgBig = LoadingPic(true);
         }
         object entranceimg = new
         {
             Base64ImageEntrance      = img.ImgBig,
             Base64ImageEntranceSmall = img.ImgSmall
         };
         return(Json(entranceimg, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         object entranceimg = new
         {
             Base64ImageEntrance      = LoadingPic(true),
             Base64ImageEntranceSmall = LoadingPic(false)
         };
         TxtLogServices.WriteTxtLog("获取进场图片异常 异常信息:{0}", ex.Message);
         return(Json(entranceimg, JsonRequestBehavior.AllowGet));
     }
 }
コード例 #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
                {
                    Maticsoft.Model.Replacement molr = bllr.GetModel(Request.QueryString["ID"].ToString());//引用id所在行的数据
                    if (molr == null)
                    {
                        Response.Write("<script>window.location.href='~/BackLogin.aspx'</script>");
                    }

                    Maticsoft.Model.MachineFatherType molmf = bllmf.GetModel(molr.MachineFatherID);
                    Maticsoft.Model.MachineSonType    molms = bllms.GetModel(molr.MachineSonID);

                    Label1.Text = molr.ReplacementID;
                    Label2.Text = molr.ReplacementModel;
                    Label3.Text = molr.ReplacementName;
                    Label4.Text = molmf.MachineFatherName + "-" + molms.MachineSonName;
                    Label5.Text = molr.ReplacementState;
                    Label6.Text = molr.ReplacementAddTime.ToString();

                    string st = molr.ReplacementPicture;

                    string[] sop = st.Split(';');

                    ImgList.Clear();

                    for (int i = 0; i < sop.Length - 1; i++)
                    {
                        ImgModel img = new ImgModel();
                        img.ID     = ImgList.Count + 1;
                        img.imgUrl = sop[i];
                        ImgList.Add(img);
                        RadListView1.Rebind();
                    }
                }
            }
        }
コード例 #15
0
        public HttpResponseMessage DeleteCommodityImg(ImgModel model)
        {
            string Result = string.Empty;
            ///图片保存位置
            string FilePath = model.ImgDisk + "://" + model.ImgRoot + "/" + model.UserAccount + "/" + model.ImgAttribute + "/" + model.SourceFileName;

            //JArray jArray = new JArray();
            //List<int> list = new List<int>();
            if (File.Exists(FilePath))
            {
                File.Delete(FilePath);
                Result = "1";
            }
            else
            {
                Result = "2";
            }
            //Result = ReturnCode(jArray).ToString();
            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("utf-8"))
            };

            return(Respend);
        }
コード例 #16
0
 public async Task <bool> CreateImg(ImgModel img)
 {
     try
     {
         var           repo = uow.ImageRepo();
         List <tblImg> ls   = new List <tblImg>();
         ls.Add(new tblImg()
         {
             Cat          = await GetCat(img.CategoryName),
             ImgId        = "IMG" + DateTime.Now.Ticks,
             ImgName      = img.ImgName,
             UploadedDate = TimeStamp.GetTimeNowInUnix().ToString(),
             UploadedBy   = img.UploadBy,
             FileName     = img.ImgURL,
             View         = 1,
             IsValid      = false
         });
         return(await repo.AddEntities(ls));
     }
     catch
     {
         return(false);
     }
 }
コード例 #17
0
        public HttpResponseMessage MoveCommodityImg(ImgModel model)
        {
            string Result = string.Empty;

            try
            {
                ///缓存图片地址
                string OldPath = string.Empty;

                ///新地址文件夹
                string FilePath = string.Empty;

                ///图片新地址
                string NewPath = string.Empty;

                ///图片类型
                string ImgType = string.Empty;

                ///图片排序
                string imgSort = string.Empty;


                OldPath  = ROOT_PATH + model.SourceFileName;
                ImgType  = System.IO.Path.GetExtension(OldPath);
                FilePath = model.ImgDisk + ":/" + model.ImgRoot + "/" + model.UserAccount + "/" + model.ImgAttribute + "/";

                ///判断文件夹是否存在
                if (Directory.Exists(FilePath) == false)
                {
                    Directory.CreateDirectory(FilePath);
                }

                //NewPath = FilePath + model.ImgName + ImgType;
                NewPath = FilePath + model.ImgName;

                if (File.Exists(NewPath))
                {
                    File.Delete(NewPath);

                    ///移动文件
                    File.Copy(OldPath, NewPath);
                    Result = "1";
                }
                else
                {
                    ///移动文件
                    File.Copy(OldPath, NewPath);
                    Result = "1";
                }
            }
            catch (Exception ex)
            {
                Result = "2";
                LogHelper.Error(ex.ToString());
            }


            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("utf-8"))
            };

            return(Respend);
        }
コード例 #18
0
        public HttpResponseMessage MoveImges(ImgModel model)
        {
            ///图片Key
            string Key = string.Empty;

            ///图片Value
            string Value = string.Empty;

            ///缓存图片地址
            string OldPath = string.Empty;

            ///新地址文件夹
            string FilePath = string.Empty;

            ///图片新地址
            string NewPath = string.Empty;

            ///图片类型
            string ImgType = string.Empty;

            string ImgSort = string.Empty;

            #region 多张一起修改
            JObject jsons = (JObject)JsonConvert.DeserializeObject(model.SourceFileName);

            List <string> list = new List <string>();
            foreach (var i in jsons)
            {
                Key   = i.Key.ToString();
                Value = i.Value.ToString();
                if (!Value.Contains(model.UserAccount))
                {
                    OldPath  = ROOT_PATH + Value;
                    ImgType  = System.IO.Path.GetExtension(Value);
                    FilePath = model.ImgDisk + ":/" + model.ImgRoot + "/" + model.UserAccount + "/" + model.ImgAttribute + "/";

                    ///判断文件夹是否存在
                    if (Directory.Exists(FilePath) == false)
                    {
                        Directory.CreateDirectory(FilePath);
                    }

                    string[] path = Directory.GetFiles(FilePath).OrderBy(x => x.Length).ThenBy(x => x).ToArray();

                    if (path.Length == 0)
                    {
                        ImgSort = 0.ToString("d2");
                    }
                    else
                    {
                        int Before = path[path.Length - 1].LastIndexOf("/");
                        int After  = path[path.Length - 1].LastIndexOf(".");
                        ImgSort = (int.Parse(path[path.Length - 1].Substring(Before + 1, After - Before - 1)) + 1).ToString("d2");
                    }

                    NewPath = FilePath + model.ImgName + ImgSort + ImgType;

                    if (File.Exists(NewPath))
                    {
                        File.Delete(NewPath);

                        ///移动文件
                        File.Copy(OldPath, NewPath);
                    }
                    else
                    {
                        ///移动文件
                        File.Copy(OldPath, NewPath);
                    }

                    //NewPath = model.ImgIp + model.UserAccount + "/" + model.ImgAttribute + "/" + ImgSort + ImgType;
                }
                else
                {
                    NewPath = Value;
                }

                list.Add(model.ImgName + ImgSort + ImgType);
            }
            //string ImgRootPath = model.ImgIp + model.UserAccount + "/" + model.ImgAttribute + "/,";
            string ServerPath = string.Join(",", list.ToArray());

            string Result = ServerPath;
            #endregion

            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("utf-8"))
            };

            return(Respend);
        }
コード例 #19
0
ファイル: Program.cs プロジェクト: yinxuequn/Loreal-ImageDemo
        static void Main(string[] args)
        {
            _baseDirectory = Environment.CurrentDirectory;
            _imgModel = CreateImgModel();

            Image destImg = ReadDestImage();
            InitParameters(destImg.Width);
            //绘制文字图片
            System.Drawing.Bitmap fontBmp = DrawFontImage();

            System.Drawing.Bitmap blankBmp = new Bitmap(destImg.Width, _currentHeight + _lineHeight + destImg.Height);

            System.Drawing.Graphics graph = System.Drawing.Graphics.FromImage(blankBmp);
            graph.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
            //设置高质量,低速度呈现平滑程度
            graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            //合并图片
            //放置文字图片
            graph.DrawImage(fontBmp, 0, 0, fontBmp.Width,fontBmp.Height);
            //DrawImage(img, 照片与相框的左边距, 照片与相框的上边距, 照片宽, 照片高);
            graph.DrawImage(destImg, 0, _currentHeight + _lineHeight, destImg.Width, destImg.Height);
            //保存处理后的图片
            SaveDestImag(blankBmp);
        }
コード例 #20
0
        public HttpResponseMessage UpdateCommodityFilePath(ProductCodeInfoModel model)
        {
            string Result = string.Empty;

            try
            {
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);

                model.UserAccount     = ParametersFilter.FilterSqlHtml(model.UserAccount, 64);
                model.Status          = ParametersFilter.FilterSqlHtml(model.Status, 1);
                model.CommodityNumber = ParametersFilter.StripSQLInjection(model.CommodityNumber);
                model.ImgStatus       = ParametersFilter.FilterSqlHtml(model.ImgStatus, 1);

                ///原图片地址
                string ImgPath = model.FilePath;

                if (model.Status == "0")
                {
                    model.FilePath = model.FilePath.Substring(model.FilePath.LastIndexOf("."), model.FilePath.Length - model.FilePath.LastIndexOf("."));
                }

                //返回结果
                Result = ApiHelper.HttpRequest(username, password, Url, model);

                //解析返回结果
                JObject jsons = (JObject)JsonConvert.DeserializeObject(Result);

                ///添加商品
                if (model.Status == "0")
                {
                    ImgModel imgModel = new ImgModel();
                    imgModel.ImgDisk        = SingleXmlInfo.GetInstance().GetWebApiConfig("imgDisk");
                    imgModel.ImgRoot        = SingleXmlInfo.GetInstance().GetWebApiConfig("imgRoot");
                    imgModel.UserAccount    = model.UserAccount;
                    imgModel.ImgAttribute   = "commodity";
                    imgModel.SourceFileName = ImgPath;
                    imgModel.ImgName        = jsons["FilePath"].ToString();

                    string Return = ApiHelper.HttpRequest(ApiHelper.MoveCommodityImg("imgUploadIp", "imgUpload"), imgModel);

                    if (Return != "1")
                    {
                        jsons["DATA"][0] = 0;
                    }
                    else
                    {
                        jsons["DATA"][0] = 1;
                    }
                    Result = JsonConvert.SerializeObject(jsons);
                }
                else if (model.Status == "1")
                {
                    if (jsons["DATA"][0].ToString() == "1")
                    {
                        ImgModel imgModel = new ImgModel();
                        imgModel.ImgDisk        = SingleXmlInfo.GetInstance().GetWebApiConfig("imgDisk");
                        imgModel.ImgRoot        = SingleXmlInfo.GetInstance().GetWebApiConfig("imgRoot");
                        imgModel.UserAccount    = model.UserAccount;
                        imgModel.ImgAttribute   = "commodity";
                        imgModel.SourceFileName = ImgPath;
                        string DeleteImg = ApiHelper.HttpRequest(ApiHelper.DeleteCommodityImg("imgUploadIp", "imgUpload"), imgModel);
                        if (DeleteImg != "1")
                        {
                            jsons["DATA"][0] = 0;
                        }

                        Result = JsonConvert.SerializeObject(jsons);
                    }
                }

                ///写日志
                string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":";
                LogHelper.LogResopnse(RequestAction + Result);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.ToString());
            }

            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respend);
        }
コード例 #21
0
        public HttpResponseMessage AdvertisingUpdate(AdvertiseMentModel model)
        {
            string Result = string.Empty;

            try
            {
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);

                //去除用户参数中包含的特殊字符
                model.DATA        = ParametersFilter.StripSQLInjection(model.DATA);
                model.UserAccount = ParametersFilter.FilterSqlHtml(model.UserAccount, 64);
                string ImgString = string.Empty;

                #region Base64
                //if (model.FilePosition.Substring(model.FilePath.Length - 3, 3) != "jpg")
                //{
                //    ImgString = model.FilePosition.Split(new char[] { ',' })[1];
                //}
                //else
                //{
                //    ImgString = model.FilePosition;
                //}

                //图片Model
                //ImgModel imgModel = new ImgModel();

                //imgModel.ImgIp = ApiHelper.ImgURL();
                //imgModel.ImgDisk = SingleXmlInfo.GetInstance().GetWebApiConfig("imgDisk");
                //imgModel.ImgRoot = SingleXmlInfo.GetInstance().GetWebApiConfig("imgRoot");
                //imgModel.ImgAttribute = "advertisement";
                //imgModel.UserAccount = model.UserAccount;
                //imgModel.ImgName = ReDateTime.GetTimeStamp();
                //imgModel.ImgString = ImgString;

                //model.FilePosition = ApiHelper.HttpRequest(ApiHelper.GetImgUploadURL("imgUploadIp", "imgUpload"), imgModel);
                //model.FilePosition = model.FilePosition.Replace("\"", "");
                #endregion

                #region fileStream
                ImgModel imgModel = new ImgModel();

                imgModel.ImgIp        = ApiHelper.ImgURL();
                imgModel.ImgDisk      = SingleXmlInfo.GetInstance().GetWebApiConfig("imgDisk");
                imgModel.ImgRoot      = SingleXmlInfo.GetInstance().GetWebApiConfig("imgRoot");
                imgModel.ImgAttribute = "advertisement";
                imgModel.UserAccount  = model.UserAccount;

                ///临时文件夹地址
                imgModel.SourceFileName = model.FilePosition;

                ///保存图片名字
                imgModel.ImgName = ReDateTime.GetTimeStamp();

                model.FilePosition = ApiHelper.HttpRequest(ApiHelper.MoveImg("imgUploadIp", "imgUpload"), imgModel);
                #endregion

                //返回结果
                Result = ApiHelper.HttpRequest(username, password, Url, model);

                ///写日志
                string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":";
                LogHelper.LogResopnse(RequestAction + Result);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.ToString());
            }

            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respend);
        }
コード例 #22
0
        public IHttpActionResult NewUploadFile()
        {
            ResultMsg result = new ResultMsg();

            string[] pictureFormatArray = ConfigValue.UploadFormat.Split(',');
            try
            {
                //获取上传图片文件
                var    context  = (HttpContextBase)Request.Properties["MS_HttpContext"];
                var    fileImg  = context.Request.Files[0];
                Stream userfile = fileImg.InputStream;                           //.InputStream;
                string suffix   = Path.GetExtension(fileImg.FileName).ToLower(); //获取文件扩展名(后缀)

                int UploadSize = int.Parse(ConfigValue.UploadFileSize);
                //判断文件大小不允许超过100Mb
                if (fileImg.ContentLength > (UploadSize * 1024 * 1024))
                {
                    result.ResultCode = -1;
                    result.ResultMsgs = "上传失败,文件大小超过100MB";
                    return(Ok(result));
                }

                //检查文件后缀名
                if (!pictureFormatArray.Contains(suffix.TrimStart('.')))
                {
                    result.ResultCode = -1;
                    result.ResultMsgs = "上传失败,文件格式必须为" + ConfigValue.UploadFormat + "类型";
                    return(Ok(result));
                }

                //如果不存在就创建file文件夹
                string SuffixName   = suffix.TrimStart('.').ToLower();
                string FileFullPath = context.Server.MapPath(string.Format("~/upload/{0}//", SuffixName));
                if (!Directory.Exists(FileFullPath))
                {
                    Directory.CreateDirectory(FileFullPath);
                }
                //不同时间上传文件
                string FileTime = FileFullPath + DateTime.Now.ToString("yyyyMMdd") + $@"\";
                if (!Directory.Exists(FileTime))
                {
                    Directory.CreateDirectory(FileTime);
                }

                string NewFileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + new Random().Next(99999); //重新处图片名称
                string NewFilePath = FileTime + NewFileName;                                                //最新的图片路径(不带后缀的路径在SaveAs时必须添加后缀SuffixName)

                //Request.Files 获取表单中的文件
                if (context.Request.Files.Count > 0)
                {
                    for (int i = 0; i < context.Request.Files.Count; i++)
                    {
                        HttpPostedFileBase hpf = context.Request.Files[i]; //这个对象是用来接收文件,利用这个对象可以获取文件的name path等
                        hpf.SaveAs(NewFilePath + "." + SuffixName);        //用SaveAs保存到上面的路径中
                    }
                }

                //if (SuffixName != "zip")
                //{
                //    ImageProcessMethod.MakeThumbnail(NewFilePath + "." + SuffixName, NewFilePath + "_small.jpeg", 150, 80);
                //    //ImageProcessMethod.AddTextWatermark(NewFilePath + "." + SuffixName, NewFilePath + "_textseal.jpeg", "版权专用", 14.0f, 120, SuffixName);
                //    ImageProcessMethod processMethod = new ImageProcessMethod();
                //    bool bo = processMethod.AddTextToImg(NewFilePath + "." + SuffixName, NewFilePath + "_textseal.jpeg", "版权专用", 5, 0, 95, 100, -45, out string error);

                //    //string watermarkImgPath = context.Server.MapPath(string.Format("~/Img/jpg/watermarkImg.png"));
                //    //ImageProcessMethod.AddImgWatermark(NewFilePath + "." + SuffixName, NewFilePath + "_imgseal.jpeg", watermarkImgPath, 120, SuffixName);
                //}

                //string uploadfileurl = System.Configuration.ConfigurationManager.AppSettings.Get("ServerImgaes");
                string retAddr = "/upload/" + SuffixName + "/" + DateTime.Now.ToString("yyyyMMdd") + "/" + NewFileName + "." + SuffixName;

                result.ResultCode = 1;
                result.ResultMsgs = "上传成功";
                result.ResultData = retAddr;

                ImgModel imgModel = new ImgModel();
                imgModel.ImgUrl = retAddr;

                int length = fileImg.FileName.Split('.').Count();

                return(Ok(ReturnHelpMethod.ReturnSuccess(200, new { ImgUrl = imgModel.ImgUrl, FileName = fileImg.FileName, Suffix = fileImg.FileName.Split('.')[length - 1], Time = DateTime.Now })));
            }
            catch (Exception ex)
            {
                WriteLog.WriteLogs(ex, "");
                result.ResultCode = -1;
                result.ResultMsgs = "上传失败";
                return(Ok(result));
            }
        }
コード例 #23
0
ファイル: RepairEdit.aspx.cs プロジェクト: Jyf524/Repair
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!String.IsNullOrEmpty(Request.QueryString["ID"]))
                {
                    Maticsoft.Model.Declaration modelDeclaration = Declaration_Bll.GetModel(Request.QueryString["ID"].ToString());; //引用id所在行的数据

                    DDMachineFather.Items.Clear();
                    DDMachineSon.Items.Clear();
                    DDMachineFather.Items.Add("请选择");
                    DDMachineSon.Items.Add("请选择");

                    DDMachineFather.DataSource     = MachineFather_Bll.GetList("");
                    DDMachineFather.DataTextField  = "MachineFatherName";
                    DDMachineFather.DataValueField = "MachineFatherID";
                    DDMachineFather.DataBind();
                    DDMachineFather.SelectedValue = modelDeclaration.MachineFatherType;

                    DDMachineSon.DataSource     = MachineSon_Bll.GetList(" MachineFatherID ='" + DDMachineFather.SelectedValue + "'  ");
                    DDMachineSon.DataTextField  = "MachineSonName";
                    DDMachineSon.DataValueField = "MachineSonID";
                    DDMachineSon.DataBind();
                    DDMachineSon.SelectedValue = modelDeclaration.MachineSonType;

                    TextBox1.Text = modelDeclaration.MachineName; //添加数据
                    TextBox2.Text = modelDeclaration.AssetsID;    //添加数据
                    TextBox3.Text = modelDeclaration.Model;
                    if (modelDeclaration.OtherPart != "")
                    {
                        aDown.Visible = true;
                        aDown.HRef    = modelDeclaration.OtherPart;//添加数据
                    }
                    if (modelDeclaration.ReplacementUse == "是")
                    {
                        RadioButton1.Checked = true;
                    }
                    else
                    {
                        RadioButton2.Checked = true;
                    }
                    //DDUnitName.DataSource = UnitsInfo_Bll.GetList("");
                    //DDUnitName.DataTextField = "UnitName";
                    //DDUnitName.DataValueField = "UnitID";
                    //DDUnitName.DataBind();
                    //DDUnitName.SelectedItem.Text = modelDeclaration.UnitName;
                    TextBox5.Text = modelDeclaration.Contact;
                    TextBox6.Text = modelDeclaration.ContactPhone;
                    if (modelDeclaration.DoorServer == "是")
                    {
                        RadioButton3.Checked = true;
                    }
                    else
                    {
                        RadioButton4.Checked = true;
                    }
                    myEditor.Value = modelDeclaration.BreakDown;


                    string st = modelDeclaration.CCC5;

                    string[] sop = st.Split(';');

                    ImgList.Clear();

                    for (int i = 0; i < sop.Length - 1; i++)        //修改图片显示
                    {
                        ImgModel img = new ImgModel();
                        img.ID     = ImgList.Count + 1;
                        img.imgUrl = sop[i];
                        ImgList.Add(img);
                        RadListView1.Rebind();
                    }
                }
                else
                {
                    Response.Redirect("RepairBX.aspx");
                }
            }
        }
コード例 #24
0
ファイル: ImgHelper.cs プロジェクト: gezhanglong/MyAdmin
        ///// <param name="thumbnailPath">缩略图路径(物理路径)</param>
        /// <summary>
        /// 生成缩略图
        /// </summary>
        /// <param name="originalImageStream">源图字节</param>
        /// <param name="width">缩略图宽度</param>
        /// <param name="height">缩略图高度</param>
        /// <param name="model">图片缩量方式</param>
        /// <param name="imgFomat">图片类型</param>
        public static byte[] MakeThumbnail(Stream originalImageStream, int width, int height, ImgModel model, ImageFormat imgFomat)
        {
            System.Drawing.Image originalImage = System.Drawing.Image.FromStream(originalImageStream);

            int towidth  = width;
            int toheight = height;

            int x  = 0;
            int y  = 0;
            int ow = originalImage.Width;
            int oh = originalImage.Height;

            switch (model)
            {
            case ImgModel.Hw:    //指定高宽缩放(可能变形)
                break;

            case ImgModel.W:    //指定宽,高按比例
                toheight = originalImage.Height * width / originalImage.Width;
                break;

            case ImgModel.H:    //指定高,宽按比例
                towidth = originalImage.Width * height / originalImage.Height;
                break;

            case ImgModel.Cut:    //指定高宽裁减(不变形)
                oh = originalImage.Height;
                ow = originalImage.Width;
                x  = 0;
                y  = 0;
                //if ((double)originalImage.Width / (double)originalImage.Height > (double)towidth / (double)toheight)
                //{
                //    oh = originalImage.Height;
                //    ow = originalImage.Height * towidth / toheight;
                //    y = 0;
                //    x = (originalImage.Width - ow) / 2;
                //}
                //else
                //{
                //    ow = originalImage.Width;
                //    oh = originalImage.Width * height / towidth;
                //    x = 0;
                //    y = (originalImage.Height - oh);
                //}
                break;

            default:
                break;
            }

            //新建一个bmp图片
            System.Drawing.Image bitmap = new System.Drawing.Bitmap(towidth, toheight);

            //新建一个画板
            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap);

            //设置高质量插值法
            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;

            //设置高质量,低速度呈现平滑程度
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            //清空画布并以透明背景色填充
            g.Clear(System.Drawing.Color.Transparent);

            //在指定位置并且按指定大小绘制原图片的指定部分
            g.DrawImage(originalImage, new System.Drawing.Rectangle(0, 0, towidth, toheight),
                        new System.Drawing.Rectangle(x, y, ow, oh),
                        System.Drawing.GraphicsUnit.Pixel);

            try
            {
                //以指定格式保存缩略图
                return(ImageToByteArray(bitmap, imgFomat));
            }
            finally
            {
                originalImage.Dispose();
                bitmap.Dispose();
                g.Dispose();
            }
        }
コード例 #25
0
        public HttpResponseMessage SubmitReportInfo(ProductInfoModel model)
        {
            string Result = string.Empty;

            //bool ReturnCode = AuthHelper.AuthUserStatus(model);

            try
            {
                //if (ReturnCode)
                //{
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);
                model.DATA        = ParametersFilter.StripSQLInjection(model.DATA);

                if (!string.IsNullOrEmpty(model.Screenshot))
                {
                    model.DATA = System.Web.HttpUtility.UrlDecode(model.DATA);
                    string datatojson = ApiHelper.DATAToJson(model.DATA);


                    string CommodityCode = JObject.Parse(datatojson)["CommodityCode"].ToString();
                    string ReportUser    = JObject.Parse(datatojson)["ReportUser"].ToString();

                    //string UserAccount =

                    ProductInfoModel InfoModel = new ProductInfoModel();
                    InfoModel.SOURCE        = model.SOURCE;
                    InfoModel.CREDENTIALS   = model.CREDENTIALS;
                    InfoModel.ADDRESS       = model.ADDRESS;
                    InfoModel.TERMINAL      = model.TERMINAL;
                    InfoModel.INDEX         = model.INDEX;
                    InfoModel.METHOD        = "GetCommodityUserAccount";
                    InfoModel.CommodityCode = CommodityCode;

                    string ReturnUserAccount = ApiHelper.HttpRequest(username, password, Url, InfoModel);
                    //解析返回结果
                    JObject jsons       = (JObject)JsonConvert.DeserializeObject(ReturnUserAccount);
                    string  UserAccount = jsons["UserAccount"].ToString();

                    #region 图片地址
                    //图片Model
                    ImgModel imgModel = new ImgModel();

                    imgModel.ImgIp        = ApiHelper.ImgURL();
                    imgModel.ImgDisk      = SingleXmlInfo.GetInstance().GetWebApiConfig("imgDisk");
                    imgModel.ImgRoot      = SingleXmlInfo.GetInstance().GetWebApiConfig("imgRoot");
                    imgModel.UserAccount  = UserAccount;
                    imgModel.ImgAttribute = "report";
                    imgModel.ImgName      = ReportUser + ReDateTime.GetTimeStamp();
                    imgModel.ImgString    = model.Screenshot;

                    //保存图片
                    model.Screenshot = ApiHelper.HttpRequest(ApiHelper.GetImgUploadURL("imgUploadIp", "imgUpload"), imgModel);
                    model.Screenshot = model.Screenshot.Replace("\"", "");
                    #endregion
                }

                model.DATA = System.Web.HttpUtility.UrlEncode(model.DATA);


                //返回结果
                Result = ApiHelper.HttpRequest(username, password, Url, model);

                ///写日志
                string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":";
                LogHelper.LogResopnse(RequestAction + Result);
                //}
                //else
                //{
                //    Result = "{\"RETURNCODE\":\"403\"}";
                //}
            }
            catch (Exception ex)
            {
                LogHelper.LogRequest(ex.ToString());
                LogHelper.LogError(ex.ToString());
                LogHelper.LogResopnse(ex.ToString());
            }

            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respend);
        }
コード例 #26
0
        public HttpResponseMessage UserInfo(UserInfoModel model)
        {
            string Result = string.Empty;

            try
            {
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);
                model.DATA        = System.Web.HttpUtility.UrlDecode(model.DATA);

                #region MyRegion
                //DATA装换为json字符串
                string datatojson = ApiHelper.DATAToJson(model.DATA);

                string UserAccount = JObject.Parse(datatojson)["UserAccount"].ToString();

                //图片Model
                ImgModel imgModel = new ImgModel();

                imgModel.ImgIp        = ApiHelper.ImgURL();
                imgModel.ImgDisk      = SingleXmlInfo.GetInstance().GetWebApiConfig("imgDisk");
                imgModel.ImgRoot      = SingleXmlInfo.GetInstance().GetWebApiConfig("imgRoot");
                imgModel.ImgAttribute = "user";
                imgModel.UserAccount  = UserAccount;
                imgModel.ImgName      = "userAvatar";
                imgModel.ImgString    = model.UserAvatar;

                //URL编码
                model.DATA = System.Web.HttpUtility.UrlEncode(model.DATA);

                //保存的图片名称
                model.UserAvatar = imgModel.ImgIp + imgModel.UserAccount + "/" + imgModel.ImgAttribute + "/" + imgModel.ImgName + ".jpg";

                //返回结果
                Result = ApiHelper.HttpRequest(username, password, Url, model);

                ////解析返回结果
                JObject jsons = (JObject)JsonConvert.DeserializeObject(Result);

                if (jsons["DATA"][0]["Result"].ToString() == "1")
                {
                    ApiHelper.HttpRequest(ApiHelper.GetImgUploadURL("imgUploadIp", "imgUpload"), imgModel);

                    model.UserMobile  = jsons["DATA"][0]["UserMobile"].ToString();
                    model.UserAccount = jsons["DATA"][0]["UserAccount"].ToString();

                    //返回凭证
                    jsons["CREDENTIALS"] = AuthHelper.AuthUserSet(model);
                    Result = JsonConvert.SerializeObject(jsons);
                }
                #endregion

                #region Redis_DATA
                //UserCheckBLL B = new UserCheckBLL();
                //Dictionary<string, string> redisData = B.UserInfo_Redis(model.DATA);

                //string imgStr = model.UserAvatar;

                //model.UserAvatar = redisData["UserAvatar"];
                //string Str = JsonConvert.SerializeObject(model, JSetting);

                ////返回结果
                //Result = ApiHelper.HttpRequest(username, password, Url, Str);

                //////解析返回结果
                //JObject jsons = (JObject)JsonConvert.DeserializeObject(Result);

                //if (jsons["DATA"][0]["Result"].ToString() == "1")
                //{
                //    // CharConversion.SaveImg(imgStr, model.UserAvatar, "~/Avatar/");

                //    //实例化Redis请求参数
                //    RedisModel.BaseModel redis = new RedisModel.BaseModel();

                //    redis.RedisIP = SingleXmlInfo.GetInstance().GetWebApiConfig("redisAddress");
                //    redis.RedisPort = SingleXmlInfo.GetInstance().GetWebApiConfig("redisPort");
                //    redis.RedisPassword = SingleXmlInfo.GetInstance().GetWebApiConfig("redisPassword");
                //    redis.RedisKey = "PAY_USER_Info_ " + redisData["UserAccount"];
                //    redis.RedisValue = ApiHelper.DictionaryToStr(redisData);
                //    redis.LifeCycle = "50000";
                //    redis.RedisFunction = "StringSet";

                //    //获取Redis中的验证码
                //    string b = ApiHelper.HttpRequest(ApiHelper.GetRedisURL(redis.RedisFunction), redis);
                //}
                #endregion

                ///写日志
                string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":";
                LogHelper.LogResopnse(RequestAction + Result);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.ToString());
            }

            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respend);
        }
コード例 #27
0
        public HttpResponseMessage UserRegister(UserInfoModel model)
        {
            string Result = string.Empty;

            try
            {
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);

                //去除用户参数中包含的特殊字符
                model.DATA        = ParametersFilter.StripSQLInjection(model.DATA);
                model.UserAccount = ParametersFilter.FilterSqlHtml(model.UserAccount, 64);

                model.DATA = System.Web.HttpUtility.UrlDecode(model.DATA);
                string datatojson = ApiHelper.DATAToJson(model.DATA);
                model.Verification = JObject.Parse(datatojson)["Verification"].ToString();
                model.UserMobile   = JObject.Parse(datatojson)["UserMobile"].ToString();
                model.DATA         = System.Web.HttpUtility.UrlEncode(model.DATA);

                //获取Redis中的验证码
                string  GetRedisAuthCode = ApiHelper.HttpRequest(ApiHelper.GetAuthCodeURL("smsCodeIp", "sms", "VerifyAuthCode"), model);
                JObject json             = (JObject)JsonConvert.DeserializeObject(GetRedisAuthCode);
                //if (json["result"].ToString() == "1")
                //{
                #region Base64
                //string ImgString = model.UserAvatar.Split(new char[] { ',' })[1];

                ////图片Model
                //ImgModel imgModel = new ImgModel();

                //imgModel.ImgIp = ApiHelper.ImgURL();
                //imgModel.ImgDisk = SingleXmlInfo.GetInstance().GetWebApiConfig("imgDisk");
                //imgModel.ImgRoot = SingleXmlInfo.GetInstance().GetWebApiConfig("imgRoot");
                //imgModel.ImgAttribute = "user";
                //imgModel.UserAccount = model.UserAccount;
                //imgModel.ImgName = "useravatar";
                //imgModel.ImgString = ImgString;

                //model.UserAvatar = ApiHelper.HttpRequest(ApiHelper.GetImgUploadURL("imgUploadIp", "imgUpload"), imgModel);
                //model.UserAvatar = model.UserAvatar.Replace("\"", "");
                #endregion

                ImgModel imgModel = new ImgModel();

                imgModel.ImgIp        = ApiHelper.ImgURL();
                imgModel.ImgDisk      = SingleXmlInfo.GetInstance().GetWebApiConfig("imgDisk");
                imgModel.ImgRoot      = SingleXmlInfo.GetInstance().GetWebApiConfig("imgRoot");
                imgModel.ImgAttribute = "user";
                imgModel.UserAccount  = model.UserAccount;

                ///临时文件夹地址
                imgModel.SourceFileName = model.UserAvatar;

                ///保存图片名字
                imgModel.ImgName = "useravatar";

                model.UserAvatar = ApiHelper.HttpRequest(ApiHelper.MoveImg("imgUploadIp", "imgUpload"), imgModel);

                //返回结果
                Result = ApiHelper.HttpRequest(username, password, Url, model);
                //}
                //else if(json["result"].ToString()=="0")
                //{
                //    ///验证码错误
                //    Result = "{\"DATA\":[5]}";
                //}
                //else
                //{
                //    ///验证码超时
                //    Result = "{\"DATA\":[6]}";
                //}

                ///写日志
                string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":";
                LogHelper.LogResopnse(RequestAction + Result);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.ToString());
            }

            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respend);
        }
コード例 #28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
                {
                    Maticsoft.Model.Replacement molr = bllr.GetModel(Request.QueryString["ID"].ToString());//引用id所在行的数据

                    if (molr.ReplacementState == "已借出")
                    {
                        Response.Write("<script>alert('已借出,无法修改!');window.location.href='SubstituteMachine.aspx'</script>");
                        return;
                    }
                    if (molr.ReplacementState == "已报废")
                    {
                        Response.Write("<script>alert('已报废,无法修改!');window.location.href='SubstituteMachine.aspx'</script>");
                        return;
                    }

                    if (molr == null)
                    {
                        Response.Write("<script>window.location.href='~/BackLogin.aspx'</script>");
                    }

                    MachineFather.Items.Clear();
                    MachineSon.Items.Clear();
                    MachineFather.Items.Add("请选择...");
                    MachineSon.Items.Add("请选择...");

                    MachineFather.DataSource     = bllmf.GetList("");
                    MachineFather.DataTextField  = "MachineFatherName";
                    MachineFather.DataValueField = "MachineFatherID";
                    MachineFather.DataBind();

                    MachineSon.DataSource     = bllms.GetList(" MachineFatherID ='" + MachineFather.SelectedValue + "'  ");
                    MachineSon.DataTextField  = "MachineSonName";
                    MachineSon.DataValueField = "MachineSonID";
                    MachineSon.DataBind();

                    Maticsoft.Model.MachineFatherType molmf = bllmf.GetModel(molr.MachineFatherID);
                    Maticsoft.Model.MachineSonType    molms = bllms.GetModel(molr.MachineSonID);

                    ReplacementName.Text        = molr.ReplacementName;
                    ReplacementModel.Text       = molr.ReplacementModel;
                    MachineFather.SelectedValue = molmf.MachineFatherID;

                    MachineSon.Items.Clear();       //清子类下拉框项目
                    MachineSon.Items.Add("请选择..."); //给市下拉框添加请选择
                    MachineSon.DataSource     = bllms.GetList(" MachineFatherID ='" + MachineFather.SelectedValue + "'  ");
                    MachineSon.DataTextField  = "MachineSonName";
                    MachineSon.DataValueField = "MachineSonID";
                    MachineSon.DataBind();

                    MachineSon.SelectedValue = molms.MachineSonID;
                    //DropDownList1.SelectedValue = molr.ReplacementState;

                    string st = molr.ReplacementPicture;

                    string[] sop = st.Split(';');

                    ImgList.Clear();

                    for (int i = 0; i < sop.Length - 1; i++)        //修改图片显示
                    {
                        ImgModel img = new ImgModel();
                        img.ID     = ImgList.Count + 1;
                        img.imgUrl = sop[i];
                        ImgList.Add(img);
                        RadListView1.Rebind();
                    }

                    //imgPic.ImageUrl = molr.ReplacementPicture;
                }
            }
        }
コード例 #29
0
ファイル: RepairContent.aspx.cs プロジェクト: Jyf524/Repair
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!String.IsNullOrEmpty(Request.QueryString["ID"]))
                {
                    Maticsoft.Model.Declaration modelDeclaration = Declaration_Bll.GetModel(Request.QueryString["ID"].ToString());; //引用id所在行的数据
                    if (modelDeclaration.ReplacementID != "")
                    {
                        Label4.Text           = modelDeclaration.ReplacementID;
                        ReplacementID.Visible = true;
                    }
                    else
                    {
                        ReplacementID.Visible = false;
                    }
                    Label14.Text = MachineFather_Bll.GetModel(modelDeclaration.MachineFatherType).MachineFatherName;
                    Label1.Text  = modelDeclaration.MachineName; //添加数据
                    Label2.Text  = modelDeclaration.AssetsID;    //添加数据
                    Label3.Text  = modelDeclaration.Model;       //添加数据
                    if (modelDeclaration.OtherPart != "")
                    {
                        aDown.HRef = modelDeclaration.OtherPart;//添加数据
                    }
                    else
                    {
                        aDown.InnerText = "暂无";
                    }
                    if (modelDeclaration.ReplacementUse == "是")
                    {
                        Label6.Text = "是";
                    }
                    else
                    {
                        Label6.Text = "否";
                    }
                    Label7.Text  = modelDeclaration.UnitName;
                    Label8.Text  = modelDeclaration.RepairTime.ToString();
                    Label9.Text  = modelDeclaration.Contact;
                    Label10.Text = modelDeclaration.ContactPhone;
                    if (modelDeclaration.DoorServer == "是")
                    {
                        Label11.Text = "是";
                    }
                    else
                    {
                        Label11.Text = "否";
                    }
                    if (modelDeclaration.RepairerName == "")
                    {
                        RepairID.Visible = false;
                    }
                    else
                    {
                        Label12.Text = modelDeclaration.RepairerName;
                    }
                    Label13.Text = modelDeclaration.DeclarationState;
                    Label5.Text  = modelDeclaration.BreakDown;
                    string st = modelDeclaration.CCC5;

                    string[] sop = st.Split(';');

                    ImgList.Clear();

                    for (int i = 0; i < sop.Length - 1; i++)
                    {
                        ImgModel img = new ImgModel();
                        img.ID     = ImgList.Count + 1;
                        img.imgUrl = sop[i];
                        ImgList.Add(img);
                        RadListView1.Rebind();
                    }
                }
                else
                {
                    Response.Redirect("RepairBX.aspx");
                }
            }
        }
コード例 #30
0
 public JsonResult GetImages(string ImagePathEntrance, string ImagePathExit)
 {
     try
     {
         ImgModel imgentrance = new ImgModel();
         ImgModel imgexit     = new ImgModel();
         if (!string.IsNullOrEmpty(ImagePathEntrance))
         {
             string path = System.IO.Path.Combine(ImagePath, ImagePathEntrance);
             imgentrance.ImgBig = GetPic(path);
             path = path.Replace("Big", "Small");
             imgentrance.ImgSmall = GetPic(path);
         }
         if (!string.IsNullOrEmpty(ImagePathExit))
         {
             string path = System.IO.Path.Combine(ImagePath, ImagePathExit);
             imgexit.ImgBig   = GetPic(path);
             path             = path.Replace("Big", "Small");
             imgexit.ImgSmall = GetPic(path);
         }
         if (imgentrance.ImgSmall.Length == 0 || imgexit.ImgSmall.Length == 0)
         {
             var v = LoadingPic(false);
             if (imgentrance.ImgSmall.Length == 0)
             {
                 imgentrance.ImgSmall = v;
             }
             if (imgexit.ImgSmall.Length == 0)
             {
                 imgexit.ImgSmall = v;
             }
         }
         if (imgentrance.ImgBig.Length == 0 || imgexit.ImgBig.Length == 0)
         {
             var v = LoadingPic(true);
             if (imgentrance.ImgBig.Length == 0)
             {
                 imgentrance.ImgBig = v;
             }
             if (imgexit.ImgBig.Length == 0)
             {
                 imgexit.ImgBig = v;
             }
         }
         object entranceimg = new
         {
             Base64ImageEntrance      = imgentrance.ImgBig,
             Base64ImageExit          = imgexit.ImgBig,
             Base64ImageEntranceSmall = imgentrance.ImgSmall,
             Base64ImageExitSmall     = imgexit.ImgSmall
         };
         return(Json(entranceimg, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         TxtLogServices.WriteTxtLog("获取进出场图片异常 异常信息:{0}", ex.Message);
         string bigimg      = LoadingPic(true);
         string smallimg    = LoadingPic(false);
         object entranceimg = new
         {
             Base64ImageEntrance      = bigimg,
             Base64ImageExit          = bigimg,
             Base64ImageEntranceSmall = smallimg,
             Base64ImageExitSmall     = smallimg
         };
         return(Json(entranceimg, JsonRequestBehavior.AllowGet));
     }
 }
コード例 #31
0
        public HttpResponseMessage ChangeUserAvatar(UserInfoModel model)
        {
            string Result = string.Empty;

            //bool ReturnCode = AuthHelper.AuthUserStatus(model);

            try
            {
                //if (ReturnCode)
                //{
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);
                model.UserAccount = ParametersFilter.FilterSqlHtml(model.UserAccount, 30);
                if (model.TERMINAL == "2")
                {
                    model.DATA = System.Web.HttpUtility.UrlEncode(model.DATA);
                }

                //图片Model
                ImgModel imgModel = new ImgModel();

                imgModel.ImgIp        = ApiHelper.ImgURL();
                imgModel.ImgDisk      = SingleXmlInfo.GetInstance().GetWebApiConfig("imgDisk");
                imgModel.ImgRoot      = SingleXmlInfo.GetInstance().GetWebApiConfig("imgRoot");
                imgModel.ImgAttribute = "user";
                imgModel.UserAccount  = model.UserAccount;
                imgModel.ImgName      = "useravatar";
                imgModel.ImgString    = model.UserAvatar;

                //保存用户头像
                model.UserAvatar = ApiHelper.HttpRequest(ApiHelper.GetImgUploadURL("imgUploadIp", "imgUpload"), imgModel);
                model.UserAvatar = model.UserAvatar.Replace("\"", "");


                //返回结果
                if (model.UserAvatar.Length > 16)
                {
                    Result = "{ \"Result\":\"Success\"}";
                }
                else
                {
                    Result = "{\"Result\":\"Fail\"}";
                }
                //}
                //else
                //{
                //    Result = "{\"RETURNCODE\":\"403\"}";
                //}

                ///写日志
                string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":";
                LogHelper.LogResopnse(RequestAction + Result);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.ToString());
            }
            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respend);
        }