protected async Task SendRequestToIntegration(StringContent message, AgencyInfo info) { HttpResponseMessage response = await SendRequest(message, info); if (!response.IsSuccessStatusCode) { try { var policy = Policy .Handle <Exception>() .WaitAndRetryAsync(3, retryAttempt => TimeSpan.FromSeconds(5)); await policy.ExecuteAsync(async() => { HttpResponseMessage response = await SendRequest(message, info); if (!response.IsSuccessStatusCode) { var responseString = await response.Content.ReadAsStringAsync(); throw new Exception( $"Polly Retry / StatusCode: {response.StatusCode}, " + $"Request: {JsonSerializer.Serialize(message)}, Response: {responseString}"); } }) .OrTimeout(TimeSpan.FromMinutes(10)); } catch (Exception ex) { throw new Exception(ex.Message); } } }
/// <summary> /// When overridden in a descendant class, sets the <see cref="ApiClient{TRequest, TResponse}.Address"/> property. /// </summary> protected override void ApplyAddress() { ValidateNull(AgencyInfo, nameof(AgencyInfo)); ValidateNull(Request, nameof(Request)); Address = AgencyInfo.GetAddress(Request.ApiName); }
/// <summary> /// When overridden in a descendant class, sets the <see cref="ApiClient{TRequest, TResponse}.Address"/> property. /// </summary> protected override void ApplyAddress() { ValidateNull(AgencyInfo, nameof(AgencyInfo)); ValidateNull(Request, nameof(Request)); ValidateEmptyString(Request.AadhaarNumber, nameof(BfdRequest.AadhaarNumber)); Address = AgencyInfo.GetAddress(Request.ApiName, Request.AadhaarNumber); }
/// <summary> /// When overridden in a descendant class, sets the <see cref="ApiClient{TRequest, TResponse}.Address"/> property. /// </summary> protected override void ApplyAddress() { ValidateNull(AgencyInfo, nameof(AgencyInfo)); ValidateNull(Request, nameof(Request)); ValidateEmptyString(Request.AadhaarOrMobileNumber, nameof(OtpRequest.AadhaarOrMobileNumber)); // Don't use Mobile number as part of the URL. Address = AgencyInfo.GetAddress(Request.ApiName, Request.RequestType == OtpRequestType.AadhaarNumber ? Request.AadhaarOrMobileNumber : null); }
private async Task <HttpResponseMessage> SendRequest(StringContent message, AgencyInfo info) { var svcCredentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(info.User + ":" + info.Password)); _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", svcCredentials); return(await _httpClient.PostAsync(info.EndpointURL, message)); }
/// <summary> /// When overridden in a descendant class, sets the address of the host and addtional properties for request and validation. /// </summary> protected virtual void ApplyInfo() { ValidateNull(Request, nameof(Request)); ValidateNull(Response, nameof(Response)); ValidateNull(AgencyInfo, nameof(AgencyInfo)); Request.AuaCode = AgencyInfo.AuaCode; Request.AuaLicenseKey = AgencyInfo.AuaLicenseKey; Request.SubAuaCode = AgencyInfo.SubAuaCode; Address = AgencyInfo.GetAddress(Request.ApiName); }
protected void gvAgency_SelectedIndexChanged(object sender, System.EventArgs e) { FillAgencyList(); AdminController aCont = new AdminController(); txtSelectedAgency.Value = (gvAgency.SelectedRow.FindControl("hdngvAgencyId") as HiddenField).Value; AgencyInfo agency = aCont.Get_AgencyById(Convert.ToInt32(txtSelectedAgency.Value)); if (agency.Id != -1) { btnDeleteAgency.Enabled = true; btnSaveAgencyAs.Enabled = true; txtAgencyAddress1.Text = agency.Address1; txtAgencyAddress2.Text = agency.Address2; txtAgencyCity.Text = agency.City; txtAgencyCountry.Text = agency.Country; txtAgencyCreatedBy.Value = agency.CreatedById.ToString(); txtAgencyCreatedDate.Value = agency.DateCreated.Ticks.ToString(); txtAgencyCustomerReference.Text = agency.CustomerReference; txtAgencyFax.Text = agency.Fax; txtAgencyName.Text = agency.AgencyName; txtAgencyPhone.Text = agency.Phone; txtAgencyState.Text = agency.State; txtAgencyZip.Text = agency.Zip; try { ddlAgencyClientType.SelectedValue = agency.ClientType.ToString(); } catch { ddlAgencyClientType.SelectedIndex = 0; } if (agency.Status) { ddlAgencyStatus.SelectedIndex = 1; } else { ddlAgencyStatus.SelectedIndex = 2; } //lblAgencyMessage.Text = ""; } else { btnDeleteAgency.Enabled = false; btnSaveAgencyAs.Enabled = false; lblAgencyMessage.Text = "There was an error loading this agency."; } //clearAll("Agency"); }
/// <summary> /// When overridden in a descendant class, sets the address of the host and addtional properties for request and validation. /// </summary> protected override void ApplyInfo() { base.ApplyInfo(); if (Request.AuthInfo != null) { using (var sha = SHA256.Create()) { Request.AuthInfo.AadhaarNumberHash = sha.ComputeHash(Request.AadhaarNumber.GetBytes()).ToHex(); Request.AuthInfo.TerminalHash = sha.ComputeHash(Request.Terminal.GetBytes()).ToHex(); Request.AuthInfo.AuaCodeHash = sha.ComputeHash(Request.AuaCode.GetBytes()).ToHex(); } Request.AuthInfo.SubAuaCode = Request.SubAuaCode; Request.AuthInfo.Encode(); } Address = AgencyInfo.GetAddress(Request.ApiName, Request.AadhaarNumber); }
/// <summary> /// When overridden in a descendant class, sets the address of the host and addtional properties for request and validation. /// </summary> protected override void ApplyInfo() { base.ApplyInfo(); if (Request.Info != null) { using (var sha = SHA256.Create()) { Request.Info.AadhaarNumberHash = sha.ComputeHash(Request.AadhaarOrMobileNumber.GetBytes()).ToHex(); Request.Info.AuaCodeHash = sha.ComputeHash(Request.AuaCode.GetBytes()).ToHex(); } Request.Info.SubAuaCode = Request.SubAuaCode; Request.Info.Encode(); } // Don't use Mobile number as part of the URL. Address = AgencyInfo.GetAddress(Request.ApiName, Request.RequestType == OtpRequestType.AadhaarNumber ? Request.AadhaarOrMobileNumber : null); }
protected void btnDeleteAgency_Click(object sender, System.EventArgs e) { AdminController aCont = new AdminController(); int AgencyId = Convert.ToInt32(txtSelectedAgency.Value); AgencyInfo agency = new AgencyInfo(); agency.Id = AgencyId; aCont.Delete_Agency(agency); lblAgencyMessage.Text = "Agency Deleted."; if (Application["Agencies"] != null) { Application.Remove("Agencies"); } FillAgencyList(); //fillDropDowns(""); clearAgency(); }
protected void btnSaveAgencyAs_Click(object sender, System.EventArgs e) { AdminController aCont = new AdminController(); AgencyInfo agency = new AgencyInfo(); agency.PortalId = PortalId; agency.LastModifiedById = UserId; agency.LastModifiedDate = DateTime.Now; agency.AgencyName = txtAgencyName.Text; agency.Address1 = txtAgencyAddress1.Text; agency.Address2 = txtAgencyAddress2.Text; agency.City = txtAgencyCity.Text; agency.State = txtAgencyState.Text; agency.Zip = txtAgencyZip.Text; agency.Country = txtAgencyCountry.Text; agency.Phone = txtAgencyPhone.Text; agency.Fax = txtAgencyFax.Text; agency.ClientType = Convert.ToInt16(ddlAgencyClientType.SelectedValue); agency.CustomerReference = txtAgencyCustomerReference.Text; if (ddlAgencyStatus.SelectedValue == "1") { //only set if true, false is default value agency.Status = true; } //save new Agency agency.CreatedById = UserId; agency.DateCreated = DateTime.Now; int agencyId = aCont.Add_Agency(agency); txtSelectedAgency.Value = agencyId.ToString(); txtAgencyCreatedBy.Value = UserId.ToString(); txtAgencyCreatedDate.Value = DateTime.Now.Ticks.ToString(); lblMessage.Text = "Agency Saved."; if (Application["Agencies"] != null) { Application.Remove("Agencies"); } FillAgencyList(); //fillDropDowns("Agency"); //clearAll("Agency"); }
/// <summary> /// 在可用机构列表中选择一个机构作为当前登录机构 /// </summary> public void SelectAgency(int index) { roles.Clear(); if ((index < 0) || (index >= agencies.Count())) { if (Thread.CurrentThread.CurrentUICulture.Name.Substring(0, 2) == "en") { throw new Exception("Index out of range"); } else { throw new Exception("索引超出数组范围!"); } } else { currentAgencyInfo = agencies[index].Clone(); GetAvailableRoles(currentAgencyInfo.AgencyID); } }
public abstract int Add_AgencyForImport(AgencyInfo Agency);
/// <summary> /// When overridden in a descendant class, sets the <see cref="Address"/> property. /// </summary> protected virtual void ApplyAddress() { Address = AgencyInfo.GetAddress(Request.ApiName); }
public string buildRequest(string ticket) { string req = ""; string[] custCodes = new string[6] { "CUSTOMIZATION 30 MIN", "HD CUSTOMIZATION 30 MIN", "SPOT CUSTOMIZATION", "HD CUSTOMIZATION SPOT", "CUSTOMIZATION 5 MIN", "HD CUSTOMIZATION 5 MIN" }; int custIndex = 2; int i = 1; string xmlString = ""; List <InvoiceInfo> invs = aCont.Get_InvoicesByToSend(); if (invs.Count > 0) { xmlString += "<?xml version=\"1.0\" encoding=\"utf-8\"?><?qbxml version=\"6.0\"?><QBXML><QBXMLMsgsRq onError=\"stopOnError\">"; //build array of xml foreach (InvoiceInfo inv in invs) { xmlString += "<InvoiceAddRq requestID=\"" + inv.Id.ToString() + "\"><InvoiceAdd>";// List <int> woIds = aCont.Get_WOInsByInvoiceId(inv.Id); if (woIds.Count > 0 && woIds[0] > 0) { WorkOrderInfo wo1 = aCont.Get_WorkOrderById(woIds[0]); AdvertiserInfo billto = aCont.Get_AdvertiserById(wo1.BillToId); if (billto.Id == -1) { billto = aCont.Get_AdvertiserById(wo1.AdvertiserId); } i++; xmlString += "<CustomerRef><FullName>" + billto.AdvertiserName.Trim().Replace("&", "&") + "</FullName></CustomerRef>"; xmlString += "<BillAddress><Addr1>" + billto.AdvertiserName.Trim().Replace("&", "&") + "</Addr1><Addr2>" + billto.Address1.Trim().Replace("&", "&"); if (billto.Address2.Trim() != "") { xmlString += " - " + billto.Address2.Trim().Replace("&", "&"); } xmlString += "</Addr2><City>" + billto.City.Trim().Replace("&", "&") + "</City><State>" + billto.State.Trim().Replace("&", "&") + "</State><PostalCode>" + billto.Zip.Trim().Replace("&", "&") + "</PostalCode><Country>" + billto.Country.Trim().Replace("&", "&") + "</Country></BillAddress>"; string po = wo1.PONumber; if (po == "") { try { po = wo1.Groups[0].LibraryItems[0].PMTMediaId.Replace("&", "&"); } catch { } } xmlString += "<PONumber>" + po.Replace("&", "&") + "</PONumber>"; if (woIds.Count == 1) { xmlString += "<FOB>WO: " + woIds[0].ToString() + "</FOB>"; } else if (woIds.Count > 1) { xmlString += "<FOB>SEE BELOW</FOB>"; } xmlString += "<Memo>" + inv.Id.ToString() + "</Memo>"; AgencyInfo ag = aCont.Get_AgencyById(wo1.AgencyId); xmlString += "<Other>" + ag.AgencyName.Trim().Replace("&", "&") + "</Other>"; foreach (int woId in woIds) { WorkOrderInfo wo = aCont.Get_WorkOrderById(woId); List <TaskInfo> tasks = aCont.Get_TasksByWOId(wo.Id); int groupId = -1; bool groupNew = true; for (int j = 0; j < tasks.Count; j++) { TaskInfo task = tasks[j]; if (groupId == -1) { groupId = task.WOGroupId; } if (task.WOGroupId != groupId) { groupNew = true; groupId = task.WOGroupId; } if (task.DeliveryStatus.ToLower() != "cancelled" && !task.isDeleted) { if (task.TaskType != GroupTypeEnum.Delivery) { WOGroupInfo group = aCont.Get_WorkOrderGroupById(task.WOGroupId); List <QBCodeInfo> servCodes = aCont.FindQBCodesByTask(task.Id, 0, true); LibraryItemInfo lib = aCont.Get_LibraryItemById(task.LibraryId); MasterItemInfo master = new MasterItemInfo(); if (task.TaskType == GroupTypeEnum.Non_Deliverable) { master = aCont.Get_MasterItemById(task.MasterId); } //foreach (ServiceInfo serv in group.Services) if (groupNew) { foreach (QBCodeInfo code in servCodes) { if (task.TaskType != GroupTypeEnum.Non_Deliverable) { xmlString += "<InvoiceLineAdd>"; xmlString += "<ItemRef><FullName>" + code.QBCode.Replace("&", "&") + "</FullName></ItemRef>"; xmlString += "<Desc>" + lib.Title.Replace("&", "&"); //code.QBCode.Replace("&", "&"); if (woIds.Count > 1 && j == 0) { xmlString += " WO " + wo.Id.ToString(); } xmlString += "</Desc>"; if (task.Quantity == 0) { task.Quantity = 1; } xmlString += "<Quantity>" + group.LibraryItems.Count.ToString() + "</Quantity>"; xmlString += "<Other1></Other1>"; xmlString += "<Other2></Other2></InvoiceLineAdd>"; } else { xmlString += "<InvoiceLineAdd>"; xmlString += "<ItemRef><FullName>" + code.QBCode.Replace("&", "&") + "</FullName></ItemRef>"; xmlString += "<Desc>" + master.Title.Replace("&", "&"); if (woIds.Count > 1 && j == 0) { xmlString += " WO " + wo.Id.ToString(); } xmlString += "</Desc>"; if (task.Quantity == 0) { task.Quantity = 1; } xmlString += "<Quantity>" + task.Quantity + "</Quantity>"; xmlString += "<Other1>" + lib.ProductDescription.Trim().Replace("&", "&") + "</Other1>"; xmlString += "<Other2>" + lib.ISCICode.Trim().Replace("&", "&") + "</Other2></InvoiceLineAdd>"; } } groupNew = false; } } if (task.TaskType == GroupTypeEnum.Bundle || task.TaskType == GroupTypeEnum.Delivery || task.TaskType == GroupTypeEnum.Customized) { LibraryItemInfo lib = aCont.Get_LibraryItemById(task.LibraryId); bool isHd = lib.MediaType.IndexOf("HD") != -1; string[] pcs = lib.MediaLength.Split(':'); int secs = 0; if (pcs.Length == 2) { try { secs = 60 * Convert.ToInt32(pcs[0]) + Convert.ToInt32(pcs[1]); } catch { } } if (secs <= 120 && !isHd) { custIndex = 2; } else if (secs <= 120 && isHd) { custIndex = 3; } else if (secs >= 1500 && secs <= 1800 && !isHd) { custIndex = 0; } else if (secs >= 1500 && secs <= 1800 && isHd) { custIndex = 1; } else if (secs >= 180 && secs <= 300 && !isHd) { custIndex = 4; } else if (secs >= 180 && secs <= 300 && !isHd) { custIndex = 5; } xmlString += "<InvoiceLineAdd>"; if (task.TaskType != GroupTypeEnum.Customized) { xmlString += "<ItemRef><FullName>" + task.QBCode.Trim().Replace("&", "&") + "</FullName></ItemRef>"; } else { xmlString += "<ItemRef><FullName>" + custCodes[custIndex] + "</FullName></ItemRef>"; } xmlString += "<Desc>" + lib.Title.Trim().Replace("&", "&"); if (woIds.Count > 1 && j == 0) { xmlString += " WO " + wo.Id.ToString(); } xmlString += "</Desc>"; if (task.Quantity == 0) { task.Quantity = 1; } xmlString += "<Quantity>" + task.Quantity + "</Quantity>"; xmlString += "<Other1>" + lib.ProductDescription.Trim().Replace("&", "&") + "</Other1>"; if (lib.TapeCode.Trim() == "") { xmlString += "<Other2>" + lib.ISCICode.Trim().Replace("&", "&") + "</Other2></InvoiceLineAdd>"; } else { xmlString += "<Other2>" + lib.TapeCode.Trim().Replace("&", "&") + "</Other2></InvoiceLineAdd>"; } WOGroupStationInfo station = aCont.Get_WorkOrderGroupStationById(task.StationId); if (station.DeliveryMethod.ToLower().IndexOf("tf_") != -1) { //check to see if we need to add shipping if (station.ShippingMethodId == -1) { int weight = 1; TapeFormatInfo tape = aCont.Get_TapeFormatById(Convert.ToInt32(station.DeliveryMethod.Replace("tf_", ""))); if (station.Quantity * tape.Weight > 1.0) { weight = 2; } string shippingPrice = ""; if (weight == 1) { if (station.PriorityId == 1) { shippingPrice = ConfigurationManager.AppSettings["FedEx1LbPriority"].ToString(); } else if (station.PriorityId == 2) { shippingPrice = ConfigurationManager.AppSettings["FedEx1LbStandard"].ToString(); } else if (station.PriorityId == 3) { shippingPrice = ConfigurationManager.AppSettings["FedEx1Lb2Day"].ToString(); } } else { if (station.PriorityId == 1) { shippingPrice = ConfigurationManager.AppSettings["FedEx2LbPriority"].ToString(); } else if (station.PriorityId == 2) { shippingPrice = ConfigurationManager.AppSettings["FedEx2LbStandard"].ToString(); } else if (station.PriorityId == 3) { shippingPrice = ConfigurationManager.AppSettings["FedEx2Lb2Day"].ToString(); } } xmlString += "<InvoiceLineAdd><ItemRef><FullName>SHIPPING</FullName></ItemRef><Desc>P" + station.PriorityId.ToString() + " " + weight.ToString() + "LB SHIPPING CHARGE</Desc><Quantity>1</Quantity><Rate>" + shippingPrice + "</Rate></InvoiceLineAdd>"; } } } } } } } xmlString += "</InvoiceAdd></InvoiceAddRq>"; //xmlString += ""; } xmlString += "</QBXMLMsgsRq></QBXML>"; req = xmlString; //} } return(req); }
public abstract int Add_Agency(AgencyInfo Agency);
public AgencyInfo GetAgencyInfoDAL( int AgencyType, long AgencyLicenseNumber ) { List <SpInPuts> inputs = new List <SpInPuts> { new SpInPuts() { KEY = "P_REG_TYPE_CODE", VALUE = AgencyType }, new SpInPuts() { KEY = "P_REG_ID", VALUE = AgencyLicenseNumber } }; List <SpOutPuts> Outouts = new List <SpOutPuts>() { new SpOutPuts() { ParameterName = "P_BRN_NAME", OracleDbType = OracleDbType.Varchar2, Size = 300 }, new SpOutPuts() { ParameterName = "P_SOC_NAME", OracleDbType = OracleDbType.Varchar2, Size = 300 }, new SpOutPuts() { ParameterName = "P_REGISTRY_DT", OracleDbType = OracleDbType.Varchar2, Size = 300 }, new SpOutPuts() { ParameterName = "P_SERVICE_AREA", OracleDbType = OracleDbType.Varchar2, Size = 300 }, new SpOutPuts() { ParameterName = "P_SUBSIDY_ACC_NO", OracleDbType = OracleDbType.Varchar2, Size = 300 }, new SpOutPuts() { ParameterName = "P_BANK_NAME", OracleDbType = OracleDbType.Varchar2, Size = 300 }, new SpOutPuts() { ParameterName = "P_CAT_NAME", OracleDbType = OracleDbType.Varchar2, Size = 300 }, new SpOutPuts() { ParameterName = "P_NO_700", OracleDbType = OracleDbType.Varchar2, Size = 300 }, new SpOutPuts() { ParameterName = "P_RESULT_CODE", OracleDbType = OracleDbType.Varchar2, Size = 300 }, new SpOutPuts() { ParameterName = "P_RESULT_TEXT", OracleDbType = OracleDbType.Varchar2, Size = 2000 } }; //Populate Parameters List <OracleParameter> OpParms = ado.PopulateSpInPuts( in inputs ); ado.PopulateSpOutPuts( ref OpParms, in Outouts ); ado.ExecuteStoredProcedure( "CH_P_CH_REG_INFO", OpParms, out OracleParameterCollection OPCs ); AgencyInfo chi = new AgencyInfo { DevelopmentCenterName = OPCs[":P_BRN_NAME"].Value.ToString(), CharityName = OPCs[":P_SOC_NAME"].Value.ToString(), LicenseDate = OPCs[":P_REGISTRY_DT"].Value.ToString(), ServiceArea = OPCs[":P_SERVICE_AREA"].Value.ToString(), BankAccountNumber = OPCs[":P_SUBSIDY_ACC_NO"].Value.ToString(), BankName = OPCs[":P_BANK_NAME"].Value.ToString(), CharityClassification = OPCs[":P_CAT_NAME"].Value.ToString(), AccountNumber700 = OPCs[":P_NO_700"].Value.ToString(), RequestResult = new RequestResult() { RequestCode = OPCs[":P_RESULT_CODE"].Value.ToString(), RequestName = OPCs[":P_RESULT_TEXT"].Value.ToString(), } }; return(chi); }
public async Task <int> Update(AgencyInfo agencyInfo) { return(await Context.SaveChangesAsync()); }
public async Task <int> Insert(AgencyInfo agencyInfo) { _agencyInfoRepository.Create(agencyInfo); return(await Context.SaveChangesAsync()); }
/// <summary> /// When overridden in a descendant class, sets the address of the host and addtional properties for request and validation. /// </summary> protected override void ApplyInfo() { base.ApplyInfo(); Address = AgencyInfo.GetAddress(Request.ApiName, Request.AadhaarNumber); }
public abstract void Delete_Agency(AgencyInfo Agency);
public abstract void Update_Agency(AgencyInfo Agency);