Ejemplo n.º 1
0
        public ActionResult GetCashflowDetailDataTable(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 = "解析偿付期[" + paymentDay + "]失败,请刷新页面后重试"
                    };
                    return ActionUtils.Success(errorResult);
                }

                try
                {
                    var result = GetCashflowDetailDataTable(projectGuid, paymentDate);
                    return ActionUtils.Success(result);
                }
                catch (ApplicationException ae)
                {
                    var errorResult = new
                    {
                        isError = true,
                        errorMessage = ae.Message
                    };
                    return ActionUtils.Success(errorResult);
                }
            }));
        }
Ejemplo n.º 2
0
        public ActionResult DeleteAgenda(string projectGuid, string guid)
        {
            return(ActionUtils.Json(() =>
            {
                CheckPermission(projectGuid);

                var project = m_dbAdapter.Project.GetProjectByGuid(projectGuid);
                CommUtils.Assert(project.ProjectSeriesId.HasValue, "找不到ProjectSeries[projectGuid={0}]信息", projectGuid);

                var agenda = m_dbAdapter.Agenda.GetAgendaByGuid(guid);

                CommUtils.Assert(IsCurrentUser(agenda.CreateUserName), "非该日程创建用户不得删除!");

                m_dbAdapter.Agenda.DeleteAgenda(agenda);

                var logicModel = Platform.GetProject(project.ProjectGuid);
                logicModel.Activity.Add(project.ProjectId, ActivityObjectType.Agenda, agenda.Guid, "删除日程:" + agenda.Name);

                return ActionUtils.Success(1);
            }));
        }
Ejemplo n.º 3
0
        public ActionResult CreateTemplate(string newTemplateName)
        {
            return(ActionUtils.Json(() =>
            {
                CommUtils.Assert(!string.IsNullOrEmpty(newTemplateName), "创建模板名称不能为空");
                CommUtils.Assert(newTemplateName.Length <= 20, "模板名称不能超过20个字符数");

                var template = new Template()
                {
                    TemplateName = newTemplateName,
                    TemplateGuid = Guid.NewGuid().ToString(),
                    CreateUser = CurrentUserName,
                    CreateTime = DateTime.Now
                };

                template = m_dbAdapter.Template.NewTemplate(template);
                LogEditProduct(EditProductType.CreateProduct, null, "创建Template[" + template.TemplateId + "][" + template.TemplateName + "]", "");

                return ActionUtils.Success("");
            }));
        }
Ejemplo n.º 4
0
        public ActionResult AddUsers(string userGroupGuid, string userNames)
        {
            return(ActionUtils.Json(() =>
            {
                var userGroup = m_dbAdapter.UserGroup.GetByGuid(userGroupGuid);
                CommUtils.Assert(IsCurrentUser(userGroup.Owner), "当前用户[{0}]不是[{1}]的创建者", CurrentUserName, userGroup.Name);

                var userNameList = CommUtils.Split(userNames);
                foreach (var userName in userNameList)
                {
                    var userGroupMap = new UserGroupMap
                    {
                        UserGroupGuid = userGroupGuid,
                        UserName = userName
                    };
                    m_dbAdapter.UserGroupMap.New(userGroupMap);
                }

                return ActionUtils.Success(1);
            }));
        }
Ejemplo n.º 5
0
        public ActionResult Generate(HttpPostedFileBase file, DateTime paymentDate, string asOfDate)
        {
            return(ActionUtils.Json(() =>
            {
                var fileName = file.FileName;
                if (!fileName.EndsWith("xls", StringComparison.CurrentCultureIgnoreCase) &&
                    !fileName.EndsWith("xlsx", StringComparison.CurrentCultureIgnoreCase))
                {
                    CommUtils.Assert(false, "根据[{0}]生成文档失败,请选择Excel文件上传", fileName);
                }

                //上传服务商报告
                var result = UploadDemoJianYuanReport(file, paymentDate, asOfDate);

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

                return ActionUtils.Success(resource.Guid.ToString());
            }));
        }
        public ActionResult GetImgs(string firstDocGuid, string secondDocGuid)
        {
            return(ActionUtils.Json(() =>
            {
                var firstFile = GetRepoFile(firstDocGuid);
                var secondFile = GetRepoFile(secondDocGuid);

                string filename = firstFile.Id + "_" + secondFile.Id;
                var compareUtil = new ComparisonUtil(imgfilePath, filename, ComparisonUtil.SaveType.Html);
                compareUtil.Compare2Doc(firstFile.GetFilePath(), secondFile.GetFilePath());

                var result = new
                {
                    addCount = compareUtil.AddCount,
                    deleteCount = compareUtil.DeleteCount,
                    imgCount = compareUtil.FileCount,
                    imgPath = compareUtil.FilePath,
                };
                return ActionUtils.Success(result);
            }));
        }
        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);
            }));
        }
Ejemplo n.º 8
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);
            }));
        }
Ejemplo n.º 9
0
        public ActionResult DownloadFile(string projectGuid, List <string> fileGuids)
        {
            return(ActionUtils.Json(() =>
            {
                var dms = GetDMSAndCheckPermission(projectGuid, PermissionType.Read);
                var resourceGuids = new List <string>();
                List <Tuple <string, string> > fileTuples = new List <Tuple <string, string> >();

                foreach (var fileGuid in fileGuids)
                {
                    CommUtils.Assert(m_dbAdapter.DMSFile.isExistDMSFile(fileGuid), "找不到文件fileGuid[{0}],请刷新页面后重试", fileGuid);
                    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);

                    var repoFile = Platform.Repository.GetFile(dmsFile.RepoFileId);
                    var resultFilePath = repoFile.GetFilePath();

                    fileTuples.Add(Tuple.Create(dmsFile.Name, resultFilePath));

                    var comment = "下载文件[" + dmsFile.Name + "]的第" + dmsFile.Version + "版本";
                    m_dbAdapter.DMSProjectLog.AddDmsProjectLog(projectGuid, dmsFileSeries.Guid, comment);
                }

                var fileNames = new List <string>();
                foreach (var fileTuple in fileTuples)
                {
                    var resource = ResourcePool.RegisterFilePath(CurrentUserName, fileTuple.Item1, fileTuple.Item2);
                    resourceGuids.Add(resource.Guid.ToString());

                    fileNames.Add("[" + fileTuple.Item1 + "]");
                }


                return ActionUtils.Success(resourceGuids);
            }));
        }
Ejemplo n.º 10
0
        public ActionResult SetKeyValue(string keyValue)
        {
            return(ActionUtils.Json(() =>
            {
                var dict = ParseKeyValue(keyValue);

                var path = DemoJianYuanUtils.GetKeyValuePath();

                //CommUtils.Assert(System.IO.File.Exists(path), "请先上传服务商报告文件(path={0})", path);
                if (System.IO.File.Exists(path))
                {
                    System.IO.File.Delete(path);
                }

                using (StreamWriter sw = new StreamWriter(path))
                {
                    sw.Write(keyValue);
                }

                return ActionUtils.Success(dict);
            }));
        }
Ejemplo n.º 11
0
        public ActionResult GetAssetInfo(string projectGuid, string paymentDate, int assetId)
        {
            return(ActionUtils.Json(() =>
            {
                var date = DateUtils.ParseDigitDate(paymentDate);
                var logicModel = Platform.GetProject(projectGuid);
                var datasetSchedule = logicModel.DealSchedule.GetByPaymentDay(date);
                var dataset = datasetSchedule.Dataset;

                CommUtils.Assert(dataset.HasDealModel, "找不到第{0}期模型", date);

                var acfTable = dataset.DealModel.AssetCashflowDt;
                var assets = dataset.Assets;
                Toolkit.AddAssetIdToRepeatedCNName(acfTable, assets);

                var assetList = assets.Where(x => x.AssetId == assetId).ToList();
                CommUtils.AssertEquals(assetList.Count, 1, "查找资产失败,AssetId={0}", assetId);

                var result = new CollateralAssetViewModel(assetList.Single());
                return ActionUtils.Success(result);
            }));
        }
Ejemplo n.º 12
0
        public ActionResult GetContacts(string projectGuid)
        {
            return(ActionUtils.Json(() =>
            {
                var project = m_dbAdapter.Project.GetProjectByGuid(projectGuid);
                CheckHandleContactPermission(project);

                var contacts = m_dbAdapter.Contact.GetContactsByProjectId(project.ProjectId);
                var result = contacts.ConvertAll(x => new
                {
                    guid = x.Guid,
                    organizationName = x.OrganizationName,
                    dutyType = x.DutyType.ToString(),
                    name = x.Name,
                    cellPhone = x.CellPhone,
                    email = x.Email,
                    note = x.Note
                });

                return ActionUtils.Success(result);
            }));
        }
        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);
            }));
        }
Ejemplo n.º 14
0
        public ActionResult DownloadFile(string fileGuid)
        {
            return(ActionUtils.Json(() =>
            {
                var file = Platform.Repository.GetFile(fileGuid);
                var resultFilePath = file.GetFilePath();

                var issueActivityId = m_dbAdapter.File.GetIssueActivityFileByFileId(file.Id).IssueActivityId;
                CommUtils.Assert(m_dbAdapter.IssueActivity.IsValidIssueActivity(issueActivityId), "找不到文件[{0}],请刷新页面后重试", file.Name);

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

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

                var resource = ResourcePool.RegisterFilePath(CurrentUserName, file.Name, resultFilePath);
                return ActionUtils.Success(resource.Guid.ToString());
            }));
        }
Ejemplo n.º 15
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("");
            }));
        }
Ejemplo n.º 16
0
        public ActionResult ResolveIssue(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.ForEach(x => CommUtils.Assert(x.IssueStatus != IssueStatus.Finished, "问题[{0}]已经解决。", x.IssueName));
                    issueList.ForEach(x =>
                    {
                        x.IssueStatus = IssueStatus.Finished;
                        m_dbAdapter.Issue.UpdateIssue(x);
                        CreateIssueActivity(x.Id, "解决了此问题", IssueActivityType.SystemGenerate, null);
                    });
                }

                return ActionUtils.Success("");
            }));
        }
        public ActionResult GetProjectSeriesByUsername()
        {
            return(ActionUtils.Json(() =>
            {
                var currentUsername = CurrentUserName;
                var uids = m_dbAdapter.Permission.GetObjectUids(currentUsername, PermissionObjectType.ProjectSeries, PermissionType.Read);
                var projectSeriesList = m_dbAdapter.ProjectSeries.GetByGuids(uids).ToList();

                var result = new
                {
                    ChiefsProjectSeries = projectSeriesList.Where(x =>
                                                                  x.RecordStatus == RecordStatus.Valid &&
                                                                  (IsCurrentUser(x.CreateUserName) || IsCurrentUser(x.PersonInCharge))
                                                                  ).ToList().ConvertAll(x => new
                    {
                        Name = x.Name,
                        Guid = x.Guid,
                    }),
                    TeamAdminProjectSeries = projectSeriesList.Where(x =>
                                                                     x.RecordStatus == RecordStatus.Valid &&
                                                                     IsTeamAdmin(x.Guid, CurrentUserName)
                                                                     ).ToList().ConvertAll(x => new
                    {
                        Name = x.Name,
                        Guid = x.Guid,
                    }),
                    CreatorProjectSeries = projectSeriesList.Where(x =>
                                                                   x.RecordStatus == RecordStatus.Valid &&
                                                                   IsCurrentUser(x.CreateUserName)
                                                                   ).ToList().ConvertAll(x => new
                    {
                        Name = x.Name,
                        Guid = x.Guid,
                    })
                };

                return ActionUtils.Success(result);
            }));
        }
Ejemplo n.º 18
0
        public ActionResult GetLog(string projectGuid, string fileSeriesGuid, int?cachedRecordCount)
        {
            return(ActionUtils.Json(() =>
            {
                var logs = m_dbAdapter.DMSProjectLog.GetLogs(projectGuid, fileSeriesGuid);
                // if (logs == null
                //    || (cachedRecordCount.HasValue && cachedRecordCount.Value == logs.Count))
                //{
                //    return ActionUtils.Success(new List<object>());
                //}

                Platform.UserProfile.Precache(logs.Select(x => x.TimeStampUserName));
                var result = logs.Select(x => new
                {
                    Time = Toolkit.DateTimeToString(x.TimeStamp),
                    UserName = Platform.UserProfile.GetDisplayRealNameAndUserName(x.TimeStampUserName),
                    Comment = x.Comment,
                });

                return ActionUtils.Success(result);
            }));
        }
        public ActionResult UpdatePaymentHistoryAssetCashflow(string projectGuid, string paymentDate, int assetId,
                                                              decimal principal, decimal interest, string comment)
        {
            return(ActionUtils.Json(() =>
            {
                CommUtils.Assert(!string.IsNullOrEmpty(comment), "[说明]不能为空");
                CommUtils.Assert(DateUtils.IsDigitDate(paymentDate), "Parse payment date failed [" + paymentDate + "].");
                var project = m_dbAdapter.Project.GetProjectByGuid(projectGuid);

                var assetPaymentInfo = m_dbAdapter.PaymentHistory.GetCurrentAssetPaymentInfo(project.ProjectId, DateUtils.ParseDigitDate(paymentDate), assetId);

                var now = DateTime.Now;
                var history = new AssetCashflowHistory();
                history.ProjectId = project.ProjectId;
                history.PaymentDate = DateUtils.ParseDigitDate(paymentDate);
                history.AssetId = assetId;
                history.AssetName = assetPaymentInfo.AssetName;
                history.HandleType = AssetCashflowHandleType.UserEdit;
                history.Comment = comment;
                history.TimeStamp = now;
                history.TimeStampUserName = CurrentUserName;

                if (principal != assetPaymentInfo.Principal)
                {
                    history.FieldType = AssetCashflowFieldType.Pricipal;
                    history.FieldValue = principal.ToString();
                    m_dbAdapter.PaymentHistory.NewAssetCashflowHistory(history);
                }

                if (interest != assetPaymentInfo.Interest)
                {
                    history.FieldType = AssetCashflowFieldType.Interest;
                    history.FieldValue = interest.ToString();
                    m_dbAdapter.PaymentHistory.NewAssetCashflowHistory(history);
                }

                return ActionUtils.Success("");
            }));
        }
Ejemplo n.º 20
0
        public ActionResult GetContact(string contactGuid)
        {
            return(ActionUtils.Json(() =>
            {
                var contact = m_dbAdapter.Contact.GetByGuid(contactGuid);
                var project = m_dbAdapter.Project.GetProjectById(contact.ProjectId);
                CheckHandleContactPermission(project);

                var result = new
                {
                    guid = contact.Guid,
                    organizationName = contact.OrganizationName,
                    dutyType = contact.DutyType.ToString(),
                    name = contact.Name,
                    cellPhone = contact.CellPhone,
                    email = contact.Email,
                    note = contact.Note
                };

                return ActionUtils.Success(result);
            }));
        }
Ejemplo n.º 21
0
        public ActionResult GetInvestments(string projectGuid, int?page, int?pageSize)
        {
            return(ActionUtils.Json(() =>
            {
                var project = m_dbAdapter.Project.GetProjectByGuid(projectGuid);
                var investments = m_dbAdapter.Investment.GetInvestmentsByProjectId(project.ProjectId);
                var investmentIds = investments.ConvertAll(x => x.Id).ToList();
                var investmentsOfPage = m_dbAdapter.Investment.GetInvestments(page ?? 1, pageSize ?? 10, investmentIds);
                var result = new
                {
                    Investments = investmentsOfPage.Items.ConvertAll(x => new
                    {
                        guid = x.Guid,
                        name = x.Name,
                        description = Toolkit.ToString(x.Description),
                        money = x.Money.ToString("n2"),
                        gains = (x.Gains.HasValue ? x.Gains.Value.ToString("n2") : "-"),
                        yield = (x.Yield.HasValue ? x.Yield.Value.ToString("P") : "-"),
                        yieldDue = (x.YieldDue.HasValue ? CommUtils.Percent(x.YieldDue.Value, 1) : "-"),
                        gainsDue = x.YieldDue.HasValue ? InterestRateUtils.CalculateGains(x.YieldDue.Value, x.Money, x.EndTime, x.StartTime).ToString("n2") : "-",
                        startTime = Toolkit.DateToString(x.StartTime),
                        endTime = Toolkit.DateToString(x.EndTime),
                        accountingTime = Toolkit.DateToString(x.AccountingTime),
                        status = x.Gains.HasValue ? "Finished" : "Running",
                        reminderInfo = m_dbAdapter.MessageReminding.GetResultByUid(x.Guid),
                    }).ToList(),
                    StatisticInfo = new
                    {
                        totalMoney = investments.Sum(x => x.Money).ToString("n2"),
                        totalGains = investments.Sum(x => x.Gains ?? 0).ToString("n2"),
                        totalCount = investments.Count.ToString("n0"),
                        totalFinished = investments.Sum(x => x.Gains.HasValue ? 1 : 0).ToString("n0"),
                        totalRunning = investments.Sum(x => x.Gains.HasValue ? 0 : 1).ToString("n0")
                    }
                };

                return ActionUtils.Success(result);
            }));
        }
Ejemplo n.º 22
0
        public ActionResult AddUserPermission(string uid, string objectType, string username, string permissionTypeText, string treeNodeName)
        {
            return(ActionUtils.Json(() =>
            {
                CommUtils.Assert(!string.IsNullOrWhiteSpace(permissionTypeText), "权限类型不能为空");
                CommUtils.Assert(m_dbAdapter.Authority.IsUserExist(username), "用户[{0}]不存在", username);

                var permissionObjectType = CommUtils.ParseEnum <PermissionObjectType>(objectType);

                AuthorityCheck(permissionObjectType, uid, treeNodeName, username);

                var permissionList = CommUtils.ParseEnumList <PermissionType>(permissionTypeText, true);
                CommUtils.Assert(permissionList.Any(x => x == PermissionType.Read), "增加用户权限时,只读权限必须勾选");
                var realName = m_dbAdapter.Authority.GetUserRealName(username);

                var toAddPermission = new List <Permission>();

                foreach (var type in permissionList)
                {
                    var permission = new Permission
                    {
                        Type = type,
                        UserName = username,
                        ObjectUniqueIdentifier = uid,
                        ObjectType = permissionObjectType
                    };
                    CommUtils.Assert(!m_dbAdapter.Permission.HasPermission(permission),
                                     "用户[{0}({1})]已有[{2}]权限", realName, username, type.ToString());
                    toAddPermission.Add(permission);
                }

                toAddPermission.ForEach(x => m_dbAdapter.Permission.NewPermission(x));
                m_dbAdapter.Project.NewEditProductLog(EditProductType.EditPermission, null,
                                                      "用户[" + realName + "(" + username + ")],ObjectType[" + permissionObjectType + "]中添加[" + permissionTypeText + "]权限", "");

                AddParentPermission(uid, username, permissionObjectType);
                return ActionUtils.Success(1);
            }));
        }
Ejemplo n.º 23
0
        public ActionResult UploadDemoJianYuanReport(HttpPostedFileBase file, string shortCode)
        {
            return(ActionUtils.Json(() =>
            {
                var fileName = file.FileName;
                if (!fileName.EndsWith("xls", StringComparison.CurrentCultureIgnoreCase) &&
                    !fileName.EndsWith("xlsx", StringComparison.CurrentCultureIgnoreCase))
                {
                    CommUtils.Assert(false, "根据[{0}]生成文档失败,请选择Excel文件上传", fileName);
                }

                var handler = new TaskExDemoJianYuanReport(CurrentUserName, shortCode);
                //上传服务商报告
                var result = handler.UploadDemoJianYuanReport(file, shortCode);

                //生成报告
                var resource = ResourcePool.RegisterMemoryStream(CurrentUserName, result.Item2.DisplayName, result.Item1);

                m_dbAdapter.Task.AddTaskLog(shortCode, "上传[" + file.FileName + "],转换为[" + result.Item2.DisplayName + "]");
                return ActionUtils.Success(resource.Guid.ToString());
            }));
        }
Ejemplo n.º 24
0
        public ActionResult SetAllotUser(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);
                    CommUtils.Assert(issueList.Select(x => x.ProjectId).Distinct().Count() == 1,
                                     "不能领取不属于同一产品的问题");
                    CommUtils.AssertEquals(issueGuids.Count, issueList.Count, "问题列表的信息错误,请刷新页面后重试");
                    issueList.ForEach(x =>
                    {
                        CommUtils.Assert(x.IssueStatus != IssueStatus.Finished, "问题[{0}]已经解决,无法继续领取", x.IssueName);
                        if (!string.IsNullOrWhiteSpace(x.AllotUser) && x.AllotUser != "-")
                        {
                            CommUtils.Assert(x.AllotUser != CurrentUserName, "您已经领取过问题[{0}]", x.IssueName);
                        }
                    });

                    issueList.ForEach(x =>
                    {
                        x.AllotUser = CurrentUserName;
                        x.IssueAllotTime = DateTime.Now;
                        x.IssueStatus = IssueStatus.Running;
                        x.LastModifyTime = DateTime.Now;
                        x.LastModifyUserName = CurrentUserName;
                        m_dbAdapter.Issue.UpdateIssue(x);
                        CreateIssueActivity(x.Id, "领取了此问题", IssueActivityType.SystemGenerate, null);
                    });

                    return ActionUtils.Success(issueList.Count);
                }
                return ActionUtils.Success(0);
            }));
        }
Ejemplo n.º 25
0
        public ActionResult GetIssueInfo(string shortCode)
        {
            return(ActionUtils.Json(() =>
            {
                var connectionTasks = m_dbAdapter.IssueConnectionTasks.GetConnectionTasksByShortCode(shortCode);
                var issueIds = connectionTasks.ConvertAll(x => x.IssueId).ToList();
                var issueList = m_dbAdapter.Issue.GetIssueByIssueIds(issueIds);

                var usernames = new List <string>();
                issueList.ForEach(x => {
                    usernames.Add(x.AllotUser);
                    usernames.Add(x.CreateUserName);
                });
                Platform.UserProfile.Precache(usernames.Distinct());

                var result = issueList.ConvertAll(x => new
                {
                    issueName = x.IssueName,
                    issueGuid = x.IssueGuid,
                    issueDescription = x.Description,
                    issueStatus = x.IssueStatus.ToString(),
                    issueEmergencyLevel = x.IssueEmergencyLevel.ToString(),
                    CreateUser = new
                    {
                        UserName = x.CreateUserName,
                        RealName = Platform.UserProfile.GetRealName(x.CreateUserName) ?? string.Empty,
                    },
                    CreateTime = Toolkit.DateTimeToString(x.CreateTime),
                    AllotUser = new
                    {
                        UserName = x.AllotUser,
                        RealName = Platform.UserProfile.GetRealName(x.AllotUser) ?? string.Empty,
                    },
                    UpdateTime = Toolkit.DateTimeToString(x.IssueAllotTime),
                });
                return ActionUtils.Success(result);
            }));
        }
Ejemplo n.º 26
0
        public ActionResult GetTasks(string taskGroupGuid)
        {
            return(ActionUtils.Json(() =>
            {
                var taskGroup = m_dbAdapter.TaskGroup.GetByGuid(taskGroupGuid);
                CheckPermission(PermissionObjectType.TaskGroup, taskGroupGuid, PermissionType.Read);

                var projectLogicModel = new ProjectLogicModel(CurrentUserName, taskGroup.ProjectId);
                var taskGroupLogicModel = projectLogicModel.TaskGroups.Single(x => x.Instance.Guid == taskGroupGuid);

                Platform.UserProfile.Precache(taskGroupLogicModel.Tasks.Select(x => x.PersonInCharge));

                var allPermissionUid = m_dbAdapter.Permission.GetObjectUids(CurrentUserName, PermissionObjectType.Task, PermissionType.Read).ToDictionary(x => x);
                var hasPermissionTasks = taskGroupLogicModel.Tasks.Where(x => allPermissionUid.ContainsKey(x.ShortCode)).ToList();
                var permissionList = m_dbAdapter.Permission.GetByObjectUid(hasPermissionTasks.Select(x => x.ShortCode)).Where(x => x.UserName == CurrentUserName);

                var result = hasPermissionTasks.ConvertAll(x =>
                                                           new
                {
                    shortCode = x.ShortCode,
                    taskName = x.Description,
                    beginTime = Toolkit.DateToString(x.StartTime),
                    endTime = Toolkit.DateToString(x.EndTime),
                    status = x.TaskStatus.ToString(),
                    personInCharge = x.PersonInCharge,
                    personInChargeUserProfile = Platform.UserProfile.Get(x.PersonInCharge),
                    target = x.TaskTarget,
                    detail = x.TaskDetail,
                    reminderInfo = m_dbAdapter.MessageReminding.GetResultByUid(x.ShortCode),
                    taskExType = x.TaskExtensionId.HasValue ? x.TaskExtension.TaskExtensionType.ToString() : string.Empty,
                    permission = permissionList.Where(p => p.ObjectUniqueIdentifier == x.ShortCode).Select(p =>
                                                                                                           p.Type.ToString())
                }
                                                           );

                return ActionUtils.Success(result);
            }));
        }
Ejemplo n.º 27
0
        public ActionResult RemoveTeamMembers(string projectSeriesGuid, string userNames)
        {
            return(ActionUtils.Json(() =>
            {
                var projectSeriesLogicModel = new ProjectSeriesLogicModel(CurrentUserName, projectSeriesGuid);
                var project = projectSeriesLogicModel.CurrentProject.Instance;
                CommUtils.Assert(IsAdmin(projectSeriesLogicModel.Instance, CurrentUserName) ||
                                 m_dbAdapter.TeamAdmin.IsTeamAdmin(project.ProjectId, CurrentUserName),
                                 "当前用户[{0}]不是项目[{1}]的创建者/负责人/管理员", Platform.UserProfile.GetDisplayRealNameAndUserName(CurrentUserName),
                                 projectSeriesLogicModel.Instance.Name);

                var teamMembers = m_dbAdapter.TeamMember.GetByProjectId(project.ProjectId);
                var userNameList = CommUtils.Split(userNames).ToList();
                foreach (var userName in userNameList)
                {
                    CommUtils.Assert(teamMembers.Any(x => x.UserName.Equals(userName, StringComparison.CurrentCultureIgnoreCase)),
                                     "查找项目成员[{0}]失败", userName);

                    CommUtils.Assert((!IsAdmin(projectSeriesLogicModel.Instance, userName)) &&
                                     (!m_dbAdapter.TeamAdmin.IsTeamAdmin(project.ProjectId, userName)),
                                     "检测到[{0}]是产品创建者/负责人,移除项目成员失败", userName);
                }

                var projectActivityLogicModel = projectSeriesLogicModel.CurrentProject.Activity;

                teamMembers = teamMembers.Where(x => userNameList.Contains(x.UserName)).ToList();
                foreach (var teamMember in teamMembers)
                {
                    m_dbAdapter.TeamMember.Remove(teamMember);
                    projectActivityLogicModel.Add(project.ProjectId, ActivityObjectType.TeamMember, teamMember.Guid, "删除项目成员:" + Platform.UserProfile.Get(teamMember.UserName).RealName);
                }

                var permissionLogicModel = new PermissionLogicModel(CurrentUserName, projectSeriesLogicModel.Instance);
                permissionLogicModel.RemoveUserPermissionByProjectSeries(userNameList);

                return ActionUtils.Success(1);
            }));
        }
Ejemplo n.º 28
0
        public ActionResult CancelSubscribe(string projectGuids)
        {
            return(ActionUtils.Json(() =>
            {
                var projectGuidList = CommUtils.Split(projectGuids).ToList();
                CommUtils.Assert(m_dbAdapter.NegativeNews.CheckProjectsPermission(projectGuidList), "当前用户没有操作该产品权限,请刷新重试");

                projectGuidList.ForEach(x =>
                {
                    if (!string.IsNullOrWhiteSpace(x))
                    {
                        var projectId = m_dbAdapter.Project.GetProjectByGuid(x).ProjectId;
                        var negativeNews = m_dbAdapter.NegativeNews.GetByProjIdUser(projectId, CurrentUserName);
                        if (negativeNews != null)
                        {
                            m_dbAdapter.Permission.HasPermission(CurrentUserName, x, PermissionType.Execute);
                            m_dbAdapter.NegativeNews.Delete(negativeNews);
                        }
                    }
                });
                return ActionUtils.Success(1);
            }));
        }
        public ActionResult Load()
        {
            return(ActionUtils.Json(() =>
            {
                var editAcf = Platform.User.ActionHabits.EditAssetCashflow;
                var result = new
                {
                    EditAssetCashflow = new
                    {
                        EditPrincipal = new
                        {
                            AutoSyncPrincipalBalance = editAcf.EditPrincipal.AutoSyncPrincipalBalance,
                        },
                        EditPrincipalBalance = new
                        {
                            AutoSyncPrincipal = editAcf.EditPrincipalBalance.AutoSyncPrincipal,
                        }
                    }
                };

                return ActionUtils.Success(result);
            }));
        }
Ejemplo n.º 30
0
        public ActionResult TestCalculateTime(string timeSeriesGuid)
        {
            return(ActionUtils.Json(() =>
            {
                var timeSeries = m_dbAdapter.TimeSeries.GetByGuid(timeSeriesGuid);
                var timeRule = GetTimeRuleDetail(timeSeries.Id);
                var timeOrigin = GetTimeOriginDetail(timeSeries.Guid, timeSeries.Id);

                //检查时间规则
                CheckTimeRuleParam(timeRule);

                //检查时间来源
                CheckTimeOriginParam(timeOrigin);

                //初始化时间列表
                var result = GetTimeListByTimeRuleOrigin(timeRule, timeOrigin);
                if (result == null)
                {
                    return ActionUtils.Success("");
                }
                return ActionUtils.Success(CommUtils.Join(result.ToArray()));
            }));
        }