Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Text;
- using System.Web.UI;
- public partial class View_Reports_SecurityComponent : CPPSiteBase
- {
- static string[] strArrOutput = new string[] {"underwriter_dn", "field_rep_dn", "merge_status", "legal_name", "business_name",
- "business_addr_name", "mailing_address", "mailing_address_1", "mailing_address_2",
- "mailing_city", "mailing_zipcode", "office_address", "office_city", "office_state",
- "office_zipcode", "phone_number", "fax_number"};
- static string[] strArrIntUserInfoOutput = new string[] { "firstname", "lastname", "middleinitial", "email", "common_name",
- "username", "roles", "agencyCodes", "shortuserid"};
- static string[] strArrExtUserInfoOutput = new string[] { "firstname", "lastname", "middleinitial", "email", "common_name",
- "username", "roles", "agencyCodes", "shortuserid", "organizations", "mainBranch"};
- protected void Page_Load(object sender, EventArgs e)
- {
- // Force IE version; newer jQuery and CSS cannot run on old versions of IE
- //Page.Header.Controls.AddAt(0, new LiteralControl("<meta http-equiv='X-UA-Compatible' content='IE = 11,10,9' />"));
- if (this.Session["environment"] == null)
- {
- this.Response.Redirect("~/default.aspx", true);
- }
- }
- // Get Agency Info
- protected void btnLookupInfo_Click(object sender, EventArgs e)
- {
- try
- {
- if (txtAgencyCode.Text != "")
- {
- //GatherOutput(sender);
- SecurityServiceNew.SecurityService userSvc = GetSecurityService();
- SecurityServiceNew.ArrayOfString[] results = userSvc.getAgencyInfo("cpp", new string[] { txtAgencyCode.Text.Trim() }, strArrOutput, null);
- if (results == null)
- {
- // Only environments listed in GetAgencyInfo will return a result string array
- lblErrorMessage.Text = "This functionality does not work in environment: " + this.Session["environment"].ToString().ToUpper();
- }
- else
- {
- string[] result = results[0].array;
- lblUnderwriterName.Text = "";
- lblFieldRepName.Text = "";
- lblMergeStatus.Text = "";
- lblLegalName.Text = "";
- lblBusinessName.Text = "";
- lblBusinessAddressName.Text = "";
- lblMailingCity.Text = "";
- lblMailingState.Text = "";
- lblMailingZip.Text = "";
- lblOfficeAddress.Text = "";
- lblOfficeCity.Text = "";
- lblOfficeState.Text = "";
- lblOfficeZip.Text = "";
- lblPhoneNumber.Text = "";
- lblFaxNumber.Text = "";
- lblMailingAddress1.Text = "";
- lblMailingAddress2.Text = "";
- lblMailingAddress.Text = "";
- for (int i = 0; i < result.Length; i++)
- {
- if (result[i].IndexOf("|") == -1)
- continue;
- if (result[i].StartsWith("underwriter_dn"))
- lblUnderwriterName.Text = result[i].Substring(15);
- else if (result[i].StartsWith("field_rep_dn"))
- lblFieldRepName.Text = result[i].Substring(13);
- else if (result[i].StartsWith("merge_status"))
- lblMergeStatus.Text = result[i].Substring(13);
- else if (result[i].StartsWith("legal_name"))
- lblLegalName.Text = result[i].Substring(11);
- else if (result[i].StartsWith("business_name"))
- lblBusinessName.Text = result[i].Substring(14);
- else if (result[i].StartsWith("business_addr_name"))
- lblBusinessAddressName.Text = result[i].Substring(19);
- else if (result[i].StartsWith("mailing_address") && (result[i].StartsWith("mailing_address_") == false))
- lblMailingAddress.Text = result[i].Substring(16);
- else if (result[i].StartsWith("mailing_address_1"))
- lblMailingAddress1.Text = result[i].Substring(18);
- else if (result[i].StartsWith("mailing_address_2"))
- lblMailingAddress2.Text = result[i].Substring(18);
- else if (result[i].StartsWith("mailing_city"))
- lblMailingCity.Text = result[i].Substring(13);
- else if (result[i].StartsWith("mailing_state"))
- lblMailingState.Text = result[i].Substring(14);
- else if (result[i].StartsWith("mailing_zipcode"))
- lblMailingZip.Text = string.Format("{0:#####-####}", float.Parse(result[i].Substring(16)));
- else if (result[i].StartsWith("office_address"))
- lblOfficeAddress.Text = result[i].Substring(15);
- else if (result[i].StartsWith("office_city"))
- lblOfficeCity.Text = result[i].Substring(12);
- else if (result[i].StartsWith("office_state"))
- lblOfficeState.Text = result[i].Substring(13);
- else if (result[i].StartsWith("office_zipcode"))
- lblOfficeZip.Text = string.Format("{0:#####-####}", float.Parse(result[i].Substring(15)));
- else if (result[i].StartsWith("phone_number"))
- lblPhoneNumber.Text = string.Format("{0:(###) ###-####}", float.Parse(result[i].Substring(13)));
- else if (result[i].StartsWith("fax_number"))
- lblFaxNumber.Text = string.Format("{0:(###) ###-####}", float.Parse(result[i].Substring(11)));
- }
- }
- }
- else
- {
- lblErrorMessage.Text = "An Agency Code must be entered.";
- }
- }
- catch (Exception ex)
- {
- lblErrorMessage.Text = "Error Message = " + ex.Message;
- }
- }
- // Get User Info By Short UID
- protected void btnUserInfo_Click(object sender, EventArgs e)
- {
- try
- {
- string strUserShortUID;
- lblFirstName.Text = "";
- lblMiddleInitial.Text = "";
- lblLastName.Text = "";
- lblEmail.Text = "";
- lblCommonName.Text = "";
- lblUsername.Text = "";
- lblRoles.Text = "";
- lblOrgRoles.Text = "";
- lblOrganizations.Text = "";
- lblAgencyCodes.Text = "";
- lblShortUserID.Text = "";
- lblMainBranch.Text = "";
- lblLifeCodes.Text = "";
- //GatherOutput(sender);
- strUserShortUID = txtUserShortUID.Text.Trim();
- if (strUserShortUID != "")
- {
- strUserShortUID = strUserShortUID.ToUpper();
- SecurityServiceNew.SecurityService userSvc = GetSecurityService();
- object[] results = null;
- if (ddlUserOrigin.SelectedValue.Equals("CFCNet", StringComparison.CurrentCulture))
- {
- results = userSvc.getUserInfoByShortuid("cpp", strUserShortUID, strArrIntUserInfoOutput);
- }
- else
- {
- results = userSvc.getUserInfoByShortuid("cpp", strUserShortUID, strArrExtUserInfoOutput);
- }
- if (results == null)
- {
- // Only environments listed in GetAgencyInfo will return a result string array
- lblErrorMessage.Text = "<b>Error in Get User Info By Short UID:</b> This functionality does not work in environment: " + this.Session["environment"].ToString().ToUpper();
- }
- else
- {
- if (results.Count() > 0)
- {
- lblErrorMessage.Text = "";
- foreach (string strResult in results)
- {
- if (strResult != null && (strResult.IndexOf("|") != -1))
- {
- if (strResult.Substring(0, 5) == "first")
- lblFirstName.Text = lblFirstName.Text + strResult.Substring(10);
- if (strResult.Substring(0, 5) == "middl")
- lblMiddleInitial.Text = lblMiddleInitial.Text + strResult.Substring(11);
- if (strResult.Substring(0, 5) == "lastn")
- lblLastName.Text = lblLastName.Text + strResult.Substring(9);
- if (strResult.Substring(0, 5) == "email")
- lblEmail.Text = lblEmail.Text + strResult.Substring(6);
- if (strResult.Substring(0, 5) == "commo")
- lblCommonName.Text = lblCommonName.Text + strResult.Substring(12);
- if (strResult.Substring(0, 5) == "usern")
- lblUsername.Text = lblUsername.Text + strResult.Substring(9);
- if (strResult.Substring(0, 5) == "roles")
- lblRoles.Text = GetMultiple(strResult, 6);
- if (strResult.Substring(0, 5) == "orgRo")
- if (lblOrgRoles.Text == "")
- lblOrgRoles.Text = strResult.Substring(9);
- else
- lblOrgRoles.Text = lblOrgRoles.Text + "<br />" + strResult.Substring(9);
- if (strResult.Substring(0, 5) == "organ")
- if (lblOrganizations.Text == "")
- lblOrganizations.Text = strResult.Substring(14);
- else
- lblOrganizations.Text = lblOrganizations.Text + "<br />" + strResult.Substring(14);
- if (strResult.Substring(0, 5) == "agenc")
- lblAgencyCodes.Text = GetMultiple(strResult, 12);
- if (strResult.Substring(0, 5) == "short")
- lblShortUserID.Text = lblShortUserID.Text + strResult.Substring(12);
- if (strResult.Substring(0, 5) == "mainB")
- lblMainBranch.Text = lblMainBranch.Text + strResult.Substring(11);
- if (strResult.Substring(0, 5) == "lifeC")
- if (lblLifeCodes.Text == "")
- lblLifeCodes.Text = strResult.Substring(10);
- else
- lblLifeCodes.Text = lblLifeCodes.Text + "<br />" + strResult.Substring(10);
- }
- }
- }
- else
- {
- lblErrorMessage.Text = "<b>Error in Get User Info By Short UID:</b> User ID " + strUserShortUID + " does not exist";
- }
- }
- }
- else
- {
- lblErrorMessage.Text = "<b>Error in Get User Info By Short UID:</b> User ID must be entered.";
- }
- }
- catch (Exception ex)
- {
- lblErrorMessage.Text = "<b>Error in Get User Info By Short UID:</b> " + ex.Message;
- }
- }
- private string GetMultiple(string strValue, int intIndex)
- {
- if (strValue.IndexOf("|") == -1)
- {
- return String.Empty;
- }
- StringBuilder result = new StringBuilder(strValue.Substring(intIndex));
- result.Replace("|", "<br />");
- return result.ToString();
- }
- private SecurityServiceNew.SecurityService GetSecurityService()
- {
- // get webservice based on environment
- SecurityServiceNew.SecurityService svc = new SecurityServiceNew.SecurityService();
- string url = DataService.GetSecurityServiceURL(this.Session["environment"]);
- if (url != null)
- {
- // update URL
- svc.Url = url;
- }
- return svc;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement