Ejemplo n.º 1
0
        private Boolean HandleNonCustomerApprovers(InMemoryUser user, IEnumerable <Dictionary <string, object> > wfassignment, string approvalGroup,
                                                   IDictionary <string, object> approval, IEnumerable <Dictionary <string, object> > wftransactions, Dictionary <string, object> rejectedTransaction)
        {
            //locate assignment
            var assignment = wfassignment.FirstOrDefault(f => f[c.RoleIdColumn].ToString().EqualsIc(approvalGroup));

            approval["#shouldshowaction"] = user.HasPersonGroup(approvalGroup);
            if (assignment == null)
            {
                //nothing has been done, so it needs approval still
                return(true);
            }
            var wfid    = assignment[c.WfIdColumn];
            var txs     = wftransactions.Where(tx => tx[c.WfIdColumn].ToString().Equals(wfid));
            var txToUse = txs.LastOrDefault();

            //locate the oldest tx of that assignment and use it´s data
            if (txToUse != null)
            {
                approval[c.ChangeByColumn]   = txToUse[c.PersonIdColumn];
                approval[c.ChangeDateColumn] = txToUse[c.TransDateColumn];
                approval[c.StatusColumn]     = GetStatusForPart1(rejectedTransaction, txToUse);
            }
            Log.DebugFormat("non customer approval handled " + string.Join(", ", approval.Select(m => m.Key + ":" + m.Value).ToArray()));
            //TODO: is this logic correct? if the status of the approvergroup is already rejected why should we give the user any chance to change it?
            return(!approval.ContainsKey(c.StatusColumn) || !approval[c.StatusColumn].EqualsAny(c.ApprovedStatus, c.RejectedStatus));
        }
Ejemplo n.º 2
0
        private bool HandleCustomerApprovers(InMemoryUser user, AttributeHolder result, string approvalGroup, IEnumerable <Dictionary <string, object> > worklogs, IDictionary <string, object> approval,
                                             IEnumerable <Dictionary <string, object> > wostatus)
        {
            //https://controltechnologysolutions.atlassian.net/browse/HAP-976
            //https://controltechnologysolutions.atlassian.net/browse/HAP-1113 --> changing the way it filters the status
            worklogs = FilterWorkLogsOlderThanLatestAuth(worklogs, wostatus);

            var wlEnumerable = worklogs as Dictionary <string, object>[] ?? worklogs.ToArray();

            var apprDescription = c.GetWorkLogDescriptions(approvalGroup, true);
            var rejDescription  = c.GetWorkLogDescriptions(approvalGroup, false);


            var apprWl = wlEnumerable.FirstOrDefault(w =>
                                                     apprDescription.EqualsIc(w["description"] as string) &&
                                                     c.WlApprLogType.EqualsIc(w["logtype"] as string) &&
                                                     w["recordkey"].Equals(result.GetAttribute("wonum"))
                                                     );

            var rejWl = wlEnumerable.FirstOrDefault(w =>
                                                    rejDescription.EqualsIc(w["description"] as string) &&
                                                    c.WlRejLogType.EqualsIc(w["logtype"] as string) &&
                                                    w["recordkey"].Equals(result.GetAttribute("wonum"))
                                                    );

            var anyrejWl = wlEnumerable.FirstOrDefault(w =>
                                                       (w["description"] != null && w["description"].ToString().StartsWith(c.RejectedWorklogDescription, StringComparison.CurrentCultureIgnoreCase)) &&
                                                       w["logtype"].ToString().Equals(c.WlRejLogType) &&
                                                       w["recordkey"].Equals(result.GetAttribute("wonum"))
                                                       );

            //approval["#shouldshowaction"] = LevelMatches(result, approval) && user.HasPersonGroup(approvalGroup); ;
            //removed due to thomas comments, on HAP-976
            approval["#shouldshowaction"] = user.HasPersonGroup(approvalGroup);
            ;

            if (apprWl != null || rejWl != null)
            {
                Log.DebugFormat("Specific approval or rejected worklog found");

                approval[c.ChangeByColumn]    = apprWl != null ? apprWl[c.CreateByColumn] : rejWl[c.CreateByColumn];
                approval[c.ChangeDateColumn]  = apprWl != null ? apprWl[c.CreateDate] : rejWl[c.CreateDate];
                approval[c.StatusColumn]      = apprWl != null ? c.ApprovedStatus : c.RejectedStatus;
                approval["#shouldshowaction"] = false;
            }
            else if (anyrejWl != null)
            {
                Log.DebugFormat("At least one rejected worklog found scenario");
                //if there´s a rejected worklog on the level, then all groups should be rejected, except the ones that might have approved it already...
                approval[c.StatusColumn] = c.RejectedStatus;
                //HAP-993 if any of the groups rejected it, we should no longer display the actions
                approval["#shouldshowaction"] = false;
            }
            Log.DebugFormat("customer approval handled " + string.Join(", ", approval.Select(m => m.Key + ":" + m.Value).ToArray()));
            //if this group has not yet been approved or rejectd, it will still require some action (maybe not by this user)
            return(!approval.ContainsKey(c.StatusColumn) || !approval[c.StatusColumn].EqualsAny(c.ApprovedStatus, c.RejectedStatus));
        }