protected void btnConfirm_Click(object sender, EventArgs e) { try { m_sm.ExecuteRequest(m_smr); switch (m_smr.Requestedrole) { case CFIStudentMapRequest.RoleType.RoleCFI: case CFIStudentMapRequest.RoleType.RoleStudent: Response.Redirect("~/Member/Training.aspx/" + (m_smr.Requestedrole == CFIStudentMapRequest.RoleType.RoleCFI ? tabID.instStudents.ToString() : tabID.instInstructors.ToString())); break; case CFIStudentMapRequest.RoleType.RoleInviteJoinClub: { // Let the requestor know that the invitation has been accepted. Profile pfTarget = MyFlightbook.Profile.GetUser(m_smr.TargetUser.Contains("@") ? System.Web.Security.Membership.GetUserNameByEmail(m_smr.TargetUser) : m_smr.TargetUser); string szSubject = String.Format(CultureInfo.CurrentCulture, Resources.Club.AddMemberInvitationAccepted, m_smr.ClubToJoin.Name); string szBody = Branding.ReBrand(Resources.Club.ClubInvitationAccepted).Replace("<% ClubName %>", m_smr.ClubToJoin.Name).Replace("<% ClubInvitee %>", pfTarget.UserFullName); foreach (ClubMember cm in ClubMember.AdminsForClub(m_smr.ClubToJoin.ID)) { util.NotifyUser(szSubject, szBody.Replace("<% FullName %>", cm.UserFullName), new MailAddress(cm.Email, cm.UserFullName), false, false); } Response.Redirect("~/Member/ClubDetails.aspx/" + m_smr.ClubToJoin.ID); } break; case CFIStudentMapRequest.RoleType.RoleRequestJoinClub: { // Let the requestor know that the request has been approved. Profile pfRequestor = MyFlightbook.Profile.GetUser(m_smr.RequestingUser); string szSubject = String.Format(CultureInfo.CurrentCulture, Resources.Club.AddMemberRequestAccepted, m_smr.ClubToJoin.Name); string szBody = Branding.ReBrand(Resources.Club.ClubRequestAccepted).Replace("<% ClubName %>", m_smr.ClubToJoin.Name).Replace("<% FullName %>", pfRequestor.UserFullName); util.NotifyUser(szSubject, szBody, new MailAddress(pfRequestor.Email, pfRequestor.UserFullName), false, false); Response.Redirect("~/Member/ClubDetails.aspx/" + m_smr.ClubToJoin.ID); } break; } } catch (MyFlightbookValidationException ex) { pnlReviewRequest.Visible = false; lblError.Text = ex.Message; pnlConfirm.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { lblSignatureDisclaimer.Text = Branding.ReBrand(Resources.SignOff.SignedFlightDisclaimer); if (Request.Cookies[szKeyCookieCopy] != null) { if (Boolean.TryParse(Request.Cookies[szKeyCookieCopy].Value, out bool copyFlight)) { ckCopyFlight.Checked = copyFlight; } } } UpdateDateState(); dropDateCFIExpiration.DefaultDate = DateTime.MinValue; }
protected override void Init(string szTitle, string szBaseFAR, RatingType ratingSought, string farLink) { MaxATDTime = 20; // can do 20 hours of FTD OR ATD time. MinXCDistance = 100; base.Init(szTitle, szBaseFAR, ratingSought, farLink); miXCPIC = new MilestoneItem(Resources.MilestoneProgress.MinInstrumentPICXC, ResolvedFAR("i"), Resources.MilestoneProgress.NoteCanadaIRXC, MilestoneItem.MilestoneType.Time, 50.0M); miXCDualXC = new MilestoneItem(String.Format(CultureInfo.InvariantCulture, Resources.MilestoneProgress.MinInstrumentXCCanada, MinXCDistance), ResolvedFAR("(ii)(D)"), Resources.MilestoneProgress.MinInstrumentXCCanadaNote, MilestoneItem.MilestoneType.AchieveOnce, 1.0M); miIFRTrainingInCategory = new MilestoneItem(String.Format(CultureInfo.CurrentCulture, Resources.MilestoneProgress.MinInstrumentTrainingInCategoryCanada, ratingSought == RatingType.InstrumentAirplane ? Resources.MilestoneProgress.CAATPAeroplanes : Resources.MilestoneProgress.CAATPHelicopters), ResolvedFAR("(ii)(B)"), string.Empty, MilestoneItem.MilestoneType.Time, 5.0M); // fix up FAR references for inherited milestones miMinTimeInCategory.FARRef = ResolvedFAR("(i)"); miMinIMCTime.FARRef = ResolvedFAR("(ii)"); miInstrumentTraining.FARRef = ResolvedFAR("(ii)(C)"); this.GeneralDisclaimer = Branding.ReBrand(Resources.MilestoneProgress.InstrumentCanadaGeneralDisclaimer); }
public static void Configure() { Configure(AppName); Log.LogDebug += Log_LogDebug; Log.LogError += Log_LogError; Log.Debug("--------------------------------===========================Application starting===========================--------------------------------"); Log.Debug("Application version : " + Assembly.GetEntryAssembly().GetName().Version); DeviceManager = new CameraDeviceManager(); ExternalDeviceManager = new ExternalDeviceManager(); Trigger = new TriggerClass(); ActionManager = new ActionManager(); QueueManager = new QueueManager(); Branding = new Branding(); ScriptManager = new ScriptManager(); PluginManager = new PluginManager(); _pipeServer = new PipeServerT(); _pipeServer.Listen("DCCPipe"); }
static void Main() { Workspace workspace = new Workspace("Corporate Branding", "This is a model of my software system."); Model model = workspace.Model; Person user = model.AddPerson("User", "A user of my software system."); SoftwareSystem softwareSystem = model.AddSoftwareSystem("Software System", "My software system."); user.Uses(softwareSystem, "Uses"); ViewSet views = workspace.Views; SystemContextView contextView = views.CreateSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram."); contextView.AddAllSoftwareSystems(); contextView.AddAllPeople(); Styles styles = views.Configuration.Styles; styles.Add(new ElementStyle(Tags.Person) { Shape = Shape.Person }); StructurizrDocumentationTemplate template = new StructurizrDocumentationTemplate(workspace); template.AddContextSection(softwareSystem, Format.Markdown, "Here is some context about the software system...\n\n![](embed:SystemContext)"); template.AddQualityAttributesSection(softwareSystem, Format.Markdown, "Here is some information about the quality attributes..."); template.AddSoftwareArchitectureSection(softwareSystem, Format.Markdown, "Here is some information about the software architecture..."); template.AddOperationAndSupportSection(softwareSystem, Format.Markdown, "Here is some information about how to operate and support the software..."); template.AddDecisionLogSection(softwareSystem, Format.Markdown, "Here is some information about the decisions made..."); Branding branding = views.Configuration.Branding; branding.Color1 = new ColorPair("#02172c", "#ffffff"); branding.Color2 = new ColorPair("#08427b", "#ffffff"); branding.Color3 = new ColorPair("#1168bd", "#ffffff"); branding.Color4 = new ColorPair("#438dd5", "#ffffff"); branding.Color5 = new ColorPair("#85bbf0", "#ffffff"); branding.Logo = ImageUtils.GetImageAsDataUri(new FileInfo("structurizr-logo.png")); StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); structurizrClient.PutWorkspace(WorkspaceId, workspace); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { litMobileAppPromo.Text = Branding.ReBrand(Resources.LocalizedText.MobileAppPromo); mvScreenShots.ActiveViewIndex = 0; int iPage = Request.Params["p"].SafeParseInt(-1); if (iPage >= 0 && iPage < mvScreenShots.Views.Count) { mvScreenShots.ActiveViewIndex = cmbMobileTarget.SelectedIndex = iPage + 1; } this.Master.SelectedTab = tabID.tabHome; this.Master.Title = Branding.CurrentBrand.AppName; } divStoreLogos.Visible = mvScreenShots.ActiveViewIndex == 0; }
protected void Page_Load(object sender, EventArgs e) { mfbDateLastCheck.DefaultDate = DateTime.MinValue; if (!IsPostBack) { lblCheckFlightsCategories.Text = Branding.ReBrand(Resources.FlightLint.CheckFlightsCategoriesHeader); SetOptions(FlightLint.DefaultOptionsForLocale); mfbDateLastCheck.Date = DateTime.MinValue; if (Request.Cookies[szCookieLastCheck] != null) { string szLastCheck = Request.Cookies[szCookieLastCheck].Value; if (DateTime.TryParse(szLastCheck, out DateTime dtLastCheck)) { spanLastCheck.Visible = true; lblLastCheck.Text = String.Format(CultureInfo.CurrentCulture, Resources.FlightLint.PromptLastCheckDate, dtLastCheck); hdnLastDateCheck.Value = dtLastCheck.ToString("d", CultureInfo.CurrentCulture); } } } else { // fix issue #906 - need to preserve ignore status if (!String.IsNullOrEmpty(hdnChanged.Value)) { Dictionary <int, bool> d = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <int, bool> >(hdnChanged.Value); if (d.Any()) { foreach (FlightWithIssues f in CheckedFlights) { // set the ignore value appropriately, but no need to commit - we're synching our cached objects with already-committed changes. if (d.ContainsKey(f.Flight.FlightID)) { SetIgnoreFlagForFlight(f.Flight, d[f.Flight.FlightID]); } } } hdnChanged.Value = string.Empty; } } }
protected void btnSend_Click(object sender, EventArgs e) { if (Page.IsValid && NoBot1.IsValid()) { MailAddress ma = new MailAddress(txtEmail.Text, txtName.Text); string szBody = txtComments.Text + "\r\n\r\nUser = "******"anonymous") + "\r\nSent: " + DateTime.Now.ToLongDateString(); string szSubject = String.Format(CultureInfo.CurrentCulture, "{0} - {1}", Branding.CurrentBrand.AppName, txtSubject.Text); using (MailMessage msg = new MailMessage() { From = new MailAddress(Branding.CurrentBrand.EmailAddress, String.Format(CultureInfo.InvariantCulture, Resources.SignOff.EmailSenderAddress, Branding.CurrentBrand.AppName, txtName.Text)), Subject = szSubject, Body = szBody }) { if (fuFile.HasFiles) { foreach (HttpPostedFile pf in fuFile.PostedFiles) { msg.Attachments.Add(new Attachment(pf.InputStream, pf.FileName, pf.ContentType)); } } msg.ReplyToList.Add(ma); util.AddAdminsToMessage(msg, true, ProfileRoles.maskCanContact); util.SendMessage(msg); } mvContact.SetActiveView(vwThanks); string szOOF = ConfigurationManager.AppSettings["UseOOF"]; if (!String.IsNullOrEmpty(szOOF) && String.Compare(szOOF, "yes", StringComparison.Ordinal) == 0) { util.NotifyUser(szSubject, Branding.ReBrand(Resources.EmailTemplates.ContactMeResponse), ma, false, false); } // if this was done via iPhone/iPad (i.e., popped up browser), suppress the "return" link. if (util.GetIntParam(Request, "noCap", 0) != 0) { lnkReturn.Visible = false; } } }
/// <summary> /// Put's a file as a stream /// </summary> /// <param name="szFileName">The file name to use</param> /// <param name="ms">The stream of the data</param> /// <returns>FileMetadata with the result</returns> /// <exception cref="OneDriveException"></exception> public async Task <Item> PutFile(Stream ms, string szFileName) { if (Client == null) { try { Client = await InitClient(); } catch (OneDriveException ex) // the exception here has no useful message, but it's clearly an auth issue, so map it to that. { throw new MyFlightbookException(Branding.ReBrand(Resources.LocalizedText.OneDriveBadAuth), ex); } } ms.Seek(0, SeekOrigin.Begin); // write out the whole stream. UploadAsync appears to pick up from the current location, which is the end-of-file after writing to a ZIP. var uploadedItem = await Client.Drive.Root.ItemWithPath(RootPath + szFileName).Content.Request().PutAsync <Item>(ms); return(uploadedItem); }
private void InitSocialNetworking() { lblCanTweet.Text = Branding.ReBrand(Resources.Profile.TwitterIsAuthed); lnkNoTweet.Text = Branding.ReBrand(Resources.Profile.DeAuthTwitter); lnkSetUpTwitter.Text = Branding.ReBrand(Resources.Profile.AuthorizeTwitter); locFBIsAuthorized.Text = Branding.ReBrand(Resources.Profile.FacebookIsAuthed); lnkNoFacebook.Text = Branding.ReBrand(Resources.Profile.DeAuthFacebook); lnkSetUpFacebook.Text = Branding.ReBrand(Resources.Profile.AuthorizeFacebook); ShowTweetState(m_pf.CanTweet()); imgMyFlightbook.ImageUrl = Branding.CurrentBrand.LogoURL; imgMyFlightbook.ToolTip = imgMyFlightbook.AlternateText = Branding.CurrentBrand.AppName; ShowFacebookState(m_pf.CanPostFacebook()); ShowGooglePlusState(m_pf.CanPostGooglePlus()); // Sharing lnkMyFlights.Text = lnkMyFlights.NavigateUrl = m_pf.PublicFlightsURL(Request.Url.Host).AbsoluteUri; }
protected override MFBImageInfo UploadForUser(string szUser, HttpPostedFile pf, string szComment) { int idFlight = Convert.ToInt32(Request.Form["idFlight"], CultureInfo.InvariantCulture); if (idFlight <= 0) { throw new MyFlightbookException(Resources.WebService.errInvalidFlight); } LogbookEntry le = new LogbookEntry { FlightID = idFlight }; if (!le.FLoadFromDB(le.FlightID, szUser, LogbookEntry.LoadTelemetryOption.None)) { throw new MyFlightbookException(Resources.WebService.errFlightDoesntExist); } if (le.User != szUser) { throw new MyFlightbookException(Resources.WebService.errFlightNotYours); } // Check if authorized for videos if (MFBImageInfo.ImageTypeFromFile(pf) == MFBImageInfo.ImageFileType.S3VideoMP4 && !EarnedGratuity.UserQualifies(szUser, Gratuity.GratuityTypes.Videos)) { throw new MyFlightbookException(Branding.ReBrand(Resources.LocalizedText.errNotAuthorizedVideos)); } LatLong ll = null; string szLat = Request.Form["txtLat"]; string szLon = Request.Form["txtLon"]; if (!String.IsNullOrEmpty(szLat) && !String.IsNullOrEmpty(szLon)) { ll = LatLong.TryParse(szLat, szLon, CultureInfo.InvariantCulture); } mfbImageFlight.Key = le.FlightID.ToString(CultureInfo.InvariantCulture); return(new MFBImageInfo(MFBImageInfo.ImageClass.Flight, mfbImageFlight.Key, pf, szComment, ll)); }
private static void ThrowGDriveError(Exception ex) { if (ex == null) { return; } GDriveError error = JsonConvert.DeserializeObject <GDriveError>(ExtractResponseString(ex.InnerException as WebException)); if (error == null) { throw new MyFlightbookException("Unknown error refreshing access token", ex); } else if (error.error.CompareCurrentCultureIgnoreCase("invalid_grant") == 0) { throw new UnauthorizedAccessException(Branding.ReBrand(Resources.LocalizedText.GoogleDriveBadAuth), ex); } else { throw new MyFlightbookException(String.Format(CultureInfo.CurrentCulture, "Error from Google Drive: {0} {1} {2}", error.error, error.error_description, error.error_link), ex); } }
protected void InitStatusDisplay() { switch (CurrentClub.Status) { case Club.ClubStatus.Promotional: mvPromoStatus.SetActiveView(vwPromotional); string szTemplate = (Page.User.Identity.Name.CompareOrdinal(Page.User.Identity.Name) == 0) ? Resources.Club.clubStatusTrialOwner : Resources.Club.clubStatusTrial; lblPromo.Text = String.Format(CultureInfo.CurrentCulture, Branding.ReBrand(szTemplate), CurrentClub.ExpirationDate.Value.ToShortDateString()); break; case Club.ClubStatus.Expired: case Club.ClubStatus.Inactive: mvPromoStatus.SetActiveView(vwInactive); lblInactive.Text = Branding.ReBrand(CurrentClub.Status == Club.ClubStatus.Inactive ? Resources.Club.errClubInactive : Resources.Club.errClubPromoExpired); break; default: mvPromoStatus.Visible = false; break; } }
private void WriteInsurenceZip(Action <String, Stream> dispatch) { if (dispatch == null) { throw new ArgumentNullException(nameof(dispatch)); } Profile pf = Profile.GetUser(Page.User.Identity.Name); mfbDownload1.User = pf.UserName; mfbDownload1.UpdateData(); string szFile = Regex.Replace(Branding.ReBrand(String.Format(CultureInfo.InvariantCulture, "{0}-{1}-{2}", Branding.CurrentBrand.AppName, pf.UserFullName, Resources.LocalizedText.InsuranceBackupName)).Replace(" ", "-"), "[^0-9a-zA-Z-]", string.Empty); using (FileStream fs = new FileStream(Path.GetTempFileName(), FileMode.Open, FileAccess.ReadWrite, FileShare.None, Int16.MaxValue, FileOptions.DeleteOnClose)) { LogbookBackup lb = new LogbookBackup(pf) { IncludeImages = false }; lb.WriteZipOfImagesToStream(fs, Branding.CurrentBrand, (zip) => { // Add the flights ZipArchiveEntry zae = zip.CreateEntry(CSVFileName); using (StreamWriter sw = new StreamWriter(zae.Open())) { sw.Write('\uFEFF'); // UTF-8 BOM. sw.Write(mfbDownload1.CSVData()); } // And add the user's information, in JSON format. zae = zip.CreateEntry("PilotInfo.JSON"); using (StreamWriter sw = new StreamWriter(zae.Open())) { sw.Write(LogbookBackup.PilotInfoAsJSon(pf)); } }); dispatch(szFile, fs); } }
protected static string MessageForCode(OneDriveErrorCodeMFB errCode) { switch (errCode) { case OneDriveErrorCodeMFB.AccessDenied: case OneDriveErrorCodeMFB.AuthenticationCancelled: case OneDriveErrorCodeMFB.AuthenticationFailure: case OneDriveErrorCodeMFB.Unauthenticated: return(Branding.ReBrand(Resources.LocalizedText.OneDriveBadAuth)); case OneDriveErrorCodeMFB.QuotaLimitReached: return(Resources.LocalizedText.OneDriveErrorOutOfSpace); case OneDriveErrorCodeMFB.Timeout: case OneDriveErrorCodeMFB.ServiceNotAvailable: case OneDriveErrorCodeMFB.TooManyRedirects: return(Resources.LocalizedText.OneDriveCantReachService); default: return(errCode.ToString()); } }
protected Boolean FCommitPass() { try { if (CurrentPassword.Text.Length == 0 || !Membership.ValidateUser(User.Identity.Name, CurrentPassword.Text)) { throw new MyFlightbookException(Resources.Profile.errBadPasswordToChange); } if (NewPassword.Text != ConfirmNewPassword.Text) // should never happen - validation should have caught this. { throw new MyFlightbookException(Resources.Profile.errPasswordsDontMatch); } UserEntity.ValidatePassword(NewPassword.Text); // will throw an exception if length, etc. is wrong. if (!Membership.Provider.ChangePassword(Page.User.Identity.Name, CurrentPassword.Text, NewPassword.Text)) { throw new MyFlightbookException(Resources.Profile.errChangePasswordFailed); } util.NotifyUser(String.Format(CultureInfo.CurrentCulture, Resources.Profile.PasswordChangedSubject, Branding.CurrentBrand.AppName), Branding.ReBrand(Resources.EmailTemplates.PasswordChanged), new System.Net.Mail.MailAddress(m_pf.Email, m_pf.UserFullName), false, false); } catch (MyFlightbookException ex) { lblPassChanged.Visible = true; lblPassChanged.Text = ex.Message; lblPassChanged.CssClass = "error"; return(false); } catch (UserEntityException ex) { lblPassChanged.Visible = true; lblPassChanged.Text = ex.Message; lblPassChanged.CssClass = "error"; return(false); } return(true); }
protected void Page_Load(object sender, EventArgs e) { this.Master.Title = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.TitleTraining, Branding.CurrentBrand.AppName); Master.SelectedTab = tabID.tabTraining; if (!IsPostBack) { Profile pf = MyFlightbook.Profile.GetUser(Page.User.Identity.Name); mfbEditEndorsement1.StudentType = Endorsement.StudentTypes.External; mfbEditEndorsement1.TargetUser = pf; cmbTemplates.DataSource = EndorsementType.LoadTemplates(); cmbTemplates.DataValueField = "id"; cmbTemplates.DataTextField = "FullTitle"; cmbTemplates.DataBind(); hdnLastTemplate.Value = cmbTemplates.SelectedValue; lblDisclaimerResponse.Text = Branding.ReBrand(Resources.SignOff.SignDisclaimerAgreement1); lblDisclaimerResponse2.Text = Branding.ReBrand(Resources.SignOff.SignDisclaimerAgreement2); CFIStudentMap sm = new CFIStudentMap(Page.User.Identity.Name); if (sm.Instructors.Count() == 0) { mfbEditEndorsement1.Mode = EndorsementMode.StudentPullAdHoc; mvAddEndorsement.SetActiveView(vwAcceptTerms); } else { cmbInstructors.DataSource = sm.Instructors; cmbInstructors.DataBind(); mvAddEndorsement.SetActiveView(vwPickInstructor); } mfbEditEndorsement1.StudentType = Endorsement.StudentTypes.Member; mfbEditEndorsement1.TargetUser = pf; } // need to reconstitute the form from the template every time to ensure postback works. mfbEditEndorsement1.EndorsementID = Convert.ToInt32(hdnLastTemplate.Value, CultureInfo.InvariantCulture); }
protected void btnSendMessage_Click(object sender, EventArgs e) { if (!Page.IsValid) { mpuGuestContact.Show(); return; } Profile pf = MyFlightbook.Profile.GetUser(Page.User.Identity.Name); IEnumerable <ClubMember> lst = ClubMember.AdminsForClub(CurrentClub.ID); using (MailMessage msg = new MailMessage()) { MailAddress maFrom = new MailAddress(pf.Email, pf.UserFullName); msg.From = new MailAddress(Branding.CurrentBrand.EmailAddress, String.Format(CultureInfo.CurrentCulture, Resources.SignOff.EmailSenderAddress, Branding.CurrentBrand.AppName, pf.UserFullName)); msg.ReplyToList.Add(maFrom); foreach (ClubMember cm in lst) { msg.To.Add(new MailAddress(cm.Email, cm.UserFullName)); } msg.Subject = String.Format(CultureInfo.CurrentCulture, Branding.ReBrand(Resources.Club.ContactSubjectTemplate), CurrentClub.Name); msg.Body = txtContact.Text + "\r\n\r\n" + String.Format(CultureInfo.CurrentCulture, Resources.Club.MessageSenderTemplate, pf.UserFullName, pf.Email); msg.IsBodyHtml = false; util.SendMessage(msg); } if (ckRequestMembership.Checked) { foreach (ClubMember admin in lst) { new CFIStudentMapRequest(Page.User.Identity.Name, admin.Email, CFIStudentMapRequest.RoleType.RoleRequestJoinClub, CurrentClub).Send(); } } mpuGuestContact.Hide(); txtContact.Text = string.Empty; ckRequestMembership.Checked = false; lblMessageStatus.Visible = true; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { lblSignatureDisclaimer.Text = Branding.ReBrand(Resources.SignOff.SignedFlightDisclaimer); if (Request.Cookies[szKeyCookieCopy] != null) { if (Boolean.TryParse(Request.Cookies[szKeyCookieCopy].Value, out bool copyFlight)) { ckCopyFlight.Checked = copyFlight; } } } else { LogbookEntry _ = Flight; // force the flight to load. } txtComments.Attributes["maxlength"] = "250"; UpdateDateState(); dropDateCFIExpiration.DefaultDate = DateTime.MinValue; }
protected void Page_Load(object sender, EventArgs e) { mfbDateLastCheck.DefaultDate = DateTime.MinValue; if (!IsPostBack) { lblCheckFlightsCategories.Text = Branding.ReBrand(Resources.FlightLint.CheckFlightsCategoriesHeader); SetOptions(FlightLint.DefaultOptionsForLocale); mfbDateLastCheck.Date = DateTime.MinValue; if (Request.Cookies[szCookieLastCheck] != null) { string szLastCheck = Request.Cookies[szCookieLastCheck].Value; if (DateTime.TryParse(szLastCheck, out DateTime dtLastCheck)) { spanLastCheck.Visible = true; lblLastCheck.Text = String.Format(CultureInfo.CurrentCulture, Resources.FlightLint.PromptLastCheckDate, dtLastCheck); hdnLastDateCheck.Value = dtLastCheck.ToString("d", CultureInfo.CurrentCulture); } } } }
protected static void HandleInvalidAuth(Exception ex) { if (ex == null) { throw new ArgumentNullException(nameof(ex)); } dynamic error = JsonConvert.DeserializeObject(ExtractResponseString(ex.InnerException as WebException)); if (error == null) { throw new MyFlightbookException("Unknown error refreshing access token", ex); } else if (error.error != null && String.Compare(error.error.ToString(), "invalid_grant", StringComparison.InvariantCulture) == 0) { OneDriveMFBException ode = new OneDriveMFBException(new OneDriveError(OneDriveErrorCodeMFB.AuthenticationFailure), ex); throw new UnauthorizedAccessException(ode.Message, ode); } else { throw new MyFlightbookException(Branding.ReBrand(Resources.LocalizedText.OneDriveBadAuth)); } }
private void InitDonations() { List <Gratuity> lstKnownGratuities = new List <Gratuity>(Gratuity.KnownGratuities); lstKnownGratuities.Sort((g1, g2) => { return(g1.Threshold.CompareTo(g2.Threshold)); }); rptAvailableGratuities.DataSource = lstKnownGratuities; rptAvailableGratuities.DataBind(); pnlPaypalCanceled.Visible = util.GetStringParam(Request, "pp").CompareCurrentCultureIgnoreCase("canceled") == 0; pnlPaypalSuccess.Visible = util.GetStringParam(Request, "pp").CompareCurrentCultureIgnoreCase("success") == 0; lblDonatePrompt.Text = Branding.ReBrand(Resources.LocalizedText.DonatePrompt); gvDonations.DataSource = Payment.RecordsForUser(User.Identity.Name); gvDonations.DataBind(); List <EarnedGrauity> lst = EarnedGrauity.GratuitiesForUser(User.Identity.Name, Gratuity.GratuityTypes.Unknown); lst.RemoveAll(eg => eg.CurrentStatus == EarnedGrauity.EarnedGratuityStatus.Expired); if (pnlEarnedGratuities.Visible = (lst.Count > 0)) { rptEarnedGratuities.DataSource = lst; rptEarnedGratuities.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { TableRow tr = new TableRow(); tblAdditionalProps.Rows.Add(tr); CustomPropertyType[] rgCpt = CustomPropertyType.GetCustomPropertyTypes(""); int cRows = (rgCpt.Length + cColumnsOfProps - 1) / cColumnsOfProps; for (int iRow = 0; iRow < cRows; iRow++) { for (int iCol = 0; iCol < cColumnsOfProps; iCol++) { int iProp = (iCol * cRows) + iRow; if (iProp < rgCpt.Length) { AddProp(rgCpt[iProp], tr); } else { // add blank cells to pad out the row. tr.Cells.Add(new TableCell()); } } tr = new TableRow(); tblAdditionalProps.Rows.Add(tr); tr.Style["vertical-align"] = "top"; } if (tr.Cells.Count == 0) { tblAdditionalProps.Rows.Remove(tr); } this.Master.SelectedTab = tabID.tabLogbook; this.Title = lblImportHeader.Text = String.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.LogbookEntry.importTableHeader, Branding.CurrentBrand.AppName); litTableMainFields.Text = Branding.ReBrand(Resources.LogbookEntry.ImportTableDescription); }
public override string ReminderBody(EarnedGrauity eg) { if (eg == null) { throw new ArgumentNullException("eg"); } Profile pf = eg.UserProfile ?? Profile.GetUser(eg.Username); switch (eg.CurrentStatus) { default: case EarnedGrauity.EarnedGratuityStatus.OK: return(string.Empty); case EarnedGrauity.EarnedGratuityStatus.ExpiringSoon: if (eg.ReminderCount == 0) { return(String.Format(CultureInfo.CurrentCulture, Branding.ReBrand(Resources.EmailTemplates.DropboxExpiring), pf.UserFullName)); } else { return(string.Empty); } case EarnedGrauity.EarnedGratuityStatus.Expired: if (eg.ReminderCount <= 1) { return(String.Format(CultureInfo.CurrentCulture, Branding.ReBrand(Resources.EmailTemplates.DropboxExpired), pf.UserFullName)); } else { return(string.Empty); } } }
private void InitCloudProviders() { List <StorageID> lstCloud = new List <StorageID>(m_pf.AvailableCloudProviders); StorageID defaultStorage = m_pf.BestCloudStorage; foreach (StorageID sid in lstCloud) { cmbDefaultCloud.Items.Add(new ListItem(CloudStorageBase.CloudStorageName(sid), sid.ToString()) { Selected = defaultStorage == sid }); } pnlDefaultCloud.Visible = lstCloud.Count > 1; // only show a choice if more than one cloud provider is set up mvDropBoxState.SetActiveView(lstCloud.Contains(StorageID.Dropbox) ? vwDeAuthDropbox : vwAuthDropBox); mvGDriveState.SetActiveView(lstCloud.Contains(StorageID.GoogleDrive) ? vwDeAuthGDrive : vwAuthGDrive); mvOneDriveState.SetActiveView(lstCloud.Contains(StorageID.OneDrive) ? vwDeAuthOneDrive : vwAuthOneDrive); locAboutCloudStorage.Text = Branding.ReBrand(Resources.Profile.AboutCloudStorage); lnkAuthDropbox.Text = Branding.ReBrand(Resources.Profile.AuthorizeDropbox); lnkDeAuthDropbox.Text = Branding.ReBrand(Resources.Profile.DeAuthDropbox); locDropboxIsAuthed.Text = Branding.ReBrand(Resources.Profile.DropboxIsAuthed); lnkAuthorizeGDrive.Text = Branding.ReBrand(Resources.Profile.AuthorizeGDrive); lnkDeAuthGDrive.Text = Branding.ReBrand(Resources.Profile.DeAuthGDrive); locGoogleDriveIsAuthed.Text = Branding.ReBrand(Resources.Profile.GDriveIsAuthed); lnkAuthorizeOneDrive.Text = Branding.ReBrand(Resources.Profile.AuthorizeOneDrive); lnkDeAuthOneDrive.Text = Branding.ReBrand(Resources.Profile.DeAuthOneDrive); locOneDriveIsAuthed.Text = Branding.ReBrand(Resources.Profile.OneDriveIsAuthed); mvCloudAhoy.SetActiveView(m_pf.CloudAhoyToken == null ? vwAuthCloudAhoy : vwDeAuthCloudAhoy); lnkAuthCloudAhoy.Text = Branding.ReBrand(Resources.Profile.AuthorizeCloudAhoy); lnkDeAuthCloudAhoy.Text = Branding.ReBrand(Resources.Profile.DeAuthCloudAhoy); locCloudAhoyIsAuthed.Text = Branding.ReBrand(Resources.Profile.CloudAhoyIsAuthed); rblCloudBackupAppendDate.SelectedValue = m_pf.OverwriteCloudBackup.ToString(CultureInfo.InvariantCulture); }
public IFRUKIRRestricted() { Title = Resources.MilestoneProgress.TitleUKIRRestricted; BaseFAR = "CAP 804 Part I E 3.1"; FARLink = "https://publicapps.caa.co.uk/docs/33/CAP804April2015REFONLY.pdf"; RatingSought = RatingType.InstrumentUKIRRestricted; miTotalTime = new MilestoneItem(Resources.MilestoneProgress.MinUKTotalTimeTraining, ResolvedFAR("(a)(i)"), Branding.ReBrand(Resources.MilestoneProgress.MinUKTotalTimeTrainingNote), MilestoneItem.MilestoneType.Time, 25); miPICTime = new MilestoneItem(Resources.MilestoneProgress.MinUKPICTime, ResolvedFAR("(a)(ii)"), string.Empty, MilestoneItem.MilestoneType.Time, 10); miPICXCTime = new MilestoneItem(Resources.MilestoneProgress.MinUKPICXCTime, ResolvedFAR("(a)(ii)"), string.Empty, MilestoneItem.MilestoneType.Time, 10); miTraining = new MilestoneItem(Resources.MilestoneProgress.MinIFRTrainingUK, ResolvedFAR("(b)"), Branding.ReBrand(Resources.MilestoneProgress.NoteMinIFRTrainingUK), MilestoneItem.MilestoneType.Time, 15); miInstTraining = new MilestoneItem(Resources.MilestoneProgress.MinIFRTrainingByRef, ResolvedFAR("(b)"), string.Empty, MilestoneItem.MilestoneType.Time, 10); }
/// <summary> /// Initializes an instrument rating object /// </summary> /// <param name="szTitle">Title</param> /// <param name="szBaseFAR">Base FAR</param> /// <param name="ratingSought">Specific rating being sought</param> protected virtual void Init(string szTitle, string szBaseFAR, RatingType ratingSought, string farLink) { Title = szTitle; BaseFAR = szBaseFAR; FARLink = farLink; RatingSought = ratingSought; FTDTimeRemaining = MaxFTDTime; string szAircraftCategory; switch (RatingSought) { case RatingType.InstrumentAirplane: szAircraftCategory = Resources.MilestoneProgress.ratingAirplane; break; case RatingType.InstrumentHelicopter: szAircraftCategory = Resources.MilestoneProgress.ratingHelicopter; break; case RatingType.InstrumentPoweredLift: szAircraftCategory = Resources.MilestoneProgress.ratingPoweredLift; break; default: throw new MyFlightbookException(String.Format(CultureInfo.InvariantCulture, "Unallowed rating for 61.65: {0}", RatingSought.ToString())); } // 61.65(def)(1) miMinXCTime = new MilestoneItem(Resources.MilestoneProgress.MinInstrumentPICXC, ResolvedFAR("(1)"), Resources.MilestoneProgress.NoteXCTime, MilestoneItem.MilestoneType.Time, 50.0M); miMinTimeInCategory = new MilestoneItem(String.Format(CultureInfo.CurrentCulture, Resources.MilestoneProgress.MinInstrumentPICInCategory, szAircraftCategory), ResolvedFAR("(1)"), String.Empty, MilestoneItem.MilestoneType.Time, 10.0M); // 61.65(def)(2) - total instrument time miMinIMCTime = new MilestoneItem(Resources.MilestoneProgress.MinInstrumentTime, ResolvedFAR("(2)"), Branding.ReBrand(Resources.MilestoneProgress.NoteInstrumentTime), MilestoneItem.MilestoneType.Time, 40.0M); // 61.65(def)(2) - Instrument training miInstrumentTraining = new MilestoneItem(Resources.MilestoneProgress.MinInstrumentTraining, ResolvedFAR("(2)"), Branding.ReBrand(Resources.MilestoneProgress.MinInstrumentTrainingNote), MilestoneItem.MilestoneType.Time, 15.0M); // 61.65(def)(2)(i) - recent test prep miMinIMCTestPrep = new MilestoneItemDecayable(String.Format(CultureInfo.CurrentCulture, Resources.MilestoneProgress.MinInstrumentTestPrep, szAircraftCategory), ResolvedFAR("(2)(i)"), Branding.ReBrand(Resources.MilestoneProgress.NoteTestPrep), MilestoneItem.MilestoneType.Time, 3.0M, 2); // 61.65(def)(2)(ii) - cross-country miIMCXC = new MilestoneItem(String.Format(CultureInfo.CurrentCulture, Resources.MilestoneProgress.MinInstrumentXC, szAircraftCategory, MinXCDistance), ResolvedFAR("(2)(ii)"), Branding.ReBrand(Resources.MilestoneProgress.NoteInstrumentXC), MilestoneItem.MilestoneType.AchieveOnce, 1.0M); }
protected void lnkDownloadImagesZip_Click(object sender, EventArgs e) { Profile pf = MyFlightbook.Profile.GetUser(Page.User.Identity.Name); Response.Clear(); Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", String.Format(CultureInfo.InvariantCulture, "attachment;filename={0}", Branding.ReBrand(String.Format(CultureInfo.InvariantCulture, "{0}.zip", Resources.LocalizedText.ImagesBackupFilename)).Replace(" ", "-"))); using (System.IO.MemoryStream ms = new LogbookBackup(pf).ZipOfImagesForUser(Branding.CurrentBrand)) Response.BinaryWrite(ms.ToArray()); Response.End(); }
private void InitApplication() { // prevent some application crash //WpfCommands.DisableWpfTabletSupport(); Dispatcher.Invoke(new Action(ServiceProvider.Configure)); ServiceProvider.Settings = new Settings(); ServiceProvider.Settings = ServiceProvider.Settings.Load(); ServiceProvider.Branding = Branding.LoadBranding(); ServiceProvider.ActionManager.Actions = new AsyncObservableCollection <IMenuAction> { //new CmdFocusStackingCombineZP(), //new CmdEnfuse(), // new CmdToJpg(), //new CmdExpJpg() }; if (ServiceProvider.Settings.DisableNativeDrivers && MessageBox.Show(TranslationStrings.MsgDisabledDrivers, "", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { ServiceProvider.Settings.DisableNativeDrivers = false; } ServiceProvider.Settings.LoadSessionData(); TranslationManager.LoadLanguage(ServiceProvider.Settings.SelectedLanguage); ServiceProvider.PluginManager.CopyPlugins(); Dispatcher.Invoke(new Action(InitWindowManager)); ServiceProvider.Trigger.Start(); ServiceProvider.Analytics.Start(); Dispatcher.Invoke(new Action(delegate { try { // event handlers ServiceProvider.Settings.SessionSelected += Settings_SessionSelected; ServiceProvider.DeviceManager.CameraConnected += DeviceManager_CameraConnected; ServiceProvider.DeviceManager.CameraSelected += DeviceManager_CameraSelected; ServiceProvider.DeviceManager.CameraDisconnected += DeviceManager_CameraDisconnected; //------------------- ServiceProvider.DeviceManager.DisableNativeDrivers = ServiceProvider.Settings.DisableNativeDrivers; if (ServiceProvider.Settings.AddFakeCamera) { ServiceProvider.DeviceManager.AddFakeCamera(); } ServiceProvider.DeviceManager.ConnectToCamera(); } catch (Exception exception) { Log.Error("Unable to initialize device manager", exception); if (exception.Message.Contains("0AF10CEC-2ECD-4B92-9581-34F6AE0637F3")) { MessageBox.Show( "Unable to initialize device manager !\nMissing some components! Please install latest Windows Media Player! "); Application.Current.Shutdown(1); } } StartApplication(); if (_startUpWindow != null) { _startUpWindow.Close(); } })); }
protected void SetUpCurrencyAndTotalsForUser(string szAuthKey, string szParam) { try { ValidateAuthorization(szAuthKey); Profile pf = MyFlightbook.Profile.GetUser(Username); EmailSubscriptionManager em = new EmailSubscriptionManager(pf.Subscriptions); IEnumerable <CurrencyStatusItem> rgExpiringCurrencies = null; IEnumerable <CurrencyStatusItem> rgPrecomputedCurrencies = null; if (pf.AssociatedData.TryGetValue(CurrencyStatusItem.AssociatedDateKeyExpiringCurrencies, out object o)) { rgExpiringCurrencies = (IEnumerable <CurrencyStatusItem>)o; } if (pf.AssociatedData.TryGetValue(CurrencyStatusItem.AssociatedDataKeyCachedCurrencies, out object o2)) { rgPrecomputedCurrencies = (IEnumerable <CurrencyStatusItem>)o2; } pf.AssociatedData.Remove(CurrencyStatusItem.AssociatedDateKeyExpiringCurrencies); pf.AssociatedData.Remove(CurrencyStatusItem.AssociatedDataKeyCachedCurrencies); bool fHasCurrency = em.HasSubscription(SubscriptionType.Currency) || (em.HasSubscription(SubscriptionType.Expiration) && rgExpiringCurrencies != null && rgPrecomputedCurrencies != null); bool fHasTotals = em.HasSubscription(SubscriptionType.Totals); bool fHasMonthly = em.HasSubscription(SubscriptionType.MonthlyTotals); bool fMonthlySummary = (String.Compare(szParam, "monthly", StringComparison.OrdinalIgnoreCase) == 0); if (!fHasCurrency && !fHasTotals && !fMonthlySummary) { throw new MyFlightbookException("Email requested but no subscriptions found! User ="******"Monthly email requested but user does not subscribe to monthly email. User = "******"http://{0}{1}", Branding.CurrentBrand.HostName, VirtualPathUtility.ToAbsolute("~/Member/EditProfile.aspx/pftDonate")); mvDonations.SetActiveView(Payment.TotalPaidSinceDate(DateTime.Now.AddYears(-1), Username) > 0 ? vwThankyou : vwPleaseGive); // Fix up the unsubscribe link. lnkUnsubscribe.NavigateUrl = String.Format(CultureInfo.InvariantCulture, "http://{0}{1}/{2}", Branding.CurrentBrand.HostName, VirtualPathUtility.ToAbsolute("~/Member/EditProfile.aspx"), tabID.pftPrefs.ToString()); lnkQuickUnsubscribe.NavigateUrl = String.Format(CultureInfo.InvariantCulture, "http://{0}{1}?u={2}", Branding.CurrentBrand.HostName, VirtualPathUtility.ToAbsolute("~/Public/Unsubscribe.aspx"), HttpUtility.UrlEncode(new UserAccessEncryptor().Encrypt(Username))); bool fAnnual = (DateTime.Now.Month == 1 && DateTime.Now.Day == 1); // if it's January 1, show prior year; else show YTD mfbTotalsByTimePeriod.BindTotalsForUser(Username, !fMonthlySummary, !fMonthlySummary, true, true, !fAnnual); if (fAnnual) { mfbRecentAchievements.Refresh(Username, new DateTime(DateTime.Now.Year - 1, 1, 1), new DateTime(DateTime.Now.Year - 1, 12, 31), true); } else { mfbRecentAchievements.Refresh(Username, new DateTime(DateTime.Now.Year, 1, 1), DateTime.Now, true); } lblRecentAchievementsTitle.Text = mfbRecentAchievements.Summary; lblRecentAchievementsTitle.Visible = mfbRecentAchievements.AchievementCount > 0; lblCurrency.Text = String.Format(CultureInfo.CurrentCulture, Resources.Profile.EmailCurrencyHeader, DateTime.Now.ToLongDateString()); pnlTotals.Visible = fHasTotals || fMonthlySummary; lblTotal.Text = String.Format(CultureInfo.CurrentCulture, Resources.Profile.EmailTotalsHeader, DateTime.Now.ToLongDateString()); lblIntroHeader.Text = String.Format(CultureInfo.CurrentCulture, fMonthlySummary ? Resources.Profile.EmailMonthlyMailIntro : Resources.Profile.EmailWeeklyMailIntro, Branding.CurrentBrand.AppName); if (fHasCurrency || fMonthlySummary) { mfbCurrency.UserName = pf.UserName; mfbCurrency.RefreshCurrencyTable(rgPrecomputedCurrencies); pnlCurrency.Visible = true; if (rgExpiringCurrencies != null && rgExpiringCurrencies.Any()) { pnlExpiringCurrencies.Visible = true; rptExpiring.DataSource = rgExpiringCurrencies; rptExpiring.DataBind(); } } } catch (Exception ex) when(ex is MyFlightbookException || ex is FormatException) { MyFlightbookException.NotifyAdminException(ex); throw; // ensure that the success tag doesn't show! } }