Exemple #1
0
        protected override void Validate(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors)
        {
            if (StateName.Trim() == "")
            {
                validationErrors.Add("The state name is required.");
            }
            else
            {
                ////The windows account name must be unique.
                if (new ENTWFStateData().IsDuplicateStateName(db, ID, StateName))
                {
                    validationErrors.Add("The state name must be unique.");
                }
            }

            if (ENTWorkflowId == 0)
            {
                validationErrors.Add("Please select a workflow to associate with this state.");
            }

            if ((ENTWFOwnerGroupId == 0) && (IsOwnerSubmitter == false))
            {
                validationErrors.Add("Please select the group that owns the issue while in this state.");
            }
        }
Exemple #2
0
        protected override void Validate(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors)
        {
            if (WorkflowName.Trim() == "")
            {
                validationErrors.Add("The workflow name is required.");
            }
            else
            {
                //The name must be unique.
                if (new ENTWorkflowData().IsDuplicateWorkflowName(db, ID, WorkflowName))
                {
                    validationErrors.Add("The name must be unique.");
                }
            }

            //The object name is required
            if (ENTWorkflowObjectName.Trim() == "")
            {
                validationErrors.Add("The class name is required.");
            }
            else
            {
                //The object name must be unique
                if (new ENTWorkflowData().IsDuplicateObjectName(db, ID, ENTWorkflowObjectName))
                {
                    validationErrors.Add("This class already has a workflow associated with it.");
                }
            }
        }
Exemple #3
0
        protected override void Validate(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors)
        {
            if (TransitionName.Trim() == "")
            {
                validationErrors.Add("The transition name is required.");
            }

            if (ENTWorkflowId == 0)
            {
                validationErrors.Add("Please select a workflow.");
            }
        }
Exemple #4
0
        protected override void Validate(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors)
        {
            if (RoleName.Trim().Length == 0)
            {
                validationErrors.Add("The name is required.");
            }

            //The role name must be unique.
            if (new ENTRoleData().IsDuplicateRoleName(db, ID, RoleName))
            {
                validationErrors.Add("The name must be unique.");
            }
        }
        protected override void Validate(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors)
        {
            var entUserAccountData = new ENTUserAccountData();

            //Windows Account Name is required.
            if (WindowsAccountName.Trim().Length == 0)
            {
                validationErrors.Add("The windows account name is required.");
            }

            ////The windows account name must be unique.
            if (entUserAccountData.IsDuplicateWindowsAccountName(db, ID, WindowsAccountName))
            {
                validationErrors.Add("The windows account name must be unique.");
            }

            //TODO: VV Validate agains AD

            //First name, last name, and email are required.
            if (FirstName.Trim().Length == 0)
            {
                validationErrors.Add("The first name is required.");
            }

            //Last Name is required
            if (LastName.Trim().Length == 0)
            {
                validationErrors.Add("The last name is required.");
            }

            //Email is required
            if (Email.Trim().Length == 0)
            {
                validationErrors.Add("The email address is required.");
            }
            else
            {
                if (entUserAccountData.IsDuplicateEmail(db, ID, Email))
                {
                    validationErrors.Add("The email address must be unique.");
                }
                else
                {
                    if (Email.IndexOf("@") < 0)
                    {
                        validationErrors.Add("The email address must contain the @ sign.");
                    }
                    else
                    {
                        string[] emailParts = Email.Split(new char[] { '@' });
                        if ((emailParts.Length != 2) ||
                            (emailParts[0].Length < 2) ||
                            (emailParts[1].ToUpper() != "POWEREDBYV2.COM"))
                        {
                            validationErrors.Add("The email address must be in the format [email protected]");
                        }
                    }
                }
            }
        }
 protected override void Validate(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors)
 {
     if (OwnerGroupName.Trim() == "")
     {
         validationErrors.Add("The name is required.");
     }
     else
     {
         //The name must be unique within a workflow.
         if (new ENTWFOwnerGroupData().IsNameUnique(db, OwnerGroupName, ENTWorkflowId, ID) == false)
         {
             validationErrors.Add("The name must be unique.");
         }
     }
 }
 protected override void Validate(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors)
 {
     if (ObjectName == "")
     {
         validationErrors.Add("Please select an object to audit.");
     }
 }
Exemple #8
0
 protected override void ValidateDelete(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors)
 {
     //Nothing to validate.
     if (new ENTWorkflowData().IsWorkflowAssociatedWithItem(db, ID))
     {
         validationErrors.Add("The workflow can not be deleted because there are items associated with this workflow.");
     }
 }
 protected override void ValidateDelete(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors)
 {
     //Do not allow delete if they are associated with a state.
     if (new ENTWFOwnerGroupData().IsAssociatedWithState(db, ID))
     {
         validationErrors.Add("This group is the default owner for one or more Workflow States and can not be deleted.");
     }
 }
Exemple #10
0
 protected void UpdateFailed(ref ENTValidationErrors validationErrors)
 {
     validationErrors.Add("This record was updated by someone else while you were editing it.  Your changes were not saved.  Click the Cancel button and enter this screen again to see the changes.");
 }
Exemple #11
0
        private void ValidateWorkflow(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors,
                                      ENTBaseEO item)
        {
            //If the current owner is required.
            if (CurrentOwnerENTUserAccountId == 0)
            {
                validationErrors.Add("Please select the " + WFOwnerGroups.GetByENTWFOwnerGroupId(Convert.ToInt32(CurrentState.ENTWFOwnerGroupId)).OwnerGroupName + ".");
            }

            if (OriginalItem == null)
            {
                throw new Exception("The original item was not sent to the workflow save method.");
            }
            else
            {
                //Check required fields.
                ENTWFStatePropertyEOList entWFStateProperties = new ENTWFStatePropertyEOList();
                entWFStateProperties.Load(db, WFItem.CurrentWFStateId);

                Type objectType = Type.GetType(Workflow.ENTWorkflowObjectName);

                foreach (ENTWFStatePropertyEO entWFStateProperty in entWFStateProperties)
                {
                    if (entWFStateProperty.Required)
                    {
                        PropertyInfo property     = objectType.GetProperty(entWFStateProperty.PropertyName);
                        string       errorMessage = "The " + entWFStateProperty.PropertyName + " is required.";

                        if (property.PropertyType.IsEnum)
                        {
                            Array a       = Enum.GetValues(property.PropertyType);
                            int   value   = Convert.ToInt32(property.GetValue(item, null));
                            bool  isValid = false;
                            foreach (int i in a)
                            {
                                if (i == value)
                                {
                                    isValid = true;
                                    break;
                                }
                            }

                            if (isValid == false)
                            {
                                validationErrors.Add(errorMessage);
                            }
                        }
                        else
                        {
                            switch (property.PropertyType.Name)
                            {
                            case "Int32":
                                if (Convert.ToInt32(property.GetValue(item, null)) == 0)
                                {
                                    validationErrors.Add(errorMessage);
                                }
                                break;

                            case "String":
                                if ((property.GetValue(item, null) == null) || (property.GetValue(item, null).ToString() == string.Empty))
                                {
                                    validationErrors.Add(errorMessage);
                                }
                                break;

                            case "DateTime":
                                if ((property.GetValue(item, null) == null) || (Convert.ToDateTime(property.GetValue(item, null)) == DateTime.MinValue))
                                {
                                    validationErrors.Add(errorMessage);
                                }
                                break;

                            case "Nullable`1":
                                if (property.GetValue(item, null) == null)
                                {
                                    validationErrors.Add(errorMessage);
                                }
                                break;

                            default:
                                throw new Exception("Property type unknown.");
                            }
                        }
                    }

                    //Check if this field is read only.  Only check read only fields if the record was already submitted.
                    if (((ENTBaseWorkflowEO)OriginalItem).CurrentState.ID != 0)
                    {
                        if (entWFStateProperty.ReadOnly)
                        {
                            PropertyInfo property = objectType.GetProperty(entWFStateProperty.PropertyName);

                            if (property.GetValue(item, null).ToString() != property.GetValue(OriginalItem, null).ToString())
                            {
                                validationErrors.Add("The " + entWFStateProperty.PropertyName + " can not be changed.");
                            }
                        }
                    }
                }
            }
        }