Exemplo n.º 1
0
        /// <summary>
        /// 出货
        /// </summary>
        /// <param name="product">出货的货物</param>
        /// <returns>是否成功</returns>
        public bool Export(ProductStorage product, string comments = "", string userName = "******")
        {
            try
            {
                ExportLog log = new ExportLog(product.m_product, comments, userName);

                bool removed = false;
                foreach (ProductStorage pro in storageList)
                {
                    if (pro == product)
                    {
                        removed = true;
                        storageList.Remove(pro);
                        break;
                    }
                }

                if (!removed)
                {
                    return(false);
                }

                exportLogList.Add(log);
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
        }
 void localMenu_OnItemClicked(string ActionType)
 {
     if (ActionType == "LocalBackup")
     {
         logs             = new ExportLog();
         this.DataContext = logs;
         SaveVouchers();
     }
 }
Exemplo n.º 3
0
 public void AddExportedCsv(ExportedCsv entry)
 {
     ExportLog.Add(entry);
 }
 public void Stop(ExportLog log)
 {
     ProgressSummary += log.SummaryBanner;
 }
Exemplo n.º 5
0
        private void ShowExportedCsv(Guid entryId)
        {
            var entry = ExportLog.Where(l => l.Id == entryId).Single();

            Process.Start(entry.Path);
        }
Exemplo n.º 6
0
        private void DeleteEntry(Guid entryId)
        {
            var entry = ExportLog.Where(l => l.Id == entryId).Single();

            ExportLog.Remove(entry);
        }
Exemplo n.º 7
0
 public ExportLogViewModel(ExportLog log)
 {
     this.log = log;
 }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            ExportLog objExportLog = new ExportLog();
            objExportLog.StartTime = DateTime.Now;
            objExportLog.Success = true;
            objExportLog.Comment = "Export effectuée avec succès.";

            string[] IdFirms = idFirmInstitution.Split(',');
            IList<Guid> lstIdFirms = new List<Guid>();
            foreach(var id in IdFirms)
            {
                Guid idFirm = Guid.Empty;
                Guid.TryParse(id, out idFirm);

                if (idFirm != Guid.Empty)
                {
                    lstIdFirms.Add(idFirm);
                }
            }

            Console.WriteLine("Debut du traitement");

            if (lstIdFirms != null)
            {
                //Liste des derniers recueils ou si pas de recueil, clients nouvellement créés ou updatés           
                lstPPReports = ReportBL.GetReportForExport(lstIdFirms, false);
                lstPMReports = ReportBL.GetReportForExport(lstIdFirms, true);

                // PP 
                string fileNameExportPP = string.Concat("PP_", DateTime.Now.ToString("ddMMyy"), "_", DateTime.Now.ToString("HHmmss"), ".txt");
                string fileNameExportPPEnfant = string.Concat("PP_ENFANTS_", DateTime.Now.ToString("ddMMyy"), "_", DateTime.Now.ToString("HHmmss"), ".txt");
                string fileNameExportPPAutrePersACharge = string.Concat("PP_PERSONNES_", DateTime.Now.ToString("ddMMyy"), "_", DateTime.Now.ToString("HHmmss"), ".txt");
                string fileNameExportImpotEtTaxes = string.Concat("PP_IMPOTS_", DateTime.Now.ToString("ddMMyy"), "_", DateTime.Now.ToString("HHmmss"), ".txt");

                // PM
                string fileNameExportPM = string.Concat("PM_", DateTime.Now.ToString("ddMMyy"), "_", DateTime.Now.ToString("HHmmss"), ".txt");
                string fileNameExportDirigeantPM = string.Concat("PM_INTERLOC_", DateTime.Now.ToString("ddMMyy"), "_", DateTime.Now.ToString("HHmmss"), ".txt");

                try
                {
                    // PP
                    string fullPathPP = string.Empty;
                    string fullPathPPenfants = string.Empty;
                    string fullPathPPAutrePersACharge = string.Empty;
                    string fullPathPPImpotEtTaxes = string.Empty;

                    // PM
                    string fullPathPM = string.Empty;
                    string fullPathPMDirigeant = string.Empty;

                    #region Génération des fichiers PP
                    Console.WriteLine("Export PP...");
                    fullPathPP = GeneratePPCSV(fileNameExportPP);
                    
                    Console.WriteLine("Export enfants PP...");
                    fullPathPPenfants = GenerateCompositionDuFoyerCSV(fileNameExportPPEnfant, 192);
                    
                    Console.WriteLine("Export autres personnes à charge...");
                    fullPathPPAutrePersACharge = GenerateCompositionDuFoyerCSV(fileNameExportPPAutrePersACharge, 193);
                    
                    Console.WriteLine("Export Impot et taxes...");
                    fullPathPPImpotEtTaxes = GenerateImpotsEtTaxesCSV(fileNameExportImpotEtTaxes);
                    #endregion

                    #region Génération des fichiers PM
                    Console.WriteLine("Export PM...");
                    fullPathPM = GeneratePMCSV(fileNameExportPM);

                    Console.WriteLine("Export PM Dirigeant et personnes habilitées...");
                    fullPathPMDirigeant = GenerateDirigeantCSV(fileNameExportDirigeantPM);
                    #endregion

                    #region Envoi FTP PP
                    // SFTP SharpSSH
                    Console.WriteLine("Transfert SFTP PP... \n");
                    SFtp sftpPP = new SFtp(fullPathPP, ftpHote, System.IO.Path.Combine(ftpDirectory, "PP"), fileNameExportPP, ftpUser, ftpPwd); 
                    sftpPP.SFtpUpload();

                    // SFTP SharpSSH
                    Console.WriteLine("Transfert SFTP PP Enfants... \n");
                    SFtp sftpPPEnfant = new SFtp(fullPathPPenfants, ftpHote, System.IO.Path.Combine(ftpDirectory, "PP_ENFANTS"), fileNameExportPPEnfant, ftpUser, ftpPwd);
                    sftpPPEnfant.SFtpUpload();

                    // SFTP SharpSSH
                    Console.WriteLine("Transfert SFTP autres personnes à charge... \n");
                    SFtp sftpPPAutrePersACharge = new SFtp(fullPathPPAutrePersACharge, ftpHote, System.IO.Path.Combine(ftpDirectory, "PP_PERSONNES"), fileNameExportPPAutrePersACharge, ftpUser, ftpPwd);
                    sftpPPAutrePersACharge.SFtpUpload();

                    // SFTP SharpSSH
                    Console.WriteLine("Transfert SFTP PP Impot et taxes... \n");
                    SFtp sftpPPImpotEtTaxe = new SFtp(fullPathPPImpotEtTaxes, ftpHote, System.IO.Path.Combine(ftpDirectory, "PP_IMPOTS"), fileNameExportImpotEtTaxes, ftpUser, ftpPwd);
                    sftpPPImpotEtTaxe.SFtpUpload();
                    #endregion

                    #region Envoi FTP PM
                    // SFTP SharpSSH
                    Console.WriteLine("Transfert SFTP PM... \n");
                    SFtp sftpPM = new SFtp(fullPathPM, ftpHote, System.IO.Path.Combine(ftpDirectory, "PM"), fileNameExportPM, ftpUser, ftpPwd);
                    sftpPM.SFtpUpload();

                    // SFTP SharpSSH
                    Console.WriteLine("Transfert SFTP PM Dirigeant et personnes habilitées... \n");
                    SFtp sftpPMDirigeant = new SFtp(fullPathPMDirigeant, ftpHote, System.IO.Path.Combine(ftpDirectory, "PM_INTERLOC"), fileNameExportDirigeantPM, ftpUser, ftpPwd);
                    sftpPMDirigeant.SFtpUpload();
                    #endregion

                    objExportLog.idFirmInstitution = idFirmInstitution;
                }
                catch (Exception ex)
                {
                    objExportLog.Comment = ex.Message;
                    objExportLog.Success = false;
                    objExportLog.idFirmInstitution = idFirmInstitution;
                    Console.WriteLine("Error: " + ex.Message);

                    Upsilab.Business.Log.Log.AppendException(ex);
                }
            }
            else
            {
                // ecrire dans le log
                objExportLog.Comment = string.Format("Le IdFirmInstitution <{0}> n'est pas correct (le type requis est le type Guid).", idFirmInstitution);
                objExportLog.Success = false;
            }

            objExportLog.EndTime = DateTime.Now;

            try
            {
                Console.WriteLine("Ecriture log...");
                ExportLogBL.InsertExportLog(objExportLog);
                
                //Toujours envoyé un email à l'Admin (Success or failed)
                Console.WriteLine("Envoi email à l'admin...");
                SendMailToAdmin(objExportLog, objExportLog.Success);
            }
            catch(Exception ex)
            {                                                                        
                Console.WriteLine("Erreur envoi mail : {0}. Detail : {1} ", ex.Message, ex.InnerException);
                Upsilab.Business.Log.Log.AppendException(ex);
            }

            Console.WriteLine("Fin du traitement.");

            //Console.ReadLine(); // TODO à enlever sur la version prod (ce code maintient l'écran)
        }
Exemplo n.º 9
0
        private static void SendMailToAdmin(ExportLog exportLog, bool isSuccess)
        {
            string from = "*****@*****.**";
            string to = adminEmail;
            string subject = "[UpsiRecueil] Export Capitis";
            string body = string.Empty;
            if (!isSuccess)
            {
                body = string.Format("L'export Capitis qui a démarré le {0} à {1} a échoué.<br /> Erreur rencontrée : {2}"
                                            , exportLog.StartTime.ToString("dd/MM/yyyy")
                                            , exportLog.StartTime.ToString("HH:mm")
                                            , exportLog.Comment);
            }
            else
            {
                body = string.Format("L'export Capitis qui a démarré le {0} à {1} a été effectuée avec succès le {2} à {3}."
                                                            , exportLog.StartTime.ToString("dd/MM/yyyy")
                                                            , exportLog.StartTime.ToString("HH:mm")
                                                            , exportLog.EndTime.ToString("dd/MM/yyyy")
                                                            , exportLog.EndTime.ToString("HH:mm")
                                                            );                
            }

            Business.Utility.EmailManager.SendEmail(from, to, "*****@*****.**", subject, body);
        }