예제 #1
0
        public object getStdSysDetail([FromBody] JObject json)
        {
            try
            {
                string  res    = json.Value <string>("json");
                dynamic dy     = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string  userid = dy.userid;
                string  id     = dy.data ?? "";
                //获取用户基本信息
                OperatorProvider.AppUserId = userid;  //设置当前用户
                Operator curUser = OperatorProvider.Provider.Current();
                if (null == curUser)
                {
                    return(new { code = -1, count = 0, info = "请求失败,请登录!", data = new object() });
                }

                var entity = new StdsysFilesBLL().GetEntity(id);
                if (entity != null)
                {
                    //附件
                    DataTable file = fileInfoBLL.GetFiles(entity.ID);
                    var       pC1  = new List <Photo>();
                    foreach (DataRow dr in file.Rows)
                    {
                        Photo p = new Photo();
                        p.id       = dr["fileid"].ToString();
                        p.filename = dr["filename"].ToString();
                        p.fileurl  = dataitemdetailbll.GetItemValue("imgUrl") + dr["filepath"].ToString().Substring(1);
                        pC1.Add(p);
                    }
                    entity.Files = pC1;
                    JsonSerializerSettings settings = new JsonSerializerSettings
                    {
                        DateFormatString = "yyyy-MM-dd HH:mm:ss", //格式化日期
                    };
                    var data = JsonConvert.SerializeObject(entity, Formatting.None, settings);
                    //data = data.ToLowerProperties();//属性名改为小写字母,值不变。

                    return(new
                    {
                        code = 0,
                        info = "获取数据成功",
                        count = 1,
                        data = JObject.Parse(data)
                    });
                }
                else
                {
                    return(new { code = -1, count = 0, info = "获取失败,记录不存在。", data = new object() });
                }
            }
            catch (Exception ex)
            {
                return(new { code = -1, count = 0, info = "获取失败,错误:" + ex.Message, data = new object() });
            }
        }
예제 #2
0
 public object EditStdSys()
 {
     try
     {
         string res = HttpContext.Current.Request["json"]; //json.Value<string>("json");
         Submit <StdsysFilesEntity> dy = JsonConvert.DeserializeObject <Submit <StdsysFilesEntity> >(res, new Newtonsoft.Json.Converters.IsoDateTimeConverter()
         {
             DateTimeFormat = "yyyy'-'MM'-'dd HH':'mm':'ss"
         });
         string userid = dy.userId;
         //获取用户基本信息
         OperatorProvider.AppUserId = userid;  //设置当前用户
         Operator curUser = OperatorProvider.Provider.Current();
         if (null == curUser)
         {
             return(new { code = -1, count = 0, info = "请求失败,请登录!", data = new object() });
         }
         var entity = dy.data;
         if (entity != null && !string.IsNullOrWhiteSpace(entity.ID))
         {
             var stdsysfilesbll = new StdsysFilesBLL();
             if (!stdsysfilesbll.ExistSame(curUser.OrganizeCode, entity.FileName, entity.ID))
             {
                 //获取删除附件ID
                 string deleteFileId = entity.DeleteFileId;
                 if (!string.IsNullOrEmpty(deleteFileId))
                 {
                     DeleteFile(deleteFileId);
                 }
                 HttpFileCollection files = hcontent.Request.Files; //附件
                 UploadifyFile(entity.ID, "", files);               //上传附件
                 stdsysfilesbll.SaveForm(entity.ID, entity);
             }
             else
             {
                 return(new { code = -1, count = 0, info = "保存失败,存在同名文件,请校正。", data = new object() });
             }
         }
         else
         {
             return(new { code = -1, count = 0, info = "保存失败,记录不存在。", data = new object() });
         }
     }
     catch (Exception ex)
     {
         return(new { code = -1, count = 0, info = "保存失败,错误:" + ex.Message, data = new object() });
     }
     return(new { code = 0, count = 0, info = "保存成功", data = new object() });
 }
예제 #3
0
        public object getStdSysList([FromBody] JObject json)
        {
            string  res    = json.Value <string>("json");
            dynamic dyy    = JsonConvert.DeserializeObject <ExpandoObject>(res);
            string  userid = dyy.userid;

            //获取用户基本信息
            OperatorProvider.AppUserId = userid;  //设置当前用户
            Operator curUser = OperatorProvider.Provider.Current();

            if (null == curUser)
            {
                return(new { code = -1, count = 0, info = "请求失败,请登录!", data = new object() });
            }
            //分页获取数据
            var        dy         = dyy.data;
            Pagination pagination = new Pagination();

            pagination.page = dy.page != null ? (int)dy.page: 1;
            pagination.rows = dy.rows != null ? (int)dy.rows : 10;
            pagination.sidx = "createdate";
            pagination.sord = "desc";
            var deptcode = "";

            if (res.Contains("owner") && !string.IsNullOrWhiteSpace(dy.owner.ToString()))
            {
                deptcode = curUser.DeptCode;
            }
            var query     = new { filename = dy.filename ?? "", type = dy.type ?? "", deptcode = deptcode };
            var queryJson = JsonConvert.SerializeObject(query);
            var data      = new StdsysFilesBLL().GetList(pagination, queryJson);
            var JsonData  = new
            {
                code  = 0,
                info  = "获取数据成功",
                count = pagination.records,
                data  = data
            };
            JsonSerializerSettings settings = new JsonSerializerSettings
            {
                DateFormatString = "yyyy-MM-dd HH:mm:ss", //格式化日期
            };
            var resultData = JsonConvert.SerializeObject(JsonData, Formatting.None, settings);

            //resultData = resultData.ToMatchEntity<StdsysFilesEntity>();//小写转换为指定类型的大小写形式。

            return(JObject.Parse(resultData));
        }