Пример #1
0
        public MemberUserView(Context context, MemberUser memberUser, MemberUserGroup memberUserGroup)
        {
            if (memberUser == null)
            {
                return;
            }
            ID        = memberUser.ID;
            LoginName = memberUser.LoginName ?? "";
            Name      = memberUser.Name != null?memberUser.Name.ToString(context.CurrentLanguage.Code) : "";

            Email            = memberUser.EMailAddress ?? "";
            MobileNumber     = memberUser.MobilePhoneNumber ?? "";
            CreatedBy        = memberUser.CreateAction != null ? memberUser.CreateAction.ByUser.LoginName : "";
            CreatedTimeStamp = memberUser.CreateAction != null
                                        ? memberUser.ApproveAction.Timestamp.ToString(
                Service.DateTimeFormat)
                                        : "";

            ApprovedBy        = memberUser.ApproveAction != null ? memberUser.ApproveAction.ByUser.LoginName : "";
            ApprovedTimeStamp = memberUser.ApproveAction != null
                                         ? memberUser.ApproveAction.Timestamp.ToString(
                Service.DateTimeFormat)
                                         : "";

            Status = UserService.GetUserStatus(memberUser, context.CurrentLanguage.Code);

            User            = memberUser;
            MemberUserGroup = memberUserGroup;
        }
        public static IList <ServiceWorkflow> GetServiceWorkflows(MemberUserGroup memberUserGroup)
        {
            IList <ServiceWorkflow> fwfs = new List <ServiceWorkflow>();

            foreach (MemberFunction mf in memberUserGroup.Member.EffectiveMemberFunctions)
            {
                foreach (ServiceWorkflow fwf in mf.Workflows)
                {
                    if (memberUserGroup.Role == UserGroupRole.Creator)
                    {
                        if (memberUserGroup.ID == (fwf.CreatorGroup == null ? 0 : fwf.CreatorGroup.ID))//Maker จะเกิดกรณีที่ MaintenanceWorkflow ไม่มี CreatroGroup เพราะเป็น Flow ของ ApprovalGroup
                        {
                            fwfs.Add(fwf);
                        }
                    }
                    else if (memberUserGroup.Role == UserGroupRole.Approver)//Approver
                    {
                        foreach (ApprovalBracket apBracket in fwf.ApprovalBrackets)
                        {
                            //foreach (ApprovalChain approvalChain in apBracket.DisjunctiveApprovalChains)
                            //{
                            foreach (ApprovalTier at in apBracket.ApprovalTiers)
                            {
                                if (memberUserGroup.ID == (at.ApproverGroup == null ? 0 : at.ApproverGroup.ID))//edit by kittikun
                                {
                                    fwfs.Add(fwf);
                                }
                            }
                            //}
                        }
                    }
                }
            }
            return(fwfs);
        }
 public static MaintenanceWorkflow GetInstance(MemberFunction memberfunction, MemberUserGroup memberUserGroup)
 {
     return(new MaintenanceWorkflow
     {
         MemberFunction = memberfunction,
         CreatorGroup = memberUserGroup,
     });
 }
Пример #4
0
 public static ApprovalTier GetInstance(MemberUserGroup approverGroup, FunctionWorkflow Workflow)
 {
     return(new ApprovalTier
     {
         ApproverGroup = approverGroup,
         Workflow = Workflow,
     });
 }
Пример #5
0
 public static UserGroupUser GetInstance(BizPortalSessionContext context, MemberUserGroup memberUserGroup, User user)
 {
     return(new UserGroupUser
     {
         CreateAction = new UserAction(context.User),
         User = user,
         Group = memberUserGroup,
     });
 }
Пример #6
0
        public static bool GetUsersEffective(BizPortalSessionContext context, MemberUserGroup memberUserGroup)
        {
            DateTime now = DateTime.Now;

            return(context.PersistenceSession
                   .QueryOver <UserGroupUser>()
                   .Where(ugu => ugu.Group.ID == memberUserGroup.ID &&
                          ugu.EffectivePeriod.From <= now &&
                          now <= ugu.EffectivePeriod.To).RowCount() > 0);
        }
        public static IList <MemberFunction> GetMemberFunctionOfFinace(MemberUserGroup memberUserGroup)
        {
            IList <MemberFunction> mfs = new List <MemberFunction>();

            foreach (MemberFunction mf in memberUserGroup.Member.EffectiveMemberFunctions)
            {
                if (mf.Function.RequireAccountSelection)
                {
                    mfs.Add(mf);
                }
            }
            return(mfs);
        }
        public static IList <MaintenanceWorkflow> GetFunctionWorkFlowEffectives(MemberUserGroup memberUserGroup)
        {
            IList <MaintenanceWorkflow> fwfs = new List <MaintenanceWorkflow>();

            foreach (MemberFunction mf in memberUserGroup.Member.EffectiveMemberFunctions)
            {
                if (mf.FunctionID != ClientMakerFunctionID.FundsTransferOneToMany)//Add by Itsada

                {
                    foreach (MaintenanceWorkflow fwf in mf.Workflows)
                    {
                        if (memberUserGroup.Role == UserGroupRole.Creator)
                        {
                            if (memberUserGroup.ID == (fwf.CreatorGroup == null ? 0 : fwf.CreatorGroup.ID))//Maker จะเกิดกรณีที่ MaintenanceWorkflow ไม่มี CreatroGroup เพราะเป็น Flow ของ ApprovalGroup
                            {
                                if (fwf.IsEffective)
                                {
                                    fwfs.Add(fwf);
                                }
                            }
                        }
                        else if (memberUserGroup.Role == UserGroupRole.Approver)//Approver
                        {
                            foreach (ApprovalTier at in fwf.ApprovalTiers)
                            {
                                if (memberUserGroup.ID == (at.ApproverGroup == null ? 0 : at.ApproverGroup.ID))//edit by kittikun
                                {
                                    if (fwf.IsEffective)
                                    {
                                        fwfs.Add(fwf);
                                    }
                                }
                            }
                        }
                        else if (memberUserGroup.Role == UserGroupRole.Admin)
                        {
                            if (memberUserGroup.ID == (fwf.CreatorGroup == null ? 0 : fwf.CreatorGroup.ID))//Maker จะเกิดกรณีที่ MaintenanceWorkflow ไม่มี CreatroGroup เพราะเป็น Flow ของ ApprovalGroup
                            {
                                if (fwf.IsEffective)
                                {
                                    fwfs.Add(fwf);
                                }
                            }
                        }
                    }
                }
            }
            return(fwfs);
        }
        public static MemberUserGroup GetInstance(Member member, UserGroupRole role, string title, BizPortalSessionContext context = null)
        {
            MemberUserGroup mug = new MemberUserGroup
            {
                Member = member,
                Role   = role,
                Title  = title,
            };

            if (context != null)
            {
                mug.CreateAction = new UserAction(context.User);
            }

            return(mug);
        }
        public static MaintenanceWorkflow GetInstance(MemberFunction memberfunction, MemberUserGroup memberUserGroup, UserGroupRole role)
        {
            MaintenanceWorkflow functionWorkFlow = null;

            switch (role)
            {
            case UserGroupRole.Admin:
                functionWorkFlow = new MaintenanceWorkflow
                {
                    MemberFunction = memberfunction,
                    CreatorGroup   = memberUserGroup,
                    //DebitableBankAccounts = workflowBankAccounts,
                    ApprovalTiers = new List <ApprovalTier> {
                        new ApprovalTier {
                            ApproverGroup = memberUserGroup,
                        },
                    },
                };
                break;

            case UserGroupRole.Creator:
                functionWorkFlow = new MaintenanceWorkflow
                {
                    MemberFunction = memberfunction,
                    CreatorGroup   = memberUserGroup,
                    //DebitableBankAccounts = workflowBankAccounts,
                };
                break;

            case UserGroupRole.Approver:
                functionWorkFlow = new MaintenanceWorkflow
                {
                    MemberFunction = memberfunction,
                    ApprovalTiers  = new List <ApprovalTier> {
                        new ApprovalTier {
                            ApproverGroup = memberUserGroup,
                        },
                    },
                    //DebitableBankAccounts = workflowBankAccounts,
                };
                break;

            default:
                break;
            }
            return(functionWorkFlow);
        }
Пример #11
0
        protected static long[] GetUserIDFromMemberUserGroup(MemberUserGroup memberUserGroup)
        {
            if (memberUserGroup == null)
            {
                return(null);
            }
            int i = 0;

            long[] uID = new long[memberUserGroup.GroupUsers.Count];
            foreach (UserGroupUser ugu in memberUserGroup.GroupUsers)
            {
                uID[i] = ugu.User.ID;
                i++;
            }

            return(uID);
        }
Пример #12
0
            public MemberUserView(BizPortalSessionContext context, MemberUser memberUser, MemberUserGroup memberUserGroup)
            {
                if (memberUser == null)
                {
                    return;
                }
                this.ID        = memberUser.ID;
                this.LoginName = memberUser.LoginName ?? "";
                this.Name      = memberUser.Name != null?memberUser.Name.ToString(context.CurrentLanguage.Code) : "";

                this.Email            = memberUser.EMailAddress ?? "";
                this.MobileNumber     = memberUser.MobilePhoneNumber ?? "";
                this.CreatedBy        = memberUser.CreateAction != null ? memberUser.CreateAction.ByUser.LoginName : "";
                this.CreatedTimeStamp = memberUser.CreateAction != null?memberUser.CreateAction.Timestamp.DateTimeFormat() : "";

                this.ApprovedBy        = memberUser.ApproveAction != null ? memberUser.ApproveAction.ByUser.LoginName : "";
                this.ApprovedTimeStamp = memberUser.ApproveAction != null?memberUser.ApproveAction.Timestamp.DateTimeFormat() : "";

                this.Status = UserService.GetUserStatus(memberUser, context.CurrentLanguage.Code);

                this.User            = memberUser;
                this.MemberUserGroup = memberUserGroup;
            }
Пример #13
0
        public static IList <ActivityLog> GetActivitiesLogs(BizPortalSessionContext context, Member member, SystemEnum system,
                                                            MemberUserGroup memberUserGroup, DateTime fromDate, DateTime toDate)
        {
            IList <ActivityLog> atLogs = new List <ActivityLog>();
            IList <UserSession> usLogs = new List <UserSession>();

            fromDate = (fromDate == DateTime.MinValue) ? TimeInterval.MinDate : fromDate.Date;
            toDate   = (toDate == DateTime.MinValue) ? TimeInterval.MaxDate : toDate.AddDays(1).Date;

            //usLogs = context.PersistenceSession.QueryOver<UserSession>()
            //    .Where(us => us.SystemID == Framework.BizPortalClientSystemID)
            //    .OrderBy(us => us.UserSessionID).Desc
            //    .List<UserSession>().AsParallel().ToList();

            if (memberUserGroup != null)
            {
                IList <UserGroupUser> mug        = memberUserGroup.GroupUsers.Where(gu => gu.EffectivePeriod != null).ToList();
                List <long>           listOfUser = mug.Select(ugu => ugu.User.ID).ToList();
                usLogs = context.PersistenceSession
                         .QueryOver <UserSession>()
                         .Where(us => us.User.ID.IsIn(listOfUser) &&
                                us.SessionPeriod.EffectiveDate >= fromDate &&
                                us.SessionPeriod.EffectiveDate < toDate)
                         .List <UserSession>();
            }
            else if (member != null)
            {
                List <long> listOfUser = member.MemberUsers.Select(mu => mu.ID).ToList();
                usLogs = context.PersistenceSession
                         .QueryOver <UserSession>()
                         .Where(us => us.User.ID.IsIn(listOfUser) &&
                                us.SessionPeriod.EffectiveDate >= fromDate &&
                                us.SessionPeriod.EffectiveDate < toDate)
                         .List <UserSession>();

                //usLogs = context.PersistenceSession.CreateCriteria<UserSession>()
                //    .Add(Expression.In("User.ID", listOfUser))
                //    .AddOrder(Order.Desc("UserSessionID"))
                //    .List<UserSession>();
            }
            else
            {
                usLogs = context.PersistenceSession
                         .QueryOver <UserSession>()
                         .Where(us => us.SystemID == SystemEnum.ClientSystem &&
                                us.SessionPeriod.EffectiveDate >= fromDate &&
                                us.SessionPeriod.EffectiveDate < toDate)
                         .List();

                //string queryString = "SELECT DISTINCT UserSessionID FROM UserSessionLog ";
                //queryString += "WHERE '" + fromDate.ToString("yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture) + " 00:00:00' <= [Timestamp] ";
                //queryString += "AND [Timestamp] <= '" + toDate.ToString("yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture) + " 00:00:00'";

                //var fffff = context.PersistenceSession.CreateSQLQuery(queryString).List();

                //usLogs = context.PersistenceSession.CreateCriteria<UserSession>()
                //    .Add(Expression.Eq("SystemID", Framework.BizPortalClientSystemID))
                //    .Add(Expression.In("UserSessionID", fffff))
                //    .AddOrder(Order.Desc("UserSessionID")).List<UserSession>();
            }

            foreach (UserSession us in usLogs)
            {
                IList <UserSessionLog> usls = GetActivityLogsByUserSessionID(context, us.ID, system, fromDate, toDate);
                foreach (UserSessionLog usl in usls)
                {
                    atLogs.Add(CreateActivityLog(context, us, usl));
                }
            }

            return(atLogs.OrderByDescending(at => at.Timestamp).ToList <ActivityLog>());
        }
Пример #14
0
        public static IList <AccessLog> GetAccessLogs(BizPortalSessionContext context, Member member, MemberUserGroup memberUserGroup,
                                                      DateTime fromDate, DateTime toDate)
        {
            IList <AccessLog>   acLogs = new List <AccessLog>();
            IList <UserSession> usLogs = new List <UserSession>();

            fromDate = (fromDate == DateTime.MinValue) ? TimeInterval.MinDate : fromDate.Date;
            toDate   = (toDate == DateTime.MinValue) ? TimeInterval.MaxDate : toDate.AddDays(1).Date;

            if (memberUserGroup != null)
            {
                IList <UserGroupUser> mug        = memberUserGroup.GroupUsers.Where(gu => gu.EffectivePeriod != null).ToList();
                List <long>           listOfUser = mug.Select(ugu => ugu.User.ID).ToList();
                usLogs = context.PersistenceSession
                         .QueryOver <UserSession>()
                         .Where(us => us.User.ID.IsIn(listOfUser) &&
                                us.SessionPeriod.EffectiveDate >= fromDate &&
                                us.SessionPeriod.EffectiveDate < toDate)
                         .List <UserSession>();
            }
            else if (member != null)
            {
                List <long> listOfUser = member.MemberUsers.Select(mu => mu.ID).ToList();
                usLogs = context.PersistenceSession
                         .QueryOver <UserSession>()
                         .Where(us => us.User.ID.IsIn(listOfUser) &&
                                us.SessionPeriod.EffectiveDate >= fromDate &&
                                us.SessionPeriod.EffectiveDate < toDate)
                         .List <UserSession>();
            }
            else
            {
                usLogs = context.PersistenceSession
                         .QueryOver <UserSession>()
                         .Where(us => us.SystemID == SystemEnum.ClientSystem &&
                                us.SessionPeriod.EffectiveDate >= fromDate &&
                                us.SessionPeriod.EffectiveDate < toDate)
                         .List();
            }

            foreach (UserSession us in usLogs)
            {
                IList <UserSessionLog> usls = GetAccessLogsByUserSessionID(context, us.ID, fromDate, toDate);
                foreach (UserSessionLog usl in usls)
                {
                    acLogs.Add(CreateAccessLog(context, us, usl));
                }
            }

            return(acLogs.OrderByDescending(ac => ac.Timestamp).ToList <AccessLog>());
        }
        public static void AddTransaction(BizPortalSessionContext context, int functionId, int pageId, MemberUserGroup mguTarget, ref string message, ref int warningCount, bool approval)
        {
            string functionName = "";
            string lange        = context.CurrentLanguage.Code;

            using (ITransaction tx = context.PersistenceSession.BeginTransaction())
            {
                try
                {
                    #region Validate Zone
                    if (mguTarget.IsNotFinalized)
                    {
                        warningCount++;
                        message = Messages.Genaral.TransactionApproved.Format(lange);
                    }
                    MaintenanceWorkflow fw = GetFunctionMaintenanceWorkflow(context.User, functionId);
                    if (IsNotPermistion(fw, ref message, ref warningCount, lange))
                    {
                        message = message + "<br/>";
                    }
                    #endregion Validate Zone

                    #region Create Transaction Zone
                    if (warningCount == 0)
                    {
                        functionName = Messages.MemberUserGroup.AddMemberUserGroup.Format(lange, mguTarget.Title);
                        BizPortalFunction         function          = fw.MemberFunction.Function;
                        AddMemberGroupTransaction transactionMember = new AddMemberGroupTransaction
                                                                          (context, fw, DateTime.Now, context.Member, mguTarget);
                        transactionMember.Transit(context, fw, functionName, TransitionEventCode.SubmitEvent);
                        transactionMember.Persist(context);
                        tx.Commit();

                        message = String.Format("{0} <br/>", Messages.Genaral.TransactionSubmitedForPendingApproval.Format(lange, functionName));
                        context.Log(functionId, pageId, 0, ActionLog.BankAdminFunction.AddMemberGroup, functionName);
                    }
                    #endregion Create Transaction Zone
                }
                catch (Exception ex)
                {
                    #region Exception Zone
                    tx.Rollback();
                    warningCount++;
                    context.Log(functionId, pageId, 0, ActionLog.BankAdminFunction.AddMemberGroup
                                , IBankException.LogMessageProgramError(ex, ExceptionMessages.AddTransactionMemberGroup_BankGroupsManagement.Code + "-" + functionName + message));
                    message = ExceptionMessages.AddTransactionMemberGroup_BankGroupsManagement.Message;
                    #endregion Exception Zone
                }
            }
        }
        public static void AddTransaction(BizPortalSessionContext context, int functionId, int pageId, MaintenanceWorkflow fwfTarget, MemberUserGroup mugTarget, ref string message, ref int warningCount, bool approval)
        {
            string functionName = "";
            string lange        = context.CurrentLanguage.Code;
            IList <MaintenanceWorkflow> ListOfMaintenanceWorkflowNotFinalized = GetIsNotFinalizedMaintenanceWorkf(context, fwfTarget.MemberFunction);

            using (ITransaction tx = context.PersistenceSession.BeginTransaction())
            {
                try
                {
                    #region Validate Zone
                    MaintenanceWorkflow fw = GetFunctionMaintenanceWorkflow(context.User, functionId);
                    if (fwfTarget.CreatorGroup != null)
                    {
                        foreach (MaintenanceWorkflow item in ListOfMaintenanceWorkflowNotFinalized)
                        {
                            if (item.CreatorGroup != null)
                            {
                                if (item.CreatorGroup.ID == fwfTarget.CreatorGroup.ID)
                                {
                                    warningCount++;
                                    message = String.Format("- {0}<br/>", Messages.Genaral.TransactionPendingApproval.Format(lange, Messages.FunctionWorkFlow.AddFunctionWorkFlow.Format(lange, fwfTarget.MemberFunction.Function.Title, mugTarget.Title)));
                                }
                            }
                        }
                    }
                    else
                    {
                        foreach (MaintenanceWorkflow item in ListOfMaintenanceWorkflowNotFinalized)
                        {
                            if (item.ApprovalTiers.Count != 0)
                            {
                                if (item.ApprovalTiers[0].ApproverGroup.ID == fwfTarget.ApprovalTiers[0].ApproverGroup.ID)
                                {
                                    warningCount++;
                                    message = String.Format("- {0}<br/>", Messages.Genaral.TransactionPendingApproval.Format(lange, Messages.FunctionWorkFlow.AddFunctionWorkFlow.Format(lange, fwfTarget.MemberFunction.Function.Title, mugTarget.Title)));
                                }
                            }
                        }
                    }

                    if (IsNotPermistion(fw, ref message, ref warningCount, lange))
                    {
                        message = message + "<br/>";
                    }
                    #endregion Validate Zone

                    #region Create Transaction Zone
                    if (warningCount == 0)
                    {
                        functionName = Messages.FunctionWorkFlow.AddFunctionWorkFlow.Format(lange, fwfTarget.MemberFunction.Function.Title, mugTarget.Title);
                        AddMaintenanceWorkflowTransaction transactionMember = new AddMaintenanceWorkflowTransaction
                                                                              (
                            context, fw, DateTime.Now, context.Member, fwfTarget
                                                                              );
                        transactionMember.Transit(context, fw, functionName, TransitionEventCode.SubmitEvent);
                        transactionMember.Persist(context);
                        tx.Commit();

                        message = String.Format("- {0} <br/>", Messages.Genaral.TransactionSubmitedForPendingApproval.Format(lange, functionName));
                        context.Log(functionId, pageId, 0, ActionLog.BankAdminFunction.AddFunctionWorkflow, functionName);
                    }
                    #endregion Create Transaction Zone
                }
                catch (Exception ex)
                {
                    #region Exception Zone
                    tx.Rollback();
                    warningCount++;
                    context.Log(functionId, pageId, 0, ActionLog.BankAdminFunction.AddFunctionWorkflow
                                , IBankException.LogMessageProgramError(ex, ExceptionMessages.AddTransactionMaintenanceWorkflow_BankGroupsManagement.Code + "-" + functionName + message));
                    message = ExceptionMessages.AddTransactionMaintenanceWorkflow_BankGroupsManagement.Message;
                    #endregion Exception Zone
                }
            }
        }
        public static IList <ServiceWorkflow> GetFunctionWorkFlowOfServiceWorlflowEffectives(MemberUserGroup memberUserGroup)
        {
            IList <ServiceWorkflow> fwfs            = new List <ServiceWorkflow>();
            IList <MemberFunction>  memberFunctions = memberUserGroup.Member.EffectiveMemberFunctions
                                                      .Where(x => x.FunctionID == ClientMakerFunctionID.FundsTransferOneToMany).ToList();

            foreach (MemberFunction mf in memberFunctions)
            {
                foreach (ServiceWorkflow fwf in mf.Workflows.Where(x => x.GetType() == typeof(ServiceWorkflow)).ToList())
                {
                    if (memberUserGroup.Role == UserGroupRole.Creator)
                    {
                        if (memberUserGroup.ID == (fwf.CreatorGroup == null ? 0 : fwf.CreatorGroup.ID))//Maker จะเกิดกรณีที่ MaintenanceWorkflow ไม่มี CreatroGroup เพราะเป็น Flow ของ ApprovalGroup
                        {
                            if (fwf.IsEffective)
                            {
                                fwfs.Add(fwf);
                            }
                        }
                    }
                    else if (memberUserGroup.Role == UserGroupRole.Approver)//Approver
                    {
                        foreach (ApprovalBracket apBracket in fwf.ApprovalBrackets)
                        {
                            //foreach (ApprovalChain approvalChain in apBracket.DisjunctiveApprovalChains)
                            //{
                            foreach (ApprovalTier at in apBracket.ApprovalTiers)
                            {
                                if (memberUserGroup.ID == (at.ApproverGroup == null ? 0 : at.ApproverGroup.ID))//edit by kittikun
                                {
                                    fwfs.Add(fwf);
                                }
                            }
                            //}
                        }
                    }
                }
            }
            return(fwfs);
        }