Exemplo n.º 1
0
        //-------------------------------------------------------------------------------------------
        static void Main(string[] args)
        {
            AppDomain appdomain = AppDomain.CurrentDomain;
               appdomain.UnhandledException += new UnhandledExceptionEventHandler(AppDomain_UnhandledException);

               Environment.ExitCode = 1;

               CommandLineArguments parsedArgs = new CommandLineArguments(args);

               if (parsedArgs["run-cron"] == "true")
               {
                    var type = typeof(ICRON);
                    var types = AppDomain.CurrentDomain.GetAssemblies().ToList()
                        .SelectMany(s => s.GetTypes())
                        .Where(p => type.IsAssignableFrom(p) && p.IsClass);

                    foreach (var interfacedClassType in types)
                    {
                         object o = Activator.CreateInstance(interfacedClassType);
                         var cronInterface = o as ICRON;
                         cronInterface.RunCronTasks(parsedArgs);
                    }

                    Environment.ExitCode = 0;
               }

               if (parsedArgs["ejabberd-extauth"] == "true")
               {
                    Weavver.Vendors.ejabberdAuth ejabberAuth = new Weavver.Vendors.ejabberdAuth();
                    ejabberAuth.Check();

                    Environment.ExitCode = 0;
               }
        }
Exemplo n.º 2
0
        //-------------------------------------------------------------------------------------------
        public void RunCronTasks(CommandLineArguments args)
        {
            Console.WriteLine("Starting to import e-mails..");
               using (WeavverEntityContainer entity = new WeavverEntityContainer())
               {
                    var accounts = from x in entity.Communication_EmailAccounts
                                   select x;

                    accounts.ToList().ForEach(account => ImportEmails(account));
               }
        }
Exemplo n.º 3
0
        public void RunCronTasks(CommandLineArguments args)
        {
            return;
               // We create a ticket if this was a support e-mail

               //CustomerService_Tickets ticket = new CustomerService_Tickets();
               //ticket.AssignedBy = Guid.Empty;
               //ticket.AssignedTo = Guid.Empty;
               //ticket.Email = m.Headers.From.Raw;
               //ticket.Source = "SMTP";
               //ticket.Subject = m.Headers.Subject;
               //ticket.Message = m.MessagePart.GetBodyAsText();
               //ticket.CreatedAt = m.Headers.Received[0].Date;
               //ticket.CreatedBy = Guid.Empty;
               //ticket.UpdatedAt = DateTime.UtcNow;
               //ticket.UpdatedBy = Guid.Empty;
               //if (ticket.Commit())
               //{
               //     client.DeleteMessage(i);
               //}
        }
Exemplo n.º 4
0
        //-------------------------------------------------------------------------------------------
        /// <summary>
        /// </summary>
        public void RunCronTasks(CommandLineArguments args)
        {
            using (WeavverEntityContainer data = new WeavverEntityContainer())
               {
                    DateTime sleepDateTime = DateTime.Now.Subtract(TimeSpan.FromMinutes(60));

                    // only load ofx enabled accounts
                    var ofxBanks = from x in data.Accounting_OFXSettings
                                   where x.Enabled == true && x.LastSuccessfulConnection < sleepDateTime
                                   select x;

                    try
                    {
                         int totalBanksInSystem = ofxBanks.Count();
                         Console.WriteLine("-Processing " + totalBanksInSystem + " OFXSettings objects (database wide count)");
                    }
                    catch (Exception ex)
                    {
                         Console.WriteLine("Exception .." + ex.Message);
                         return;
                    }

                    foreach (Accounting_OFXSettings ofxSetting in data.Accounting_OFXSettings)
                    {
                         Console.WriteLine("--Processing ofxSetting item " + ofxSetting.Id.ToString());
                         //data.Entry(ofxSetting) = System.Data.Entity.EntityState.Detached;

                         // 1. Only import Bill Payment data for checking accounts
                         // We do this before ImportingLedgerItems so we can sync the check numbers
                         var account = ofxSetting.GetAccount();
                         if (account != null)
                         {
                              if (account.LedgerType == LedgerType.Checking.ToString())
                              {
                                   int count = ofxSetting.ImportScheduledPayments();
                                   Console.WriteLine("---Imported " + count.ToString() + " scheduled payments");
                              }

                              // 2. Import any Ledger Items && Match to checks in our database
                              // -- this should be done AFTER Bill Payment data is imported

                               System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage("Weavver Cron <*****@*****.**>", ConfigurationManager.AppSettings["audit_address"]);

                              try
                              {
                                   DynamicDataWebMethodReturnType response = ofxSetting.ImportLedgerItems();

                                   ofxSetting.LastSuccessfulConnection = DateTime.UtcNow;
                                   data.SaveChanges();

                                   Console.WriteLine("---Imported " + response.Message);
                                   message.Subject = "Daily Accounting Import Ledger Items Result";
                                   message.Body = response.Message;
                              }
                              catch (Exception ex)
                              {
                                   Console.WriteLine("---Error " + ex.Message);

                                   message.Subject = "Daily Accounting Import Ledger Items Result - ERROR";
                                   message.Body = "ObjectId: " + ofxSetting.Id.ToString() + "\r\n\r\n" +  ex.ToString();
                              }

                              SmtpClient smtpClient = new SmtpClient(ConfigurationManager.AppSettings["smtp_server"]);
                              smtpClient.Send(message);
                         }
                    }
               }
        }