Example #1
0
        public ActionResult DeleteTemplateTask(string templateTaskId)
        {
            return(ActionUtils.Json(() =>
            {
                CommUtils.Assert(!string.IsNullOrEmpty(templateTaskId), "找不到模板工作,请刷新页面后重试");

                int id = int.Parse(templateTaskId);
                var templateTask = m_dbAdapter.Template.GetTemplateTask(id);
                var templateTasks = m_dbAdapter.Template.GetTemplateTasks(templateTask.TemplateId.Value);
                templateTasks = templateTasks.Where(x => x.PrevIds.Contains(id)).ToList();

                if (templateTasks.Count > 0)
                {
                    for (int i = 0; i < templateTasks.Count; i++)
                    {
                        templateTasks[i].PrevIds.Remove(id);
                        LogEditProduct(EditProductType.EditTask, null,
                                       "更新模板工作[" + templateTasks[i].TemplateTaskId +
                                       "],删除前置任务prev_template_task_ids[" + id + "]", "");
                    }

                    templateTasks.All(x => 1 == m_dbAdapter.Task.UpdateTemplateTask(x));
                }

                int result = m_dbAdapter.Template.DeleteTemplateTask(templateTask);
                LogEditProduct(EditProductType.CreateProduct, null, "删除模板工作[" + templateTaskId + "][" + templateTask.TemplateTaskName + "]", "");
                CommUtils.Assert(result == 1, "操作异常");

                return ActionUtils.Success("");
            }));
        }
        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);
            }));
        }
Example #3
0
        public ActionResult SetRead(string projectGuid, Int64 nid)
        {
            return(ActionUtils.Json(() =>
            {
                var authorizedIds = m_dbAdapter.Authority.GetAuthorizedProjectIds();
                var project = m_dbAdapter.Project.GetProjectByGuid(projectGuid);
                CommUtils.Assert(authorizedIds.Contains(project.ProjectId), "当前用户没有修改产品[{0}]的权限", project.Name);

                var result = true;
                if (nid == 0)
                {
                    //set all read
                    if (!m_dbAdapter.News.SetAllNewsRead(project.ProjectId))
                    {
                        result = false;
                    }
                    else
                    {
                        return ActionUtils.Success(result);
                    }
                }
                //set single read
                if (!m_dbAdapter.News.SetNewsStatusRead(nid, project.ProjectId))
                {
                    result = false;
                }
                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("");
            }));
        }
Example #5
0
        public ActionResult GetAssetCashFlowDataDetail(string projectGuid, string paymentDay)
        {
            return(ActionUtils.Json(() =>
            {
                if (string.IsNullOrWhiteSpace(paymentDay))
                {
                    var errorResult = new
                    {
                        isError = true,
                        errorMessage = "请选择偿付期"
                    };
                    return ActionUtils.Success(errorResult);
                }

                DateTime paymentDate;
                if (!DateTime.TryParse(paymentDay, out paymentDate))
                {
                    var errorResult = new
                    {
                        isError = true,
                        errorMessage = "偿付期错误,请刷新页面后重试"
                    };
                    return ActionUtils.Success(errorResult);
                }

                var result = GetAssetCashflowTableDetail(projectGuid, paymentDate);

                return ActionUtils.Success(result);
            }));
        }
        public ActionResult GetRelatedUsers()
        {
            return(ActionUtils.Json(() =>
            {
                var projectSeriesGuidsOfCurrentUserName = m_dbAdapter.Permission.GetObjectUids(CurrentUserName, PermissionObjectType.ProjectSeries, PermissionType.Read);
                var projectSeries = m_dbAdapter.ProjectSeries.GetByGuids(projectSeriesGuidsOfCurrentUserName);

                List <string> usernameList = new List <string>();
                foreach (var singleProjectSeries in projectSeries)
                {
                    var singleProjectSeriesLogicModel = new ProjectSeriesLogicModel(CurrentUserName, singleProjectSeries);
                    var projectSeriesInstance = singleProjectSeriesLogicModel.Instance;
                    var project = singleProjectSeriesLogicModel.CurrentProject.Instance;

                    usernameList.Add(projectSeriesInstance.PersonInCharge);
                    usernameList.Add(projectSeriesInstance.CreateUserName);
                    var teamMembers = m_dbAdapter.TeamMember.GetByProjectId(project.ProjectId);
                    var teamMemberUsernames = teamMembers.Select(x => x.UserName).ToList();
                    usernameList.AddRange(teamMemberUsernames);
                }

                usernameList = usernameList.Distinct(StringComparer.OrdinalIgnoreCase).ToList();
                Platform.UserProfile.Precache(usernameList);

                var result = usernameList.ConvertAll(x => new
                {
                    userName = Platform.UserProfile.Get(x).UserName,
                    realName = Platform.UserProfile.Get(x).RealName,
                });
                return ActionUtils.Success(result);
            }));
        }
Example #7
0
        public ActionResult DeleteExtensionCheckItem(string shortCode, string checkItemName, string groupName)
        {
            return(ActionUtils.Json(() =>
            {
                CheckPermission(PermissionObjectType.Task, shortCode, PermissionType.Write);
                var task = m_dbAdapter.Task.GetTaskWithExInfo(shortCode);
                var taskExInfo = task.TaskExtension.TaskExtensionInfo;
                if (taskExInfo != null)
                {
                    var taskExCheckListInfo = CommUtils.FromJson <TaskExCheckListInfo>(taskExInfo);
                    foreach (var checkItemGroup in taskExCheckListInfo.CheckGroups)
                    {
                        if (checkItemGroup.GroupName == groupName)
                        {
                            CommUtils.AssertEquals(checkItemGroup.CheckItems.Count(x => x.Name == checkItemName), 1,
                                                   "工作[" + task + "]检查项分组[" + checkItemGroup.GroupName + "]下的[" + checkItemName + "]项有误,请刷新后重试");
                            checkItemGroup.CheckItems.RemoveAll(x => x.Name == checkItemName);
                        }
                    }
                    task.TaskExtension.TaskExtensionInfo = CommUtils.ToJson(taskExCheckListInfo);
                }

                task.TaskHandler = CurrentUserName;

                m_dbAdapter.Task.UpdateTaskExtension(task.TaskExtension);
                m_dbAdapter.Task.UpdateTask(task);
                m_dbAdapter.Project.NewEditProductLog(EditProductType.EditTask, task.ProjectId,
                                                      "更新Task[" + task.Description + "(" + task.ShortCode + ")]," + "删除扩展工作检查项分组[" + groupName + "]下的检查项[" + checkItemName + "]", "");
                var comment = "删除分组[" + groupName + "]中的工作要点[" + checkItemName + "]";
                m_dbAdapter.Task.AddTaskLog(task, comment);

                return ActionUtils.Success("");
            }));
        }
Example #8
0
        public ActionResult RemoveFile(string projectGuid, List <string> fileGuids)
        {
            return(ActionUtils.Json(() =>
            {
                var dms = GetDMSAndCheckPermission(projectGuid, PermissionType.Write);
                var dmsFiles = new List <DMSFile>();
                foreach (var fileGuid in fileGuids)
                {
                    var dmsFile = m_dbAdapter.DMSFile.GetByGuid(fileGuid);
                    var dmsFileSeries = m_dbAdapter.DMSFileSeries.GetById(dmsFile.DMSFileSeriesId);
                    var dmsFolder = m_dbAdapter.DMSFolder.GetById(dmsFileSeries.DMSFolderId);

                    CommUtils.AssertEquals(dmsFolder.DMSId, dms.Instance.Id,
                                           "FileGuid[{0}]不在DMS[{1}]中", fileGuid, dms.Instance.Guid);

                    CommUtils.Assert(IsCurrentUser(dmsFile.CreateUserName),
                                     "当前用户[{0}]不是[{1}]的创建者[{2}]", CurrentUserName, dmsFile.Name, dmsFile.CreateUserName);

                    dmsFiles.Add(dmsFile);
                }

                var fileNames = new List <string>();
                foreach (var dmsFile in dmsFiles)
                {
                    m_dbAdapter.DMSFile.Remove(dmsFile);
                    fileNames.Add("[" + dmsFile.Name + "]");
                }

                // m_dbAdapter.DMSProjectLog.AddDmsProjectLog(projectGuid, "删除文件" + string.Join(",", fileNames.ToArray()));

                return ActionUtils.Success(dmsFiles.Count);
            }));
        }
Example #9
0
        public ActionResult RemoveTask(string shortCode)
        {
            return(ActionUtils.Json(() =>
            {
                var task = m_dbAdapter.Task.GetTask(shortCode);
                var project = m_dbAdapter.Project.GetProjectById(task.ProjectId);
                CommUtils.AssertNotNull(project.ProjectSeriesId, "查找ProjectSeries失败,shortCode={0}", shortCode);
                CommUtils.AssertNotNull(task.TaskGroupId, "查找TaskGroup失败,shortCode={0}", shortCode);

                CheckPermission(PermissionObjectType.Task, shortCode, PermissionType.Write);
                task.TaskStatus = TaskStatus.Deleted;
                int removeRecordsCount = m_dbAdapter.Task.UpdateTask(task);

                //删除项目问题中对应的受阻工作
                var connectTasks = m_dbAdapter.IssueConnectionTasks.GetConnectionTasksByShortCode(shortCode);
                m_dbAdapter.IssueConnectionTasks.DeleteConnectionTasks(connectTasks);

                var logicModel = Platform.GetProject(project.ProjectGuid);
                logicModel.Activity.Add(project.ProjectId, ActivityObjectType.Task, task.ShortCode, "删除工作:" + task.Description);

                LogEditProduct(EditProductType.EditTask, project.ProjectId, "删除任务",
                               "删除一条任务:id=" + task.TaskId + ";name=" + task.Description + ";shortCode=" + task.ShortCode);

                return ActionUtils.Success(removeRecordsCount);
            }));
        }
Example #10
0
        public ActionResult GetFiles(string projectGuid, string folderGuid)
        {
            return(ActionUtils.Json(() =>
            {
                var dms = GetDMSAndCheckPermission(projectGuid, PermissionType.Read);
                var folder = dms.FindFolder(folderGuid);
                folder.IgnoreNull = false;

                CommUtils.AssertNotNull(folder, "找不到文件夹[folderGuid={0} DMSGuid={1}],请刷新后再试",
                                        folderGuid, dms.Instance.Guid);

                Platform.UserProfile.Precache(folder.Files.Select(x => x.LatestVerFile.CreateUserName));
                Platform.UserProfile.Precache(folder.Files.Select(x => x.LatestVerFile.LastModifyUserName));

                var result = folder.Files.Select(x => new
                {
                    folderGuid = folderGuid,
                    latestVerFileGuid = x.LatestVerFile.Guid,
                    fileSeriesGuid = x.FileSeries.Guid,
                    fileSeriesName = x.FileSeries.Name,
                    latestVerFileName = x.LatestVerFile.Name,
                    version = x.LatestVerFile.Version,
                    description = x.LatestVerFile.Description,
                    size = FileUtils.FormatSize(x.LatestVerFile.Size),
                    createTime = Toolkit.DateTimeToString(x.LatestVerFile.CreateTime),
                    createUser = Platform.UserProfile.Get(x.LatestVerFile.CreateUserName) == null? x.LatestVerFile.CreateUserName: Platform.UserProfile.Get(x.LatestVerFile.CreateUserName).RealName,
                    lastModifyTime = Toolkit.DateTimeToString(x.LatestVerFile.LastModifyTime),
                    lastModifyUser = Platform.UserProfile.Get(x.LatestVerFile.LastModifyUserName) == null? x.LatestVerFile.LastModifyUserName: Platform.UserProfile.Get(x.LatestVerFile.LastModifyUserName).RealName,
                });
                return ActionUtils.Success(result);
            }));
        }
Example #11
0
        public ActionResult RemoveFileSeries(string projectGuid, List <string> fileSeriesGuids)
        {
            return(ActionUtils.Json(() =>
            {
                var dms = GetDMSAndCheckPermission(projectGuid, PermissionType.Write);
                var fileSeriesList = new List <DMSFileSeries>();
                foreach (var fileSeriesGuid in fileSeriesGuids)
                {
                    var dmsFileSeries = m_dbAdapter.DMSFileSeries.GetByGuid(fileSeriesGuid);
                    var dmsFolder = m_dbAdapter.DMSFolder.GetById(dmsFileSeries.DMSFolderId);

                    CommUtils.AssertEquals(dmsFolder.DMSId, dms.Instance.Id,
                                           "fileSeriesGuid[{0}]不在DMS[{1}]中", fileSeriesGuid, dms.Instance.Guid);

                    CommUtils.Assert(IsCurrentUser(dmsFileSeries.CreateUserName),
                                     "当前用户[{0}]不是[{1}]的创建者[{2}]", CurrentUserName, dmsFileSeries.Name, dmsFileSeries.CreateUserName);

                    fileSeriesList.Add(dmsFileSeries);
                    m_dbAdapter.DMSProjectLog.AddDmsProjectLog(projectGuid, fileSeriesGuid, "删除文件" + fileSeriesGuid);
                }

                var result = m_dbAdapter.DMSFileSeries.Remove(fileSeriesList);

                return ActionUtils.Success(result);
            }));
        }
Example #12
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);
            }));
        }
Example #13
0
 public ActionResult IsValidTaskShortCode(string shortCode)
 {
     return(ActionUtils.Json(() => {
         CommUtils.Assert(m_dbAdapter.Task.TaskExists(shortCode), "工作代码[" + shortCode + "]不存在");
         return ActionUtils.Success(shortCode);
     }));
 }
Example #14
0
        public ActionResult GetNewestTaskStatus(string shortCodeList, string taskStatusList)
        {
            return(ActionUtils.Json(() =>
            {
                var authorizedIds = m_dbAdapter.Authority.GetAuthorizedProjectIds();
                var shortCodes = CommUtils.Split(shortCodeList);
                var tasks = m_dbAdapter.Task.GetTasks(shortCodes);

                var taskStatus = CommUtils.ParseEnumList <TaskStatus>(taskStatusList);

                var resultList = new List <TaskShortCodeStatus>();

                if (tasks.Count != taskStatus.Count)
                {
                    return ActionUtils.Success(resultList);
                }

                for (int i = 0; i < tasks.Count; i++)
                {
                    var task = tasks[i];
                    CommUtils.Assert(authorizedIds.Contains(task.ProjectId), "工作列表页面发生异常,请刷新页面后重试");
                    if (task.TaskStatus != taskStatus[i])
                    {
                        var taskShortCodeStatus = new TaskShortCodeStatus();
                        taskShortCodeStatus.ShortCode = task.ShortCode;
                        taskShortCodeStatus.TaskStatus = task.TaskStatus.ToString();
                        resultList.Add(taskShortCodeStatus);
                    }
                }

                return ActionUtils.Success(resultList);
            }));
        }
Example #15
0
        public ActionResult ResetSequence(string projectSeriesGuid, string orderedTaskGroupGuids)
        {
            return(ActionUtils.Json(() =>
            {
                var projectSeries = new ProjectSeriesLogicModel(CurrentUserName, projectSeriesGuid);
                var project = projectSeries.CurrentProject.Instance;
                CheckPermission(PermissionObjectType.Project, project.ProjectGuid, PermissionType.Write);

                var taskGroups = projectSeries.CurrentProject.TaskGroups;

                var oldGuids = taskGroups.Select(x => x.Instance.Guid).ToArray();
                var newGuids = CommUtils.Split(orderedTaskGroupGuids);
                CommUtils.Assert(CommUtils.IsEqual(oldGuids, newGuids), "当前工作组和服务器上不一致,请刷新后再试");

                var oldSequences = taskGroups.Select(x => x.Instance.Sequence.Value).ToList();
                taskGroups.ForEach(x => x.Instance.Sequence = oldSequences[Array.IndexOf(newGuids, x.Instance.Guid)]);

                var newTaskGroups = new List <TaskGroup>();
                for (int i = 0; i < taskGroups.Count(); i++)
                {
                    var taskGroup = taskGroups[i].Instance;
                    if (taskGroup.Sequence != oldSequences[i])
                    {
                        CheckPermission(PermissionObjectType.TaskGroup, taskGroup.Guid, PermissionType.Write);
                        newTaskGroups.Add(taskGroups[i].Instance);
                    }
                }

                newTaskGroups.ForEach(x => m_dbAdapter.TaskGroup.UpdateTaskGroup(x));

                return ActionUtils.Success(1);
            }));
        }
Example #16
0
        public ActionResult GetTaskInfo(string shortCode)
        {
            return(ActionUtils.Json(() =>
            {
                var task = m_dbAdapter.Task.GetTask(shortCode);

                CommUtils.AssertNotNull(task.TaskGroupId, "查找TaskGroup失败,shortCode={0}", shortCode);
                CheckPermission(PermissionObjectType.Task, shortCode, PermissionType.Read);

                if (task.TaskExtensionId.HasValue)
                {
                    task.TaskExtension = m_dbAdapter.Task.GetTaskExtension(task.TaskExtensionId.Value);
                }

                var taskInfo = new
                {
                    shortCode = task.ShortCode,
                    taskName = task.Description,
                    startTime = Toolkit.DateToString(task.StartTime),
                    endTime = Toolkit.DateToString(task.EndTime),
                    taskExType = task.TaskExtensionId.HasValue ? task.TaskExtension.TaskExtensionType.ToString() : string.Empty,
                    status = Toolkit.ToCnString(task.TaskStatus),
                    detail = task.TaskDetail,
                    target = task.TaskTarget,
                    personInCharge = task.PersonInCharge,
                    personInChargeUserProfile = Platform.UserProfile.Get(task.PersonInCharge),
                };

                return ActionUtils.Success(taskInfo);
            }));
        }
Example #17
0
        public ActionResult GenerateByUploadedExcel(DateTime paymentDate, string asOfDate)
        {
            return(ActionUtils.Json(() =>
            {
                var path = DemoJianYuanUtils.GetExcelReportPath();
                CommUtils.Assert(System.IO.File.Exists(path), "请先上传服务商报告文件(path={0})", path);

                Resource resource = null;
                using (FileStream fs = new FileStream(path, FileMode.Open))
                {
                    var ms = new MemoryStream();
                    var docFileInfo = new DocFileInfo {
                        DisplayName = "信托受托机构报告.docx"
                    };

                    var utils = new DemoJianYuanUtils();
                    utils.Generate(ms, fs, "服务商报告.xls", paymentDate, asOfDate);

                    ms.Seek(0, SeekOrigin.Begin);
                    var result = Tuple.Create(ms, docFileInfo);

                    //生成报告
                    var userName = string.IsNullOrWhiteSpace(CurrentUserName) ? "anonymous" : CurrentUserName;
                    resource = ResourcePool.RegisterMemoryStream(userName, result.Item2.DisplayName, result.Item1);
                }

                return ActionUtils.Success(resource.Guid.ToString());
            }));
        }
Example #18
0
        public ActionResult GetPersonInCharges(string projectSeriesGuid)
        {
            return(ActionUtils.Json(() =>
            {
                var projectSeriesLogicModel = new ProjectSeriesLogicModel(CurrentUserName, projectSeriesGuid);
                var projectSeries = projectSeriesLogicModel.Instance;
                var projectId = projectSeriesLogicModel.CurrentProject.Instance.ProjectId;

                CheckPermission(PermissionObjectType.ProjectSeries, projectSeriesGuid, PermissionType.Read);

                var adminUserNames = projectSeriesLogicModel.CurrentProject.Team.Chiefs.Select(x => x.UserName).ToList();

                var teamMembers = m_dbAdapter.TeamMember.GetByProjectId(projectId);
                var teamMemberUserNames = teamMembers.Select(x => x.UserName).ToList();

                var teamAdmins = m_dbAdapter.TeamAdmin.GetByProjectId(projectId);
                var teamAdminUserNames = teamAdmins.Select(x => x.UserName).ToList();

                var allUserNames = new List <string>();
                allUserNames.AddRange(adminUserNames);
                allUserNames.AddRange(teamAdminUserNames);
                allUserNames.AddRange(teamMemberUserNames);
                allUserNames = allUserNames.Distinct(StringComparer.OrdinalIgnoreCase).ToList();

                Platform.UserProfile.Precache(allUserNames);

                var result = allUserNames.ConvertAll(x => new {
                    UserInfo = Platform.UserProfile.Get(x),
                });

                return ActionUtils.Success(result);
            }));
        }
Example #19
0
        public ActionResult GetAssetCashflowDataTable(string projectGuid, string paymentDay)
        {
            return(ActionUtils.Json(() =>
            {
                if (string.IsNullOrWhiteSpace(paymentDay))
                {
                    var errorResult = new
                    {
                        isError = true,
                        errorMessage = "请选择偿付期"
                    };
                    return ActionUtils.Success(errorResult);
                }

                DateTime paymentDate;
                if (!DateTime.TryParse(paymentDay, out paymentDate))
                {
                    var errorResult = new
                    {
                        isError = true,
                        errorMessage = "偿付期错误,请刷新页面后重试"
                    };
                    return ActionUtils.Success(errorResult);
                }

                var handler = new TaskExAssetCashflow(CurrentUserName, null);
                var viewModel = new AssetCashflowStatisticInfo();
                var result = handler.GetACFTableByProject(viewModel, projectGuid, paymentDate);

                return ActionUtils.Success(result);
            }));
        }
        public ActionResult GetOneProjectSeriesInfo(string projectSeriesGuid)
        {
            return(ActionUtils.Json(() =>
            {
                var projectSeriesLogicModel = new ProjectSeriesLogicModel(CurrentUserName, projectSeriesGuid);
                var projectSeries = projectSeriesLogicModel.Instance;
                var project = projectSeriesLogicModel.CurrentProject.Instance;

                CommUtils.Assert(IsCurrentUser(projectSeries.CreateUserName) ||
                                 IsCurrentUser(projectSeries.PersonInCharge) ||
                                 m_dbAdapter.TeamAdmin.IsTeamAdmin(project.ProjectId, CurrentUserName),
                                 "当前用户[{0}]不是项目[{1}]的管理员/创建者/负责人", CurrentUserName, projectSeries.Name);

                CheckPermission(PermissionObjectType.ProjectSeries, projectSeriesGuid, PermissionType.Write);

                var result = new
                {
                    Name = projectSeries.Name,
                    Type = projectSeries.Type.ToString(),
                    StartTime = projectSeries.CreateTime.ToString("yyyy-MM-dd"),
                    EndTime = projectSeries.EstimatedFinishTime.HasValue?projectSeries.EstimatedFinishTime.Value.ToString("yyyy-MM-dd"):"",
                    PersonInCharge = Platform.UserProfile.Get(projectSeries.PersonInCharge).UserName,
                    Email = projectSeries.Email,
                };
                return ActionUtils.Success(result);
            }));
        }
        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);
            }));
        }
Example #22
0
        public ActionResult IsExistAllotUser(string projectGuid, string issueGuidText)
        {
            return(ActionUtils.Json(() =>
            {
                CheckPermission(PermissionObjectType.Project, projectGuid, PermissionType.Read);

                if (!string.IsNullOrWhiteSpace(issueGuidText))
                {
                    var issueGuids = CommUtils.Split(issueGuidText).ToList();
                    var issueList = m_dbAdapter.Issue.GetByGuids(issueGuids);
                    issueList = issueList.Where(x => !string.IsNullOrWhiteSpace(x.AllotUser)).ToList();

                    var allotUsers = issueList.ConvertAll(x => x.AllotUser);
                    Platform.UserProfile.Precache(allotUsers);

                    var result = issueList.ConvertAll(x => new
                    {
                        issueName = x.IssueName,
                        issueGuid = x.IssueGuid,
                        userName = x.AllotUser,
                        realName = Platform.UserProfile.Get(x.AllotUser).RealName,
                        issueStatus = x.IssueStatus
                    });

                    return ActionUtils.Success(result);
                }
                return ActionUtils.Success("");
            }));
        }
        public ActionResult GetPrepaymentHistory(string projectGuid, string paymentDate, int assetId)
        {
            return(ActionUtils.Json(() =>
            {
                var project = m_dbAdapter.Project.GetProjectByGuid(projectGuid);
                var dataset = m_dbAdapter.Dataset.GetDataset(project.ProjectId, DateUtils.ParseDigitDate(paymentDate));

                var histories = m_dbAdapter.PaymentHistory.GetAssetPrepaymentHistory(project.ProjectId, dataset.DatasetId, assetId);

                var result = new List <PrepayHistory>();

                Platform.UserProfile.Precache(histories.Select(x => x.TimeStampUserName));
                foreach (var history in histories)
                {
                    var prepayHistory = new PrepayHistory();
                    prepayHistory.AssetId = history.AssetId;
                    prepayHistory.PrepayAmount = double.Parse(history.PrepayAmount.ToString("n2"));
                    prepayHistory.PrepayTime = history.PrepayTime.ToString("yyyy-MM-dd");
                    prepayHistory.DistributionType = GetCnDistributionType(history.DistributionType);
                    prepayHistory.DistributionDetail = history.DistributionDetail;
                    prepayHistory.Comment = (history.Comment == null ? string.Empty : history.Comment);
                    prepayHistory.TimeStamp = history.TimeStamp.ToString();
                    prepayHistory.TimeStampUserName = Platform.UserProfile.GetDisplayRealNameAndUserName(history.TimeStampUserName);
                    result.Add(prepayHistory);
                }

                return ActionUtils.Success(result);
            }));
        }
Example #24
0
        public ActionResult DownloadImage(string imageGuid, string imageSharpnessTypeText)
        {
            return(ActionUtils.Json(() =>
            {
                var image = Platform.Repository.GetImage(imageGuid);
                var imageSharpnessType = CommUtils.ParseEnum <ImageSharpnessType>(imageSharpnessTypeText);

                var issueActivityId = m_dbAdapter.Image.GetIssueActivityImageByImageId(image.Id).IssueActivityId;
                CommUtils.Assert(m_dbAdapter.IssueActivity.IsValidIssueActivity(issueActivityId), "找不到图片[{0}],请刷新页面后重试", image.Name);

                var issue = m_dbAdapter.Issue.GetIssueByImageId(image.Id);
                CommUtils.Assert(issue.RecordStatus == RecordStatus.Valid, "问题[{0}]已经被删除,请刷新页面后重试", issue.IssueName);

                var project = m_dbAdapter.Project.GetProjectById(issue.ProjectId);
                CommUtils.Assert(project.ProjectId == issue.ProjectId,
                                 "您要下载的图片imageGuid[{0}],与当前产品projectGuid[{1}]不一致,请刷新页面后重试", imageGuid, project.ProjectGuid);
                CheckPermission(PermissionObjectType.Project, project.ProjectGuid, PermissionType.Read);

                var resultImagePath = image.GetImagePath();

                var imageName = Path.GetFileName(resultImagePath);
                var imageExtensionName = imageName.Substring(imageName.LastIndexOf('.') + 1);

                ImageFileType fileType;
                if (!Enum.TryParse <ImageFileType>(imageExtensionName.ToUpperInvariant(), out fileType))
                {
                    throw new ApplicationException("下载图片[" + imageName + "]失败,原图发生错误,重新上传后才可以下载");
                }

                var resource = ResourcePool.RegisterFilePath(CurrentUserName, imageName, resultImagePath);
                return ActionUtils.Success(resource.Guid.ToString());
            }));
        }
Example #25
0
        public ActionResult GetUserPermissionByUid(string uid, string objectType, string treeNodeName)
        {
            return(ActionUtils.Json(() =>
            {
                var permissionObjectType = CommUtils.ParseEnum <PermissionObjectType>(objectType);
                AuthorityCheck(permissionObjectType, uid, treeNodeName);
                var allUserName = m_dbAdapter.Permission.GetAllUserNameByUid(uid);
                Platform.UserProfile.Precache(allUserName);

                var allPermission = new List <Permission>();
                allUserName.ForEach(x => allPermission.AddRange(m_dbAdapter.Permission.GetAllPermission(x, uid)));

                var dictAllPermission = allPermission.GroupBy(x => x.UserName).ToDictionary(x => x.Key, y => y.ToList());
                var result = new List <UserPermissionInfo>();

                foreach (var item in dictAllPermission.Keys)
                {
                    var userRealName = Platform.UserProfile.GetRealName(item);
                    var userPermission = dictAllPermission[item];
                    if (userPermission.Count != 0 && userPermission.Count > 1)
                    {
                        var permissionTypeList = userPermission.ConvertAll(x => x.Type.ToString());
                        var permissionInfo = ConvertUserPermissionInfo(userPermission[0], userRealName);
                        permissionInfo.Permission = CommUtils.Join(permissionTypeList);
                        result.Add(permissionInfo);
                        continue;
                    }

                    var userPermissionInfo = ConvertUserPermissionInfo(userPermission.First(), userRealName);
                    result.Add(userPermissionInfo);
                }

                return ActionUtils.Success(result);
            }));
        }
Example #26
0
        public ActionResult CreateContact(string projectGuid, string organizationName,
                                          string dutyType, string name, string cellPhone, string email, string note)
        {
            return(ActionUtils.Json(() =>
            {
                var project = m_dbAdapter.Project.GetProjectByGuid(projectGuid);
                CheckHandleContactPermission(project);

                ValidateUtils.Name(organizationName, "相关方", 50);
                CommUtils.Assert(name.Length <= 30, "联系人不能超过30个字符数!");
                CommUtils.Assert(email.Length <= 38, "邮箱不能超过38个字符数!");
                CommUtils.Assert(cellPhone.Length <= 30, "电话不能超过30个字符数!");

                var contact = new Contact();
                contact.ProjectId = project.ProjectId;
                contact.OrganizationName = organizationName;
                contact.DutyType = CommUtils.ParseEnum <EDutyType>(dutyType);
                contact.Name = name;
                contact.Email = email;
                contact.CellPhone = cellPhone;
                contact.Note = note;
                m_dbAdapter.Contact.AddContact(contact);

                var logicModel = Platform.GetProject(project.ProjectGuid);
                logicModel.Activity.Add(project.ProjectId, ActivityObjectType.Contact, contact.Guid, "增加机构:" + contact.OrganizationName);

                return ActionUtils.Success(1);
            }));
        }
Example #27
0
        public ActionResult GetNewsDetail(string projectGuid, int?page, int?status, int?pageSize, DateTime?start, DateTime?end)
        {
            return(ActionUtils.Json(() =>
            {
                //权限检查
                var authorizedIds = m_dbAdapter.Authority.GetAuthorizedProjectIds();
                var project = m_dbAdapter.Project.GetProjectByGuid(projectGuid);
                CommUtils.Assert(authorizedIds.Contains(project.ProjectId), "当前用户没有读取产品[{0}]的权限", project.Name);

                var newsDetail = m_dbAdapter.News.GetProjectNewsDetail(project.ProjectId, page, status, pageSize, start, end);
                var result = new
                {
                    News = newsDetail.News.ConvertAll(x => new
                    {
                        ID = x.ID.ToString(),
                        URL = x.URL,
                        ProjectID = x.ProjectID,
                        Title = Toolkit.LongTitleDisplay(x.Title, 32),
                        Source = x.Source,
                        Status = x.Status,
                        OriginDate = ChineseAbs.ABSManagement.Utils.DateUtils.IsNormalDate(x.OriginDate) ? Toolkit.DateToString(x.OriginDate) : "-"
                    }),
                    StatisticInfo = new
                    {
                        Min = Toolkit.DateToString(newsDetail.Min),
                        Max = Toolkit.DateToString(newsDetail.Max),
                        TotalCount = newsDetail.TotalCount,
                        ReadCount = newsDetail.ReadCount,
                        UnreadCount = newsDetail.UnreadCount,
                        TotalPage = newsDetail.TotalPage
                    }
                };
                return ActionUtils.Success(result);
            }));
        }
Example #28
0
        public ActionResult GetTaskGroupList(string projectSeriesGuid)
        {
            return(ActionUtils.Json(() =>
            {
                var projectSeries = new ProjectSeriesLogicModel(CurrentUserName, projectSeriesGuid);
                var project = projectSeries.CurrentProject.Instance;
                CheckPermission(PermissionObjectType.Project, project.ProjectGuid, PermissionType.Read);

                var taskGroups = projectSeries.CurrentProject.TaskGroups;
                var allPermissionUid = m_dbAdapter.Permission.GetObjectUids(CurrentUserName, PermissionObjectType.TaskGroup, PermissionType.Read).ToDictionary(x => x);
                var hasPermissionTaskGroups = taskGroups.Where(x => allPermissionUid.ContainsKey(x.Instance.Guid)).ToList();

                var result = hasPermissionTaskGroups.ConvertAll(x => new
                {
                    guid = x.Instance.Guid,
                    name = x.Instance.Name,
                    projectGuid = projectSeries.CurrentProject.Instance.ProjectGuid,
                    description = x.Instance.Description,
                    sequence = x.Instance.Sequence,
                    percentCompleted = CommUtils.Percent(x.Tasks.Count(task => task.TaskStatus == TaskStatus.Finished), x.Tasks.Count, 0),
                    finishedTaskCount = x.Tasks.Count(task => task.TaskStatus == TaskStatus.Finished),
                    taskCount = x.Tasks.Count,
                    createUserName = x.Instance.CreateUserName,
                    createTimeStamp = Toolkit.DateTimeToString(x.Instance.CreateTime)
                });

                return ActionUtils.Success(result);
            }));
        }
Example #29
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 GetProjectActivities(string projectGuid, int topRecordCount)
        {
            return(ActionUtils.Json(() =>
            {
                CheckPermission(PermissionObjectType.Project, projectGuid, PermissionType.Read);

                var logicModel = new ProjectLogicModel(CurrentUserName, projectGuid);
                var records = logicModel.Activity.Get(topRecordCount);

                var userNames = records.Select(x => x.CreateUserName);
                Platform.UserProfile.Precache(userNames);

                var result = records.ConvertAll(x => new {
                    Guid = x.Guid,
                    CreatTime = Toolkit.DateTimeToString(x.CreateTime),
                    UidChainInfo = GetUidChainInfo(x.ActivityObjectType, x.ActivityObjectUniqueIdentifier),
                    Type = x.ActivityObjectType.ToString(),
                    UserInfo = new {
                        RealName = Platform.UserProfile.Get(x.CreateUserName).RealName,
                        UserName = Platform.UserProfile.Get(x.CreateUserName).UserName
                    },
                    LastModifyTime = Toolkit.DateTimeToString(x.LastModifyTime),
                    LastModifyUserName = x.LastModifyUserName,
                    Comment = x.Comment
                });

                return ActionUtils.Success(result);
            }));
        }