public static ClientAttributes GetClientInfo(string customer_code) { ClientAttributes Client = new ClientAttributes(); string query = "Select id,Name,SubDomainName from cc_masterdataset.customer where SubDomainName='" + customer_code + "'"; SqlConnection conn = new SqlConnection(DBConnectionString()); conn.Open(); SqlCommand cmd = new SqlCommand(); cmd = new SqlCommand(query, conn); SqlDataReader rd = cmd.ExecuteReader(); rd.Read(); if (rd.HasRows) { Client.ID = Convert.ToInt32(rd["id"].ToString()); Client.Name = rd["Name"].ToString(); Client.Isvalid = true; Client.Subdm = rd["SubDomainName"].ToString(); } else { Client.ID = 0; Client.Name = "Wrong Domain"; Client.Isvalid = false; Client.Subdm = "Wrong Sub Domain"; } conn.Close(); return(Client); }
public static AdminDomainAttributes AdminSplitUrl(Uri url) { AdminDomainAttributes Dm = new AdminDomainAttributes(); ClientAttributes client = new ClientAttributes(); string host = url.Host; Dm.Length = host.Split('.').Length; switch (Dm.Length) { case 3: client = GetClientInfo(host.Split('.')[0]); Dm.DmID = client.ID; Dm.DmName = client.Name; Dm.Subdm = client.Subdm; break; default: myredirect("Invalid Url Contact Administration."); break; } return(Dm); }
public static DomainAttributes SplitUrl(Uri url, string subdomain) { string Appsettingquery = "Select * from [cc_masterdataset].[customersettings] where [Customer_Id]="; string Faxcostquery = "SELECT Cost FROM cc_clientdataset.delivery_type where (Type = 'Fax') AND Customer_Id="; string Emailcostquery = "SELECT Cost FROM cc_clientdataset.delivery_type where (Type = 'Email') AND Customer_Id="; string AdditionalCopyquery = "SELECT Cost FROM cc_clientdataset.service WHERE (Type = 'Additional Copy') AND Customer_Id ="; DomainAttributes Dm = new DomainAttributes(); ClientAttributes client = new ClientAttributes(); string host = url.Host; Dm.Length = host.Split('.').Length; if (subdomain != "nosubdomain") { Dm.IsMultidomain = true; client = GetClientInfo(host.Split('.')[0]); Dm.DmID = client.ID; Dm.DmName = client.Name; client = GetClientInfo(subdomain); Dm.SubDmID = client.ID; Dm.SubDmName = client.Name; Appsettingquery += Dm.SubDmID; Faxcostquery += Dm.SubDmID; AdditionalCopyquery += Dm.SubDmID; Emailcostquery += Dm.SubDmID; } else { client = GetClientInfo(host.Split('.')[0]); Dm.IsMultidomain = false; Dm.DmID = client.ID; Dm.DmName = client.Name; Dm.SubDmID = 0; Dm.SubDmName = ""; Appsettingquery += Dm.DmID; Faxcostquery += Dm.DmID; AdditionalCopyquery += Dm.DmID; Emailcostquery += Dm.DmID; } //switch (Dm.Length) //{ // case 3: // client = GetClientInfo(host.Split('.')[0]); // Dm.IsMultidomain = false; // Dm.DmID = client.ID; // Dm.DmName = client.Name; // Dm.SubDmID = 0; // Dm.SubDmName = ""; // Appsettingquery += Dm.DmID; // Faxcostquery += Dm.DmID; // AdditionalCopyquery += Dm.DmID; // Emailcostquery += Dm.DmID; // break; // case 4: // Dm.IsMultidomain = true; // client = GetClientInfo(host.Split('.')[1]); // Dm.DmID = client.ID; // Dm.DmName = client.Name; // client = GetClientInfo(host.Split('.')[0]); // Dm.SubDmID = client.ID; // Dm.SubDmName = client.Name; // Appsettingquery += Dm.SubDmID; // Faxcostquery += Dm.SubDmID; // AdditionalCopyquery += Dm.SubDmID; // Emailcostquery += Dm.SubDmID; // break; //} //Application settings DataSet ds = new DataSet(); ds = GetDataSet(Appsettingquery); if (ds.Tables[0].Rows.Count > 0) { Dm.EducationalInstruction = ds.Tables[0].Rows[0]["Education_Instructions"].ToString(); Dm.DeliveryInstruction = ds.Tables[0].Rows[0]["Delivery_Instructions"].ToString(); Dm.DocumentInstruction = ds.Tables[0].Rows[0]["Document_Instructions"].ToString(); Dm.IncludedCopies = Convert.ToInt32(ds.Tables[0].Rows[0]["Delivery_copy"].ToString()); Dm.IsRedirect = Convert.ToInt32(ds.Tables[0].Rows[0]["ThkuPage"].ToString()); Dm.RedirectUrl = ds.Tables[0].Rows[0]["SiteUrl"].ToString(); Dm.IsCreditcard = Convert.ToInt32(ds.Tables[0].Rows[0]["CreditCard"].ToString()); Dm.SupportedCards = ds.Tables[0].Rows[0]["Credit_Type"].ToString(); Dm.AddSection = Convert.ToBoolean(ds.Tables[0].Rows[0]["Additional_Section"].ToString()); Dm.FaxSection = Convert.ToBoolean(ds.Tables[0].Rows[0]["Fax_Section"].ToString()); Dm.EmailSection = Convert.ToBoolean(ds.Tables[0].Rows[0]["Email_Section"].ToString()); Dm.Talentdb = Convert.ToBoolean(ds.Tables[0].Rows[0]["Talent_Database"].ToString()); Dm.PurposeSection = Convert.ToBoolean(ds.Tables[0].Rows[0]["Purpose_Section"].ToString()); Dm.Lock_PurposeId = Convert.ToInt32(ds.Tables[0].Rows[0]["Lock_PurposeId"].ToString()); Dm.Lock_TargetName = ds.Tables[0].Rows[0]["Lock_TargetName"].ToString(); Dm.Lock_State = ds.Tables[0].Rows[0]["Lock_State"].ToString(); Dm.Spl_Instruction = ds.Tables[0].Rows[0]["Spl_Instruction"].ToString(); Dm.Completed_Instruction = ds.Tables[0].Rows[0]["Completed_Instruction"].ToString(); Dm.Appl_Upload = Convert.ToBoolean(ds.Tables[0].Rows[0]["Applicant_Upload"].ToString()); Dm.App_Type = Convert.ToInt32(ds.Tables[0].Rows[0]["Application_Type"].ToString()); Dm.Target_Section = Convert.ToInt32(ds.Tables[0].Rows[0]["Target_Section"].ToString()); Dm.Onlinecc = Convert.ToInt32(ds.Tables[0].Rows[0]["Onlinecc"].ToString()); Dm.Creditcard_Instructions = ds.Tables[0].Rows[0]["Creditcard_Instructions"].ToString(); Dm.Moneyorder = Convert.ToInt32(ds.Tables[0].Rows[0]["Moneyorder"].ToString()); Dm.Moneyorder_Instructions = ds.Tables[0].Rows[0]["Moneyorder_Instructions"].ToString(); Dm.Personalcheck = Convert.ToInt32(ds.Tables[0].Rows[0]["Personalcheck"].ToString()); Dm.Personalcheck_Instructions = ds.Tables[0].Rows[0]["Personalcheck_Instructions"].ToString(); } //Cost settings ds.Clear(); ds = GetDataSet(Faxcostquery); if (ds.Tables[0].Rows.Count > 0) { Dm.FaxCopy = Convert.ToInt32(ds.Tables[0].Rows[0]["Cost"].ToString()); } else { Dm.FaxCopy = 0; } ds.Clear(); ds = GetDataSet(AdditionalCopyquery); if (ds.Tables[0].Rows.Count > 0) { Dm.AdditionalCopy = Convert.ToInt32(ds.Tables[0].Rows[0]["Cost"].ToString()); } else { Dm.AdditionalCopy = 0; } ds.Clear(); ds = GetDataSet(Emailcostquery); if (ds.Tables[0].Rows.Count > 0) { Dm.EmailCopy = Convert.ToInt32(ds.Tables[0].Rows[0]["Cost"].ToString()); } else { Dm.EmailCopy = 0; } return(Dm); }