/// <summary>
        /// Describes what our service is capable of doing and what parameters would be needed.
        /// </summary>
        /// <returns></returns>
        public override string DescribeSchema()
        {
            base.Service.Name = "WorklistService";
            base.Service.MetaData.DisplayName = "Worklist Service";
            base.Service.MetaData.Description = "Service that is used to retrieve user(s) Worklist items.";

            BasicWorklistItem bwi = new BasicWorklistItem();
            DetailedWorklistItem dwi = new DetailedWorklistItem();
            WorklistItemAction wla = new WorklistItemAction();
            base.Service.ServiceObjects.Add(bwi.DescribeServiceObject());
            base.Service.ServiceObjects.Add(dwi.DescribeServiceObject());
            base.Service.ServiceObjects.Add(wla.DescribeServiceObject());

            return base.DescribeSchema();
        }
        /// <summary>
        /// Describes what our service is capable of doing and what parameters would be needed.
        /// </summary>
        /// <returns></returns>
        public override string DescribeSchema()
        {
            base.Service.Name = "WorklistService";
            base.Service.MetaData.DisplayName = "Worklist Service";
            base.Service.MetaData.Description = "Service that is used to retrieve user(s) Worklist items.";

            BasicWorklistItem    bwi = new BasicWorklistItem();
            DetailedWorklistItem dwi = new DetailedWorklistItem();
            WorklistItemAction   wla = new WorklistItemAction();

            base.Service.ServiceObjects.Add(bwi.DescribeServiceObject());
            base.Service.ServiceObjects.Add(dwi.DescribeServiceObject());
            base.Service.ServiceObjects.Add(wla.DescribeServiceObject());

            return(base.DescribeSchema());
        }
        public override void Execute()
        {
            ValidateConfigSection();
            base.ServicePackage.ResultTable = null;
            DataTable result = new DataTable("Result");

            try
            {
                foreach (ServiceObject serviceObj in base.Service.ServiceObjects)
                {
                    foreach (Method method in serviceObj.Methods)
                    {
                        #region build the input collections for method execution
                        // build the properties collection.
                        Dictionary <string, object> properties = new Dictionary <string, object>();
                        foreach (Property property in serviceObj.Properties)
                        {
                            if ((property.Value != null) && (!string.IsNullOrEmpty(property.Value.ToString())))
                            {
                                properties.Add(property.Name, property.Value);
                            }
                        }

                        // build the method parameters collection
                        Dictionary <string, object> parameters = new Dictionary <string, object>();
                        foreach (MethodParameter parameter in method.MethodParameters)
                        {
                            if ((parameter.Value != null) && (!string.IsNullOrEmpty(parameter.Value.ToString())))
                            {
                                parameters.Add(parameter.Name, parameter.Value);
                            }
                        }
                        #endregion

                        ExecutionSettings settings = null;

                        if (properties.ContainsKey("UserName"))
                        {
                            if (!(string.IsNullOrEmpty(properties["UserName"].ToString())))
                            {
                                settings = new ExecutionSettings(this._connectionStringImpersonate, properties["UserName"].ToString());
                            }
                        }
                        else
                        {
                            settings = new ExecutionSettings(this._connectionString);
                        }


                        string methodName = method.Name.ToLower();

                        switch (serviceObj.Name.ToLower())
                        {
                        case "basicworklistitem":
                        {
                            BasicWorklistItem worklist = new BasicWorklistItem(settings);
                            if (methodName == "getworklistitems")
                            {
                                result = worklist.GetWorklistItems(properties, parameters);
                            }

                            if (methodName == "loadworklistitem")
                            {
                                if ((properties.ContainsKey("SerialNumber") && (properties["SerialNumber"].ToString() != string.Empty)))
                                {
                                    result = worklist.LoadWorklistItem(properties["SerialNumber"].ToString());
                                }
                                else
                                {
                                    throw new ArgumentException("Input value cannot be null or empty", "serialNumber");
                                }
                            }
                            break;
                        }

                        case "detailedworklistitem":
                        {
                            DetailedWorklistItem worklist = new DetailedWorklistItem(settings);
                            if (methodName == "getworklistitems")
                            {
                                result = worklist.GetWorklistItems(properties, parameters);
                            }

                            if (methodName == "loadworklistitem")
                            {
                                if ((properties.ContainsKey("SerialNumber") && (properties["SerialNumber"].ToString() != string.Empty)))
                                {
                                    result = worklist.LoadWorklistItem(properties["SerialNumber"].ToString());
                                }
                                else
                                {
                                    throw new ArgumentException("Input value cannot be null or empty", "serialNumber");
                                }
                            }
                            break;
                        }

                        case "worklistitemaction":
                        {
                            WorklistItemAction worklistaction = new WorklistItemAction(_connectionString, _connectionStringImpersonate);

                            if (methodName == "getworklistitemactions")
                            {
                                result = worklistaction.GetWorklistItemActions(Convert.ToString(properties["SerialNumber"]));
                            }

                            if (methodName == "redirectworklistitem")
                            {
                                worklistaction.RedirectWorklistItem(Convert.ToString(properties["SerialNumber"]), Convert.ToString(parameters["UserName"]));
                            }

                            if (methodName == "redirectmanageduserworklistitem")
                            {
                                worklistaction.RedirectManagedUserWorklistItem(Convert.ToString(parameters["ManagedUserName"]), Convert.ToString(properties["SerialNumber"]), Convert.ToString(parameters["UserName"]));
                            }


                            if (methodName == "actionworklistitem")
                            {
                                worklistaction.ActionWorklistItem(Convert.ToString(properties["SerialNumber"]), Convert.ToString(properties["ActionName"]));
                            }

                            if (methodName == "openworklistitem")
                            {
                                result = worklistaction.OpenWorklistItem(Convert.ToString(properties["SerialNumber"]));
                            }

                            if (methodName == "releaseworklistitem")
                            {
                                result = worklistaction.ReleaseWorklistItem(Convert.ToString(properties["SerialNumber"]));
                            }

                            break;
                        }
                        }
                    }
                }
                base.ServicePackage.ResultTable  = result;
                base.ServicePackage.IsSuccessful = true;
            }
            catch (Exception ex)
            {
                base.ServicePackage.IsSuccessful = false;
                base.ServicePackage.ServiceMessages.Add(new ServiceMessage(ex.Message, MessageSeverity.Error));
            }
        }
        private DataTable LoadDetailedWorklistItem(Dictionary<string, object> properties)
        {
            DataTable result = null;
            DetailedWorklistItem dwi = new DetailedWorklistItem(_connectionString, _connectionStringImpersonate);

            if (properties.ContainsKey("SerialNumber"))
                result = dwi.LoadWorklistItem(properties["SerialNumber"].ToString());
            return result;
        }
 private DataTable GetDetailedWorklistItems(Dictionary<string, object> properties, Dictionary<string, object> parameters)
 {
     DataTable result;
     DetailedWorklistItem worklistitem = new DetailedWorklistItem(_connectionString, _connectionStringImpersonate);
     result = worklistitem.GetWorklistItems(properties, parameters);
     return result;
 }