コード例 #1
0
ファイル: FileService.cs プロジェクト: wwkkww1983/ShanxiEPM
        /// <summary>
        /// 根据表名和ID获取附件
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public Result <List <Epm_TzAttachs> > GetFilesByTZTable(string tableName, long id)
        {
            Result <List <Epm_TzAttachs> > result = new Result <List <Epm_TzAttachs> >();

            try
            {
                var models = DataOperateBusiness <Epm_TzAttachs> .Get().GetList(i => i.DataId == id && i.TableName == tableName && !i.IsDelete).ToList();

                if (models != null)
                {
                    foreach (var item in models)
                    {
                        string size = ListExtensionMethod.GetByteLength(item.Size);
                        item.FilesSize = Convert.ToInt32(size);
                    }
                }
                models      = models.OrderBy(i => i.Id).ToList();
                result.Data = models;
                result.Flag = EResultFlag.Success;
            }
            catch (Exception ex)
            {
                result.Data      = null;
                result.Flag      = EResultFlag.Failure;
                result.Exception = new ExceptionEx(ex, "GetFilesByTable");
            }
            return(result);
        }
コード例 #2
0
        public ActionResult Add(Epm_CompletionAcceptance model)
        {
            ResultView <int>         view     = new ResultView <int>();
            CompletionAcceptanceView complete = new CompletionAcceptanceView();

            complete.CompletionAcceptance = model;
            //表单校验
            if (string.IsNullOrEmpty(model.ProjectName))
            {
                view.Flag    = false;
                view.Message = "项目名称不能为空";
                return(Json(view));
            }
            if (string.IsNullOrEmpty(model.Title))
            {
                view.Flag    = false;
                view.Message = "验收标题不能为空";
                return(Json(view));
            }
            if (string.IsNullOrEmpty(model.Content))
            {
                view.Flag    = false;
                view.Message = "验收内容不能为空";
                return(Json(view));
            }

            string dataVisaCompany = Request.Form["Unit"];

            if (!string.IsNullOrEmpty(dataVisaCompany))
            {
                complete.CompletionRectifyCompanys = JsonConvert.DeserializeObject <List <Epm_CompletionRectifyCompany> >(dataVisaCompany);
            }

            string fileDataJson = Request.Form["fileDataJsonFile"];                                //获取上传图片json字符串

            complete.BaseFiles = JsonConvert.DeserializeObject <List <Base_Files> >(fileDataJson); //将文件信息json字符

            Result <int> result = new Result <int>();

            using (ClientSiteClientProxy proxy = new ClientSiteClientProxy(ProxyEx(Request)))
            {
                result = proxy.AddCompletionAcceptanceNew(complete);
                var      project = proxy.GetProject(model.ProjectId.Value).Data;
                DateTime time    = DateTime.Now;
                foreach (var item in complete.BaseFiles)
                {
                    if (string.IsNullOrEmpty(item.ImageType))
                    {
                        if (item.TableColumn == "YSD" || item.TableColumn == "JGT")
                        {
                            Bp_SendDate send = new Bp_SendDate();
                            send.IsSend = false;
                            if (item.TableColumn == "YSD")
                            {
                                send.Key = "2003020004";
                            }
                            if (item.TableColumn == "JGT")
                            {
                                send.Key = "2003020002";
                            }

                            send.Value           = "{\"FDFS_NAME\":\"" + item.Url + "\",\"FDFS_GROUP\":\"" + item.Group + "\",\"NAME\":\"" + item.Name + "\",\"WJLX\":\"" + ListExtensionMethod.GetFileType(item.Name) + "\",\"SIZE\":\"" + ListExtensionMethod.GetByteLength(item.Size) + "\",\"USER\":\"" + CurrentUser.UserCode + "\"}";
                            send.Type            = "12";
                            send.Project         = "BIM";
                            send.KeyValue        = project.ObjeId;
                            send.UserName        = CurrentUser.UserCode;
                            send.CreateTime      = time;
                            send.OperateTime     = time;
                            send.OperateUserId   = CurrentUser.UserId;
                            send.OperateUserName = CurrentUser.UserName;
                            send.CreateUserId    = CurrentUser.UserId;
                            send.CreateUserName  = CurrentUser.UserName;
                            proxy.AddSendDate(send);
                        }
                    }
                }
            }
            return(Json(result.ToResultView()));
        }