/// <summary>
        /// Creates or updates an mtblActivityLibraryDependencies entry
        /// </summary>
        /// <param name="request">request object</param>
        /// <returns>StoreActivityLibrariesDependenciesDC object</returns>
        public static StoreActivityLibrariesDependenciesDC StoreActivityLibraryDependenciesCreateOrUpdate(StoreActivityLibrariesDependenciesDC request)
        {
            var reply = new StoreActivityLibrariesDependenciesDC();
            var status = new StatusReplyDC();
            Database db = null;
            DbCommand cmd = null;
            int retValue = 0;
            string outErrorString = string.Empty;

            try
            {
                db = DatabaseFactory.CreateDatabase();
                cmd = db.GetStoredProcCommand(StoredProcNames.ActivityLibraryDependencyCreateOrUpdate);
                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, "@inActivityLibraryName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.StoreDependenciesRootActiveLibrary.ActivityLibraryName);
                db.AddParameter(cmd, "@inActivityLibraryVersionNumber", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.StoreDependenciesRootActiveLibrary.ActivityLibraryVersionNumber);
                db.AddParameter(cmd, "@inActivityLibraryDependentName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.StoreDependenciesDependentActiveLibraryList[0].ActivityLibraryDependentName);
                db.AddParameter(cmd, "@inActivityLibraryDependentVersionNumber", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.StoreDependenciesDependentActiveLibraryList[0].ActivityLibraryDependentVersionNumber);
                db.AddParameter(cmd, "@InInsertedByUserAlias", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.InsertedByUserAlias);
                db.AddParameter(cmd, "@InUpdatedByUserAlias", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.UpdatedByUserAlias);
                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.ACTIVITY_LIBRARY_DEPENDENCIES_CREATE_OR_UPDATE_CALL_ERROR_MSG,
                                outErrorString);
                }
            }
            catch (Exception ex)
            {
                status.ErrorMessage = SprocValues.ACTIVITY_LIBRARY_DEPENDENCIES_CREATE_OR_UPDATE_CALL_ERROR_MSG + ex.Message;
                status.Errorcode = SprocValues.GENERIC_CATCH_ID;
                Logging.Log(SprocValues.GENERIC_CATCH_ID,
                            EventLogEntryType.Error,
                            SprocValues.ACTIVITY_LIBRARY_DEPENDENCIES_CREATE_OR_UPDATE_CALL_ERROR_MSG,
                            ex);
            }

            reply.StatusReply = status;
            return reply;
        }
        /// <summary>
        /// Validates input and gets the list of all the dependencies in the dependency hierarchy for an an activity library.
        /// </summary>
        /// <param name="request">Request that defines the root activity library for which the dependencies are to be found.</param>
        /// <returns>Response that contains a list of dependencies.</returns>
        public static List<StoreActivityLibrariesDependenciesDC> GetActivityLibraryDependencyTree(StoreActivityLibrariesDependenciesDC request)
        {
            List<StoreActivityLibrariesDependenciesDC> reply = null;
            try
            {
                // Validates the input and throws ValidationException for any issues found.
                request.ValidateRequest();

                reply = ActivityLibraryDependencyRepositoryService.GetActivityLibraryDependencyTree(request);
            }
            catch (ValidationException e)
            {
                e.HandleException();
            }
            catch (DataAccessException e)
            {
                e.HandleException();
            }

            return reply;
        }
        /// <summary>
        /// Gets the list of all the dependencies in the dependency hierarchy for an an activity library.
        /// </summary>
        /// <param name="request">Request that defines the root activity library for which the dependencies are to be found.</param>
        /// <returns>Response that contains a list of dependencies.</returns>
        public static List<StoreActivityLibrariesDependenciesDC> GetActivityLibraryDependencyTree(StoreActivityLibrariesDependenciesDC request)
        {
            List<StoreActivityLibrariesDependenciesDC> reply = new List<StoreActivityLibrariesDependenciesDC>();
            StoreActivityLibrariesDependenciesDC dependencies = new StoreActivityLibrariesDependenciesDC();
            dependencies.StoreDependenciesRootActiveLibrary = new StoreDependenciesRootActiveLibrary();
            dependencies.StoreDependenciesDependentActiveLibraryList = new List<StoreDependenciesDependentActiveLibrary>();
            reply.Add(dependencies);

            try
            {
                Database database = DatabaseFactory.CreateDatabase();
                DbCommand command = null;
                command = database.GetStoredProcCommand(StoredProcNames.ActivityLibraryDependencyGetTree);

                database.AddParameter(command, StoredProcParamNames.Name, DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, Convert.ToString(request.StoreDependenciesRootActiveLibrary.ActivityLibraryName));
                database.AddParameter(command, StoredProcParamNames.Version, DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, Convert.ToString(request.StoreDependenciesRootActiveLibrary.ActivityLibraryVersionNumber));

                using (IDataReader reader = database.ExecuteReader(command))
                {
                    while (reader.Read())
                    {
                        StoreDependenciesDependentActiveLibrary dependentLib = new StoreDependenciesDependentActiveLibrary();
                        dependentLib.ActivityLibraryDependentId = Convert.ToInt32(reader[DataColumnNames.DependentActivityLibraryId]);
                        dependentLib.ActivityLibraryParentId = reader[DataColumnNames.ActivityLibraryId] != DBNull.Value ? Convert.ToInt32(reader[DataColumnNames.ActivityLibraryId]) : 0;
                        dependencies.StoreDependenciesDependentActiveLibraryList.Add(dependentLib);
                    }

                    if (!reader.IsClosed) reader.Close();
                }
            }
            catch (SqlException e)
            {
                e.HandleException();
            }

            return reply;
        }
        /// <summary>
        /// Verify GET FROM mtblActivityLibraryDependencies Table
        /// </summary>
        /// <param name="activitiyLibraryName">activitiyLibraryName to be used in the request</param>
        /// <param name="version">version to be used in the request</param>
        /// <param name="treeGet">if treeGet is true, a TreeGet is called, otherwise just a Get</param>
        /// <returns>returns the id of this row</returns>
        private int VerifyGetActivityLibraryDependencies(string activitiyLibraryName, string version, bool treeGet)
        {
            getRequest = new StoreActivityLibrariesDependenciesDC();
            getReplyList = new List<StoreActivityLibrariesDependenciesDC>();

            //Populate the request data
            getRequest.Incaller = IN_CALLER;
            getRequest.UpdatedByUserAlias = USER;
            getRequest.InsertedByUserAlias = USER;
            getRequest.IncallerVersion = IN_CALLER_VERSION;

            getRequest.StoreDependenciesRootActiveLibrary = new StoreDependenciesRootActiveLibrary();

            getRequest.StoreDependenciesRootActiveLibrary.ActivityLibraryVersionNumber = version;
            getRequest.StoreDependenciesRootActiveLibrary.ActivityLibraryName = activitiyLibraryName;

            try
            {
                getReplyList = new List<StoreActivityLibrariesDependenciesDC>(devBranchProxy.StoreActivityLibraryDependenciesTreeGet(getRequest));
            }
            catch (FaultException e)
            {
                Assert.Fail("Failed to get data from mtblActivityLibraryDependencies: {0}", e.Message);
            }
            catch (Exception ex)
            {
                Assert.Fail("Failed to get data from mtblActivityLibraryDependencies: {0}", ex.Message);
            }

            Assert.IsNotNull(getReplyList, "getReply.List is null");
            Assert.AreEqual(1, getReplyList.Count, "Get returned the wrong number of entries. activitiyLibraryName: {0}. It should have returned 1 but instead returned {1}.", activitiyLibraryName, getReplyList.Count);
            Assert.IsNotNull(getReplyList[0].StatusReply, "getReply.StatusReply is null");
            Assert.AreEqual(0, getReplyList[0].StatusReply.Errorcode, "StatusReply.Errorcode returned the wrong value. Errorcode: {0}", getReplyList[0].StatusReply.Errorcode);

            //bug 14840 for the next sprint
            //Assert.AreEqual(activitiyLibraryName, getReplyList[0].StoreDependenciesRootActiveLibrary.ActivityLibraryName, "Get returned the wrong ActivityLibraryName. Expected activitiyLibraryName: {0}. Actual ActivityLibraryName", activitiyLibraryName, getReplyList[0].StoreDependenciesRootActiveLibrary.ActivityLibraryName);
            //Assert.AreEqual(version, getReplyList[0].StoreDependenciesRootActiveLibrary.ActivityLibraryVersionNumber, "Get returned the wrong version. Expected version: {0}. Actual ActivityLibraryName", version, getReplyList[0].StoreDependenciesRootActiveLibrary.ActivityLibraryVersionNumber);
            Assert.IsNotNull(getReplyList[0].StoreDependenciesDependentActiveLibraryList, "StoreDependenciesDependentActiveLibraryList is null");
            Assert.AreNotEqual(0, getReplyList[0].StoreDependenciesDependentActiveLibraryList.Count, "StoreDependenciesDependentActiveLibraryList is empty");

            int id = getReplyList[0].StoreDependenciesDependentActiveLibraryList[0].ActivityLibraryParentId;
            return id;
        }
        /// <summary>
        /// Verify GET FROM mtblActivityLibraryDependencies Table
        /// </summary>
        /// <param name="activitiyLibraryName">activitiyLibraryName to be used in the request</param>
        /// <param name="version">version to be used in the request</param>
        /// <param name="treeGet">if treeGet is true, a TreeGet is called, otherwise just a Get</param>
        private void GetActivityLibraryDependenciesForInvalidNameOrVersion(string activitiyLibraryName, string version, bool isTreeGet)
        {
            bool isFaultException = false;

            getRequest = new StoreActivityLibrariesDependenciesDC();
            getReplyList = new List<StoreActivityLibrariesDependenciesDC>();

            //Populate the request data
            getRequest.Incaller = IN_CALLER;
            getRequest.IncallerVersion = IN_CALLER_VERSION;
            getRequest.InsertedByUserAlias = USER;
            getRequest.UpdatedByUserAlias = USER;

            getRequest.StoreDependenciesRootActiveLibrary = new StoreDependenciesRootActiveLibrary();

            getRequest.StoreDependenciesRootActiveLibrary.ActivityLibraryName = activitiyLibraryName;
            getRequest.StoreDependenciesRootActiveLibrary.ActivityLibraryVersionNumber = version;

            try
            {
                if (isTreeGet)
                {
                    getReplyList = new List<StoreActivityLibrariesDependenciesDC>(devBranchProxy.StoreActivityLibraryDependenciesTreeGet(getRequest));
                }
            }
            catch (FaultException e)
            {
                Assert.Fail("Failed to get data from mtblActivityLibraryDependencies: {0}", e.Message);
            }
            catch (Exception ex)
            {
                Assert.Fail("Failed to get data from mtblActivityLibraryDependencies: {0}", ex.Message);
            }

            if (!isFaultException)
            {
                int errorCode = GetErrorCodeForActivityLibraryDependencies(activitiyLibraryName, version);
                Assert.IsNotNull(getReplyList, "getReply.List is null");
                Assert.AreEqual(1, getReplyList.Count, "Get returned the wrong number of entries. activitiyLibraryName: {0}. It should have returned 1 but instead returned {1}.", activitiyLibraryName, getReplyList.Count);
                Assert.IsNotNull(getReplyList[0].StatusReply, "getReply.StatusReply is null");
                Assert.AreEqual(errorCode, getReplyList[0].StatusReply.Errorcode, "StatusReply.Errorcode returned the wrong value. Errorcode: {0}", getReplyList[0].StatusReply.Errorcode);
            }
        }
        /// <summary>
        /// Verify CreateActivityLibrariesDependencyList FROM mtblActivityLibraryDependencies Table..
        /// </summary>
        /// <param name="activitiyLibraryName">activitiyLibraryName to do a create or update on.</param>
        /// <param name="version">version to do a create or update on.</param>
        /// <param name="activityLibraryDependentName">activityLibraryDependentName to do a create or update on.</param>
        /// <returns>returns the id created</returns>
        private int CreateActivityLibrariesDependencyList(int activitiyLibraryId, string activitiyLibraryName, string version, 
            int activityLibraryDependentId, string activityLibraryDependentName, string versionDependent)
        {
            createOrUpdateReply = null;

            //Populate the request data
            createOrUpdateRequest = new StoreActivityLibrariesDependenciesDC();
            createOrUpdateRequest.Incaller = IN_CALLER;
            createOrUpdateRequest.UpdatedByUserAlias = USER;
            createOrUpdateRequest.InsertedByUserAlias = USER;
            createOrUpdateRequest.IncallerVersion = IN_CALLER_VERSION;

            var storeDependenciesActivityLib = new StoreDependenciesRootActiveLibrary();
            storeDependenciesActivityLib.ActivityLibraryId = activitiyLibraryId;
            storeDependenciesActivityLib.ActivityLibraryName = activitiyLibraryName;
            storeDependenciesActivityLib.ActivityLibraryVersionNumber = version;

            //Set Request StoreDependenciesRootActiveLibrary object
            createOrUpdateRequest.StoreDependenciesRootActiveLibrary = storeDependenciesActivityLib;

            var storeDependenciesDependentActiveLibraryList = new List<StoreDependenciesDependentActiveLibrary>();
            StoreDependenciesDependentActiveLibrary storeDependenciesDependentActiveLibrary = new StoreDependenciesDependentActiveLibrary();
            storeDependenciesDependentActiveLibrary.ActivityLibraryDependentId = activityLibraryDependentId;
            storeDependenciesDependentActiveLibrary.ActivityLibraryDependentName = activityLibraryDependentName;
            storeDependenciesDependentActiveLibrary.ActivityLibraryDependentVersionNumber = versionDependent;
            storeDependenciesDependentActiveLibraryList.Add(storeDependenciesDependentActiveLibrary);

            //set StoreDependenciesDependentActiveLibraryList object
            createOrUpdateRequest.StoreDependenciesDependentActiveLibraryList = storeDependenciesDependentActiveLibraryList;

            try
            {
                createOrUpdateReply = devBranchProxy.StoreActivityLibraryDependencyList(createOrUpdateRequest);
            }
            catch (FaultException e)
            {
                Assert.Fail("Failed to createOrUpdate data from mtblActivityLibraryDependencies: {0}", e.Message);
            }
            catch (Exception ex)
            {
                Assert.Fail("Failed to createOrUpdate data from mtblActivityLibraryDependencies: {0}", ex.Message);
            }

            Assert.IsNotNull(createOrUpdateReply, "StoreActivityLibrariesDependenciesDC object null");
            Assert.IsNotNull(createOrUpdateReply.StatusReply, "createOrUpdateReply.StatusReply is null");
            Assert.AreEqual(0, createOrUpdateReply.StatusReply.Errorcode, "createOrUpdateReply.StatusReply.Errorcode is not 0. Instead it is {0}.", createOrUpdateReply.StatusReply.Errorcode);

            int activityLibraryId = VerifyGetActivityLibraryDependencies(activitiyLibraryName, version, false);
            Assert.IsNotNull(getReplyList, "getReplyList is null.");
            Assert.AreNotEqual(0, getReplyList.Count, " getReply.List.Count is 0.");

            return activityLibraryId;
        }
Exemple #7
0
        public void StoreActivityLibraryDependencyListBADdependencyActivityLibrary()
        {
            CWF.DataContracts.StoreActivityLibrariesDependenciesDC request = new CWF.DataContracts.StoreActivityLibrariesDependenciesDC();
            CWF.DataContracts.StoreDependenciesRootActiveLibrary rdl = new CWF.DataContracts.StoreDependenciesRootActiveLibrary();
            CWF.DataContracts.StoreActivityLibrariesDependenciesDC reply = null;
            List<CWF.DataContracts.StoreDependenciesDependentActiveLibrary> dalList = new List<CWF.DataContracts.StoreDependenciesDependentActiveLibrary>();

            request.InsertedByUserAlias = INSERTEDBYUSERALIAS;
            request.UpdatedByUserAlias = UPDATEDBYUSERALIAS;
            request.Incaller = INCALLER;
            request.IncallerVersion = INCALLERVERSION;
            rdl.ActivityLibraryName = "TEST#200";
            rdl.ActivityLibraryVersionNumber = "1.0.0.4";

            request.StoreDependenciesRootActiveLibrary = rdl;
            request.StoreDependenciesDependentActiveLibraryList = dalList;

            try
            {
                reply = CWF.BAL.Services.StoreActivityLibraryDependencyList(request);
            }
            catch (Exception ex)
            {
                string faultMessage = ex.Message;
                Assert.Fail(faultMessage + "-catch (Exception ex) on reply = CWF.BAL.StoreActivityLibraryDependencies.StoreActivityLibraryDependencyList(request);");
            }

            Assert.IsNull(reply);
        }
Exemple #8
0
        public void BALActivityLibraryDependenciesTreeGet()
        {
            var request = new CWF.DataContracts.StoreActivityLibrariesDependenciesDC();
            var rdl = new CWF.DataContracts.StoreDependenciesRootActiveLibrary();
            List<CWF.DataContracts.StoreActivityLibrariesDependenciesDC> reply = null;

            request.Incaller = INCALLER;
            request.IncallerVersion = INCALLERVERSION;
            rdl.ActivityLibraryName = "OASP.Core";
            rdl.ActivityLibraryVersionNumber = "2.2.108.0";
            request.StoreDependenciesRootActiveLibrary = rdl;

            //// TreeGet
            try
            {
                reply = ActivityLibraryDependencyBusinessService.GetActivityLibraryDependencyTree(request);
            }
            catch (Exception ex)
            {
                string faultMessage = ex.Message;
                Assert.Fail(faultMessage + "-catch (Exception ex) in reply = CWF.DAL.Activities.StoreActivityLibraryDependenciesTreeGet(request, treeGet)");
            }

            Assert.IsNotNull(reply);
            Assert.AreEqual(SprocValues.REPLY_ERRORCODE_VALUE_OK, reply[0].StatusReply.Errorcode);
        }
        /// <summary>
        /// Stores the list of library dependencies
        /// </summary>
        /// <param name="request">request object</param>
        /// <returns>StoreActivityLibrariesDependenciesDC with StatusReply</returns>
        public static StoreActivityLibrariesDependenciesDC StoreActivityLibraryDependencyList(StoreActivityLibrariesDependenciesDC request)
        {
            StatusReplyDC statusReply = new StatusReplyDC();
            //// StoreDependenciesDependentActiveLibrary  dal = null;
            StoreActivityLibrariesDependenciesDC storeActivityLibrariesDependenciesDC = new StoreActivityLibrariesDependenciesDC();
            storeActivityLibrariesDependenciesDC.StoreDependenciesDependentActiveLibraryList = new List<StoreDependenciesDependentActiveLibrary>();
            storeActivityLibrariesDependenciesDC.StoreDependenciesRootActiveLibrary = request.StoreDependenciesRootActiveLibrary;
            StoreActivityLibrariesDependenciesDC reply = null;

            using (TransactionScope ts = new TransactionScope())
            {
                try
                {
                    if (request == null)
                    {
                        statusReply.Errorcode = Constants.SprocValues.REQUEST_OBJECT_IS_NULL_ID;
                        statusReply.ErrorMessage = Constants.SprocValues.REQUEST_OBJECT_IS_NULL_MSG;
                        throw new Exception(statusReply.ErrorMessage);
                    }

                    if (request.StoreDependenciesRootActiveLibrary == null)
                    {
                        statusReply.Errorcode = Constants.SprocValues.REQUEST_ACTION_STORE_DEPENDENCIES_ROOTACTIVITY_LIBRARY_IS_NULL_ID;
                        statusReply.ErrorMessage = Constants.SprocValues.REQUEST_ACTION_STORE_DEPENDENCIES_ROOTACTIVITY_LIBRARY_IS_NULL_MSG;
                        throw new Exception(statusReply.ErrorMessage);
                    }

                    if (request.StoreDependenciesDependentActiveLibraryList == null)
                    {
                    statusReply.Errorcode = Constants.SprocValues.REQUEST_ACTION_STORE_DEPENDENCIES_DEPENDENT_ACTIVITY_LIBRARY_IS_NULL_ID;
                        statusReply.ErrorMessage = Constants.SprocValues.REQUEST_ACTION_STORE_DEPENDENCIES_DEPENDENT_ACTIVITY_LIBRARY_IS_NULL_MSG;
                        throw new Exception(statusReply.ErrorMessage);
                    }

                    storeActivityLibrariesDependenciesDC.StoreDependenciesRootActiveLibrary = request.StoreDependenciesRootActiveLibrary;
                    //// CreateOrUpdate ActivityLibraryDependencies
                    foreach (var dependentLibrary in request.StoreDependenciesDependentActiveLibraryList)
                    {
                        storeActivityLibrariesDependenciesDC.StoreDependenciesDependentActiveLibraryList.Add(dependentLibrary);
                        storeActivityLibrariesDependenciesDC.Incaller = request.Incaller;
                        storeActivityLibrariesDependenciesDC.IncallerVersion = request.IncallerVersion;
                        storeActivityLibrariesDependenciesDC.InsertedByUserAlias = request.InsertedByUserAlias;
                        storeActivityLibrariesDependenciesDC.UpdatedByUserAlias = request.UpdatedByUserAlias;
                        reply = DAL.Activities.StoreActivityLibraryDependenciesCreateOrUpdate(storeActivityLibrariesDependenciesDC);
                        if (reply.StatusReply.Errorcode != 0)
                            throw new Exception(reply.StatusReply.ErrorMessage);
                        storeActivityLibrariesDependenciesDC.StoreDependenciesDependentActiveLibraryList.Remove(dependentLibrary);
                    }
                }
                catch (TransactionAbortedException)
                {
                    //// TODO temp removal of faults tex case
                    //// throw new FaultException(new FaultReason(Convert.ToString(reply.StatusReply.Errorcode) + "|" + reply.StatusReply.ErrorMessage));
                    statusReply.ErrorMessage = reply.StatusReply.ErrorMessage;
                    statusReply.Errorcode = reply.StatusReply.Errorcode;
                }
                catch (Exception)
                {
                    //// TODO temp removal of faults ex case
                    //// throw new FaultException(new FaultReason(Convert.ToString(reply.StatusReply.Errorcode) + "|" + reply.StatusReply.ErrorMessage));
                    statusReply.ErrorMessage = reply.StatusReply.ErrorMessage;
                    statusReply.Errorcode = reply.StatusReply.Errorcode;
                }

                ts.Complete();
            }

            return reply;
        }