コード例 #1
0
        public override void PerformFinalUpdate()
        {
            // Move the image into the user's data directory.
            //AManager.mainForm master = (AManager.mainForm)this.Attributes["var_masterform"];

            XTS.DBFileSystem filesys = new XTS.DBFileSystem((dbal.AbstractObjects.Database)this.Attributes["var_dbobject"]);
            XTS.DBFile file = filesys.GetFileByPath((string)this.Attributes["ucpath"]);
            string oldpath = file.ucpath;
            if (oldpath.IndexOf(@"Temp\Swapspace") > 0)
            {
                string newpath = oldpath.Replace(@"Temp\Swapspace", (string)this.Attributes["var_finalfilepath"]);
                filesys.MoveFile(oldpath, newpath, true);
                this.Attributes["ucpath"] = newpath;
            }
        }
コード例 #2
0
        public override void PerformPostSettingsUpdate()
        {
            if (this.Attributes.ContainsKey("ucpath") && (!this.Attributes.ContainsKey("require_post_update")))
            {
                //AManager.mainForm master = (AManager.mainForm)this.Attributes["var_masterform"];
                XTS.DBFileSystem filesys = new XTS.DBFileSystem((dbal.AbstractObjects.Database)this.Attributes["var_dbobject"]);
                XTS.DBFile newFile = null;
                string filename = (string)this.Attributes["ucpath"];
                filename = filename.Substring(filename.LastIndexOf(@"\") + 1);
                //if (!filesys.fileExists(@"USERS\"+(string)this.Attributes["var_username"]+@"\Temp\Swapspace\"+filename))
                //    newFile = filesys.createFile(@"USERS\" + (string)this.Attributes["var_username"] + @"\Temp\Swapspace\" + filename);
                newFile = filesys.GetFileByPath(@"USERS\" + (string)this.Attributes["var_username"] + @"\Temp\Swapspace\" + filename);
                System.IO.MemoryStream ts = new System.IO.MemoryStream();

                System.IO.FileStream fs = new System.IO.FileStream((string)this.Attributes["ucpath"], System.IO.FileMode.Open);

                newFile.WriteFromStream(fs);

                //this.Attributes.Remove("ucpath"); //Security fix.
                this.Attributes["ucpath"] = newFile.ucpath;
                this.Attributes["_core_SourceImage"] = newFile.data;
                this.Attributes["require_post_update"] = false;
            }
        }
コード例 #3
0
ファイル: AOFileloader.cs プロジェクト: andrewjc/sqlconsole
 private void lnkFileSrc_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     // Save the file.
     try
     {
         dbal.AbstractObjects.Database dbo = ((dbal.AbstractObjects.Database)this._paramList["var_dbobject"]);
         if (this.fsw != null) this.fsw.EnableRaisingEvents = false;
         XTS.DBFileSystem dbs = new XTS.DBFileSystem(dbo);
         XTS.DBFile file = dbs.GetFileByPath((string)this._filename);
         file.Reload();
         System.IO.FileStream tempFile = new System.IO.FileStream(Environment.GetEnvironmentVariable("TEMP") + @"\" + _filename.Substring(_filename.LastIndexOf("\\") + 1), System.IO.FileMode.OpenOrCreate);
         tempFile.Write(file.data, 0, file.data.Length);
         tempFile.Close();
         try
         {
             startAndWatch(Environment.GetEnvironmentVariable("TEMP") + @"\" + _filename.Substring(_filename.LastIndexOf("\\") + 1));
         }
         catch
         {
             MessageBox.Show("There was a problem opening the selected file.\r\nMake sure there is an associated program for the file extension.");
             return;
         }
     }
     catch(Exception err)
     {
         aoButton1_Click(sender, e);
     }
 }
コード例 #4
0
ファイル: AOFileloader.cs プロジェクト: andrewjc/sqlconsole
 private void ActiveFileChanged()
 {
     if (this.InvokeRequired)
     {
         Invoke(new FileChangeDelegate(ActiveFileChanged), new object[] { });
     }
     else
     {
         if (MessageBox.Show("The following file has changed outside of the system:\r\n\r\n" + _filename.Substring(_filename.LastIndexOf("\\") + 1) + "\r\n\r\nWould you like to reload it into the database?", "Filesystem Notification", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             // Save the file.
             dbal.AbstractObjects.Database dbo = ((dbal.AbstractObjects.Database)this._paramList["var_dbobject"]);
             XTS.DBFileSystem dbs = new XTS.DBFileSystem(dbo);
             XTS.DBFile file = dbs.GetFileByPath((string)this._filename);
             System.IO.FileStream tempFile = new System.IO.FileStream(Environment.GetEnvironmentVariable("TEMP") + @"\" + _filename.Substring(_filename.LastIndexOf("\\") + 1), System.IO.FileMode.Open);
             file.data = new byte[tempFile.Length];
             tempFile.Position = 0;
             file.WriteFromStream(tempFile);
             tempFile.Close();
             file.Flush();
         }
     }
 }
コード例 #5
0
ファイル: AOFileloader.cs プロジェクト: andrewjc/sqlconsole
        private void aoButton1_Click(object sender, EventArgs e)
        {
            AOFileSystemBrowser fsb = new AOFileSystemBrowser();
            fsb.dbObject = ((dbal.AbstractObjects.Database)this._paramList["var_dbobject"]);
            //fsb.dbObject = ((AManager.mainForm)this.ParentForm.MdiParent).getDatabaseObject();
            if (this.tq != null)
            {
                this.tq.RollBack();
                this.tq = new dbal.AbstractObjects.TransactionQueue(fsb.dbObject);
            }
            Form popupForm = new Form();
            popupForm.Controls.Add(fsb);
            //popupForm.MdiParent = this.ParentForm.MdiParent;

            popupForm.Size = fsb.Size;

            fsb.Dock = DockStyle.Fill;

            popupForm.Text = "Select File";

            popupForm.StartPosition = FormStartPosition.CenterScreen;
            fsb.InitControl();
            if (popupForm.ShowDialog() == DialogResult.OK)
            {
                System.IO.FileStream fStream = null;
                try
                {
                    fStream = new System.IO.FileStream(fsb.Filename, System.IO.FileMode.Open);
                }
                catch
                {
                    MessageBox.Show("Access to the selected file was denied.", "Upload failed", MessageBoxButtons.OK);
                    return;
                }
                XTS.DBFileSystem dfs = new XTS.DBFileSystem(fsb.dbObject);
                XTS.DBFile dbo = dfs.GetFileByPath(@"USERS\" + (string)this._paramList["var_username"] + @"\Temp\Swapspace\" + fsb.Filename.Substring(fsb.Filename.LastIndexOf("\\") + 1));
                dbo.WriteFromStream(fStream);
                dbo.Flush();
                fStream.Close();
                dbo.Reload();
                this._filename = dbo.ucpath;
                this.lnkFileSrc.Text = fsb.Filename.Substring(fsb.Filename.LastIndexOf("\\")+1);
                this._middlemode = true;
                this.OnTextChanged(new EventArgs());
            }
        }