Beispiel #1
0
        /// <summary>
        /// Method to check if a specified process instance still exists.
        /// </summary>
        /// <param name="procInstID">The process instance ID that needs to be checked.</param>
        /// <param name="server">An instance of the workflow management server.</param>
        /// <returns></returns>
        private bool ProcessInstanceExists(int procInstID, k2Mgnt.WorkflowManagementServer server)
        {
            // use SmartObjectClientServer for accessing SmartObjects
            SmartObjectClientServer sos = new SmartObjectClientServer();

            // prepare the connection
            sos.CreateConnection();

            // open the connection
            sos.Connection.Open(connectionString);

            // get a "Process Instance" SmartObject (an ootB K2 SmartObject > Workflow Reports > Workflow General)
            SmartObject so = sos.GetSmartObject("Process_Instance");

            // tell the SmartObject to return a list of results
            so.MethodToExecute = "List";

            // set filter for results - return the live instance for the specified procInstID
            so.Properties["ProcessInstanceID"].Value = procInstID.ToString();

            // execute - return the results as a DataTable
            DataTable dt = sos.ExecuteListDataTable(so);

            // if there's one row the instance is still there and not deleted
            if (dt.Rows.Count == 1)
            {
                // close the connection and return true
                sos.Connection.Close();
                return(true);
            }

            // if there is no row than the instance has been deleted
            return(false);
        }
        private void ListPlaceholders()
        {
            //Adding dynamic placeholders
            if (!string.IsNullOrEmpty(_pSmoSystemName))
            {
                SmartObjectClientServer smoServer = ServiceBroker.K2Connection.GetConnection <SmartObjectClientServer>();
                using (smoServer.Connection)
                {
                    var smo = smoServer.GetSmartObject(_pSmoSystemName);
                    smo.MethodToExecute = _pSmoListName;
                    var dt = smoServer.ExecuteListDataTable(smo);
                    foreach (DataRow row in dt.Rows)
                    {
                        _placeholders.AddItem(row[_pNameProperty].ToString());
                    }
                }
            }
            //Adding static placeholders
            //Adding static placeholders
            foreach (var item in GetStaticPlaceholders())
            {
                _placeholders.AddItem(item);
            }
            ServiceBroker.Service.ServiceObjects[0].Properties.InitResultTable();
            DataTable results = ServiceBroker.ServicePackage.ResultTable;

            foreach (var item in _placeholders.Items)
            {
                DataRow dr = results.NewRow();
                dr[Constants.Properties.Placeholder]            = item.Name;
                dr[Constants.Properties.PlaceholderWithWrapper] = _placeholders.Wrapper + item.Name + _placeholders.Wrapper;
                results.Rows.Add(dr);
            }
        }
        private void GetEmailTemplate()
        {
            //Getting all the ServiceConfig and Input properties
            var _inputSubject = GetStringProperty(Constants.Properties.InputEmailSubject) ?? string.Empty;
            var _inputBody    = GetStringProperty(Constants.Properties.InputEmailBody) ?? string.Empty;

            foreach (var idName in GetInputIds())
            {
                _inputIds.Add(idName, GetStringParameter(idName));
            }

            if (!string.IsNullOrEmpty(_pSmoSystemName))
            {
                SmartObjectClientServer smoServer = ServiceBroker.K2Connection.GetConnection <SmartObjectClientServer>();
                using (smoServer.Connection)
                {
                    var smo = smoServer.GetSmartObject(_pSmoSystemName);
                    smo.MethodToExecute = _pSmoListName;
                    var dt = smoServer.ExecuteListDataTable(smo);
                    foreach (DataRow row in dt.Rows)
                    {
                        var placeholder = _placeholders.Wrapper + row[_pNameProperty] + _placeholders.Wrapper;
                        //Getting only the placholders, which are used in the EmailSubject/EmailBody
                        if (_inputSubject.Contains(placeholder) || _inputBody.Contains(placeholder))
                        {
                            _placeholders.AddItem(row[_pNameProperty].ToString(), row[_pAdoNetProperty].ToString(), row[_pReturnProperty].ToString());
                        }
                    }
                }
                //Getting the values of the placeholders
                _placeholders.GetAllValues(_inputIds, ServiceBroker);
            }
            //Adding static placeholders
            foreach (var item in GetStaticPlaceholders())
            {
                _placeholders.AddItemWithValue(item, GetStringParameter(item));
            }
            //Replacing all the values
            var outputSubject = _placeholders.ReplacePlaceholders(_inputSubject);
            var outputBody    = _placeholders.ReplacePlaceholders(_inputBody);

            ServiceBroker.Service.ServiceObjects[0].Properties.InitResultTable();
            DataTable results = ServiceBroker.ServicePackage.ResultTable;

            DataRow dr = results.NewRow();

            dr[Constants.Properties.OutputEmailBody]    = outputBody;
            dr[Constants.Properties.OutputEmailSubject] = outputSubject;
            results.Rows.Add(dr);
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="soname">Smart Object Name</param>
        /// <param name="method">Method</param>
        /// <param name="properties">Input Properties</param>
        /// <returns></returns>
        public static DataTable SOExecuteListDataTable(string soname, string method, NameValueCollection properties)
        {
            SmartObjectClientServer soClient = null;
            DataTable SOList = null;

            try
            {
                // get connection to smartobject Server
                soClient = GetSOClientConnection();

                // get smartobject
                SmartObject SO = soClient.GetSmartObject(soname);

                if (properties != null)
                {
                    for (int i = 0; i < properties.Count; i++)
                    {
                        string key = properties.GetKey(i).ToString();
                        if (properties[key] != null && !string.IsNullOrEmpty(properties[key]))
                        {
                            string value = properties[key].ToString();
                            //SO.ListMethods[method].InputProperties[key].Value = value;
                            SO.Properties[key].Value = value;
                        }
                    }
                }

                SO.MethodToExecute = method;

                SOList = soClient.ExecuteListDataTable(SO);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                // close connection
                if (soClient != null)
                {
                    soClient.Connection.Close();
                }
            }
            return(SOList);
        }
Beispiel #5
0
 public virtual DataTable ExecuteListDataTable(SmartObject smartObject, ExecuteListOptions options)
 {
     return(_serviceClientServer.ExecuteListDataTable(smartObject, options));
 }