//public override System.Xml.XmlDocument XmlSerialize () {

        //    System.Xml.XmlDocument workOutcomeDocument = base.XmlSerialize ();

        //    System.Xml.XmlElement workOutcomeNode = workOutcomeDocument.CreateElement ("WorkOutcome");

        //    System.Xml.XmlElement propertiesNode;

        //    //System.Xml.XmlNode importedNode;



        //    workOutcomeDocument.AppendChild (workOutcomeNode);

        //    workOutcomeNode.SetAttribute ("WorkOutcomeId", workOutcomeId.ToString ());

        //    workOutcomeNode.SetAttribute ("Name", workOutcomeName);

        //    propertiesNode = workOutcomeDocument.CreateElement ("Properties");

        //    workOutcomeNode.AppendChild (propertiesNode);


        //    #region Work Outcome Properties

        //    CommonFunctions.XmlDocumentAppendPropertyNode (workOutcomeDocument, propertiesNode, "WorkOutcomeId", workOutcomeId.ToString ());

        //    CommonFunctions.XmlDocumentAppendPropertyNode (workOutcomeDocument, propertiesNode, "WorkOutcomeName", workOutcomeName);

        //    CommonFunctions.XmlDocumentAppendPropertyNode (workOutcomeDocument, propertiesNode, "WorkOutcomeDescription", workOutcomeDescription);

        //    CommonFunctions.XmlDocumentAppendPropertyNode (workOutcomeDocument, propertiesNode, "Enabled", enabled.ToString ());

        //    CommonFunctions.XmlDocumentAppendPropertyNode (workOutcomeDocument, propertiesNode, "Visible", visible.ToString ());

        //    #endregion

        //    return workOutcomeDocument;

        //}

        //public override List<Mercury.Server.Services.Responses.ConfigurationImportResponse> XmlImport (System.Xml.XmlNode objectNode) {

        //    List<Mercury.Server.Services.Responses.ConfigurationImportResponse> response = new List<Mercury.Server.Services.Responses.ConfigurationImportResponse> ();

        //    Services.Responses.ConfigurationImportResponse importResponse = new Mercury.Server.Services.Responses.ConfigurationImportResponse ();


        //    importResponse.ObjectType = objectNode.Name;

        //    importResponse.ObjectName = objectNode.Attributes ["Name"].InnerText;

        //    importResponse.Success = true;


        //    if (importResponse.ObjectType == "WorkOutcome") {

        //        foreach (System.Xml.XmlNode currentNode in objectNode.ChildNodes) {

        //            switch (currentNode.Name) {

        //                case "Properties":

        //                    foreach (System.Xml.XmlNode currentProperty in currentNode.ChildNodes) {

        //                        switch (currentProperty.Attributes["Name"].InnerText) {

        //                            case "WorkOutcomeName": workOutcomeName = currentProperty.InnerText; break;

        //                            case "Description": description = currentProperty.InnerText; break;

        //                            case "Enabled": enabled = Convert.ToBoolean (currentProperty.InnerText); break;

        //                            case "Visible": visible = Convert.ToBoolean (currentProperty.InnerText); break;

        //                        }

        //                    }

        //                    break;

        //            }

        //        }

        //        importResponse.Success = Save ();

        //        importResponse.Id = Id;

        //        if (!importResponse.Success) { importResponse.SetException (base.application.LastException); }

        //    }

        //    else { importResponse.SetException (new ApplicationException ("Invalid Object Type Parsed as WorkOutcome.")); }

        //    response.Add (importResponse);

        //    return response;

        //}

        #endregion


        #region Validation Functions

        public override Dictionary <String, String> Validate()
        {
            Dictionary <String, String> validationResponse = base.Validate();


            // VALIDATE UNIQUE INSTANCE
            WorkOutcome duplicateObject = application.WorkOutcomeGet(Name);

            if (duplicateObject != null)
            {
                if (Id != duplicateObject.Id)
                {
                    validationResponse.Add("Duplicate", "Duplicate Found.");
                }
            }

            return(validationResponse);
        }
Example #2
0
        public Boolean Close(Int64 forWorkOutcomeId, Boolean validatePermission)
        {
            Boolean success = false;

            application.SetLastException(null);

            try {
                if (WorkQueue != null)
                {
                    if ((WorkQueue.HasManagePermission) || (HasOwnership) || (!validatePermission))
                    {
                        WorkOutcome workOutcome = application.WorkOutcomeGet(forWorkOutcomeId);

                        if (workOutcome != null)
                        {
                            if (!completionDate.HasValue)
                            {
                                success = SelfAssign("Work Queue Item Close", validatePermission);

                                if (success)
                                {
                                    lastWorkedDate = DateTime.Now;

                                    workflowNextStep = String.Empty;

                                    completionDate = DateTime.Now;

                                    workOutcomeId = forWorkOutcomeId;

                                    success = Save();
                                }

                                else
                                {
                                    throw new ApplicationException("Permission Denied on Closing Work Queue Item [" + Id.ToString() + "] (not assigned to you or no manager rights to Work Queue).");
                                }
                            }

                            else
                            {
                                throw new ApplicationException("Work Queue Item [" + Id.ToString() + "] is already closed.");
                            }
                        }

                        else
                        {
                            throw new ApplicationException("No Work Outcome Assigned for closing Work Queue Item [" + Id.ToString() + "].");
                        }
                    }

                    else
                    {
                        throw new ApplicationException("Permission Denied on Closing Work Queue Item [" + Id.ToString() + "] (not assigned to you or no manager rights to Work Queue).");
                    }
                }

                else
                {
                    throw new ApplicationException("Unable to reference Work Queue for Work Queue Item [" + Id.ToString() + "].");
                }
            }

            catch (Exception applicationException) {
                application.SetLastException(applicationException);

                success = false;
            }

            return(success);
        }