private void ClearErrors() { HotelNameError.Dispose(); HotelEmailError.Dispose(); NumberError.Dispose(); DescriptionError.Dispose(); HotelRatingError.Dispose(); CountryError.Dispose(); StreetError.Dispose(); CityError.Dispose(); }
private bool CheckErrors() { bool Result = false; if (HotelCity.Text == "") { CityError.SetError(HotelCity, "Please Enter the Hotel City"); } if (HotelCountry.Text == "") { CountryError.SetError(HotelCountry, "Please Enter the Hotel Country"); } if (HotelStreet.Text == "") { StreetError.SetError(HotelStreet, "Please Enter the Hotel Street"); } if (!ValidHotelName(HotelName.Text)) { HotelNameError.SetError(HotelName, "This Hotel Name Already Exists"); Result = true; } if (!HelperClass.ValidEmail(HotelEmail.Text) || !HelperClass.UniqueHotelEmail(HotelEmail.Text, AddHotelConnection)) { HotelEmailError.SetError(HotelEmail, "This Email Is Not Valid or Already Exists"); Result = true; } if (!HelperClass.ValidPhoneNumber(HotelContactNumber.Text) || !HelperClass.UniqueHotelNumber(HotelContactNumber.Text, AddHotelConnection)) { NumberError.SetError(HotelContactNumber, "The Number Format You Entered Wrong, Correct Form 12 numbers Or Already Exists"); Result = true; } if (!HelperClass.ValidRating(HotelRating.Value)) { HotelRatingError.SetError(HotelRating, "Please Enter Rating For The Hotel"); Result = true; } return(Result); }
/// <summary> /// Check if athe number is on truecaller DB /// and return it /// </summary> public void TrueCallerInfo() { try { this.ErrorType = NumberError.none; var request = (HttpWebRequest)WebRequest.Create("http://truecaller.com/" + CountryAbb + "/" + number); request.UserAgent = settings.GetUserAgent(); request.Accept = settings.GetAccept(); request.Headers.Add("Accept-Language", "en-US,en;q=0.5"); request.Headers.Add("cookie", settings.GetCookie()); request.AllowAutoRedirect = false; var respons = (HttpWebResponse)request.GetResponse(); int resp_code = ((int)respons.StatusCode); string docmnt = new StreamReader(respons.GetResponseStream()).ReadToEnd(); try { settings.setLastDumbed(this.number); } catch { } WebHeaderCollection __respHEADERScollection = respons.Headers; for (int i = 0; i < __respHEADERScollection.Count; i++) { String header__ = __respHEADERScollection.GetKey(i); if (header__.ToLower() != "location") { continue; } String[] values = __respHEADERScollection.GetValues(header__); if (values.Length > 0) { this.SetSessionExpired(true); this.Checked_OntrueCaller = true; this.ErrorType = NumberError.SessionError; this.HasError = true; return; } } this.HasError = true; if (docmnt.Contains("You need to sign in to view the result")) { this.ErrorType = NumberError.SessionError; return; } if (docmnt.Contains("<p>The document has moved <a") || docmnt.Contains("Redirecting to <a href=\"http://www.truecaller.com\">http://www.truecaller.com</a>") || docmnt.Contains("You have excedeed your search limit. Please try again in 12 hours ")) { this.ErrorType = NumberError.SessionError; return; } bool IfoundThename = false, IfoundTheimage = false, Finished = false; string[] sepd = docmnt.Split(new string[] { "<" }, StringSplitOptions.RemoveEmptyEntries); if (docmnt.Contains("The truth is out there")) { this.ErrorType = NumberError.NotOnTrueCaller; this.HasError = false; return; } else if (docmnt.Contains(">You need to sign in to view the result")) { this.SetSessionExpired(true); this.ErrorType = NumberError.SessionError; this.Checked_OntrueCaller = false; return; } foreach (string s in sepd) { // check if number has name if (s.Contains("class=\"result__name") && !s.Contains("The truth is out there") && !IfoundThename) { Checked_OntrueCaller = true; this.TrueCalled_Stored = true; string[] rps = s.Split(new string[] { ">", "<" }, StringSplitOptions.RemoveEmptyEntries); this.name = rps[1]; IfoundThename = this.TrueCalled_Stored = true; this.ErrorType = NumberError.none; this.HasError = false; } // check if number has image else if (!IfoundTheimage && s.Contains("img width=\"128px\" height=\"128px\"") && s.Contains("truecaller.com/myview/")) { HasImage = true; string[] sepdbyqout = s.Split(new char[] { '"' }); if (sepdbyqout.Length > 5) { this.ImageLink = sepdbyqout[5]; } IfoundTheimage = true; } else if ((IfoundThename && IfoundTheimage) || Finished) { break; } } } catch (Exception x) { TrueCalled_Stored = false; this.HasError = true; if (x.Message.Contains("The remote name could not be resolved")) { this.ErrorType = NumberError.InternetError; } } }
/// <summary> /// Check if athe number is on truecaller DB /// and return it /// </summary> public void TrueCallerInfo() { try { this.ErrorType = NumberError.none; var request = (HttpWebRequest)WebRequest.Create("http://truecaller.com/" + CountryAbb + "/" + number); request.UserAgent = settings.GetUserAgent(); request.Accept = settings.GetAccept(); request.Headers.Add("Accept-Language", "en-US,en;q=0.5"); request.Headers.Add("cookie", settings.GetCookie()); request.AllowAutoRedirect = false; var respons = (HttpWebResponse)request.GetResponse(); int resp_code = ((int)respons.StatusCode); string docmnt = new StreamReader(respons.GetResponseStream()).ReadToEnd(); try { settings.setLastDumbed(this.number); } catch { } WebHeaderCollection __respHEADERScollection = respons.Headers; for (int i = 0; i < __respHEADERScollection.Count; i++) { String header__ = __respHEADERScollection.GetKey(i); if (header__.ToLower() != "location") continue; String[] values = __respHEADERScollection.GetValues(header__); if (values.Length > 0) { this.SetSessionExpired(true); this.Checked_OntrueCaller = true; this.ErrorType = NumberError.SessionError; this.HasError = true; return; } } this.HasError = true; if(docmnt.Contains("You need to sign in to view the result")) { this.ErrorType = NumberError.SessionError; return; } if(docmnt.Contains("<p>The document has moved <a")||docmnt.Contains("Redirecting to <a href=\"http://www.truecaller.com\">http://www.truecaller.com</a>")||docmnt.Contains("You have excedeed your search limit. Please try again in 12 hours ")) { this.ErrorType = NumberError.SessionError; return; } bool IfoundThename = false, IfoundTheimage=false,Finished=false; string[] sepd = docmnt.Split(new string[] { "<" }, StringSplitOptions.RemoveEmptyEntries); if (docmnt.Contains("The truth is out there")) { this.ErrorType = NumberError.NotOnTrueCaller; this.HasError = false; return; } else if (docmnt.Contains(">You need to sign in to view the result")) { this.SetSessionExpired(true); this.ErrorType = NumberError.SessionError; this.Checked_OntrueCaller = false; return; } foreach (string s in sepd) { // check if number has name if (s.Contains("class=\"result__name") && !s.Contains("The truth is out there") && !IfoundThename) { Checked_OntrueCaller = true; this.TrueCalled_Stored = true; string[] rps = s.Split(new string[] { ">", "<" }, StringSplitOptions.RemoveEmptyEntries); this.name = rps[1]; IfoundThename = this.TrueCalled_Stored=true; this.ErrorType = NumberError.none; this.HasError = false; } // check if number has image else if (!IfoundTheimage && s.Contains("img width=\"128px\" height=\"128px\"") && s.Contains("truecaller.com/myview/")) { HasImage = true; string[] sepdbyqout = s.Split(new char[] { '"' }); if (sepdbyqout.Length > 5) this.ImageLink = sepdbyqout[5]; IfoundTheimage = true; } else if ((IfoundThename && IfoundTheimage) || Finished) break; } } catch(Exception x) { TrueCalled_Stored = false; this.HasError = true; if (x.Message.Contains("The remote name could not be resolved")) this.ErrorType = NumberError.InternetError; } }