Beispiel #1
0
        /// <summary>
        /// Validate the Input request
        /// </summary>
        /// <param name="objGetSNHierarchyRequest"></param>
        /// <param name="objGetSNHierarchyResponse"></param>
        /// <returns></returns>
        public bool ValidateRequest(GetSNHierarchyRequest objGetSNHierarchyRequest, GetSNHierarchyResponse objGetSNHierarchyResponse)
        {
            CommonValidationBL objCommonValidationBL = new CommonValidationBL();
            bool  ValidationStatus = true;
            Int64 countSN          = Convert.ToInt64((ConfigurationSettings.AppSettings["countSN"]));

            if (!objGetSNHierarchyRequest.RequestID.IsValidString() && ValidationStatus)
            {
                objGetSNHierarchyResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                objGetSNHierarchyResponse.ResponseMessage = Constants.ResponseStatus.InvalidParameter.ToString();
                ValidationStatus = false;
            }
            if (!objGetSNHierarchyRequest.RequestingSystem.IsValidString() && ValidationStatus)
            {
                objGetSNHierarchyResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                objGetSNHierarchyResponse.ResponseMessage = Constants.ResponseStatus.InvalidParameter.ToString();
                ValidationStatus = false;
            }
            if (!objGetSNHierarchyRequest.RequestingSystem.IsValidString() && ValidationStatus)
            {
                objGetSNHierarchyResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                objGetSNHierarchyResponse.ResponseMessage = Constants.ResponseStatus.InvalidParameter.ToString();
                ValidationStatus = false;
            }
            if (objCommonValidationBL.DupCheckRequestId(objGetSNHierarchyRequest.RequestID, objGetSNHierarchyRequest.RequestingSystem) && ValidationStatus)
            {
                objGetSNHierarchyResponse.ResponseStatus  = (int)Constants.ResponseStatus.AmbigousRequest;
                objGetSNHierarchyResponse.ResponseMessage = Constants.ResponseMessage[3].ToString();
                ValidationStatus = false;
            }
            if ((objGetSNHierarchyRequest.SNum == null || objGetSNHierarchyRequest.SNum.Length < 1 || objGetSNHierarchyRequest.SNum.Length > countSN) && ValidationStatus)  //VALIDATE SNUM UNIT (MAX 100)
            {
                objGetSNHierarchyResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                objGetSNHierarchyResponse.ResponseMessage = "Invalid SNum List";
                ValidationStatus = false;
            }
            if (objGetSNHierarchyRequest.SNum != null && ValidationStatus)
            {
                for (int i = 0; i < objGetSNHierarchyRequest.SNum.Length; i++)
                {
                    if (!objGetSNHierarchyRequest.SNum[i].IsValidSNumFormat() && ValidationStatus)  //VALIDATE SNUM FORMAT
                    {
                        objGetSNHierarchyResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                        objGetSNHierarchyResponse.ResponseMessage = "Invalid SNum Format";
                        ValidationStatus = false;
                    }
                }
            }
            return(ValidationStatus);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="objGetParentChildAssociationRequest"></param>
        /// <returns></returns>
        public GetSNHierarchyResponse GetSNHierarchy(GetSNHierarchyRequest objGetSNHierarchyRequest)
        {
            GetSNHierarchyResponse objGetSNHierarchyResponse = new GetSNHierarchyResponse();
            GetSNHierarchyBL       objBL = new GetSNHierarchyBL();

            try
            {
                //do validation here
                if (objBL.ValidateRequest(objGetSNHierarchyRequest, objGetSNHierarchyResponse))
                {
                    objBL.ProcessRequest(objGetSNHierarchyRequest, objGetSNHierarchyResponse);
                }
            }
            catch (Exception ex)
            {
                //SET FAILURE STATUS
                objGetSNHierarchyResponse.ResponseStatus  = (int)Constants.ResponseStatus.ServiceUnavailable;
                objGetSNHierarchyResponse.ResponseMessage = Constants.ResponseMessage[1000].ToString();

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

                if (objGetSNHierarchyRequest.SNum != null)
                {
                    for (int s = 0; s < objGetSNHierarchyRequest.SNum.Length; s++)
                    {
                        if (objGetSNHierarchyRequest.SNum[s].Length > 0)
                        {
                            //if ((objGetSNHierarchyRequest.Filter != null))
                            //{
                            //    if (objGetSNHierarchyRequest.Filter.LookupFilter == null)
                            //    {
                            //        objGetSNHierarchyResponse.Association[s].Status = (int)Constants.ResponseStatus.InvalidParameter;
                            //        objGetSNHierarchyResponse.Association[s].Message = "Please select LookUp Filter (FilterName and FilterValue) to proceed";
                            //        objGetSNHierarchyResponse.Association[s].SNumList = null;
                            //        break;
                            //    }


                            //    if (
                            //                        (
                            //                        (objParentChildAssociationRequest.Filter.LookupFilter.FilterValue == ConfigurationSettings.AppSettings["ALL"]) ||
                            //                        (objParentChildAssociationRequest.Filter.LookupFilter.FilterValue == ConfigurationSettings.AppSettings["SN_HIERARCHY_AND_SW_VERSIONS"]) ||
                            //                        (objParentChildAssociationRequest.Filter.LookupFilter.FilterValue == ConfigurationSettings.AppSettings["SN_HIERARCHY_ONLY"])
                            //                        ) &&
                            //                        (objParentChildAssociationResponse.ResponseStatus == 0) &&
                            //                        (!(objParentChildAssociationRequest.Filter.LookupFilter.FilterName == ConfigurationSettings.AppSettings["LOOK_UP"]))
                            //                        )
                            //    {
                            //        objParentChildAssociationResponse.Association[s].Status = (int)Constants.ResponseStatus.InvalidParameter;
                            //        objParentChildAssociationResponse.Association[s].Message = "Invalid FilterName. The valid Filter Name is LOOK_UP.";
                            //        objParentChildAssociationResponse.Association[s].SNumList = null;
                            //    }

                            //    else
                            //    {

                            //        if ((
                            //             (!(objParentChildAssociationRequest.Filter.LookupFilter.FilterValue == ConfigurationSettings.AppSettings["ALL"])) &&
                            //              (!(objParentChildAssociationRequest.Filter.LookupFilter.FilterValue == ConfigurationSettings.AppSettings["SN_HIERARCHY_AND_SW_VERSIONS"])) &&
                            //              (!(objParentChildAssociationRequest.Filter.LookupFilter.FilterValue == ConfigurationSettings.AppSettings["SN_HIERARCHY_ONLY"]))
                            //              ) &&
                            //              (objParentChildAssociationResponse.ResponseStatus == 0) &&
                            //              (objParentChildAssociationRequest.Filter.LookupFilter.FilterName == ConfigurationSettings.AppSettings["LOOK_UP"])
                            //              )
                            //        {
                            //            objParentChildAssociationResponse.Association[s].Status = (int)Constants.ResponseStatus.InvalidParameter;
                            //            objParentChildAssociationResponse.Association[s].Message = "Invalid FilterValue. The valid Filter Values are SN_HIERARCHY_AND_SW_VERSIONS,SN_HIERARCHY_ONLY and ALL.";
                            //            objParentChildAssociationResponse.Association[s].SNumList = null;
                            //        }

                            //        else
                            //        {
                            //            if (
                            //        (
                            //        (!(objParentChildAssociationRequest.Filter.LookupFilter.FilterValue == ConfigurationSettings.AppSettings["ALL"])) &&
                            //        (!(objParentChildAssociationRequest.Filter.LookupFilter.FilterValue == ConfigurationSettings.AppSettings["SN_HIERARCHY_AND_SW_VERSIONS"])) &&
                            //        (!(objParentChildAssociationRequest.Filter.LookupFilter.FilterValue == ConfigurationSettings.AppSettings["SN_HIERARCHY_ONLY"]))
                            //        ) &&
                            //        (objParentChildAssociationResponse.ResponseStatus == 0) &&
                            //        (!(objParentChildAssociationRequest.Filter.LookupFilter.FilterName == ConfigurationSettings.AppSettings["LOOK_UP"]))
                            //        )
                            //            {
                            //                objParentChildAssociationResponse.Association[s].Status = (int)Constants.ResponseStatus.InvalidParameter;
                            //                objParentChildAssociationResponse.Association[s].Message = "Invalid/blank/null FilterName and FilterValue. The valid Filter Name is LOOK_UP and the valid Filter Values are SN_HIERARCHY_AND_SW_VERSIONS,SN_HIERARCHY_ONLY and ALL.";
                            //                objParentChildAssociationResponse.Association[s].SNumList = null;
                            //            }

                            //            else
                            //            {

                            //                //if ((objParentChildAssociationRequest.Filter != null) && (objParentChildAssociationRequest.Filter.LookupFilter != null)
                            //                //    && (objParentChildAssociationResponse.ResponseStatus == 0))
                            //                //{
                            //                if ((objParentChildAssociationRequest.Filter.LookupFilter.FilterValue == ConfigurationSettings.AppSettings["SN_HIERARCHY_ONLY"])
                            //                    && (objParentChildAssociationResponse.ResponseStatus == 0)
                            //                    && objParentChildAssociationRequest.Filter.LookupFilter.FilterName == ConfigurationSettings.AppSettings["LOOK_UP"])
                            //                {
                            //                    for (int i = 0; i < objParentChildAssociationRequest.SNum.Length; i++)
                            //                    {
                            //                        SNumsAssociation list1 = objParentChildAssociationResponse.Association[i];
                            //                        SNums[] snumlist = list1.SNumList;
                            //                        SNums[] IsSNumList = snumlist.Where(o => o.IsLicensableSNum == true).ToArray<SNums>();
                            //                        if (IsSNumList.Length > 0)
                            //                        {
                            //                            list1.LicensableSNum = IsSNumList[0].SNum;
                            //                            list1.SNumList = null;
                            //                        }
                            //                        else
                            //                        {
                            //                            objParentChildAssociationResponse.Association[s].Status = (int)Constants.ResponseStatus.NoParentChildFound;
                            //                            objParentChildAssociationResponse.Association[s].Message = Constants.ResponseMessage[8].ToString();
                            //                            objParentChildAssociationResponse.Association[s].SNumList = null;
                            //                        }

                            //                    }
                            //                    break;
                            //                }
                            //                else
                            //                {
                            //                    if ((objParentChildAssociationRequest.Filter.LookupFilter.FilterValue == ConfigurationSettings.AppSettings["SN_HIERARCHY_AND_SW_VERSIONS"])
                            //                        && (objParentChildAssociationResponse.ResponseStatus == 0)
                            //                    && objParentChildAssociationRequest.Filter.LookupFilter.FilterName == ConfigurationSettings.AppSettings["LOOK_UP"])
                            //                    {
                            //                        for (int i = 0; i < objParentChildAssociationRequest.SNum.Length; i++)
                            //                        {

                            //                            SNumsAssociation list1 = objParentChildAssociationResponse.Association[i];
                            //                            SNums[] snumlist = list1.SNumList;
                            //                            SNums[] IsSNumList = snumlist.Where(o => o.IsLicensableSNum == true).ToArray<SNums>();
                            //                            if (IsSNumList.Length > 0)
                            //                            {
                            //                                list1.LicensableSNum = IsSNumList[0].SNum;
                            //                                SKUDetailInfo[] inputswsku = IsSNumList[0].SKU.ToArray<SKUDetailInfo>();
                            //                                var swsku1 = inputswsku.Where(o => o.SKUType == "SW");
                            //                                IsSNumList[0].SKU = swsku1.ToArray();
                            //                                list1.SNumList = IsSNumList;
                            //                            }
                            //                            else
                            //                            {
                            //                                objParentChildAssociationResponse.Association[s].Status = (int)Constants.ResponseStatus.NoParentChildFound;
                            //                                objParentChildAssociationResponse.Association[s].Message = Constants.ResponseMessage[8].ToString();
                            //                                objParentChildAssociationResponse.Association[s].SNumList = null;
                            //                            }
                            //                        }
                            //                        break;

                            //                    }

                            //                    else
                            //                    {
                            //                        if ((objParentChildAssociationRequest.Filter.LookupFilter.FilterValue == ConfigurationSettings.AppSettings["ALL"]) && (objParentChildAssociationResponse.ResponseStatus == 0)
                            //                    && objParentChildAssociationRequest.Filter.LookupFilter.FilterName == ConfigurationSettings.AppSettings["LOOK_UP"])
                            //                        {
                            //                            for (int i = 0; i < objParentChildAssociationRequest.SNum.Length; i++)
                            //                            {

                            //                                SNumsAssociation list1 = objParentChildAssociationResponse.Association[i];
                            //                                SNums[] snumlist = list1.SNumList;
                            //                                SNums[] IsSNumList = snumlist.Where(o => o.IsLicensableSNum == true).ToArray<SNums>();
                            //                                if (IsSNumList.Length > 0)
                            //                                {
                            //                                    list1.LicensableSNum = IsSNumList[0].SNum;
                            //                                    list1.SNumList = IsSNumList;
                            //                                }
                            //                                else
                            //                                {
                            //                                    objParentChildAssociationResponse.Association[s].Status = (int)Constants.ResponseStatus.NoParentChildFound;
                            //                                    objParentChildAssociationResponse.Association[s].Message = Constants.ResponseMessage[8].ToString();
                            //                                    objParentChildAssociationResponse.Association[s].SNumList = null;
                            //                                }
                            //                            }
                            //                            break;
                            //                        }
                            //                    }
                            //                }
                            //                //}
                            //            }
                            //        }
                            //    }
                            //}

                            //else
                            //{
                            //fix for defect 2904 - add null check
                            if (objGetSNHierarchyResponse.Association != null)
                            {
                                if ((objGetSNHierarchyResponse.Association[0].SNumList.Length <= 0))
                                {
                                    objGetSNHierarchyResponse.Association[s].Status   = (int)Constants.ResponseStatus.NoParentChildFound;
                                    objGetSNHierarchyResponse.Association[s].Message  = Constants.ResponseMessage[8].ToString();
                                    objGetSNHierarchyResponse.Association[s].SNumList = null;
                                }
                            }
                            //}
                        }
                    }
                }

                //SERIALIZE REQUEST/RESPONSE
                string request  = "GetParentChildAssociationRequest";
                string response = "GetParentChildAssociationResponse";

                try
                {
                    request  = Util.SerializeObject(objGetSNHierarchyRequest);
                    response = Util.SerializeObject(objGetSNHierarchyResponse);
                }
                catch (Exception ex)
                {
                    objEventLogger.WriteEntry("Request/Response Object Serialization Error: " + ex.Message + Environment.NewLine + ex.StackTrace);
                }

                if (!request.IsValidString())
                {
                    request = "GetParentChildAssociationRequest";
                }
                if (!response.IsValidString())
                {
                    response = "GetParentChildAssociationResponse";
                }


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

                //EVENT LOG ENTRY
                objEventLogger.WriteEntry("End Processing GetParentChildAssociation");
            }
            return(objGetSNHierarchyResponse);
        }
Beispiel #3
0
        public bool ProcessRequest(GetSNHierarchyRequest objGetSNHierarchyRequest, GetSNHierarchyResponse objGetSNHierarchyResponse)
        {
            bool flag = false;

            try
            {
                //ASSIGNING ID'S
                objGetSNHierarchyResponse.RequestID  = objGetSNHierarchyRequest.RequestID;
                objGetSNHierarchyResponse.ResponseID = objGetSNHierarchyRequest.RequestID;

                //validateRequest()

                if (objGetSNHierarchyRequest.SNum.Length > 0)
                {
                    SNumsAssociationSN[] association         = new SNumsAssociationSN[objGetSNHierarchyRequest.SNum.Length];
                    string[]             arrCommaSeparatedSN = new string[objGetSNHierarchyRequest.SNum.Length];

                    #region Tracing Start Code
                    objTraceLogger = new PerformanceTraceLogger(objGetSNHierarchyRequest.RequestID, "GetParentChildAssociation", "Getting SNum Mac Tree For GetSNHierarchyRequest", objGetSNHierarchyRequest.SNum.Length);

                    if (objTraceLogger.IsEnable)
                    {
                        objTraceLogger.StartTrace();
                    }
                    #endregion

                    DataSet objMfgDS = null;
                    for (int i = 0; i < association.Length; i++)
                    {
                        association[i]      = new SNumsAssociationSN();
                        association[i].SNum = objGetSNHierarchyRequest.SNum[i];
                        string commaSepIndividualSN = "";
                        //get Snum & Mac tree
                        objMfgDS = GetSNumMacTreeForSNHierarchy(objGetSNHierarchyRequest.SNum[i]);
                        //populate SNumList

                        association[i].SNumList = GetSNumsList(objMfgDS, ref commaSepIndividualSN);
                        association[i].Message  = "Success";
                        association[i].Status   = 0;

                        arrCommaSeparatedSN[i] = commaSepIndividualSN;
                    }

                    #region Tracing End Code
                    if (objTraceLogger.IsEnable)
                    {
                        objTraceLogger.EndTrace();
                    }
                    #endregion


                    objGetSNHierarchyResponse.Association = association;
                }
                else
                {
                    objGetSNHierarchyResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                    objGetSNHierarchyResponse.ResponseMessage = Constants.ResponseStatus.InvalidParameter.ToString();
                }
                flag = true;
            }
            catch (Exception ex)
            {
                throw new Exception("Error In GetSNHierarchy Method. " + ex.Message);
            }
            return(flag);
        }