/// <summary> /// /// </summary> /// <param name="objParentChildAssociationRequest"></param> /// <param name="objParentChildAssociationResponse"></param> /// <returns></returns> public bool ValidateRequest(GetParentChildAssociationRequest objParentChildAssociationRequest, GetParentChildAssociationResponse objParentChildAssociationResponse) { CommonValidationBL objCommonValidationBL = new CommonValidationBL(); bool ValidationStatus = true; Int64 countSN = Convert.ToInt64((ConfigurationSettings.AppSettings["countSN"])); if (!objParentChildAssociationRequest.RequestID.IsValidString() && ValidationStatus) { objParentChildAssociationResponse.ResponseStatus = (int)Constants.ResponseStatus.InvalidParameter; objParentChildAssociationResponse.ResponseMessage = Constants.ResponseStatus.InvalidParameter.ToString(); ValidationStatus = false; } if (!objParentChildAssociationRequest.RequestingSystem.IsValidString() && ValidationStatus) { objParentChildAssociationResponse.ResponseStatus = (int)Constants.ResponseStatus.InvalidParameter; objParentChildAssociationResponse.ResponseMessage = Constants.ResponseStatus.InvalidParameter.ToString(); ValidationStatus = false; } if (!objParentChildAssociationRequest.RequestingSystem.IsValidString() && ValidationStatus) { objParentChildAssociationResponse.ResponseStatus = (int)Constants.ResponseStatus.InvalidParameter; objParentChildAssociationResponse.ResponseMessage = Constants.ResponseStatus.InvalidParameter.ToString(); ValidationStatus = false; } if (objCommonValidationBL.DupCheckRequestId(objParentChildAssociationRequest.RequestID, objParentChildAssociationRequest.RequestingSystem) && ValidationStatus) { objParentChildAssociationResponse.ResponseStatus = (int)Constants.ResponseStatus.AmbigousRequest; objParentChildAssociationResponse.ResponseMessage = Constants.ResponseMessage[3].ToString(); ValidationStatus = false; } if ((objParentChildAssociationRequest.SNum == null || objParentChildAssociationRequest.SNum.Length < 1 || objParentChildAssociationRequest.SNum.Length > countSN) && ValidationStatus) //VALIDATE SNUM UNIT (MAX 100) { objParentChildAssociationResponse.ResponseStatus = (int)Constants.ResponseStatus.InvalidParameter; objParentChildAssociationResponse.ResponseMessage = "Invalid SNum List"; ValidationStatus = false; } if (objParentChildAssociationRequest.SNum != null && ValidationStatus) { for (int i = 0; i < objParentChildAssociationRequest.SNum.Length; i++) { if (!objParentChildAssociationRequest.SNum[i].IsValidSNumFormat() && ValidationStatus) //VALIDATE SNUM FORMAT { objParentChildAssociationResponse.ResponseStatus = (int)Constants.ResponseStatus.InvalidParameter; objParentChildAssociationResponse.ResponseMessage = "Invalid SNum Format"; ValidationStatus = false; } } } return(ValidationStatus); }
public bool ProcessRequest(GetParentChildAssociationRequest objParentChildAssociationRequest, GetParentChildAssociationResponse objParentChildAssociationResponse) { bool flag = false; try { //ASSIGNING ID'S objParentChildAssociationResponse.RequestID = objParentChildAssociationRequest.RequestID; objParentChildAssociationResponse.ResponseID = objParentChildAssociationRequest.RequestID; //validateRequest() if (objParentChildAssociationRequest.SNum.Length > 0) { SNumsAssociation[] association = new SNumsAssociation[objParentChildAssociationRequest.SNum.Length]; string[] arrCommaSeparatedSN = new string[objParentChildAssociationRequest.SNum.Length]; #region Tracing Start Code objTraceLogger = new PerformanceTraceLogger(objParentChildAssociationRequest.RequestID, "GetParentChildAssociation", "Getting SNum Mac Tree", objParentChildAssociationRequest.SNum.Length); if (objTraceLogger.IsEnable) { objTraceLogger.StartTrace(); } #endregion DataSet objMfgDS = null; for (int i = 0; i < association.Length; i++) { association[i] = new SNumsAssociation(); association[i].SNum = objParentChildAssociationRequest.SNum[i]; string commaSepIndividualSN = ""; //get Snum & Mac tree objMfgDS = GetSNumMacTree(objParentChildAssociationRequest.SNum[i]); //populate SNumList association[i].SNumList = GetSNumsList(objMfgDS, ref commaSepIndividualSN); association[i].Message = ""; association[i].Status = 0; arrCommaSeparatedSN[i] = commaSepIndividualSN; } #region Tracing End Code if (objTraceLogger.IsEnable) { objTraceLogger.EndTrace(); } #endregion //For each associate //go through SnumList array and create comma separated string of SNum //call objBL.GetLicenseDataTree(objDS); //from DS #region Tracing Start Code objTraceLogger = new PerformanceTraceLogger(objParentChildAssociationRequest.RequestID, "GetParentChildAssociation", "GetLicenseAndSKUData", objParentChildAssociationRequest.SNum.Length); if (objTraceLogger.IsEnable) { objTraceLogger.StartTrace(); } #endregion for (int i = 0; i < association.Length; i++) { DataSet objCryptoLgrDS = null; //pass ds to cryptologger and get license data //passing comma separated serial numbers for individual association //comma separated includes the input snum too //below method fetches two resultsets - //1) distinct skus with latest date from license key table //2) second resultset gets all sku details including version objCryptoLgrDS = GetLicenseAndSKUData(arrCommaSeparatedSN[i]); //This method calls common bl method which gets sku details association[i].SNumList = UpdateSNArrayWithLicenseAndSKU(objCryptoLgrDS, association[i].SNumList); } #region Tracing End Code if (objTraceLogger.IsEnable) { objTraceLogger.EndTrace(); } #endregion objParentChildAssociationResponse.Association = association; } else { objParentChildAssociationResponse.ResponseStatus = (int)Constants.ResponseStatus.InvalidParameter; objParentChildAssociationResponse.ResponseMessage = Constants.ResponseStatus.InvalidParameter.ToString(); } flag = true; } catch (Exception ex) { throw new Exception("Error In Get Parent Child Association. " + ex.Message); } return(flag); }
/// <summary> /// /// </summary> /// <param name="objGetParentChildAssociationRequest"></param> /// <returns></returns> public GetParentChildAssociationResponse GetParentChildAssociation(GetParentChildAssociationRequest objParentChildAssociationRequest) { GetParentChildAssociationResponse objParentChildAssociationResponse = new GetParentChildAssociationResponse(); ParentChildAssociationBL objBL = new ParentChildAssociationBL(); try { //do validation here if (objBL.ValidateRequest(objParentChildAssociationRequest, objParentChildAssociationResponse)) { objBL.ProcessRequest(objParentChildAssociationRequest, objParentChildAssociationResponse); } } catch (Exception ex) { //SET FAILURE STATUS objParentChildAssociationResponse.ResponseStatus = (int)Constants.ResponseStatus.ServiceUnavailable; objParentChildAssociationResponse.ResponseMessage = Constants.ResponseMessage[1000].ToString(); //LOG EXCEPTION objEventLogger.WriteLog(ex.Message + Environment.NewLine + ex.StackTrace, objParentChildAssociationRequest.RequestingSystem, DateTime.UtcNow, objParentChildAssociationRequest.RequestID); } finally { objParentChildAssociationResponse.ResponseDateTime = DateTime.UtcNow; if (objParentChildAssociationRequest.SNum != null) { for (int s = 0; s < objParentChildAssociationRequest.SNum.Length; s++) { if (objParentChildAssociationRequest.SNum[s].Length > 0) { if ((objParentChildAssociationRequest.Filter != null)) { if (objParentChildAssociationRequest.Filter.LookupFilter == null) { objParentChildAssociationResponse.Association[s].Status = (int)Constants.ResponseStatus.InvalidParameter; objParentChildAssociationResponse.Association[s].Message = "Please select LookUp Filter (FilterName and FilterValue) to proceed"; objParentChildAssociationResponse.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 (objParentChildAssociationResponse.Association != null) { if ((objParentChildAssociationResponse.Association[0].SNumList.Length <= 0)) { objParentChildAssociationResponse.Association[s].Status = (int)Constants.ResponseStatus.NoParentChildFound; objParentChildAssociationResponse.Association[s].Message = Constants.ResponseMessage[8].ToString(); objParentChildAssociationResponse.Association[s].SNumList = null; } } } } } } //SERIALIZE REQUEST/RESPONSE string request = "GetParentChildAssociationRequest"; string response = "GetParentChildAssociationResponse"; try { request = Util.SerializeObject(objParentChildAssociationRequest); response = Util.SerializeObject(objParentChildAssociationResponse); } 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(objParentChildAssociationRequest.RequestID, objParentChildAssociationRequest.RequestDateTime, objParentChildAssociationRequest.RequestingSystem, request, objParentChildAssociationResponse.ResponseID, objParentChildAssociationResponse.ResponseDateTime, response, objParentChildAssociationResponse.ResponseStatus, objParentChildAssociationResponse.ResponseMessage, 0); //EVENT LOG ENTRY objEventLogger.WriteEntry("End Processing GetParentChildAssociation"); } return(objParentChildAssociationResponse); }
public GetParentChildAssociationResponse GetParentChildAssociation(GetParentChildAssociationRequest objParentChildAssociationRequest, bool ValidateRequest) { return(new GetParentChildAssociationResponse()); }
public DataTable GetUpdatedSNumAssocation(RMASwapRequest objRMASwapRequest) { //CREATE REQUEST/RESPONSE OBJECT FOR PARENT CHILD GetParentChildAssociationRequest objGetParentChildAssociationRequest = new GetParentChildAssociationRequest(); GetParentChildAssociationResponse objGetParentChildAssociationResponse = new GetParentChildAssociationResponse(); DataTable SNumAssocation = GetAssociationDataTable(); DataTable SourceSNumAssocation = GetAssociationDataTable(); DataTable DestSNumAssocation = GetAssociationDataTable(); string[] sNumArray = new string[2]; sNumArray[0] = objRMASwapRequest.SourceLicenseSNum; sNumArray[1] = objRMASwapRequest.DestLicenseSNum; string[] sNum = sNumArray; string SourceParentSNum = string.Empty; string DestParentSNum = string.Empty; DataRow drImport = null; if (sNum != null && sNum.Length > 0) { #region REQUEST TO PARENT CHILD METHOD objGetParentChildAssociationRequest.RequestID = Guid.NewGuid().ToString(); objGetParentChildAssociationRequest.RequestDateTime = DateTime.UtcNow; objGetParentChildAssociationRequest.RequestingSystem = objRMASwapRequest.RequestingSystem; objGetParentChildAssociationRequest.SNum = sNum; bool flag = objParentChildAssociationBL.ProcessRequest(objGetParentChildAssociationRequest, objGetParentChildAssociationResponse); #endregion if (objGetParentChildAssociationResponse != null && objGetParentChildAssociationResponse.Association != null && objGetParentChildAssociationResponse.ResponseStatus == (int)Constants.ResponseStatus.Success) { // FIND RESPONSE OBJECT FOR GIVEN SOURCE SNUM var objSourceSNumsAssociation = objGetParentChildAssociationResponse.Association.Where(obj => obj.SNum == objRMASwapRequest.SourceLicenseSNum && obj.Status == (int)Constants.ResponseStatus.Success).FirstOrDefault <SNumsAssociation>(); var objDestSNumsAssociation = objGetParentChildAssociationResponse.Association.Where(obj => obj.SNum == objRMASwapRequest.DestLicenseSNum && obj.Status == (int)Constants.ResponseStatus.Success).FirstOrDefault <SNumsAssociation>(); #region BUILD HIERARCHY FOR SOURCE TREE if (objSourceSNumsAssociation != null && objSourceSNumsAssociation.SNumList != null) { var objSourceSNumList = objSourceSNumsAssociation.SNumList.Distinct(new SNumsComparer()).ToArray(); if (objSourceSNumList != null && objSourceSNumList.Length > 0) { var topParentSNum = objSourceSNumList.Where(obj => String.IsNullOrEmpty(obj.ParentSNum) == true).FirstOrDefault <SNums>(); if (topParentSNum != null) { string parentSNum = string.Empty; parentSNum = topParentSNum.SNum; //GET DATA TABLE FOR WHOLE HIERARCHY SO WE CAN CREATE INSERT STATMENTS CreateHierarchy(ref SourceSNumAssocation, objSourceSNumList, parentSNum, null); if (SourceSNumAssocation != null && SourceSNumAssocation.Rows.Count > 0) { //debugging for (int i = 0; i < SourceSNumAssocation.Rows.Count; i++) { string sernum = Convert.ToString(SourceSNumAssocation.Rows[i]["SerialNum"]); string parentsernum = Convert.ToString(SourceSNumAssocation.Rows[i]["ParentSerialNum"]); } //FIND CHILD ROWS OF SOURCE SNUM DataRow[] sourceChildRows = SourceSNumAssocation.Select("ParentSerialNum = '" + objRMASwapRequest.SourceLicenseSNum + "'"); for (int j = 0; j < sourceChildRows.Length; j++) { //REPLACE PARENT OF ALL CHILDS WITH DEST SNUM sourceChildRows[j]["ParentSerialNum"] = objRMASwapRequest.DestLicenseSNum; } //REPLACE SOURCE SNUM WITH DEST SNUM DataRow[] sourceParentRow = SourceSNumAssocation.Select("SerialNum = '" + objRMASwapRequest.SourceLicenseSNum + "'"); for (int j = 0; j < sourceParentRow.Length; j++) { sourceParentRow[j]["SerialNum"] = objRMASwapRequest.DestLicenseSNum; } } } } } #endregion #region BUILD HIERARCHY FOR DESTINATION CHILDS if (objDestSNumsAssociation != null && objDestSNumsAssociation.SNumList != null) { var objDestSNumList = objDestSNumsAssociation.SNumList.Distinct(new SNumsComparer()).ToArray(); if (objDestSNumList != null && objDestSNumList.Length > 0) { var DestChildSNum = objDestSNumList.Where(obj => obj.ParentSNum == objRMASwapRequest.DestLicenseSNum).ToArray(); if (DestChildSNum != null && DestChildSNum.Length > 0) { CreateHierarchy(ref DestSNumAssocation, objDestSNumList, objRMASwapRequest.DestLicenseSNum, null); if (DestSNumAssocation != null && DestSNumAssocation.Rows.Count > 0) { for (int i = 0; i < DestSNumAssocation.Rows.Count; i++) { string sernum = Convert.ToString(DestSNumAssocation.Rows[i]["SerialNum"]); string parentsernum = Convert.ToString(DestSNumAssocation.Rows[i]["ParentSerialNum"]); } } } } } #endregion #region INSERT DESTINATION CHILD HIERARCHY AT SOURCE SIDE if (DestSNumAssocation != null && DestSNumAssocation.Rows.Count > 0) { for (int i = 0; i < SourceSNumAssocation.Rows.Count; i++) { //FIND DESTINATION SNUM IN UPDATED SOURCE TREE && ADD ALL CHILDS OF DESTINATION TO FINAL DATATABLE if (Convert.ToString(SourceSNumAssocation.Rows[i]["SerialNum"]) == objRMASwapRequest.DestLicenseSNum) { for (int j = 0; j < DestSNumAssocation.Rows.Count; j++) { //avoid null parent entry of destination tree as we are already setting new parent on source side. if (!String.IsNullOrEmpty(Convert.ToString(DestSNumAssocation.Rows[j]["ParentSerialNum"]))) { drImport = SNumAssocation.NewRow(); drImport["SerialNum"] = Convert.ToString(DestSNumAssocation.Rows[j]["SerialNum"]);; drImport["ParentSerialNum"] = Convert.ToString(DestSNumAssocation.Rows[j]["ParentSerialNum"]); SNumAssocation.Rows.Add(drImport); } } } drImport = SNumAssocation.NewRow(); drImport["SerialNum"] = Convert.ToString(SourceSNumAssocation.Rows[i]["SerialNum"]); drImport["ParentSerialNum"] = Convert.ToString(SourceSNumAssocation.Rows[i]["ParentSerialNum"]); SNumAssocation.Rows.Add(drImport); } } else { //IF THERE IS NO CHILD OF DESTINATION SNUM THAN JUST USE UPDATED SOURCE SNumAssocation = SourceSNumAssocation; } /* NOT REQUIRE AS PER CHARLES COMMENT * * //UNLINK SOURCE SNUM FROM TREE * drImport = SNumAssocation.NewRow(); * drImport["SerialNum"] = objRMASwapRequest.SourceLicenseSNum; * drImport["ParentSerialNum"] = objRMASwapRequest.SourceLicenseSNum; * SNumAssocation.Rows.Add(drImport); */ #endregion } } //debugging for (int i = 0; i < SNumAssocation.Rows.Count; i++) { string sernum = Convert.ToString(SNumAssocation.Rows[i]["SerialNum"]); string parentsernum = Convert.ToString(SNumAssocation.Rows[i]["ParentSerialNum"]); } return(SNumAssocation); }
public override GetParentChildAssociationResponse GetParentChildAssociation(GetParentChildAssociationRequest objParentChildAssociationRequest) { ParentChildAssociationProcess objParentChildAssociationProcess = new ParentChildAssociationProcess(); return(objParentChildAssociationProcess.GetParentChildAssociation(objParentChildAssociationRequest)); }