Exemplo n.º 1
0
        public HttpResponseMessage EditThreeBagsInf(TreeBagsModel model)
        {
            HttpRequestBase request = ((HttpContextWrapper)this.Request.Properties["MS_HttpContext"]).Request;

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);

            string[] fileClass          = model.uploadpanelValue;
            List <FileUploadClass> list = new List <FileUploadClass>();

            if (fileClass != null && fileClass.Length > 0)
            {
                foreach (var item in fileClass)
                {
                    FileUploadClass file = new FileUploadClass();
                    JObject         jo   = new JObject();
                    jo = (JObject)JsonConvert.DeserializeObject(item);
                    file.OriginalPath = jo["OriginalPath"] == null ? "" : jo["OriginalPath"].ToString();
                    file.OriginalName = jo["OriginalName"] == null ? "" : jo["OriginalName"].ToString();
                    file.OriginalType = jo["OriginalType"] == null ? "" : jo["OriginalType"].ToString();
                    file.size         = jo["size"] == null ? 0 : (double)jo["size"];
                    list.Add(file);
                }
            }


            int success = bll.EditThreeBagsInf(model, list);

            if (success > 0)
            {
                response.Content = new StringContent("{\"success\":true}", Encoding.GetEncoding("UTF-8"), "text/html");
            }
            return(response);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加门前三包
        /// </summary>
        /// <returns></returns>
        public int AddThreeBagsInf(TreeBagsModel model, List <FileUploadClass> list)
        {
            bool        info = false, file = false;
            Base_ZdsDAL base_dal = new Base_ZdsDAL();

            using (Entities db = new Entities())
            {
                xz_threebags bags_model = new xz_threebags();
                bags_model.storename    = model.storename;
                bags_model.person       = model.person;
                bags_model.card         = model.card;
                bags_model.contactphone = model.contactphone;
                bags_model.address      = model.address;
                bags_model.geography    = model.geography;
                bags_model.remark       = model.remark;
                bags_model.createuserid = model.createuserid;
                bags_model.createtime   = DateTime.Now;

                if (model != null)
                {
                    string id = model.storetype;
                    //model.storetype = Convert.ToString(base_model.GetTypeById(id, "type_djlx")[id]);
                    bags_model.storetype = model.storetype;
                }

                db.xz_threebags.Add(bags_model);
                if (db.SaveChanges() > 0)
                {
                    info = true;
                }

                foreach (var item in list)
                {
                    xzj_files filemodel = new xzj_files();
                    filemodel.source   = 1; //1 门前三包  2行政许可
                    filemodel.filename = item.OriginalName;
                    filemodel.filepath = item.OriginalPath;
                    filemodel.filesize = item.size;
                    filemodel.filetype = item.OriginalType;
                    filemodel.sourceid = bags_model.storeid;

                    db.xzj_files.Add(filemodel);
                }

                if (db.SaveChanges() > 0)
                {
                    file = true;
                }

                if (info && file)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
        }
Exemplo n.º 3
0
        public int AddThreeBagsInf(TreeBagsModel model, List <FileClass> list)
        {
            bool info = false, file = false;

            using (Entities db = new Entities())
            {
                xz_threebags bags_model = new xz_threebags();
                bags_model.storename    = model.storename;
                bags_model.storetype    = model.storetype;
                bags_model.person       = model.person;
                bags_model.card         = model.card;
                bags_model.contactphone = model.contactphone;
                bags_model.address      = model.address;
                bags_model.geography    = model.geography;
                bags_model.remark       = model.remark;
                bags_model.createuserid = model.createuserid;
                bags_model.createtime   = DateTime.Now;

                db.xz_threebags.Add(bags_model);
                if (db.SaveChanges() > 0)
                {
                    info = true;
                }

                foreach (var item in list)
                {
                    xzj_files filemodel = new xzj_files();
                    filemodel.source   = 1; //1 门前三包  2行政许可
                    filemodel.filename = item.OriginalName;
                    filemodel.filepath = item.OriginalPath;
                    filemodel.filesize = item.size;
                    filemodel.filetype = item.OriginalType;
                    filemodel.sourceid = bags_model.storeid;

                    db.xzj_files.Add(filemodel);
                }

                if (db.SaveChanges() > 0)
                {
                    file = true;
                }

                if (info && file || info)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 修改门前三包信息
        /// </summary>
        /// <param name="storeid"></param>
        /// <returns></returns>
        public int EditThreeBagsInf(TreeBagsModel model, List <FileUploadClass> list)
        {
            bool info = false, file = false;

            using (Entities db = new Entities())
            {
                xz_threebags bags_model = db.xz_threebags.FirstOrDefault(a => a.storeid == model.storeid);
                if (bags_model != null)
                {
                    bags_model.storename    = model.storename;
                    bags_model.storetype    = model.storetype;
                    bags_model.person       = model.person;
                    bags_model.card         = model.card;
                    bags_model.contactphone = model.contactphone;
                    bags_model.address      = model.address;
                    bags_model.geography    = model.geography;
                    bags_model.remark       = model.remark;
                    if (db.SaveChanges() > 0)
                    {
                        info = true;
                    }
                }
                foreach (var item in list)
                {
                    xzj_files filemodel = new xzj_files();
                    filemodel.source   = 1; //1 门前三包  2行政许可
                    filemodel.filename = item.OriginalName;
                    filemodel.filepath = item.OriginalPath;
                    filemodel.filesize = item.size;
                    filemodel.filetype = item.OriginalType;
                    filemodel.sourceid = bags_model.storeid;

                    db.xzj_files.Add(filemodel);
                }

                if (db.SaveChanges() > 0)
                {
                    file = true;
                }

                if ((info && file) || info)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
        }
Exemplo n.º 5
0
        public object SmAddThreeBagsInf(TreeBagsModel model)
        {
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);
            HttpRequestBase     request  = ((HttpContextWrapper)this.Request.Properties["MS_HttpContext"]).Request;
            //文件上传
            List <FileClass> list       = new List <FileClass>();
            string           OriginPath = ConfigManageClass.ThreeBagsOrignalPath;
            string           smallPath  = ConfigManageClass.ThreeBagsSmallPath;

            try
            {
                for (int i = 0; i < model.base64.Length; i++)
                {
                    string   imgArray = model.base64[i];
                    string[] spilt    = imgArray.Split(',');
                    if (spilt.Length > 0)
                    {
                        byte[]    imgByte = Convert.FromBase64String(spilt[1]);
                        FileClass imgFile = FileFactory.FileUpload(imgByte, ".jpg", OriginPath, smallPath, 100, 100);
                        list.Add(imgFile);
                    }
                }
            }
            catch (Exception e)
            {
                var error = e.Message;
                response.Content = new StringContent("{\"failure\":true}", Encoding.GetEncoding("UTF-8"), "text/html");
            }
            int success = bll.AddThreeBagsInf(model, list);

            if (success > 0)
            {
                response.Content = new StringContent("{\"success\":true}", Encoding.GetEncoding("UTF-8"), "text/html");

                //return new {
                //    success=true
                //};
            }
            return(response);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 门前三包详情
        /// </summary>
        /// <param name="storeid"></param>
        /// <returns></returns>
        public TreeBagsModel GetThreeBagsInfo(int storeid)
        {
            TreeBagsModel model = new TreeBagsModel();

            using (Entities db = new Entities())
            {
                IQueryable <TreeBagsModel> queryable = from a in db.xz_threebags
                                                       join b in db.base_zds.Where(t => t.zd_type == "type_djlx") on a.storetype equals b.zd_id
                                                       where a.storeid == storeid
                                                       select new TreeBagsModel
                {
                    storeid       = a.storeid,
                    storename     = a.storename,
                    storetype     = a.storetype,
                    person        = a.person,
                    card          = a.card,
                    contactphone  = a.contactphone,
                    address       = a.address,
                    geography     = a.geography,
                    remark        = a.remark,
                    createuserid  = a.createuserid,
                    createtime    = a.createtime,
                    storetypename = b.zd_name
                };
                model = queryable.FirstOrDefault();
                if (GetFilesByStoreID(storeid) != null)
                {
                    List <string> imgList = GetFilesByStoreID(storeid);
                    if (imgList.Count > 0)
                    {
                        if (model != null)
                        {
                            model.imgUrl = imgList;
                        }
                    }
                }
            }
            return(model);
        }
Exemplo n.º 7
0
        public int AddThreeBagsInf(TreeBagsModel model, List <FileClass> list)
        {
            int success = dal.AddThreeBagsInf(model, list);

            return(success);
        }
Exemplo n.º 8
0
 /// <summary>
 /// 修改门前三包信息
 /// </summary>
 /// <param name="storeid"></param>
 /// <returns></returns>
 public int EditThreeBagsInf(TreeBagsModel model, List <FileUploadClass> list)
 {
     return(dal.EditThreeBagsInf(model, list));
 }