private void NewDataEventHandler(object sender, DisposalInterconnectionData e)
 {
     if (string.IsNullOrEmpty(e.ID))
     {
         return;
     }
     EnsureChildControls();
     m_SelectedItemTitle.Text = e.Title;
     using (Entities _entities = new Entities())
     {
         DisposalRequestLib _drl = Element.GetAtIndex <DisposalRequestLib>(_entities.DisposalRequestLibrary, e.ID);
         List <SAD>         _cns = new List <SAD>();
         SPWeb _wb = SPContext.Current.Web;
         foreach (CustomsWarehouseDisposal _cwd in _drl.CustomsWarehouseDisposal(_entities, false))
         {
             if (_cwd.CWL_CWDisposal2ClearanceID == null)
             {
                 continue;
             }
             if (_cwd.CWL_CWDisposal2ClearanceID.SADConsignmentLibraryIndex == null)
             {
                 continue;
             }
             SPDocumentLibrary _lib = (SPDocumentLibrary)_wb.Lists[SADConsignment.IPRSADConsignmentLibraryTitle];
             SAD _sad = CAS.SharePoint.DocumentsFactory.File.ReadXmlFile <SAD>(_lib, _cwd.CWL_CWDisposal2ClearanceID.SADConsignmentLibraryIndex.Id.Value);
             _cns.Add(_sad);
         }
         SADCollection _sc = new SADCollection()
         {
             ListOfSAD = _cns.ToArray()
         };
         m_HiddenFieldData.Value = System.Web.HttpUtility.HtmlEncode(CAS.SharePoint.Serialization.XmlSerializer.Serialize <SADCollection>(_sc, Settings.SADCollectionStylesheetName));
     }
 }
Ejemplo n.º 2
0
        private StatementContent CraeteStatement(Entities entities, DisposalRequestLib disposalRequestLib, string _MasterDocumentName)
        {
            List <Statement> _SADDocuments = new List <Statement>();

            foreach (CustomsWarehouseDisposal _cwdx in disposalRequestLib.CustomsWarehouseDisposal(entities, false))
            {
                if (_cwdx.SADDocumentNo.IsNullOrEmpty())
                {
                    throw new ArgumentNullException("SADDocumentNo", "SAD Document No cannot be empty");
                }
                Statement _newItem = new Statement
                {
                    DutyAndVAT           = _cwdx.DutyAndVAT.GetValueOrDefault(),
                    DutyPerSettledAmount = _cwdx.DutyPerSettledAmount.Value,
                    No                  = -1,
                    SADDocumentNo       = _cwdx.SADDocumentNo,
                    ReferenceNumber     = _cwdx.CWL_CWDisposal2ClearanceID.ReferenceNumber,
                    VATPerSettledAmount = _cwdx.VATPerSettledAmount.Value,
                };
                _SADDocuments.Add(_newItem);
            }
            _SADDocuments.Sort((Statement x, Statement y) => { return(x.SADDocumentNo.CompareTo(y.SADDocumentNo)); });
            for (int i = 0; i < _SADDocuments.Count; i++)
            {
                _SADDocuments[i].No = i + 1;
            }
            StatementContent _NewSC = new StatementContent()
            {
                DocumentDate      = DateTime.Today,
                CustomsProcedure  = disposalRequestLib.ClearenceProcedure.Value.Convert2String(),
                StatementOfDuties = _SADDocuments.ToArray()
            };

            return(_NewSC);
        }
Ejemplo n.º 3
0
 private void onCreateMessageTemplates(object sender, EventArgs e)
 {
     TraceEvent("Entering ClearThroughCustoms.onCreateMessageTemplates", 46, TraceSeverity.Monitorable);
     try
     {
         string _MasterDocumentName = String.Empty;
         using (Entities _entities = new Entities(workflowProperties.WebUrl))
         {
             DisposalRequestLib _Dr = Element.GetAtIndex <DisposalRequestLib>(_entities.DisposalRequestLibrary, workflowProperties.ItemId);
             foreach (CustomsWarehouseDisposal _cwdx in _Dr.CustomsWarehouseDisposal(_entities, false))
             {
                 if (_cwdx.CustomsStatus.Value != CustomsStatus.NotStarted)
                 {
                     continue;
                 }
                 Clearence _newClearance = Clearence.CreataClearence(_entities, "Customs Warehouse Withdraw", _Dr.ClearenceProcedure.Value, TraceEvent);
                 _cwdx.CWL_CWDisposal2ClearanceID = _newClearance;
                 _cwdx.CustomsStatus = CustomsStatus.Started;
                 if (_cwdx.CWL_CWDisposal2CustomsWarehouseID.TobaccoNotAllocated.Value > 0 ||
                     _cwdx.CWL_CWDisposal2CustomsWarehouseID.CustomsWarehouseDisposal(_entities, false).Where <CustomsWarehouseDisposal>(x => x.CustomsStatus.Value == CustomsStatus.NotStarted).Any <CustomsWarehouseDisposal>())
                 {
                     _cwdx.ClearingType = ClearingType.PartialWindingUp;
                 }
                 else
                 {
                     _cwdx.ClearingType         = ClearingType.TotalWindingUp;
                     _cwdx.TobaccoValue        += _cwdx.CWL_CWDisposal2CustomsWarehouseID.Value.Value - _cwdx.CWL_CWDisposal2CustomsWarehouseID.CustomsWarehouseDisposal(_entities, false).Sum <CustomsWarehouseDisposal>(x => x.TobaccoValue.Value);
                     _cwdx.TobaccoValue         = _cwdx.TobaccoValue.Value.RoundValue();
                     _cwdx.CW_SettledNetMass   += _cwdx.CWL_CWDisposal2CustomsWarehouseID.CW_Quantity.Value - _cwdx.CWL_CWDisposal2CustomsWarehouseID.CustomsWarehouseDisposal(_entities, false).Sum <CustomsWarehouseDisposal>(x => x.CW_SettledNetMass.Value);
                     _cwdx.CW_SettledNetMass    = _cwdx.CW_SettledNetMass.Value.RoundValue();
                     _cwdx.CW_SettledGrossMass += _cwdx.CWL_CWDisposal2CustomsWarehouseID.GrossMass.Value - _cwdx.CWL_CWDisposal2CustomsWarehouseID.CustomsWarehouseDisposal(_entities, false).Sum <CustomsWarehouseDisposal>(x => x.CW_SettledGrossMass.Value);
                     _cwdx.CW_SettledGrossMass  = _cwdx.CW_SettledGrossMass.Value.RoundValue();
                 }
                 _MasterDocumentName = _newClearance.SADTemplateDocumentNameFileName(_entities);
                 SAD _sad = CraeteSAD(_entities, _cwdx, _MasterDocumentName);
                 TraceEvent(" ClearThroughCustoms.onCreateMessageTemplates at File.CreateXmlFile", 4756, TraceSeverity.Monitorable);
                 SPFile         _newFile        = File.CreateXmlFile <SAD>(workflowProperties.Web, _sad, _MasterDocumentName, SADConsignment.IPRSADConsignmentLibraryTitle, SAD.StylesheetNmane);
                 SADConsignment _sadConsignment = Element.GetAtIndex <SADConsignment>(_entities.SADConsignment, _newFile.Item.ID);
                 _sadConsignment.Archival = true;
                 _newClearance.SADConsignmentLibraryIndex = _sadConsignment;
                 TraceEvent(" ClearThroughCustoms.onCreateMessageTemplates at SubmitChanges", 80, TraceSeverity.Monitorable);
                 _entities.SubmitChanges();
             }
         }
         logToHistoryListActivity_HistoryOutcome     = "Success";
         logToHistoryListActivity_HistoryDescription = String.Format("Document {0} created successfully", _MasterDocumentName);
     }
     catch (Exception _ex)
     {
         logToHistoryListActivity_HistoryOutcome     = "Exception";
         logToHistoryListActivity_HistoryDescription = _ex.Message;
         TraceEvent(String.Format("Exception {0} at ClearThroughCustoms.onCreateMessageTemplates: {1}; StackTrace: {2}", _ex.GetType().Name, _ex.Message, _ex.StackTrace), 46, TraceSeverity.High);
     }
     TraceEvent("Finishing ClearThroughCustoms.onCreateMessageTemplates", 98, TraceSeverity.Monitorable);
 }