Exemplo n.º 1
0
        /// <summary>
        /// Gets the outbound quantity.
        /// </summary>
        /// <param name="entities">The entities.</param>
        /// <param name="parent">The parent.</param>
        /// <param name="start">The start.</param>
        /// <param name="end">The end.</param>
        /// <returns></returns>
        public override decimal GetOutboundQuantity(Entities entities, JSOXLib parent, out DateTime start, out DateTime end)
        {
            decimal _ret = 0;

            SummaryContentList = new List <JSOXCustomsSummaryContent>();
            start = LinqIPRExtensions.DateTimeMaxValue;
            end   = LinqIPRExtensions.DateTimeMinValue;
            foreach (Disposal _dspx in Disposal.GetEntries4JSOX(entities, parent))
            {
                start = LinqIPRExtensions.Min(start, _dspx.SADDate.GetValueOrDefault(LinqIPRExtensions.DateTimeMaxValue));
                end   = LinqIPRExtensions.Max(end, _dspx.SADDate.GetValueOrDefault(LinqIPRExtensions.DateTimeMinValue));
                JSOXCustomsSummaryContent _new = new JSOXCustomsSummaryContent()
                {
                    CompensationGood           = _dspx.Disposal2PCNID == null ? "TBD" : _dspx.Disposal2PCNID.CompensationGood,
                    EntryDocumentNo            = _dspx.Disposal2IPRIndex.DocumentNo,
                    ExportOrFreeCirculationSAD = _dspx.SADDocumentNo,
                    InvoiceNo        = _dspx.InvoiceNo,
                    SADDate          = _dspx.SADDate.GetValueOrDefault(),
                    Quantity         = _dspx.SettledQuantityDec,
                    Balance          = _dspx.RemainingQuantity.Round2DecimalOrDefault(),
                    Procedure        = _dspx.CustomsProcedure,
                    SadConsignmentNo = _dspx.SadConsignmentNo
                };
                _ret += _dspx.SettledQuantityDec;
                _dspx.JSOXReportID = parent.Id.Value;
                SummaryContentList.Add(_new);
            }
            return(_ret);
        }
        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);
        }
        private static BalanceSheetContent CreateContent(Entities edc, IEnumerable <BalanceBatchWrapper> batches, JSOXLibFactory factory, string documentName, bool preliminary)
        {
            if (preliminary)
            {
                documentName += " " + "PRELIMINARY".GetLocalizedString();
            }
            JSOXLib list = factory.JSOXList;
            List <BalanceCutfillerContent> _cr  = CreateBalanceCutfillerContent(edc, factory);
            BalanceSheetContent            _ret = new BalanceSheetContent()
            {
                DocumentDate     = DateTime.Today.Date,
                DocumentNo       = documentName,
                EndDate          = list.SituationDate.GetValueOrDefault(),
                BalanceBatch     = GetBalanceBatchContent(batches),
                JSOX             = GetJSOContent(factory),
                SituationAtDate  = list.SituationDate.GetValueOrDefault(),
                StartDate        = list.PreviousMonthDate.GetValueOrDefault(),
                BalanceCutfiller = _cr.ToArray <BalanceCutfillerContent>()
            };

            return(_ret);
        }
        private static JSOContent GetJSOContent(JSOXLibFactory factory)
        {
            JSOXLib    list = factory.JSOXList;
            JSOContent _ret = new JSOContent()
            {
                BalanceDate            = list.BalanceDate.GetValueOrDefault(),
                BalanceQuantity        = list.BalanceQuantity.Round2DecimalOrDefault(),
                JSOXCustomsSummaryList = GetDisposalsList(factory.SummaryContentList),
                IntroducingDateEnd     = list.IntroducingDateEnd.GetValueOrDefault(),
                IntroducingDateStart   = list.IntroducingDateStart.GetValueOrDefault(),
                IntroducingQuantity    = list.IntroducingQuantity.Round2DecimalOrDefault(),
                OutboundDateEnd        = list.OutboundDateEnd.GetValueOrDefault(),
                OutboundDateStart      = list.OutboundDateStart.GetValueOrDefault(),
                OutboundQuantity       = list.OutboundQuantity.Round2DecimalOrDefault(),
                PreviousMonthDate      = list.PreviousMonthDate.GetValueOrDefault(),
                PreviousMonthQuantity  = list.PreviousMonthQuantity.Round2DecimalOrDefault(),
                ReassumeQuantity       = list.ReassumeQuantity.Round2DecimalOrDefault(),
                SituationDate          = list.SituationDate.GetValueOrDefault(),
                SituationQuantity      = list.SituationQuantity.Round2DecimalOrDefault()
            };

            return(_ret);
        }
 /// <summary>
 /// Realize the synchronization operation..
 /// </summary>
 /// <param name="settings">The settings.</param>
 /// <param name="progressChanged">The progress changed.</param>
 public static void Go(SynchronizationSettings settings, ProgressChangedEventHandler progressChanged)
 {
     using (Entities _spedc = new Entities(settings.SiteURL))
     {
         using (IPRDEV _sqledc = IPRDEV.Connect2SQL(settings.ConnectionString, progressChanged))
         {
             _spedc.RowLimit = settings.RowLimit;
             Synchronize(_sqledc.JSOXLibrary, _spedc.JSOXLibrary, progressChanged, JSOXLib.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.BalanceBatch, _spedc.BalanceBatch, progressChanged, Linq.BalanceBatch.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.SADDocumentLibrary, _spedc.SADDocumentLibrary, progressChanged, Linq.SADDocumentLib.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.SADDocument, _spedc.SADDocument, progressChanged, Linq.SADDocumentType.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.SADGood, _spedc.SADGood, progressChanged, Linq.SADGood.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.SADConsignment, _spedc.SADConsignment, progressChanged, Linq.SADConsignment.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.Clearence, _spedc.Clearence, progressChanged, Linq.Clearence.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.Consent, _spedc.Consent, progressChanged, Linq.Consent.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.PCNCode, _spedc.PCNCode, progressChanged, Linq.PCNCode.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.IPRLibrary, _spedc.IPRLibrary, progressChanged, Linq.IPRLib.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.IPR, _spedc.IPR, progressChanged, Linq.IPR.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.BalanceIPR, _spedc.BalanceIPR, progressChanged, Linq.BalanceIPR.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.BatchLibrary, _spedc.BatchLibrary, progressChanged, Linq.BatchLib.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.SPFormat, _spedc.Format, progressChanged, Linq.Format.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.SKULibrary, _spedc.SKULibrary, progressChanged, Linq.Document.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.SKU, _spedc.SKU, progressChanged, Linq.SKUCommonPart.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.Batch, _spedc.Batch, progressChanged, Linq.Batch.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.CustomsUnion, _spedc.CustomsUnion, progressChanged, Linq.CustomsUnion.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.CutfillerCoefficient, _spedc.CutfillerCoefficient, progressChanged, Linq.CutfillerCoefficient.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.InvoiceLibrary, _spedc.InvoiceLibrary, progressChanged, Linq.InvoiceLib.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.InvoiceContent, _spedc.InvoiceContent, progressChanged, Linq.InvoiceContent.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.Material, _spedc.Material, progressChanged, Linq.Material.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.JSOXCustomsSummary, _spedc.JSOXCustomsSummary, progressChanged, Linq.JSOXCustomsSummary.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.Disposal, _spedc.Disposal, progressChanged, Linq.Disposal.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.Dust, _spedc.Dust, progressChanged, Linq.Dust.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.SADDuties, _spedc.SADDuties, progressChanged, Linq.SADDuties.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.SADPackage, _spedc.SADPackage, progressChanged, Linq.SADPackage.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.SADQuantity, _spedc.SADQuantity, progressChanged, Linq.SADQuantity.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.SADRequiredDocuments, _spedc.SADRequiredDocuments, progressChanged, Linq.SADRequiredDocuments.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.Settings, _spedc.Settings, progressChanged, Linq.Settings.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.SHMenthol, _spedc.SHMenthol, progressChanged, Linq.SHMenthol.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.StockLibrary, _spedc.StockLibrary, progressChanged, Linq.StockLib.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.StockEntry, _spedc.StockEntry, progressChanged, Linq.StockEntry.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.Usage, _spedc.Usage, progressChanged, Linq.Usage.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.Warehouse, _spedc.Warehouse, progressChanged, Linq.Warehouse.GetMappings(), settings.Port2Rel210);
             Synchronize(_sqledc.Waste, _spedc.Waste, progressChanged, Linq.Waste.GetMappings(), settings.Port2Rel210);
         }
         using (IPRDEV _sqledc = IPRDEV.Connect2SQL(settings.ConnectionString, progressChanged))
         {
             Synchronize(_sqledc.ActivityLog, _spedc.ActivityLog, progressChanged, Linq.ActivityLogCT.GetMappings(), settings.Port2Rel210);
         }
     }
     if (settings.Port2Rel210)
     {
         Linq.Settings.SaveCurrentContentVersion(settings.SiteURL, progressChanged);
     }
     using (IPRDEV _sqledc = IPRDEV.Connect2SQL(settings.ConnectionString, progressChanged))
         Linq2SQL.ArchivingOperationLogs.UpdateActivitiesLogs(_sqledc, Linq2SQL.ArchivingOperationLogs.OperationName.Synchronization, progressChanged);
     progressChanged(1, new ProgressChangedEventArgs(1, "SynchronizationContent has been finished"));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Gets the outbound quantity.
 /// </summary>
 /// <param name="entities">The entities.</param>
 /// <param name="parent">The parent.</param>
 /// <param name="start">The start date.</param>
 /// <param name="end">The end date.</param>
 /// <returns></returns>
 public abstract decimal GetOutboundQuantity(Entities entities, JSOXLib parent, out DateTime start, out DateTime end);
Exemplo n.º 7
0
 /// <summary>
 /// Updates the JSOX report.
 /// </summary>
 /// <param name="edc">The <see cref="Entities" /> representing data model.</param>
 /// <param name="previous">The previous report.</param>
 /// <param name="batches">The list of <see cref="BalanceBatchWrapper"/>.</param>
 /// <param name="trace">The trace action.</param>
 /// <returns><c>true</c>if the report is consistent, <c>false</c> otherwise.</returns>
 public bool CreateJSOXReport(Entities edc, JSOXLib previous, List <BalanceBatchWrapper> batches, NamedTraceLogger.TraceAction trace)
 {
     trace("Entering JSOXLibFactoryBase.CreateJSOXReport", 40, TraceSeverity.Verbose);
     this.JSOXList.CreateJSOXReport(previous);
     return(UpdateBalanceReport(edc, batches, trace));
 }