internal static AttachmentInfo FetchAttachmentInfo(Data.Attachment data) { var result = new AttachmentInfo(); result.Fetch(data); return(result); }
protected void Insert(Data.Attachment data) { data.AttachmentId = this.ReadProperty(AttachmentIdProperty); data.CreatedBy = ((BusinessIdentity)Csla.ApplicationContext.User.Identity).UserId; data.CreatedDate = DateTime.Now; this.Update(data); }
protected void Update(Data.Attachment data) { if (this.IsSelfDirty) { data.SourceType = (int)this.ReadProperty(SourceTypeProperty); data.SourceId = this.ReadProperty(SourceIdProperty); data.Name = this.ReadProperty(NameProperty); data.FileType = this.ReadProperty(FileTypeProperty); data.FileData = this.ReadProperty(FileDataProperty); data.ModifiedBy = ((BusinessIdentity)Csla.ApplicationContext.User.Identity).UserId; data.ModifiedDate = DateTime.Now; } }
protected void Fetch(Data.Attachment data) { this.LoadProperty(AttachmentIdProperty, data.AttachmentId); this.LoadProperty(SourceTypeProperty, data.SourceType); this.LoadProperty(SourceIdProperty, data.SourceId); this.LoadProperty(NameProperty, data.Name); this.LoadProperty(FileTypeProperty, data.FileType); this.LoadProperty(FileDataProperty, data.FileData); this.LoadProperty(ModifiedByProperty, data.ModifiedBy); this.LoadProperty(ModifiedByNameProperty, data.ModifiedByUser.Name); this.LoadProperty(ModifiedDateProperty, data.ModifiedDate); this.LoadProperty(CreatedByProperty, data.CreatedBy); this.LoadProperty(CreatedByNameProperty, data.CreatedByUser.Name); this.LoadProperty(CreatedDateProperty, data.CreatedDate); }
protected override void DataPortal_DeleteSelf() { using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities> .GetManager(Database.ApplicationConnection, false)) { var data = new Data.Attachment { AttachmentId = this.ReadProperty(AttachmentIdProperty) }; ctx.ObjectContext.Attachments.DeleteObject(data); ctx.ObjectContext.SaveChanges(); } }
protected override void DataPortal_Insert() { using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities> .GetManager(Database.ApplicationConnection, false)) { var data = new Data.Attachment(); this.Insert(data); ctx.ObjectContext.AddToAttachments(data); ctx.ObjectContext.SaveChanges(); this.LoadProperty(AttachmentIdProperty, data.AttachmentId); this.LoadProperty(CreatedByProperty, data.CreatedBy); this.LoadProperty(CreatedDateProperty, data.CreatedDate); } }
protected override void DataPortal_Update() { using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities> .GetManager(Database.ApplicationConnection, false)) { var data = new Data.Attachment { AttachmentId = this.ReadProperty(AttachmentIdProperty) }; ctx.ObjectContext.Attachments.Attach(data); this.Update(data); ctx.ObjectContext.SaveChanges(); this.LoadProperty(ModifiedByProperty, data.ModifiedBy); this.LoadProperty(ModifiedDateProperty, data.ModifiedDate); } }
public void SaveToUserPersistantLog() { try { var ud = Session["PersistingUserData"] as Data.UserData; string pdf = Session["CombinedPdf"] as string; Data.Attachment a = new Data.Attachment(); a.Email = ud.Email; a.Name = ud.Name; a.Files.Add(new Data.FileReference(Session["Ordernumber"] as string, pdf)); ud.Attachments.Add(a); ud.Log.Add(new Data.LogEntry("Checked Out Order #" + Session["Ordernumber"] as string, Session["Ordernumber"] as string)); SettingsDBData db = new SettingsDBData(); db.Appname = ud.Guid; db.XmlData = ud.SerializeToXmlString(ud); Save.Setting(db); } catch { } }
public static int MediaType(this Data.Attachment attachment) { var videos = new List <string>() { ".AVI", ".MKV", ".MOV", ".MP4", ".TS", ".WEBM" }; var audios = new List <string>() { ".MP3", ".WAV", ".AAC", ".WMV", ".WMA", ".3GP" }; var images = new List <string>() { ".MPEG", ".JPEG", ".JPG ", ".PNG" }; var docs = new List <string>() { ".PDF", ".XLSX", ".DOC ", ".DOCX", ".TXT", ".HTML", ".OXPS" }; if (videos.Any(c => c.ToLower() == attachment.Extension.ToLower())) { return((int)MediaFileType.VIDEO); } else if (audios.Any(c => c.ToLower() == attachment.Extension.ToLower())) { return((int)MediaFileType.AUDIO); } else if (images.Any(c => c.ToLower() == attachment.Extension.ToLower())) { return((int)MediaFileType.IMAGE); } else if (docs.Any(c => c.ToLower() == attachment.Extension.ToLower())) { return((int)MediaFileType.DOCUMENT); } else { return(0); } }