Пример #1
0
        private IHttpActionResult ApproveOrReject(ActionApprovalInfo actionApproval, ApprovalMemberResults approvalType)
        {
            try
            {
                var actions = DynamicTypeManager.GetInfoListById<IInfoList>(Constants.ActionItemsProcessName, actionApproval.ActionId);
                var action = actions.Cast<IActionItemInfo>().FirstOrDefault();

                if (action == null)
                {
                    return Ok(new { Success = false, Message = "Action not found" });
                }

                var authenticationResult = AuthenticateUserCommand.Execute(actionApproval.UserName, actionApproval.Password, Utils.CurrentUserPersonId);
                if (authenticationResult.AuthenticationResult != LoginStatuses.Success)
                {
                    return Ok(new { Success = false, Message = "Authentication failed" });
                }

                var approveCommandResult = UpdateApprovalMemberResultCommand.Execute(actionApproval.ActionId, approvalType, actionApproval.Comments);
                if (approveCommandResult.IsSuccessful)
                {
                    return Ok(new { Success = true, ActionId = actionApproval.ActionId });
                }

                var errorMessage = !string.IsNullOrEmpty(approveCommandResult.ErrorMessage)
                                       ? approveCommandResult.ErrorMessage
                                       : "There was an error with this action, please try to refresh and repeat";

                return Ok(new { Success = false, Message = errorMessage });
            }
            catch (Exception ex)
            {
                Logger.Log(LogSeverity.Error, "Approve", ex.ToString());
                return Ok(new { Success = false, Message = "There was an error with this action, please try to refresh and repeat." });
            }
        }
Пример #2
0
 /// <summary>
 /// Updates the state of the approval.
 /// </summary>
 /// <param name="item">The editable root.</param>
 /// <param name="approvalFieldName">Name of the approval field.</param>
 /// <param name="personId">The person identifier.</param>
 /// <param name="level">The level.</param>
 /// <param name="result">The result.</param>
 /// <param name="comments">The comments.</param>
 public void UpdateApprovalState(IEditableRoot item, string approvalFieldName, int personId, int level, ApprovalMemberResults result, string comments)
 {
     GetApprovalFieldManager(item, approvalFieldName).UpdateApprovalState(item, personId, level, result, comments);
 }
Пример #3
0
 /// <summary>
 /// Sets the approval level result.
 /// </summary>
 /// <param name="al">The al.</param>
 /// <param name="result">The result.</param>
 public static void SetApprovalLevelResult(this IApprovalLevelResult al, ApprovalMemberResults result)
 {
     if (al != null)
         al.ApprovalResult = result.ToString();
 }
Пример #4
0
 /// <summary>
 /// Overrides the approval level.
 /// </summary>
 /// <param name="item">The target item.</param>
 /// <param name="approvalFieldName">Name of the approval field.</param>
 /// <param name="personId">The person id.</param>
 /// <param name="level">The level.</param>
 /// <param name="result">The result.</param>
 /// <param name="comments">The comments.</param>
 public void OverrideApprovalLevel(IEditableRoot item, string approvalFieldName, int personId, int level, ApprovalMemberResults result, string comments)
 {
     GetApprovalFieldManager(item, approvalFieldName).OverrideApprovalLevel(item, personId, level, result, comments);
 }
Пример #5
0
 /// <summary>
 /// Sets the approval member result.
 /// </summary>
 /// <param name="am">The am.</param>
 /// <param name="result">The result.</param>
 public static void SetApprovalMemberResult(this IApprovalMemberResultEdit am, ApprovalMemberResults result)
 {
     if (am != null)
         am.ApprovalMemberResult = result.ToString();
 }