Ejemplo n.º 1
0
        /// <summary>
        /// If the request parameters other than @InCaller & @InCallerversion are null, returns a list of entries, otherwise returns a list of one entry.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static StatusCodeGetReplyDC StatusCodeGet(StatusCodeGetRequestDC request)
        {
            var reply = new StatusCodeGetReplyDC();
            var status = new StatusReplyDC();
            IList<StatusCodeAttributes> list = new List<StatusCodeAttributes>();
            StatusCodeAttributes sa = null;
            int retValue = 0;
            string outErrorString = string.Empty;
            Database db = null;
            DbCommand cmd = null;

            try
            {
                db = DatabaseFactory.CreateDatabase();
                cmd = db.GetStoredProcCommand(StoredProcNames.StatusCodeGet);
                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, "@inCode", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.InCode);
                db.AddParameter(cmd, "@inName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.InName);
                db.AddParameter(cmd, "@ReturnValue", DbType.Int32, ParameterDirection.ReturnValue, null, DataRowVersion.Default, 0);
                db.AddOutParameter(cmd, "@outErrorString", DbType.String, 300);

                using (IDataReader reader = db.ExecuteReader(cmd))
                {
                    while (reader.Read())
                    {
                        sa = new StatusCodeAttributes();
                        sa.Description = Convert.ToString(reader["Description"]) ?? string.Empty;
                        if (reader["IsDeleted"] == DBNull.Value)
                            sa.IsDeleted = false;
                        else
                            sa.IsDeleted = Convert.ToBoolean(reader["IsDeleted"]);
                        if (reader["IsEligibleForCleanUp"] == DBNull.Value)
                            sa.IsEligibleForCleanUp = false;
                        else
                            sa.IsEligibleForCleanUp = Convert.ToBoolean(reader["IsEligibleForCleanUp"]);
                        sa.LockForChanges = Convert.ToBoolean(reader["LockForChanges"]);
                        sa.Name = Convert.ToString(reader["Name"]);
                        sa.Code = Convert.ToInt32(reader["Code"]);
                        sa.ShowInProduction = Convert.ToBoolean(reader["ShowInProduction"]);
                        list.Add(sa);
                    }
                }

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

            reply.StatusReply = status;
            reply.List = list;
            return reply;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Verify GET FROM ltblStatusCodes Table for Valid Name
        /// </summary>
        /// <param name="name">name from row to do a get on</param>
        private void GetStatusCodeForValidName(string name)
        {
            getRequest = new StatusCodeGetRequestDC();
            getReply = null;

            getRequest.Incaller = IN_CALLER;
            getRequest.IncallerVersion = IN_CALLER_VERSION;

            getRequest.InName = name;

            try
            {
                getReply = devBranchProxy.StatusCodeGet(getRequest);
            }
            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, "StatusCodeGetRequestDC object null");
            Assert.IsNotNull(getReply.List, "getReply.List is null");
            Assert.AreEqual(1, getReply.List.Count, "Get returned the wrong number of entries. It should have returned 1 but instead returned {0}.", getReply.List.Count);
            Assert.IsNotNull(getReply.StatusReply, "getReply.StatusReply is null");
            Assert.AreEqual(getReply.List[0].Name, getRequest.InName);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Verify GET FROM ltblStatusCodes Table for Invalid IDs
        /// </summary>
        /// <param name="softDeletedIncode">incode of row to do a get on</param>
        private void VerifyGetStatusCodeForInvalidIncode(int inCode)
        {
            bool isFaultException = false;
            getRequest = new StatusCodeGetRequestDC();
            getReply = null;

            getRequest.Incaller = IN_CALLER;
            getRequest.IncallerVersion = IN_CALLER_VERSION;

            getRequest.InCode = inCode;

            try
            {
                getReply = devBranchProxy.StatusCodeGet(getRequest);
            }
            // Task 20943. Add fault exception validation.
            //catch (FaultException<www.microsoft.com.practices.EnterpriseLibrary._2007._01.wcf.validation.ValidationFault> exc)
            //{
            //    if (getRequest.InCode < 0)
            //    {
            //        Assert.IsNotNull(exc.Detail.Details);
            //        Assert.AreEqual(1, exc.Detail.Details.Count);
            //        Assert.IsNotNull(exc.Detail.Details[0].Message);
            //        Assert.AreEqual(CWF.Constants.SprocValues.INVALID_PARMETER_VALUE_InCode_MSG, exc.Detail.Details[0].Message);
            //        isFaultException = true;
            //    }
            //    else
            //    {
            //        Assert.Fail("Failed to get data from ltblStatusCodes: {0}", exc.Message);
            //    }
            //}
            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);
            }

            if (!isFaultException)
            {
                int errorConstant = GetErrorConstantInvalidIncode(inCode);

                Assert.IsNotNull(getReply, "getReply is null.");
                Assert.IsNotNull(getReply.StatusReply, "getReply.StatusReply is null");
                Assert.AreEqual(0, getReply.List.Count, "Service returned wrong number of records. InCode= {0}. It should have returned 0 but instead returned {1}.", inCode, getReply.List.Count);
                Assert.IsNotNull(getReply.StatusReply.ErrorMessage, "Error Message is null");
                Assert.AreEqual(errorConstant, getReply.StatusReply.Errorcode, "Service returned unexpected error code. Expected: {0}, Returned: {1}", errorConstant, getReply.StatusReply.Errorcode);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Verify GET FROM ltblStatusCodes Table for softDeleted IDs
        /// </summary>
        /// <param name="softDeletedIncode">incode of row to do a get on</param>
        private void GetStatusCodeForSoftDeletedIncodes(int softDeletedIncode)
        {
            getRequest = new StatusCodeGetRequestDC();

            // Populate Request
            getRequest.Incaller = IN_CALLER;
            getRequest.IncallerVersion = IN_CALLER_VERSION;
            getRequest.InCode = softDeletedIncode;

            try
            {
                getReply = devBranchProxy.StatusCodeGet(getRequest);
            }
            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);
            }

            int errorConstant = GetErrorConstantSoftDeletedID();

            Assert.IsNotNull(getReply, "getReply is null.");
            Assert.IsNotNull(getReply.StatusReply, "getReply.StatusReply is null");
            Assert.AreEqual(0, getReply.List.Count, "Service returned wrong number of records. InId= {0}. It should have returned 0 but instead returned {1}.", softDeletedIncode, getReply.List.Count);
            Assert.IsNotNull(getReply.StatusReply.ErrorMessage, "Error Message is null");
            Assert.AreEqual(errorConstant, getReply.StatusReply.Errorcode, "Service returned unexpected error code. Expected: {0}, Returned: {1}", errorConstant, getReply.StatusReply.Errorcode);
        }