private void button1_Click(object sender, EventArgs e)
 {
     using (AddFilesForm dlg = new AddFilesForm())
     {
         if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             string[] fp   = dlg.FilePaths;
             string   cmnt = dlg.Comment;
             foreach (string f in fp)
             {
                 if ((from s in _activeAttachements where s.FilePath.ToLower() == f.ToLower() select s).FirstOrDefault() == null)
                 {
                     AttachementItem ai = new AttachementItem();
                     ai.FilePath     = f;
                     ai.Comment      = cmnt;
                     ai.GeocacheCode = Core.ActiveGeocache.Code;
                     _activeAttachements.Add(ai);
                     addAttachementItemToList(ai);
                     lock (Core.SettingsProvider)
                     {
                         try
                         {
                             Core.SettingsProvider.Database.Execute(string.Format("insert into {3} (code, filepath, comment) values ('{2}', '{0}', '{1}')", ai.FilePath.Replace("'", "''"), ai.Comment.Replace("'", "''"), ai.GeocacheCode.Replace("'", "''"), Core.SettingsProvider.GetFullTableName("attachements")));
                         }
                         catch
                         {
                         }
                     }
                 }
             }
         }
     }
 }
 public void UpdateView()
 {
     _activeAttachements.Clear();
     linkLabelGC.Links.Clear();
     listView1.Items.Clear();
     if (Core.ActiveGeocache != null)
     {
         pictureBoxGC.ImageLocation = Utils.ImageSupport.Instance.GetImagePath(Core, Framework.Data.ImageSize.Default, Core.ActiveGeocache.GeocacheType);
         linkLabelGC.Text           = string.Format("{0}, {1}", Core.ActiveGeocache.Code, Core.ActiveGeocache.Name);
         linkLabelGC.Links.Add(0, Core.ActiveGeocache.Code.Length, Core.ActiveGeocache.Url);
         button1.Enabled = true;
         lock (Core.SettingsProvider)
         {
             var pocos = Core.SettingsProvider.Database.Fetch <AttachementPoco>(string.Format("select * from {1} where code='{0}'", Core.ActiveGeocache.Code, Core.SettingsProvider.GetFullTableName("attachements")));
             foreach (var poco in pocos)
             {
                 AttachementItem ai = new AttachementItem();
                 ai.Comment      = poco.comment;
                 ai.FilePath     = poco.filepath;
                 ai.GeocacheCode = poco.code;
                 _activeAttachements.Add(ai);
                 addAttachementItemToList(ai);
             }
         }
     }
     else
     {
         pictureBoxGC.Image = null;
         linkLabelGC.Text   = "-";
         button1.Enabled    = false;
     }
 }
        private void addAttachementItemToList(AttachementItem ai)
        {
            ListViewItem lvi = new ListViewItem(new string[] { ai.FilePath, ai.Comment });

            lvi.Tag = ai;
            listView1.Items.Add(lvi);
        }
        public ActionResult GetAttachement(int chainid, long chainindex, int attachementkey, long transactionid, string name)
        {
            if (!AttachementItem.IsNameValid(name))
            {
                return(BadRequest());
            }

            var path = _node.AttachementManager.GetAttachementPath(chainid, (uint)chainindex, attachementkey, transactionid, name);

            return(PhysicalFile(path, "application/octet-stream", AttachementManager.GetAttachementFileName(transactionid, name)));
        }
 private void button3_Click(object sender, EventArgs e)
 {
     if (listView1.SelectedItems.Count > 0)
     {
         AttachementItem ai = listView1.SelectedItems[0].Tag as AttachementItem;
         try
         {
             System.Diagnostics.Process.Start(ai.FilePath);
         }
         catch
         {
         }
     }
 }
 private void button2_Click(object sender, EventArgs e)
 {
     if (listView1.SelectedItems.Count > 0)
     {
         AttachementItem ai = listView1.SelectedItems[0].Tag as AttachementItem;
         lock (Core.SettingsProvider)
         {
             try
             {
                 Core.SettingsProvider.Database.Execute(string.Format("delete from {2} where code='{1}' and filepath='{0}'", ai.FilePath.Replace("'", "''"), ai.GeocacheCode.Replace("'", "''"), Core.SettingsProvider.GetFullTableName("attachements")));
             }
             catch
             {
             }
         }
         _activeAttachements.Remove(ai);
         listView1.Items.Remove(listView1.SelectedItems[0]);
     }
 }
Exemple #7
0
 public void UpdateView()
 {
     _activeAttachements.Clear();
     linkLabelGC.Links.Clear();
     listView1.Items.Clear();
     if (Core.ActiveGeocache != null)
     {
         pictureBoxGC.ImageLocation = Utils.ImageSupport.Instance.GetImagePath(Core, Framework.Data.ImageSize.Default, Core.ActiveGeocache.GeocacheType);
         linkLabelGC.Text = string.Format("{0}, {1}", Core.ActiveGeocache.Code, Core.ActiveGeocache.Name);
         linkLabelGC.Links.Add(0, Core.ActiveGeocache.Code.Length, Core.ActiveGeocache.Url);
         button1.Enabled = true;
         if (initDatabase() != null)
         {
             DbDataReader dr = _dbcon.ExecuteReader(string.Format("select filepath, comment from attachements where code='{0}'", Core.ActiveGeocache.Code.Replace("'","''")));
             while (dr.Read())
             {
                 AttachementItem ai = new AttachementItem();
                 ai.Comment = dr["comment"] as string;
                 ai.FilePath = dr["filepath"] as string;
                 ai.GeocacheCode = Core.ActiveGeocache.Code;
                 _activeAttachements.Add(ai);
                 addAttachementItemToList(ai);
             }
         }
     }
     else
     {
         pictureBoxGC.Image = null;
         linkLabelGC.Text = "-";
         button1.Enabled = false;
     }
 }
Exemple #8
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (AddFilesForm dlg = new AddFilesForm())
     {
         if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             string[] fp = dlg.FilePaths;
             string cmnt = dlg.Comment;
             foreach (string f in fp)
             {
                 if ((from s in _activeAttachements where s.FilePath.ToLower() == f.ToLower() select s).FirstOrDefault() == null)
                 {
                     AttachementItem ai = new AttachementItem();
                     ai.FilePath = f;
                     ai.Comment = cmnt;
                     ai.GeocacheCode = Core.ActiveGeocache.Code;
                     _activeAttachements.Add(ai);
                     addAttachementItemToList(ai);
                     if (initDatabase() != null)
                     {
                         try
                         {
                             _dbcon.ExecuteNonQuery(string.Format("insert into attachements (code, filepath, comment) values ('{2}', '{0}', '{1}')", ai.FilePath.Replace("'", "''"), ai.Comment.Replace("'", "''"), ai.GeocacheCode.Replace("'", "''")));
                         }
                         catch
                         {
                         }
                     }
                 }
             }
         }
     }
 }
Exemple #9
0
 private void addAttachementItemToList(AttachementItem ai)
 {
     ListViewItem lvi = new ListViewItem(new string[] {ai.FilePath, ai.Comment });
     lvi.Tag = ai;
     listView1.Items.Add(lvi);
 }
Exemple #10
0
 public AttachementTempFile(AttachementItem item, Stream stream)
 {
     Item   = item;
     Stream = stream;
 }
Exemple #11
0
 public void UpdateView()
 {
     _activeAttachements.Clear();
     linkLabelGC.Links.Clear();
     listView1.Items.Clear();
     if (Core.ActiveGeocache != null)
     {
         pictureBoxGC.ImageLocation = Utils.ImageSupport.Instance.GetImagePath(Core, Framework.Data.ImageSize.Default, Core.ActiveGeocache.GeocacheType);
         linkLabelGC.Text = string.Format("{0}, {1}", Core.ActiveGeocache.Code, Core.ActiveGeocache.Name);
         linkLabelGC.Links.Add(0, Core.ActiveGeocache.Code.Length, Core.ActiveGeocache.Url);
         button1.Enabled = true;
         lock (Core.SettingsProvider)
         {
             var pocos = Core.SettingsProvider.Database.Fetch<AttachementPoco>(string.Format("select * from {1} where code='{0}'", Core.ActiveGeocache.Code, Core.SettingsProvider.GetFullTableName("attachements")));
             foreach(var poco in pocos)
             {
                 AttachementItem ai = new AttachementItem();
                 ai.Comment = poco.comment;
                 ai.FilePath = poco.filepath;
                 ai.GeocacheCode = poco.code;
                 _activeAttachements.Add(ai);
                 addAttachementItemToList(ai);
             }
         }
     }
     else
     {
         pictureBoxGC.Image = null;
         linkLabelGC.Text = "-";
         button1.Enabled = false;
     }
 }
 public ServiceAttachementFile(string tempPath, AttachementItem item)
 {
     TempPath = tempPath;
     Item     = item;
 }