private void m_CreatePO_ExecuteCode(object sender, EventArgs e)
        {
            string _spTitle     = default(string);
            string _newFileName = default(string);
            string _stt         = "Starting";

            try
            {
                _stt = "using";
                using (EntitiesDataContext _EDC = new EntitiesDataContext(workflowProperties.SiteUrl))
                {
                    Shipping _sp = (from idx in _EDC.Shipping
                                    where idx.Id == workflowProperties.ItemId
                                    select idx).First();
                    if (!_sp.IsOutbound.Value)
                    {
                        m_AfterCreationLogToHistoryList_HistoryDescription1 = "Document has not been created because it is not outbound shipment";
                        return;
                    }
                    _stt     = "Shipping";
                    _spTitle = _sp.Title;
                    SPDocumentLibrary _lib = (SPDocumentLibrary)workflowProperties.Web.Lists[CommonDefinition.SealProtocolLibraryTitle];
                    _stt = "SPDocumentLibrary";
                    SPFile _teml    = workflowProperties.Web.GetFile(_lib.DocumentTemplateUrl);
                    string _fname   = String.Format("SealProtocolFileName".GetLocalizedString(), _sp.Id.ToString());
                    SPFile _docFile = OpenXMLHelpers.AddDocument2Collection(_teml, _lib.RootFolder.Files, _fname);
                    _newFileName = _docFile.Name;
                    _stt         = "_doc";
                    int          _docId = (int)_docFile.Item.ID;
                    SealProtocol _sprt  = (from idx in _EDC.SealProtocolLibrary
                                           where idx.Id == _docId
                                           select idx).First();
                    Dictionary <TeamMembers, string> _team = GetTeamData(_EDC, _sp);
                    _sprt.SealProtocol1stDriver          = _team[TeamMembers._1stDriver];
                    _sprt.SealProtocol2ndDriver          = _team[TeamMembers._2ndDriver];
                    _sprt.SealProtocol1stEscort          = _team[TeamMembers._1stEscort];
                    _sprt.SealProtocol2ndEscort          = _team[TeamMembers._2ndEscort];
                    _sprt.SealProtocolDispatchDateActual = _sp.StartTime;
                    _sprt.SealProtocolCity                   = _sp.Shipping2City.Title();
                    _sprt.SealProtocolContainersNo           = _sp.ContainerNo.NotAvailable();
                    _sprt.SealProtocolCountry                = _sp.Shipping2City == null ? String.Empty : _sp.Shipping2City.CountryTitle.Title();
                    _sprt.SealProtocolDispatchDate           = _sp.StartTime;
                    _sprt.SealProtocolDriverPhone            = _team[TeamMembers.DriverSPhone];
                    _sprt.SealProtocolEscortCarNo            = _team[TeamMembers.EscortCarNo];
                    _sprt.SealProtocolEscortPhone            = _team[TeamMembers.EscortPhone];
                    _sprt.SealProtocolForwarder              = _sp.PartnerTitle.Title();
                    _sprt.SealProtocolSecurityEscortProvider = _sp.Shipping2PartnerTitle.Title();
                    _sp.SecuritySealProtocolIndex            = _sprt;
                    _sprt.SealProtocolTrailerNo              = _team[TeamMembers.TrailerNo];
                    _sprt.SealProtocolTruckNo                = _team[TeamMembers.TruckNo];
                    _sprt.Title = String.Format("Security Seal & Signature Protocol SSP-3{0, 5}", _sprt.Id);
                    _sprt.SealProtocolWarehouse = _sp.Shipping2WarehouseTitle == null?String.Empty.NotAvailable() : _sp.Shipping2WarehouseTitle.WarehouseAddress.NotAvailable();

                    _stt = "WarehouseAddress ";
                    _EDC.SubmitChanges();
                }
                m_AfterCreationLogToHistoryList_HistoryOutcome1     = "Item Created";
                m_AfterCreationLogToHistoryList_HistoryDescription1 = String.Format("File {0} containing purchase order for shipping {1} successfully created.", _newFileName, _spTitle);
            }
            catch (Exception _ex)
            {
                m_AfterCreationLogToHistoryList_HistoryOutcome1 = "Exception";
                string _frmt = "Creation of the Seal Protocol failed in the \"{0}\" state because of the error {1}";
                m_AfterCreationLogToHistoryList_HistoryDescription1 = string.Format(_frmt, _stt, _ex.Message);
            }
        }
Exemple #2
0
        private void CreatePOItem(object sender, EventArgs e)
        {
            string _spTitle     = default(string);
            string _newFileName = default(string);
            string _stt         = default(string);

            try
            {
                using (EntitiesDataContext _EDC = new EntitiesDataContext(m_WorkflowProperties.SiteUrl))
                {
                    _stt = "using";
                    Shipping _sp = (from idx in _EDC.Shipping
                                    where idx.Id == m_WorkflowProperties.ItemId
                                    select idx).First();
                    if (!_sp.IsOutbound.Value)
                    {
                        m_LogAfterCreateToHistoryList_HistoryDescription1 = "Document has not been created because it is not outbound shipment";
                        return;
                    }
                    _stt     = "Shipping";
                    _spTitle = _sp.Title;
                    SPDocumentLibrary _lib = (SPDocumentLibrary)m_WorkflowProperties.Web.Lists[CommonDefinition.FreightPOLibraryTitle];
                    _stt = "SPDocumentLibrary";
                    SPFile _teml    = m_WorkflowProperties.Web.GetFile(_lib.DocumentTemplateUrl);
                    string _fname   = String.Format("FREIGHTPOFileName".GetLocalizedString(), _sp.Id.ToString());
                    SPFile _docFile = OpenXMLHelpers.AddDocument2Collection(_teml, _lib.RootFolder.Files, _fname);
                    _newFileName = _docFile.Name;
                    _stt         = "_doc";
                    int       _docId = (int)_docFile.Item.ID;
                    FreightPO _fpo   = (from idx in _EDC.FreightPOLibrary
                                        where idx.Id == _docId
                                        select idx).First();
                    _stt = "FreightPO";
                    if (_sp.Shipping2RouteTitle != null)
                    {
                        Route _rt = _sp.Shipping2RouteTitle;
                        _fpo.FreightPOTransportCosts    = _rt.TransportCosts.GetValueOrDefault(0.0);
                        _fpo.FreightPOTransportUnitType = _sp.Shipping2TransportUnitType.Title();
                        _fpo.FreightPOCommodity         = _rt.Route2Commodity.Title();
                        _fpo.FreightPOCurrency          = _rt.CurrencyTitle.Title();
                        _fpo.FPOFreightPO = _rt.GoodsHandlingPO.NotAvailable();
                        _stt = "FreightPO0";
                        if (_rt.FreightPayerTitle != null)
                        {
                            _fpo.FreightPOPayerAddress           = _rt.FreightPayerTitle != null ? _rt.FreightPayerTitle.CompanyAddress : String.Empty.NotAvailable();
                            _fpo.FreightPOPayerNIP               = _rt.FreightPayerTitle.NIP.NotAvailable();
                            _fpo.FreightPOPayerName              = _rt.FreightPayerTitle.PayerName.NotAvailable();
                            _fpo.FreightPOSendInvoiceToMultiline = _rt.FreightPayerTitle.SendInvoiceToMultiline.NotAvailable();
                            _fpo.FreightPOPayerZip               = _rt.FreightPayerTitle.WorkZip.NotAvailable();
                            _fpo.FreightPOPayerCity              = _rt.FreightPayerTitle.WorkCity.NotAvailable();
                        }
                    }
                    _stt = "Route";
                    _fpo.FreightPOForwarder = _sp.PartnerTitle.Title();
                    _fpo.FreightPOCity      = _sp.Shipping2City.Title();
                    _fpo.FreightPOCountry   = _sp.Shipping2City == null?String.Empty.NotAvailable() : _sp.Shipping2City.CountryTitle.Title();

                    _fpo.FPODispatchDate = _sp.EndTime;
                    _fpo.EmailAddress    = _sp.PartnerTitle == null?String.Empty.NotAvailable() : _sp.PartnerTitle.EmailAddress.NotAvailable();

                    _fpo.FPOLoadingDate      = _sp.StartTime;
                    _fpo.Title               = String.Format("FREIGHT PURCHASE ORDER FPO-1{0, 5}", _fpo.Id.Value);
                    _fpo.FPOWarehouseAddress = _sp.Shipping2WarehouseTitle == null?String.Empty.NotAvailable() : _sp.Shipping2WarehouseTitle.WarehouseAddress.NotAvailable();

                    _stt = "WarehouseAddress ";
                    _sp.Shipping2FreightPOIndex = _fpo;
                    _EDC.SubmitChanges();
                };
                _stt = "SubmitChanges";
                m_LogAfterCreateToHistoryList_HistoryOutcome1     = "Item Created";
                m_LogAfterCreateToHistoryList_HistoryDescription1 = String.Format("File {0} containing purchase order for shipping {1} successfully created.", _newFileName, _spTitle);
            }
            catch (Exception _ex)
            {
                m_LogAfterCreateToHistoryList_HistoryOutcome1 = "Exception";
                string _frmt = "Creation of the PO failed in the \"{0}\" state because of the error {1}";
                m_LogAfterCreateToHistoryList_HistoryDescription1 = string.Format(_frmt, _stt, _ex.Message);
            }
        }
Exemple #3
0
        private void m_CreatePOMethod_Run(object sender, EventArgs e)
        {
            string _spTitle     = default(string);
            string _newFileName = default(string);
            string _stt         = "Starting";

            try
            {
                using (EntitiesDataContext _EDC = new EntitiesDataContext(workflowProperties.SiteUrl))
                {
                    _stt = "using";
                    Shipping _sp = (from idx in _EDC.Shipping
                                    where idx.Id == workflowProperties.ItemId
                                    select idx).First();
                    if (!_sp.IsOutbound.Value)
                    {
                        m_AfterCreateLogToHistoryList_HistoryDescription = "Document has not been created because it is not outbound shipment";
                        return;
                    }
                    _stt     = "Shipping";
                    _spTitle = _sp.Title;
                    SPDocumentLibrary _lib = (SPDocumentLibrary)workflowProperties.Web.Lists[CommonDefinition.EscortPOLibraryTitle];
                    _stt = "SPDocumentLibrary";
                    SPFile _teml    = workflowProperties.Web.GetFile(_lib.DocumentTemplateUrl);
                    string _fname   = String.Format("ESCORTPONFileName".GetLocalizedString(), _sp.Id.ToString());
                    SPFile _docFile = OpenXMLHelpers.AddDocument2Collection(_teml, _lib.RootFolder.Files, _fname);
                    _newFileName = _docFile.Name;
                    _stt         = "_doc";
                    int      _docId = (int)_docFile.Item.ID;
                    EscortPO _epo   = (from idx in _EDC.EscortPOLibrary
                                       where idx.Id == _docId
                                       select idx).First();
                    _stt = "EscortPO";
                    if (_sp.Shipping2RouteTitle != null)
                    {
                        _epo.SecurityPOCommodity = _sp.Shipping2RouteTitle.Route2Commodity.Title();
                        if (_sp.Shipping2RouteTitle.FreightPayerTitle != null)
                        {
                            _epo.SecurityPOEscortPayerAddress     = _sp.Shipping2RouteTitle.FreightPayerTitle != null ? _sp.Shipping2RouteTitle.FreightPayerTitle.CompanyAddress : String.Empty.NotAvailable();
                            _epo.SecurityPOEscortPayerCity        = _sp.Shipping2RouteTitle.FreightPayerTitle.WorkCity.NotAvailable();
                            _epo.SecurityPOEscortPayerName        = _sp.Shipping2RouteTitle.FreightPayerTitle.PayerName.NotAvailable();
                            _epo.SecurityPOEscortPayerNIP         = _sp.Shipping2RouteTitle.FreightPayerTitle.NIP.NotAvailable();
                            _epo.SecurityPOEscortPayerZip         = _sp.Shipping2RouteTitle.FreightPayerTitle.WorkZip.NotAvailable();
                            _epo.SecurityPOSentInvoiceToMultiline = _sp.Shipping2RouteTitle.FreightPayerTitle.SendInvoiceToMultiline.NotAvailable();
                        }
                    }
                    _stt = "SendInvoiceTo";
                    if (_sp.Shipping2PartnerTitle != null)
                    {
                        _epo.SecurityPOEscortCurrency = _sp.SecurityEscortCatalogTitle.CurrencyTitle.Title();
                        _epo.SecurityPOEscortCosts    = _sp.SecurityEscortCatalogTitle.SecurityCost;
                        _epo.SPOFreightPO             = _sp.SecurityEscortCatalogTitle.SecurityEscrotPO;
                        _epo.SecurityPOEscortProvider = _sp.Shipping2PartnerTitle.Title();
                    }
                    _stt = "SecurityEscortProvider";
                    _epo.SecurityPOCity    = _sp.Shipping2City.Title();
                    _epo.SecurityPOCountry = _sp.Shipping2City == null?String.Empty.NotAvailable() : _sp.Shipping2City.CountryTitle.Title();

                    _epo.SPODispatchDate = _sp.StartTime;
                    _epo.EmailAddress    = _sp.Shipping2PartnerTitle == null?String.Empty.NotAvailable() : _sp.Shipping2PartnerTitle.EmailAddress.NotAvailable();

                    _epo.Title = String.Format("SECURITY ESCORT PURCHASE ORDER EPO-2{0, 5}", _epo.Id);
                    _epo.FPOWarehouseAddress = _sp.Shipping2WarehouseTitle == null?String.Empty.NotAvailable() : _sp.Shipping2WarehouseTitle.WarehouseAddress.NotAvailable();

                    _stt = "WarehouseAddress";
                    _sp.Shipping2EscortPOIndex = _epo;
                    _EDC.SubmitChanges();
                }
                _stt = "SubmitChanges";
                m_AfterCreateLogToHistoryList_HistoryOutcome     = "Item Created";
                m_AfterCreateLogToHistoryList_HistoryDescription = String.Format("File {0} containing purchase order for shipping {1} successfully created.", _newFileName, _spTitle);
            }
            catch (Exception _ex)
            {
                m_AfterCreateLogToHistoryList_HistoryOutcome = "Exception";
                string _frmt = "Creation of the Escort PO failed in the \"{0}\" state because of the error {1}";
                m_AfterCreateLogToHistoryList_HistoryDescription = string.Format(_frmt, _stt, _ex.Message);
            }
        }