Ejemplo n.º 1
0
        public EditWorkflowTypeViewModel(WorkflowTypeOperations operations, WorkflowTypeSearchDC workflowTypeParam, Action canUploadWorkflowType)
        {
            this.refreshCommandCanExecute = canUploadWorkflowType;
            this.BroswerPublishingWorkflowsCommand = new DelegateCommand(BrowserPublishingWorkflows);
            this.BroswerTemplateWorkflowsCommand = new DelegateCommand(BrowserTemplateWorkflows);
            if (workflowTypeParam != null)
                this.workflowType = workflowTypeParam;
            else
            {
                this.workflowType = new WorkflowTypeSearchDC();
                this.workflowType.Guid = Guid.NewGuid();
            }

            if (operations == WorkflowTypeOperations.Add)
                this.WindowTitle = addWorkflowType;
            else
                this.WindowTitle = editWorkflowType;
            this.Name = this.workflowType.Name;
            this.PublishingWorkflow = this.workflowType.PublishingWorkflow;
            this.PublishingWorkflowId = this.workflowType.PublishingWorkflowId;
            this.Template = this.workflowType.WorkflowTemplate;
            this.TemplateId = this.workflowType.WorkflowTemplateId;
            WorkflowsQueryServiceUtility.UsingClient(this.GetAuthGroups);
        }
        /// <summary>
        /// Search workflowtypes 
        /// </summary>
        /// <returns></returns>
        public static WorkflowTypeSearchReply SearchWorkflowTypes(WorkflowTypeSearchRequest request)
        {
            WorkflowTypeSearchReply reply = new WorkflowTypeSearchReply();
            IList<WorkflowTypeSearchDC> wftList = new List<WorkflowTypeSearchDC>();
            try
            {
                WorkflowTypeSearchDC wfat = null;

                Database db = DatabaseFactory.CreateDatabase();
                DbCommand cmd = db.GetStoredProcCommand(StoredProcNames.WorkflowType_Search);
                db.AddParameter(cmd, "@SearchText", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.SearchText);
                db.AddParameter(cmd, "@SortColumn", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.SortColumn);
                db.AddParameter(cmd, "@SortAscending", DbType.Boolean, ParameterDirection.Input, null, DataRowVersion.Default, request.SortAscending);
                db.AddParameter(cmd, "@PageSize", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.PageSize);
                db.AddParameter(cmd, "@PageNumber", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.PageNumber);

                using (IDataReader reader = db.ExecuteReader(cmd))
                {
                    while (reader.Read())
                    {
                        wfat =new WorkflowTypeSearchDC();

                        wfat.Guid = reader[DataColumnNames.Guid] != DBNull.Value ?(Guid)reader[DataColumnNames.Guid] : Guid.Empty;

                        wfat.Id = Convert.ToInt32(reader[DataColumnNames.Id]);

                        wfat.Name = Convert.ToString(reader[DataColumnNames.Name]);

                        wfat.AuthGroupId = Convert.ToInt32(reader[DataColumnNames.AuthGroupId]);

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

                        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.WorkflowTemplate = reader[DataColumnNames.WorkflowTemplateName] != DBNull.Value
                            ? Convert.ToString(reader[DataColumnNames.WorkflowTemplateName]) : string.Empty;

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

                        wfat.WorkflowTemplateId = reader[DataColumnNames.WorkflowTemplateId] != DBNull.Value
                            ? Convert.ToInt32(reader[DataColumnNames.WorkflowTemplateId]) : 0;

                        wfat.WorkflowsCount = reader[DataColumnNames.WorkflowsCount] != DBNull.Value
                            ? Convert.ToInt32(reader[DataColumnNames.WorkflowsCount]) : 0;

                        wftList.Add(wfat);
                    }

                    reply.SearchResults = wftList;
                    reader.NextResult();
                    if (reader.Read())
                    {
                        reply.ServerResultsLength = Convert.ToInt32(reader["Total"]);
                    }
                }
            }
            catch (SqlException e)
            {
                e.HandleException();
            }
            return reply;
        }