/// <summary> /// Method that returns name of akcive database /// </summary> /// <param name="e"></param> /// <returns></returns> private string getFileName(FileSavingEventArgs e) { string fName = ""; if (e.Database.IOConnectionInfo.IsLocalFile()) { // local file var f = new FileInfo(e.Database.IOConnectionInfo.Path); fName = f.Name; // remove file extension if (!string.IsNullOrEmpty(f.Extension)) { fName = fName.Substring(0, fName.Length - f.Extension.Length); } f = null; } else { if (MessageBox.Show("Only Local stored Files allowed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Question) == DialogResult.OK) { Terminate(); } } return(fName); }
private void OTPDB_FileSaved(object sender, FileSavingEventArgs e) { if (e.Cancel) { return; } if (e.Database.IOConnectionInfo.Path != DB.IOConnectionInfo.Path) { return; } if (!Valid) { return; } List <System.Diagnostics.StackFrame> lSF = new System.Diagnostics.StackTrace().GetFrames().ToList(); bool bSync = lSF.Find(f => (f.GetMethod().Name == "Synchronize") && (f.GetMethod().ReflectedType == typeof(ImportUtil))) != null; //Save if OTP database exists and is unlocked and ImportUtil.Synchronize is not called if (!bSync && OTPDB_Exists && OTPDB_Opened) { OTPDB_Save(); } else if (bSync) //Sync if ImportUtil.Synchronize is called, don't care about OTP database existance / lock status { if (OTPDB_Reload()) { OTPDB_Save(); } } }
static void PrepareFileToDelayedRemove(DevExpress.Web.ASPxHtmlEditor.ASPxHtmlEditor htmlEditor, Func <DevExpress.Web.ASPxHtmlEditor.ASPxHtmlEditor, ASPxHtmlEditorUploadSettingsBase> uploadSettingsGetter, FileSavingEventArgs e) { e.FileName = string.Format("DEMOTMPFILE_{0}{1}", Guid.NewGuid(), Path.GetExtension(e.FileName)); string filePath = Path.Combine(htmlEditor.Page.MapPath(uploadSettingsGetter(htmlEditor).UploadFolder), e.FileName); }
protected override void Invoke(object parameter) { FileSavingEventArgs args = parameter as FileSavingEventArgs; if (args != null) { DocxExporting.ConvertToDocument(((RichTextBoxAdv)Target).Document, args.DoucmentStream, args.FormatType); } }
public static string GetSourceFileName(FileSavingEventArgs e) { string SourceFileName = string.Empty; if (e.Database.IOConnectionInfo.IsLocalFile()) { // local file var f = new FileInfo(e.Database.IOConnectionInfo.Path); SourceFileName = f.Name; // remove file extension if (!string.IsNullOrEmpty(f.Extension)) { SourceFileName = SourceFileName.Substring(0, SourceFileName.Length - f.Extension.Length); } f = null; } else { // remote file SourceFileName = e.Database.IOConnectionInfo.Path; //MessageBox.Show(e.Database.IOConnectionInfo.Path); //Complete URI int lastPosBack = SourceFileName.LastIndexOf("/"); if (lastPosBack > 0 && lastPosBack < SourceFileName.Length) { SourceFileName = SourceFileName.Substring(lastPosBack + 1); } int lastPosSlash = SourceFileName.LastIndexOf(@"\"); if (lastPosSlash > 0 && lastPosSlash < SourceFileName.Length) { SourceFileName = SourceFileName.Substring(lastPosSlash + 1); } // remove file extension int lastPoitDot = SourceFileName.LastIndexOf("."); int lenghtWithoutDot = SourceFileName.Length - lastPoitDot; if (lenghtWithoutDot == 3 || lenghtWithoutDot == 4 || lenghtWithoutDot == 5) { SourceFileName = SourceFileName.Substring(0, lastPoitDot); } } //MessageBox.Show(SourceFileName); //Filename w/o ext return(SourceFileName); }
private void OnKPDBSaving(object sender, FileSavingEventArgs e) { SignalAllManagedRPCClients(Signal.DATABASE_SAVING); }
private void OnFileSaving(object sender, FileSavingEventArgs e) { saveNotified = false; }
private void OnFileSaving(object sender, FileSavingEventArgs fileSavingEventArgs) { this.IsSaving = true; }
private void OnKPDBSaving(object sender, FileSavingEventArgs e) { SignalAllManagedRPCClients(KeePassRPC.DataExchangeModel.Signal.DATABASE_SAVING); }
static void OnVideoFileSaving(object s, FileSavingEventArgs e) { PrepareFileToDelayedRemove(s as DevExpress.Web.ASPxHtmlEditor.ASPxHtmlEditor, he => he.SettingsDialogs.InsertVideoDialog.SettingsVideoUpload, e); }
/// <summary> /// Handler to be called before the KeePass Database is saved. It checks /// whether the database has been modified and updates the internal flag /// of this class accordingly. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnDatabaseSavingPreAction(object sender, FileSavingEventArgs e) { m_databaseModifiedAfterLastBackup = m_databaseModifiedAfterLastBackup || e.Database.Modified; }
private void OnFileSaving(object sender, FileSavingEventArgs e) { mEntryView.FinishEditingNotes(); }
private void OnFileSaving(object sender, FileSavingEventArgs e) { //Thats the way we do it! if (e.Database.IsOpen) { //MessageBox.Show("Database is open."); //MessageBox.Show("Database mod: " + e.Database.Modified); if (e.Database.Modified) { //MessageBox.Show("Database is modified. " + e.Database.Modified); string SourceFile = string.Empty; string SourceFileName = string.Empty; string DateAppend = "_" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"); string BackupFile = string.Empty; //Just the backup file filename (without path) string BackupFilePath = string.Empty; //The complete path and filename SourceFileName = GetSourceFileName(e); //MessageBox.Show("SFN: " + SourceFileName); //Filename Only if (e.Database.IOConnectionInfo.IsLocalFile()) { SourceFile = e.Database.IOConnectionInfo.Path; } else { // remote file SourceFile = Path.GetTempFileName(); var wc = new WebClient(); wc.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore); if ((e.Database.IOConnectionInfo.UserName.Length > 0) || (e.Database.IOConnectionInfo.Password.Length > 0)) { wc.Credentials = new NetworkCredential(e.Database.IOConnectionInfo.UserName, e.Database.IOConnectionInfo.Password); } wc.DownloadFile(e.Database.IOConnectionInfo.Path, SourceFile); //MessageBox.Show("Downloaded_from:"+ e.Database.IOConnectionInfo.Path+ " To:"+ SourceFile+ " UN:PW"+ e.Database.IOConnectionInfo.UserName+ e.Database.IOConnectionInfo.Password); wc.Dispose(); wc = null; } string destPath = Path.GetDirectoryName(e.Database.IOConnectionInfo.GetDisplayName()); // Destination backup folder is KeePass.exe directory if (Directory.Exists(destPath)) { if (File.Exists(SourceFile)) { // create file BackupFile = SourceFileName + backupPostfix + DateAppend + backupExt; BackupFilePath = destPath + "/" + BackupFile; // MessageBox.Show("Creating backup " + BackupFilePath); File.Copy(SourceFile, BackupFilePath, true); //Get all backup databases in path List <string> bakFiles = new List <string>(); foreach (string file in Directory.GetFiles(destPath, SourceFileName + backupPostfix + "*" + backupExt)) { bakFiles.Add(file); } //Clean up (delete) all old database backups bakFiles.Reverse(); //descending sort - newest on top /* Debug only * string bf = "bakFiles: "; * foreach (string bakFile in bakFiles) * { * bf = bf + " " + bakFile; * } * MessageBox.Show(bf); */ int cnt = 0; foreach (string bakFile in bakFiles) { cnt++; if (cnt > NumberOfBackups) { if (File.Exists(bakFile)) { File.Delete(bakFile); } } } } } else { MessageBox.Show("Backupfolder not found : " + destPath); } // delete temp remote file if (!e.Database.IOConnectionInfo.IsLocalFile()) { File.Delete(SourceFile); } } } else { MessageBox.Show("Database is not open."); } }