protected void gvAircraft_RowUpdating(object sender, GridViewUpdateEventArgs e) { ClubAircraft ca = CurrentClub.MemberAircraft.FirstOrDefault(ac => ac.AircraftID == Convert.ToInt32(e.Keys[0])); if (ca != null) { GridViewRow row = ((GridView)sender).Rows[e.RowIndex]; ca.ClubDescription = ((Controls_mfbHtmlEdit)row.FindControl("txtDescription")).FixedHtml; ca.HighWater = ((Controls_mfbDecimalEdit)row.FindControl("decEditTime")).Value; if (ca.FSaveToClub()) { gvAircraft.EditIndex = -1; RefreshAircraft(); } else { lblManageAircraftError.Text = ca.LastError; } } }
protected void gvAircraft_RowCommand(object sender, GridViewCommandEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } if (e.CommandName.CompareOrdinalIgnoreCase("_Delete") == 0) { ClubAircraft ca = CurrentClub.MemberAircraft.FirstOrDefault(ac => ac.AircraftID == Convert.ToInt32(e.CommandArgument, CultureInfo.InvariantCulture)); if (ca != null) { if (!ca.FDeleteFromClub()) { lblManageAircraftError.Text = ca.LastError; } else { CurrentClub.InvalidateMemberAircraft(); RefreshAircraft(); } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!Page.User.Identity.IsAuthenticated) { throw new MyFlightbookException("Unauthorized!"); } int idClub = util.GetIntParam(Request, "c", 0); if (idClub == 0) { throw new MyFlightbookException("Invalid club"); } Club c = Club.ClubWithID(idClub); if (c == null) { throw new MyFlightbookException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Invalid club: {0}", idClub)); } string szIDs = util.GetStringParam(Request, "sid"); string[] rgSIDs = szIDs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (rgSIDs.Length == 0) { throw new MyFlightbookException("No scheduled events to download specified"); } bool fIsAdmin = c.HasAdmin(Page.User.Identity.Name); using (Ical.Net.Calendar ic = new Ical.Net.Calendar()) { ic.AddTimeZone(new VTimeZone(c.TimeZone.Id)); string szTitle = string.Empty; foreach (string sid in rgSIDs) { ScheduledEvent se = ScheduledEvent.AppointmentByID(sid, c.TimeZone); if (se == null) { throw new MyFlightbookException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Invalid scheduled event ID: {0}", sid)); } if (!fIsAdmin && Page.User.Identity.Name.CompareOrdinal(se.OwningUser) != 0) { throw new MyFlightbookException("Attempt to download appointment that you don't own!"); } ClubAircraft ca = c.MemberAircraft.FirstOrDefault(ca2 => ca2.AircraftID.ToString(System.Globalization.CultureInfo.InvariantCulture).CompareOrdinal(se.ResourceID) == 0); Event ev = ic.Create <Event>(); ev.Uid = se.ID; ev.IsAllDay = false; ev.Start = new CalDateTime(se.StartUtc, TimeZoneInfo.Utc.Id); ev.End = new CalDateTime(se.EndUtc, TimeZoneInfo.Utc.Id); ev.Start.HasTime = ev.End.HasTime = true; // has time is false if the ultimate time is midnight. szTitle = ev.Description = ev.Summary = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0}{1}", ca == null ? string.Empty : String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0} - ", ca.DisplayTailnumber), se.Body); ev.Location = c.HomeAirport == null ? c.HomeAirportCode : String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0} - {1}", c.HomeAirportCode, c.HomeAirport.Name); Alarm a = new Alarm(); a.Action = AlarmAction.Display; a.Description = ev.Summary; a.Trigger = new Trigger(); a.Trigger.DateTime = ev.Start.AddMinutes(-30); ev.Alarms.Add(a); ic.Method = "PUBLISH"; } CalendarSerializer s = new CalendarSerializer(); string output = s.SerializeToString(ic); Page.Response.Clear(); Page.Response.ContentType = "text/calendar"; Response.AddHeader("Content-Disposition", String.Format(System.Globalization.CultureInfo.InvariantCulture, "inline;filename={0}", Branding.ReBrand(String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}appt.ics", szTitle)).Replace(" ", "-"))); Response.Write(output); Response.Flush(); Response.End(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!Page.User.Identity.IsAuthenticated) { throw new MyFlightbookException("Unauthorized!"); } int idClub = util.GetIntParam(Request, "c", 0); if (idClub == 0) { throw new MyFlightbookException("Invalid club"); } Club c = Club.ClubWithID(idClub); if (c == null) { throw new MyFlightbookException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Invalid club: {0}", idClub)); } string szIDs = util.GetStringParam(Request, "sid"); string[] rgSIDs = szIDs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (rgSIDs.Length == 0) { throw new MyFlightbookException("No scheduled events to download specified"); } bool fIsAdmin = c.HasAdmin(Page.User.Identity.Name); Calendar ic = new Calendar(); ic.Calendar.AddTimeZone(c.TimeZone); string szTitle = string.Empty; foreach (string sid in rgSIDs) { ScheduledEvent se = ScheduledEvent.AppointmentByID(sid, c.TimeZone); if (se == null) { throw new MyFlightbookException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Invalid scheduled event ID: {0}", sid)); } if (!fIsAdmin && Page.User.Identity.Name.CompareOrdinal(se.OwningUser) != 0) { throw new MyFlightbookException("Attempt to download appointment that you don't own!"); } ClubAircraft ca = c.MemberAircraft.FirstOrDefault(ca2 => ca2.AircraftID.ToString(System.Globalization.CultureInfo.InvariantCulture).CompareOrdinal(se.ResourceID) == 0); szTitle = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0}{1}", ca == null ? string.Empty : String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0} - ", ca.DisplayTailnumber), se.Body); CalendarEvent ev = new CalendarEvent() { Uid = se.ID, IsAllDay = false, Start = new CalDateTime(se.StartUtc, TimeZoneInfo.Utc.Id), End = new CalDateTime(se.EndUtc, TimeZoneInfo.Utc.Id), Description = szTitle, Summary = szTitle, Location = c.HomeAirport == null ? c.HomeAirportCode : String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0} - {1}", c.HomeAirportCode, c.HomeAirport.Name) }; ev.Start.HasTime = ev.End.HasTime = true; // has time is false if the ultimate time is midnight. Alarm a = new Alarm() { Action = AlarmAction.Display, Description = ev.Summary, Trigger = new Trigger() { DateTime = ev.Start.AddMinutes(-30), AssociatedObject = ic } }; ev.Alarms.Add(a); ic.Calendar.Events.Add(ev); ic.Calendar.Method = "PUBLISH"; } string szFormat = util.GetStringParam(Request, "fmt"); switch (szFormat.ToUpperInvariant()) { case "ICAL": default: WriteICal(ic); break; case "G": WriteGoogle(ic, c.TimeZone); break; case "Y": WriteYahoo(ic, c.TimeZone); break; } } }