Beispiel #1
0
        /// <summary>
        /// 添加投资管理附件/同表不同页面附件
        /// </summary>
        /// <param name="model"></param>
        /// <param name="fileList"></param>
        /// <param name="isdelete"></param>
        /// <returns></returns>
        public int AddConferenceFiles(string tableName, long id, List <Epm_TzAttachs> fileList, InvestmentEnclosure ie = InvestmentEnclosure.itself, bool isdelete = true)
        {
            if (fileList != null)
            {
                //删除之前的附件
                if (isdelete)
                {
                    var columns  = fileList.Select(i => i.TypeNo);
                    var oldFiles = DataOperateBusiness <Epm_TzAttachs> .Get().GetList(i => i.DataId == id && i.TableName == tableName && columns.Contains(i.TypeNo)).ToList();

                    DataOperateBusiness <Epm_TzAttachs> .Get().DeleteRange(oldFiles);
                }
                //新增附件
                List <Epm_TzAttachs> fileModels = new List <Epm_TzAttachs>();
                foreach (var item in fileList)
                {
                    SetCurrentUser(item);
                    if (ie != InvestmentEnclosure.itself)
                    {
                        item.Nature     = ie.ToString();
                        item.NatureName = ie.GetText();
                    }
                    item.DataId    = id;
                    item.TableName = tableName;
                    fileModels.Add(item);
                }
                int rows = 0;
                rows = DataOperateBusiness <Epm_TzAttachs> .Get().AddRange(fileModels);

                return(rows);
            }
            return(0);
        }
Beispiel #2
0
        public Result <List <Epm_TzAttachs> > GetConferenceFiles(string tableName, long id, InvestmentEnclosure ie = InvestmentEnclosure.itself)
        {
            Result <List <Epm_TzAttachs> > result = new Result <List <Epm_TzAttachs> >();

            try
            {
                List <Epm_TzAttachs> models;
                if (ie == InvestmentEnclosure.itself)
                {
                    models = DataOperateBusiness <Epm_TzAttachs> .Get().GetList(i => i.DataId == id && i.TableName == tableName && !i.IsDelete && i.Nature == null).ToList();
                }
                else
                {
                    models = DataOperateBusiness <Epm_TzAttachs> .Get().GetList(i => i.DataId == id && i.TableName == tableName && !i.IsDelete && i.Nature != ie.ToString()).ToList();
                }
                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);
        }