Esempio n. 1
0
        public IHttpActionResult GetSiteInfo(string usCode, Guid identifier, string projectId = "", string flowCode = "")
        {
            var storeSTLocation = StoreSTLocation.GetStoreSTLocation(usCode);
            var history         = StoreSTLocationHistory.FirstOrDefault(e => e.RefId == identifier);

            if (history != null)
            {
                Mapper.CreateMap <StoreSTLocationHistory, StoreSTLocation>();
                storeSTLocation = Mapper.Map <StoreSTLocation>(history);
            }
            if (!string.IsNullOrEmpty(projectId) &&
                !string.IsNullOrEmpty(flowCode))
            {
                var wfEntity = BaseWFEntity.GetWorkflowEntity(projectId, BaseWFEntity.GetMainProjectFlowCode(flowCode));

                var designStyle = wfEntity.GetDesignStypleForSiteInfo();
                if (!string.IsNullOrEmpty(designStyle))
                {
                    storeSTLocation.DesignStyle = designStyle;
                }
            }
            storeSTLocation.ProjectIdentifier = identifier;

            return(Ok(storeSTLocation));
        }
Esempio n. 2
0
        public IHttpActionResult EditProject(PostSimpleWorkflowData postData)
        {
            var wfEntity = BaseWFEntity.GetWorkflowEntity(postData.ProjectId, postData.FlowCode);
            var result   = wfEntity.Edit();

            return(Ok(result));
        }
Esempio n. 3
0
 public IHttpActionResult EditMultipleProjects(PostEditProjects postEditProjects)
 {
     if (postEditProjects.EditProjects.Count > 0)
     {
         using (TransactionScope tranScope = new TransactionScope())
         {
             var projectId          = postEditProjects.ProjectId;
             var parentCode         = postEditProjects.EditProjects[0].ParentCode;
             var projects           = ProjectInfo.Search(pi => pi.ProjectId == projectId).ToList();
             var usCode             = projects[0].USCode;
             var store              = StoreBasicInfo.GetStorInfo(usCode);
             var minExecuteSequence = postEditProjects.EditProjects.Min(p => p.ExecuteSequence);
             var maxExecuteSequance = postEditProjects.EditProjects.Max(p => p.ExecuteSequence);
             foreach (TopNavigator nav in postEditProjects.EditProjects)
             {
                 var workflow = BaseWFEntity.GetWorkflowEntity(postEditProjects.ProjectId, nav.Code);
                 workflow.Edit();
             }
             string[] cancelWorkflowCodes = FlowInfo.Search(f => f.ParentCode == parentCode && f.ExecuteSequence <= maxExecuteSequance + 1).Select(f => f.Code).ToArray();
             TaskWork.Cancel(t => cancelWorkflowCodes.Contains(t.TypeCode) && t.RefID == postEditProjects.ProjectId && t.Status != TaskWorkStatus.Finished);
             postEditProjects.EditProjects.Where(n => n.ExecuteSequence == minExecuteSequence).ToList().ForEach(n =>
             {
                 var project            = projects.FirstOrDefault(pi => pi.FlowCode == n.Code);
                 var originator         = Employee.GetSimpleEmployeeByCode(project.CreateUserAccount);
                 var source             = FlowInfo.Get(n.ParentCode);
                 var taskType           = FlowInfo.Get(n.Code);
                 TaskWork task          = new TaskWork();
                 task.Id                = Guid.NewGuid();
                 task.SourceCode        = source.Code;
                 task.SourceNameENUS    = source.NameENUS;
                 task.SourceNameZHCN    = source.NameZHCN;
                 task.Status            = TaskWorkStatus.UnFinish;
                 task.StatusNameZHCN    = "任务";
                 task.StatusNameENUS    = "任务";
                 task.Title             = TaskWork.BuildTitle(postEditProjects.ProjectId, store.NameZHCN, store.NameENUS);
                 task.RefID             = postEditProjects.ProjectId;
                 task.StoreCode         = usCode;
                 task.ReceiverAccount   = originator.Code;
                 task.ReceiverNameENUS  = originator.NameENUS;
                 task.ReceiverNameZHCN  = originator.NameZHCN;
                 task.TypeCode          = taskType.Code;
                 task.TypeNameENUS      = taskType.NameENUS;
                 task.TypeNameZHCN      = taskType.NameZHCN;
                 task.Url               = TaskWork.BuildUrl(n.Code, projectId, "");
                 task.CreateTime        = DateTime.Now;
                 task.CreateUserAccount = ClientCookie.UserCode;
                 task.Sequence          = 0;
                 task.ActivityName      = "Start";
                 task.Add();
             });
             tranScope.Complete();
         }
         return(Ok());
     }
     else
     {
         return(BadRequest("you must select projects to be edited!"));
     }
 }
Esempio n. 4
0
        public IHttpActionResult ChangeProjectTeamMembers(ProjectDto project)
        {
            var wfEntity = BaseWFEntity.GetWorkflowEntity(project.ProjectId, project.FlowCode);

            wfEntity.ChangeProjectTeamMembers(project.ProjectId, project.ProjectTeamMembers);

            return(Ok());
        }
Esempio n. 5
0
        public void FinishTest()
        {
            var taskWork = TaskWork.FirstOrDefault(e => e.Id == new Guid("6bae9906-8608-49a2-8faa-0bbd5eaa43ee"));

            var wfEntity = BaseWFEntity.GetWorkflowEntity("MajorLease15030405", FlowCode.MajorLease_ConsInfo);

            wfEntity.Finish(TaskWorkStatus.K2ProcessApproved, taskWork);
        }
Esempio n. 6
0
        public void EditTest()
        {
            var task =
                JsonConvert.DeserializeObject <TaskWork>(
                    "{'TypeName':'Reimage_Package','SourceName':'Reimage','TaskType':2,'Id':'9372e8a1-d769-4844-a938-5bd153daec5e','Num':9194,'Title':'Reimage14112502 Changle Airport 长乐机场','Url':'/Reimage/Main#/Package/Process/Approval?SN=3401_33&ProcInstID=3401','SourceCode':'Reimage','RefID':'Reimage14112502','Status':100,'ReceiverAccount':'E5009955','CreateTime':'2014-11-25T16:34:24.103','CreateUserAccount':'bpm.service','FinishTime':null,'Sequence':null,'TypeCode':'Reimage_Package','ProcInstID':3401,'DoActionUser':null,'ActionName':null,'K2SN':'3401_33','StoreCode':'1410096','ReceiverNameZHCN':'聂淼','ReceiverNameENUS':'Karuna Nie','SourceNameENUS':'Reimage','SourceNameZHCN':'Reimage','TypeNameZHCN':'Reimage_Package','TypeNameENUS':'Reimage_Package','StatusNameZHCN':'任务','StatusNameENUS':'任务','RefTableId':null,'RefTableName':null,'ActivityName':'Market Manager'}");
            var wfEntity = BaseWFEntity.GetWorkflowEntity("Reimage14112502", "Reimage_Package");

            if (wfEntity != null)
            {
                wfEntity.Finish(TaskWorkStatus.K2ProcessDeclined, task);
            }
        }
Esempio n. 7
0
        public IHttpActionResult ChangePackageHoldingStatus(PackageHoldingDto packageHoldingDto)
        {
            try
            {
                var wfEntity = BaseWFEntity.GetWorkflowEntity(packageHoldingDto.ProjectId, packageHoldingDto.HoldingPackageCode);
                wfEntity.ChangePackageHoldingStatus(packageHoldingDto.Status);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(Ok(packageHoldingDto));
        }
Esempio n. 8
0
        //public void SetPackageHoldingSource()
        //{
        //    var packageHoldingDto = new PackageHoldingDto();
        //    packageHoldingDto.ProjectId = ProjectId;
        //    packageHoldingDto.FlowCode = FlowCode;

        //    if (FlowCode == Constants.FlowCode.Reimage)
        //    {
        //        var wfEntity = BaseWFEntity.GetWorkflowEntity(ProjectId, Constants.FlowCode.Reimage_Package);

        //        if (wfEntity != null)
        //        {
        //            var packageRoleUsers = BaseWFEntity.GetPackageHoldingRoleUsers();
        //            if (packageRoleUsers.Select(e => e.Code).Contains(ClientCookie.UserCode)
        //                && ProjectInfo.Any(e => e.ProjectId == ProjectId
        //                    && e.FlowCode == Constants.FlowCode.Reimage_ConsInfo
        //                    && e.Status == ProjectStatus.Finished)
        //                && ProjectInfo.Any(e => e.ProjectId == ProjectId
        //                    && e.FlowCode == Constants.FlowCode.Reimage_Summary
        //                    && e.Status == ProjectStatus.Finished)
        //                && ProjectInfo.Any(e => e.ProjectId == ProjectId
        //                    && e.FlowCode == Constants.FlowCode.Reimage_Package
        //                    && e.Status == ProjectStatus.UnFinish))
        //            {
        //                packageHoldingDto.HasRight = true;
        //                //packageHoldingDto.HasRight = false;

        //                packageHoldingDto.Status = wfEntity.GetPackageHoldingStatus();

        //            }
        //        }

        //    }

        //    PackageHoldingDto = packageHoldingDto;
        //}

        public void SetPendingRight()
        {
            var marketAssetMgr   = Employee.GetEmployeesByRole(RoleCode.Market_Asset_Mgr);
            var regionalAssetMgr = Employee.GetEmployeesByRole(RoleCode.Regional_Asset_Mgr);

            var packageRoleUsers = BaseWFEntity.GetPackageHoldingRoleUsers();

            if (ProjectUsers.Any(pu => pu.ProjectId == ProjectId &&
                                 pu.UserAccount == ClientCookie.UserCode &&
                                 pu.RoleCode == ProjectUserRoleCode.AssetActor) ||
                packageRoleUsers.Select(e => e.Code).Contains(ClientCookie.UserCode) ||
                marketAssetMgr.Select(e => e.Code).Contains(ClientCookie.UserCode) ||
                regionalAssetMgr.Select(e => e.Code).Contains(ClientCookie.UserCode))
            {
                HasPendingRight = true;
            }
        }
Esempio n. 9
0
        public IHttpActionResult ChangeWorkflowApprovers(ProjectDto project)
        {
            try
            {
                var wfEntity    = BaseWFEntity.GetWorkflowEntity(project.ProjectId, project.FlowCode);
                var newTaskList = wfEntity.ChangeWorkflowApprovers(project.ProjectId, project.ApproveUsers);
                if (newTaskList.Count > 0)
                {
                    SendEmail(newTaskList);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Ok());
        }
Esempio n. 10
0
        public List <SimpleEmployee> GetCreatorList()
        {
            List <SimpleEmployee> listEmp = null;
            var    entity    = BaseWFEntity.GetWorkflowEntity(ProjectId, FlowCode);
            Guid?  entityId  = null;
            string souceCode = "";
            string tableName = "";

            if (entity != null)
            {
                souceCode = entity.WorkflowCode.Split('_')[0];
                entityId  = entity.EntityId;
            }
            using (var context = GetDb())
            {
                listEmp = (from N in context.Notification
                           join E in context.Employee on N.SenderCode equals E.Code
                           where N.ProjectId == ProjectId
                           select new SimpleEmployee()
                {
                    Code = N.SenderCode,
                    NameZHCN = E.NameZHCN,
                    NameENUS = E.NameENUS
                }).Union(
                    from PC in context.ProjectComment
                    where PC.RefTableId == entityId && PC.SourceCode == souceCode
                    select new SimpleEmployee()
                {
                    Code     = PC.UserAccount,
                    NameZHCN = PC.UserNameZHCN,
                    NameENUS = PC.UserNameENUS
                }
                    ).Distinct().ToList();
            }

            return(listEmp);
        }
        private List <ProjectComment> GetProjectComments(NotificationSearchCondition searchCondition, out int totalSize)
        {
            var entity = BaseWFEntity.GetWorkflowEntity(searchCondition.ProjectId, searchCondition.FlowCode);
            var list   = entity == null ? null : entity.GetEntityProjectComment();

            if (list != null && list.Count > 0)
            {
                var nextDay = searchCondition.CreateDate;
                if (searchCondition.CreateDate.HasValue)
                {
                    nextDay = searchCondition.CreateDate.Value.AddDays(1);
                }

                var tmpList =
                    list.Where(
                        e =>
                        (string.IsNullOrEmpty(searchCondition.Title) ||
                         e.Content.Contains(searchCondition.Title)) &&
                        (!searchCondition.CreateDate.HasValue ||
                         (e.CreateTime > searchCondition.CreateDate.Value && e.CreateTime < nextDay))
                        &&
                        (string.IsNullOrEmpty(searchCondition.SenderCode) ||
                         e.CreateUserAccount == searchCondition.SenderCode)).ToList();
                totalSize = tmpList.Count;
                tmpList   =
                    tmpList.Skip(searchCondition.PageSize * (searchCondition.PageIndex - 1))
                    .Take(searchCondition.PageSize)
                    .ToList();
                return(tmpList);
            }
            else
            {
                totalSize = 0;
                return(null);
            }
        }
Esempio n. 12
0
        public IHttpActionResult GetRebuildApprovers(string flowCode, string projectId = "", bool isNeedEntity = false)
        {
            if (string.IsNullOrEmpty(flowCode))
            {
                throw new Exception("flowCode is NULL");
            }

            RebuildInfo rbdInfo = null;

            if (!string.IsNullOrEmpty(projectId))
            {
                rbdInfo = RebuildInfo.Search(e => e.ProjectId.Equals(projectId)).FirstOrDefault();
            }
            if (rbdInfo == null)
            {
                throw new Exception("Could not find the Rebuild Info, please check it!");
            }
            var          dicUsers     = new Dictionary <string, List <SimpleEmployee> >();
            BaseWFEntity returnEntity = null;

            switch (flowCode)
            {
            case FlowCode.Rebuild_LegalReview:
                dicUsers.Add("Legals", new List <SimpleEmployee>()
                {
                    new SimpleEmployee()
                    {
                        Code     = rbdInfo.LegalAccount,
                        NameENUS = rbdInfo.LegalNameENUS,
                        NameZHCN = rbdInfo.LegalNameZHCN
                    }
                });
                if (isNeedEntity)
                {
                    var entity = RebuildLegalReview.FirstOrDefault((e => e.ProjectId.Equals(projectId) && !e.IsHistory));
                    if (entity != null)
                    {
                        RebuildLegalReview.PopulateAppUsers(entity);
                        returnEntity = entity;
                    }
                }
                break;

            case FlowCode.Rebuild_FinanceAnalysis:
                dicUsers.Add("FMs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Finance_Manager));
                if (isNeedEntity)
                {
                    var entity = RebuildFinancAnalysis.FirstOrDefault((e => e.ProjectId.Equals(projectId) && !e.IsHistory));
                    if (entity != null)
                    {
                        RebuildFinancAnalysis.PopulateAppUsers(entity);
                        returnEntity = entity;
                    }
                }
                break;

            case FlowCode.Rebuild_ConsInfo:
                dicUsers.Add("ConstructionManagers", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Cons_Mgr));
                dicUsers.Add("MCCLConsManagers", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.MCCL_Cons_Manager));
                if (isNeedEntity)
                {
                    var entity = RebuildConsInfo.FirstOrDefault((e => e.ProjectId.Equals(projectId) && !e.IsHistory));
                    if (entity != null)
                    {
                        RebuildConsInfo.PopulateAppUsers(entity);
                        returnEntity = entity;
                    }
                }
                break;

            case FlowCode.Rebuild_Package:
                dicUsers.Add("MarketMgrs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Market_Asset_Mgr));
                dicUsers.Add("RegionalMgrs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Regional_Asset_Mgr));
                dicUsers.Add("MDDs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Market_DD));
                dicUsers.Add("GMs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.GM));
                dicUsers.Add("FCs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Finance_Controller));
                dicUsers.Add("RDDs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Regional_DD));
                dicUsers.Add("VPGMs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.VPGM));
                dicUsers.Add("CDOs", Employee.GetEmployeesByRole(RoleCode.CDO));
                dicUsers.Add("CFOs", Employee.GetEmployeesByRole(RoleCode.CFO));
                dicUsers.Add("MngDirectors", Employee.GetEmployeesByRole(RoleCode.MD));
                if (isNeedEntity)
                {
                    var entity = RebuildPackage.FirstOrDefault((e => e.ProjectId.Equals(projectId) && !e.IsHistory));
                    if (entity != null)
                    {
                        RebuildPackage.PopulateAppUsers(entity);
                        returnEntity = entity;
                    }
                }
                break;

            case FlowCode.Rebuild_ConsInvtChecking:
                //dicUsers.Add("FMs", new List<SimpleEmployee>()
                //{
                //    new SimpleEmployee()
                //    {
                //        Code = rbdInfo.FinanceAccount,
                //        NameENUS = rbdInfo.FinanceNameENUS,
                //        NameZHCN = rbdInfo.FinanceNameZHCN
                //    }
                //});
                dicUsers.Add("FMs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Finance_Manager));
                dicUsers.Add("ConstructionManagers", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Cons_Mgr));
                dicUsers.Add("FinanceControllers", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Finance_Controller));
                dicUsers.Add("VPGMs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.VPGM));
                if (isNeedEntity)
                {
                    var entity = RebuildConsInvtChecking.FirstOrDefault((e => e.ProjectId.Equals(projectId) && !e.IsHistory));
                    if (entity != null)
                    {
                        RebuildConsInvtChecking.PopulateAppUsers(entity);
                        returnEntity = entity;
                    }
                }
                break;

            case FlowCode.Rebuild_GBMemo:
                dicUsers.Add("ConstructionManagers", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Cons_Mgr));
                if (isNeedEntity)
                {
                    var entity = GBMemo.FirstOrDefault((e => e.ProjectId.Equals(projectId) && !e.IsHistory));
                    if (entity != null)
                    {
                        GBMemo.PopulateAppUsers(entity);
                        returnEntity = entity;
                    }
                }
                break;
            }
            dicUsers.Add("MCCLAssetMgrs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.MCCL_Asset_Mgr));
            dicUsers.Add("MCCLAssetDtrs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.MCCL_Asset_Director));


            return(Ok(new
            {
                dicUsers,
                returnEntity,
                rbdInfo
            }));
        }
Esempio n. 13
0
        public IHttpActionResult RecallProject(PostSimpleWorkflowData postData)
        {
            ApiProxy.SetCookies(Request.RequestUri.Host, HttpContext.Current.Request.Cookies);
            var rootPath = string.Concat(HttpContext.Current.Request.Url.Scheme, @"://", HttpContext.Current.Request.Url.Authority, HttpContext.Current.Request.ApplicationPath);

            switch (postData.FlowCode)
            {
                #region Closure
            case FlowCode.Closure_WOCheckList:
            {
                var entity = ClosureWOCheckList.Get(postData.ProjectId);
                entity.Comments = postData.ProjectComment;
                var postDataBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(entity));
                ApiProxy.Call(rootPath + "api/ClosureWOCheckList/Recall", "POST", null, postDataBytes);
            }
            break;

            case FlowCode.Closure_LegalReview:
            {
                var entity = ClosureLegalReview.Get(postData.ProjectId);
                entity.Comments = postData.ProjectComment;
                var postDataBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(entity));
                ApiProxy.Call(rootPath + "api/LegalReview/Recall", "POST", null, postDataBytes);
            }
            break;

            case FlowCode.Closure_ClosurePackage:
            {
                var entity = ClosurePackage.Get(postData.ProjectId);
                entity.Comments = postData.ProjectComment;
                var postDataBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(entity));
                ApiProxy.Call(rootPath + "api/ClosurePackage/Recall", "POST", null, postDataBytes);
            }
            break;

            case FlowCode.Closure_ConsInvtChecking:
            {
                var entity = ClosureConsInvtChecking.Get(postData.ProjectId);
                entity.Comments = postData.ProjectComment;
                var postDataBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(entity));
                ApiProxy.Call(rootPath + "api/ClosureConsInvtChecking/Recall", "POST", null, postDataBytes);
            }
            break;

            case FlowCode.Closure_ClosureTool:
            {
                var entity = ClosureTool.Get(postData.ProjectId);
                entity.Comments = postData.ProjectComment;
                var postDataBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(entity));
                ApiProxy.Call(rootPath + "api/closureTool/Recall", "POST", null, postDataBytes);
            }
            break;

                #endregion Closure
            default:
                var wfEntity = BaseWFEntity.GetWorkflowEntity(postData.ProjectId, postData.FlowCode);
                wfEntity.Recall(postData.ProjectComment);
                break;
            }
            return(Ok());
        }
Esempio n. 14
0
 public void GetWorkflowEntityTest()
 {
     var wfEntity = BaseWFEntity.GetWorkflowEntity("MajorLease15032702", FlowCode.MajorLease_ConsInfo);
 }
Esempio n. 15
0
        public static List <NotificationDTO> GetNotificationList(NotificationSearchCondition condition, out int totalSize)
        {
            var context = PrepareDb();

            if (condition == null)
            {
                condition = new NotificationSearchCondition();
            }
            var    entity    = BaseWFEntity.GetWorkflowEntity(condition.ProjectId, condition.FlowCode);
            Guid?  entityId  = null;
            string souceCode = "";
            string tableName = "";

            if (entity != null)
            {
                souceCode = entity.WorkflowCode.Split('_')[0];
                entityId  = entity.EntityId;
            }

            int pageIndex = condition.PageIndex;
            int pageSize  = condition.PageSize;

            totalSize = 0;
            var data = (from N in context.Notification
                        join M in context.NotificationMessage
                        on N.ContentId equals M.Id
                        join E in context.Employee
                        on N.SenderCode equals E.Code
                        join R in context.Employee
                        on N.ReceiverCode equals R.Code
                        into TEMPEM
                        from tem in TEMPEM.DefaultIfEmpty()
                        where (string.IsNullOrEmpty(condition.Title) || M.MessageContent.Contains(condition.Title)) &&
                        N.ProjectId == condition.ProjectId &&
                        N.FlowCode == condition.FlowCode &&
                        (string.IsNullOrEmpty(condition.SenderCode) || N.SenderCode == condition.SenderCode)
                        orderby N.CreateTime descending
                        select new NotificationDTO
            {
                Id = N.Id,
                RefId = N.RefId,
                ProjectId = N.ProjectId,
                SenderCode = N.SenderCode,
                ReceiverCode = N.ReceiverCode,
                CreateTime = N.CreateTime,
                LastUpdateTime = N.LastUpdateTime,
                CreateUserAccount = N.CreateUserAccount,
                IsSendEmail = N.IsSendEmail,
                HasRead = N.HasRead,
                FlowCode = N.FlowCode,
                PositionENUS = E.PositionENUS,
                PositionZHCN = E.PositionZHCN,
                SenderENUS = E.NameENUS,
                SenderZHCN = E.NameZHCN,
                ReceiverENUS = tem.NameENUS,
                ReceiverZHCN = tem.NameZHCN,
                Message = M.MessageContent
            }
                        ).Union(
                from PC in context.ProjectComment
                where PC.Status == ProjectCommentStatus.Submit &&
                entityId != null &&
                PC.RefTableId == entityId &&
                PC.SourceCode == souceCode &&
                (string.IsNullOrEmpty(condition.Title) || PC.Content.Contains(condition.Title)) &&
                (string.IsNullOrEmpty(condition.SenderCode) || PC.CreateUserAccount == condition.SenderCode)
                orderby PC.CreateTime descending
                select new NotificationDTO
            {
                Id                = PC.Num,
                RefId             = PC.RefTableId,
                ProjectId         = condition.ProjectId,
                SenderCode        = PC.CreateUserAccount,
                ReceiverCode      = "",
                CreateTime        = PC.CreateTime,
                LastUpdateTime    = null,
                CreateUserAccount = PC.CreateUserAccount,
                IsSendEmail       = false,
                HasRead           = true,
                FlowCode          = condition.FlowCode,
                PositionENUS      = "",
                PositionZHCN      = "",
                SenderENUS        = string.IsNullOrEmpty(PC.CreateUserNameENUS)?PC.UserNameENUS:PC.CreateUserNameENUS,
                SenderZHCN        = string.IsNullOrEmpty(PC.CreateUserNameZHCN) ? PC.UserNameZHCN : PC.CreateUserNameZHCN,
                ReceiverENUS      = "",
                ReceiverZHCN      = "",
                Message           = PC.Content
            }
                );

            IQueryable <NotificationDTO> filterData = null;

            if (condition.CreateDate.HasValue && condition.EndDate.HasValue)
            {
                var endDate = condition.EndDate.Value.AddDays(1);
                filterData =
                    data.Where(
                        e => e.CreateTime >= condition.CreateDate.Value && e.CreateTime <= endDate);
            }
            else
            {
                filterData = data;
            }

            totalSize = filterData.Count();
            var result = filterData
                         .OrderByDescending(e => e.CreateTime)
                         .Skip(pageSize * (pageIndex - 1))
                         .Take(pageSize)
                         .ToList()
                         .Select(e => new NotificationDTO()
            {
                Id                = e.Id,
                RefId             = e.RefId,
                ProjectId         = e.ProjectId,
                SenderCode        = e.SenderCode,
                ReceiverCode      = e.ReceiverCode,
                CreateTime        = e.CreateTime,
                LastUpdateTime    = e.LastUpdateTime,
                CreateUserAccount = e.CreateUserAccount,
                IsSendEmail       = e.IsSendEmail,
                HasRead           = e.HasRead,
                FlowCode          = e.FlowCode,
                PositionENUS      = e.PositionENUS,
                PositionZHCN      = e.PositionZHCN,
                SenderZHCN        = e.SenderZHCN,
                SenderENUS        = e.SenderENUS,
                ReceiverENUS      = e.ReceiverENUS,
                ReceiverZHCN      = e.ReceiverZHCN,
                Message           = e.Message
            }).ToList();

            return(result);
        }
Esempio n. 16
0
        public IHttpActionResult GetFlowInfo(string projectId, string flowCode)
        {
            var wfEntity = BaseWFEntity.GetWorkflowEntity(projectId, flowCode);

            return(Ok(wfEntity));
        }
Esempio n. 17
0
 public IHttpActionResult GetPackageHoldingRoleUsers()
 {
     return(Ok(BaseWFEntity.GetPackageHoldingRoleUsers()));
 }
Esempio n. 18
0
        public IHttpActionResult GetMajorLeaseApprovers(string flowCode, string projectId = "")
        {
            if (string.IsNullOrEmpty(flowCode))
            {
                throw new Exception("flowCode is NULL");
            }

            MajorLeaseInfo majorLeaseInfo = null;

            if (!string.IsNullOrEmpty(projectId))
            {
                majorLeaseInfo = MajorLeaseInfo.Search(e => e.ProjectId.Equals(projectId)).FirstOrDefault();
            }
            if (majorLeaseInfo == null)
            {
                throw new Exception("Could not find the Major Lease Info, please check it!");
            }

            var wfEntity  = BaseWFEntity.GetWorkflowEntity(projectId, flowCode);
            var approvers = wfEntity.GetApproveDialogUser();

            var dicUsers = new Dictionary <string, List <SimpleEmployee> >();

            switch (flowCode)
            {
            case FlowCode.MajorLease_LegalReview:

                dicUsers.Add("Legals", new List <SimpleEmployee>()
                {
                    new SimpleEmployee()
                    {
                        Code     = majorLeaseInfo.LegalAccount,
                        NameENUS = majorLeaseInfo.LegalNameENUS,
                        NameZHCN = majorLeaseInfo.LegalNameZHCN
                    }
                });
                break;

            case FlowCode.MajorLease_FinanceAnalysis:
                dicUsers.Add("FMs", Employee.GetStoreEmployeesByRole(majorLeaseInfo.USCode, RoleCode.Finance_Manager));
                break;

            case FlowCode.MajorLease_ConsInfo:
                dicUsers.Add("ConstructionManagers", Employee.GetStoreEmployeesByRole(majorLeaseInfo.USCode, RoleCode.Cons_Mgr));
                dicUsers.Add("MCCLConsManagers", Employee.GetStoreEmployeesByRole(majorLeaseInfo.USCode, RoleCode.MCCL_Cons_Manager));
                break;

            case FlowCode.MajorLease_Package:
                dicUsers.Add("MarketMgrs", Employee.GetStoreEmployeesByRole(majorLeaseInfo.USCode, RoleCode.Market_Asset_Mgr));
                dicUsers.Add("RegionalMgrs", Employee.GetStoreEmployeesByRole(majorLeaseInfo.USCode, RoleCode.Regional_Asset_Mgr));
                dicUsers.Add("DDs", Employee.GetStoreEmployeesByRole(majorLeaseInfo.USCode, RoleCode.Market_DD));
                dicUsers.Add("GMs", Employee.GetStoreEmployeesByRole(majorLeaseInfo.USCode, RoleCode.GM));
                dicUsers.Add("FCs", Employee.GetStoreEmployeesByRole(majorLeaseInfo.USCode, RoleCode.Finance_Controller));
                dicUsers.Add("RDDs", Employee.GetStoreEmployeesByRole(majorLeaseInfo.USCode, RoleCode.Regional_DD));
                dicUsers.Add("VPGMs", Employee.GetStoreEmployeesByRole(majorLeaseInfo.USCode, RoleCode.VPGM));
                dicUsers.Add("CDOs", Employee.GetEmployeesByRole(RoleCode.CDO));
                dicUsers.Add("CFOs", Employee.GetEmployeesByRole(RoleCode.CFO));
                dicUsers.Add("ManagingDirectors", Employee.GetEmployeesByRole(RoleCode.MD));
                break;

            case FlowCode.MajorLease_ConsInvtChecking:
                //dicUsers.Add("FMs", new List<SimpleEmployee>()
                //{
                //    new SimpleEmployee()
                //    {
                //        Code = majorLeaseInfo.FinanceAccount,
                //        NameENUS = majorLeaseInfo.FinanceNameENUS,
                //        NameZHCN = majorLeaseInfo.FinanceNameZHCN
                //    }
                //});
                dicUsers.Add("FMs", Employee.GetStoreEmployeesByRole(majorLeaseInfo.USCode, RoleCode.Finance_Manager));
                dicUsers.Add("ConstructionManagers", Employee.GetStoreEmployeesByRole(majorLeaseInfo.USCode, RoleCode.Cons_Mgr));
                dicUsers.Add("FinanceControllers", Employee.GetStoreEmployeesByRole(majorLeaseInfo.USCode, RoleCode.Finance_Controller));
                dicUsers.Add("VPGMs", Employee.GetStoreEmployeesByRole(majorLeaseInfo.USCode, RoleCode.VPGM));
                break;

            case FlowCode.MajorLease_GBMemo:
                dicUsers.Add("ConstructionManagers", Employee.GetStoreEmployeesByRole(majorLeaseInfo.USCode, RoleCode.Cons_Mgr));
                break;
            }
            dicUsers.Add("MCCLAssetMgrs", Employee.GetStoreEmployeesByRole(majorLeaseInfo.USCode, RoleCode.MCCL_Asset_Mgr));
            dicUsers.Add("MCCLAssetDtrs", Employee.GetStoreEmployeesByRole(majorLeaseInfo.USCode, RoleCode.MCCL_Asset_Director));
            return(Ok(new { dicUsers, approvers }));
        }
Esempio n. 19
0
        public override void Input(ExcelWorksheet worksheet, ExcelInputDTO inputInfo)
        {
            var projectInfo = ProjectInfo.FirstOrDefault(e => e.ProjectId == inputInfo.ProjectId);

            if (projectInfo == null)
            {
                throw new Exception("Cannot find the project info!");
            }
            var store = StoreBasicInfo.Search(e => e.StoreCode == projectInfo.USCode).FirstOrDefault();

            if (store == null)
            {
                throw new Exception("Cannot find Store info!");
            }

            var reimageSummary = BaseWFEntity.GetWorkflowEntity(inputInfo.ProjectId, FlowCode.Reimage_Summary) as ReimageSummary;

            if (reimageSummary == null)
            {
                throw new Exception("Cannot find Reimage Summary Info!");
            }
            var storeSTLocation = StoreSTLocation.GetStoreSTLocation(projectInfo.USCode);
            var storeLeaseInfo  = new StoreProfitabilityAndLeaseInfo();
            var reimageConsInfo = ReimageConsInfo.GetConsInfo(inputInfo.ProjectId);
            var reinvestment    = ReinvestmentBasicInfo.FirstOrDefault(e => e.ConsInfoID == reimageConsInfo.Id);

            if (reimageSummary != null)
            {
                storeLeaseInfo =
                    StoreProfitabilityAndLeaseInfo.FirstOrDefault(e => e.RefId == reimageSummary.Id);
                if (storeLeaseInfo != null)
                {
                    if (storeLeaseInfo.LastRemodelDate.HasValue && storeLeaseInfo.LastRemodelDate.Value.ToString("yyyy-MM-dd") != "1900-01-01")
                    {
                        worksheet.Cells["B43"].Value = storeLeaseInfo.LastRemodelDate;
                    }
                    worksheet.Cells["B44"].Value = storeLeaseInfo.RemainingLeaseYears;

                    worksheet.Cells["B46"].Value = storeLeaseInfo.TTMSOIPercent / 100;
                    worksheet.Cells["B47"].Value = storeLeaseInfo.AsOf;
                    worksheet.Cells["B48"].Value = reimageSummary.OperationRequirements;
                    var financial = FinancialPreanalysis.FirstOrDefault(e => e.RefId == reimageSummary.Id);
                    worksheet.Cells["B49"].Value = TryParseDecimal(financial.TotalSalesInc);
                    worksheet.Cells["B45"].Value = financial.TTMSales;
                    worksheet.Cells["B50"].Value = TryParseDecimal(financial.StoreCM) * 100 + "%";
                    worksheet.Cells["B51"].Value = financial.CurrentPriceTier;
                    worksheet.Cells["B52"].Value = string.IsNullOrEmpty(financial.SPTAR) ? 0 : financial.SPTAR.As <decimal>();
                    worksheet.Cells["B53"].Value = financial.PriceTierafterReimage;
                }
                //worksheet.Cells["E4"].Value = financial.MarginInc;
            }
            else
            {
                var reimageInfo       = ReimageInfo.FirstOrDefault(e => e.ProjectId == inputInfo.ProjectId);
                var storeBasicInfo    = StoreBasicInfo.FirstOrDefault(e => e.StoreCode == reimageInfo.USCode);
                var storeContractInfo = StoreContractInfo.FirstOrDefault(e => e.StoreCode == reimageInfo.USCode);
                int Year = 0;
                if (storeContractInfo != null)
                {
                    if (storeContractInfo.EndDate != null)
                    {
                        DateTime dtNow = DateTime.Now;
                        Year = int.Parse(storeContractInfo.EndDate.ToString().Split('/')[2].Substring(0, 4)) - dtNow.Year;
                    }
                }

                DateTime?dt = storeBasicInfo.ReImageDate;
                if (dt != null)
                {
                    if (dt.ToString().Substring(0, 8) == "1/1/1900")
                    {
                        dt = null;
                    }
                }
                worksheet.Cells["B43"].Value = dt;
                worksheet.Cells["B44"].Value = Year;
                //storeLeaseInfo.LastRemodelDate = dt;
                //storeLeaseInfo.RemainingLeaseYears = Year;
            }
            ReinvestmentCost cost = ReinvestmentCost.FirstOrDefault(e => e.ConsInfoID == reimageConsInfo.Id);

            worksheet.Cells["B2"].Value = store.Region;
            worksheet.Cells["B3"].Value = store.StoreCode;
            if (reinvestment != null)
            {
                worksheet.Cells["B8"].Value  = TryParseDecimal(reinvestment.RightSizingSeatNo);
                worksheet.Cells["B11"].Value = TryParseDecimal(reinvestment.EstimatedSeatNo);
                worksheet.Cells["B41"].Value = reinvestment.GBDate;
                worksheet.Cells["B42"].Value = reinvestment.ConsCompletionDate;
            }
            if (cost != null)
            {
                worksheet.Cells["B13"].Value = TryParseDecimal(cost.DesignFee);
                worksheet.Cells["B14"].Value = TryParseDecimal(cost.PublicBudget);
                worksheet.Cells["B15"].Value = TryParseDecimal(cost.BuildingFacade);
                worksheet.Cells["B16"].Value = TryParseDecimal(cost.SiteBudget);
                worksheet.Cells["B17"].Value = TryParseDecimal(cost.BuildingWork);
                worksheet.Cells["B18"].Value = TryParseDecimal(cost.PlumbingSystem);
                worksheet.Cells["B19"].Value = TryParseDecimal(cost.ElectricalSystem);
                worksheet.Cells["B20"].Value = TryParseDecimal(cost.HVACDuctSystem);
                worksheet.Cells["B21"].Value = TryParseDecimal(cost.Signage);
                worksheet.Cells["B22"].Value = TryParseDecimal(cost.Seating);
                worksheet.Cells["B23"].Value = TryParseDecimal(cost.Decor);
                worksheet.Cells["B24"].Value = TryParseDecimal(cost.Kiosk);
                worksheet.Cells["B25"].Value = TryParseDecimal(cost.McCafe);
                worksheet.Cells["B26"].Value = TryParseDecimal(cost.MDS);
                worksheet.Cells["B27"].Value = TryParseDecimal(cost.Playland);
                worksheet.Cells["B28"].Value = TryParseDecimal(cost.KitchenCapacityUpgrade);
                worksheet.Cells["B29"].Value = TryParseDecimal(cost.BuildingWorks);
                worksheet.Cells["B30"].Value = TryParseDecimal(cost.KitchenEquipment);
                worksheet.Cells["B31"].Value = TryParseDecimal(cost.HVAC);
                worksheet.Cells["B32"].Value = TryParseDecimal(cost.Plumbing);
                worksheet.Cells["B33"].Value = TryParseDecimal(cost.ElectricDistribution);
                worksheet.Cells["B34"].Value = TryParseDecimal(cost.Structure);
                worksheet.Cells["B35"].Value = TryParseDecimal(cost.Others);
                worksheet.Cells["B36"].Value = TryParseDecimal(cost.LHIPMAct);
                worksheet.Cells["B37"].Value = TryParseDecimal(cost.SignagePMAct);
                worksheet.Cells["B38"].Value = TryParseDecimal(cost.EquipmentPMAct);
                worksheet.Cells["B39"].Value = TryParseDecimal(cost.SeatingPackagePMAct);
                worksheet.Cells["B40"].Value = TryParseDecimal(cost.DecorPMAct);
            }
            worksheet.Cells["B5"].Value = storeSTLocation.TotalArea.As <decimal>();
            worksheet.Cells["B6"].Value = store.ProvinceZHCN;
            worksheet.Cells["B7"].Value = store.NameZHCN;

            worksheet.Cells["B4"].Value  = TryParseDecimal(storeSTLocation.TotalSeatsNo);
            worksheet.Cells["B9"].Value  = TryParseDecimal(storeSTLocation.KitchenArea);
            worksheet.Cells["B10"].Value = store.CityZHCN;

            if (!string.IsNullOrEmpty(storeSTLocation.DesignStyle))
            {
                var dict = Dictionary.FirstOrDefault(i => i.Code == storeSTLocation.DesignStyle);
                if (dict != null)
                {
                    worksheet.Cells["B12"].Value = dict.NameZHCN;
                }
                else
                {
                    worksheet.Cells["B12"].Value = storeSTLocation.DesignStyle;
                }
            }
            //worksheet.Cells["B24"].Value = reimageSummary.ReinvestmentBasicInfo.NewKiosk;
            //worksheet.Cells["B25"].Value = reimageSummary.ReinvestmentBasicInfo.NewMcCafe;
            //worksheet.Cells["B26"].Value = reimageSummary.ReinvestmentBasicInfo.NewMDS;
            //worksheet.Cells["B41"].Value = reimageSummary.ReinvestmentBasicInfo.GBDate;
            //worksheet.Cells["B42"].Value = reimageSummary.ReinvestmentBasicInfo.ConsCompletionDate;


            worksheet.Cells["B10"].Value = store.CityZHCN;
            //worksheet.Cells["B11"].Value = inputInfo.StoreType;
            //worksheet.Cells["B12"].Value = inputInfo.StoreType;
            //worksheet.Cells["B13"].Value = inputInfo.StoreType;
            //worksheet.Cells["B14"].Value = inputInfo.StoreType;
            //worksheet.Cells["B15"].Value = inputInfo.StoreType;
            //worksheet.Cells["B16"].Value = inputInfo.StoreType;
            //worksheet.Cells["B17"].Value = inputInfo.StoreType;
            //worksheet.Cells["B18"].Value = inputInfo.StoreType;
            //worksheet.Cells["B19"].Value = inputInfo.StoreType;
            //worksheet.Cells["B20"].Value = inputInfo.StoreType;
            //worksheet.Cells["B21"].Value = inputInfo.StoreType;
            //worksheet.Cells["B22"].Value = inputInfo.StoreType;
            //worksheet.Cells["B23"].Value = inputInfo.StoreType;

            //worksheet.Cells["B27"].Value = inputInfo.StoreType;
            //worksheet.Cells["B28"].Value = inputInfo.StoreType;
            //worksheet.Cells["B29"].Value = inputInfo.StoreType;
            //worksheet.Cells["B30"].Value = inputInfo.StoreType;
            //worksheet.Cells["B31"].Value = inputInfo.StoreType;
            //worksheet.Cells["B32"].Value = inputInfo.StoreType;
            //worksheet.Cells["B33"].Value = inputInfo.StoreType;
            //worksheet.Cells["B34"].Value = inputInfo.StoreType;
            //worksheet.Cells["B35"].Value = inputInfo.StoreType;
            //worksheet.Cells["B36"].Value = inputInfo.StoreType;
            //worksheet.Cells["B37"].Value = inputInfo.StoreType;
            //worksheet.Cells["B38"].Value = inputInfo.StoreType;
            //worksheet.Cells["B39"].Value = inputInfo.StoreType;
            //worksheet.Cells["B40"].Value = inputInfo.StoreType;

            //if (reimageSummary.StoreProfitabilityAndLeaseInfo != null)
            //{
            //    worksheet.Cells["B43"].Value = reimageSummary.StoreProfitabilityAndLeaseInfo.LastRemodelDate;
            //    worksheet.Cells["B44"].Value = reimageSummary.StoreProfitabilityAndLeaseInfo.RemainingLeaseYears;
            //    worksheet.Cells["B45"].Value = reimageSummary.StoreProfitabilityAndLeaseInfo.TTMSales;
            //    worksheet.Cells["B46"].Value = reimageSummary.StoreProfitabilityAndLeaseInfo.TTMSOIPercent;
            //    worksheet.Cells["B47"].Value = reimageSummary.StoreProfitabilityAndLeaseInfo.AsOf;
            //}

            ////worksheet.Cells["B48"].Value = reimageSummary.OperationRequirements;
            //if (reimageSummary.FinancialPreanalysis != null)
            //{
            //    worksheet.Cells["B49"].Value = reimageSummary.FinancialPreanalysis.TotalSalesInc;
            //    worksheet.Cells["B50"].Value = reimageSummary.FinancialPreanalysis.StoreCM;
            //    worksheet.Cells["B51"].Value = reimageSummary.FinancialPreanalysis.CurrentPriceTier;
            //    worksheet.Cells["B52"].Value = reimageSummary.FinancialPreanalysis.ISDWIP;
            //    worksheet.Cells["B53"].Value = reimageSummary.FinancialPreanalysis.SPTAR;

            //}
        }