Exemple #1
0
 /// <summary>
 /// Creates a new instance from a file path.
 /// </summary>
 /// <param name="filePath">Full path of the file.</param>
 /// <param name="objectGuid">Guid of the DB object to be associated with this attachment. ie. Device Guid or SibiRequest Guid.</param>
 /// <param name="folder">The folder instance to be associated with this attachment.</param>
 /// <param name="columns"><see cref="AttachmentsBaseCols"/> instance which contains the field column names to be mapped.</param>
 public Attachment(string filePath, string objectGuid, Folder folder, AttachmentsBaseCols columns)
 {
     fileInfo        = new FileInfo(filePath);
     fileName        = Path.GetFileNameWithoutExtension(fileInfo.Name);
     fileGuid        = Guid.NewGuid().ToString();
     fileMD5         = null;
     streamMD5       = null;
     fileSize        = fileInfo.Length;
     extention       = fileInfo.Extension;
     this.folder     = folder;
     this.objectGuid = objectGuid;
     attachColumns   = columns;
     dataStream      = fileInfo.OpenRead();
 }
Exemple #2
0
 public Attachment()
 {
     fileInfo      = null;
     fileName      = null;
     fileSize      = 0;
     extention     = null;
     folder        = new Folder();
     objectGuid    = null;
     fileMD5       = null;
     streamMD5     = null;
     fileGuid      = null;
     attachColumns = null;
     dataStream    = null;
 }
Exemple #3
0
 /// <summary>
 /// Creates a new instance from a <see cref="DataRow"/>.
 /// </summary>
 /// <param name="attachRow"><see cref="DataRow"/> which contains the fields to be mapped to this instance.</param>
 /// <param name="columns"><see cref="AttachmentsBaseCols"/> instance which contains the field column names to be mapped.</param>
 public Attachment(DataRow attachRow, AttachmentsBaseCols columns)
 {
     fileInfo      = null;
     dataStream    = null;
     attachColumns = columns;
     fileName      = attachRow[columns.FileName].ToString();
     fileGuid      = attachRow[columns.FileGuid].ToString();
     fileMD5       = attachRow[columns.FileHash].ToString();
     streamMD5     = null;
     fileSize      = Convert.ToInt64(attachRow[columns.FileSize]);
     extention     = attachRow[columns.FileType].ToString();
     folder        = new Folder(attachRow[columns.FolderName].ToString(), attachRow[columns.FolderNameGuid].ToString());
     objectGuid    = attachRow[columns.FKey].ToString();
 }
 public static void SetAttachmentCount(ToolStripButton targetTool, string attachFolderGuid, AttachmentsBaseCols attachTable)
 {
     if (!GlobalSwitches.CachedMode)
     {
         try
         {
             int attachCount = Convert.ToInt32(GetSqlValue(attachTable.TableName, attachTable.FKey, attachFolderGuid, "COUNT(*)"));
             targetTool.Text        = "(" + attachCount.ToString() + ")";
             targetTool.ToolTipText = "Attachments " + targetTool.Text;
         }
         catch (Exception ex)
         {
             ErrorHandling.ErrHandle(ex, System.Reflection.MethodBase.GetCurrentMethod());
         }
     }
 }