/// <summary>
 /// Add worklfow type or edit workflow type
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public static WorkFlowTypeCreateOrUpdateReplyDC WorkflowTypeCreateOrUpdate(WorkFlowTypeCreateOrUpdateRequestDC request)
 {
     WorkFlowTypeCreateOrUpdateReplyDC reply = null;
     try
     {
         reply = WorkflowTypeRepositoryService.WorkflowTypeCreateOrUpdate(request);
     }
     catch (Exception e)
     {
         throw new BusinessException(-1, e.Message);
     }
     return reply;
 }
        /// <summary>
        /// Delete WorkflowType by Id
        /// </summary>
        /// <param name="workflowTypeId"></param>
        private void DeleteWorkflowType(IWorkflowsQueryService client)
        {
            if (this.SelectedWorkflowType == null)
                return;
            if (this.SelectedWorkflowType.WorkflowsCount > 0)
            {
                MessageBoxService.ShowError(string.Format( "The {0} can't be deleted, because there are workflows using it.",this.SelectedWorkflowType.Name));
                return;
            }

            WorkFlowTypeCreateOrUpdateRequestDC request = new WorkFlowTypeCreateOrUpdateRequestDC();
            request.SetIncaller();
            request.InId = this.SelectedWorkflowType.Id;
            request.IsDeleted = true;
            request.InAuthGroupId = this.SelectedWorkflowType.AuthGroupId;
            request.InPublishingWorkflowId = this.SelectedWorkflowType.PublishingWorkflowId;
            request.InWorkflowTemplateId = this.SelectedWorkflowType.WorkflowTemplateId;
            WorkFlowTypeCreateOrUpdateReplyDC reply = client.WorkflowTypeCreateOrUpdate(request);
            if (reply != null && reply.StatusReply != null)
                reply.StatusReply.CheckErrors();
            this.GetWorkflowTypes(client);
        }
 /// <summary>
 /// Validate workflow type 
 /// Name length
 /// </summary>
 /// <returns></returns>
 private bool ValidWorkflowType(WorkFlowTypeCreateOrUpdateRequestDC request)
 {
     if (request == null)
         return false;
     if (request.InName.Length > maxNameLength)
     {
         throw new UserFacingException(nameTooLong);
     }
     return true;
 }
        /// <summary>
        /// Upload workflowtype to server
        /// </summary>
        public void UploadWorkflowType(IWorkflowsQueryService client)
        {
            WorkFlowTypeCreateOrUpdateRequestDC request = new WorkFlowTypeCreateOrUpdateRequestDC();
            request.SetIncaller();
            request.InGuid = this.workflowType.Guid;
            request.InId = this.workflowType.Id;
            request.InName = this.Name;
            request.InPublishingWorkflowId = this.PublishingWorkflowId;
            request.InWorkflowTemplateId = this.TemplateId;
            request.InAuthGroupId = this.SelectedAuthGroup != null ? this.SelectedAuthGroup.AuthGroupId : 0;
            request.IsDeleted = false;

            this.ValidWorkflowType(request);

            WorkFlowTypeCreateOrUpdateReplyDC reply = client.WorkflowTypeCreateOrUpdate(request);
            if (reply != null && reply.StatusReply != null)
            {
                try
                {
                    StatusReplyDC error = reply.StatusReply.CheckErrors();
                }
                catch (Exception ex)
                {
                    throw new UserFacingException(ex.Message);
                }
            }
        }
        /// <summary>
        /// If the parameter request.InId is valid, it is an update, otherwise it is a create operation.
        /// </summary>
        /// <param name="request">WorkFlowTypeCreateOrUpdateRequestDC object</param>
        /// <returns>WorkFlowTypeCreateOrUpdateReplyDC object</returns>
        public static WorkFlowTypeCreateOrUpdateReplyDC WorkflowTypeCreateOrUpdate(WorkFlowTypeCreateOrUpdateRequestDC request)
        {
            var reply = new WorkFlowTypeCreateOrUpdateReplyDC();
            var status = new StatusReplyDC();
            reply.StatusReply = status;
            Database db = null;
            DbCommand cmd = null;
            int retValue = 0;
            string outErrorString = string.Empty;
            try
            {
                db = DatabaseFactory.CreateDatabase();
                cmd = db.GetStoredProcCommand(StoredProcNames.WorkflowTypeCreateOrUpdate);
                db.AddParameter(cmd, "@inCaller", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Incaller);
                db.AddParameter(cmd, "@inCallerVersion", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.IncallerVersion);
                db.AddParameter(cmd, "@InHandleVariable", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.InHandleVariable);
                db.AddParameter(cmd, "@InId", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.InId);
                db.AddParameter(cmd, "@InGuid", DbType.Guid, ParameterDirection.Input, null, DataRowVersion.Default, request.InGuid);
                db.AddParameter(cmd, "@InName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.InName);
                db.AddParameter(cmd, "@InPageViewVariable", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.InPageViewVariable);

                db.AddParameter(cmd, "@InPublishingWorkflowId", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.InPublishingWorkflowId);
                db.AddParameter(cmd, "@InSelectionWorkflowId", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.InSelectionWorkflowId);
                db.AddParameter(cmd, "@InWorkflowTemplateId", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.InWorkflowTemplateId);
                db.AddParameter(cmd, "@InAuthGroupId", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.InAuthGroupId);
                db.AddParameter(cmd, "@InSoftDelete", DbType.Boolean, ParameterDirection.Input, null, DataRowVersion.Default, request.IsDeleted);

                db.AddParameter(cmd, "@InInsertedByUserAlias", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.InInsertedByUserAlias);
                db.AddParameter(cmd, "@InUpdatedByUserAlias", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.InUpdatedByUserAlias);

                db.AddParameter(cmd, "@ReturnValue", DbType.Int32, ParameterDirection.ReturnValue, null, DataRowVersion.Default, 0);
                db.AddOutParameter(cmd, "@outErrorString", DbType.String, 300);

                db.ExecuteScalar(cmd);
                retValue = Convert.ToInt32(cmd.Parameters["@ReturnValue"].Value);
                outErrorString = Convert.ToString(cmd.Parameters["@outErrorString"].Value);
                if (retValue != 0)
                {
                    status.ErrorMessage = outErrorString;
                    status.Errorcode = retValue;
                    Logging.Log(retValue,
                                EventLogEntryType.Error,
                                SprocValues.WORKFLOW_TYPE_CREATE_OR_UPDATE_CALL_ERROR_MSG,
                                outErrorString);
                }
            }
            catch (Exception ex)
            {
                status.ErrorMessage = SprocValues.WORKFLOW_TYPE_CREATE_OR_UPDATE_CALL_ERROR_MSG + ex.Message;
                status.Errorcode = SprocValues.GENERIC_CATCH_ID;
                Logging.Log(SprocValues.GENERIC_CATCH_ID,
                            EventLogEntryType.Error,
                            SprocValues.WORKFLOW_TYPE_CREATE_OR_UPDATE_CALL_ERROR_MSG,
                            ex);
            }

            reply.StatusReply = status;
            return reply;
        }
Exemple #6
0
        public void WorkflowTypeSearch()
        {
            //Test create a new workflow type
            WorkFlowTypeCreateOrUpdateRequestDC request = new WorkFlowTypeCreateOrUpdateRequestDC();
            WorkFlowTypeCreateOrUpdateReplyDC reply = null;
            request.Incaller = INCALLER;
            request.IncallerVersion = INCALLERVERSION;
            request.InGuid = Guid.NewGuid();
            request.InName = "TestType_" + request.InGuid.ToString();
            request.InInsertedByUserAlias = INSERTEDBYUSERALIAS;
            request.InAuthGroupId = 2;
            try
            {
                reply = WorkflowTypeBusinessService.WorkflowTypeCreateOrUpdate(request);
                Assert.IsNotNull(reply);
                Assert.AreEqual(reply.StatusReply.Errorcode, 0);

                WorkflowTypeSearchRequest searchRequest = new WorkflowTypeSearchRequest();
                searchRequest.Incaller = INCALLER;
                searchRequest.IncallerVersion = INCALLERVERSION;
                searchRequest.SearchText = "TestType";
                searchRequest.PageSize = 10;
                searchRequest.PageNumber = 1;
                WorkflowTypeSearchReply searchReply = WorkflowTypeBusinessService.SearchWorkflowTypes(searchRequest);

                Assert.IsNotNull(searchReply);
                Assert.AreEqual(searchReply.StatusReply.Errorcode, 0);
                Assert.IsTrue(searchReply.ServerResultsLength >= 1);
            }
            catch (Exception ex)
            {
                string faultMessage = ex.Message;
                Assert.Fail(faultMessage + "-catch (Exception ex) in reply = CWF.BAL.WorkflowTypeBusinessService.WorkflowTypeCreateOrUpdate();");
            }
        }