Esempio n. 1
0
        public ActionResult EditBankAccount(string projectGuid, string bankAccountGuid,
                                            string bankAccountType, string bankAccountName,
                                            string issuerBank, string bankAccountNumber)
        {
            return(ActionUtils.Json(() =>
            {
                var project = Platform.GetProject(projectGuid);
                CheckPermission(project);

                var accountType = CommUtils.ParseEnum <EAccountType>(bankAccountType);
                CommUtils.AssertHasContent(bankAccountName, "请输入账户名称");

                var account = m_dbAdapter.BankAccount.GetAccount(bankAccountGuid);
                CommUtils.Assert(project.Instance.ProjectId == account.ProjectId,
                                 "传入参数错误:[ProjectGuid={0}][BankAccountGuid={1}]",
                                 projectGuid, bankAccountGuid);

                account.AccountType = accountType;
                account.AccountTypeId = (int)accountType;
                account.Name = bankAccountName;
                account.IssuerBank = issuerBank;
                account.BankAccount = bankAccountNumber;
                m_dbAdapter.BankAccount.UpdateAccount(account);
                return ActionUtils.Success(null);
            }));
        }
        public ActionResult GetProjectAuthorityByUsername(string username)
        {
            return(ActionUtils.Json(() =>
            {
                CommUtils.AssertHasContent(username, "当前用户不能为空");
                CommUtils.Assert(IsUserExist(username), "当前用户[" + username + "]不存在");

                var allAuthorityTable = m_dbAdapter.Authority.GetAuthorityByUsername(username);
                var projectIds = allAuthorityTable.ConvertAll(x => x.ModifyProjectId);
                var projects = m_dbAdapter.Project.GetProjects(projectIds);

                var dictProject = projects.ToDictionary(x => x.ProjectId);

                Func <int, bool> isExistAuthority = x => x == 1;

                var result = allAuthorityTable.Where(x => dictProject.ContainsKey(x.ModifyProjectId))
                             .ToList().ConvertAll(x => {
                    var project = dictProject[x.ModifyProjectId];
                    return new
                    {
                        ProjectName = project.Name,
                        CreateUserName = Toolkit.ToString(project.CreateUserName),
                        EnterpriseName = m_dbAdapter.Authority.GetAuthorizedEnterpriseName(project.ProjectId),
                        CreateTime = project.CreateTime,
                        ModifyModelAuthority = isExistAuthority(x.ModifyModelAuthority),
                        ModifyTaskAuthority = isExistAuthority(x.ModifyTaskAuthority),
                        ProjectGuid = project.ProjectGuid
                    };
                });
                return ActionUtils.Success(result);
            }));
        }
        public ActionResult GetTemplate(string projectGuid)
        {
            return(ActionUtils.Json(() =>
            {
                CommUtils.AssertHasContent(projectGuid, "projectGuid不能为空");

                var authoritiedProjectIds = m_dbAdapter.Authority.GetAuthorizedProjectIds();
                var project = m_dbAdapter.Project.GetProjectByGuid(projectGuid);
                CommUtils.Assert(authoritiedProjectIds.Any(x => x == project.ProjectId), "用户[{0}]没有上传文件模板到产品[{1}]的权限", CurrentUserName, project.Name);

                var docPatternTypes = GetDocPatternTypes(project);
                var result = docPatternTypes.ConvertAll(x =>
                {
                    var path = DocumentPattern.GetPath(project, x);
                    var fileName = DocumentPattern.GetFileName(x);
                    var exist = System.IO.File.Exists(path);
                    return new
                    {
                        templateFileName = fileName.Remove(fileName.LastIndexOf(".")),
                        docPatternType = x.ToString(),
                        status = exist ? "Exist" : "NotExist",
                        createTime = exist ? System.IO.File.GetCreationTime(path).ToString("yyyy-MM-dd HH:mm") : "",
                    };
                });

                return ActionUtils.Success(result);
            }));
        }
        public ActionResult ConfigTemplate(string projectGuid, string fileSeriesGuid, string templateType)
        {
            return(ActionUtils.Json(() =>
            {
                CommUtils.AssertHasContent(projectGuid, "ProjectGuid不能为空");

                var dmsFileSeries = m_dbAdapter.DMSFileSeries.GetByGuid(fileSeriesGuid);
                var fileSeriesTemplateType = CommUtils.ParseEnum <DmsFileSeriesTemplateType>(templateType);
                var template = m_dbAdapter.DMSFileSeriesTemplate.GetByFileSeriesId(dmsFileSeries.Id);
                if (template == null)
                {
                    var dmsFileSeriesTemplate = new DMSFileSeriesTemplate();
                    dmsFileSeriesTemplate.FileSeriesId = dmsFileSeries.Id;
                    dmsFileSeriesTemplate.TemplateType = fileSeriesTemplateType;
                    m_dbAdapter.DMSFileSeriesTemplate.New(dmsFileSeriesTemplate);
                }
                else
                {
                    if (template.TemplateType != fileSeriesTemplateType)
                    {
                        template.TemplateType = fileSeriesTemplateType;
                        m_dbAdapter.DMSFileSeriesTemplate.Update(template);

                        var log = string.Format("更新模板文档类型为 [{0}]", Toolkit.ToCnString(fileSeriesTemplateType));
                        m_dbAdapter.DMSProjectLog.AddDmsProjectLog(projectGuid, fileSeriesGuid, log);
                    }
                }

                return ActionUtils.Success("");
            }));
        }
Esempio n. 5
0
        public bool IsSuperUser()
        {
            CommUtils.AssertHasContent(UserInfo.UserName, "Username is empty");
            var records = Select <ABSMgrConn.TableSuperUser>("super_user_name", UserInfo.UserName);

            return(records.Count() == 1);
        }
Esempio n. 6
0
        public ActionResult EditFileName(string projectGuid, string folderGuid, string fileSeriesGuid, string fileName)
        {
            return(ActionUtils.Json(() =>
            {
                var dms = GetDMSAndCheckPermission(projectGuid, PermissionType.Write);
                CommUtils.AssertHasContent(fileName, "文件名称不能为空");
                ValidateUtils.FileName(fileName, "文档名称");
                CommUtils.Assert(fileName.Length <= 100, "文档名称[{0}]不能超过100个字符数", fileName);

                var folder = dms.FindFolder(folderGuid);
                folder.IgnoreNull = false;
                CommUtils.AssertNotNull(folder, "找不到文件夹[FolderGuid={0} DMSGuid={1}],请刷新后再试",
                                        folderGuid, dms.Instance.Guid);
                CommUtils.Assert(!folder.Files.Any(x => x.FileSeries.Name == fileName && x.FileSeries.Guid != fileSeriesGuid),
                                 "文件[{0}]已经存在", fileName);
                CommUtils.Assert(folder.Files.Exists(x => x.FileSeries.Guid == fileSeriesGuid), "文档不在文件夹下");

                var fileSeries = m_dbAdapter.DMSFileSeries.GetByGuid(fileSeriesGuid);
                var comment = "修改文件名称[" + fileSeries.Name + "]为[" + fileName + "]";
                fileSeries.Name = fileName;
                m_dbAdapter.DMSFileSeries.Update(fileSeries);
                m_dbAdapter.DMSProjectLog.AddDmsProjectLog(projectGuid, fileSeriesGuid, comment);
                return ActionUtils.Success(true);
            }));
        }
Esempio n. 7
0
        private List <Task> ParseTaskTable(List <List <object> > table)
        {
            var excelTaskNames = table.ConvertAll(x => x[1].ToString());

            for (int i = 0; i < excelTaskNames.Count; i++)
            {
                CommUtils.Assert(excelTaskNames[i].Length <= 30, "工作列表文件解析错误(Row:{0}):工作名称[{1}]的最大长度为30字符数", (i + 1), excelTaskNames[i]);
            }

            var tasks = new List <Task>();

            for (int i = 0; i < table.Count; i++)
            {
                try
                {
                    tasks.Add(ParseTaskRow(table[i]));
                }
                catch (Exception e)
                {
                    CommUtils.Assert(false, "工作列表文件解析错误(Row:" + (i + 1).ToString() + "):" + e.Message);
                }
            }

            for (int i = 0; i < tasks.Count; i++)
            {
                CommUtils.AssertHasContent(tasks[i].Description, "工作列表文件解析错误(Row:" + (i + 1) + "):" + "模板工作名称不能为空");
            }

            return(tasks);
        }
        public void Add(int projectId, ActivityObjectType activityObjectType, string activityObjectUniqueIdentifier, string comment)
        {
            CommUtils.AssertHasContent(comment, "Project activity's comment must has content.");
            CommUtils.AssertHasContent(activityObjectUniqueIdentifier, "Project activity's activityObjectUniqueIdentifier must has content.");

            m_dbAdapter.ProjectActivity.NewProjectActivity(projectId, activityObjectType, activityObjectUniqueIdentifier, comment);
        }
        public ActionResult ClearingInvestment(string investmentGuid, string endTime, double gains, string accountingTime)
        {
            return(ActionUtils.Json(() =>
            {
                CommUtils.AssertHasContent(investmentGuid, "Investment guid不能为空");
                CommUtils.AssertHasContent(endTime, "[到期时间]不能为空");
                CommUtils.AssertHasContent(accountingTime, "[到账时间]不能为空");
                CommUtils.Assert(gains <= 1000000000000, "[收益金额]不能大于10,000亿元");
                CommUtils.Assert(gains >= -1000000000000, "[收益金额]不能小于-10,000亿元");

                var valEndTime = DateTime.Parse(endTime);
                var valAccountingTime = DateTime.Parse(accountingTime);
                CommUtils.Assert(DateTime.Compare(valAccountingTime, valEndTime) >= 0, "[到账时间]不能小于[到期时间]");

                var investment = m_dbAdapter.Investment.GetInvestment(investmentGuid);
                CommUtils.Assert(DateTime.Compare(valEndTime, investment.StartTime) > 0, "[到期时间]必须大于[开始时间]");
                CommUtils.Assert(!(gains <0 && System.Math.Abs(gains)> investment.Money), "[收益金额]不能亏损超过[投资金额]");

                investment.Gains = gains;
                investment.EndTime = valEndTime;
                investment.AccountingTime = valAccountingTime;
                investment.Yield = InterestRateUtils.CalculateYield(investment.Gains.Value, investment.Money, investment.EndTime, investment.StartTime);
                var result = m_dbAdapter.Investment.UpdateInvestment(investment);

                return ActionUtils.Success(result);
            }));
        }
Esempio n. 10
0
        public ActionResult UploadFile(string shortCode, string fileSeriesGuid, string description)
        {
            return(ActionUtils.Json(() =>
            {
                var dms = GetDMSAndCheckPermission(shortCode, PermissionType.Execute);

                var dmsFileSeries = m_dbAdapter.DMSFileSeries.GetByGuid(fileSeriesGuid);
                var dmsFolder = m_dbAdapter.DMSFolder.GetById(dmsFileSeries.DMSFolderId);
                CommUtils.AssertEquals(dms.Instance.Id, dmsFolder.DMSId,
                                       "文件[fileSeriesGuid={0}]不在DMS[DMSGuid={1}]中,请刷新后再试",
                                       fileSeriesGuid, dms.Instance.Guid);

                var files = Request.Files;
                CommUtils.Assert(files.Count > 0, "请选择上传文件");
                CommUtils.AssertEquals(files.Count, 1, "只能上传一个文件");

                var file = files[0];
                var index = Math.Max(file.FileName.LastIndexOf('\\'), file.FileName.LastIndexOf('/'));
                var fileName = index < 0 ? file.FileName : file.FileName.Substring(index + 1);

                CommUtils.Assert(file.ContentLength > 0, "上传文件不能为空");
                CommUtils.AssertHasContent(fileName, "文件名不能为空");
                CommUtils.Assert(fileName.Length <= 100, "文件名不能超过100个字符数");

                var memoryStream = new MemoryStream(new BinaryReader(file.InputStream).ReadBytes(file.ContentLength));
                var repoFile = Platform.Repository.AddFile(fileName, memoryStream);

                var allFiles = m_dbAdapter.DMSFile.GetFilesByFileSeriesId(dmsFileSeries.Id);
                var currentVer = allFiles.Count == 0?0: allFiles.Max(x => x.Version);

                DMSFile newDMSFile = new DMSFile();
                newDMSFile.DMSId = dms.Instance.Id;
                newDMSFile.DMSFileSeriesId = dmsFileSeries.Id;

                newDMSFile.RepoFileId = repoFile.Id;
                newDMSFile.Name = repoFile.Name;
                newDMSFile.Description = description ?? string.Empty;

                newDMSFile.Size = file.ContentLength;
                newDMSFile.Version = currentVer + 1;

                var now = DateTime.Now;
                newDMSFile.LastModifyUserName = CurrentUserName;
                newDMSFile.LastModifyTime = now;
                newDMSFile.CreateUserName = CurrentUserName;
                newDMSFile.CreateTime = now;

                newDMSFile = m_dbAdapter.DMSFile.Create(newDMSFile);

                var task = m_dbAdapter.Task.GetTask(shortCode);
                new TaskLogicModel(dms.ProjectLogicModel, task).Start();

                var comment = "文件夹[" + dmsFolder.Name + "]中上传文件["
                              + dmsFileSeries.Name + "]的第" + newDMSFile.Version + "版本";
                m_dbAdapter.Task.AddTaskLog(task, comment);

                return ActionUtils.Success(newDMSFile.Guid);
            }));
        }
Esempio n. 11
0
        public void CheckParam()
        {
            var timeTypeEN = CommUtils.ParseEnum <MetaTaskTimeType>(TimeType);

            var timeTypeCN = timeTypeEN == MetaTaskTimeType.StartTime ? "开始时间" : "截止时间";

            CommUtils.AssertHasContent(TimeSeriesGuid, "当前工作的{0}不能为空", timeTypeCN);
        }
        public ActionResult ModifyInvestment(string investmentGuid, string name, string description,
                                             double money, string yieldDue, double?gains, string startTime, string endTime, string accountingTime)
        {
            return(ActionUtils.Json(() =>
            {
                ValidateUtils.Name(name, "投资标的");
                CommUtils.AssertHasContent(startTime, "[开始时间]不能为空");
                CommUtils.AssertHasContent(endTime, "[到期时间]不能为空");
                CommUtils.Assert(money <= 1000000000000, "[投资金额]不能大于10,000亿元");
                CommUtils.Assert(money > 0, "[投资金额]必须大于0元");

                var valStartTime = DateTime.Parse(startTime);
                var valEndTime = DateTime.Parse(endTime);
                CommUtils.Assert(DateTime.Compare(valEndTime, valStartTime) > 0, "[到期时间]必须大于[开始时间]");

                var investment = m_dbAdapter.Investment.GetInvestment(investmentGuid);
                investment.Name = name;
                investment.Description = description;
                investment.Money = money;
                investment.StartTime = valStartTime;
                investment.EndTime = valEndTime;
                investment.YieldDue = null;

                if (investment.Gains.HasValue)
                {
                    CommUtils.AssertNotNull(gains, "[收益金额]不能为空");
                    CommUtils.AssertHasContent(accountingTime, "[到账时间]不能为空");
                    CommUtils.Assert(gains <= 1000000000000, "[收益金额]不能大于10,000亿元");
                    CommUtils.Assert(gains >= -1000000000000, "[收益金额]不能小于-10,000亿元");
                    CommUtils.Assert(!(gains <0 && System.Math.Abs(gains.Value)> investment.Money), "[收益金额]不能亏损超过[投资金额]");

                    var valAccountingTime = DateTime.Parse(accountingTime);
                    CommUtils.Assert(DateTime.Compare(valAccountingTime, valEndTime) >= 0, "[到账时间]不能小于[到期时间]");

                    investment.AccountingTime = valAccountingTime;
                    investment.Gains = gains;
                    investment.Yield = InterestRateUtils.CalculateYield(investment.Gains.Value, investment.Money, investment.EndTime, investment.StartTime);
                }

                if (!string.IsNullOrWhiteSpace(yieldDue) && yieldDue != "-")
                {
                    var percentValue = 0.0;
                    if (yieldDue.Contains('%'))
                    {
                        CommUtils.Assert(double.TryParse(yieldDue.Substring(0, yieldDue.Length - 1), out percentValue), "预计收益率必须为数字");
                    }
                    else
                    {
                        CommUtils.Assert(double.TryParse(yieldDue, out percentValue), "预计收益率必须为数字");
                    }
                    CommUtils.Assert(percentValue >= 365.00 * (-1) / (valEndTime - valStartTime).TotalDays, "预计收益率过低,请重新填写");
                    investment.YieldDue = percentValue / 100;
                }

                var result = m_dbAdapter.Investment.UpdateInvestment(investment);
                return ActionUtils.Success(result);
            }));
        }
Esempio n. 13
0
        public ActionResult CreateTimeSeries(string timeSeriesName)
        {
            return(ActionUtils.Json(() =>
            {
                CommUtils.AssertHasContent(timeSeriesName, "名称不能为空");
                var newTimeSeries = m_dbAdapter.TimeSeries.NewTimeSeries(timeSeriesName);

                return ActionUtils.Success(newTimeSeries.Guid);
            }));
        }
Esempio n. 14
0
        public ActionResult ModifyTaskExtensionCheckList(string shortCode, string groupName, string checkItemName, string checkItemGuid, string checkItemType)
        {
            return(ActionUtils.Json(() =>
            {
                CheckPermission(PermissionObjectType.Task, shortCode, PermissionType.Execute);
                var task = m_dbAdapter.Task.GetTaskWithExInfo(shortCode);
                m_dbAdapter.Task.CheckPrevIsFinished(task);

                CommUtils.Assert(CommUtils.ParseEnum <TaskExtensionType>(task.TaskExtension.TaskExtensionType) == TaskExtensionType.CheckList,
                                 "工作[" + task.Description + "]的工作扩展类型不是[工作要点检查]");

                var oldItemStatus = CommUtils.ParseEnum <TaskExCheckType>(checkItemType);

                var revisionCheckType = string.Empty;

                CommUtils.AssertHasContent(task.TaskExtension.TaskExtensionInfo, "当前工作不包含扩展信息。");
                var taskExInfo = task.TaskExtension.TaskExtensionInfo;
                var taskExCheckListInfo = CommUtils.FromJson <TaskExCheckListInfo>(taskExInfo);

                CommUtils.AssertEquals(taskExCheckListInfo.CheckGroups.Count(x => x.GroupName == groupName), 1, "找不到检查项分组{0}", groupName);
                var group = taskExCheckListInfo.CheckGroups.Single(x => x.GroupName == groupName);

                CommUtils.AssertEquals(group.CheckItems.Count(x => x.Name == checkItemName), 1, "检查项分组{0}中,找不到检查项{1}", checkItemName);
                var checkItem = group.CheckItems.Single(x => x.Name == checkItemName);

                CommUtils.AssertEquals(checkItem.Guid, checkItemGuid, "检查项分组{0}中,检查项{1}匹配失败", groupName, checkItemName);
                CommUtils.AssertEquals(checkItem.CheckStatus, checkItemType, "检查项分组{0}中,检查项{1}状态有误,请刷新后再试", groupName, checkItemName);

                if (oldItemStatus == TaskExCheckType.Unchecked)
                {
                    checkItem.CheckStatus = TaskExCheckType.Checked.ToString();
                }
                else if (oldItemStatus == TaskExCheckType.Checked)
                {
                    checkItem.CheckStatus = TaskExCheckType.Unchecked.ToString();
                }
                else
                {
                    CommUtils.Assert(false, "无法识别的检查项内容[{0}]", oldItemStatus.ToString());
                }

                revisionCheckType = checkItem.CheckStatus;
                task.TaskExtension.TaskExtensionInfo = CommUtils.ToJson(taskExCheckListInfo);
                task.TaskHandler = CurrentUserName;

                m_dbAdapter.Task.UpdateTaskExtension(task.TaskExtension);

                var logicModel = Platform.GetProject(task.ProjectId);
                new TaskLogicModel(logicModel, task).Start();
                m_dbAdapter.Task.UpdateTask(task);
                m_dbAdapter.Task.AddTaskLog(task, "校验分组[" + groupName + "]中的工作要点[" + checkItemName + "],状态为:" + Toolkit.ConvertTaskExCheckType(revisionCheckType));

                return ActionUtils.Success(1);
            }));
        }
        public ActionResult RemoveInvestment(string investmentGuid)
        {
            return(ActionUtils.Json(() =>
            {
                CommUtils.AssertHasContent(investmentGuid, "Investment guid不能为空");

                var investment = m_dbAdapter.Investment.GetInvestment(investmentGuid);
                var result = m_dbAdapter.Investment.RemoveInvestment(investment);
                return ActionUtils.Success(result);
            }));
        }
Esempio n. 16
0
        public ActionResult ModifyIssueDescription(string projectGuid, string issueGuid, string issueActivityGuid,
                                                   string issueName, string description, string emergencyLevelText, string allotUser,
                                                   string fileGuidsText, string imageGuidsText, string shortCodeText)
        {
            return(ActionUtils.Json(() =>
            {
                CheckPermission(PermissionObjectType.Project, projectGuid, PermissionType.Read);

                var issue = m_dbAdapter.Issue.GetIssueByIssueGuid(issueGuid);
                var issueActivity = m_dbAdapter.IssueActivity.GetIssueActivityByGuid(issueActivityGuid);
                CommUtils.Assert(issue.IssueStatus != IssueStatus.Finished, "问题[{0}]已经被解决,不能编辑,请刷新页面后重试", issue.IssueName);
                CommUtils.AssertEquals(issue.Id, issueActivity.IssueId,
                                       "当前描述issueActivityGuid[{0}]不属于当前所选择的问题issueGuid[{1}],请刷新页面后重试", issueActivityGuid, issueGuid);
                CommUtils.Assert(issueActivity.IssueActivityTypeId == IssueActivityType.Original, "问题描述的类型不是");
                CommUtils.AssertHasContent(issueName, "问题名称不能为空");
                CommUtils.Assert(issueName.Length <= 30, "问题名称不能超过30个字符数");
                CommUtils.Assert(description.Length <= 10000, "问题描述不能超过10000个字符数");
                if (!string.IsNullOrWhiteSpace(allotUser))
                {
                    CommUtils.Assert(m_dbAdapter.Authority.IsUserExist(allotUser), "用户[{0}]不存在,请刷新页面后重试", allotUser);
                }

                var emergencyLevel = CommUtils.ParseEnum <IssueEmergencyLevel>(emergencyLevelText);

                //上传文件和图片
                var files = Request.Files;
                var dicFileAndImageIds = UploadFileAndImage(files);

                issue.IssueName = issueName;
                issue.Description = description;
                issue.IssueEmergencyLevel = emergencyLevel;
                issue.LastModifyTime = DateTime.Now;
                issue.LastModifyUserName = CurrentUserName;
                issue.AllotUser = allotUser;

                m_dbAdapter.Issue.UpdateIssue(issue);

                issueActivity.Comment = description;
                m_dbAdapter.IssueActivity.UpdateIssueActivity(issueActivity);

                //删除IssueActivity原有的图片及文件
                DeleteActivityFilesAndImages(issueActivity.IssueActivityId, fileGuidsText, imageGuidsText);

                //添加新的文件及图片
                if (dicFileAndImageIds != null)
                {
                    dicFileAndImageIds["file"].ForEach(x => m_dbAdapter.File.NewIssueActivityFile(issueActivity.IssueActivityId, x));
                    dicFileAndImageIds["image"].ForEach(x => m_dbAdapter.Image.NewIssueActivityImage(issueActivity.IssueActivityId, x));
                }

                return ActionUtils.Success("");
            }));
        }
        public ActionResult DownloadTemplate(string projectGuid, string templateFileName)
        {
            CommUtils.AssertHasContent(projectGuid, "projectGuid不能为空");
            CommUtils.AssertHasContent(templateFileName, "templateFileName不能为空");

            var authoritiedProjectIds = m_dbAdapter.Authority.GetAuthorizedProjectIds();
            var project = m_dbAdapter.Project.GetProjectByGuid(projectGuid);

            CommUtils.Assert(authoritiedProjectIds.Any(x => x == project.ProjectId), "用户[{0}]没有修改产品[{1}]的权限", CurrentUserName, project.Name);

            templateFileName += ".docx";
            string sourcePath = Path.Combine(DocumentPattern.GetFolder(project), templateFileName);

            return(File(sourcePath, "application/octet-stream", templateFileName));
        }
Esempio n. 18
0
        public void CheckParam()
        {
            CommUtils.AssertHasContent(BeginTime, "第一个日期不能为空");
            CommUtils.AssertHasContent(EndTime, "截止日期不能为空");
            DateTime biginTime;
            DateTime endTime;

            DateTime.TryParse(BeginTime, out biginTime);
            DateTime.TryParse(EndTime, out endTime);
            CommUtils.Assert(DateTime.TryParse(BeginTime, out biginTime), "第一个日期[{0}]的格式不正确", BeginTime);
            CommUtils.Assert(DateTime.TryParse(EndTime, out endTime), "截止日期[{0}]的格式不正确", EndTime);
            CommUtils.Assert(biginTime <= endTime, "第一个日期[{0}]必须小于等于截止日期[{1}]", BeginTime, EndTime);
            CommUtils.Assert(Interval > 0 && Interval <= 365, "循环周期中的数字必须为1-365之间的整数");
            CommUtils.ParseEnum <TimeRuleUnitType>(RuleUnitType);
        }
        public ActionResult UploadTemplate(string projectGuid, string templateFileName)
        {
            return(ActionUtils.Json(() =>
            {
                CommUtils.Assert(Request.Files.Count > 0, "请选择文件");

                var file = Request.Files[0];
                CommUtils.Assert(file.ContentLength > 0, "文件内容不能为空");

                CommUtils.AssertHasContent(projectGuid, "projectGuid不能为空");
                CommUtils.AssertHasContent(templateFileName, "templateFileName不能为空");

                //   var authoritiedProjectIds = m_dbAdapter.Authority.GetAuthorizedProjectIds(AuthorityType.ModifyTask);
                var authoritiedProjectIds = m_dbAdapter.Authority.GetAuthorizedProjectIds();

                var project = m_dbAdapter.Project.GetProjectByGuid(projectGuid);
                CommUtils.Assert(authoritiedProjectIds.Any(x => x == project.ProjectId), "用户[{0}]没有修改产品[{1}]的权限", CurrentUserName, project.Name);

                templateFileName += ".docx";
                CommUtils.Assert(file.FileName.EndsWith(".docx", StringComparison.CurrentCultureIgnoreCase),
                                 "文件[{0}]格式错误,请选择.docx格式的文件", file.FileName);

                CommUtils.Assert(!CommUtils.IsWPS(file.InputStream), "不支持wps编辑过的.docx格式文件,仅支持office编辑的.docx文件");
                CommUtils.Assert(IsValidDocPatternName(project, templateFileName), "上传参数有误:templateFileName={0}", templateFileName);

                string sourcePath = Path.Combine(DocumentPattern.GetFolder(project), templateFileName);
                string backupPath = Path.Combine(DocumentPattern.GetFolder(project), "backup");
                if (!Directory.Exists(backupPath))
                {
                    DirectoryInfo directoryInfo = new DirectoryInfo(backupPath);
                    directoryInfo.Create();
                }

                string backupFilePath = Path.Combine(backupPath, templateFileName);

                if (System.IO.File.Exists(sourcePath))
                {
                    backupFilePath = FileUtils.InsertTimeStamp(backupFilePath);
                    System.IO.File.Copy(sourcePath, backupFilePath, true);
                }

                file.SaveAs(sourcePath);

                return ActionUtils.Success(1);
            }));
        }
Esempio n. 20
0
        public ActionResult CreateMetaTask(string projectGuid, string metaTaskName, string guidAsStartTime, string guidAsEndTime,
                                           string prevMetaTaskText, string taskExtensionType, string detail, string target)
        {
            return(ActionUtils.Json(() =>
            {
                ValidateUtils.Name(metaTaskName, "工作名称");
                CommUtils.Assert(detail == null ? true : detail.Length <= 500, "工作描述不能超过500个字符数");
                CommUtils.Assert(target == null ? true : target.Length <= 500, "工作目标不能超过500个字符数");
                CommUtils.AssertHasContent(guidAsEndTime, "请先设置截止时间");

                var startTimeSeries = string.IsNullOrWhiteSpace(guidAsStartTime) ? null : m_dbAdapter.TimeSeries.GetByGuid(guidAsStartTime);
                var endTimeSeries = m_dbAdapter.TimeSeries.GetByGuid(guidAsEndTime);

                var timeListCount = CheckStartAndEndTimeCount(startTimeSeries, endTimeSeries);

                var extensionType = CommUtils.ParseEnum <TaskExtensionType>(taskExtensionType);
                var project = m_dbAdapter.Project.GetProjectByGuid(projectGuid);
                var prevMetaTaskGuidList = CommUtils.Split(prevMetaTaskText).ToList();
                var prevMetaTask = m_dbAdapter.MetaTask.GetMetaTaskByGuids(prevMetaTaskGuidList);

                var prevMetaTaskIds = prevMetaTask.ConvertAll(x => x.Id.ToString()).ToList();

                CheckPrevMetaTaskGenerateCount(timeListCount, prevMetaTask);

                var metaTask = new MetaTask();
                metaTask.ProjectId = project.ProjectId;
                metaTask.Name = metaTaskName;
                if (startTimeSeries == null)
                {
                    metaTask.StartTimeSeriesId = null;
                }
                else
                {
                    metaTask.StartTimeSeriesId = startTimeSeries.Id;
                }
                metaTask.EndTimeSeriesId = endTimeSeries.Id;
                metaTask.PreMetaTaskIds = CommUtils.Join(prevMetaTaskIds);
                metaTask.TaskExtensionType = extensionType;
                metaTask.Detail = detail;
                metaTask.Target = target;

                var newMetaTask = m_dbAdapter.MetaTask.New(metaTask);

                return ActionUtils.Success(newMetaTask.Guid);
            }));
        }
Esempio n. 21
0
        public ActionResult SaveTimeOrigin(TimeOriginViewModel timeOriginViewModel)
        {
            return(ActionUtils.Json(() =>
            {
                if (timeOriginViewModel != null)
                {
                    //检查timeOriginViewModel里的参数
                    CommUtils.AssertHasContent(timeOriginViewModel.TimeSeriesGuid, "TimeSeriesGuid不能为空");
                    CommUtils.AssertHasContent(timeOriginViewModel.TimeOriginType, "TimeOriginType不能为空");

                    CheckTimeOriginParam(timeOriginViewModel);

                    CreateTimeOriginAndDetailOrigin(timeOriginViewModel);
                }
                return ActionUtils.Success("ok");
            }));
        }
Esempio n. 22
0
        public ActionResult SaveTimeRule(TimeRuleViewModel timeRuleViewModel)
        {
            return(ActionUtils.Json(() =>
            {
                if (timeRuleViewModel != null && timeRuleViewModel.IsExistRule)
                {
                    //检查timeRuleViewModel里的参数
                    CommUtils.AssertHasContent(timeRuleViewModel.TimeSeriesGuid, "TimeSeriesGuid不能为空");

                    CheckTimeRuleParam(timeRuleViewModel);

                    CreateTimeRuleAndDetailRule(timeRuleViewModel);
                }

                return ActionUtils.Success("");
            }));
        }
Esempio n. 23
0
        public ActionResult CreateFolders(string projectGuid, string parentFolderGuid, List <string> folderNames, List <string> folderDescriptions)
        {
            return(ActionUtils.Json(() =>
            {
                folderNames.ForEach(x => ValidateUtils.FileName(x, "文档名称"));
                CommUtils.AssertEquals(folderNames.Count, folderDescriptions.Count, "传入folderNames和folderDescriptions长度不相等");
                CommUtils.AssertEquals(folderNames.Select(x => x.ToLower()).Distinct().Count(),
                                       folderNames.Count, "传入了重复的文件夹名");
                CommUtils.Assert(folderNames.Any(x => x.Length <= 100), "文件夹名称不能超过100个字符数");
                CommUtils.AssertHasContent(folderNames, "文件夹名称不能为空");

                var dms = GetDMSAndCheckPermission(projectGuid, PermissionType.Write);

                var parentFolder = m_dbAdapter.DMSFolder.GetByGuid(parentFolderGuid);
                CommUtils.AssertEquals(parentFolder.DMSId, dms.Instance.Id, "传入projectGuid和folderGuid不在同一个DMS中");

                var sibbingFolders = dms.AllFolders.Where(x => x.ParentFolderId.HasValue &&
                                                          x.ParentFolderId.Value == parentFolder.Id);
                foreach (var folderName in folderNames)
                {
                    CommUtils.Assert(!sibbingFolders.Any(x => x.Name.Equals(folderName, StringComparison.CurrentCultureIgnoreCase)),
                                     "文件夹[{0}]已经存在,请刷新后再试", folderName);
                }

                var folders = new List <DMSFolder>();
                var now = DateTime.Now;
                for (int i = 0; i < folderNames.Count; i++)
                {
                    var folder = new DMSFolder();
                    folder.DMSId = dms.Instance.Id;
                    folder.Name = folderNames[i];
                    folder.Description = folderDescriptions[i];
                    folder.DmsFolderType = DmsFolderType.Normal;
                    folder.ParentFolderId = parentFolder.Id;
                    folder.CreateTime = now;
                    folder.CreateUserName = CurrentUserName;
                    folder.LastModifyTime = now;
                    folder.LastModifyUserName = CurrentUserName;
                    folder = m_dbAdapter.DMSFolder.Create(folder);
                    folders.Add(folder);
                }
                var folderGuids = folders.Select(x => x.Guid);
                return ActionUtils.Success(folderGuids);
            }));
        }
        public ActionResult CreateInvestment(string projectGuid, string name, double money,
                                             string yieldDue, string startTime, string endTime, string description)
        {
            return(ActionUtils.Json(() =>
            {
                ValidateUtils.Name(name, "投资标的");
                CommUtils.AssertHasContent(startTime, "[开始时间]不能为空");
                CommUtils.AssertHasContent(endTime, "[到期时间]不能为空");
                CommUtils.Assert(money <= 1000000000000, "[投资金额]不能大于10,000亿元");
                CommUtils.Assert(money > 0, "[投资金额]必须大于0元");

                var valStartTime = DateTime.Parse(startTime);
                var valEndTime = DateTime.Parse(endTime);
                CommUtils.Assert(DateTime.Compare(valEndTime, valStartTime) > 0, "[到期时间]必须大于[开始时间]");

                var investment = new Investment();
                var project = m_dbAdapter.Project.GetProjectByGuid(projectGuid);
                investment.ProjectId = project.ProjectId;
                investment.Name = name;
                investment.Money = money;
                investment.StartTime = valStartTime;
                investment.EndTime = valEndTime;
                investment.Description = description;
                investment.YieldDue = null;

                if (!string.IsNullOrWhiteSpace(yieldDue))
                {
                    var percentValue = 0.0;
                    if (yieldDue.Contains('%'))
                    {
                        CommUtils.Assert(double.TryParse(yieldDue.Substring(0, yieldDue.Length - 1), out percentValue), "预计收益率必须为数字");
                    }
                    else
                    {
                        CommUtils.Assert(double.TryParse(yieldDue, out percentValue), "预计收益率必须为数字");
                    }
                    CommUtils.Assert(percentValue >= 365.00 * (-1) / (valEndTime - valStartTime).TotalDays, "预计收益率过低,请重新填写");
                    investment.YieldDue = percentValue / 100;
                }

                m_dbAdapter.Investment.NewInvestment(investment);
                return ActionUtils.Success(1);
            }));
        }
 public ActionResult CreateMessageReminding(string uid, string userid, string remark, DateTime remindTime, string type)
 {
     return(ActionUtils.Json(() =>
     {
         CommUtils.AssertHasContent(userid, "提醒人员不能为空");
         CommUtils.AssertHasContent(remindTime.ToString(), "提醒时间不能为空");
         CommUtils.Assert(remindTime > DateTime.Now, "提醒时间要大于现在时间");
         var msgType = CommUtils.ParseEnum <MessageUidType>(type);
         CheckRemindingPermission(uid, msgType);
         userid.Split(',').ToList().ForEach(x =>
         {
             if (x != "")
             {
                 m_dbAdapter.MessageReminding.New(uid, x, remark, remindTime, msgType);
             }
         });
         return ActionUtils.Success(1);
     }));
 }
        public ActionResult GetUserInfo(string userName)
        {
            return(ActionUtils.Json(() =>
            {
                CommUtils.AssertHasContent(userName, "用户名不能为空");

                var queryUserEnterpriseId = m_dbAdapter.Authority.GetEnterpriseId(userName);
                var currentUserEnterpriseId = m_dbAdapter.Authority.GetEnterpriseId(CurrentUserName);
                CommUtils.Assert(queryUserEnterpriseId.HasValue && currentUserEnterpriseId.HasValue &&
                                 queryUserEnterpriseId.Value == currentUserEnterpriseId.Value, "查询用户和当前登录用户不在同一机构");

                var accountInfo = UserService.GetUserByName(userName);
                var result = new
                {
                    realName = accountInfo != null? accountInfo.Name : userName,
                    cellphone = accountInfo != null ? accountInfo.PhoneNumber : "",
                    email = accountInfo != null ? accountInfo.Email : ""
                };
                return ActionUtils.Success(result);
            }));
        }
Esempio n. 27
0
        public ActionResult DownloadModel(string asOfDate)
        {
            return(ActionUtils.Json(() =>
            {
                CommUtils.AssertHasContent(asOfDate, "无效的参数:asOfDate");

                var folder = DemoJianYuanUtils.GetModelFolder();

                var ymlFilePath = Path.Combine(folder, "script.yml");

                CommUtils.Assert(System.IO.File.Exists(ymlFilePath), "请先上传模型(找不到模型文件:{0})", ymlFilePath);

                var asOfDateFolder = Path.Combine(folder, asOfDate);
                CommUtils.Assert(System.IO.Directory.Exists(asOfDateFolder), "请先上传模型(找不到路径:{0})", asOfDateFolder);

                var fileNames = new List <string> {
                    "script.yml",
                    asOfDate + @"\AmortizationSchedule.csv",
                    asOfDate + @"\Reinvestment.csv",
                    asOfDate + @"\AnalyzerResults.csv",
                    asOfDate + @"\AssetCashflowTable.csv",
                    asOfDate + @"\CashflowTable.csv",
                    asOfDate + @"\collateral.csv",
                    asOfDate + @"\CurrentVariables.csv",
                    asOfDate + @"\FutureVariables.csv",
                    asOfDate + @"\PastVariables.csv"
                };

                var ms = new MemoryStream();
                ZipUtils.CompressFiles(folder, fileNames, ms);

                var fileFullName = "DataModel(" + asOfDate + ").zip";

                var userName = string.IsNullOrWhiteSpace(CurrentUserName) ? "anonymous" : CurrentUserName;
                var resource = ResourcePool.RegisterMemoryStream(userName, fileFullName, ms);
                var guid = resource.Guid.ToString();

                return ActionUtils.Success(guid);
            }));
        }
        public ActionResult ModifyMessageReminding(string uid, string userid, string remark, DateTime remindTime, string type)
        {
            return(ActionUtils.Json(() =>
            {
                CommUtils.AssertHasContent(userid, "提醒人员不能为空");
                CommUtils.AssertHasContent(remindTime.ToString(), "提醒时间不能为空");
                CommUtils.Assert(remindTime > DateTime.Now, "提醒时间要大于现在时间");
                var msgType = CommUtils.ParseEnum <MessageUidType>(type);
                CheckRemindingPermission(uid, msgType);

                var messageRemindList = m_dbAdapter.MessageReminding.GetByUid(uid);
                string[] useridArr = userid.Split(',');

                var deleteList = messageRemindList.Where(x => !useridArr.Contains(x.UserName));
                deleteList.ToList().ForEach(x =>
                {
                    m_dbAdapter.MessageReminding.Remove(x);
                });

                var addList = useridArr.ToList().Where(x => x != "" && !messageRemindList.Select(t => t.UserName).Contains(x));
                addList.ToList().ForEach(x =>
                {
                    m_dbAdapter.MessageReminding.New(uid, x, remark, remindTime, msgType);
                });

                var modifyList = messageRemindList.Except(deleteList);
                modifyList.ToList().ForEach(x =>
                {
                    var messageRemind = m_dbAdapter.MessageReminding.GetByGuid(x.Guid);
                    messageRemind.UserName = x.UserName;
                    messageRemind.Remark = remark;
                    messageRemind.RemindTime = remindTime;
                    messageRemind.MessageStatus = MessageStatusEnum.UnSend;
                    m_dbAdapter.MessageReminding.Update(messageRemind);
                });

                return ActionUtils.Success(1);
            }));
        }
Esempio n. 29
0
        public ActionResult CreateIssueActivity(string projectGuid, string issueGuid, string comment)
        {
            return(ActionUtils.Json(() =>
            {
                CheckPermission(PermissionObjectType.Project, projectGuid, PermissionType.Read);
                CommUtils.AssertHasContent(comment, "追加评论不能为空");
                CommUtils.Assert(comment.Length <= 10000, "追加评论不能超过10000个字符数");
                var issue = m_dbAdapter.Issue.GetIssueByIssueGuid(issueGuid);
                CommUtils.Assert(issue.IssueStatus != IssueStatus.Finished, "问题[{0}]已经解决,不能够进行追加", issue.IssueName);
                var files = Request.Files;

                //上传文件和图片
                var dicFileAndImageIds = UploadFileAndImage(files);

                var project = m_dbAdapter.Project.GetProjectByGuid(projectGuid);
                CommUtils.AssertEquals(issue.ProjectId, project.ProjectId, "追加的问题[{0}]和当前项目[{1}]不属于同一个项目,请刷新页面后重试", issue.IssueName, project.Name);

                CreateIssueActivity(issue.Id, comment, IssueActivityType.Additional, dicFileAndImageIds);

                return ActionUtils.Success("");
            }));
        }
Esempio n. 30
0
        public ActionResult CreateBankAccount(string projectGuid, string bankAccountType,
                                              string bankAccountName, string issuerBank, string bankAccountNumber)
        {
            return(ActionUtils.Json(() =>
            {
                var project = Platform.GetProject(projectGuid);
                CheckPermission(project);

                var accountType = CommUtils.ParseEnum <EAccountType>(bankAccountType);
                CommUtils.AssertHasContent(bankAccountName, "请输入账户名称");

                var account = new Account();
                account.AccountId = m_dbAdapter.BankAccount.GetMaxAccountId() + 1;
                account.AccountGuid = Guid.NewGuid().ToString();
                account.ProjectId = project.Instance.ProjectId;
                account.AccountType = accountType;
                account.AccountTypeId = (int)accountType;
                account.Name = bankAccountName;
                account.IssuerBank = issuerBank;
                account.BankAccount = bankAccountNumber;
                m_dbAdapter.BankAccount.AddAccount(account);
                return ActionUtils.Success(null);
            }));
        }