Exemplo n.º 1
0
        public object uploadSign()
        {
            try
            {
                var     dd   = new DataItemDetailBLL();
                string  res  = ctx.Request["json"];
                dynamic dy   = JsonConvert.DeserializeObject <ExpandoObject>(res);
                long    mode = 0;
                if (res.Contains("mode"))
                {
                    mode = dy.data.mode;
                }
                HttpFileCollection files  = ctx.Request.Files; //签名图片
                string             userId = dy.userid;         //新增类型

                string path   = dd.GetItemValue("imgPath") + "\\Resource\\sign";
                string imgurl = dd.GetItemValue("imgUrl");

                if (!System.IO.Directory.Exists(path))
                {
                    System.IO.Directory.CreateDirectory(path);
                }
                string ext      = System.IO.Path.GetExtension(files[0].FileName);
                string fileName = Guid.NewGuid().ToString() + ".png";
                files[0].SaveAs(path + "\\" + fileName);
                if (mode == 0)
                {
                    userBll.UploadSignImg(userId, "/Resource/sign/" + fileName);
                }

                string bzAppUrl = new DataItemDetailBLL().GetItemValue("bzAppUrl");
                if (!string.IsNullOrEmpty(bzAppUrl))
                {
                    UpdateSign(userId, fileName, path, imgurl, bzAppUrl);
                }

                return(new { Code = 0, Count = 0, Info = "操作成功", data = new { signUrl = imgurl + "/Resource/sign/" + fileName } });
            }
            catch (Exception ex)
            {
                return(new { Code = -1, Count = 0, Info = ex.Message });
            }
        }