private void SaveMaterialContentFromFile(MaterialContent content) { SourceFileInfo.NullCheck("SourceFileInfo"); if (CheckSourceFileExists) { ExceptionHelper.FalseThrow(SourceFileInfo.Exists, string.Format(Resources.FileNotFound, SourceFileInfo.Name)); } if (SourceFileInfo.Exists) { content.FileSize = SourceFileInfo.Length; using (TransactionScope scope = TransactionScopeFactory.Create()) { using (FileStream stream = SourceFileInfo.OpenRead()) { MaterialContentAdapter.Instance.Update(content, stream); TransactionScopeFactory.AttachCommittedAction(new Action <TransactionEventArgs>(Current_TransactionCompleted), false); } scope.Complete(); } } }
private static void AttachTransactionEvent() { if (Transaction.Current != null && TransactionEventAttached == false) { TransactionScopeFactory.AttachCommittedAction(new Action <TransactionEventArgs>(Current_TransactionCompleted), false); TransactionEventAttached = true; } }
private void SaveMaterialContentFromData(MaterialContent content) { content.FileSize = content.ContentData.Length; using (TransactionScope scope = TransactionScopeFactory.Create()) { using (MemoryStream stream = new MemoryStream(content.ContentData)) { MaterialContentAdapter.Instance.Update(content, stream); TransactionScopeFactory.AttachCommittedAction(new Action <TransactionEventArgs>(Current_TransactionCompleted), false); } scope.Complete(); } }