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);
            }));
        }
Esempio n. 2
0
        public void Commit()
        {
            if (this.disposed)
            {
                return;
            }

            try
            {
                if (this.dataAccessObjectDataContext != null)
                {
                    this.commandsContext = this.GetSqlTransactionalCommandsContext();
                    this.dataAccessObjectDataContext.Commit(this.commandsContext, false);
                    this.commandsContext.Commit();
                }
            }
            catch (Exception e)
            {
                ActionUtils.IgnoreExceptions(() => this.commandsContext?.Rollback());

                throw new DataAccessTransactionAbortedException(e);
            }
            finally
            {
                this.Dispose();
            }
        }
Esempio n. 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);
            }));
        }
Esempio n. 4
0
        public void SinglePhaseCommit(SinglePhaseEnlistment singlePhaseEnlistment)
        {
            if (this.disposed)
            {
                return;
            }

            try
            {
                this.dataAccessObjectDataContext?.Commit(this, false);

                foreach (var commandsContext in this.commandsContextsBySqlDatabaseContexts.Values)
                {
                    commandsContext.Commit();
                }

                singlePhaseEnlistment.Committed();
            }
            catch (Exception e)
            {
                commandsContextsBySqlDatabaseContexts.Values.ForEach(c => ActionUtils.IgnoreExceptions(c.Rollback));

                singlePhaseEnlistment.Aborted(e);
            }
            finally
            {
                this.Dispose();
            }
        }
        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 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);
            }));
        }
Esempio n. 7
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);
            }));
        }
Esempio n. 8
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);
            }));
        }
Esempio n. 9
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);
            }));
        }
Esempio n. 10
0
        /// <summary>
        /// Returns the ServerCharacter of the foe we hit, or null if none found.
        /// </summary>
        /// <returns></returns>
        private IDamageable DetectFoe(ulong foeHint = 0)
        {
            //this simple detect just does a boxcast out from our position in the direction we're facing, out to the range of the attack.

            RaycastHit[] results;
            int          numResults = ActionUtils.DetectMeleeFoe(Description.IsFriendly ^ m_Parent.IsNpc, m_Parent.GetComponent <Collider>(), Description, out results);

            if (numResults == 0)
            {
                return(null);
            }

            //everything that passes the mask should have a ServerCharacter component.
            IDamageable foundFoe = results[0].collider.GetComponent <IDamageable>();

            //we always prefer the hinted foe. If he's still in range, he should take the damage, because he's who the client visualization
            //system will play the hit-react on (in case there's any ambiguity).
            for (int i = 0; i < numResults; i++)
            {
                var serverChar = results[i].collider.GetComponent <IDamageable>();
                if (serverChar != null && serverChar.NetworkObjectId == foeHint)
                {
                    foundFoe = serverChar;
                    break;
                }
            }

            return(foundFoe);
        }
        public override void Run()
        {
            try
            {
                for (;;)
                {
                    try
                    {
                        if (this.RunLevel.Equals(DisconnectedRunLevel.Default))
                        {
                            ActionUtils.IgnoreExceptions(Close);

                            return;
                        }

                        BuildAndProcessSingleCommand();
                    }
                    catch (Exception e)
                    {
                        UnhandledExceptionFromSingleCommand(e);
                    }
                }
            }
            finally
            {
                ActionUtils.IgnoreExceptions(Close);
            }
        }
Esempio n. 12
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);
            }));
        }
Esempio n. 13
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());
            }));
        }
Esempio n. 14
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 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. 16
0
        public async Task Self_Ready()
        {
            //inits
            DataManager.pp_songs               = Utils.InitPpSong();
            DataManager.people_spam            = new Dictionary <ulong, int>();
            DataManager.actions                = new Dictionary <string, Actions.Action>();
            DataManager.otherActions           = new List <Actions.OtherActions.AOtherAction>();
            DataManager.nsfw_content_inprocess = new Dictionary <IUserMessage, IUserMessage>();
            DataManager.actions_used           = SaveStateManager.Load <Dictionary <string, int> >(DataManager.Binary.POP_ACTIONS_FILE) ?? new Dictionary <string, int>();

            //register des actions
            ActionUtils.RegisterActions("DiscordBot.Actions.CommandActions");
            ActionUtils.RegisterActions("DiscordBot.Actions.AdminActions");
            ActionUtils.RegisterActions("DiscordBot.Actions.DeleteActions");
            ActionUtils.RegisterActions("DiscordBot.Actions.OtherActions");

            //mes setups
            Utils.Init();

            try {
                if (!Utils.IsTestBot)
                {
                    //Thread qui regarde les nouveaux scans
                    new Thread(ThreadUtils.QwerteeThread).Start();
                    new Thread(new JapscanMangaCrawler().Crawl).Start();
                }
                new Thread(ThreadUtils.EmptyPeopleSpamStack).Start();
            }
            catch (System.Exception e) {
                e.Display("Problème Threads Self_Ready");
                await Channels.Problems.SendMessagesAsync(e.Message);
            }

            await Channels.Debugs.SendMessageAsync("Bot ready");
        }
Esempio n. 17
0
 protected override void onStart()
 {
     base.onStart();
     waitOver = false;
     openNext = false;
     ActionUtils.RunAction(GameObjectAgent.getAgentGameObject(gameObject, gameObject), target);
 }
Esempio n. 18
0
        public virtual T CreateDataAccessObject <T, K>(K primaryKey, PrimaryKeyType primaryKeyType)
            where T : DataAccessObject
        {
            var objectPropertyAndValues = this.GetObjectPropertyValues <K>(typeof(T), primaryKey, primaryKeyType);

            if (objectPropertyAndValues.Any(keyValue => keyValue.Value == null))
            {
                throw new MissingOrInvalidPrimaryKeyException();
            }

            var existing = this.GetCurrentDataContext(false).GetObject(this.GetConcreteTypeFromDefinitionType(typeof(T)), objectPropertyAndValues);

            if (existing != null)
            {
                T obj = null;

                ActionUtils.IgnoreExceptions(() => obj = this.GetReference <T, K>(primaryKey, primaryKeyType));

                throw new ObjectAlreadyExistsException(obj, null, "CreateDataAccessObject");
            }
            else
            {
                var retval = this.RuntimeDataAccessModelInfo.CreateDataAccessObject <T>(this, true);

                retval.ToObjectInternal().SetPrimaryKeys(objectPropertyAndValues);
                retval.ToObjectInternal().FinishedInitializing();
                retval.ToObjectInternal().SubmitToCache();

                return(retval);
            }
        }
Esempio n. 19
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);
            }));
        }
Esempio n. 20
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());
            }));
        }
            public override void Close()
            {
                lock (this)
                {
                    if (!this.closed)
                    {
                        StabilizeClientState();

                        Flush();

                        OnBeforeClose(EventArgs.Empty);

                        if (ActionUtils.IgnoreExceptions(delegate
                        {
                            this.client.SendCommand(1, "exit");

                            this.client.ReadReady();

                            this.closed = true;
                        }) != null)
                        {
                            ActionUtils.IgnoreExceptions(() => this.client.Disconnect());
                        }

                        OnAfterClose(EventArgs.Empty);
                    }
                }
            }
        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);
            }));
        }
Esempio n. 23
0
        public void Commit()
        {
            if (this.disposed)
            {
                return;
            }

            try
            {
                // ReSharper disable once UseNullPropagation
                if (this.dataAccessObjectDataContext != null)
                {
                    this.dataAccessObjectDataContext.Commit(this, false);
                }

                foreach (var commandsContext in this.commandsContextsBySqlDatabaseContexts.Values)
                {
                    commandsContext.Commit();
                }
            }
            catch (Exception e)
            {
                commandsContextsBySqlDatabaseContexts.Values.ForEach(c => ActionUtils.IgnoreExceptions(c.Rollback));

                throw new DataAccessTransactionAbortedException(e);
            }
            finally
            {
                this.Dispose();
            }
        }
Esempio n. 24
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);
            }));
        }
Esempio n. 25
0
        public void SinglePhaseCommit(SinglePhaseEnlistment singlePhaseEnlistment)
        {
            if (this.disposed)
            {
                return;
            }

            try
            {
                if (this.dataAccessObjectDataContext != null)
                {
                    this.commandsContext = this.GetSqlTransactionalCommandsContext();

                    this.dataAccessObjectDataContext.Commit(this.commandsContext, false);
                    this.commandsContext.Commit();
                }

                singlePhaseEnlistment.Committed();
            }
            catch (Exception e)
            {
                ActionUtils.IgnoreExceptions(() => this.commandsContext.Rollback());

                singlePhaseEnlistment.Aborted(e);
            }
            finally
            {
                this.Dispose();
            }
        }
Esempio n. 26
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("");
            }));
        }
Esempio n. 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);
            }));
        }
        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. 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);
            }));
        }
Esempio n. 30
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);
            }));
        }