private void InitCusRelContext() { if (context == null) { context = new CusRelEntities(); } }
public void InitCusRelContext() { if (cusRelContext == null) { cusRelContext = new CusRelEntities("CusRelUserEntities"); } }
private List <tblAttachmentsTemp> ForceCloseFiles() { using (cusRelContext = new CusRelEntities()) { return((from f in cusRelContext.tblAttachmentsTemp where f.ScanId != null && f.ForceClose != null && f.ForceClose.Value select f).ToList().Select(cleanData).ToList()); } }
private List <tblAttachmentsTemp> ProcessingFiles() { using (cusRelContext = new CusRelEntities()) { return((from f in cusRelContext.tblAttachmentsTemp where f.ScanId != null && f.ScanResult == null select f).ToList().Select(cleanData).ToList()); } }
protected tblAttachmentsTemp GetAttachmentTemp(tblAttachmentsTemp attachmentTemp) { using (cusRelContext = new CusRelEntities()) { var attachment = (from a in cusRelContext.tblAttachmentsTemp where (attachmentTemp.Id > 0 && a.Id == attachmentTemp.Id) || (attachmentTemp.Id <= 0 && (attachmentTemp.AttachmentNum > 0 && a.AttachmentNum == attachmentTemp.AttachmentNum) && (attachmentTemp.FileName != "" && a.FileName == attachmentTemp.FileName) && (attachmentTemp.ScanId != "" && a.ScanId == attachmentTemp.ScanId)) select a).FirstOrDefault(); return(cleanData(attachment)); } }
protected bool UpdateAttachmentTemp(tblAttachmentsTemp attachment) { try { using (cusRelContext = new CusRelEntities()) { cusRelContext.tblAttachmentsTemp.Attach(attachment); cusRelContext.Entry(attachment).State = EntityState.Modified; return(cusRelContext.SaveChanges() == 1); } } catch (Exception e) { return(false); } }
protected bool DeleteAttachmentTemp(tblAttachmentsTemp attachment) { try { using (cusRelContext = new CusRelEntities()) { cusRelContext.tblAttachmentsTemp.Attach(attachment); cusRelContext.tblAttachmentsTemp.Remove(attachment); return(cusRelContext.SaveChanges() == 1); } } catch (Exception e) { return(false); } }
public void Detach(CusRelEntities context) { DetachObject(context, Contact); if (Attachments != null) { foreach (var item in Attachments) { DetachObject(context, item); } } if (ResponseHistory != null) { foreach (var item in ResponseHistory) { DetachObject(context, item); } } if (ResearchHistory != null) { foreach (var item in ResearchHistory) { DetachObject(context, item); } } if (IncidentUpdateHistory != null) { foreach (var item in IncidentUpdateHistory) { DetachObject(context, item); } } if (LinkedContacts != null) { foreach (var item in LinkedContacts) { DetachObject(context, item); } } if (ChangeHistory != null) { foreach (var item in ChangeHistory) { DetachObject(context, item); } } }
protected bool AllowAttachment(tblAttachmentsTemp attachment) { try { using (cusRelContext = new CusRelEntities()) { var newAttachment = new tblAttachments(); newAttachment.InjectFrom(new LoopInjection(new[] { "tblContacts" }), attachment); newAttachment.BinaryData = Convert.FromBase64String(attachment.Base64Data); cusRelContext.tblAttachments.Attach(newAttachment); cusRelContext.Entry(newAttachment).State = EntityState.Added; return(cusRelContext.SaveChanges() == 1); } } catch (Exception e) { return(false); } }
// ============================================================= #region Set Logic and Relations public void PrepareContext(CusRelEntities context) { log.Debug("Begin PrepareContext"); try { log.Debug(string.Format("Contact.FileNum: {0}", Contact.FileNum)); if (Contact.FileNum >= 0) { Contact.updatedOn = DateTime.Now; context.tblContacts.AddOrUpdate(Contact); } if (Contact.FileNum == 0) { return; } if (Attachments != null) { foreach (var item in Attachments) { // ignore when item.FileSize is 0 log.Debug(string.Format("Attachment id:{0} ({1}), FileSize:{2}", item.AttachmentNum, item.FileName, item.FileSize)); if (item.FileSize > 0) { if (item.DateUploaded == null) { item.DateUploaded = DateTime.Now; } context.tblAttachments.AddOrUpdate(item); } else if (item.FileSize == -1) { context.tblAttachments.Attach(item); context.tblAttachments.Remove(item); } } } if (ResponseHistory != null) { foreach (var item in ResponseHistory) { // deletes not allowed if (item.ContactDateTime == null) { item.ContactDateTime = DateTime.Now; } context.tblContactHistory.AddOrUpdate(item); } } if (ResearchHistory != null) { foreach (var item in ResearchHistory) { // deletes not allowed if (item.EnteredDateTime == null) { item.EnteredDateTime = DateTime.Now; } context.tblResearchHistory.AddOrUpdate(item); } } if (IncidentUpdateHistory != null) { foreach (var item in IncidentUpdateHistory) { // deletes not allowed context.tblIncidentUpdateHistory.AddOrUpdate(item); } } if (LinkedContacts != null) { foreach (var item in LinkedContacts) { if (item.Active) { context.tblLinkedContacts.AddOrUpdate(item); } else { context.tblLinkedContacts.Attach(item); context.tblLinkedContacts.Remove(item); } } } // ChangeHistory is read-only, do nothing } finally { log.Debug("Begin PrepareContext"); } }
public TicketRepository(CusRelEntities context) { cusRelContext = context; init(); }
public TicketEntitiesRepository(CusRelEntities context) { this.context = context; }
public TicketEntitiesRepository() { context = new CusRelEntities(); }
public CusRelRepository(CusRelEntities context) { this.context = context; }
public SettingsRepository(CusRelEntities context) { cusRelContext = context; }
public void DetachObject(CusRelEntities context, object obj) { ((IObjectContextAdapter)context).ObjectContext.Detach(obj); }
public UserRepository(CusRelEntities context) { cusRelContext = context; }
//public int CurrentVersionId { get; private set; } public CusRelRepository(CusRelEntities context) { this.context = context; InitCusRelContext(); }