コード例 #1
0
        private void ListDataFields()
        {
            var procId = GetIntProperty(Constants.SoProperties.ProcessInstance.ProcInstId, true);

            ServiceBroker.Service.ServiceObjects[0].Properties.InitResultTable();
            var dt = ServiceBroker.ServicePackage.ResultTable;

            using (_wfClient = ServiceBroker.K2Connection.GetWorkflowClientConnection())
            {
                var pi = _wfClient.OpenProcessInstance(procId);
                foreach (client.DataField dataField in pi.DataFields)
                {
                    var dRow = dt.NewRow();
                    dRow[Constants.SoProperties.ProcessInstance.DataFieldName] = dataField.Name;
                    dRow[Constants.SoProperties.ProcessInstance.DataFieldType] = dataField.ValueType.ToString();
                    string dataFieldValue;
                    switch (dataField.ValueType)
                    {
                    case client.DataType.TypeBinary:
                        dataFieldValue = Convert.ToBase64String((byte[])dataField.Value);
                        break;

                    case client.DataType.TypeDate:
                        dataFieldValue = Convert.ToDateTime(dataField.Value).ToString("yyyy-MM-dd HH:mm:ss");
                        break;

                    default:
                        dataFieldValue = Convert.ToString(dataField.Value);
                        break;
                    }
                    dRow[Constants.SoProperties.ProcessInstance.DataFieldValue] = dataFieldValue;
                    dt.Rows.Add(dRow);
                }
            }
        }
コード例 #2
0
        private void UpdateFolio()
        {
            var folio  = GetStringProperty(Constants.SoProperties.ProcessInstance.ProcessFolio, true);
            var procId = GetIntProperty(Constants.SoProperties.ProcessInstance.ProcInstId, true);

            using (_wfClient = ServiceBroker.K2Connection.GetWorkflowClientConnection())
            {
                var pi = _wfClient.OpenProcessInstance(procId);
                pi.Folio = folio;
                pi.Update();
            }
        }
コード例 #3
0
        private void UpdateXmlField()
        {
            var xmlFieldName  = GetStringProperty(Constants.SoProperties.ProcessInstance.XmlFieldName, true);
            var xmlFieldValue = GetStringProperty(Constants.SoProperties.ProcessInstance.XmlFieldValue);
            var procId        = GetIntProperty(Constants.SoProperties.ProcessInstance.ProcInstId, true);

            using (_wfClient = ServiceBroker.K2Connection.GetWorkflowClientConnection())
            {
                var pi       = _wfClient.OpenProcessInstance(procId);
                var xmlField = pi.XmlFields[xmlFieldName];
                xmlField.Value = xmlFieldValue;
                pi.Update();
            }
        }
コード例 #4
0
        private void SetFolio()
        {
            ServiceObject serviceObject = ServiceBroker.Service.ServiceObjects[0];

            string folio  = base.GetStringProperty(Constants.SOProperties.ProcessInstanceClient.ProcessFolio, false);
            int    procId = base.GetIntProperty(Constants.SOProperties.ProcessInstanceClient.ProcessInstanceId, true);

            using (CLIENT.Connection k2Con = this.ServiceBroker.K2Connection.GetWorkflowClientConnection())
            {
                CLIENT.ProcessInstance pi = k2Con.OpenProcessInstance(procId);
                pi.Folio = folio;
                pi.Update();
                k2Con.Close();
            }
        }
コード例 #5
0
        private void UpdateDataField()
        {
            var dataFieldName  = GetStringProperty(Constants.SoProperties.ProcessInstance.DataFieldName, true);
            var dataFieldValue = GetStringProperty(Constants.SoProperties.ProcessInstance.DataFieldValue);
            var procId         = GetIntProperty(Constants.SoProperties.ProcessInstance.ProcInstId, true);

            using (_wfClient = ServiceBroker.K2Connection.GetWorkflowClientConnection())
            {
                var pi        = _wfClient.OpenProcessInstance(procId);
                var dataField = pi.DataFields[dataFieldName];
                switch (dataField.ValueType)
                {
                case client.DataType.TypeBinary:
                    dataField.Value = Convert.FromBase64String(dataFieldValue);
                    break;

                case client.DataType.TypeBoolean:
                    dataField.Value = Convert.ToBoolean(dataFieldValue);
                    break;

                case client.DataType.TypeDate:
                    dataField.Value = Convert.ToDateTime(dataFieldValue);
                    break;

                case client.DataType.TypeDecimal:
                    dataField.Value = Convert.ToDecimal(dataFieldValue);
                    break;

                case client.DataType.TypeDouble:
                    dataField.Value = Convert.ToDouble(dataFieldValue);
                    break;

                case client.DataType.TypeInteger:
                    dataField.Value = Convert.ToInt32(dataFieldValue);
                    break;

                case client.DataType.TypeLong:
                    dataField.Value = Convert.ToInt64(dataFieldValue);
                    break;

                default:
                    dataField.Value = dataFieldValue;
                    break;
                }
                pi.Update();
            }
        }
コード例 #6
0
        private void ListXmlFields()
        {
            var procId = GetIntProperty(Constants.SoProperties.ProcessInstance.ProcInstId, true);

            ServiceBroker.Service.ServiceObjects[0].Properties.InitResultTable();
            var dt = ServiceBroker.ServicePackage.ResultTable;

            using (_wfClient = ServiceBroker.K2Connection.GetWorkflowClientConnection())
            {
                var pi = _wfClient.OpenProcessInstance(procId);
                foreach (client.XmlField xmlField in pi.XmlFields)
                {
                    var dRow = dt.NewRow();
                    dRow[Constants.SoProperties.ProcessInstance.XmlFieldName]  = xmlField.Name;
                    dRow[Constants.SoProperties.ProcessInstance.XmlFieldValue] = xmlField.Value;
                    dt.Rows.Add(dRow);
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Method to prune collection by removing errors for process instances that are not in error state anymore.
        /// </summary>
        /// <param name="client">K2 Client connection for retreiving specific process instances.</param>
        public void Prune(k2Client.Connection client, k2Mgnt.WorkflowManagementServer server)
        {
            int i = 0;

            while (i < Count)
            {
                bool found  = false;
                bool remove = false;
                k2Client.ProcessInstance procInst = null;

                // check if the process instance still exists and is not deleted
                if (ProcessInstanceExists(this[i].ProcInstId, server))
                {
                    // get the process instance that's logged
                    procInst = client.OpenProcessInstance(this[i].ProcInstId);
                    // process instance is still alive!
                    found = true;

                    // now determine whether or not the process instance is still in an error state.
                    // if it is no longer in an error state, flag that it can be removed from the error collection.
                    if (procInst.Status1 != k2Client.ProcessInstance.Status.Error)
                    {
                        remove = true;
                    }
                }

                // if the associated process instance is no longer in an error state OR it has since been
                // 'fixed and completed' or simply deleted, remove the error item from the error collection.
                if ((!found) || remove)
                {
                    RemoveAt(i);
                    _isDirty = true;
                }
                else
                {
                    i++;
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Method to update the error collection using the specified process instance object.
        /// </summary>
        /// <param name="processInstance"></param>
        public void Update(k2Mgnt.ErrorLog el, k2Client.Connection client)
        {
            // check if this error is logged / or if the same error ID if already logged
            if (!Exists(el.ID))
            {
                // get the process instance for the originator and startdate details
                k2Client.ProcessInstance procInst = client.OpenProcessInstance(el.ProcInstID);

                base.Add(
                    new K2ProcessError(
                        el.ID,
                        el.ProcInstID,
                        el.ProcessName,
                        el.Folio,
                        el.ErrorItemName,
                        el.Description,
                        el.ErrorDate,
                        procInst.StartDate,
                        procInst.Originator.FQN));

                _isDirty = true;
            }
        }