diff --git a/Backend/Backend.csproj b/Backend/Backend.csproj index 79098f80..819839dc 100644 --- a/Backend/Backend.csproj +++ b/Backend/Backend.csproj @@ -77,7 +77,7 @@ - + diff --git a/Backend/Program.cs b/Backend/BackendLoop.cs similarity index 96% rename from Backend/Program.cs rename to Backend/BackendLoop.cs index e29bb1ab..a955156b 100644 --- a/Backend/Program.cs +++ b/Backend/BackendLoop.cs @@ -1,795 +1,795 @@ -using System; -using System.Diagnostics; -using System.Globalization; -using System.Threading; -using Mono.Unix; -using Mono.Unix.Native; -using Swarmops.Database; -using Swarmops.Logic.Communications; -using Swarmops.Logic.Communications.Payload; -using Swarmops.Logic.Communications.Resolution; -using Swarmops.Logic.Financial; -using Swarmops.Logic.Structure; -using Swarmops.Logic.Support; -using Swarmops.Utility; -using Swarmops.Utility.BotCode; -using Swarmops.Utility.Communications; -using Swarmops.Utility.Mail; - -namespace Swarmops.Backend -{ - internal class Program - { - private const string heartbeatFile = "/var/run/swarmops/backend/heartbeat.txt"; - private static bool testMode; - - private static void Main (string[] args) - { - // Checking for schemata upgrade first of all - - DatabaseMaintenance.UpgradeSchemata(); - - testMode = false; - - UnixSignal[] killSignals = null; - - if (!Debugger.IsAttached) - { - killSignals = new UnixSignal[] {new UnixSignal (Signum.SIGINT), new UnixSignal (Signum.SIGTERM)}; - } - - BotLog.Write (0, "MainCycle", string.Empty); - BotLog.Write (0, "MainCycle", "-----------------------------------------------"); - BotLog.Write (0, "MainCycle", string.Empty); - - if (args.Length > 0) - { - if (args[0].ToLower() == "test") - { -/* - BotLog.Write(0, "MainCycle", "Running self-tests"); - HeartBeater.Instance.Beat(heartbeatFile); // Otherwise Heartbeater.Beat() will fail in various places - - testMode = true; - Console.WriteLine("Testing All Maintenance Processes (except membership-changing ones)."); - PWLog.Write(PWLogItem.None, 0, PWLogAction.SystemTest, string.Empty, string.Empty); - - Console.WriteLine("\r\n10-second intervals:"); - OnEveryTenSeconds(); - Console.WriteLine("\r\nEvery minute:"); - OnEveryMinute(); - Console.WriteLine("\r\nEvery five minutes:"); - OnEveryFiveMinutes(); - Console.WriteLine("\r\nEvery hour:"); - OnEveryHour(); - Console.WriteLine("\r\nNoon:"); - OnNoon(); - Console.WriteLine("\r\nMidnight:"); - OnMidnight(); - */ - - Console.WriteLine ("Testing database access..."); - - Console.WriteLine (SwarmDb.GetDatabaseForReading().GetPerson (1).Name); - Console.WriteLine (SwarmDb.GetDatabaseForReading().GetPerson (1).PasswordHash); - - Console.WriteLine ("Creating OutboundComm..."); - - OutboundComm.CreateNotification (null, NotificationResource.System_Startup); - - Console.WriteLine ("Transmitting..."); - - OutboundComms comms = OutboundComms.GetOpen(); - - Console.WriteLine ("{0} open items in outbound comms.", comms.Count); - - foreach (OutboundComm comm in comms) - { - if (comm.TransmitterClass != "Swarmops.Utility.Communications.CommsTransmitterMail") - { - throw new NotImplementedException(); - } - - ICommsTransmitter transmitter = new CommsTransmitterMail(); - - OutboundCommRecipients recipients = comm.Recipients; - PayloadEnvelope envelope = PayloadEnvelope.FromXml (comm.PayloadXml); - - foreach (OutboundCommRecipient recipient in recipients) - { - transmitter.Transmit (envelope, recipient.Person); - } - } - - - Console.Write ("\r\nAll tests run. Waiting for mail queue to flush... "); - while (!MailTransmitter.CanExit) - { - Thread.Sleep (50); - } - - Console.WriteLine ("done."); - BotLog.Write (0, "MainCycle", "Exiting self-tests"); - return; - } - - if (args[0].ToLower() == "console") - { - Console.WriteLine ("\r\nRunning Swarmops-Backend in CONSOLE mode.\r\n"); - - // ------------------------------------------------------------------------------------- - // ------------------------------------------------------------------------------------- - // ------------------------------------------------------------------------------------- - - // ----------------------- INSERT ANY ONE-OFF ACTIONS HERE ------------------------- - - - Console.Write ("\r\nWaiting for mail queue to flush... "); - - while (!MailTransmitter.CanExit) - { - Thread.Sleep (50); - } - - Console.WriteLine ("done."); - - return; - } - - if (args[0].ToLower() == "rsm") - { - Console.WriteLine ("Testing character encoding: räksmörgås RÄKSMÖRGÅS"); - return; - } - } - - /* - MailMessage message = new MailMessage(); - message.From = new MailAddress(Strings.MailSenderAddress, Strings.MailSenderName); - message.To.Add (new MailAddress ("rick@piratpartiet.se", "Rick Falkvinge (Piratpartiet)")); - message.Subject = "Räksmörgåsarnas ékÖNÖMÏåvdëlnïng"; - message.Body = "Hejsan hoppsan Räksmörgåsar."; - message.BodyEncoding = Encoding.Default; - message.SubjectEncoding = Encoding.Default; - - SmtpClient smtpClient = new SmtpClient ("localhost"); - smtpClient.Credentials = null; // mono bug - smtpClient.Send (message);*/ - - Console.WriteLine (" * Swarmops Backend starting"); - - BotLog.Write(0, "MainCycle", "Backend STARTING"); - - // Disable certificate checking due to Mono not installing with a certificate repository - this is UTTERLY broken - - SupportFunctions.DisableSslCertificateChecks(); // MONO BUG/MISFEATURE: Mono has no root certificates, so can't verify cert - - // Tell sysop we're starting - - OutboundComm.CreateNotification (null, NotificationResource.System_Startup); - - // Check for existence of installation ID. If not, create one. Warning: has privacy implications when communicated. - - if (Persistence.Key["SwarmopsInstallationId"] == string.Empty) - { - Persistence.Key["SwarmopsInstallationId"] = Guid.NewGuid().ToString(); - } - - // Check for existence of bitcoin hotwallet root - - BitcoinUtility.VerifyBitcoinHotWallet(); - - // Begin maintenance loop - - DateTime cycleStartTime = DateTime.UtcNow; - DateTime cycleEndTime; - - int lastSecond = cycleStartTime.Second; - int lastMinute = cycleStartTime.Minute; - int lastHour = cycleStartTime.Hour; - - bool exitFlag = false; - - while (!exitFlag) // exit is handled by signals handling at end of loop - { - BotLog.Write (0, "MainCycle", "Cycle Start"); - - cycleStartTime = DateTime.UtcNow; - cycleEndTime = cycleStartTime.AddSeconds(10); - - try - { - OnEveryTenSeconds(); - - if (cycleStartTime.Second < lastSecond) - { - OnEveryMinute(); - - if (cycleStartTime.Minute%5 == 0) - { - OnEveryFiveMinutes(); - } - } - - if (cycleStartTime.Minute < lastMinute) - { - OnEveryHour(); - - if (DateTime.Now.Hour == 10 && DateTime.Today.DayOfWeek == DayOfWeek.Tuesday) - { - OnTuesdayMorning(); - } - - if (DateTime.Now.Hour == 7 && DateTime.Today.DayOfWeek == DayOfWeek.Monday) - { - OnMondayMorning(); - } - } - - if (cycleStartTime.Hour >= 12 && lastHour < 12) - { - OnNoon(); - } - - if (cycleStartTime.Hour < lastHour) - { - OnMidnight(); - } - } - - catch (Exception e) - { - // Note each "OnEvery..." catches its own errors and sends Exception mails, - // so that failure in one should not stop the others from running. This particular - // code should never run. - - ExceptionMail.Send (new Exception ("Failed in swarmops-backend main loop", e), true); - } - - lastSecond = cycleStartTime.Second; - lastMinute = cycleStartTime.Minute; - lastHour = cycleStartTime.Hour; - - // Wait for a maximum of ten seconds (the difference between cycleStartTime and cycleEndTime) - - DateTime utcNow = DateTime.UtcNow; - while (utcNow < cycleEndTime && !exitFlag) - { - int signalIndex = 250; - - // Block until a SIGINT or SIGTERM signal is generated, or 1/4 second has passed. - // However, we can't do that in a development environment - it won't have the - // Mono.Posix assembly, and won't understand UnixSignals. So people running this in - // a dev environment will need to stop it manually. - - if (!Debugger.IsAttached) - { - signalIndex = UnixSignal.WaitAny(killSignals, 250); - } - else - { - TimeSpan timeLeft = (cycleEndTime - utcNow); - - BotLog.Write(0, "MainCycle Debug", - string.Format(CultureInfo.InvariantCulture, "Waiting for {0:F2} more seconds for cycle end", - timeLeft.TotalMilliseconds / 1000.0)); - Thread.Sleep(250); - } - - if (signalIndex < 250) - { - exitFlag = true; - Console.WriteLine ("Caught signal " + killSignals[signalIndex].Signum + ", exiting"); - BotLog.Write (0, "MainCycle", - "EXIT SIGNAL (" + killSignals[signalIndex].Signum + "), terminating backend"); - } - - utcNow = DateTime.UtcNow; - } - } - - Console.WriteLine (" * Swarmops Backend stopping"); - BotLog.Write (0, "MainCycle", "BACKEND EXITING, sending backend-termination notices"); - - /* - if (HeartBeater.Instance.WasKilled) - { - // removed unconditional delete, cron job that restarts bot uses it to know that it is intentionally down. - ExceptionMail.Send(new Exception("HeartBeater triggered restart of Swarmops Backend. Will commence after 800 seconds."), false); - }*/ - - BotLog.Write (0, "MainCycle", "...done"); - - /* - while (!MailTransmitter.CanExit) - { - System.Threading.Thread.Sleep(50); - }*/ - - Thread.Sleep (2000); - } - - private static void OnEveryTenSeconds() - { - try - { - BotLog.Write (0, "MainCycle", "Ten-second entry"); - - CommsTransmitter.Run(); - - try - { - /*TestTrace("Running EventProcessor.Run()..."); - EventProcessor.Run(); - TestTrace(" done.\r\n");*/ - } - catch (Exception e) - { - TraceAndReport (e); - } - - try - { - /*TestTrace("Running MailResolver.Run()..."); - MailResolver.Run(); - TestTrace(" done.\r\n");*/ - } - catch (Exception e) - { - TraceAndReport (e); - } - - try - { - /*TestTrace("Running MailProcessor.Run()..."); - MailProcessor.Run(); - TestTrace(" done.\r\n");*/ - } - catch (Exception e) - { - TraceAndReport (e); - } - - BotLog.Write (0, "MainCycle", "Ten-second exit"); - } - catch (Exception e) - { - ExceptionMail.Send (e, true); - } - } - - private static void OnEveryMinute() - { - try - { - BotLog.Write (0, "MainCycle", "One-minute process (empty)"); - } - catch (Exception e) - { - TraceAndReport (e); - } - // empty - } - - - private static void OnEveryFiveMinutes() - { - try - { - BotLog.Write (0, "MainCycle", "Five-minute entry"); - - try - { - BotLog.Write(1, "FiveMinute", "Starting automated payout processing"); - Payouts.PerformAutomated(); - } - catch (Exception e) - { - TraceAndReport (e); - } - - try - { - /*BotLog.Write(1, "FiveMinute", "Starting newsletter checker"); - TestTrace("Running NewsletterChecker.Run()..."); - NewsletterChecker.Run(); - TestTrace(" done.\r\n");*/ - } - catch (Exception e) - { - TraceAndReport (e); - } - - try - { - /*BotLog.Write(1, "FiveMinute", "Starting turnaround tracker"); - TestTrace("Running TurnaroundTracker.Run()..."); - TurnaroundTracker.Run(); - TestTrace(" done.\r\n");*/ - } - catch (Exception e) - { - TraceAndReport (e); - } - - try - { - // TestTrace(" done.\r\nRunning UpdateStatsCache.Run()..."); - // UpdateStatsCache.Run(); - /*TestTrace(" done.\r\nRunning TranslateUrls()..."); - TranslateUrls();*/ - - // Added during election rush 2010: clean up support database every five minutes instead of once a day - // SMS notifications for bounces are turned off, so people don't get SMS notifications in the middle of the night - } - catch (Exception e) - { - TraceAndReport (e); - } - - try - { - /*BotLog.Write(1, "FiveMinute", "Closing delay warnings"); - TestTrace("Running SupportDatabase.CloseDelayWarnings()..."); - SupportDatabase.CloseDelayWarnings(); - TestTrace(" done.\r\n");*/ - } - catch (Exception e) - { - TraceAndReport (e); - } - - try - { - /*TestTrace("Running SupportDatabase.NotifyBouncingEmails()..."); - BotLog.Write(1, "FiveMinute", "Notifying bouncing emails"); - SupportDatabase.NotifyBouncingEmails(); - TestTrace(" done.\r\n");*/ - } - catch (Exception e) - { - TraceAndReport (e); - } - - try - { - /*TestTrace("Running SupportMailReview.Run()..."); - BotLog.Write(1, "FiveMinute", "Running support mail review"); - SupportMailReview.Run(); - TestTrace(" done.\r\n");*/ - } - catch (Exception e) - { - TraceAndReport (e); - } - - - BotLog.Write (0, "MainCycle", "Five-minute exit"); - } - catch (Exception e) - { - ExceptionMail.Send (e, true); - TestTrace (e.ToString()); - } - } - - - private static void OnEveryHour() - { - try - { - BotLog.Write (0, "MainCycle", "One-hour entry"); - - try - { - // This will upgrade the database schema if and only if we failed to do so on entry. - - if (SwarmDb.DbVersion < SwarmDb.DbVersionExpected) - { - BotLog.Write (1, "OneHour", "Entering DbUpgrade"); - DatabaseMaintenance.UpgradeSchemata(); - BotLog.Write (1, "OneHour", "Exited DbUpgrade"); - } - } - catch (Exception e) - { - TraceAndReport (e); - } - - - try - { - BotLog.Write(1, "OneHour", "Entering Automatch"); - Organizations organizations = Organizations.GetAll(); - foreach (Organization organization in organizations) - { - if (organization.IsEconomyEnabled) - { - BotLog.Write(1, "OneHour", "Automatching org #" + organization.Identity.ToString(CultureInfo.InvariantCulture)); - Payouts.AutomatchAgainstUnbalancedTransactions(organization); - } - } - BotLog.Write(1, "OneHour", "Exited Automatch"); - - /*TestTrace("Running PaymentGroupMapper.Run()..."); - PaymentGroupMapper.Run(); - TestTrace(" done.\r\n");*/ - } - catch (Exception e) - { - TraceAndReport (e); - } - - try - { - /*TestTrace("Running BlogTop50Scraper.Run()..."); - BlogTop50Scraper.Run(); - TestTrace(" done.\r\n");*/ - } - catch (Exception e) - { - TraceAndReport (e); - } - - try - { - /*TestTrace("Running Mappery.CreatePiratpartietOrganizationStrengthCircuitMap()..."); - Mappery.CreatePiratpartietOrganizationStrengthCircuitMap(); - TestTrace(" done.\r\n");*/ - } - catch (Exception e) - { - TraceAndReport (e); - } - - try - { - /*TestTrace("Running Mappery.CreatePiratpartietOrganizationStrengthCityMap()..."); - Mappery.CreatePiratpartietOrganizationStrengthCityMap(); - TestTrace(" done.\r\n");*/ - } - catch (Exception e) - { - TraceAndReport (e); - } - - BotLog.Write (0, "MainCycle", "One-hour exit"); - } - catch (Exception e) - { - TraceAndReport (e); - } - } - - private static void OnMidnight() - { - try - { - BotLog.Write (0, "MainCycle", "Midnight entry"); - - try - { - if (!testMode) - { - /*TestTrace("Running RosterHousekeeping.ChurnExpiredMembers()..."); - RosterHousekeeping.ChurnExpiredMembers(); - TestTrace(" done.\r\n");*/ - } - - ExchangeRateSnapshot.Create(); - } - catch (Exception e) - { - TraceAndReport (e); - } - - try - { - BotLog.DeleteOld (14); // delete logs older than 14 days - } - catch (Exception e) - { - TraceAndReport (e); - } - - try - { - /*TestTrace("Running SwedishForumMemberCheck.Run()..."); - SwedishForumMemberCheck.Run(); - TestTrace(" done.\r\n");*/ - } - catch (Exception e) - { - TraceAndReport (e); - } - - try - { - /*TestTrace("Running SalaryProcessor.Run()..."); - SalaryProcessor.Run(); - TestTrace(" done.\r\n");*/ - } - catch (Exception e) - { - TraceAndReport (e); - } - - try - { - /*TestTrace("Running TurnaroundTracker.Housekeeping()..."); - TurnaroundTracker.Housekeeping(); - TestTrace(" done.\r\n");*/ - } - catch (Exception e) - { - TraceAndReport (e); - } - - try - { - /*TestTrace("Running Mappery.CreateUngPiratUptakeMap()..."); - Mappery.CreateUngPiratUptakeMap(); - TestTrace(" done.\r\n");*/ - } - catch (Exception e) - { - TraceAndReport (e); - } - - try - { - /*TestTrace("Running RosterHousekeeping.TimeoutVolunteers()..."); - RosterHousekeeping.TimeoutVolunteers(); - TestTrace(" done.\r\n");*/ - } - catch (Exception e) - { - TraceAndReport (e); - } - - BotLog.Write (0, "MainCycle", "Midnight exit"); - } - catch (Exception e) - { - ExceptionMail.Send (e, true); - TestTrace (e.ToString()); - } - } - - private static void OnNoon() - { - BotLog.Write (0, "MainCycle", "Noon entry"); - - try - { - if (!PilotInstallationIds.IsPilot (PilotInstallationIds.PiratePartySE)) - { - // PPSE is still running PW4 code for this, so don't run for PPSE - - Payroll.ProcessMonthly(); // will only actually run on the 1st, but no harm in testing every noon - } - - // Check all bitcoin accounts for previously-unseen transactions once a day - - Organizations allOrganizations = Organizations.GetAll(); - foreach (Organization organization in allOrganizations) - { - // this actually checks hot storage too, but that's supposed - // to be up to date since we're the ones handling it - BitcoinUtility.CheckColdStorageForOrganization (organization); - } - - if (!testMode) - { - /*TestTrace("Running RosterHousekeeping.RemindAllExpiries()..."); - RosterHousekeeping.RemindAllExpiries(); - TestTrace(" done.\r\n");*/ - } - } - catch (Exception e) - { - TraceAndReport (e); - } - - try - { - if (!testMode) - { - /*TestTrace("Running SupportDatabase.NotifyBouncingEmails()..."); - SupportDatabase.NotifyBouncingEmails(); - TestTrace(" done.\r\n");*/ - } - } - catch (Exception e) - { - TraceAndReport (e); - } - - try - { - /*TestTrace("Running SupportDatabase.CloseDelayWarnings()..."); - SupportDatabase.CloseDelayWarnings(); - TestTrace(" done.\r\n");*/ - } - catch (Exception e) - { - TraceAndReport (e); - } - - try - { - /*TestTrace("Running SupportMailReview.Run()..."); - SupportMailReview.Run(); - TestTrace(" done.\r\n");*/ - } - catch (Exception e) - { - TraceAndReport (e); - } - - - BotLog.Write (0, "MainCycle", "Noon exit"); - } - - private static void OnMondayMorning() - { - try - { - // Detect and log any forex difference exceeding 100 cents. - - FinancialAccounts allAccounts = FinancialAccounts.GetAll(); // across ALL ORGS! - - foreach (FinancialAccount account in allAccounts) - { - // For every account, if it's based on foreign currency, check for forex gains/losses - - if (account.ForeignCurrency != null) - { - account.CheckForexProfitLoss(); - } - } - } - catch (Exception e) - { - ExceptionMail.Send(e, true); - if (testMode) - { - Console.WriteLine(e.ToString()); - } - } - } - - private static void OnTuesdayMorning() - { - try - { - //TestTrace("Running ActivityMailer.Run()..."); - // PirateWeb.Utility.BotCode.ActivityMailer.Run(); - //TestTrace(" done.\r\n"); - } - catch (Exception e) - { - ExceptionMail.Send (e, true); - if (testMode) - { - Console.WriteLine (e.ToString()); - } - } - } - - private static void TraceAndReport (Exception e) - { - TestTrace (" failed.\r\n"); - ExceptionMail.Send (e, true); - TestTrace (e.ToString()); - } - - private static void TestTrace (string message) - { - if (testMode) - { - Console.Write (message); - } - } - } +using System; +using System.Diagnostics; +using System.Globalization; +using System.Threading; +using Mono.Unix; +using Mono.Unix.Native; +using Swarmops.Database; +using Swarmops.Logic.Communications; +using Swarmops.Logic.Communications.Payload; +using Swarmops.Logic.Communications.Resolution; +using Swarmops.Logic.Financial; +using Swarmops.Logic.Structure; +using Swarmops.Logic.Support; +using Swarmops.Utility; +using Swarmops.Utility.BotCode; +using Swarmops.Utility.Communications; +using Swarmops.Utility.Mail; + +namespace Swarmops.Backend +{ + internal class BackendLoop + { + private const string heartbeatFile = "/var/run/swarmops/backend/heartbeat.txt"; + private static bool testMode; + + private static void Main (string[] args) + { + // Checking for schemata upgrade first of all + + DatabaseMaintenance.UpgradeSchemata(); + + testMode = false; + + UnixSignal[] killSignals = null; + + if (!Debugger.IsAttached) + { + killSignals = new UnixSignal[] {new UnixSignal (Signum.SIGINT), new UnixSignal (Signum.SIGTERM)}; + } + + BotLog.Write (0, "MainCycle", string.Empty); + BotLog.Write (0, "MainCycle", "-----------------------------------------------"); + BotLog.Write (0, "MainCycle", string.Empty); + + if (args.Length > 0) + { + if (args[0].ToLower() == "test") + { +/* + BotLog.Write(0, "MainCycle", "Running self-tests"); + HeartBeater.Instance.Beat(heartbeatFile); // Otherwise Heartbeater.Beat() will fail in various places + + testMode = true; + Console.WriteLine("Testing All Maintenance Processes (except membership-changing ones)."); + PWLog.Write(PWLogItem.None, 0, PWLogAction.SystemTest, string.Empty, string.Empty); + + Console.WriteLine("\r\n10-second intervals:"); + OnEveryTenSeconds(); + Console.WriteLine("\r\nEvery minute:"); + OnEveryMinute(); + Console.WriteLine("\r\nEvery five minutes:"); + OnEveryFiveMinutes(); + Console.WriteLine("\r\nEvery hour:"); + OnEveryHour(); + Console.WriteLine("\r\nNoon:"); + OnNoon(); + Console.WriteLine("\r\nMidnight:"); + OnMidnight(); + */ + + Console.WriteLine ("Testing database access..."); + + Console.WriteLine (SwarmDb.GetDatabaseForReading().GetPerson (1).Name); + Console.WriteLine (SwarmDb.GetDatabaseForReading().GetPerson (1).PasswordHash); + + Console.WriteLine ("Creating OutboundComm..."); + + OutboundComm.CreateNotification (null, NotificationResource.System_Startup_Backend); + + Console.WriteLine ("Transmitting..."); + + OutboundComms comms = OutboundComms.GetOpen(); + + Console.WriteLine ("{0} open items in outbound comms.", comms.Count); + + foreach (OutboundComm comm in comms) + { + if (comm.TransmitterClass != "Swarmops.Utility.Communications.CommsTransmitterMail") + { + throw new NotImplementedException(); + } + + ICommsTransmitter transmitter = new CommsTransmitterMail(); + + OutboundCommRecipients recipients = comm.Recipients; + PayloadEnvelope envelope = PayloadEnvelope.FromXml (comm.PayloadXml); + + foreach (OutboundCommRecipient recipient in recipients) + { + transmitter.Transmit (envelope, recipient.Person); + } + } + + + Console.Write ("\r\nAll tests run. Waiting for mail queue to flush... "); + while (!MailTransmitter.CanExit) + { + Thread.Sleep (50); + } + + Console.WriteLine ("done."); + BotLog.Write (0, "MainCycle", "Exiting self-tests"); + return; + } + + if (args[0].ToLower() == "console") + { + Console.WriteLine ("\r\nRunning Swarmops-Backend in CONSOLE mode.\r\n"); + + // ------------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------------- + + // ----------------------- INSERT ANY ONE-OFF ACTIONS HERE ------------------------- + + + Console.Write ("\r\nWaiting for mail queue to flush... "); + + while (!MailTransmitter.CanExit) + { + Thread.Sleep (50); + } + + Console.WriteLine ("done."); + + return; + } + + if (args[0].ToLower() == "rsm") + { + Console.WriteLine ("Testing character encoding: räksmörgås RÄKSMÖRGÅS"); + return; + } + } + + /* + MailMessage message = new MailMessage(); + message.From = new MailAddress(Strings.MailSenderAddress, Strings.MailSenderName); + message.To.Add (new MailAddress ("rick@piratpartiet.se", "Rick Falkvinge (Piratpartiet)")); + message.Subject = "Räksmörgåsarnas ékÖNÖMÏåvdëlnïng"; + message.Body = "Hejsan hoppsan Räksmörgåsar."; + message.BodyEncoding = Encoding.Default; + message.SubjectEncoding = Encoding.Default; + + SmtpClient smtpClient = new SmtpClient ("localhost"); + smtpClient.Credentials = null; // mono bug + smtpClient.Send (message);*/ + + Console.WriteLine (" * Swarmops Backend starting"); + + BotLog.Write(0, "MainCycle", "Backend STARTING"); + + // Disable certificate checking due to Mono not installing with a certificate repository - this is UTTERLY broken + + SupportFunctions.DisableSslCertificateChecks(); // MONO BUG/MISFEATURE: Mono has no root certificates, so can't verify cert + + // Tell sysop we're starting + + OutboundComm.CreateNotification (null, NotificationResource.System_Startup_Backend); + + // Check for existence of installation ID. If not, create one. Warning: has privacy implications when communicated. + + if (Persistence.Key["SwarmopsInstallationId"] == string.Empty) + { + Persistence.Key["SwarmopsInstallationId"] = Guid.NewGuid().ToString(); + } + + // Check for existence of bitcoin hotwallet root + + BitcoinUtility.VerifyBitcoinHotWallet(); + + // Begin maintenance loop + + DateTime cycleStartTime = DateTime.UtcNow; + DateTime cycleEndTime; + + int lastSecond = cycleStartTime.Second; + int lastMinute = cycleStartTime.Minute; + int lastHour = cycleStartTime.Hour; + + bool exitFlag = false; + + while (!exitFlag) // exit is handled by signals handling at end of loop + { + BotLog.Write (0, "MainCycle", "Cycle Start"); + + cycleStartTime = DateTime.UtcNow; + cycleEndTime = cycleStartTime.AddSeconds(10); + + try + { + OnEveryTenSeconds(); + + if (cycleStartTime.Second < lastSecond) + { + OnEveryMinute(); + + if (cycleStartTime.Minute%5 == 0) + { + OnEveryFiveMinutes(); + } + } + + if (cycleStartTime.Minute < lastMinute) + { + OnEveryHour(); + + if (DateTime.Now.Hour == 10 && DateTime.Today.DayOfWeek == DayOfWeek.Tuesday) + { + OnTuesdayMorning(); + } + + if (DateTime.Now.Hour == 7 && DateTime.Today.DayOfWeek == DayOfWeek.Monday) + { + OnMondayMorning(); + } + } + + if (cycleStartTime.Hour >= 12 && lastHour < 12) + { + OnNoon(); + } + + if (cycleStartTime.Hour < lastHour) + { + OnMidnight(); + } + } + + catch (Exception e) + { + // Note each "OnEvery..." catches its own errors and sends Exception mails, + // so that failure in one should not stop the others from running. This particular + // code should never run. + + ExceptionMail.Send (new Exception ("Failed in swarmops-backend main loop", e), true); + } + + lastSecond = cycleStartTime.Second; + lastMinute = cycleStartTime.Minute; + lastHour = cycleStartTime.Hour; + + // Wait for a maximum of ten seconds (the difference between cycleStartTime and cycleEndTime) + + DateTime utcNow = DateTime.UtcNow; + while (utcNow < cycleEndTime && !exitFlag) + { + int signalIndex = 250; + + // Block until a SIGINT or SIGTERM signal is generated, or 1/4 second has passed. + // However, we can't do that in a development environment - it won't have the + // Mono.Posix assembly, and won't understand UnixSignals. So people running this in + // a dev environment will need to stop it manually. + + if (!Debugger.IsAttached) + { + signalIndex = UnixSignal.WaitAny(killSignals, 250); + } + else + { + TimeSpan timeLeft = (cycleEndTime - utcNow); + + BotLog.Write(0, "MainCycle Debug", + string.Format(CultureInfo.InvariantCulture, "Waiting for {0:F2} more seconds for cycle end", + timeLeft.TotalMilliseconds / 1000.0)); + Thread.Sleep(250); + } + + if (signalIndex < 250) + { + exitFlag = true; + Console.WriteLine ("Caught signal " + killSignals[signalIndex].Signum + ", exiting"); + BotLog.Write (0, "MainCycle", + "EXIT SIGNAL (" + killSignals[signalIndex].Signum + "), terminating backend"); + } + + utcNow = DateTime.UtcNow; + } + } + + Console.WriteLine (" * Swarmops Backend stopping"); + BotLog.Write (0, "MainCycle", "BACKEND EXITING, sending backend-termination notices"); + + /* + if (HeartBeater.Instance.WasKilled) + { + // removed unconditional delete, cron job that restarts bot uses it to know that it is intentionally down. + ExceptionMail.Send(new Exception("HeartBeater triggered restart of Swarmops Backend. Will commence after 800 seconds."), false); + }*/ + + BotLog.Write (0, "MainCycle", "...done"); + + /* + while (!MailTransmitter.CanExit) + { + System.Threading.Thread.Sleep(50); + }*/ + + Thread.Sleep (2000); + } + + private static void OnEveryTenSeconds() + { + try + { + BotLog.Write (0, "MainCycle", "Ten-second entry"); + + CommsTransmitter.Run(); + + try + { + /*TestTrace("Running EventProcessor.Run()..."); + EventProcessor.Run(); + TestTrace(" done.\r\n");*/ + } + catch (Exception e) + { + TraceAndReport (e); + } + + try + { + /*TestTrace("Running MailResolver.Run()..."); + MailResolver.Run(); + TestTrace(" done.\r\n");*/ + } + catch (Exception e) + { + TraceAndReport (e); + } + + try + { + /*TestTrace("Running MailProcessor.Run()..."); + MailProcessor.Run(); + TestTrace(" done.\r\n");*/ + } + catch (Exception e) + { + TraceAndReport (e); + } + + BotLog.Write (0, "MainCycle", "Ten-second exit"); + } + catch (Exception e) + { + ExceptionMail.Send (e, true); + } + } + + private static void OnEveryMinute() + { + try + { + BotLog.Write (0, "MainCycle", "One-minute process (empty)"); + } + catch (Exception e) + { + TraceAndReport (e); + } + // empty + } + + + private static void OnEveryFiveMinutes() + { + try + { + BotLog.Write (0, "MainCycle", "Five-minute entry"); + + try + { + BotLog.Write(1, "FiveMinute", "Starting automated payout processing"); + Payouts.PerformAutomated(); + } + catch (Exception e) + { + TraceAndReport (e); + } + + try + { + /*BotLog.Write(1, "FiveMinute", "Starting newsletter checker"); + TestTrace("Running NewsletterChecker.Run()..."); + NewsletterChecker.Run(); + TestTrace(" done.\r\n");*/ + } + catch (Exception e) + { + TraceAndReport (e); + } + + try + { + /*BotLog.Write(1, "FiveMinute", "Starting turnaround tracker"); + TestTrace("Running TurnaroundTracker.Run()..."); + TurnaroundTracker.Run(); + TestTrace(" done.\r\n");*/ + } + catch (Exception e) + { + TraceAndReport (e); + } + + try + { + // TestTrace(" done.\r\nRunning UpdateStatsCache.Run()..."); + // UpdateStatsCache.Run(); + /*TestTrace(" done.\r\nRunning TranslateUrls()..."); + TranslateUrls();*/ + + // Added during election rush 2010: clean up support database every five minutes instead of once a day + // SMS notifications for bounces are turned off, so people don't get SMS notifications in the middle of the night + } + catch (Exception e) + { + TraceAndReport (e); + } + + try + { + /*BotLog.Write(1, "FiveMinute", "Closing delay warnings"); + TestTrace("Running SupportDatabase.CloseDelayWarnings()..."); + SupportDatabase.CloseDelayWarnings(); + TestTrace(" done.\r\n");*/ + } + catch (Exception e) + { + TraceAndReport (e); + } + + try + { + /*TestTrace("Running SupportDatabase.NotifyBouncingEmails()..."); + BotLog.Write(1, "FiveMinute", "Notifying bouncing emails"); + SupportDatabase.NotifyBouncingEmails(); + TestTrace(" done.\r\n");*/ + } + catch (Exception e) + { + TraceAndReport (e); + } + + try + { + /*TestTrace("Running SupportMailReview.Run()..."); + BotLog.Write(1, "FiveMinute", "Running support mail review"); + SupportMailReview.Run(); + TestTrace(" done.\r\n");*/ + } + catch (Exception e) + { + TraceAndReport (e); + } + + + BotLog.Write (0, "MainCycle", "Five-minute exit"); + } + catch (Exception e) + { + ExceptionMail.Send (e, true); + TestTrace (e.ToString()); + } + } + + + private static void OnEveryHour() + { + try + { + BotLog.Write (0, "MainCycle", "One-hour entry"); + + try + { + // This will upgrade the database schema if and only if we failed to do so on entry. + + if (SwarmDb.DbVersion < SwarmDb.DbVersionExpected) + { + BotLog.Write (1, "OneHour", "Entering DbUpgrade"); + DatabaseMaintenance.UpgradeSchemata(); + BotLog.Write (1, "OneHour", "Exited DbUpgrade"); + } + } + catch (Exception e) + { + TraceAndReport (e); + } + + + try + { + BotLog.Write(1, "OneHour", "Entering Automatch"); + Organizations organizations = Organizations.GetAll(); + foreach (Organization organization in organizations) + { + if (organization.IsEconomyEnabled) + { + BotLog.Write(1, "OneHour", "Automatching org #" + organization.Identity.ToString(CultureInfo.InvariantCulture)); + Payouts.AutomatchAgainstUnbalancedTransactions(organization); + } + } + BotLog.Write(1, "OneHour", "Exited Automatch"); + + /*TestTrace("Running PaymentGroupMapper.Run()..."); + PaymentGroupMapper.Run(); + TestTrace(" done.\r\n");*/ + } + catch (Exception e) + { + TraceAndReport (e); + } + + try + { + /*TestTrace("Running BlogTop50Scraper.Run()..."); + BlogTop50Scraper.Run(); + TestTrace(" done.\r\n");*/ + } + catch (Exception e) + { + TraceAndReport (e); + } + + try + { + /*TestTrace("Running Mappery.CreatePiratpartietOrganizationStrengthCircuitMap()..."); + Mappery.CreatePiratpartietOrganizationStrengthCircuitMap(); + TestTrace(" done.\r\n");*/ + } + catch (Exception e) + { + TraceAndReport (e); + } + + try + { + /*TestTrace("Running Mappery.CreatePiratpartietOrganizationStrengthCityMap()..."); + Mappery.CreatePiratpartietOrganizationStrengthCityMap(); + TestTrace(" done.\r\n");*/ + } + catch (Exception e) + { + TraceAndReport (e); + } + + BotLog.Write (0, "MainCycle", "One-hour exit"); + } + catch (Exception e) + { + TraceAndReport (e); + } + } + + private static void OnMidnight() + { + try + { + BotLog.Write (0, "MainCycle", "Midnight entry"); + + try + { + if (!testMode) + { + /*TestTrace("Running RosterHousekeeping.ChurnExpiredMembers()..."); + RosterHousekeeping.ChurnExpiredMembers(); + TestTrace(" done.\r\n");*/ + } + + ExchangeRateSnapshot.Create(); + } + catch (Exception e) + { + TraceAndReport (e); + } + + try + { + BotLog.DeleteOld (14); // delete logs older than 14 days + } + catch (Exception e) + { + TraceAndReport (e); + } + + try + { + /*TestTrace("Running SwedishForumMemberCheck.Run()..."); + SwedishForumMemberCheck.Run(); + TestTrace(" done.\r\n");*/ + } + catch (Exception e) + { + TraceAndReport (e); + } + + try + { + /*TestTrace("Running SalaryProcessor.Run()..."); + SalaryProcessor.Run(); + TestTrace(" done.\r\n");*/ + } + catch (Exception e) + { + TraceAndReport (e); + } + + try + { + /*TestTrace("Running TurnaroundTracker.Housekeeping()..."); + TurnaroundTracker.Housekeeping(); + TestTrace(" done.\r\n");*/ + } + catch (Exception e) + { + TraceAndReport (e); + } + + try + { + /*TestTrace("Running Mappery.CreateUngPiratUptakeMap()..."); + Mappery.CreateUngPiratUptakeMap(); + TestTrace(" done.\r\n");*/ + } + catch (Exception e) + { + TraceAndReport (e); + } + + try + { + /*TestTrace("Running RosterHousekeeping.TimeoutVolunteers()..."); + RosterHousekeeping.TimeoutVolunteers(); + TestTrace(" done.\r\n");*/ + } + catch (Exception e) + { + TraceAndReport (e); + } + + BotLog.Write (0, "MainCycle", "Midnight exit"); + } + catch (Exception e) + { + ExceptionMail.Send (e, true); + TestTrace (e.ToString()); + } + } + + private static void OnNoon() + { + BotLog.Write (0, "MainCycle", "Noon entry"); + + try + { + if (!PilotInstallationIds.IsPilot (PilotInstallationIds.PiratePartySE)) + { + // PPSE is still running PW4 code for this, so don't run for PPSE + + Payroll.ProcessMonthly(); // will only actually run on the 1st, but no harm in testing every noon + } + + // Check all bitcoin accounts for previously-unseen transactions once a day + + Organizations allOrganizations = Organizations.GetAll(); + foreach (Organization organization in allOrganizations) + { + // this actually checks hot storage too, but that's supposed + // to be up to date since we're the ones handling it + BitcoinUtility.CheckColdStorageForOrganization (organization); + } + + if (!testMode) + { + /*TestTrace("Running RosterHousekeeping.RemindAllExpiries()..."); + RosterHousekeeping.RemindAllExpiries(); + TestTrace(" done.\r\n");*/ + } + } + catch (Exception e) + { + TraceAndReport (e); + } + + try + { + if (!testMode) + { + /*TestTrace("Running SupportDatabase.NotifyBouncingEmails()..."); + SupportDatabase.NotifyBouncingEmails(); + TestTrace(" done.\r\n");*/ + } + } + catch (Exception e) + { + TraceAndReport (e); + } + + try + { + /*TestTrace("Running SupportDatabase.CloseDelayWarnings()..."); + SupportDatabase.CloseDelayWarnings(); + TestTrace(" done.\r\n");*/ + } + catch (Exception e) + { + TraceAndReport (e); + } + + try + { + /*TestTrace("Running SupportMailReview.Run()..."); + SupportMailReview.Run(); + TestTrace(" done.\r\n");*/ + } + catch (Exception e) + { + TraceAndReport (e); + } + + + BotLog.Write (0, "MainCycle", "Noon exit"); + } + + private static void OnMondayMorning() + { + try + { + // Detect and log any forex difference exceeding 100 cents. + + FinancialAccounts allAccounts = FinancialAccounts.GetAll(); // across ALL ORGS! + + foreach (FinancialAccount account in allAccounts) + { + // For every account, if it's based on foreign currency, check for forex gains/losses + + if (account.ForeignCurrency != null) + { + account.CheckForexProfitLoss(); + } + } + } + catch (Exception e) + { + ExceptionMail.Send(e, true); + if (testMode) + { + Console.WriteLine(e.ToString()); + } + } + } + + private static void OnTuesdayMorning() + { + try + { + //TestTrace("Running ActivityMailer.Run()..."); + // PirateWeb.Utility.BotCode.ActivityMailer.Run(); + //TestTrace(" done.\r\n"); + } + catch (Exception e) + { + ExceptionMail.Send (e, true); + if (testMode) + { + Console.WriteLine (e.ToString()); + } + } + } + + private static void TraceAndReport (Exception e) + { + TestTrace (" failed.\r\n"); + ExceptionMail.Send (e, true); + TestTrace (e.ToString()); + } + + private static void TestTrace (string message) + { + if (testMode) + { + Console.Write (message); + } + } + } } \ No newline at end of file diff --git a/Common/Enums/PositionTitle.cs b/Common/Enums/PositionTitle.cs index 1daaca0b..38586d1a 100644 --- a/Common/Enums/PositionTitle.cs +++ b/Common/Enums/PositionTitle.cs @@ -33,7 +33,12 @@ namespace Swarmops.Common.Enums /// /// Totally customized and not stock localized - look up in PositionTitlesCustom table /// - Custom + Custom, + + /// + /// These titles are not actual positions, but UX elements (categories, etc) + /// + UxElement // Expand with various title names } diff --git a/Common/Enums/PositionType.cs b/Common/Enums/PositionType.cs index ebd85868..ee7d16f1 100644 --- a/Common/Enums/PositionType.cs +++ b/Common/Enums/PositionType.cs @@ -46,7 +46,8 @@ namespace Swarmops.Common.Enums Geographic_ActivismLeader, /* dotreports to Operations */ Geographic_ActivismLeaderAssistant, Geographic_OutreachLeader, /* dotreports to Marketing */ - Geographic_OutreachLeaderAssistant + Geographic_OutreachLeaderAssistant, + Geographic_ExpandingSubleaderNode /* Just a UX element, not a position */ // ReSharper restore InconsistentNaming } } diff --git a/FrontSocket/Frontend-Socket.csproj b/FrontSocket/Frontend-Socket.csproj index 15e0c76b..b0580c6a 100644 --- a/FrontSocket/Frontend-Socket.csproj +++ b/FrontSocket/Frontend-Socket.csproj @@ -56,8 +56,8 @@ - - + + diff --git a/FrontSocket/Program.cs b/FrontSocket/FrontendLoop.cs similarity index 93% rename from FrontSocket/Program.cs rename to FrontSocket/FrontendLoop.cs index fbf00949..22355b9b 100644 --- a/FrontSocket/Program.cs +++ b/FrontSocket/FrontendLoop.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics; +using System.Globalization; using System.IO; using System.Net; using System.Net.Security; @@ -8,15 +9,25 @@ using Mono.Unix; using Mono.Unix.Native; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Swarmops.Logic.Communications; +using Swarmops.Logic.Communications.Payload; using Swarmops.Logic.ExtensionMethods; +using Swarmops.Logic.Support; using WebSocketSharp.Server; namespace Swarmops.Frontend.Socket { - internal class Program + internal class FrontendLoop { static void Main(string[] args) { + // Check if we're Sandbox + + if (PilotInstallationIds.IsPilot(PilotInstallationIds.DevelopmentSandbox)) + { + _isSandbox = true; + } + // Disable SSL cert checking (because Mono doesn't have a cert repo, dammit) Swarmops.Logic.Support.SupportFunctions.DisableSslCertificateChecks(); @@ -31,8 +42,10 @@ namespace Swarmops.Frontend.Socket Console.WriteLine(" * Swarmops Frontend Socket Server starting up."); + OutboundComm.CreateNotification(null, NotificationResource.System_Startup_Frontend); + _socketServer = new WebSocketServer (12172); // TODO: Read from database - _socketServer.AddWebSocketService ("/ws"); + _socketServer.AddWebSocketService ("/Master"); // _socketServer.KeepClean = false; // as per the author's recommendation - this may be bad in the long run _socketServer.Start(); @@ -143,11 +156,27 @@ namespace Swarmops.Frontend.Socket Console.WriteLine(" * Swarmops Frontend Socket Server exiting"); } - private static WebSocketServer _socketServer; + private static WebSocketServer _socketServer; + private static bool _isSandbox = false; + private static int _sandboxDummy1 = 500; + private static int _sandboxDummy2 = 50000; private static void OnEveryTenSeconds() { _socketServer.WebSocketServices.Broadcast ("{\"messageType\":\"Heartbeat\"}"); + + if (_isSandbox) + { + _sandboxDummy1 += new Random().Next(10) - 3; + _sandboxDummy2 += new Random().Next(1000) - 200; + + JObject data = new JObject(); + data["messageType"] = "SandboxUpdate"; + data["local"] = _sandboxDummy1.ToString(CultureInfo.InvariantCulture); + data["profit"] = _sandboxDummy2.ToString(CultureInfo.InvariantCulture); + + _socketServer.WebSocketServices.Broadcast(data.ToString()); + } } diff --git a/FrontSocket/SocketServices.cs b/FrontSocket/MasterServices.cs similarity index 86% rename from FrontSocket/SocketServices.cs rename to FrontSocket/MasterServices.cs index 38c7fdc0..8cb93985 100644 --- a/FrontSocket/SocketServices.cs +++ b/FrontSocket/MasterServices.cs @@ -11,9 +11,9 @@ using WebSocketSharp.Server; namespace Swarmops.Frontend.Socket { - internal class SocketServices: WebSocketBehavior + internal class MasterServices: WebSocketBehavior { - public SocketServices() + public MasterServices() { base.IgnoreExtensions = true; // Necessary to suppress a Deflate exception that kills server otherwise } @@ -34,7 +34,7 @@ namespace Swarmops.Frontend.Socket switch (serverRequest) { case "UpdateQueueCounts": - Sessions.Broadcast (Program.GetQueueInfoJson()); + Sessions.Broadcast (FrontendLoop.GetQueueInfoJson()); break; case "Ping": Sessions.Broadcast("{\"messageType\":\"Heartbeat\"}"); @@ -47,18 +47,22 @@ namespace Swarmops.Frontend.Socket protected override void OnOpen() { + Console.WriteLine(" * Attempted socket connection"); + string authBase64 = Context.QueryString["Auth"]; authBase64 = Uri.UnescapeDataString (authBase64); // Defensive programming - % sign does not exist in base64 so this won't ever collapse a working encoding _authority = Authority.FromEncryptedXml (authBase64); + Console.WriteLine(" - - authenticated: " + _authority.Person.Canonical); + base.OnOpen(); if (Context.QueryString["Notify"] != "false") { Sessions.Broadcast ("{\"messageType\":\"EditorCount\"," + String.Format("\"editorCount\":\"{0}\"", Sessions.ActiveIDs.ToArray().Length) + '}'); - Send(Program.GetQueueInfoJson()); + Send(FrontendLoop.GetQueueInfoJson()); } } diff --git a/Logic/Communications/Payload/NotificationPayload.cs b/Logic/Communications/Payload/NotificationPayload.cs index ab0cd54c..c1ce925c 100644 --- a/Logic/Communications/Payload/NotificationPayload.cs +++ b/Logic/Communications/Payload/NotificationPayload.cs @@ -144,7 +144,8 @@ namespace Swarmops.Logic.Communications.Payload public enum NotificationResource { Unknown = 0, - System_Startup, + System_Startup_Backend, + System_Startup_Frontend, System_Exception, System_DatabaseSchemaUpgraded, System_DatabaseUpgradeFailed, diff --git a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs index c6f7da16..d87366a1 100644 --- a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs +++ b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs @@ -846,18 +846,36 @@ namespace Swarmops.Logic.Resources { /// /// Looks up a localized string similar to Swarmops Backend version [SwarmopsVersion] on host [HostName] has successfully started and connected to database and notification frameworks.. /// - internal static string System_Startup_Body { + internal static string System_Startup_Backend_Body { get { - return ResourceManager.GetString("System_Startup_Body", resourceCulture); + return ResourceManager.GetString("System_Startup_Backend_Body", resourceCulture); } } /// /// Looks up a localized string similar to Swarmops Backend operational. /// - internal static string System_Startup_Subject { + internal static string System_Startup_Backend_Subject { get { - return ResourceManager.GetString("System_Startup_Subject", resourceCulture); + return ResourceManager.GetString("System_Startup_Backend_Subject", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Swarmops Frontend socket server version [SwarmopsVersion] on host [HostName] has successfully started and connected to database and notification frameworks.. + /// + internal static string System_Startup_Frontend_Body { + get { + return ResourceManager.GetString("System_Startup_Frontend_Body", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Swarmops Frontend operational. + /// + internal static string System_Startup_Frontend_Subject { + get { + return ResourceManager.GetString("System_Startup_Frontend_Subject", resourceCulture); } } diff --git a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx index 1d899baf..51f0fdb5 100644 --- a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx +++ b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx @@ -455,12 +455,18 @@ The upgrade will be retried every hour. Some functionality may be disabled until Swarmops: Hotwallet public root key reset - + Swarmops Backend version [SwarmopsVersion] on host [HostName] has successfully started and connected to database and notification frameworks. - + Swarmops Backend operational + + Swarmops Frontend socket server version [SwarmopsVersion] on host [HostName] has successfully started and connected to database and notification frameworks. + + + Swarmops Frontend operational + The Swarmops transmission engine on [HostName] has encountered an unknown payload type ([UnrecognizedPayloadType]). This should only happen at very rare occasions in conjunction with upgrades where an upgraded version has to take care of something that changed names in the process, itself a rare phenomenon. diff --git a/Logic/Resources/Logic.Swarm.Position.Designer.cs b/Logic/Resources/Logic.Swarm.Position.Designer.cs index f351d6d2..029afcf0 100644 --- a/Logic/Resources/Logic.Swarm.Position.Designer.cs +++ b/Logic/Resources/Logic.Swarm.Position.Designer.cs @@ -456,6 +456,15 @@ namespace Swarmops.Logic.Resources { } } + /// + /// Looks up a localized string similar to Geographic Subleaders. + /// + internal static string Position_Geographic_ExpandingSubleaderNode_UxElement { + get { + return ResourceManager.GetString("Position_Geographic_ExpandingSubleaderNode_UxElement", resourceCulture); + } + } + /// /// Looks up a localized string similar to Information Leader. /// diff --git a/Logic/Resources/Logic.Swarm.Position.resx b/Logic/Resources/Logic.Swarm.Position.resx index 4f3e21f6..58fc3ff3 100644 --- a/Logic/Resources/Logic.Swarm.Position.resx +++ b/Logic/Resources/Logic.Swarm.Position.resx @@ -249,6 +249,10 @@ Deputies + + Geographic Subleaders + Leaders for geographies below the one displayed + Information Leader diff --git a/Logic/Swarm/DashboardTodos.cs b/Logic/Swarm/DashboardTodos.cs index ca90a087..d8de992c 100644 --- a/Logic/Swarm/DashboardTodos.cs +++ b/Logic/Swarm/DashboardTodos.cs @@ -44,7 +44,7 @@ namespace Swarmops.Logic.Swarm DashboardTodo todo = new DashboardTodo(); todo.Description = Logic_Swarm_DashboardTodos.Bitcoin_SetPayoutAddress; - todo.Icon = "/Images/Icons/bitcoin-icon-16px.png"; + todo.Icon = "/Images/Icons/bitcoin-icon-256px.png"; todo.JavaScript = "alertify.prompt(decodeURIComponent('" + Uri.EscapeDataString ( Logic_Swarm_DashboardTodos.Bitcoin_SetPayoutAddress_Prompt.Replace ( diff --git a/Logic/Swarm/Position.cs b/Logic/Swarm/Position.cs index d746af12..d2e134bb 100644 --- a/Logic/Swarm/Position.cs +++ b/Logic/Swarm/Position.cs @@ -196,7 +196,7 @@ namespace Swarmops.Logic.Swarm string titleStringUntyped = type.ToString(); string titleStringTyped = titleStringUntyped + "_" + title.ToString(); - if (plural) + if (plural && title != PositionTitle.UxElement) { titleStringUntyped += "_Plural"; titleStringTyped += "_Plural"; diff --git a/Logic/Swarm/Positions.cs b/Logic/Swarm/Positions.cs index 2d549c35..413a0744 100644 --- a/Logic/Swarm/Positions.cs +++ b/Logic/Swarm/Positions.cs @@ -61,7 +61,12 @@ namespace Swarmops.Logic.Swarm Tree geoTree = geography.Tree; - ForOrganizationGeographyRecurse (geoTree.RootNodes[0], treeResult.RootNodes[0], geographyLeaderTemplate, 2); + Position expandingSubleaderNode = + Position.FromBasic(new BasicPosition(0, PositionLevel.GeographyDefault, organization.Identity, geography.Identity, 0, 0, 0, DateTime.Today, + "Geographic_ExpandingSubleaderNode", "UxElement", false, true, false, false, false, 0, 0, 0, 0)); // UX element, not real position + TreeNode expandingNode = treeResult.RootNodes[0].AddChild(expandingSubleaderNode); + + ForOrganizationGeographyRecurse (geoTree.RootNodes[0], expandingNode, geographyLeaderTemplate, 2); return treeResult; } diff --git a/Site/App_GlobalResources/Controls.Swarm.designer.cs b/Site/App_GlobalResources/Controls.Swarm.designer.cs index bcdde755..f4c0d765 100644 --- a/Site/App_GlobalResources/Controls.Swarm.designer.cs +++ b/Site/App_GlobalResources/Controls.Swarm.designer.cs @@ -19,7 +19,7 @@ namespace Resources.Controls { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option or rebuild the Visual Studio project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Web.Application.StronglyTypedResourceProxyBuilder", "11.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Web.Application.StronglyTypedResourceProxyBuilder", "14.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Swarm { @@ -222,6 +222,15 @@ namespace Resources.Controls { } } + /// + /// Looks up a localized string similar to Leaders of subdivisions. + /// + internal static string Positions_Subleaders { + get { + return ResourceManager.GetString("Positions_Subleaders", resourceCulture); + } + } + /// /// Looks up a localized string similar to Do Not Terminate. /// diff --git a/Site/App_GlobalResources/Controls.Swarm.resx b/Site/App_GlobalResources/Controls.Swarm.resx index aa0caa40..67759237 100644 --- a/Site/App_GlobalResources/Controls.Swarm.resx +++ b/Site/App_GlobalResources/Controls.Swarm.resx @@ -193,4 +193,7 @@ Create new position... + + Leaders of subdivisions + \ No newline at end of file diff --git a/Site/Automation/Json-PositionsTree.aspx.cs b/Site/Automation/Json-PositionsTree.aspx.cs index ad62cd60..b2a64771 100644 --- a/Site/Automation/Json-PositionsTree.aspx.cs +++ b/Site/Automation/Json-PositionsTree.aspx.cs @@ -130,6 +130,7 @@ namespace Swarmops.Frontend.Automation nodeState = "closed"; } + string expires = string.Empty; string action = string.Empty; string assignedName = string.Empty; @@ -153,6 +154,7 @@ namespace Swarmops.Frontend.Automation if (localizedPositionName == null) { localizedPositionName = @"NULL (" + position.PositionType.ToString() + ")"; + string test = position.Localized(); } if (assignments.Count > 0) @@ -172,12 +174,35 @@ namespace Swarmops.Frontend.Automation assignments[0].PersonId == CurrentUser.Identity ? "self='true'" : string.Empty); } } + string element = string.Empty; - string element = string.Format("\"id\":\"{0}-1-{8}\",\"positionTitle\":\"{1}\",\"assignedName\":\"{2}\",\"expires\":\"{3}\",\"minMax\":\"{4} / {5}\",\"iconType\":\"{6}\",\"actions\":\"{7}\"", - position.Identity, JsonSanitize (localizedPositionName), JsonSanitize (assignedName), JsonSanitize (expires), position.MinCount, - position.MaxCount == 0? @"∞" : position.MaxCount.ToString(CultureInfo.InvariantCulture), - position.MaxCount == 1? "Person" : "Group", - action, position.GeographyId); + if (position.Identity > 0) // regular + { + element = + string.Format( + "\"id\":\"{0}-1-{8}\",\"positionTitle\":\"{1}\",\"assignedName\":\"{2}\",\"expires\":\"{3}\",\"minMax\":\"{4} / {5}\",\"iconType\":\"{6}\",\"actions\":\"{7}\"", + position.Identity, JsonSanitize(localizedPositionName), JsonSanitize(assignedName), + JsonSanitize(expires), position.MinCount, + position.MaxCount == 0 + ? @"∞" + : position.MaxCount.ToString(CultureInfo.InvariantCulture), + position.MaxCount == 1 ? "Person" : "Group", + action, position.GeographyId); + } + else // UX element + { + nodeState = "closed"; + element = + string.Format( + "\"id\":\"{0}-1-{8}\",\"positionTitle\":\"{1}\",\"assignedName\":\"\",\"expires\":\"\",\"minMax\":\"\",\"iconType\":\"{6}\",\"actions\":\"\"", + position.Identity, JsonSanitize(localizedPositionName), JsonSanitize(assignedName), + JsonSanitize(expires), position.MinCount, + position.MaxCount == 0 + ? @"∞" + : position.MaxCount.ToString(CultureInfo.InvariantCulture), + position.MaxCount == 1 ? "Person" : "Group", + action, position.GeographyId); + } // TODO: Add all assignments after the first one right here diff --git a/Site/Controls/v5/Swarm/TreePositions.ascx b/Site/Controls/v5/Swarm/TreePositions.ascx index d55ce461..bced3b2c 100644 --- a/Site/Controls/v5/Swarm/TreePositions.ascx +++ b/Site/Controls/v5/Swarm/TreePositions.ascx @@ -173,7 +173,7 @@ - +<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" Inherits="Swarmops.Frontend.Default" CodeFile="Default.aspx.cs" %> @@ -9,34 +9,29 @@
-
12345689.001
Current Participants (Testing new code)
+
12342500
Current Participants (Testing new code)
-
123689.001
Active Participants Last 30 Days (Testing new code)
+
125498
Active Participants Last 30 Days (Testing new code)

-
123689.001
Current Participants Sollentuna
+
498.001
Current Participants Sollentuna
-
12345689.001
Annual Profit To Date (Testing new code)
+
0.001
Annual Profit To Date (Testing new code)
-

Dashboard Placeholder

-

This system, Swarmops, is under heavy (re)construction. It has been the admin mainstay of the Swedish Pirate Party since 2006, and is being generalized to encompass any organization.

-

What you see here is the new interface being rewritten on top of the already-running engine. It runs on Debian/Ubuntu servers for frontend and backend.

-

This notice will be replaced with a proper Dashboard when all the basic functions are in place. You can see functions appear as they are implemented in the menu.

-

A rough roadmap says that basic financials are implemented first, then member registry functions, then communications, then responsibilities, then governance. For more on the specific roadmap, go to the SCRUM planning for Swarmops.

-

Look at the Swarmops code on Github (and feel free to contribute)! Current line count: 140,936.

-

Use this form to report bugs for these early builds.

+

+ -
+
diff --git a/Site/Default.aspx.cs b/Site/Default.aspx.cs index f3990d55..8c2b21e9 100644 --- a/Site/Default.aspx.cs +++ b/Site/Default.aspx.cs @@ -4,6 +4,7 @@ using Swarmops.Logic.Financial; using Swarmops.Logic.Security; using Swarmops.Logic.Support; using Swarmops.Logic.Swarm; +using Swarmops.Logic.Structure; namespace Swarmops.Frontend { @@ -28,6 +29,8 @@ namespace Swarmops.Frontend InfoBoxLiteral = "This is a Dashboard placeholder. It will contain a snapshot of the state of things as soon as the basic functions are re-implemented in the new interface."; + InitializePositionPanel(); + // If Open Ledgers, redirect to Balance Sheet: Don't show Dashboard if (CurrentUser.Identity == Person.OpenLedgersIdentity) @@ -35,5 +38,33 @@ namespace Swarmops.Frontend Response.Redirect ("/Ledgers/BalanceSheet"); } } + + internal void InitializePositionPanel() + { + Geography displayGeography = CurrentUser.Geography; + + if (CurrentAuthority.Position != null && CurrentAuthority.Position.Geography != CurrentUser.Geography) + { + if (CurrentAuthority.Position.Geography == null) + { + displayGeography = Geography.Root; + } + else + { + displayGeography = CurrentAuthority.Position.Geography; + } + } + + if (displayGeography.Identity == Geography.RootIdentity) + { + this.LabelHeaderLocal.Text = Resources.Pages.Swarm.LocalOrganization_HeaderGlobal; + } + else + { + this.LabelHeaderLocal.Text = String.Format(Resources.Pages.Swarm.LocalOrganization_Header, displayGeography.Name); + } + + this.TreePositions.GeographyId = displayGeography.Identity; + } } } \ No newline at end of file diff --git a/Site/Default.aspx.designer.cs b/Site/Default.aspx.designer.cs index ef4fc046..48c3d304 100644 --- a/Site/Default.aspx.designer.cs +++ b/Site/Default.aspx.designer.cs @@ -11,5 +11,23 @@ namespace Swarmops.Frontend { public partial class Default { + + /// + /// LabelHeaderLocal control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelHeaderLocal; + + /// + /// TreePositions control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::Swarmops.Frontend.Controls.Swarm.TreePositions TreePositions; } } diff --git a/Site/Images/Flags/flag-highlight-128px.png b/Site/Images/Flags/flag-highlight-128px.png new file mode 100644 index 00000000..0365a621 Binary files /dev/null and b/Site/Images/Flags/flag-highlight-128px.png differ diff --git a/Site/Images/Icons/bitcoin-icon-256px.png b/Site/Images/Icons/bitcoin-icon-256px.png new file mode 100644 index 00000000..cf55a4be Binary files /dev/null and b/Site/Images/Icons/bitcoin-icon-256px.png differ diff --git a/Site/Images/Icons/iconshock-balloon-128x96px-hot.png b/Site/Images/Icons/iconshock-balloon-128x96px-hot.png new file mode 100644 index 00000000..5dc2a706 Binary files /dev/null and b/Site/Images/Icons/iconshock-balloon-128x96px-hot.png differ diff --git a/Site/Images/Icons/iconshock-balloon-128x96px.png b/Site/Images/Icons/iconshock-balloon-128x96px.png new file mode 100644 index 00000000..0682ba43 Binary files /dev/null and b/Site/Images/Icons/iconshock-balloon-128x96px.png differ diff --git a/Site/Images/Icons/iconshock-balloon-defer-128x96px-hot.png b/Site/Images/Icons/iconshock-balloon-defer-128x96px-hot.png new file mode 100644 index 00000000..26afe020 Binary files /dev/null and b/Site/Images/Icons/iconshock-balloon-defer-128x96px-hot.png differ diff --git a/Site/Images/Icons/iconshock-balloon-defer-128x96px.png b/Site/Images/Icons/iconshock-balloon-defer-128x96px.png new file mode 100644 index 00000000..297aeba5 Binary files /dev/null and b/Site/Images/Icons/iconshock-balloon-defer-128x96px.png differ diff --git a/Site/Images/Icons/iconshock-balloon-wrench-128x96px-hot.png b/Site/Images/Icons/iconshock-balloon-wrench-128x96px-hot.png new file mode 100644 index 00000000..835e7f01 Binary files /dev/null and b/Site/Images/Icons/iconshock-balloon-wrench-128x96px-hot.png differ diff --git a/Site/Images/Icons/iconshock-balloon-wrench-128x96px.png b/Site/Images/Icons/iconshock-balloon-wrench-128x96px.png new file mode 100644 index 00000000..8e49d39d Binary files /dev/null and b/Site/Images/Icons/iconshock-balloon-wrench-128x96px.png differ diff --git a/Site/Images/Icons/iconshock-stars-1-128x96px.png b/Site/Images/Icons/iconshock-stars-1-128x96px.png new file mode 100644 index 00000000..2d2f1273 Binary files /dev/null and b/Site/Images/Icons/iconshock-stars-1-128x96px.png differ diff --git a/Site/Images/Icons/iconshock-stars-2-128x96px.png b/Site/Images/Icons/iconshock-stars-2-128x96px.png new file mode 100644 index 00000000..ada089cc Binary files /dev/null and b/Site/Images/Icons/iconshock-stars-2-128x96px.png differ diff --git a/Site/Images/Icons/iconshock-stars-3-128x96px.png b/Site/Images/Icons/iconshock-stars-3-128x96px.png new file mode 100644 index 00000000..e2405416 Binary files /dev/null and b/Site/Images/Icons/iconshock-stars-3-128x96px.png differ diff --git a/Site/Images/Icons/iconshock-stars-4-128x96px.png b/Site/Images/Icons/iconshock-stars-4-128x96px.png new file mode 100644 index 00000000..cc84526c Binary files /dev/null and b/Site/Images/Icons/iconshock-stars-4-128x96px.png differ diff --git a/Site/Images/Icons/iconshock-stars-5-128x96px.png b/Site/Images/Icons/iconshock-stars-5-128x96px.png new file mode 100644 index 00000000..3cbf81e0 Binary files /dev/null and b/Site/Images/Icons/iconshock-stars-5-128x96px.png differ diff --git a/Site/Images/Icons/iconshock-stars-6-128x96px.png b/Site/Images/Icons/iconshock-stars-6-128x96px.png new file mode 100644 index 00000000..1955a874 Binary files /dev/null and b/Site/Images/Icons/iconshock-stars-6-128x96px.png differ diff --git a/Site/Images/Icons/iconshock-user-female.png b/Site/Images/Icons/iconshock-user-female.png index 70568b1f..b689ef33 100644 Binary files a/Site/Images/Icons/iconshock-user-female.png and b/Site/Images/Icons/iconshock-user-female.png differ diff --git a/Site/Images/Icons/iconshock-user-male.png b/Site/Images/Icons/iconshock-user-male.png index 22c41bf0..da05322c 100644 Binary files a/Site/Images/Icons/iconshock-user-male.png and b/Site/Images/Icons/iconshock-user-male.png differ diff --git a/Site/Images/Icons/iconshock-user-unknown.png b/Site/Images/Icons/iconshock-user-unknown.png index b4497898..022322f6 100644 Binary files a/Site/Images/Icons/iconshock-user-unknown.png and b/Site/Images/Icons/iconshock-user-unknown.png differ diff --git a/Site/Images/Icons/iconshock-wrench-128x96px-centered.png b/Site/Images/Icons/iconshock-wrench-128x96px-centered.png new file mode 100644 index 00000000..9d9d2240 Binary files /dev/null and b/Site/Images/Icons/iconshock-wrench-128x96px-centered.png differ diff --git a/Site/Master-v5.master b/Site/Master-v5.master index 0b984b70..71573cb7 100644 --- a/Site/Master-v5.master +++ b/Site/Master-v5.master @@ -142,10 +142,13 @@ - + - -
-
-
-
unlock icon

PIRATEWEB5β LOGIN

-
-
- -
-  
-  
-
-

-
-
-  
-  
-
-
-
-
-
-
-
- -
- - diff --git a/Site/Security/Login-Old.aspx.cs b/Site/Security/Login-Old.aspx.cs deleted file mode 100644 index 5ca5f52e..00000000 --- a/Site/Security/Login-Old.aspx.cs +++ /dev/null @@ -1,106 +0,0 @@ -using System; -using System.Diagnostics; -using System.Threading; -using System.Web; -using System.Web.Security; -using System.Web.UI; -using Swarmops.Basic.Types; -using Swarmops.Basic.Types.Swarm; -using Swarmops.Interface.Support; -using Swarmops.Logic.Security; -using Swarmops.Logic.Support; -using Swarmops.Logic.Swarm; - -namespace Swarmops.Pages.Security -{ - public partial class LoginOld : Page - { - protected void Page_Load (object sender, EventArgs e) - { - // Check if this is the first run ever. If so, redirect to Init. - - if (!SupportFunctions.DatabaseConfigured) - { - Response.Redirect ("/Pages/v5/Init/", true); - return; - } - - // If this is the Dev Sandbox, autologin - - if (Request.Url.Host == "dev.swarmops.com" && - PilotInstallationIds.IsPilot (PilotInstallationIds.DevelopmentSandbox)) - { - DashboardMessage.Set ("

You have been logged on as Sandbox Administrator to the Swarmops Development Sandbox.


This machine runs the latest development build, so you may run into diagnostic code and half-finished features. All data here is bogus test data and is reset every night.


In other words, welcome, and play away!



"); - FormsAuthentication.RedirectFromLoginPage ("1,1", true); - } - - - // THE DAMN BITID NEEDS TO GO INTO ANDROID WALLET SO WE CAN STREAMLINE AND REWRITE THIS POS - - - this.LabelLoginFailed.Visible = false; - this.TextLogin.Focus(); - - - // Check for SSL and force it - - // Special case for CloudFlare deployments - there is a case where somebody will get their connections de-SSLed at the server - - string cloudFlareVisitorScheme = Request.Headers["CF-Visitor"]; - bool cloudFlareSsl = false; - - if (!string.IsNullOrEmpty (cloudFlareVisitorScheme)) - { - if (cloudFlareVisitorScheme.Contains ("\"scheme\":\"https\"")) - { - cloudFlareSsl = true; - } - } - - // TODO: Same thing for Pound deployments - - // Rewrite if applicable - - if (Request.Url.ToString().StartsWith ("http://") && !cloudFlareSsl) - // only check client-side as many server sites de-SSL the connection before reaching the web server - { - if (!Request.Url.ToString().StartsWith ("http://dev.swarmops.com/") && - !Request.Url.ToString().StartsWith ("http://localhost:") && - !Request.Url.ToString().StartsWith ("http://swarmops-")) - { - Response.Redirect (Request.Url.ToString().Replace ("http:", "https:")); - } - } - } - - protected void ButtonLogin_Click (object sender, EventArgs e) - { - string loginToken = this.TextLogin.Text; - string password = this.TextPassword.Text; - - if (!string.IsNullOrEmpty (loginToken.Trim()) && !string.IsNullOrEmpty (password.Trim())) - { - try - { - BasicPerson authenticatedPerson = Authentication.Authenticate (loginToken, - password); - Person p = Person.FromIdentity (authenticatedPerson.PersonId); - - if (p.PreferredCulture != Thread.CurrentThread.CurrentCulture.Name) - p.PreferredCulture = Thread.CurrentThread.CurrentCulture.Name; - - // TODO: Determine logged-on organization; possibly ask for clarification - - FormsAuthentication.RedirectFromLoginPage (authenticatedPerson.PersonId + ",1", true); - } - catch (Exception exception) - { - Debug.WriteLine (exception.ToString()); - this.LabelLoginFailed.Text = exception.ToString(); - this.LabelLoginFailed.Visible = true; - this.TextLogin.Focus(); - } - } - } - } -} \ No newline at end of file diff --git a/Site/Security/Login-Old.aspx.designer.cs b/Site/Security/Login-Old.aspx.designer.cs deleted file mode 100644 index 49f04784..00000000 --- a/Site/Security/Login-Old.aspx.designer.cs +++ /dev/null @@ -1,87 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Swarmops.Pages.Security { - - - public partial class LoginOld { - - /// - /// form1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.HtmlControls.HtmlForm form1; - - /// - /// ScriptManager1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.ScriptManager ScriptManager1; - - /// - /// TextLogin control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox TextLogin; - - /// - /// TextPassword control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox TextPassword; - - /// - /// ButtonLogin control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Button ButtonLogin; - - /// - /// ValidatorRequired_Login control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.RequiredFieldValidator ValidatorRequired_Login; - - /// - /// LabelLoginFailed control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Label LabelLoginFailed; - - /// - /// ValidatorRequired_Password control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.RequiredFieldValidator ValidatorRequired_Password; - } -} diff --git a/Site/Site.csproj b/Site/Site.csproj index be0aa536..60b23a56 100644 --- a/Site/Site.csproj +++ b/Site/Site.csproj @@ -565,13 +565,6 @@ FinalizeLogin.aspx - - Login-Old.aspx - ASPXCodeBehind - - - Login-Old.aspx - Login.aspx ASPXCodeBehind @@ -690,6 +683,7 @@ + @@ -731,8 +725,13 @@ + + + + + @@ -744,6 +743,8 @@ + + @@ -811,6 +812,12 @@ + + + + + + @@ -827,6 +834,7 @@ + @@ -1762,7 +1770,6 @@ - diff --git a/Site/Style/odometer-theme-car.css b/Site/Style/odometer-theme-car.css index b5b7afc4..7211b3ca 100644 --- a/Site/Style/odometer-theme-car.css +++ b/Site/Style/odometer-theme-car.css @@ -111,8 +111,7 @@ color: #000; } - -.odometer.odometer-auto-theme:not(.nocents) .odometer-digit:nth-last-child(1) { +.odometer.odometer-auto-theme:not(.nocents) .odometer-digit:last-child, .odometer.odometer-auto-theme:not(.nocents) .odometer-digit:nth-last-child(1), .odometer.odometer-theme-car:not(.nocents) .odometer-digit:last-child, .odometer.odometer-theme-car:not(.nocents) .odometer-digit:nth-last-child(1) { display: none; } diff --git a/Site/Style/style-v5.css b/Site/Style/style-v5.css index 201f5b45..c6b1883f 100644 --- a/Site/Style/style-v5.css +++ b/Site/Style/style-v5.css @@ -254,6 +254,28 @@ body.rtl span.buildId { direction: ltr; /* parentheses freak out unless specified LTR */ } +div#DivMasterUserIcon { + height: 28px; + width: 28px; + background-size: 28px; + background-position-y: 0; +} + +div#DivMasterUserIcon:hover { + background-position-y: 28px; +} + +div#DivMasterFlag { + margin-top: 6px; + padding-top: 4px; + background-image: url('/Images/Flags/flag-highlight-128px.png'); + background-size:0 +} + +div#DivMasterFlag:hover { + background-size: 28px; +} + /* DASHBOARD THINGS */ .odometer { @@ -278,6 +300,13 @@ body.rtl .odometer-label { padding-right: 4px; } + +.odometer.odometer-auto-theme:not(.nocents) .odometer-digit:last-child, .odometer.odometer-auto-theme:not(.nocents) .odometer-digit:nth-last-child(1), .odometer.odometer-theme-car:not(.nocents) .odometer-digit:last-child, .odometer.odometer-theme-car:not(.nocents) .odometer-digit:nth-last-child(1) { + display: none; /* redundant workaround for cent rounding - moved here to escape caching of styles; main file has a cache buster and others don't */ +} + + + /* BARS AND BOXEN */ .mainbar diff --git a/Site/apache-default-config.txt b/Site/apache-default-config.txt index b6ce6c99..3b17c817 100644 --- a/Site/apache-default-config.txt +++ b/Site/apache-default-config.txt @@ -2,11 +2,11 @@ ServerName swarmops-frontend ServerAdmin swarmops-frontend@swarmops.com DocumentRoot /usr/share/swarmops/frontend/ -# Redirect websocket requests to Swarmops FrontSocket server +# With mod_proxy enabled, kill the ability to make unsolicited proxy requests ProxyRequests Off -ProxyPass "/ws/" "ws:/localhost:12172" -# Explicitly specify Mono version 4 +# Point out application folder, explicitly specify Mono version 4 +MonoApplications swarmops-frontend "/:/usr/share/swarmops/frontend/" MonoServerPath swarmops-frontend "/usr/bin/mod-mono-server4" # Uncomment the line below to enable debugging: @@ -15,16 +15,30 @@ MonoServerPath swarmops-frontend "/usr/bin/mod-mono-server4" # Uncomment the line below and enter FQDNs (one or more) for Swarmops if # running virtual hosts: # ServerAlias FQDN1 FQDN2 FQDN3 ... - -MonoApplications swarmops-frontend "/:/usr/share/swarmops/frontend/" - + + +# Redirect websocket requests to Swarmops FrontSocket server + + Allow from all - Order allow,deny - SetHandler mono - MonoSetServerAlias swarmops-frontend - SetOutputFilter DEFLATE - SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary + ProxyPass "ws://localhost:12172/" + ProxyPassReverse "ws://localhost:12172/" + +# Trigger main handler only if Upgrade header is not [Ww]ebsocket +# (because in that particular case, we're passing to socket above) + + + + Allow from all + Order allow,deny + SetHandler mono + MonoSetServerAlias swarmops-frontend + SetOutputFilter DEFLATE + SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary + + + AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript diff --git a/Site/web.config b/Site/web.config index 516cd2ce..06cad2c8 100644 --- a/Site/web.config +++ b/Site/web.config @@ -40,6 +40,7 @@ +