internal static InboundDocsDto CreateInboundDocsDto(InboundDocsView inbDocView, string newFileName = null) { InboundDocsDto inboundDocsData = new InboundDocsDto { CallerRef = inbDocView.CallerRef, Cmt = inbDocView.Cmt, DocStatusCode = inbDocView.DocStatusCode, FileName = newFileName ?? inbDocView.FileName, HasAutoAsctedFlag = inbDocView.HasAutoAsctedFlag, Id = inbDocView.Id, MappedCptySn = inbDocView.MappedCptySn, Sender = inbDocView.Sender, SentTo = inbDocView.SentTo, RcvdTs = inbDocView.RcvdTs }; return inboundDocsData; }
private void CopyDataToBeUpdated() { sumDataCacheCopy.Clear(); rqmtDataCacheCopy.Clear(); assDocDataCacheCopy.Clear(); inbDocViewCacheCopy.Clear(); tradeRqmtConfirmCacheCopy.Clear(); foreach (SummaryData data in sumDataCache) { SummaryData copyData = new SummaryData(); copyData = data; sumDataCacheCopy.Add(copyData); } foreach (RqmtData data in rqmtDataCache) { RqmtData copyData = new RqmtData(); copyData = data; rqmtDataCacheCopy.Add(copyData); } foreach (AssociatedDoc data in assDocDataCache) { AssociatedDoc copyData = new AssociatedDoc(); copyData = data; assDocDataCacheCopy.Add(copyData); } foreach (InboundDocsView data in inbDocViewCache) { InboundDocsView copyData = new InboundDocsView(); copyData = data; inbDocViewCacheCopy.Add(copyData); } foreach (TradeRqmtConfirm data in tradeRqmtConfirmCache) { TradeRqmtConfirm copyData = new TradeRqmtConfirm(); copyData = data; tradeRqmtConfirmCacheCopy.Add(copyData); } }
private string GenerateCopyFileName(InboundDocsView inbDocView, string fileNameMiddle = "_copy_") { var fileName = inbDocView.FileName; var lastDot = fileName.LastIndexOf('.'); var ext = (lastDot < 0) ? "" : fileName.Substring(lastDot, fileName.Length-lastDot); fileName = fileName.Replace(ext, ""); var pattern = string.Format("(.*){0}([0-9]+)$",fileNameMiddle); Regex regex = new Regex(pattern, RegexOptions.IgnoreCase); var match = regex.Match(fileName); if (!match.Success) { return string.Format("{0}{1}1{2}", fileName, fileNameMiddle, ext); } var filePrefix = match.Groups[1].Value; var numCapture = match.Groups[2].Value; var next = Convert.ToInt32(numCapture) + 1; return string.Format("{0}{1}{2}{3}", filePrefix, fileNameMiddle, next, ext); }
private void ApplyMergeResultsToView(InboundDocsView viewToDiscard) { try { gridViewInboundDocs.BeginDataUpdate(); InboundPnl.MasterInboundDocsTable.BeginLoadData(); var rowFound = InboundPnl.MasterInboundDocsTable.Rows.Find(viewToDiscard.Id); if (rowFound != null) { CollectionHelper.UpdateDataRowFromObject<InboundDocsView>(viewToDiscard, ref rowFound); } } finally { FinishApplyingInboundGridViewChanges(); } }
private void ApplyNewInboundDocToView(InboundDocsView newInboundDoc) { var table = InboundDocsViewTable; try { gridViewInboundDocs.BeginDataUpdate(); table.BeginLoadData(); var newRow = table.NewRow(); table.Rows.Add(CollectionHelper.CreateDataRowFromObject<InboundDocsView>(newInboundDoc, newRow)); } finally { FinishApplyingInboundGridViewChanges(); } }
private void PersistDocumentSplit(InboundDocsView current, DocumentSplitResult splitResult, ImagesDto originalDocDto) { using (var ts = new TransactionScope()) { string guidFileName = GenerateCopyFileName(current, "_split_"); var newInboundDocDto = DtoViewConverter.CreateInboundDocsDto(current,guidFileName); newInboundDocDto.Id = inboundDocsDal.Insert(newInboundDocDto); Logger.DebugFormat("Persisted document split, new document Id = {0}", newInboundDocDto.Id); var splitImage = splitResult.SplitPages.GetImageBytes(); imagesDal.Insert( new ImagesDto( newInboundDocDto.Id, splitImage, originalDocDto.MarkupImageFileExt, splitImage, originalDocDto.MarkupImageFileExt, originalDocDto.Type) ); originalDocDto.MarkupImage = splitResult.Remainder.GetImageBytes(); imagesDal.Update(originalDocDto); var newInboundDocView = DtoViewConverter.CreateInboundDocsView(newInboundDocDto); ApplyNewInboundDocToView(newInboundDocView); ts.Complete(); } }
public void LoadImageInEditor(InboundDocsView view) { if (IsDocumentEdited != null && IsDocumentEdited() && !isCacheUpdating) { if (MessageBox.Show(@"Save image changes?", @"Save Image", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly) == DialogResult.Yes) { ImagesEventManager.Instance.Raise(new ImagesSavingEventArgs()); } } if (view != null) { var imagesDto = imagesDal.GetByDocId(view.Id, ImagesDtoType.Inbound); if (imagesDto == null) { Logger.WarnFormat("Attempt to display non-existant inbound image for id = {0}", view.Id); } ImagesEventManager.Instance.Raise(new ImagesSelectedEventArgs(imagesDto, (imagesDto != null))); } else { ImagesEventManager.Instance.Raise(new ImagesSelectedEventArgs(null, false)); } }
public void EndGridDataUpdates() { try { gridViewInboundDocs.EndDataUpdate(); if (focusedInbDocBeforeUpdates != null) { try { DataRow[] found = InboundDocsViewTable.Select("Id = " + focusedInbDocBeforeUpdates.Id); if (found.Length > 0) { GridColumn col = gridViewInboundDocs.Columns["Id"]; int rowHandle = gridViewInboundDocs.LocateByValue(0, col, focusedInbDocBeforeUpdates.Id); if ((rowHandle >= 0)) { gridViewInboundDocs.ClearSelection(); gridViewInboundDocs.SelectRow(rowHandle); gridViewInboundDocs.FocusedRowHandle = rowHandle; } } } catch (Exception ex) { LogAndDisplayException("An error occurred while processing updates for Id: " + focusedInbDocBeforeUpdates.Id + "." + Environment.NewLine + "Error CNF-517 in " + FORM_NAME + ".EndGridDataUpdates().", ex); } } focusedInbDocBeforeUpdates = null; gridViewInboundDocs.FocusedRowChanged += gridViewInboundDocs_FocusedRowChanged; } finally { isCacheUpdating = false; } }
public void BeginDataGridUpdates() { isCacheUpdating = true; DataRow dr = null; focusedInbDocBeforeUpdates = null; gridViewInboundDocs.BeginDataUpdate(); if (gridViewInboundDocs.IsValidRowHandle(gridViewInboundDocs.FocusedRowHandle) && (gridViewInboundDocs.FocusedRowHandle != DevExpress.XtraGrid.GridControl.AutoFilterRowHandle)) { dr = gridViewInboundDocs.GetDataRow(gridViewInboundDocs.FocusedRowHandle); if (dr != null) { focusedInbDocBeforeUpdates = CollectionHelper.CreateObjectFromDataRow<InboundDocsView>(dr); } } this.gridViewInboundDocs.FocusedRowChanged -= this.gridViewInboundDocs_FocusedRowChanged; }
private void ValidateInboundDocument(InboundDocsView inbDoc) { ImagesDto byDocId = imagesDal.GetByDocId(inbDoc.Id, ImagesDtoType.Inbound); if (byDocId == null || byDocId.OriginalImage == null || byDocId.MarkupImage == null) { throw new Exception(string.Format( "Cannot Find selected Inbound Document for Id: {0}, FileName: {1}", inbDoc.Id, inbDoc.FileName) + Environment.NewLine + "Error CNF-511 in " + FORM_NAME + ".ValidateInboundDocument()."); } }
private void ValidateAssociation(InboundDocsView inbDoc) { var currentSelected = ImagesEventManager.Instance.CurrentSelected; if (currentSelected == null) { throw new Exception("No document is currently selected." + Environment.NewLine + "Error CNF-538 in " + FORM_NAME + ".ValidateAssociation()."); } if (currentSelected.Type != ImagesDtoType.Inbound && currentSelected.DocsId != inbDoc.Id) { throw new Exception("The display document does not match current document selected. Please reload selected document." + Environment.NewLine + "Error CNF-539 in " + FORM_NAME + ".ValidateAssociation()."); } if (gridViewInboundDocs.GetSelectedRows().Length > 1) { throw new Exception("Cannot perform this operation on multiple documents." + Environment.NewLine + "Error CNF-540 in " + FORM_NAME + ".ValidateAssociation()."); } if ((!gridViewInboundDocs.IsValidRowHandle(gridViewInboundDocs.FocusedRowHandle)) || inbDoc == null) { throw new Exception("No Inbound Document is currently selected." + Environment.NewLine + "Error CNF-541 in " + FORM_NAME + ".ValidateAssociation()."); } ValidateRqmt(); ValidateInboundDocument(inbDoc); }
private AssociatedDoc CreateAssociatedDoc(InboundDocsView inbDocView, RqmtData activeTradeRqmt, SummaryData activeSummaryData) { var assDoc = new AssociatedDoc(); assDoc.AssociatedBy = p_UserId; assDoc.InboundDocsId = inbDocView.Id; assDoc.MultipleAssociatedDocs = false; assDoc.SecondValidateReqFlag = activeTradeRqmt.SecondCheckFlag ?? "N"; assDoc.TradeId = activeTradeRqmt.TradeId; assDoc.TradeRqmtId = activeTradeRqmt.Id; assDoc.TradeId = activeTradeRqmt.TradeId; //Israel 12/02/2015 -- Changed rqmt code to readable display //assDoc.DocTypeCode = activeTradeRqmt.Rqmt; assDoc.DocTypeCode = activeTradeRqmt.DisplayText; // Trade Summary Data.. assDoc.CptyShortName = activeSummaryData.CptySn; assDoc.BrokerShortName = activeSummaryData.BrokerSn; assDoc.CdtyGroupCode = activeSummaryData.CdtyGrpCode; assDoc.SetDocStatus(); SetDocIndexValue(ref assDoc); assDoc.FileName = inbDocView.FileName; return assDoc; }