Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="objSetSKUMetadataRequest"></param>
        /// <param name="objSetSKUMetadataResponse"></param>
        /// <returns></returns>
        public bool ProcessRequest(SetSKUMetadataRequest objSetSKUMetadataRequest, SetSKUMetadataResponse objSetSKUMetadataResponse)
        {
            bool   flag      = false;
            string statusMsg = string.Empty;

            try
            {
                #region codestart
                DataSet ds = new DataSet();
                if (objSetSKUMetadataRequest.SKUMetadata.SKUID != null)
                {
                    statusMsg = SetSKUMetadata(objSetSKUMetadataRequest);
                }
                if ((!string.IsNullOrEmpty(statusMsg)) && (statusMsg.Contains("Record already exists") || statusMsg.Contains("No record exists")))
                {
                    objSetSKUMetadataResponse.ResponseStatus  = 1;
                    objSetSKUMetadataResponse.ResponseMessage = statusMsg;
                    flag = false;
                }
                else
                {
                    objSetSKUMetadataResponse.ResponseStatus  = (int)Constants.ResponseStatus.Success;
                    objSetSKUMetadataResponse.ResponseMessage = statusMsg;
                    flag = true;
                }



                #endregion
            }
            catch (Exception ex)
            {
                throw new Exception("Error Occured While getting the output of ProcessRequest method related to SetSKUMetadata. " + ex.Message + Environment.NewLine + ex.StackTrace);
            }

            return(flag);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="objSetSoftwareMetadataRequest"></param>
        /// <returns></returns>
        public SetSKUMetadataResponse SetSKUMetadata(SetSKUMetadataRequest objSetSKUMetadataRequest)
        {
            var objSetSKUMetadataResponse = new SetSKUMetadataResponse();

            objSetSKUMetadataResponse.RequestID        = objSetSKUMetadataRequest.RequestID;
            objSetSKUMetadataResponse.ResponseID       = objSetSKUMetadataRequest.RequestID;
            objSetSKUMetadataResponse.ResponseDateTime = DateTime.UtcNow;
            objSetSKUMetadataResponse.ResponseStatus   = (int)Constants.ResponseStatus.NotImplemented;
            objSetSKUMetadataResponse.ResponseMessage  = Constants.ResponseStatus.NotImplemented.ToString();

            try
            {
                //ASSIGNING ID'S
                objSetSKUMetadataResponse.RequestID  = objSetSKUMetadataRequest.RequestID;
                objSetSKUMetadataResponse.ResponseID = objSetSKUMetadataRequest.RequestID;

                //INPUT DATA VALIDATION

                if (objSetSKUMetadataBL.ValidateRequest(objSetSKUMetadataRequest, objSetSKUMetadataResponse))
                {
                    //PROCESS DATA & RETURN RESPONSE
                    objSetSKUMetadataBL.ProcessRequest(objSetSKUMetadataRequest, objSetSKUMetadataResponse);
                }
            }
            catch (Exception ex)
            {
                //SET FAILURE STATUS

                objSetSKUMetadataResponse.ResponseStatus  = (int)Constants.ResponseStatus.ServiceUnavailable;
                objSetSKUMetadataResponse.ResponseMessage = Constants.ResponseMessage[1000].ToString();

                //LOG EXCEPTION
                objEventLogger.WriteLog(ex.Message + Environment.NewLine + ex.StackTrace, objSetSKUMetadataRequest.RequestingSystem, DateTime.UtcNow, objSetSKUMetadataRequest.RequestID);
            }
            finally
            {
                objSetSKUMetadataResponse.ResponseDateTime = DateTime.UtcNow;


                //SERIALIZE REQUEST/RESPONSE
                string request  = "SetSKUMetadataRequest";
                string response = "SetSKUMetadataResponse";

                try
                {
                    request  = Util.SerializeObject(objSetSKUMetadataRequest);
                    response = Util.SerializeObject(objSetSKUMetadataResponse);
                }
                catch (Exception ex)
                {
                    objEventLogger.WriteLog("Request/Response Object Serialization Error: " + ex.Message + Environment.NewLine + ex.StackTrace, objSetSKUMetadataRequest.RequestingSystem, DateTime.UtcNow, objSetSKUMetadataRequest.RequestID);
                }

                if (!request.IsValidString())
                {
                    request = "SetSKUMetadataRequest";
                }
                if (!response.IsValidString())
                {
                    response = "SetSKUMetadataResponse";
                }


                //LOG REQUEST/RESPONSE
                objTransactionLogger.LogTransaction(objSetSKUMetadataRequest.RequestID, objSetSKUMetadataRequest.RequestDateTime, objSetSKUMetadataRequest.RequestingSystem,
                                                    request, objSetSKUMetadataResponse.ResponseID, objSetSKUMetadataResponse.ResponseDateTime, response,
                                                    objSetSKUMetadataResponse.ResponseStatus, objSetSKUMetadataResponse.ResponseMessage, 0);

                //End Processing SetSKUMetadata
            }

            //SetSKUMetadata ends
            return(objSetSKUMetadataResponse);


            //return resp;
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="objSetSKUMetadataRequest"></param>
        /// <param name="objSetSKUMetadataResponse"></param>
        /// <returns></returns>
        public bool ValidateRequest(SetSKUMetadataRequest objSetSKUMetadataRequest, SetSKUMetadataResponse objSetSKUMetadataResponse)
        {
            bool          ValidationStatus = true;
            string        strAlgIDs        = ConfigurationSettings.AppSettings["Algorithms"];
            List <string> lstAlgIds        = new List <string>(strAlgIDs.Split(','));

            if (!objSetSKUMetadataRequest.RequestID.IsValidString() && ValidationStatus)
            {
                objSetSKUMetadataResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                objSetSKUMetadataResponse.ResponseMessage = Constants.ResponseStatus.InvalidParameter.ToString();
                ValidationStatus = false;
            }
            if (!objSetSKUMetadataRequest.RequestingSystem.IsValidString() && ValidationStatus)
            {
                objSetSKUMetadataResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                objSetSKUMetadataResponse.ResponseMessage = Constants.ResponseStatus.InvalidParameter.ToString();
                ValidationStatus = false;
            }
            if (objCommonValidationBL.DupCheckRequestId(objSetSKUMetadataRequest.RequestID, objSetSKUMetadataRequest.RequestingSystem) && ValidationStatus)
            {
                objSetSKUMetadataResponse.ResponseStatus  = (int)Constants.ResponseStatus.AmbigousRequest;
                objSetSKUMetadataResponse.ResponseMessage = Constants.ResponseMessage[3].ToString();
                ValidationStatus = false;
            }
            if (((objSetSKUMetadataRequest.SKUMetadata.SKUID == null) || (objSetSKUMetadataRequest.SKUMetadata.SKUID != null && !objSetSKUMetadataRequest.SKUMetadata.SKUID.IsValidString())) && ValidationStatus)
            {
                objSetSKUMetadataResponse.ResponseStatus = (int)Constants.ResponseStatus.UnKnownSKU;
                /*Bug no:4397 */
                objSetSKUMetadataResponse.ResponseMessage = "SKU element is required. Please enter valid SKU";//"Please enter valid SKU";
                ValidationStatus = false;
            }
            if ((objSetSKUMetadataRequest.SKUMetadata.SKUID != null) && ValidationStatus)
            {
                if (objSetSKUMetadataRequest.SKUMetadata.SKUID.Trim().ToLower().Equals("null"))
                {
                    objSetSKUMetadataResponse.ResponseStatus  = (int)Constants.ResponseStatus.UnKnownSKU;
                    objSetSKUMetadataResponse.ResponseMessage = "SKUID cannot be 'NULL'.Please enter valid SKUID";
                    ValidationStatus = false;
                }
            }

            if (objSetSKUMetadataRequest.SKUMetadata.ActionType == null && ValidationStatus)
            {
                objSetSKUMetadataResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                objSetSKUMetadataResponse.ResponseMessage = "Please enter valid Action Type";
                ValidationStatus = false;
            }

            if (objSetSKUMetadataRequest.SKUMetadata.ActionType != null && ValidationStatus)
            {
                if (!(objSetSKUMetadataRequest.SKUMetadata.ActionType.Trim().ToLower().Equals("insert") || objSetSKUMetadataRequest.SKUMetadata.ActionType.Trim().ToLower().Equals("update") || objSetSKUMetadataRequest.SKUMetadata.ActionType.Trim().ToLower().Equals("delete")))
                {
                    objSetSKUMetadataResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                    objSetSKUMetadataResponse.ResponseMessage = "Invalid ActionType. Valid Action Type(s) are : insert or Update or Delete";
                    ValidationStatus = false;
                }
            }
            if (objSetSKUMetadataRequest.SKUMetadata.ActionType != null)
            {
                if ((objSetSKUMetadataRequest.SKUMetadata.ActionType.Trim().ToLower().Equals("insert") || objSetSKUMetadataRequest.SKUMetadata.ActionType.Trim().ToLower().Equals("update")) && ValidationStatus)
                {
                    if ((objSetSKUMetadataRequest.SKUMetadata.AlgID == null || (objSetSKUMetadataRequest.SKUMetadata.AlgID != null && !objSetSKUMetadataRequest.SKUMetadata.AlgID.IsValidString())) && ValidationStatus)
                    {
                        objSetSKUMetadataResponse.ResponseStatus = (int)Constants.ResponseStatus.InvalidParameter;
                        /*Bug no:4397 */
                        objSetSKUMetadataResponse.ResponseMessage = "Alg. ID element is required. Please enter valid Alg. ID";//"Invalid Alg ID";
                        ValidationStatus = false;
                    }
                    if (objSetSKUMetadataRequest.SKUMetadata.AlgID != null && ValidationStatus)
                    {
                        if (objSetSKUMetadataRequest.SKUMetadata.AlgID.Trim().ToLower().Equals("null"))
                        {
                            objSetSKUMetadataResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                            objSetSKUMetadataResponse.ResponseMessage = "AlgID cannot be 'NULL'.Please enter proper value.";
                            ValidationStatus = false;
                        }
                        else if (!lstAlgIds.Contains(objSetSKUMetadataRequest.SKUMetadata.AlgID))
                        {
                            objSetSKUMetadataResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                            objSetSKUMetadataResponse.ResponseMessage = "Not valid AlgID.AlgID Should be one among the range " + strAlgIDs;
                            ValidationStatus = false;
                        }
                    }


                    if ((objSetSKUMetadataRequest.SKUMetadata.Seed == null || (objSetSKUMetadataRequest.SKUMetadata.Seed != null && !objSetSKUMetadataRequest.SKUMetadata.Seed.IsValidString())) && ValidationStatus)
                    {
                        objSetSKUMetadataResponse.ResponseStatus = (int)Constants.ResponseStatus.InvalidParameter;
                        /*Bug no:4397 */
                        objSetSKUMetadataResponse.ResponseMessage = "Seed element is required. Please enter valid Seed";//"Invalid seed";
                        ValidationStatus = false;
                    }
                    if (objSetSKUMetadataRequest.SKUMetadata.Seed != null && ValidationStatus)
                    {
                        if (objSetSKUMetadataRequest.SKUMetadata.Seed.Trim().ToLower().Equals("null"))
                        {
                            objSetSKUMetadataResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                            objSetSKUMetadataResponse.ResponseMessage = "Seed cannot be 'NULL'.Please enter proper value.";
                            ValidationStatus = false;
                        }
                    }
                }
            }
            if (objSetSKUMetadataRequest.SKUMetadata.ProductType != null && ValidationStatus)
            {
                if (!(objSetSKUMetadataRequest.SKUMetadata.ProductType.Equals(1) || objSetSKUMetadataRequest.SKUMetadata.ProductType.Equals(2)))
                {
                    objSetSKUMetadataResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                    objSetSKUMetadataResponse.ResponseMessage = "Invalid ProductType.Please enter either 1 or 2";
                    ValidationStatus = false;
                }
                if ((objSetSKUMetadataRequest.SKUMetadata.ProductType.Equals(2) && objSetSKUMetadataRequest.SKUMetadata.SoftwareMetadata != null) && ValidationStatus)
                {
                    objSetSKUMetadataResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                    objSetSKUMetadataResponse.ResponseMessage = "SW cannot have  a  product type of 2.Please change the ProductType or uncheck the SoftwareMetadata";
                    ValidationStatus = false;
                }
                if ((objSetSKUMetadataRequest.SKUMetadata.ActionType.Trim().ToLower().Equals("insert") || objSetSKUMetadataRequest.SKUMetadata.ActionType.Trim().ToLower().Equals("update")) && ValidationStatus)
                {
                    if ((objSetSKUMetadataRequest.SKUMetadata.ProductType.Equals(1) && objSetSKUMetadataRequest.SKUMetadata.SoftwareMetadata == null) && ValidationStatus)
                    {
                        objSetSKUMetadataResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                        objSetSKUMetadataResponse.ResponseMessage = "SW should have SoftwareMetadata.";
                        ValidationStatus = false;
                        //We cannot have a SW without Version metadata
                    }
                }
            }


            if (objSetSKUMetadataRequest.SKUMetadata.SoftwareMetadata != null && ValidationStatus)
            {
                if (objSetSKUMetadataRequest.SKUMetadata.SoftwareMetadata.Version == null && ValidationStatus)
                {
                    objSetSKUMetadataResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                    objSetSKUMetadataResponse.ResponseMessage = "Please enter valid Version";
                    ValidationStatus = false;
                }
                if (objSetSKUMetadataRequest.SKUMetadata.SoftwareMetadata.VersionType == null && ValidationStatus)
                {
                    objSetSKUMetadataResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                    objSetSKUMetadataResponse.ResponseMessage = "Please enter valid VersionType";
                    ValidationStatus = false;
                }
                if (objSetSKUMetadataRequest.SKUMetadata.SoftwareMetadata.VersionSeqNo == null && ValidationStatus)
                {
                    objSetSKUMetadataResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                    objSetSKUMetadataResponse.ResponseMessage = "Please enter valid VersionSeqNo";
                    ValidationStatus = false;
                }
                if ((objSetSKUMetadataRequest.SKUMetadata.SoftwareMetadata.Version != null && objSetSKUMetadataRequest.SKUMetadata.SoftwareMetadata.Version.Trim().ToLower().Equals("null")) && ValidationStatus)
                {
                    objSetSKUMetadataResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                    objSetSKUMetadataResponse.ResponseMessage = "Version cannot be 'NULL'.Please enter proper value.";
                    ValidationStatus = false;
                }
                if ((objSetSKUMetadataRequest.SKUMetadata.SoftwareMetadata.VersionType != null && objSetSKUMetadataRequest.SKUMetadata.SoftwareMetadata.VersionType.Trim().ToLower().Equals("null")) && ValidationStatus)
                {
                    objSetSKUMetadataResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                    objSetSKUMetadataResponse.ResponseMessage = "VersionType cannot be 'NULL'.Please enter proper value.";
                    ValidationStatus = false;
                }
                if ((objSetSKUMetadataRequest.SKUMetadata.SoftwareMetadata.VersionSeqNo != null && objSetSKUMetadataRequest.SKUMetadata.SoftwareMetadata.VersionSeqNo.ToString().ToLower().Equals("null")) && ValidationStatus)
                {
                    objSetSKUMetadataResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                    objSetSKUMetadataResponse.ResponseMessage = "VersionSeqNo cannot be 'NULL'.Please enter proper int value.";
                    ValidationStatus = false;
                }
                if ((objSetSKUMetadataRequest.SKUMetadata.SoftwareMetadata.VersionReleaseClassification != null && objSetSKUMetadataRequest.SKUMetadata.SoftwareMetadata.VersionReleaseClassification.Trim().ToLower().Equals("null")) && ValidationStatus)
                {
                    objSetSKUMetadataResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                    objSetSKUMetadataResponse.ResponseMessage = "VersionReleaseClassification cannot be 'NULL'.Please enter proper value.";
                    ValidationStatus = false;
                }
            }
            if (objSetSKUMetadataRequest.SKUMetadata.ActionType.Trim().ToLower().Equals("insert") && ValidationStatus)
            {
                if (((objSetSKUMetadataRequest.SKUMetadata.CreatedBy == null) || (objSetSKUMetadataRequest.SKUMetadata.CreatedBy != null && !objSetSKUMetadataRequest.SKUMetadata.CreatedBy.IsValidString())) && ValidationStatus)
                {
                    objSetSKUMetadataResponse.ResponseStatus = (int)Constants.ResponseStatus.InvalidParameter;
                    /*Bug no:4397 */
                    objSetSKUMetadataResponse.ResponseMessage = "CreatedBy element is required. Please enter valid user id for CreatedBy";//"Please enter valid user id for CreatedBy";
                    ValidationStatus = false;
                }
                if (((objSetSKUMetadataRequest.SKUMetadata.UpdatedBy == null) || (objSetSKUMetadataRequest.SKUMetadata.UpdatedBy != null && !objSetSKUMetadataRequest.SKUMetadata.UpdatedBy.IsValidString())) && ValidationStatus)
                {
                    objSetSKUMetadataResponse.ResponseStatus = (int)Constants.ResponseStatus.InvalidParameter;
                    /*Bug no:4397 */
                    objSetSKUMetadataResponse.ResponseMessage = "UpdatedBy element is required. Please enter valid user id for UpdatedBy";//"Please enter valid user id for UpdatedBy";
                    ValidationStatus = false;
                }
            }
            if ((objSetSKUMetadataRequest.SKUMetadata.ActionType.Trim().ToLower().Equals("update") || objSetSKUMetadataRequest.SKUMetadata.ActionType.Trim().ToLower().Equals("delete")) && ValidationStatus)
            {
                if (((objSetSKUMetadataRequest.SKUMetadata.UpdatedBy == null) || (objSetSKUMetadataRequest.SKUMetadata.UpdatedBy != null && !objSetSKUMetadataRequest.SKUMetadata.UpdatedBy.IsValidString())) && ValidationStatus)
                {
                    objSetSKUMetadataResponse.ResponseStatus = (int)Constants.ResponseStatus.InvalidParameter;
                    /*Bug no:4397 */
                    objSetSKUMetadataResponse.ResponseMessage = "UpdatedBy element is required. Please enter valid user id for UpdatedBy";//"Please enter valid user id for UpdatedBy";
                    ValidationStatus = false;
                }
            }

            return(ValidationStatus);
        }