internal static void UpdateReport(SPListItem listItem, string WebUrl, int jsoxLibItemId, NamedTraceLogger.TraceAction trace) { trace("Entering BalanceSheetContentFactory.UpdateReport", 62, TraceSeverity.Verbose); BalanceSheetContent _content = null; using (Entities _edc = new Entities(WebUrl)) { JSOXLibFactory _jsoxLibFactory = JSOXLibFactory.ConstructJSOXLibFActory(_edc, jsoxLibItemId); if (_jsoxLibFactory.JSOXLibraryReadOnly) { string _msg = "The record is read only and the report must not be updated."; trace("ApplicationException at BalanceSheetContentFactory.UpdateReport: " + _msg, 70, TraceSeverity.Monitorable); throw new ApplicationException(_msg); } List <BalanceBatchWrapper> batches = new List <BalanceBatchWrapper>(); bool _validated = _jsoxLibFactory.UpdateBalanceReport(_edc, batches, trace); string _documentName = Settings.RequestForBalanceSheetDocumentName(_edc, _jsoxLibFactory.Id); _content = DocumentsFactory.BalanceSheetContentFactory.CreateContent(_edc, batches, _jsoxLibFactory, _documentName, !_validated); _jsoxLibFactory.JSOXLibraryReadOnly = true; _edc.SubmitChanges(); } _content.UpdateDocument(listItem.File); listItem.ParentList.Update(); trace("Finished BalanceSheetContentFactory.UpdateReport", 82, TraceSeverity.Verbose); }
internal static void CreateReport(SPWeb web, string webUrl, int jsoxLibItemId, NamedTraceLogger.TraceAction trace) { trace("Entering BalanceSheetContentFactory.CreateReport", 33, TraceSeverity.Verbose); SPFile _newFile = default(SPFile); BalanceSheetContent _content = default(BalanceSheetContent); using (Entities _edc = new Entities(webUrl)) { JSOXLib _old = Element.GetAtIndex <JSOXLib>(_edc.JSOXLibrary, jsoxLibItemId); if (_old.JSOXLibraryReadOnly.Value) { throw new ApplicationException("The record is read only and new report must not be created."); } _old.JSOXLibraryReadOnly = true; _content = DocumentsFactory.BalanceSheetContentFactory.CreateEmptyContent(); string _documentName = Settings.RequestForBalanceSheetDocumentName(_edc, jsoxLibItemId + 1); _newFile = SPDocumentFactory.Prepare(web, _content, _documentName); _newFile.DocumentLibrary.Update(); JSOXLibFactory _current = JSOXLibFactory.ConstructJSOXLibFActory(_edc, _newFile.Item.ID); List <BalanceBatchWrapper> batches = new List <BalanceBatchWrapper>(); bool _validated = _current.CreateJSOXReport(_edc, _old, batches, trace); trace("BalanceSheetContentFactory.CreateReport SubmitChanges", 33, TraceSeverity.Verbose); _edc.SubmitChanges(); _content = CreateContent(_edc, batches, _current, _documentName, !_validated); } trace("UpdateDocument " + _newFile.Name, 51, TraceSeverity.Verbose); _content.UpdateDocument(_newFile); _newFile.DocumentLibrary.Update(); trace("Finished BalanceSheetContentFactory.CreateReport", 53, TraceSeverity.Verbose); }