コード例 #1
0
        /// <summary>
        /// This method is to get the latest approvers that have approved the rfq for each level and before the current approval level
        /// </summary>
        /// <param name="level"></param>
        /// <returns></returns>
        private List<Approvers> ApproversList(int level)
        {
            List<Approvers> approvers = new List<Approvers>();
            DataTable dt = TablesLogic.tActivityHistory.Select(TablesLogic.tActivityHistory.PreviousApprovalLevel.As("Level"),
                                                                      TablesLogic.tActivityHistory.CreatedDateTime.Max().As("CreatedDateTime"))
                                                              .Where(TablesLogic.tActivityHistory.AttachedObjectID == this.ObjectID &
                                                                     TablesLogic.tActivityHistory.TriggeringEventName == "Approve" &
                                                                     TablesLogic.tActivityHistory.PreviousApprovalLevel <= level)
                                                              .GroupBy(TablesLogic.tActivityHistory.PreviousApprovalLevel)
                                                              .OrderBy(TablesLogic.tActivityHistory.PreviousApprovalLevel.Asc);
            foreach (DataRow row in dt.Rows)
            {

                OActivityHistory ah = TablesLogic.tActivityHistory.Load(
                                        TablesLogic.tActivityHistory.PreviousApprovalLevel == Convert.ToInt16(row["Level"]) &
                                        TablesLogic.tActivityHistory.CreatedDateTime == Convert.ToDateTime(row["CreatedDateTime"]) &
                                        TablesLogic.tActivityHistory.AttachedObjectID == this.ObjectID &
                                        TablesLogic.tActivityHistory.TriggeringEventName == "Approve");
                if (ah != null)
                {
                    Approvers app = new Approvers();
                    app.ApproverName = ah.CreatedUser;
                    app.ApprovalDateTime = ah.CreatedDateTime;
                    if (ah.TriggeringEventName.Is("Approve"))
                        app.ApprovalStatus = Resources.Strings.TriggeringEventName_Approve;
                    else if (ah.TriggeringEventName.Is("Reject"))
                        app.ApprovalStatus = Resources.Strings.TriggeringEventName_Reject;
                    else if (ah.TriggeringEventName.Is("Approve_Supporter"))
                        app.ApprovalStatus = Resources.Strings.TriggeringEventName_Approve_Supporter;
                    else
                        app.ApprovalStatus = ah.TriggeringEventName;
                    app.ApprovalLevel = ah.PreviousApprovalLevel;
                    approvers.Add(app);
                }

            }
            return approvers;
        }
コード例 #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="level"></param>
        /// <returns></returns>
        private List<Approvers> GetPreviousApproversByLevel(int? level)
        {
            List<Approvers> approvers = new List<Approvers>();

            TActivityHistory actHistory = TablesLogic.tActivityHistory;
            TActivityHistory activityHistory = new TActivityHistory();
            DataTable dt = actHistory.Select
                            (actHistory.PreviousApprovalLevel,
                            actHistory.CreatedDateTime,
                            actHistory.CreatedUser,
                            actHistory.TriggeringEventName)
                            .Where
                            ((actHistory.PreviousApprovalLevel <= level |
                            actHistory.PreviousApprovalLevel == null) &
                            actHistory.AttachedObjectID == this.ObjectID &
                            (actHistory.TriggeringEventName.Like("Approve%")) &
                            actHistory.CreatedDateTime.In
                            (activityHistory.Select
                            (activityHistory.CreatedDateTime.Max().As("CreatedDateTime"))
                            .Where
                            (
                            (activityHistory.PreviousApprovalLevel == actHistory.PreviousApprovalLevel | actHistory.PreviousApprovalLevel == null) &
                            (activityHistory.TriggeringEventName.Like("Approve%")) &
                            activityHistory.AttachedObjectID == this.ObjectID)
                            .GroupBy(activityHistory.PreviousApprovalLevel, activityHistory.CreatedUser)))
                            .OrderBy(actHistory.PreviousApprovalLevel.Asc);
            
            foreach (DataRow dr in dt.Rows)
            {
                Approvers app = new Approvers();
                app.ApproverName = dr["CreatedUser"].ToString();
                app.ApprovalDateTime = Convert.ToDateTime(dr["CreatedDateTime"]);

                if (dr["TriggeringEventName"].ToString().Is("Approve"))
                    app.ApprovalStatus = Resources.Strings.TriggeringEventName_Approve;
                else if (dr["TriggeringEventName"].ToString().Is("Reject"))
                    app.ApprovalStatus = Resources.Strings.TriggeringEventName_Reject;
                else if (dr["TriggeringEventName"].ToString().Is("Approve_Supporter"))
                    app.ApprovalStatus = Resources.Strings.TriggeringEventName_Approve_Supporter;
                else
                    app.ApprovalStatus = dr["TriggeringEventName"].ToString();
                if (dr["PreviousApprovalLevel"] != DBNull.Value)
                    app.ApprovalLevel = Convert.ToInt16(dr["PreviousApprovalLevel"]);
                approvers.Add(app);
            }
            return approvers;

        }