/// <summary>
        /// Performs input validation and gets activity categories by ID, Name or by ID & Name.
        /// </summary>
        /// <param name="request">Request.</param>
        /// <returns>List of activity categories found.</returns>
        public static List<ActivityCategoryByNameGetReplyDC> GetActivityCategories(ActivityCategoryByNameGetRequestDC request)
        {
            List<ActivityCategoryByNameGetReplyDC> reply = null;
            try
            {
                // Validates the input and throws ValidationException for any issues found.
                request.ValidateRequest();

                reply = ActivityCategoryRepositoryService.GetActivityCategories(request);
            }
            catch (ValidationException e)
            {
                e.HandleException();
            }
            catch (DataAccessException e)
            {
                e.HandleException();
            }

            return reply;
        }
        /// <summary>
        /// Gets activity categories by ID, Name or by ID & Name.
        /// </summary>
        /// <param name="request">Request.</param>
        /// <returns>List of activity categories found.</returns>
        public static List<ActivityCategoryByNameGetReplyDC> GetActivityCategories(ActivityCategoryByNameGetRequestDC request)
        {
            List<ActivityCategoryByNameGetReplyDC> reply = null;

            try
            {
                Database database = DatabaseFactory.CreateDatabase();
                DbCommand command = database.GetStoredProcCommand(StoredProcNames.ActivityCategoryGet);
                database.AddParameter(command, StoredProcParamNames.Id, DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.InId);
                database.AddParameter(command, StoredProcParamNames.Name, DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.InName);

                using (IDataReader reader = database.ExecuteReader(command))
                {
                    ActivityCategoryByNameGetReplyDC activityCategoryEntry = null;
                    reply = new List<ActivityCategoryByNameGetReplyDC>();
                    while (reader.Read())
                    {
                        activityCategoryEntry = new ActivityCategoryByNameGetReplyDC();
                        activityCategoryEntry.Guid = new Guid(Convert.ToString(reader[DataColumnNames.Guid]));
                        activityCategoryEntry.Description = Convert.ToString(reader[DataColumnNames.Description]) ?? string.Empty;
                        activityCategoryEntry.Id = Convert.ToInt32(reader[DataColumnNames.Id]);
                        activityCategoryEntry.MetaTags = Convert.ToString(reader[DataColumnNames.MetaTags]) ?? string.Empty;
                        activityCategoryEntry.Name = Convert.ToString(reader[DataColumnNames.Name]);
                        activityCategoryEntry.AuthGroupId = Convert.ToInt32(reader[DataColumnNames.AuthGroupId]);
                        activityCategoryEntry.AuthGroupName = Convert.ToString(reader[DataColumnNames.AuthGroupName]);
                        reply.Add(activityCategoryEntry);
                    }
                }
            }
            catch (SqlException e)
            {
                e.HandleException();
            }

            return reply;
        }
        /// <summary>
        /// Verify GET FROM ltblActivityCategory Table for Valid IDs
        /// </summary>
        /// <param name="id">id of row to do a get on</param>
        private void GetActivityCategoriesForValidIDs(int id)
        {
            getByNameRequest = new ActivityCategoryByNameGetRequestDC();
            getByNameReplyList = new List<ActivityCategoryByNameGetReplyDC>();

            getByNameRequest.Incaller = IN_CALLER;
            getByNameRequest.IncallerVersion = IN_CALLER_VERSION;

            getByNameRequest.InId = id;

            try
            {
                getByNameReplyList = new List<ActivityCategoryByNameGetReplyDC>(devBranchProxy.ActivityCategoryGet(getByNameRequest));
            }
            catch (FaultException ex)
            {
                Assert.Fail("Caught WCF FaultException: 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);
            }

            // Validate
            Assert.IsNotNull(getByNameReplyList, "getByNameReplyList is null.");
            Assert.AreEqual(1, getByNameReplyList.Count, "getByNameReplyList.Count is not 1.");
            Assert.IsNotNull(getByNameReplyList[0].StatusReply, "getByNameReplyList[0].StatusReply is null");
            Assert.AreEqual(0, getByNameReplyList[0].StatusReply.Errorcode, "StatusReply.Errorcode is not 0. Instead it is {0}.", getByNameReplyList[0].StatusReply.Errorcode);
            Assert.IsTrue(string.IsNullOrEmpty(getByNameReplyList[0].StatusReply.ErrorMessage), "Error Message is not null. Error Message: {0}", getByNameReplyList[0].StatusReply.ErrorMessage);
            Assert.IsTrue(string.IsNullOrEmpty(getByNameReplyList[0].StatusReply.ErrorGuid), "ErrorGuid is not null. ErrorGuid: {0}", getByNameReplyList[0].StatusReply.ErrorGuid);
            Assert.AreEqual(getByNameRequest.InId, getByNameReplyList[0].Id, "Service returned the wrong record. Expected Id: {0}, Actual Id: {1}", getByNameRequest.InId, getByNameReplyList[0].Id);
        }
        /// <summary>
        /// Verify GET FROM ltblActivityCategory Table for a valid name
        /// </summary>
        /// <param name="name">name from row to do a get on</param>
        /// <returns>returns the id of this row</returns>
        private int GetActivityCategoriesForValidName(string name)
        {
            getByNameRequest = new ActivityCategoryByNameGetRequestDC();
            getByNameReplyList = new List<ActivityCategoryByNameGetReplyDC>();

            getByNameRequest.Incaller = IN_CALLER;
            getByNameRequest.IncallerVersion = IN_CALLER_VERSION;

            getByNameRequest.InName = name;

            try
            {
                getByNameReplyList = new List<ActivityCategoryByNameGetReplyDC>(devBranchProxy.ActivityCategoryGet(getByNameRequest));
            }
            catch (FaultException ex)
            {
                Assert.Fail("Caught WCF FaultException: 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);
            }

            // Validate
            Assert.IsNotNull(getByNameReplyList, "getByNameReplyList is null.");
            Assert.AreNotEqual(0, getByNameReplyList.Count, "getByNameReplyList.Count is 0");
            Assert.IsNotNull(getByNameReplyList[0].StatusReply, "getByNameReplyList[0].StatusReply is null");
            Assert.IsTrue(string.IsNullOrEmpty(getByNameReplyList[0].StatusReply.ErrorMessage), "Error Message is not null. Error Message: {0}", getByNameReplyList[0].StatusReply.ErrorMessage);
            Assert.IsTrue(string.IsNullOrEmpty(getByNameReplyList[0].StatusReply.ErrorGuid), "ErrorGuid is not null. ErrorGuid: {0}", getByNameReplyList[0].StatusReply.ErrorGuid);
            int id = getByNameReplyList[0].Id;

            return id;
        }
        /// <summary>
        /// Verify GET FROM ltblActivityCategory Table for softDeleted IDs
        /// </summary>
        /// <param name="getByNameRequest">object to do a get on</param>
        private void GetActivityCategoriesForSoftDeletedIDs(ActivityCategoryByNameGetRequestDC getByNameRequest)
        {
            getByNameReplyList = new List<ActivityCategoryByNameGetReplyDC>();

            try
            {
                getByNameReplyList = new List<ActivityCategoryByNameGetReplyDC>(devBranchProxy.ActivityCategoryGet(getByNameRequest));
            }
            catch (FaultException ex)
            {
                Assert.Fail("Caught WCF FaultException: 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);
            }

            int errorConstant = GetErrorConstantSoftDeletedID();

            // Validate
            Assert.IsNotNull(getByNameReplyList, "getByNameReplyList is null.");
            Assert.AreNotEqual(0, getByNameReplyList.Count, "getByNameReplyList.Count is 0");
            Assert.IsNotNull(getByNameReplyList[0].StatusReply, "getByNameReplyList[0].StatusReply is null");
            Assert.IsNotNull(getByNameReplyList[0].StatusReply.ErrorMessage, "Error Message is null.");
            Assert.AreEqual(errorConstant, getByNameReplyList[0].StatusReply.Errorcode, "Returned the wrong status error code. InId: {0}", getByNameRequest.InId);
        }
        /// <summary>
        /// Verify GET FROM ltblActivityCategory Table for softDeleted IDs
        /// </summary>
        /// <param name="softDeletedID">id of row to do a get on</param>
        private void GetActivityCategoriesForSoftDeletedIDs(int softDeletedID)
        {
            getByNameRequest = new ActivityCategoryByNameGetRequestDC();

            getByNameRequest.Incaller = IN_CALLER;
            getByNameRequest.IncallerVersion = IN_CALLER_VERSION;

            getByNameRequest.InId = softDeletedID;

            GetActivityCategoriesForSoftDeletedIDs(getByNameRequest);
        }
        /// <summary>
        /// Verify GET FROM ltblActivityCategory Table for Invalid IDs
        /// </summary>
        /// <param name="nonExistingID">id of row to do a get on</param>
        private void GetActivityCategoriesForInvalidIDs(int nonExistingID)
        {
            bool isFaultException = false;

            getByNameRequest = new ActivityCategoryByNameGetRequestDC();
            getByNameReplyList = new List<ActivityCategoryByNameGetReplyDC>();

            getByNameRequest.Incaller = IN_CALLER;
            getByNameRequest.IncallerVersion = IN_CALLER_VERSION;

            getByNameRequest.InId = nonExistingID;

            try
            {
                getByNameReplyList = new List<ActivityCategoryByNameGetReplyDC>(devBranchProxy.ActivityCategoryGet(getByNameRequest));
            }
            catch (FaultException ex)
            {
                Assert.Fail("Caught WCF FaultException: 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);
            }

            if (!isFaultException)
            {

                // Validate
                Assert.IsNotNull(getByNameReplyList, "getByNameReplyList is null.");
                Assert.AreNotEqual(0, getByNameReplyList.Count, "getByNameReplyList.Count is 0");
                Assert.IsNotNull(getByNameReplyList[0].StatusReply, "getByNameReplyList[0].StatusReply is null");
                Assert.IsTrue(string.IsNullOrEmpty(getByNameReplyList[0].StatusReply.ErrorMessage), "Error Message is null.");

                int id = getByNameReplyList[0].Id;
                Assert.IsFalse(id > 1, "Id should be gereater than 1");

                //int errorConstant = GetErrorConstantInvalidID(nonExistingID);
                //Assert.AreNotEqual(errorConstant, getByNameReplyList[0].StatusReply.Errorcode, "Returned the wrong status error code. InId: {0}", nonExistingID);
            }
        }
Example #8
0
        public void BALActivityCategoryGet()
        {
            List<CWF.DataContracts.ActivityCategoryByNameGetReplyDC> reply = null;
            try
            {
                CWF.DataContracts.ActivityCategoryByNameGetRequestDC request = new CWF.DataContracts.ActivityCategoryByNameGetRequestDC();
                request.Incaller = INCALLER;
                request.IncallerVersion = "1.0.0.0";
                request.InName = "OAS Basic Controls";

                try
                {
                    reply = ActivityCategoryBusinessService.GetActivityCategories(request);
                }
                catch (Exception ex)
                {
                    string faultMessage = ex.Message;
                    Assert.Fail(faultMessage + "-catch (Exception ex) in reply = CWF.DAL.Activities.ActivityCategoryGet(request);");
                }
            }
            catch (Exception ex)
            {
                string faultMessage = ex.Message;
            }

            Assert.IsNotNull(reply);
            Assert.AreEqual(reply[0].StatusReply.Errorcode, SprocValues.REPLY_ERRORCODE_VALUE_OK);
        }
Example #9
0
        /// <summary>
        /// Get a list of activity categories from the asset store.
        /// </summary>
        public static bool GetActivityCategories()
        {
            using (var client = WorkflowsQueryServiceUtility.GetWorkflowQueryServiceClient())
            {
                var request = new ActivityCategoryByNameGetRequestDC
                {
                    Incaller = Assembly.GetExecutingAssembly().GetName().Name,
                    IncallerVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(),
                    InInsertedByUserAlias = Environment.UserName,
                    InUpdatedByUserAlias = Environment.UserName
                };

                var categoriesCollection = client.ActivityCategoryGet(request);

                categoriesCollection.Add(new ActivityCategoryByNameGetReplyDC { Name = String.Empty }); // we need a blank entry in the import wizard on step #2

                Categories.Assign(from category in categoriesCollection select category.Name);

                ActivityCategories = new CollectionViewSource { Source = Categories };
                ActivityCategories.SortDescriptions.Add(new SortDescription("", ListSortDirection.Ascending));
                return true;
            }
        }