/// <summary>
        /// Get workflow types either by Id or by Name.  If none is specified, returns all the 
        /// workflow types.
        /// </summary>
        /// <param name="id">Workflow type ID.</param>
        /// <param name="name">Workflow type name.</param>
        /// <returns>Reply that contains the list of workflow types found.</returns>
        public static WorkflowTypeGetReplyDC GetWorkflowTypes(int id = 0, string name = "")
        {
            WorkflowTypeGetReplyDC reply = new WorkflowTypeGetReplyDC();
            IList<WorkflowTypesGetBase> wftList = new List<WorkflowTypesGetBase>();
            try
            {
                WorkflowTypesGetBase wfat = null;

                Database db = DatabaseFactory.CreateDatabase();
                DbCommand cmd = db.GetStoredProcCommand(StoredProcNames.WorkflowTypeGet);
                db.AddParameter(cmd, StoredProcParamNames.Id, DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, id);
                db.AddParameter(cmd, StoredProcParamNames.Name, DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, name);

                using (IDataReader reader = db.ExecuteReader(cmd))
                {
                    while (reader.Read())
                    {
                        wfat = new WorkflowTypesGetBase();
                        wfat.AuthGroupId = Convert.ToInt32(reader[DataColumnNames.AuthGroupId]);
                        wfat.AuthGroupName = reader[DataColumnNames.AuthGroupName] != DBNull.Value ? Convert.ToString(reader[DataColumnNames.AuthGroupName]) : string.Empty;
                        wfat.Guid = (Guid)reader[DataColumnNames.Guid];
                        wfat.HandleVariableId = reader[DataColumnNames.HandleVariableId] != DBNull.Value
                            ? Convert.ToInt32(reader[DataColumnNames.HandleVariableId]) : 0;
                        wfat.Id = Convert.ToInt32(reader[DataColumnNames.Id]);
                        wfat.Name = Convert.ToString(reader[DataColumnNames.Name]);
                        wfat.PageViewVariableId = reader[DataColumnNames.PageViewVariableId] != DBNull.Value
                            ? Convert.ToInt32(reader[DataColumnNames.PageViewVariableId]) : 0;
                        wfat.PublishingWorkflow = reader[DataColumnNames.PublishingWorkflowName] != DBNull.Value
                            ? Convert.ToString(reader[DataColumnNames.PublishingWorkflowName]) : string.Empty;

                        wfat.PublishingWorkflowVersion = reader[DataColumnNames.PublishingWorkflowVersion] != DBNull.Value
                            ? Convert.ToString(reader[DataColumnNames.PublishingWorkflowVersion]) : string.Empty;

                        wfat.PublishingWorkflowId = reader[DataColumnNames.PublishingWorkflowId] != DBNull.Value
                            ? Convert.ToInt32(reader[DataColumnNames.PublishingWorkflowId]) : 0;
                        wfat.SelectionWorkflowId = reader[DataColumnNames.SelectionWorkflowId] != DBNull.Value
                            ? Convert.ToInt32(reader[DataColumnNames.SelectionWorkflowId]) : 0;
                        wfat.WorkflowTemplate = reader[DataColumnNames.WorkflowTemplateName] != DBNull.Value
                            ? Convert.ToString(reader[DataColumnNames.WorkflowTemplateName]) : string.Empty;
                        wfat.WorkflowTemplateId = reader[DataColumnNames.WorkflowTemplateId] != DBNull.Value
                            ? Convert.ToInt32(reader[DataColumnNames.WorkflowTemplateId]) : 0;
                        wftList.Add(wfat);
                    }

                    reply.WorkflowActivityType = wftList;
                }
            }
            catch (SqlException e)
            {
                e.HandleException();
            }

            return reply;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Verify the WCF call WorkflowTypeGet
        /// </summary>
        private void WorkflowGet()
        {
            getReply = null;

            try
            {
                getReply = devBranchProxy.WorkflowTypeGet();
            }
            catch (FaultException ex)
            {
                Assert.Fail("Caught WCF FaultExceptionException: Message: {0} \n Stack Trace: {1}", ex.Message, ex.StackTrace);
            }
            catch (Exception e)
            {
                Assert.Fail("Caught Exception Invoking the Service. Message: {0} \n Stack Trace: {1}", e.Message, e.StackTrace);
            }

            Assert.IsNotNull(getReply, "WorkflowTypeGetReplyDC object null");
            Assert.IsNotNull(getReply.StatusReply, "getReply.StatusReply is null");
            Assert.AreEqual(0, getReply.StatusReply.Errorcode, "getFromNameAndVersionReply.StatusReply. Errorcode is not 0. Instead it is {0}.", getReply.StatusReply.Errorcode);
            Assert.IsNotNull(getReply.WorkflowActivityType);
        }