Ejemplo n.º 1
0
        public async Task <string> PostUploadFileBk()
        {
            try
            {
                if (!Request.Content.IsMimeMultipartContent())
                {
                    var data1 = new
                    {
                        Status = ResponseStatus.Error,
                        Msg    = "请求数据不是multipart/form-data类型",
                        Data   = ""
                    };
                    return(DataConverterHelper.SerializeObject(data1));
                }
                //web api 获取项目根目录下指定的文件下
                var    root         = System.Web.Hosting.HostingEnvironment.MapPath("~/UpLoadFiles/BkPayment/");
                string date         = DateTime.Now.ToString("yyyy-MM-dd");
                string resourcePath = Path.Combine(root, date);
                if (!Directory.Exists(resourcePath))
                {
                    Directory.CreateDirectory(resourcePath);
                }
                var multipartMemoryStreamProvider = await Request.Content.ReadAsMultipartAsync();

                var contentsList = multipartMemoryStreamProvider.Contents;

                //获取表单数据
                Dictionary <string, string> dic = new Dictionary <string, string>();
                //List<FileParameter> paraList = new List<FileParameter>();

                List <string> files = new List <string>();
                //原始文件名
                List <string>            oldnames = new List <string>();
                List <QtAttachmentModel> list     = new List <QtAttachmentModel>();

                foreach (var content in contentsList)
                {
                    //通过判断fileName是否为空,判断是否为文件类型
                    if (!string.IsNullOrEmpty(content.Headers.ContentDisposition.FileName))
                    {
                        string fileName = content.Headers.ContentDisposition.FileName.Replace("\"", string.Empty);
                        using (Stream stream = await content.ReadAsStreamAsync())
                        {
                            //文件如果大于100MB  提示不允许
                            if (stream.Length > 104857600)
                            {
                                return(DCHelper.ErrorMessage("上传的文件不能大于100MB!"));
                            }
                            byte[] bytes = new byte[stream.Length];
                            stream.Read(bytes, 0, bytes.Length);
                            stream.Seek(0, SeekOrigin.Begin);

                            //获取对应文件后缀名
                            string extension = Path.GetExtension(fileName);
                            //获取文件名
                            string b_name = Path.GetFileName(fileName);

                            //修改文件名
                            string newFileName = Guid.NewGuid().ToString("N") + extension;
                            string uploadPath  = Path.Combine(resourcePath, newFileName);

                            //保存文件
                            MemoryStream ms = new MemoryStream(bytes);
                            FileStream   fs = new FileStream(uploadPath, FileMode.Create);
                            ms.WriteTo(fs);
                            ms.Close();
                            fs.Close();

                            string b_urlpath = "/UpLoadFiles/BkPayment/" + date + "/" + newFileName;

                            QtAttachmentModel model = new QtAttachmentModel();
                            model.BName = b_name;
                            model.BType = extension;
                            model.BSize = decimal.Round((decimal)stream.Length / (1024), 2); //保留2位小数
                            //model.BFilebody = bytes;
                            model.BUrlpath = b_urlpath;
                            model.BTable   = "BK3_PAYMENT_XM";
                            model.BRemark  = "";

                            list.Add(model);
                            //返回文件相对路径
                            files.Add(b_urlpath);
                            oldnames.Add(b_name);
                        }
                    }
                    else
                    {
                        string val = await content.ReadAsStringAsync();

                        dic.Add(content.Headers.ContentDisposition.Name.ToString(), val);
                    }
                }
                var data = new
                {
                    Status     = ResponseStatus.Success,
                    Msg        = "附件上传成功。",
                    Data       = list,
                    Attachment = files,
                    Oldnames   = oldnames
                };
                return(DataConverterHelper.SerializeObject(data));
            }
            catch (Exception ex)
            {
                return(DCHelper.ErrorMessage(ex.Message));
            }
        }
Ejemplo n.º 2
0
        public string GetQtXmDistributeList([FromUri] long OrgPhid)
        {
            if (OrgPhid == 0)
            {
                return(DCHelper.ErrorMessage("组织ID为空!"));
            }
            List <XmDistributeModel> result = new List <XmDistributeModel>();
            var syssets = QTSysSetService.Find(x => x.DicType == "Business" && x.Orgid == OrgPhid).Data.ToList();
            //取有权限修改的
            var data1 = QtXmDistributeService.Find(x => x.Distributeorgid == OrgPhid, "FProjcode").Data.ToList();

            if (data1 != null && data1.Count > 0)
            {
                var data2          = new List <QtXmDistributeModel>();
                var FProjcodeList1 = data1.Select(x => x.FProjcode).Distinct().ToList();
                foreach (var code in FProjcodeList1)
                {
                    data2 = data1.FindAll(x => x.FProjcode == code);
                    XmDistributeModel a = new XmDistributeModel();
                    a.CanFF     = true;
                    a.FProjcode = code;
                    a.FProjname = data2[0].FProjname;
                    a.FBusiness = data2[0].FBusiness;
                    if (!string.IsNullOrEmpty(a.FBusiness) && syssets != null)
                    {
                        if (syssets.Find(x => x.TypeCode == a.FBusiness) != null)
                        {
                            a.FBusiness_EXName = syssets.Find(x => x.TypeCode == a.FBusiness).TypeName;
                        }
                    }
                    a.EnableOrgList = data2.OrderBy(x => x.Orgcode).Select(x => x.Orgid).ToList();
                    if (a.EnableOrgList != null && a.EnableOrgList.Count > 0)
                    {
                        a.EnableOrgList2 = new List <object>();
                        foreach (var o in a.EnableOrgList)
                        {
                            var disabled = data2.Find(x => x.Orgid == o).Isactive == 0 ? false : true;
                            a.EnableOrgList2.Add(new { phid = o, disabled = disabled });
                        }
                        a.EnableOrgStr = CorrespondenceSettingsService.GetOrgStr(a.EnableOrgList);
                    }
                    if (data2.FindAll(x => x.Isactive == 1).Count > 0)
                    {
                        a.CanUpdate = false;
                    }
                    else
                    {
                        a.CanUpdate = true;
                    }
                    result.Add(a);
                }
            }

            //取没分发权限的
            var data3 = QtXmDistributeService.Find(x => x.Distributeorgid != OrgPhid && x.Orgid == OrgPhid).Data.ToList();

            if (data3 != null && data3.Count > 0)
            {
                var data4          = new List <QtXmDistributeModel>();
                var FProjcodeList2 = data3.Select(x => x.FProjcode).Distinct().ToList();
                foreach (var code in FProjcodeList2)
                {
                    data4 = QtXmDistributeService.Find(x => x.FProjcode == code).Data.ToList();
                    XmDistributeModel b = new XmDistributeModel();
                    b.CanFF     = false;
                    b.FProjcode = code;
                    b.FProjname = data4[0].FProjname;
                    b.FBusiness = data4[0].FBusiness;
                    if (!string.IsNullOrEmpty(b.FBusiness) && syssets != null)
                    {
                        if (syssets.Find(x => x.TypeCode == b.FBusiness) != null)
                        {
                            b.FBusiness_EXName = syssets.Find(x => x.TypeCode == b.FBusiness).TypeName;
                        }
                    }
                    b.EnableOrgList = data4.OrderBy(x => x.Orgcode).Select(x => x.Orgid).ToList();
                    if (b.EnableOrgList != null && b.EnableOrgList.Count > 0)
                    {
                        b.EnableOrgList2 = new List <object>();
                        foreach (var o in b.EnableOrgList)
                        {
                            var disabled = data4.Find(x => x.Orgid == o).Isactive == 0 ? false : true;
                            b.EnableOrgList2.Add(new { phid = o, disabled = disabled });
                        }
                        //b.EnableOrgList = data4.OrderBy(x => x.Orgcode).Select(x => x.Orgid).ToList();
                        b.EnableOrgStr = CorrespondenceSettingsService.GetOrgStr(b.EnableOrgList);
                    }
                    b.CanUpdate = false;
                    result.Add(b);
                }
            }

            result = result.OrderBy(x => x.FProjcode).ToList();
            return(DCHelper.ModelListToJson <XmDistributeModel>(result, (Int32)result.Count));
        }
Ejemplo n.º 3
0
        public string GetNaviCode([FromUri] long Operator)
        {
            if (Operator != 0)
            {
                var dic = new Dictionary <string, object>();
                new CreateCriteria(dic).Add(ORMRestrictions <Int64> .NotEq("PhId", 0));
                new CreateCriteria(dic).Add(ORMRestrictions <Int64> .Eq("Operator", Operator));
                var Query = QtNaviGationService.Find(dic);
                if (Query.Data.Count > 0)
                {
                    var area1 = Query.Data.Where(m => m.Invisible == 1).OrderBy(m => m.Sortvalue).ToList();
                    var area2 = Query.Data.Where(m => m.Invisible == 2).OrderBy(m => m.Sortvalue).ToList();
                    var data  = new
                    {
                        area1,
                        area2
                    };
                    return(DataConverterHelper.SerializeObject(data));
                }
                else
                {
                    List <QtNaviGationModel> qtlist      = new List <QtNaviGationModel>();
                    QtNaviGationModel        model       = new QtNaviGationModel();
                    SavedResult <Int64>      savedResult = new SavedResult <long>();
                    var list = new List <QtNaviGationModel>
                    {
                        new QtNaviGationModel {
                            Sortvalue = 1, Buttoncode = "projectmanage", Operator = Operator, PersistentState = PersistentState.Added, Invisible = 2, Name = "预算项目", Menu = "projectmanage", Srcs = "yunsuan"
                        },
                        new QtNaviGationModel {
                            Sortvalue = 2, Buttoncode = "fund", Operator = Operator, PersistentState = PersistentState.Added, Invisible = 2, Name = "资金拨付", Menu = "fund", Srcs = "zjbf"
                        },
                        new QtNaviGationModel {
                            Sortvalue = 3, Buttoncode = "approvalcenter", Operator = Operator, PersistentState = PersistentState.Added, Invisible = 2, Name = "审批中心", Menu = "approvalcenter", Srcs = "spzx"
                        },
                        new QtNaviGationModel {
                            Sortvalue = 4, Buttoncode = "paycenter", Operator = Operator, PersistentState = PersistentState.Added, Invisible = 2, Name = "支付中心", Menu = "paycenter", Srcs = "zfzx"
                        },
                        new QtNaviGationModel {
                            Sortvalue = 5, Buttoncode = "bankaccount", Operator = Operator, PersistentState = PersistentState.Added, Invisible = 2, Name = "银行档案", Menu = "bankaccount", Srcs = "yhdn"
                        },
                        new QtNaviGationModel {
                            Sortvalue = 6, Buttoncode = "setting", Operator = Operator, PersistentState = PersistentState.Added, Invisible = 2, Name = "系统设置", Menu = "sysSetting", Srcs = "xtsz"
                        },
                        new QtNaviGationModel {
                            Sortvalue = 7, Buttoncode = "projectspent", Operator = Operator, PersistentState = PersistentState.Added, Invisible = 2, Name = "项目用款", Menu = "projectspent", Srcs = "xmyk"
                        },
                    };
                    #region 通过反射的方式获取object的属性数据
                    // foreach (var item in list)
                    //{
                    //Type type = item.GetType();
                    //var pro = type.GetProperties();

                    //for (int i = 0, j = pro.Length; i < j; i++)
                    //{
                    //    if (pro[i].CanRead)
                    //    {
                    //        try
                    //        {
                    //            var o = pro[i].GetValue(item, null);
                    //            if (o != null)
                    //            {
                    //                if (o.GetType() == typeof(int))
                    //                {
                    //                    model.Sortvalue = (int)o;
                    //                }
                    //                else if (o.GetType() == typeof(string))
                    //                {
                    //                    model.Buttoncode = o.ToString();

                    //                }
                    //                else if (o.GetType() == typeof(long))
                    //                {
                    //                    model.Operator = (long)o;
                    //                }
                    //                model.Invisible = 2;
                    //                model.PersistentState = PersistentState.Added;
                    //            }
                    //            else
                    //            {
                    //                return DCHelper.ErrorMessage("数据赋值失败");
                    //            }
                    //        }
                    //        catch (Exception ex)
                    //        {
                    //            return DCHelper.ErrorMessage(ex.ToString());
                    //        }
                    //    }
                    //}
                    //qtlist.Add(model);
                    // }
                    #endregion
                    try
                    {
                        savedResult = QtNaviGationService.Save <Int64>(list, string.Empty);
                    }
                    catch (Exception ex)
                    {
                        return(DCHelper.ErrorMessage(ex.ToString()));
                    }
                    var QueryS = QtNaviGationService.Find(dic);
                    if (QueryS.Data.Count > 0)
                    {
                        var area1 = Query.Data.Where(m => m.Invisible == 2).OrderBy(m => m.Sortvalue);
                        var area2 = Query.Data.Where(m => m.Invisible == 1).OrderBy(m => m.Sortvalue);
                        var data  = new
                        {
                            area1,
                            area2
                        };
                        return(DataConverterHelper.SerializeObject(data));
                    }
                    else
                    {
                        return(DCHelper.ErrorMessage("数据列表获取失败"));
                    }
                }
            }
            else
            {
                return(DCHelper.ErrorMessage("参数传递失败"));
            }
        }
Ejemplo n.º 4
0
 public string GetAllCoverUpList([FromUri] BaseListModel param)
 {
     if (string.IsNullOrEmpty(param.uCode))
     {
         return(DCHelper.ErrorMessage("用户编码不能为空!"));
     }
     if (string.IsNullOrEmpty(param.processCode))
     {
         return(DCHelper.ErrorMessage("过程选择不能为空!"));
     }
     try
     {
         if (param.uCode != "Admin")
         {
             return(DCHelper.ErrorMessage("非Admin用户无权限访问此功能!"));
         }
         //内置的模板数据
         var allCoverUps = this.QtCoverUpDataService.GetQtCoverUpDataList();
         IList <AllCoverUpModel> allCoverUpModels = new List <AllCoverUpModel>();
         if (param.processCode.Equals("001"))
         {
             AllCoverUpModel allCoverUpModel = new AllCoverUpModel();
             allCoverUpModel.ProcessCode      = "001";
             allCoverUpModel.ProcessName      = "预立项";
             allCoverUpModel.QtCoverUpForOrgs = this.QtCoverUpForOrgService.GetQtCoverUpForOrgs(allCoverUpModel.ProcessCode, allCoverUpModel.ProcessName);
             allCoverUpModels.Add(allCoverUpModel);
         }
         else if (param.processCode.Equals("002"))
         {
             AllCoverUpModel allCoverUpModel = new AllCoverUpModel();
             allCoverUpModel.ProcessCode      = "002";
             allCoverUpModel.ProcessName      = "项目立项";
             allCoverUpModel.QtCoverUpForOrgs = this.QtCoverUpForOrgService.GetQtCoverUpForOrgs(allCoverUpModel.ProcessCode, allCoverUpModel.ProcessName);
             allCoverUpModels.Add(allCoverUpModel);
         }
         else if (param.processCode.Equals("003"))
         {
             AllCoverUpModel allCoverUpModel = new AllCoverUpModel();
             allCoverUpModel.ProcessCode      = "003";
             allCoverUpModel.ProcessName      = "年中新增";
             allCoverUpModel.QtCoverUpForOrgs = this.QtCoverUpForOrgService.GetQtCoverUpForOrgs(allCoverUpModel.ProcessCode, allCoverUpModel.ProcessName);
             allCoverUpModels.Add(allCoverUpModel);
         }
         else if (param.processCode.Equals("004"))
         {
             AllCoverUpModel allCoverUpModel = new AllCoverUpModel();
             allCoverUpModel.ProcessCode      = "004";
             allCoverUpModel.ProcessName      = "年中调整";
             allCoverUpModel.QtCoverUpForOrgs = this.QtCoverUpForOrgService.GetQtCoverUpForOrgs(allCoverUpModel.ProcessCode, allCoverUpModel.ProcessName);
             allCoverUpModels.Add(allCoverUpModel);
         }
         //else if (param.processCode.Equals("003"))
         //{
         //    AllCoverUpModel allCoverUpModel = new AllCoverUpModel();
         //    allCoverUpModel.ProcessCode = "003";
         //    allCoverUpModel.ProcessName = "项目立项申报";
         //    allCoverUpModel.QtCoverUpForOrgs = this.QtCoverUpForOrgService.GetQtCoverUpForOrgs(allCoverUpModel.ProcessCode, allCoverUpModel.ProcessName);
         //    allCoverUpModels.Add(allCoverUpModel);
         //}
         //else if (param.processCode.Equals("004"))
         //{
         //    AllCoverUpModel allCoverUpModel = new AllCoverUpModel();
         //    allCoverUpModel.ProcessCode = "004";
         //    allCoverUpModel.ProcessName = "项目立项汇总";
         //    allCoverUpModel.QtCoverUpForOrgs = this.QtCoverUpForOrgService.GetQtCoverUpForOrgs(allCoverUpModel.ProcessCode, allCoverUpModel.ProcessName);
         //    allCoverUpModels.Add(allCoverUpModel);
         //}
         else
         {
             //(获取四个过程项)
             AllCoverUpModel allCoverUpModel1 = new AllCoverUpModel();
             allCoverUpModel1.ProcessCode      = "001";
             allCoverUpModel1.ProcessName      = "预立项";
             allCoverUpModel1.QtCoverUpForOrgs = this.QtCoverUpForOrgService.GetQtCoverUpForOrgs(allCoverUpModel1.ProcessCode, allCoverUpModel1.ProcessName);
             allCoverUpModels.Add(allCoverUpModel1);
             AllCoverUpModel allCoverUpModel2 = new AllCoverUpModel();
             allCoverUpModel2.ProcessCode      = "002";
             allCoverUpModel2.ProcessName      = "项目立项";
             allCoverUpModel2.QtCoverUpForOrgs = this.QtCoverUpForOrgService.GetQtCoverUpForOrgs(allCoverUpModel2.ProcessCode, allCoverUpModel2.ProcessName);
             allCoverUpModels.Add(allCoverUpModel2);
             AllCoverUpModel allCoverUpModel3 = new AllCoverUpModel();
             allCoverUpModel3.ProcessCode      = "003";
             allCoverUpModel3.ProcessName      = "年中新增";
             allCoverUpModel3.QtCoverUpForOrgs = this.QtCoverUpForOrgService.GetQtCoverUpForOrgs(allCoverUpModel3.ProcessCode, allCoverUpModel3.ProcessName);
             allCoverUpModels.Add(allCoverUpModel3);
             AllCoverUpModel allCoverUpModel4 = new AllCoverUpModel();
             allCoverUpModel4.ProcessCode      = "004";
             allCoverUpModel4.ProcessName      = "年中调整";
             allCoverUpModel4.QtCoverUpForOrgs = this.QtCoverUpForOrgService.GetQtCoverUpForOrgs(allCoverUpModel4.ProcessCode, allCoverUpModel4.ProcessName);
             allCoverUpModels.Add(allCoverUpModel4);
         }
         var data = new
         {
             Status = ResponseStatus.Success,
             Msg    = "获取成功!",
             Data   = allCoverUpModels,
         };
         return(DataConverterHelper.SerializeObject(data));
     }
     catch (Exception ex)
     {
         return(DCHelper.ErrorMessage(ex.Message));
     }
 }