Esempio n. 1
0
 internal DetailedWorklistItem(ExecutionSettings settings) : base(settings)
 {
 }
        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));
            }
        }
 internal BasicWorklistItem(ExecutionSettings settings)
 {
     this._execSettings = settings;
 }