protected void OnUpdateSuccess(MReport report) { UpdateSuccessHandler handler = this.m_updateSuccessEvent; if (handler != null) { handler(report); } }
protected void OnInsertSuccess(MReport report) { InsertSuccessHandler handler = this.m_insertSuccessEvent; if (handler != null) { handler(report); } }
protected void OnUpdateError(MReport report) { UpdateErrorHandler handler = this.m_updateErrorEvent; if (handler != null) { handler(report); } }
protected void OnInsertError(MReport report) { InsertErrorHandler handler = this.m_insertErrorEvent; if (handler != null) { handler(report); } }
public void UpdateAndInsertReport(MReport report) { FilterDefinition<MReport> filter = this.FilterBuiler.Eq(r => r.ReportID, report.ReportID) & FilterBuiler.Eq(r => r.ActiveFlag, 1); UpdateDefinition<MReport> updater = this.UpdateBuiler.Set(r => r.ActiveFlag, 0); try { IMongoCollection<MReport> ReportCollection = LisMDB.GetCollection<MReport>("labs"); UpdateResult res = ReportCollection.UpdateOne(filter, updater); if (res.IsAcknowledged) { if (res.MatchedCount == 0 && res.ModifiedCount == 0) { this.InsertReport(report); } else if (res.MatchedCount == res.ModifiedCount) { this.OnUpdateSuccess(report); this.InsertReport(report); } else { throw new Exception(); } } else { throw new Exception(); } } catch (Exception ex) { throw ex; } }
public void InsertReport(MReport report) { try { IMongoCollection<MReport> ReportCollection = LisMDB.GetCollection<MReport>("labs"); ReportCollection.InsertOne(report); this.OnInsertSuccess(report); } catch (Exception ex) { throw ex; } }
private void SaveReport(LabReport lr) { MReport mr = new MReport(); this.ConvertReport(lr, mr); // this.MongoService.UpdateAndInsertReport(mr); }
private void ConvertReport(LabReport lr, MReport mr) { mr.ReportID = lr.Info.ReportID; mr.ActiveFlag = 1; this.ConvertInfo(lr.Info, mr.Info); this.ConvertItems(lr.ItemList, mr.ItemCollection); this.ConvertCustoms(lr.CustomList, mr.CustomCollection); this.ConvertImages(lr.ImageList, mr.ImageMap); }