private void CreateGMTEntries() { const string GmtShort = "GMT"; const string GmtLong = "Greenwich Mean Time"; TimeZones.Add(GmtShort.ToLower(), new TimeZoneTO(GmtShort, GmtShort, GmtLong)); TimeZones.Add(GmtLong.ToLower(), new TimeZoneTO(GmtShort, GmtShort, GmtLong)); for (int hours = -12; hours < 13; hours++) { if (hours != 0) { for (int minutes = 0; minutes < 2; minutes++) { var min = minutes == 0 ? "00" : "30"; var hrs = string.Concat(hours / Math.Abs(hours) < 0 ? "-" : "+", Math.Abs(hours).ToString(CultureInfo.InvariantCulture).PadLeft(2, '0')); var gmt = string.Concat(GmtShort, hrs, ":", min); TimeZones.Add(gmt.ToLower(), new TimeZoneTO(GmtShort, gmt, GmtLong)); } } else { TimeZones.Add(GmtShort + "-00:30", new TimeZoneTO(GmtShort, GmtShort + "-00:30", GmtLong)); TimeZones.Add(GmtShort + "+00:30", new TimeZoneTO(GmtShort, GmtShort + "+00:30", GmtLong)); } } }
public void GetZonesByIso_Invalid() { // Invalid var c = TimeZones.GetZonesByIso("INVALID"); Assert.Null(c); }
public RankChartGenerator(Database db, RankChartParameters rcp, string title) { _db = db; _rcp = rcp; _title = title; //Look up the time zone of the user _timeZone = TimeZones.GetTimeZone(_rcp.TimezoneOffsetIndex); //Determine the time range if (rcp.DateRangeType == DateRangeSelector.DateRanges.Custom) { _start = _rcp.StartTime; _end = _rcp.EndTime; } else { DateRangeSelector.GetDateRangeByType(rcp.DateRangeType, out _start, out _end); } //Add 1 day to the end of the range, so that it ecompasses the whole last day in the range _end = _end.AddDays(1); _chart = new XYChart(ChartWidth, ChartHeight, 0xeeeeee, 0x000000, 1); Chart.setLicenseCode(CHARTDIRECTOR_LICENSE); }
/// <summary> /// Busca el horario respecto un dia especificado /// </summary> /// <param name="day">dia a buscar</param> /// <returns>retorna el horario, nulo en caso de error</returns> public TimeZones searchTimeZone(String day) { TimeZones timeZone = new TimeZones(); timeZone = model.searchTimeZone(day); return(timeZone); }
private static String FormatTime(TimeZones whichTimeZone, TimeFormatting typeOfFormatting) { String formattedTime = ""; DateTimeOffset localDateTime = GetLocalDateTime(whichTimeZone); int hour = localDateTime.Hour; int minute = localDateTime.Minute; int second = localDateTime.Second; switch (typeOfFormatting) { case TimeFormatting.NUMERIC: formattedTime = FormatTimeNumeric(hour, minute, second); if (whichTimeZone == TimeZones.UTC) { formattedTime += "Z"; } break; case TimeFormatting.APPROXIMATE_WORDING: formattedTime = FormatTimeApproximateWording(hour, minute, second); if (whichTimeZone == TimeZones.UTC) { formattedTime += " Zulu"; } break; } return(formattedTime); }
/// <summary> /// Adds an <see cref="iCalObject"/>-based component to the /// appropriate collection. Currently, the iCalendar component /// supports the following components: /// <list type="bullet"> /// <item><see cref="DDay.iCal.Components.Event"/></item> /// <item><see cref="DDay.iCal.Components.FreeBusy"/></item> /// <item><see cref="DDay.iCal.Components.Journal"/></item> /// <item><see cref="DDay.iCal.Components.TimeZone"/></item> /// <item><see cref="DDay.iCal.Components.Todo"/></item> /// </list> /// </summary> /// <param name="child"></param> public override void AddChild(iCalObject child) { base.AddChild(child); child.Parent = this; if (child is UniqueComponent) { UniqueComponents.Add((UniqueComponent)child); } Type type = child.GetType(); if (type == typeof(Event) || type.IsSubclassOf(typeof(Event))) { Events.Add((Event)child); } else if (type == typeof(FreeBusy) || type.IsSubclassOf(typeof(FreeBusy))) { FreeBusy.Add((FreeBusy)child); } else if (type == typeof(Journal) || type.IsSubclassOf(typeof(Journal))) { Journals.Add((Journal)child); } else if (type == typeof(iCalTimeZone) || type.IsSubclassOf(typeof(iCalTimeZone))) { TimeZones.Add((iCalTimeZone)child); } else if (type == typeof(Todo) || type.IsSubclassOf(typeof(Todo))) { Todos.Add((Todo)child); } }
//// GET: Configurations //public async Task<ActionResult> Index() //{ // return View(await db.Configurations.ToListAsync()); //} //// GET: Configurations/Details/5 //public async Task<ActionResult> Details(int? id) //{ // if (id == null) // { // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); // } // Configuration configuration = await db.Configurations.FindAsync(id); // if (configuration == null) // { // return HttpNotFound(); // } // return View(configuration); //} //// GET: Configurations/Create //public ActionResult Create() //{ // return View(); //} //// POST: Configurations/Create //// To protect from overposting attacks, please enable the specific properties you want to bind to, for //// more details see http://go.microsoft.com/fwlink/?LinkId=317598. //[HttpPost] //[ValidateAntiForgeryToken] //public async Task<ActionResult> Create([Bind(Include = "ID,ConfigAdminID,CompanyName,ShortTitle,Tagline,WebsiteURL,Email,LogoPath,ThemeColor,PropertyRenewal,SchedulerInterval,TimeZoneId,CompanyDescription")] Configuration configuration) //{ // if (ModelState.IsValid) // { // db.Configurations.Add(configuration); // await db.SaveChangesAsync(); // return RedirectToAction("Index"); // } // return View(configuration); //} // GET: Configurations/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Configuration configuration = await db.Configurations.FindAsync(id); if (configuration == null && id != 1) { return(HttpNotFound()); } else if (configuration == null && id == 1) { strCurrentUserId = User.Identity.GetUserId(); Configuration con = new Configuration { ID = 1, ConfigAdminID = strCurrentUserId, CompanyName = "Property4U", ShortTitle = "P4U", Tagline = "Open Source Real Estate 2.0", WebsiteURL = "www.property4u.com.pk", Email = "*****@*****.**", OfficeAddress = "Minar-e-Pakistan, Circular Rd Lahore Punjab, Pakistan", LogoPath = "P4U_logo.png", Favicon = "P4U_favicon.png", ThemeColor = ThemeColor.Blue, PropertyRenewal = PropertyRenewal.Monthly, RenewalCost = 20.00, TimeZoneId = "Pakistan Standard Time", CompanyDescription = "Property4U is an Open Source Real Estate 2.0 solution completely equipped with Buying, Selling, Renting and Bidding features. It also provides Developer APIs.", Keywords = "p4u, realtors, selling house fast, quickly configurable, open source, real estate 2.0, real estate bidding 2.0, search real estate agent", LastEdit = DateTime.Now }; db.Configurations.Add(con); await db.SaveChangesAsync(); Property4U.Core.ConfigSys.Settings = con; return(RedirectToAction("Edit", null, new { id = id })); } ViewBag.ConfigAdminID = configuration.ConfigAdminID; SelectList timeZones = new SelectList(TimeZones.GetTimeZoneHelpers(), "Id", "DisplayName", configuration.TimeZone); ViewBag.TimeZoneId = timeZones; ViewBag.LastEdit = DateTime.Now; return(View(configuration)); }
/// <summary> /// Removes an <see cref="iCalObject"/>-based component from all /// of the collections that this object may be contained in within /// the iCalendar. /// </summary> /// <param name="child"></param> public override void RemoveChild(iCalObject child) { base.RemoveChild(child); if (child is UniqueComponent) { UniqueComponents.Remove((UniqueComponent)child); } Type type = child.GetType(); if (type == typeof(Event) || type.IsSubclassOf(typeof(Event))) { Events.Remove((Event)child); } else if (type == typeof(FreeBusy) || type.IsSubclassOf(typeof(FreeBusy))) { FreeBusy.Remove((FreeBusy)child); } else if (type == typeof(Journal) || type.IsSubclassOf(typeof(Journal))) { Journals.Remove((Journal)child); } else if (type == typeof(DDay.iCal.Components.TimeZone) || type.IsSubclassOf(typeof(DDay.iCal.Components.TimeZone))) { TimeZones.Remove((DDay.iCal.Components.TimeZone)child); } else if (type == typeof(Todo) || type.IsSubclassOf(typeof(Todo))) { Todos.Remove((Todo)child); } }
// GET: Configurations/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Configuration configuration = await db.Configurations.FindAsync(id); if (configuration == null && id != 1) { return(HttpNotFound()); } else if (configuration == null && id == 1) { strCurrentUserId = User.Identity.GetUserId(); Configuration con = new Configuration { ID = 1, ConfigAdminID = strCurrentUserId, CompanyName = "DreamFlat", ShortTitle = "DFBD", Tagline = "Best Property Service in BD", WebsiteURL = "www.dreamflat.com.bd", Email = "*****@*****.**", OfficeAddress = "Abiding Neela, Shahid Baki Road Khilgaon, Dhaka", LogoPath = "logo.png", Favicon = "favicon.png", ThemeColor = ThemeColor.Blue, PropertyRenewal = PropertyRenewal.Monthly, RenewalCost = 20.00, TimeZoneId = "Bangladesh Standard Time", CompanyDescription = "Dream Flat is completely equipped with Buying, Selling, Renting, and Bidding features. The best Property management service in BD. lorem ipsum color dot amet.", Keywords = "dfbd, real state, selling house fast, rent, buy, loan, real estate bidding, search real estate agent", LastEdit = DateTime.Now }; db.Configurations.Add(con); await db.SaveChangesAsync(); DreamFlat.Core.ConfigSys.Settings = con; return(RedirectToAction("Edit", null, new { id = id })); } ViewBag.ConfigAdminID = configuration.ConfigAdminID; SelectList timeZones = new SelectList(TimeZones.GetTimeZoneHelpers(), "Id", "DisplayName", configuration.TimeZone); ViewBag.TimeZoneId = timeZones; ViewBag.LastEdit = DateTime.Now; return(View(configuration)); }
public void Add() { Model.TimeZone item = new Model.TimeZone(); TimeZoneRepository.Instance.SetItem(item); TimeZones.Add(item); SelectedTimeZone = item; }
public void TestNewIndianaTZ() { string tzId = "America/Indiana/Indianapolis"; // google is returning this in some geo calls under the property: "timeZoneId" TimeZoneInfo tzi = TimeZones.GetTimeZoneInfoFromTZId(tzId); True(tzi != null && tzi.Id == "Eastern Standard Time"); }
public RegistrationWindowVM(RegistrationWindow window) { _window = window; _isClient = true; TimeZones = TimeZoneRepository.Instance.GetAllItems(); TimeZones.Sort(CompareTimeZonesByHour); }
public List <Entities.TimeZone> RetrieveAll() { SqlCommand command = null; SqlDataAdapter adapter = null; try { command = mDbConnection.CreateCommand(); command.CommandText = "RetrieveAllTimeZones"; command.CommandType = CommandType.StoredProcedure; adapter = new SqlDataAdapter(command); DataTable TimeZoneDataTable = new DataTable("TimeZone"); adapter.Fill(TimeZoneDataTable); //create a List List <Entities.TimeZone> TimeZones = null; if (TimeZoneDataTable.Rows.Count > 0) { TimeZones = new List <Entities.TimeZone>(); } // Iterate each row. foreach (DataRow row in TimeZoneDataTable.Rows) { // Create an instance of TimeZones. Entities.TimeZone timezone = new Entities.TimeZone(Int32.Parse(row["TimeZoneId"].ToString())); timezone.Name = row["Name"].ToString(); timezone.ShortName = row["ShortName"].ToString(); timezone.Description = row["Description"].ToString(); timezone.Reason = row["Reason"].ToString(); timezone.IsActive = bool.Parse(row["IsActive"].ToString()); timezone.LastUpdateUserId = Int32.Parse(row["LastUpdateUserId"].ToString()); timezone.LastUpdateDate = DateTime.Parse(row["LastUpdateDate"].ToString()); // Add to the List TimeZones.Add(timezone); } // Return the list. return(TimeZones); } catch { throw; } finally { // Dispose. if (adapter != null) { adapter.Dispose(); } if (command != null) { command.Dispose(); } } }
public ActionResult Index() { SectionViewModel model = new SectionViewModel(); model = DecorateViewModel <SectionViewModel>(model); model.TimeZones = TimeZones.getDictionary(); return(View(model)); }
/// <summary> /// Searches for geographical locations synchronously. /// </summary> /// <param name="searchString">String to search</param> /// <returns>List of location items matching the specified search string</returns> private List <LocationSearchItem> Search(string searchString) { List <LocationSearchItem> results = new List <LocationSearchItem>(); if (searchString.Length == 0) { return(results); } var stringPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Data", "Cities.dat"); FileStream _FileStream = File.OpenRead(stringPath); using (var fileReader = new StreamReader(_FileStream, Encoding.UTF8)) { _LastSearchString = searchString; string line = null; try { while ((line = fileReader.ReadLine()) != null && searchString.Equals(_LastSearchString)) { string[] chunks = line.Split('\t'); var names = new List <string>(); names.Add(chunks[1]); names.AddRange(chunks[3].Split(',')); var name = names.FirstOrDefault(s => s.Replace("\'", "").StartsWith(searchString, StringComparison.InvariantCultureIgnoreCase)); if (name != null) { double latitude = double.Parse(chunks[4], CultureInfo.InvariantCulture); double longitude = double.Parse(chunks[5], CultureInfo.InvariantCulture); double elevation = double.Parse(string.IsNullOrWhiteSpace(chunks[15]) ? "0" : chunks[15], CultureInfo.InvariantCulture); TimeZoneItem timeZone = TimeZones.FirstOrDefault(tz => tz.TimeZoneId.Equals(chunks[17], StringComparison.InvariantCultureIgnoreCase)); results.Add(new LocationSearchItem { Name = name, Country = chunks[8], Names = string.Join(", ", names.Distinct().Except(new[] { name }).ToArray()), Location = new CrdsGeographical(-longitude, latitude, timeZone.UtcOffset, elevation, timeZone.TimeZoneId, name) }); if (results.Count == 10) { break; } } } } catch (Exception ex) { } return(results.OrderBy(r => r.Name).ToList()); } }
public async Task OnControlCenterEscalation([ServiceBusTrigger("efp-api-escalation-topic", "efp-api-escalation-sub-send-notification")] BrokeredMessage message, TraceWriter trace) { message.Complete(); try { var deserializedObject = DeserializeBrokeredMessage <string>(message); var parsedJObject = JObject.Parse(deserializedObject); string recepient = parsedJObject["Entity"]["To"].ToObject <string>(); Workorder deserializedWorkorder = parsedJObject["Entity"]["Workorder"].ToObject <Workorder>(); Product parsedProduct = parsedJObject["Entity"]["Product"].ToObject <Product>(); EventMonitor eventMonitor = parsedJObject["Entity"]["EventMonitor"].ToObject <EventMonitor>(); var workorder = await _apiService.WorkorderData(deserializedWorkorder.Id); TimeZones timezoneId = await _apiService.TimeZoneData(workorder.Site.TimeZone); Product product = await _apiService.ProductData(parsedProduct.Id); bool sublocation = product.Group.Name == "SUBLOCATION"; if (!recepient.Contains("@")) { using (MailService mailService = new MailService(_cultureService)) { mailService.CreateTwilioClient(); var body = sublocation ? mailService.SmsSublocation(workorder, product) : mailService.SmsEquipment(workorder, product); var result = await MessageResource.CreateAsync(new PhoneNumber(recepient), from : new PhoneNumber("+13094200014"), body : body); LogData(trace, $"Sent sms to {result.To} for workorder: {workorder.Id} for escalation: {eventMonitor.Name}", false); } } else { var templateKey = sublocation ? "TemplateEscalationSublocation" : "TemplateEscalationEquipment"; using (MailService mailService = new MailService(_cultureService)) { MailMessage mail = mailService.EscalationMail(workorder, product, eventMonitor, timezoneId, recepient, templateKey); mailService.SmtpClient.Send(mail); } LogData(trace, $"Sent mail to {recepient} for workorder: {workorder.Id} for escalation: {eventMonitor.Name}", false); } } catch (Exception ex) { LogData(trace, $"Message:{ex.Message} InnerException:{ex.InnerException} StackTrace:{ex.StackTrace}", true); } LogData(trace, "Escalation Alert Sending Finished", false); }
protected bool Equals(Calendar other) { return(string.Equals(Name, other.Name, StringComparison.OrdinalIgnoreCase) && UniqueComponents.SequenceEqual(other.UniqueComponents) && Events.SequenceEqual(other.Events) && Todos.SequenceEqual(other.Todos) && Journals.SequenceEqual(other.Journals) && FreeBusy.SequenceEqual(other.FreeBusy) && TimeZones.SequenceEqual(other.TimeZones)); }
public void Dispose() { Children.Clear(); Events.Clear(); FreeBusy.Clear(); Journals.Clear(); Todos.Clear(); TimeZones.Clear(); UniqueComponents.Clear(); }
public void GetTimeZone_InvalidZone_Failure() { var timeZones = new TimeZones(_connectionServer); ConnectionTimeZone oTemp; WebCallResult res = timeZones.GetTimeZone(-1, out oTemp); Assert.IsFalse(res.Success, "Fetching time zone of -1 should fail."); }
public void SendEscalationSublocationTemplate() { var timezone = new TimeZones { InfoId = "Eastern Standard Time" }; var mail = _mailService.EscalationMail(_workorder, _sublocation, _eventMonitor, timezone, "*****@*****.**", "TemplateEscalationSublocation"); _mailService.SmtpClient.Send(mail); }
void CompDateValue_DateTimeValueChanged(object sender, EventArgs e) { if ((CompDateValue.DateTimeValue != null)) { TimeZones tzones = new TimeZones(); TimeZone comptz = tzones.FindTimeZone(CompTzSelect.SelectedValue, TimeZones.TZFindType.ftDisplayName); DateTime newDateTime = (DateTime)(CompDateValue.DateTimeValue); newDateTime = newDateTime.AddMinutes(-1 * TimeZone.BiasForGivenDate(newDateTime)); CurrDateValue.DateTimeValue = newDateTime.AddMinutes(comptz.BiasForGivenDate(newDateTime)); } }
private static void initializeAvailable() { TimeZone[] zones = TimeZones.getTimeZones(); AvailableZones = new HashMap <String, TimeZone>( (zones.Length + 1) * 4 / 3); AvailableZones.put(GMT.getID(), GMT); for (int i = 0; i < zones.Length; i++) { AvailableZones.put(zones[i].getID(), zones[i]); } }
public static DateTime TransformToLocalTime(TimeZones timeZoneEnum, DateTime utc) { var timeZone = GetTimeZoneInfo(timeZoneEnum); if (timeZone == null) { return(utc); } return(utc + timeZone.GetUtcOffset(utc)); }
public static String GetFormattedTime(TimeZones whichTimeZone, TimeFormatting typeOfFormatting, Boolean eMailTimeFlag) { String formattedTime = FormatTime(whichTimeZone, typeOfFormatting); if (eMailTimeFlag) { SendEmail(formattedTime); } return(formattedTime); }
public PageAirlineData(StartDataObject startData) { this.AllTimeZones = TimeZones.GetTimeZones(); this.AllAirports = new ObservableCollection <Airport>(); this.StartData = startData; InitializeComponent(); var airlines = Airlines.GetAirlines(airline => (airline.Profile.Country.Region == this.StartData.Region || (this.StartData.Region.Uid == "100" && this.StartData.Continent.Uid == "100") || (this.StartData.Region.Uid == "100" && this.StartData.Continent.hasRegion(airline.Profile.Country.Region))) && airline.Profile.Founded <= this.StartData.Year && airline.Profile.Folded > this.StartData.Year).OrderBy(a => a.Profile.Name).ToList(); cbAirline.ItemsSource = airlines; }
private static TimeZoneInfo GetTimeZoneInfo(TimeZones value) { var fieldInfo = value.GetType().GetField(value.ToString()); var timeZoneId = fieldInfo.GetDisplayShortName(); if (timeZoneId == null) { return(null); } return(TimeZoneInfo.FindSystemTimeZoneById(timeZoneId)); }
public void GetTimeZone_Success() { var timeZones = new TimeZones(_connectionServer); ConnectionTimeZone oTemp; WebCallResult res = timeZones.GetTimeZone(227, out oTemp); Assert.IsTrue(res.Success, "Failed to fetch 227 time zone:" + res.ToString()); Console.WriteLine(oTemp.ToString()); }
public async Task <ActionResult> Edit([Bind(Include = "ID,ConfigAdminID,CompanyName,ShortTitle,Tagline,WebsiteURL,Email,PublicPhoneNo,OfficeAddress,LogoPath,Favicon,ThemeColor,PropertyRenewal,RenewalCost,SchedulerInterval,TimeZoneId,CompanyDescription,Keywords,FacebookAppId,FacebookAppSecret,GoogleClientId,GoogleClientSecret,FacebookURL,TwitterURL,GooglePlusURL,LinkedInURL,DribbbleURL,LastEdit")] Configuration configuration, HttpPostedFileBase logoFile, string oldLogoPath, HttpPostedFileBase faviconFile, string oldfaviconPath) { if (ModelState.IsValid) { if (logoFile != null) { string logoImageName = Path.GetFileName(logoFile.FileName); string configlogoToPath = Path.Combine(Server.MapPath("~/Content/Uploads/Assets"), logoImageName); if (!System.IO.File.Exists(configlogoToPath)) { // Delete previously uploaded file System.IO.File.Delete(Path.Combine(Server.MapPath("~/Content/Uploads/Assets"), oldLogoPath)); // New file is uploaded logoFile.SaveAs(configlogoToPath); configuration.LogoPath = logoImageName; } } if (faviconFile != null) { string favImageName = Path.GetFileName(faviconFile.FileName); string configFavToPath = Path.Combine(Server.MapPath("~/Content/Uploads/Assets"), favImageName); if (!System.IO.File.Exists(configFavToPath)) { // Delete previously uploaded file System.IO.File.Delete(Path.Combine(Server.MapPath("~/Content/Uploads/Assets"), oldfaviconPath)); // New file is uploaded faviconFile.SaveAs(configFavToPath); configuration.Favicon = favImageName; } } // Remove PROTOCOL(http://) from URI System.Uri uri = new Uri(configuration.WebsiteURL); configuration.WebsiteURL = uri.Host + uri.PathAndQuery; db.Entry(configuration).State = EntityState.Modified; await db.SaveChangesAsync(); DreamFlat.Core.ConfigSys.Settings = configuration; return(RedirectToAction("Edit", null, new { id = configuration.ID })); } ViewBag.ConfigAdminID = configuration.ConfigAdminID; SelectList timeZones = new SelectList(TimeZones.GetTimeZoneHelpers(), "Id", "DisplayName", configuration.TimeZone); ViewBag.TimeZoneId = timeZones; ViewBag.LastEdit = DateTime.Now; return(View(configuration)); }
public void CanGetTimeZones() { // arrange, act ReadOnlyCollection <TimeZoneInfo> timeZones = TimeZones.GetTimeZones(); foreach (TimeZoneInfo timeZone in timeZones) { Console.WriteLine(timeZone.Id.GetHashCode() + "\t" + timeZone.StandardName); } // assert Assert.Greater(timeZones.Count, 10); }
public void GenerateUpdateScript() { string sql = string.Empty; string sqlFormat = "UPDATE [<dbUser,varchar,dbo>].[subtext_Config] SET TimeZoneId = '{0}' WHERE TimeZone = {1}" + Environment.NewLine + "GO" + Environment.NewLine; foreach (TimeZoneInfo timezone in TimeZones.GetTimeZones()) { sql += String.Format(sqlFormat, timezone.Id, timezone.Id.GetHashCode()); } Console.Write(sql); }
void CompDateValue_DateTimeValueChanged(object sender, EventArgs e) { if ((CompDateValue.DateTimeValue != null)) { TimeZones tzones = new TimeZones(); TimeZone comptz = tzones.FindTimeZone(CompTzSelect.SelectedValue, TimeZones.TZFindType.ftDisplayName); DateTime newDateTime = (DateTime)(CompDateValue.DateTimeValue); newDateTime = newDateTime.AddMinutes(-1 * TimeZone.BiasForGivenDate(newDateTime)); CurrDateValue.DateTimeValue = newDateTime.AddMinutes(comptz.BiasForGivenDate(newDateTime)); } }
protected void Page_Load(object sender, EventArgs e) { Util util = new Util(); Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID]; if (util.CheckSessionTimeout(State,Response,"Default.aspx")) return; try { if (!IsPostBack) { CopyRight.InnerText = HttpRuntime.Cache["CopyRight"].ToString(); UserLabel.Text = State["Username"].ToString(); } if ( HttpRuntime.Cache["TechSupportEmail"] != null) { util.AddEmailToButton(SupportButton, HttpRuntime.Cache["TechSupportEmail"].ToString(), "Email To Tech Support"); } util.UpdateSessionLog(State, "post", "TabMyProfile"); if (State["ServerAdminCustomerUsername"] != null) UsernameLabel.Text = State["ServerAdminCustomerUsername"].ToString(); else UsernameLabel.Text = State["Username"].ToString(); Message.Text = ""; string sql = null; if (State["Username"].ToString() != "admin") { sql = "SELECT * FROM customers WHERE customer_id='" + State["CustomerID"].ToString() + "'"; } else { sql = "SELECT * FROM customers WHERE customer_id='" + State["ServerAdminCustomerID"].ToString() + "'"; } DB db = new DB(); DataRow[] rows = db.ViziAppsExecuteSql(State, sql); DataRow row = rows[0]; PasswordTextBox.Text = ""; ConfirmPasswordBox.Text = ""; CompanyTextBox.Text = util.DecodeMySql(row["company"].ToString()); RoleTextBox.Text = util.DecodeMySql(row["role"].ToString()); FirstNameTextBox.Text = util.DecodeMySql(row["first_name"].ToString()); LastNameTextBox.Text = util.DecodeMySql(row["last_name"].ToString()); StreetTextBox.Text = util.DecodeMySql(row["street_address"].ToString()); CityTextBox.Text = util.DecodeMySql(row["city"].ToString()); if (row["state"] != null && row["state"].ToString().Length > 0) StateList.Text = row["state"].ToString(); PostalCodeTextBox.Text = row["postal_code"].ToString(); CountryTextBox.Text = util.DecodeMySql(row["country"].ToString()); PhoneTextbox.Text = row["phone"].ToString(); EmailTextBox.Text = row["email"].ToString(); string status = row["status"].ToString(); //Additions for the CC fields if (!IsPostBack) { CCFirstNameTextbox.Text = util.DecodeMySql(row["first_name"].ToString()); CCLastNameTextBox.Text = util.DecodeMySql(row["last_name"].ToString()); CCZipTextBox.Text = row["postal_code"].ToString(); } db.CloseViziAppsDatabase(State); TimeZones zone_util = new TimeZones(); string default_time_zone_delta_hours = row["default_time_zone_delta_hours"].ToString(); zone_util.InitTimeZones(State, DateTime.Now.ToUniversalTime(), TimeZoneList, default_time_zone_delta_hours); string force_1_user_sessions = row["force_1_user_sessions"].ToString(); Force1UserSessions.Checked = force_1_user_sessions == "1" || force_1_user_sessions.ToLower() == "true"; } catch (Exception ex) { util.ProcessMainExceptions(State, Response, ex); } }
protected void UpdateProfile_Click(object sender, EventArgs e) { Util util = new Util(); Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID]; if (util.CheckSessionTimeout(State, Response, "Default.aspx")) return; Message.Text = ""; PasswordTextBox.Text = Request.Form.Get("PasswordTextBox"); ConfirmPasswordBox.Text = Request.Form.Get("ConfirmPasswordBox"); CompanyTextBox.Text = Request.Form.Get("CompanyTextBox"); RoleTextBox.Text = Request.Form.Get("RoleTextBox"); FirstNameTextBox.Text = Request.Form.Get("FirstNameTextBox"); LastNameTextBox.Text = Request.Form.Get("LastNameTextBox"); StreetTextBox.Text = Request.Form.Get("StreetTextBox"); CityTextBox.Text = Request.Form.Get("CityTextBox"); StateList.Text = Request.Form.Get("StateList"); PostalCodeTextBox.Text = Request.Form.Get("PostalCodeTextBox"); CountryTextBox.Text = Request.Form.Get("CountryTextBox"); PhoneTextbox.Text = Request.Form.Get("PhoneTextbox"); EmailTextBox.Text = Request.Form.Get("EmailTextBox"); string force_1_user_sessions = Request.Form.Get("Force1UserSessions"); Force1UserSessions.Checked = force_1_user_sessions == "on" ? true : false; //validation if (CompanyTextBox.Text.Length > 0 && !Check.ValidateName(Message, CompanyTextBox.Text)) { return; } if (RoleTextBox.Text.Length > 0 && !Check.ValidateString(Message, RoleTextBox.Text)) { return; } if (FirstNameTextBox.Text.Length > 0 && !Check.ValidateName(Message, FirstNameTextBox.Text)) { return; } if (LastNameTextBox.Text.Length > 0 && !Check.ValidateName(Message, LastNameTextBox.Text)) { return; } if (StreetTextBox.Text.Length > 0 && !Check.ValidateText(Message, StreetTextBox.Text)) { return; } if (CityTextBox.Text.Length > 0 && !Check.ValidateName(Message, CityTextBox.Text)) { return; } if (PostalCodeTextBox.Text.Length > 0 && !Check.ValidateZipcode(Message, PostalCodeTextBox.Text)) { return; } if (CountryTextBox.Text.Length > 0 && !Check.ValidateName(Message, CountryTextBox.Text)) { return; } if (!Check.ValidatePhone(Message, PhoneTextbox.Text)) { return; } if (!Check.ValidateEmail(Message, EmailTextBox.Text)) { return; } StringBuilder sql = null; DB db = new DB(); string username = null; if (State["Username"].ToString() != "admin") { username = State["Username"].ToString(); } else { username = State["ServerAdminUsername"].ToString(); } if (PasswordTextBox.Text.Length > 0 || ConfirmPasswordBox.Text.Length > 0) { if (PasswordTextBox.Text == ConfirmPasswordBox.Text) { if (!Check.ValidatePassword(Message, PasswordTextBox.Text)) { return; } sql = new StringBuilder("UPDATE customers SET password='******'"); sql.Append(" WHERE username='******'"); db.ViziAppsExecuteNonQuery(State, sql.ToString()); sql = new StringBuilder("SELECT email from customers WHERE username='******'"); string to_email = db.ViziAppsExecuteScalar(State, sql.ToString()); Email email = new Email(); StringBuilder body = new StringBuilder("\nYour ViziApps password has been changed.\n\n"); body.Append("If you did not change it, contact our support team at [email protected] right away. "); body.Append("\n\n - The ViziApps Team \n"); email.SendEmail(State, HttpRuntime.Cache["TechSupportEmail"].ToString(), to_email, "", "", "ViziApps Notice", body.ToString(), "",false); } else { Message.Text = "New password and confirmation password do not match. Your account information has not been updated"; return; } } sql = new StringBuilder("UPDATE customers SET "); sql.Append("company='" + util.MySqlFilter(CompanyTextBox.Text) + "'"); sql.Append(",role='" + util.MySqlFilter(RoleTextBox.Text) + "'"); sql.Append(",first_name='" + util.MySqlFilter(FirstNameTextBox.Text) + "'"); sql.Append(",last_name='" + util.MySqlFilter(LastNameTextBox.Text) + "'"); sql.Append(",street_address='" + util.MySqlFilter(StreetTextBox.Text) + "'"); sql.Append(",city='" + util.MySqlFilter(CityTextBox.Text) + "'"); if (StateList.SelectedValue.IndexOf("->") < 0) sql.Append(",state='" + StateList.SelectedValue + "'"); else sql.Append(",state=''"); sql.Append(",postal_code='" + PostalCodeTextBox.Text + "'"); sql.Append(",country='" + util.MySqlFilter(CountryTextBox.Text) + "'"); sql.Append(",phone='" + PhoneTextbox.Text + "'"); sql.Append(",email='" + EmailTextBox.Text + "'"); sql.Append(",default_time_zone_delta_hours='" + TimeZoneList.SelectedValue + "'"); force_1_user_sessions = force_1_user_sessions == "on" ? "1" : "0"; sql.Append(",force_1_user_sessions=" + force_1_user_sessions); sql.Append(" WHERE username='******'"); db.ViziAppsExecuteNonQuery(State, sql.ToString()); db.CloseViziAppsDatabase(State); TimeZones zone_util = new TimeZones(); zone_util.GetDefaultTimeZone(State); //Update with CheddarGetter the CreditCardDetails if the Checkbox for CreditCardUpdate is checked. if (Update_CC_Details_CheckBox.Checked) { if (UpdateCheddarGetterWithCC() == true) Message.Text = "Your account profile has been updated. "; else Message.Text = "There was a problem updating your credit card info. Please contact [email protected] for assistance."; } else Message.Text = "Your account profile has been updated. "; //End CC Update }
void CurrDateValue_DateTimeValueChanged(object sender, EventArgs e) { if ((CurrDateValue.DateTimeValue != null)) { TimeZones tzones = new TimeZones(); TimeZone comptz = tzones.FindTimeZone(CompTzSelect.SelectedValue, TimeZones.TZFindType.ftDisplayName); DateTime newDateTime = (DateTime)(CurrDateValue.DateTimeValue); newDateTime = newDateTime.AddMinutes(TimeZone.BiasForGivenDate(newDateTime)); CompDateValue.DateTimeValue = newDateTime.AddMinutes(-1 * comptz.BiasForGivenDate(newDateTime)); chkCompDltAdjust.Disabled = (!comptz.ObservervesDaylightTime); lblCompDltAdjust.Disabled = (!comptz.ObservervesDaylightTime); } }
protected void Page_Load(object sender, EventArgs e) { Util util = new Util(); Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID]; if (State == null || State.Count <= 2) { Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "timeOut('../Default.aspx');", true); return; } util.UpdateSessionLog(State, "post", "MyProfile"); try { if( State["ServerAdminCustomerUsername"] != null) UsernameLabel.Text = State["ServerAdminCustomerUsername"].ToString(); else UsernameLabel.Text = State["Username"].ToString(); Message.Text = ""; string sql = null; if ( State["Username"].ToString() != "admin") { sql = "SELECT * FROM customers WHERE customer_id='" + State["CustomerID"].ToString() + "'"; } else { sql = "SELECT * FROM customers WHERE customer_id='" + State["ServerAdminCustomerID"].ToString() + "'"; } DB db = new DB(); DataRow[] rows = db.ViziAppsExecuteSql(State, sql); DataRow row = rows[0]; PasswordTextBox.Text = ""; ConfirmPasswordBox.Text = ""; CompanyTextBox.Text = SQLDecode(row["company"].ToString()); RoleTextBox.Text = SQLDecode(row["role"].ToString()); FirstNameTextBox.Text = SQLDecode(row["first_name"].ToString()); LastNameTextBox.Text = SQLDecode(row["last_name"].ToString()); StreetTextBox.Text = row["street_address"].ToString(); CityTextBox.Text = SQLDecode(row["city"].ToString()); if (row["state"] != null && row["state"].ToString().Length > 0) StateList.Text = row["state"].ToString(); PostalCodeTextBox.Text = row["postal_code"].ToString(); CountryTextBox.Text = SQLDecode(row["country"].ToString()); PhoneTextbox.Text = row["phone"].ToString(); EmailTextBox.Text = row["email"].ToString(); string status = row["status"].ToString(); db.CloseViziAppsDatabase(State); TimeZones zone_util = new TimeZones(); string default_time_zone_delta_hours = row["default_time_zone_delta_hours"].ToString(); zone_util.InitTimeZones(State, DateTime.Now.ToUniversalTime(), TimeZoneList, default_time_zone_delta_hours); string force_1_user_sessions = row["force_1_user_sessions"].ToString(); Force1UserSessions.Checked = force_1_user_sessions == "1" || force_1_user_sessions.ToLower() == "true"; } catch (Exception ex) { util.ProcessMainExceptions(State, Response, ex); } }
public string LoginToViziApps(Hashtable State, string username, string password) { try { string sql = "SELECT * FROM customers WHERE username='******'"; DB db = new DB(); DataRow[] rows = db.ViziAppsExecuteSql(State, sql); if (rows.Length == 0) { db.CloseViziAppsDatabase(State); return "Either the username or the password is incorrect."; } DataRow row = rows[0]; if (row["status"].ToString() == "inactive") { db.CloseViziAppsDatabase(State); return "Your account is inactive. Contact ViziApps to re-activate your account."; } string db_password = row["password"].ToString(); if (db_password == password) { //check expiration date string expiration_date = row["expiration_date"].ToString(); if (expiration_date.Length > 0) { DateTime expiration = DateTime.Parse(expiration_date); if (expiration < DateTime.Now.ToUniversalTime()) { sql = "UPDATE customers SET status='inactive' WHERE customer_id='" + row["customer_id"].ToString() + "'"; db.ViziAppsExecuteNonQuery(State, sql); db.CloseViziAppsDatabase(State); return "Your account has expired."; } } State["CustomerID"] = row["customer_id"].ToString(); Util util = new Util(); string[] account_type_list = GetAccountType(row["account_type"].ToString()).Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); string AllowedAccountTypes = ConfigurationManager.AppSettings["AllowedAccountTypes"]; string[] allowed_account_type_list = AllowedAccountTypes.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); bool isAccountTypeAllowed = false; foreach (string allowed_account_type in allowed_account_type_list) { foreach (string account_type in account_type_list) { if (account_type == allowed_account_type) { isAccountTypeAllowed = true; break; } } if (isAccountTypeAllowed) break; } if (!isAccountTypeAllowed) { foreach (string account_type in account_type_list) { if (account_type == "google_apps") return "If you created a ViziApps account from Google Apps Marketplace, you can only login into ViziApps from your Google account to maintain secure access to your data."; } return "Invalid Login"; } State["AccountType"] = GetAccountType(row["account_type"].ToString()); Hashtable UsersList = (Hashtable)HttpRuntime.Cache["UsersList"]; if (UsersList == null) { //this shouldn't happen so report this now and go on String error = "Application Cache UsersList has been set to null"; string NOW = GetCurrentDateTimeUTCMySqlFormat(); sql = "INSERT INTO error_log SET log_id=UUID(), timestamp='" + NOW + "',username='******',app='no app selectred',error='" + error + "',stacktrace='no stack trace'"; db.ViziAppsExecuteNonQuery(State, sql); db.CloseViziAppsDatabase(State); HttpRuntime.Cache["UsersList"] = new Hashtable(); UsersList = (Hashtable)HttpRuntime.Cache["UsersList"]; } string force_1_user_sessions = row["force_1_user_sessions"].ToString(); bool one_user_allowed = force_1_user_sessions == "1" || force_1_user_sessions.ToLower() == "true"; if (UsersList[username] != null) { Hashtable UserTable = (Hashtable)UsersList[username]; //check if only 1 user is allowed if (one_user_allowed && State["PageRequestIPAddress"] != null && UserTable["PageRequestIPAddress"].ToString() != State["PageRequestIPAddress"].ToString()) return "The account is already in use."; UserTable["PageRequestIPAddress"] = State["PageRequestIPAddress"].ToString(); UserTable["SessionID"] = State["SessionID"]; } else { Hashtable UserTable = new Hashtable(); UserTable["PageRequestIPAddress"] = State["PageRequestIPAddress"].ToString(); UserTable["SessionID"] = State["SessionID"]; UsersList[username] = UserTable; } //initialize configurations State["CustomerStatus"] = row["status"].ToString(); State["Password"] = password; State["Username"] = username; SetLoggedIn(State); TimeZones zone_util = new TimeZones(); zone_util.GetDefaultTimeZone(State); IncrementNLogins(State); LogLastUsed(State); string agreed_to_eula = row["agreed_to_eula"].ToString(); if (username.ToLower() == "admin") return "admin"; else if (agreed_to_eula == "1" || agreed_to_eula.ToLower() == "true") { return "OK"; } else return "agree_to_EULA"; } else { db.CloseViziAppsDatabase(State); return "Either the username or the password is incorrect."; } } catch (Exception ex) { LogError(State, ex); return "Internal error in login process."; } }
public string LoginToViziAppsFromGoogleApps(Hashtable State, string username) { try { string sql = "SELECT * FROM customers WHERE username='******' AND account_type like '%google_apps%'"; DB db = new DB(); DataRow[] rows = db.ViziAppsExecuteSql(State, sql); if (rows.Length == 0) { db.CloseViziAppsDatabase(State); return "The username is incorrect."; } DataRow row = rows[0]; if (row["status"].ToString() == "inactive") { db.CloseViziAppsDatabase(State); return "Your account is inactive. Contact ViziApps to re-activate your account."; } //check expiration date string expiration_date = row["expiration_date"].ToString(); if (expiration_date.Length > 0) { DateTime expiration = DateTime.Parse(expiration_date); if (expiration < DateTime.Now.ToUniversalTime()) { sql = "UPDATE customers SET status='inactive' WHERE customer_id='" + row["customer_id"].ToString() + "'"; db.ViziAppsExecuteNonQuery(State, sql); db.CloseViziAppsDatabase(State); return "Your account has expired."; } } State["CustomerID"] = row["customer_id"].ToString(); string account_type = GetAccountType(row["account_type"].ToString()); State["AccountType"] = account_type; State["CustomerEmail"] = row["email"].ToString(); Hashtable UsersList = (Hashtable)HttpRuntime.Cache["UsersList"]; if (UsersList == null) { //this shouldn't happen so report this now and go on String error = "Application Cache UsersList has been set to null"; string NOW = GetCurrentDateTimeUTCMySqlFormat(); sql = "INSERT INTO error_log SET log_id=UUID(), timestamp='" + NOW + "',username='******',app='no app selectred',error='" + error + "',stacktrace='no stack trace'"; db.ViziAppsExecuteNonQuery(State, sql); db.CloseViziAppsDatabase(State); HttpRuntime.Cache["UsersList"] = new Hashtable(); UsersList = (Hashtable)HttpRuntime.Cache["UsersList"]; } string force_1_user_sessions = row["force_1_user_sessions"].ToString(); bool one_user_allowed = force_1_user_sessions == "1" || force_1_user_sessions.ToLower() == "true"; if (UsersList[username] != null) { Hashtable UserTable = (Hashtable)UsersList[username]; //check if only 1 user is allowed if (one_user_allowed && State["PageRequestIPAddress"] != null && UserTable["PageRequestIPAddress"].ToString() != State["PageRequestIPAddress"].ToString()) return "The account is already in use."; UserTable["PageRequestIPAddress"] = State["PageRequestIPAddress"].ToString(); UserTable["SessionID"] = State["SessionID"]; } else { Hashtable UserTable = new Hashtable(); UserTable["PageRequestIPAddress"] = State["PageRequestIPAddress"].ToString(); UserTable["SessionID"] = State["SessionID"]; UsersList[username] = UserTable; } //initialize configurations State["CustomerStatus"] = row["status"].ToString(); State["Password"] = ""; State["Username"] = username; SetLoggedIn(State); TimeZones zone_util = new TimeZones(); zone_util.GetDefaultTimeZone(State); IncrementNLogins(State); LogLastUsed(State); string agreed_to_eula = row["agreed_to_eula"].ToString(); if (username.ToLower() == "admin") return "admin"; else if (agreed_to_eula == "1" || agreed_to_eula.ToLower() == "true") { return "OK"; } else return "agree_to_EULA"; } catch (Exception ex) { LogError(State, ex); return "Internal error in login process."; } }
public string CreateMobiFlexAccount(Hashtable State, string username, string password, string security_question, string security_answer, string first_name, string last_name, string email, string phone, string account_type, string referral_source, string app_to_build, string status) { StringBuilder sql = new StringBuilder("INSERT INTO customers SET "); string customer_id = Guid.NewGuid().ToString(); sql.Append("customer_id='" + customer_id + "'"); sql.Append(",username='******'"); sql.Append(",password='******'"); if (security_question.Length > 0) sql.Append(",security_question='" + security_question.Replace("'", "''") + "'"); if (security_answer.Length > 0) sql.Append(",security_answer='" + security_answer.Replace("'", "''") + "'"); sql.Append(",first_name='" + MySqlFilter(first_name) + "'"); sql.Append(",last_name='" + MySqlFilter(last_name) + "'"); sql.Append(",email='" + email + "'"); double DefaultTimeZoneDeltaHours = Convert.ToDouble( HttpRuntime.Cache["DefaultTimeZoneDeltaHours"].ToString()); TimeZones zone_util = new TimeZones(); string zone = Convert.ToString(DefaultTimeZoneDeltaHours + zone_util.GetDaylightSavingsTimeOffset(DateTime.Now.ToUniversalTime())); sql.Append(",default_time_zone_delta_hours='" + zone + "'"); if (phone != null && phone.Length > 0) { sql.Append(",phone='" + phone + "'"); } sql.Append(",account_type='" + account_type + "'"); if (referral_source != null && referral_source.IndexOf("->") < 0) { sql.Append(",referral_source='" + referral_source + "'"); } if (app_to_build != null && app_to_build.Length > 0) { sql.Append(",app_to_build='" + MySqlFilter(app_to_build) + "'"); } string NOW = DateTime.Now.ToUniversalTime().ToString("s").Replace("T", " "); sql.Append(",registration_date_time='" + NOW + "',status='" + status + "'"); DB db = new DB(); db.ViziAppsExecuteNonQuery(State, sql.ToString()); db.CloseViziAppsDatabase(State); return customer_id; }