예제 #1
0
 public StatusUpdaterService()
 {
     _nestWebService        = ServiceContainer.GetService <INestWebService>();
     _delayedStatusProvider = ServiceContainer.GetService <IStatusProvider>();
     _updateStatusTimer     = ServiceContainer.GetService <ITimer>();
     _updateStatusTimer.SetCallback(OnTimerTick);
 }
예제 #2
0
 public TemplateGenerator(ILogProvider logProvider, IStatusProvider statusProvider, ISubscription sourceSubscription, ISubscription targetSubscription)
 {
     _logProvider        = logProvider;
     _statusProvider     = statusProvider;
     _SourceSubscription = sourceSubscription;
     _TargetSubscription = targetSubscription;
 }
예제 #3
0
        public AsmToArmForm()
        {
            InitializeComponent();
            _logProvider           = new FileLogProvider();
            _statusProvider        = new UIStatusProvider(lblStatus);
            _saveSelectionProvider = new UISaveSelectionProvider();
            _telemetryProvider     = new CloudTelemetryProvider();
            _appSettingsProvider   = new AppSettingsProvider();

            _AzureContextSourceASM = new AzureContext(_logProvider, _statusProvider, _appSettingsProvider);
            _AzureContextSourceASM.AzureEnvironmentChanged       += _AzureContextSourceASM_AzureEnvironmentChanged;
            _AzureContextSourceASM.UserAuthenticated             += _AzureContextSourceASM_UserAuthenticated;
            _AzureContextSourceASM.BeforeAzureSubscriptionChange += _AzureContextSourceASM_BeforeAzureSubscriptionChange;
            _AzureContextSourceASM.AfterAzureSubscriptionChange  += _AzureContextSourceASM_AfterAzureSubscriptionChange;
            _AzureContextSourceASM.BeforeUserSignOut             += _AzureContextSourceASM_BeforeUserSignOut;
            _AzureContextSourceASM.AfterUserSignOut += _AzureContextSourceASM_AfterUserSignOut;

            _AzureContextTargetARM = new AzureContext(_logProvider, _statusProvider, _appSettingsProvider);
            _AzureContextTargetARM.AzureEnvironmentChanged      += _AzureContextTargetARM_AzureEnvironmentChanged;
            _AzureContextTargetARM.UserAuthenticated            += _AzureContextTargetARM_UserAuthenticated;
            _AzureContextTargetARM.AfterAzureSubscriptionChange += _AzureContextTargetARM_AfterAzureSubscriptionChange;
            _AzureContextTargetARM.AfterUserSignOut             += _AzureContextTargetARM_AfterUserSignOut;

            _TargetResourceGroup = new ArmResourceGroup(this.AzureContextSourceASM, "Target Resource Group");
        }
예제 #4
0
파일: AsmToArm.cs 프로젝트: rickrain/migAz
        public AsmToArm(IStatusProvider statusProvider, ILogProvider logProvider, PropertyPanel propertyPanel)
            : base(statusProvider, logProvider)
        {
            InitializeComponent();

            _saveSelectionProvider = new UISaveSelectionProvider();
            _telemetryProvider     = new AsmToArmTelemetryProvider();
            _appSettingsProvider   = new AppSettingsProvider();
            _PropertyPanel         = propertyPanel;

            _AzureContextSourceASM = new AzureContext(LogProvider, StatusProvider, _appSettingsProvider);
            _AzureContextSourceASM.AzureEnvironmentChanged       += _AzureContextSourceASM_AzureEnvironmentChanged;
            _AzureContextSourceASM.UserAuthenticated             += _AzureContextSourceASM_UserAuthenticated;
            _AzureContextSourceASM.BeforeAzureSubscriptionChange += _AzureContextSourceASM_BeforeAzureSubscriptionChange;
            _AzureContextSourceASM.AfterAzureSubscriptionChange  += _AzureContextSourceASM_AfterAzureSubscriptionChange;
            _AzureContextSourceASM.BeforeUserSignOut             += _AzureContextSourceASM_BeforeUserSignOut;
            _AzureContextSourceASM.AfterUserSignOut       += _AzureContextSourceASM_AfterUserSignOut;
            _AzureContextSourceASM.AfterAzureTenantChange += _AzureContextSourceASM_AfterAzureTenantChange;

            _AzureContextTargetARM = new AzureContext(LogProvider, StatusProvider, _appSettingsProvider);

            _TargetResourceGroup = new ResourceGroup(this.AzureContextSourceASM, "Target Resource Group");

            azureLoginContextViewerASM.Bind(_AzureContextSourceASM);
            azureLoginContextViewerARM.Bind(_AzureContextTargetARM);

            this.TemplateGenerator = new AsmToArmGenerator(_AzureContextSourceASM.AzureSubscription, _AzureContextTargetARM.AzureSubscription, _TargetResourceGroup, LogProvider, StatusProvider, _telemetryProvider, _appSettingsProvider);
        }
예제 #5
0
 public PersonController(AgeRangerContext ctx, HttpStatusMapper statusProvider, IOptions <AppModuleConfig> appConfig)
 {
     _ctx            = ctx;
     _statusProvider = statusProvider;
     _provider       = new AgeRangerDataProvider(ctx);
     _appConfig      = appConfig;
 }
예제 #6
0
파일: AwsToArm.cs 프로젝트: rickrain/migAz
        public AwsToArm(IStatusProvider statusProvider, ILogProvider logProvider, PropertyPanel propertyPanel)
            : base(statusProvider, logProvider)
        {
            InitializeComponent();

            _PropertyPanel = propertyPanel;
        }
예제 #7
0
        public AwsToArm(IStatusProvider statusProvider, ILogProvider logProvider, PropertyPanel propertyPanel)
            : base(statusProvider, logProvider)
        {
            InitializeComponent();

            _PropertyPanel         = propertyPanel;
            _saveSelectionProvider = new AwsToArmSaveSelectionProvider();
            _telemetryProvider     = new AwsToArmSaveSelectionProvider();

            _AzureContextTargetARM = new AzureContext(LogProvider, StatusProvider, null); // _appSettingsProvider);
            _AzureContextTargetARM.AfterAzureSubscriptionChange += _AzureContextTargetARM_AfterAzureSubscriptionChange;

            azureLoginContextViewer21.Bind(_AzureContextTargetARM);

            this.TemplateGenerator = new AwsGenerator(LogProvider, StatusProvider);

            this.treeTargetARM.LogProvider    = this.LogProvider;
            this.treeTargetARM.StatusProvider = this.StatusProvider;

            if (_AzureContextTargetARM != null && _AzureContextTargetARM.SettingsProvider != null)
            {
                this.treeTargetARM.SettingsProvider = _AzureContextTargetARM.SettingsProvider;
            }

            this._PropertyPanel.LogProvider      = this.LogProvider;
            this._PropertyPanel.StatusProvider   = this.StatusProvider;
            this._PropertyPanel.AzureContext     = _AzureContextTargetARM;
            this._PropertyPanel.TargetTreeView   = treeTargetARM;
            this._PropertyPanel.PropertyChanged += _PropertyPanel_PropertyChanged;
        }
예제 #8
0
        /// <summary>
        /// Creates a new EliteDangerousAPI class
        /// </summary>
        /// <param name="services">ServiceProvider</param>
        public EliteDangerousAPI(IServiceProvider services)
        {
            try
            {
                Version = Assembly.GetExecutingAssembly().GetName().Version;

                _log    = services.GetRequiredService <ILogger <EliteDangerousAPI> >();
                _config = services.GetRequiredService <IConfiguration>();

                _eventProvider   = services.GetRequiredService <IEventProvider>();
                _eventProcessors = services.GetRequiredService <IEnumerable <IEventProcessor> >();

                _journalDirectoryProvider = services.GetRequiredService <IJournalDirectoryProvider>();

                _journalProvider  = services.GetRequiredService <IJournalProvider>();
                _journalProcessor = services.GetRequiredService <IJournalProcessor>();

                _statusProvider  = services.GetRequiredService <IStatusProvider>();
                _statusProcessor = services.GetRequiredService <IStatusProcessor>();

                Events = services.GetRequiredService <EventHandler>();
                Status = services.GetRequiredService <IShipStatus>();
            }
            catch (Exception ex)
            {
                PreInitializationException = ex;
            }
        }
예제 #9
0
 public AzureContext(AzureRetriever azureRetriever, TargetSettings targetSettings, PromptBehavior defaultPromptBehavior = PromptBehavior.Always)
 {
     _AzureRetriever      = azureRetriever;
     _TargetSettings      = targetSettings;
     _LogProvider         = azureRetriever.LogProvider;
     _StatusProvider      = azureRetriever.StatusProvider;
     _LoginPromptBehavior = defaultPromptBehavior;
 }
예제 #10
0
 public static void SetupStatusRespond(this Form form, TextBox txt, IStatusProvider provider)
 {
     provider.OnStatusChange += delegate(Status s)
     {
         MethodInvoker action = delegate { txt.Text = s.Message; };
         form.BeginInvoke(action);
     };
 }
예제 #11
0
 public AzureContext(ILogProvider logProvider, IStatusProvider statusProvider, ISettingsProvider settingsProvider)
 {
     _LogProvider      = logProvider;
     _StatusProvider   = statusProvider;
     _SettingsProvider = settingsProvider;
     _TokenProvider    = new AzureTokenProvider(_LogProvider);
     _AzureRetriever   = new AzureRetriever(this);
 }
예제 #12
0
 /// <summary>
 /// Add a new <see cref="IStatusProvider"/> to writing job status
 /// </summary>
 /// <param name="provider">Instance of an <see cref="IStatusProvider"/></param>
 /// <exception cref="ArgumentNullException" />
 public void AddStatusProvider(IStatusProvider provider)
 {
     if (provider == null)
     {
         throw new ArgumentNullException(nameof(provider));
     }
     _statusProviders.Add(provider);
 }
예제 #13
0
        public void Bind(ILogProvider logProvider, IStatusProvider statusProvider, TargetSettings targetSettings, ImageList imageList, PromptBehavior promptBehavior)
        {
            _TargetSettings = targetSettings;
            _LogProvider    = logProvider;
            _StatusProvider = statusProvider;
            _ImageList      = imageList;

            treeAzureARM.ImageList = _ImageList;
        }
예제 #14
0
 public AzureGenerator(
     ISubscription sourceSubscription,
     ISubscription targetSubscription,
     ILogProvider logProvider,
     IStatusProvider statusProvider,
     ITelemetryProvider telemetryProvider,
     ISettingsProvider settingsProvider) : base(logProvider, statusProvider, sourceSubscription, targetSubscription, telemetryProvider, settingsProvider)
 {
 }
예제 #15
0
 public AutopublishProvider(ISettingsService settingsService, IStatusProvider statusProvider, IOptions <IntegrationProperties> intProps)
 {
     _settingsService = settingsService;
     _statusProvider  = statusProvider;
     _baseTntUri      = string.IsNullOrEmpty(intProps.Value.TarantoolApiUrl) ?
                        new Uri(intProps.Value.TarantoolApiUrl) : null;
     _baseWebApiUri = string.IsNullOrEmpty(intProps.Value.DpcWebApiUrl)
         ? new Uri(intProps.Value.DpcWebApiUrl) : null;
 }
예제 #16
0
        public ProgressRunningDialog(IStatusProvider statusProvider, Action cancelProcessAction)        {
            statusProvider.StatusChanged += ProgressReported;
            _StatusProvider = statusProvider;
            _CancelProcessAction = cancelProcessAction;

            InitializeComponent();

            btDone.Enabled = false;
            btAbort.Enabled = cancelProcessAction != null;
        }
예제 #17
0
        public ProgressRunningDialog(IStatusProvider statusProvider, Action cancelProcessAction)
        {
            statusProvider.StatusChanged += ProgressReported;
            _StatusProvider      = statusProvider;
            _CancelProcessAction = cancelProcessAction;

            InitializeComponent();

            btDone.Enabled  = false;
            btAbort.Enabled = cancelProcessAction != null;
        }
예제 #18
0
        public Window()
        {
            InitializeComponent();
            _logProvider    = new FileLogProvider();
            _statusProvider = new UIStatusProvider(lblStatus);
            _asmRetriever   = new AsmRetriever(_logProvider, _statusProvider);
            var tokenProvider     = new InteractiveTokenProvider();
            var telemetryProvider = new CloudTelemetryProvider();

            _templateGenerator = new TemplateGenerator(_logProvider, _statusProvider, telemetryProvider, tokenProvider, _asmRetriever);
        }
예제 #19
0
        public static void UpdateStatus(this IStatusProvider provider, Status status)
        {
            if (provider == null)
            {
                return;
            }

            if (provider.OnStatusChange != null)
            {
                provider.OnStatusChange(status);
            }
        }
예제 #20
0
        public MigAzForm()
        {
            InitializeComponent();
            _logProvider            = new FileLogProvider();
            _logProvider.OnMessage += _logProvider_OnMessage;
            _statusProvider         = new UIStatusProvider(this.toolStripStatusLabel1);
            _appSettingsProvider    = new AppSettingsProvider();

            txtDestinationFolder.Text = AppDomain.CurrentDomain.BaseDirectory;
            propertyPanel1.Clear();
            splitContainer2.SplitterDistance = this.Height / 2;
            lblLastOutputRefresh.Text        = String.Empty;
        }
예제 #21
0
        public NestViewModel()
        {
            if (DesignerProperties.IsInDesignTool)
            {
                return;
            }

            _statusProvider                = ServiceContainer.GetService <IStatusProvider>();
            _sessionProvider               = ServiceContainer.GetService <ISessionProvider>();
            _nestWebService                = ServiceContainer.GetService <INestWebService>();
            _statusUpdater                 = ServiceContainer.GetService <IStatusUpdaterService>();
            _analyticsService              = ServiceContainer.GetService <IAnalyticsService>();
            _statusProvider.StatusUpdated += OnStatusUpdated;
        }
예제 #22
0
        public ThermostatViewModel(Thermostat thermostat)
        {
            if (DesignerProperties.IsInDesignTool)
            {
                return;
            }

            _thermostat                    = thermostat;
            _statusProvider                = ServiceContainer.GetService <IStatusProvider>();
            _nestWebService                = ServiceContainer.GetService <INestWebService>();
            _statusUpdater                 = ServiceContainer.GetService <IStatusUpdaterService>();
            _exceptionHandler              = ServiceContainer.GetService <IExceptionHandler>();
            _statusProvider.StatusUpdated += OnStatusUpdated;
        }
예제 #23
0
        public AwsObjectRetriever(string accessKeyID, string secretKeyID, Amazon.RegionEndpoint region, ILogProvider logProvider, IStatusProvider statusProvider)
        {
            _logProvider    = logProvider;
            _statusProvider = statusProvider;

            createEC2Client(accessKeyID, secretKeyID, region);
            createLBClient(accessKeyID, secretKeyID, region);
            REGION = region.SystemName;

            _vpcs      = GetAllVpcs();
            _instances = GetAllInstances();
            _volumes   = GetAllVolumes();
            Application.DoEvents();
            _Loadbalancers = GetAllLBs();
        }
예제 #24
0
        //public string PingCmd {get; protected set;}
        //public Predicate<string> PingCorrect { get; protected set; }

        /// <summary>
        /// Finds an open port that responds to a given command.
        /// </summary>
        /// <param name="board"></param>
        /// <param name="portLow"></param>
        /// <param name="portHigh"></param>
        /// <param name="pingCmd"></param>
        /// <param name="pingCorrect"></param>
        /// <returns></returns>
        public static int FindExistingPort(IPAddress ipAdress,
                                           int portLow,
                                           int portHigh,
                                           Func <IPAddress, int, INetworkCom> getComDevice,
                                           string pingCmd,
                                           Predicate <string> pingCorrect,
                                           IStatusProvider status = null)
        {
            //NOTE: status.UpdateStatus is a null safe extension method

            status.UpdateStatus(Status.Starting("Searhing for available port."));

            int thePort = -1;

            //using threads to speed up tha scan
            Parallel.For(portLow, portHigh - 1, (P, S) =>
            {
                try
                {
                    //is the port open
                    TcpClient client      = new TcpClient();
                    client.SendTimeout    = 2000;
                    client.ReceiveTimeout = 2000;
                    client.Connect(ipAdress, P);
                    bool open = client.Connected;
                    client.Close();

                    //test to see if it will do what we want
                    if (open)
                    {
                        INetworkCom com = getComDevice(ipAdress, P);
                        if (TestConection(com, pingCmd, pingCorrect, status))
                        {
                            thePort = P;
                            S.Break();
                        }
                    }
                    client.Close();
                }
                catch
                {
                }
            });

            status.UpdateStatus((thePort >= 0) ? Status.Done("Found working port: " + thePort):
                                Status.Error("Could not find suitable port. "));
            return(thePort);
        }
예제 #25
0
        public ArmToArm(IStatusProvider statusProvider, ILogProvider logProvider, PropertyPanel propertyPanel)
            : base(statusProvider, logProvider)
        {
            InitializeComponent();

            _saveSelectionProvider = new MigAz.Forms.ARM.Providers.UISaveSelectionProvider();
            _telemetryProvider     = new ArmToArmTelemetryProvider();
            _appSettingsProvider   = new AppSettingsProvider();
            _PropertyPanel         = propertyPanel;

            _AzureContextARM = new AzureContext(LogProvider, StatusProvider, _appSettingsProvider);
            _AzureContextARM.AfterAzureSubscriptionChange += _AzureContextARM_AfterAzureSubscriptionChange;
            azureLoginContextViewer1.Bind(_AzureContextARM);

            _TargetResourceGroup = new ResourceGroup(this._AzureContextARM, "Target Resource Group");

            this.TemplateGenerator = new ArmToArmGenerator(_AzureContextARM.AzureSubscription, _AzureContextARM.AzureSubscription, _TargetResourceGroup, LogProvider, StatusProvider, _telemetryProvider, _appSettingsProvider);
        }
예제 #26
0
        /// <summary>
        /// Creates a new EliteDangerousAPI class
        /// </summary>
        /// <param name="services"> ServiceProvider </param>
        public EliteDangerousApi(IServiceProvider services)
        {
            try
            {
                _log = services.GetRequiredService <ILogger <EliteDangerousApi> >();

                Events     = services.GetRequiredService <EventHandler>();
                Ship       = services.GetRequiredService <IShip>();
                Commander  = services.GetRequiredService <ICommander>();
                NavRoute   = services.GetRequiredService <INavRoute>();
                Cargo      = services.GetRequiredService <ICargo>();
                Market     = services.GetRequiredService <IMarket>();
                Modules    = services.GetRequiredService <IModules>();
                Backpack   = services.GetRequiredService <IBackpack>();
                Shipyard   = services.GetRequiredService <IShipyard>();
                Outfitting = services.GetRequiredService <IOutfitting>();
                Bindings   = services.GetRequiredService <IBindings>();

                Version = Assembly.GetExecutingAssembly().GetCustomAttribute <AssemblyInformationalVersionAttribute>()
                          .InformationalVersion.Split('+')[0];

                _config     = services.GetRequiredService <IConfiguration>();
                _codeConfig = services.GetRequiredService <IEliteDangerousApiConfiguration>();

                _eventProvider   = services.GetRequiredService <IEventProvider>();
                _eventProcessors = services.GetRequiredService <IEnumerable <IEventProcessor> >();

                _journalDirectoryProvider = services.GetRequiredService <IJournalDirectoryProvider>();

                _journalProvider  = services.GetRequiredService <IJournalProvider>();
                _journalProcessor = services.GetRequiredService <IJournalProcessor>();

                _statusProvider  = services.GetRequiredService <IStatusProvider>();
                _statusProcessor = services.GetRequiredService <IStatusProcessor>();

                _optionsDirectoryProvider = services.GetRequiredService <IOptionsDirectoryProvider>();
                _optionsProvider          = services.GetRequiredService <IOptionsProvider>();
                _optionsProcessor         = services.GetRequiredService <IOptionsProcessor>();
            }
            catch (Exception ex)
            {
                PreInitializationException = ex;
            }
        }
예제 #27
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }

                _CancelProcessAction = null;

                if (_StatusProvider != null)
                {
                    _StatusProvider.StatusChanged -= ProgressReported;
                    _StatusProvider = null;
                }
            }
            base.Dispose(disposing);
        }
예제 #28
0
        public Window()
        {
            InitializeComponent();
            _logProvider           = new FileLogProvider();
            _statusProvider        = new UIStatusProvider(lblStatus);
            telemetryProvider      = new CloudTelemetryProvider();
            _saveSelectionProvider = new UISaveSelectionProvider();

            Regions = new List <Amazon.RegionEndpoint>();
            foreach (var region in Amazon.RegionEndpoint.EnumerableAllRegions)
            {
                Regions.Add(region);
            }



            //var tokenProvider = new InteractiveTokenProvider();
            //
        }
예제 #29
0
        public static bool TestConection(INetworkCom connection,
                                         string pingCmd,
                                         Predicate <string> pingCorrect,
                                         IStatusProvider status = null)
        {
            //NOTE: status.UpdateStatus is a null safe extension method

            bool successful = false;
            //TelnetCom tc = new SimpleTelnetCom(Board.IpAdress, TelnetPort);
            Why telnetConected = connection.Connect();

            if (telnetConected)
            {
                Task.Delay(500);
                status.UpdateStatus(Status.Done("Coms available: " + connection));
                status.UpdateStatus(Status.Done("Banner data: " + connection.InputBuffer.ToString()));
                successful = true;

                if (!string.IsNullOrEmpty(pingCmd))
                {
                    string telnetResponce = connection.ExecuteCommand(pingCmd);
                    if (pingCorrect != null)
                    {
                        successful = pingCorrect(telnetResponce);
                        status.UpdateStatus(successful ? Status.Done("Telnet test passed: " + telnetResponce) :
                                            Status.Error("Telnet test failed: " + telnetResponce));
                    }
                    else
                    {
                        successful = !string.IsNullOrWhiteSpace(telnetResponce);
                        status.UpdateStatus(successful ? Status.Done("Telnet responded to ping command: " + telnetResponce) :
                                            Status.Error("Telnet didn't respond to ping command: " + telnetResponce));
                    }
                }
            }
            else
            {
                status.UpdateStatus(Status.Error("Telnet un-available: " + telnetConected.Reason ?? "(no information)"));
            }
            return(successful);
        }
예제 #30
0
        private async Task <Application> CollectStatusAsync(HttpContext httpContext)
        {
            var statusPageOptions = httpContext.RequestServices.GetService <StatusPageOptions>();
            var statusProviders   = httpContext.RequestServices.GetServices <IStatusProvider>().ToList();

            IStatusProvider mainStatusProvider = null;

            if (!string.IsNullOrEmpty(statusPageOptions?.Uri))
            {
                mainStatusProvider = new WebServiceStatusProvider(new WebServiceStatusProviderOptions("Main")
                {
                    Uri = statusPageOptions.Uri
                });
                statusProviders.Insert(0, mainStatusProvider);
            }

            await statusProviderCustomization(statusProviders, default);

            var assemblyName = Assembly.GetExecutingAssembly().GetName();

            var checkStatusTasks = statusProviders.Select(p => p.CheckStatusAsync(default));
예제 #31
0
        public void Bind(AzureRetriever azureRetriever, IStatusProvider statusProvider, ILogProvider logProvider, TargetSettings targetSettings, ImageList imageList, PromptBehavior promptBehavior, List <AzureEnvironment> azureEnvironments, ref List <AzureEnvironment> userDefinedAzureEnvironments)
        {
            _TargetSettings = targetSettings;
            _LogProvider    = logProvider;
            _StatusProvider = statusProvider;
            _ImageList      = imageList;

            _AzureContextSource = new AzureContext(azureRetriever, targetSettings, promptBehavior);
            _AzureContextSource.AzureEnvironmentChanged       += _AzureContext_AzureEnvironmentChanged;
            _AzureContextSource.UserAuthenticated             += _AzureContext_UserAuthenticated;
            _AzureContextSource.BeforeAzureSubscriptionChange += _AzureContext_BeforeAzureSubscriptionChange;
            _AzureContextSource.AfterAzureSubscriptionChange  += _AzureContext_AfterAzureSubscriptionChange;
            _AzureContextSource.BeforeUserSignOut             += _AzureContext_BeforeUserSignOut;
            _AzureContextSource.AfterUserSignOut              += _AzureContext_AfterUserSignOut;
            _AzureContextSource.AfterAzureTenantChange        += _AzureContext_AfterAzureTenantChange;
            _AzureContextSource.BeforeAzureTenantChange       += _AzureContextSource_BeforeAzureTenantChange;
            azureLoginContextViewerSource.AfterContextChanged += AzureLoginContextViewerSource_AfterContextChanged;

            azureLoginContextViewerSource.Bind(_AzureContextSource, azureRetriever, azureEnvironments, ref userDefinedAzureEnvironments);
            treeViewSourceResourceManager1.Bind(logProvider, statusProvider, targetSettings, imageList, promptBehavior);
        }
예제 #32
0
        public static void DownloadContent(IAdditionalContent content, IStatusProvider statusForm)
        {
            if (DownloadsEnabled && !IsDownloadingContent(content))
            {
                if (!content.CurrentUserCanDownload)
                {
                    if (statusForm != null)
                    {
                        statusForm.SetStatus("<LOC>You do not have permission to download this content.", 0xbb8, new object[0]);
                    }
                }
                else
                {
                    ThreadPool.QueueUserWorkItem(delegate (object s) {
                        int @int = ConfigSettings.GetInt("MaxDailyVaultDownload", 5);
                        if (!User.Current.IsAdmin && (DailyDownloadCount >= @int))
                        {
                            string message = string.Format(Loc.Get("<LOC>You have reached the maximum number of downloads allowed per day. You are allowed up to {0} downloads in any 24 hour period."), @int);
                            if (statusForm == null)
                            {
                                DlgMessage.ShowDialog(message);
                            }
                            else
                            {
                                statusForm.SetStatus(message, 0x1388, new object[0]);
                            }
                        }
                        else
                        {
                            IVaultOperation operation;
                            if (!content.HasVolunteeredForDownload)
                            {
                                if (DlgMessage.ShowDialog("<LOC>To download this file you must first agree to its legal conditions by volunteering to download it. Click OK to continue to the volunteer form.") != DialogResult.OK)
                                {
                                    return;
                                }
                                OGen0 method = null;
                                VolunteerEffort effort;
                                if (new QuazalQuery("GetVolunteerEffortByName", new object[] { content.DownloadVolunteerEffort }).GetObject<VolunteerEffort>(out effort))
                                {
                                    if (method == null)
                                    {
                                        method = delegate {
                                            if (new DlgVolunteer(effort).ShowDialog() == DialogResult.OK)
                                            {
                                                content.HasVolunteeredForDownload = true;
                                                return true;
                                            }
                                            return false;
                                        };
                                    }
                                    if (!((bool) Program.MainForm.Invoke(method)))
                                    {
                                        return;
                                    }
                                }
                            }
                            mDownloadTarget = content;
                            if ((content.ContentDependencies != null) && (content.ContentDependencies.Length > 0))
                            {
                                List<int> missing = new List<int>();
                                Dictionary<int, IAdditionalContent> dictionary = new Dictionary<int, IAdditionalContent>(MyContent.Count);
                                foreach (IAdditionalContent content1 in MyContent)
                                {
                                    dictionary[content1.ID] = content1;
                                }
                                foreach (int num2 in content.ContentDependencies)
                                {
                                    if (!dictionary.ContainsKey(num2))
                                    {
                                        missing.Add(num2);
                                    }
                                }
                                if (missing.Count > 0)
                                {
                                    DialogResult result = DialogResult.No;
                                    Program.MainForm.Invoke((VGen0)delegate {
                                        result = new DlgYesNoCancel("<LOC>Content Dependency", string.Format(Loc.Get("<LOC>The requested {0} is dependent on {1} additional vaulted download(s) that you do not have and may not operate properly without them. GPGnet can download these for you now, or you can manually download them later. Do you want GPGnet to download these dependencies now?"), content.ContentType.SingularDisplayName.ToLower(), missing.Count)).ShowDialog();
                                    });
                                    switch (result)
                                    {
                                        case DialogResult.Yes:
                                            foreach (int num3 in missing)
                                            {
                                                DownloadContent(num3, statusForm);
                                            }
                                            break;

                                        case DialogResult.Cancel:
                                            return;
                                    }
                                }
                            }
                            if (!content.IsDirectHTTPDownload)
                            {
                                operation = new VaultDownloadOperation(content);
                            }
                            else
                            {
                                operation = new VaultDirectDownloadOperation(content);
                            }
                            if (BeginDownloadContent != null)
                            {
                                BeginDownloadContent(new ContentOperationCallbackArgs(content, operation));
                            }
                            operation.OperationFinished += new ContentOperationCallback(AdditionalContent.DownloadOperation_Finished);
                            operation.Start();
                        }
                    });
                }
            }
        }
예제 #33
0
 public static void UploadContent(IAdditionalContent content, IStatusProvider initialForm)
 {
     if (!content.CurrentUserIsOwner && !content.IsContentUnique())
     {
         if (initialForm != null)
         {
             initialForm.SetStatus("<LOC>Unable to upload, a {0} by this name already exists", 0xbb8, new object[] { content.ContentType.SingularDisplayName.ToLower() });
         }
     }
     else if (!content.CurrentUserCanUpload)
     {
         if (initialForm != null)
         {
             initialForm.SetStatus("<LOC>You do not have permission to upload this content type.", 0xbb8, new object[0]);
         }
     }
     else
     {
         mUploadingContent = true;
         ThreadPool.QueueUserWorkItem(delegate (object s) {
             content.Version++;
             IVaultOperation activityMonitor = null;
             if ((content is IFTPInfo) && (content as IFTPInfo).UploadFTP())
             {
                 activityMonitor = new VaultFTPUploadOperation(content);
             }
             else
             {
                 activityMonitor = new VaultUploadOperation(content);
             }
             if (BeginUploadContent != null)
             {
                 BeginUploadContent(new ContentOperationCallbackArgs(content, activityMonitor));
             }
             activityMonitor.OperationFinished += new ContentOperationCallback(AdditionalContent.UploadOperation_Finished);
             activityMonitor.Start();
         });
     }
 }
예제 #34
0
 public static void DownloadUpdate(int contentId, IStatusProvider statusForm)
 {
     if (DownloadsEnabled && !IsDownloadingContent(contentId))
     {
         if (statusForm != null)
         {
             statusForm.SetStatus(Loc.Get("<LOC>Locating content..."), new object[0]);
         }
         int @int = new QuazalQuery("GetContentTypeById", new object[] { contentId }).GetInt();
         if (@int < 0)
         {
             if (statusForm != null)
             {
                 statusForm.SetStatus("<LOC>An error occurred while downloading file, please try again.", 0xbb8, new object[0]);
             }
         }
         else
         {
             IAdditionalContent content;
             if (!GPG.Multiplayer.Client.Vaulting.ContentType.FromID(@int).CreateInstance().FromID(contentId, out content))
             {
                 if (statusForm != null)
                 {
                     statusForm.SetStatus("<LOC>An error occurred while downloading file, please try again.", 0xbb8, new object[0]);
                 }
             }
             else
             {
                 DownloadContent(content, statusForm);
             }
         }
     }
 }
예제 #35
0
 public static void ProcessLadderQueue(IStatusProvider statusProvider)
 {
     try
     {
         StatusProvider = statusProvider;
         mHasErrors = false;
         DateTime dateTime = ConfigSettings.GetDateTime("LastLadderJoinProc", DateTime.UtcNow);
         TimeSpan span = TimeSpan.FromMinutes((double) ConfigSettings.GetInt("LadderJoinInterval", 5));
         if ((DateTime.UtcNow - dateTime) >= span)
         {
             ProcessLadderJoins();
             if (!new QuazalQuery("SetLadderConfig", new object[] { "LastLadderJoinProc", DataAccess.FormatDate(DateTime.UtcNow) }).ExecuteNonQuery())
             {
                 Error("Failed to update the last process time for joins", new object[0]);
             }
         }
         else
         {
             object[] args = new object[1];
             TimeSpan span6 = (TimeSpan) (DateTime.UtcNow - dateTime);
             args[0] = Math.Round((double) (span.TotalMinutes - span6.TotalMinutes), 2);
             Status("Skipping joins processing for the next {0} minutes", args);
         }
         DateTime time2 = ConfigSettings.GetDateTime("LastLadderReportsProc", DateTime.UtcNow);
         TimeSpan span2 = TimeSpan.FromMinutes((double) ConfigSettings.GetInt("LadderReportsInterval", 10));
         if ((DateTime.UtcNow - time2) >= span2)
         {
             ProcessLadderReports();
             if (!new QuazalQuery("SetLadderConfig", new object[] { "LastLadderReportsProc", DataAccess.FormatDate(DateTime.UtcNow) }).ExecuteNonQuery())
             {
                 Error("Failed to update the last process time for reports", new object[0]);
             }
         }
         else
         {
             object[] objArray4 = new object[1];
             TimeSpan span7 = (TimeSpan) (DateTime.UtcNow - time2);
             objArray4[0] = Math.Round((double) (span2.TotalMinutes - span7.TotalMinutes), 2);
             Status("Skipping reports processing for the next {0} minutes", objArray4);
         }
         DateTime time3 = ConfigSettings.GetDateTime("LastLadderRemovalProc", DateTime.UtcNow);
         TimeSpan span3 = TimeSpan.FromMinutes((double) ConfigSettings.GetInt("LadderRemovalInterval", 15));
         if ((DateTime.UtcNow - time3) >= span3)
         {
             ProcessLadderRemovals();
             if (!new QuazalQuery("SetLadderConfig", new object[] { "LastLadderRemovalProc", DataAccess.FormatDate(DateTime.UtcNow) }).ExecuteNonQuery())
             {
                 Error("Failed to update the last process time for removals", new object[0]);
             }
         }
         else
         {
             object[] objArray6 = new object[1];
             TimeSpan span8 = (TimeSpan) (DateTime.UtcNow - time3);
             objArray6[0] = Math.Round((double) (span3.TotalMinutes - span8.TotalMinutes), 2);
             Status("Skipping removals processing for the next {0} minutes", objArray6);
         }
         DateTime time4 = ConfigSettings.GetDateTime("LastLadderDegradeProc", DateTime.UtcNow);
         TimeSpan span4 = TimeSpan.FromMinutes((double) ConfigSettings.GetInt("LadderDegradeInterval", 60));
         if ((DateTime.UtcNow - time4) >= span4)
         {
             ProcessLadderDegradation();
             if (!new QuazalQuery("SetLadderConfig", new object[] { "LastLadderDegradeProc", DataAccess.FormatDate(DateTime.UtcNow) }).ExecuteNonQuery())
             {
                 Error("Failed to update the last process time for degradation", new object[0]);
             }
         }
         else
         {
             object[] objArray8 = new object[1];
             TimeSpan span9 = (TimeSpan) (DateTime.UtcNow - time4);
             objArray8[0] = Math.Round((double) (span4.TotalMinutes - span9.TotalMinutes), 2);
             Status("Skipping degradation processing for the next {0} minutes", objArray8);
         }
         DateTime time5 = ConfigSettings.GetDateTime("LastLadderSessionsProc", DateTime.UtcNow);
         TimeSpan span5 = TimeSpan.FromMinutes((double) ConfigSettings.GetInt("LadderSessionsInterval", 180));
         if ((DateTime.UtcNow - time5) >= span5)
         {
             ProcessStaleGameSessions();
             if (!new QuazalQuery("SetLadderConfig", new object[] { "LastLadderSessionsProc", DataAccess.FormatDate(DateTime.UtcNow) }).ExecuteNonQuery())
             {
                 Error("Failed to update the last process time for stale sessions", new object[0]);
             }
         }
         else
         {
             object[] objArray10 = new object[1];
             TimeSpan span10 = (TimeSpan) (DateTime.UtcNow - time5);
             objArray10[0] = Math.Round((double) (span5.TotalMinutes - span10.TotalMinutes), 2);
             Status("Skipping stale sessions processing for the next {0} minutes", objArray10);
         }
     }
     catch (Exception exception)
     {
         Error("Error processing ladder queue", new object[0]);
         Error(exception);
     }
 }
예제 #36
0
 private void operation_StatusChanged(IStatusProvider sender, string status)
 {
     VGen0 method = null;
     if ((base.InvokeRequired && !base.Disposing) && !base.IsDisposed)
     {
         if (method == null)
         {
             method = delegate {
                 this.operation_StatusChanged(sender, status);
             };
         }
         base.BeginInvoke(method);
     }
     else if (!(base.Disposing || base.IsDisposed))
     {
         this.gpgLabelStatus.Text = Loc.Get(status);
     }
 }
예제 #37
0
파일: Mod.cs 프로젝트: micheljung/gpgnetfix
 public bool SaveDownload(IStatusProvider statusProvider)
 {
     if (!base.ContentType.CurrentUserCanDownload)
     {
         if (statusProvider != null)
         {
             statusProvider.SetStatus("<LOC>You do not have permission to download this content", new object[0]);
         }
         return false;
     }
     try
     {
         string downloadPath = this.GetDownloadPath();
         string path = downloadPath + @"\content.partial";
         bool flag = false;
         foreach (string str3 in Directory.GetDirectories(this.GetDownloadPath(true)))
         {
             if (!(str3 == downloadPath))
             {
                 flag = true;
                 Directory.Delete(str3, true);
             }
         }
         foreach (string str4 in Directory.GetFiles(this.GetDownloadPath(true), "*.*", SearchOption.TopDirectoryOnly))
         {
             flag = true;
             System.IO.File.Delete(str4);
         }
         if (flag)
         {
             AdditionalContent.DeleteMyContent(this, true, false, true);
             foreach (IAdditionalContent content in AdditionalContent.MyContent.ToArray())
             {
                 if (((content.TypeID == base.TypeID) && (content.Name == base.Name)) && (content.Version != base.Version))
                 {
                     AdditionalContent.MyContent.Remove(content);
                 }
             }
         }
         if (!System.IO.File.Exists(path))
         {
             ErrorLog.WriteLine("The expected download file: {0} was not found.", new object[] { path });
             if (statusProvider != null)
             {
                 statusProvider.SetStatus("<LOC>An error occurred while downloading file, please try again.", 0xbb8, new object[0]);
             }
             return false;
         }
         statusProvider.SetStatus("<LOC>Extracting File(s)...", new object[0]);
         Compression.Unzip(path, this.GetDownloadPath(true));
         if (!Directory.Exists(this.GetDownloadPath()))
         {
             Directory.CreateDirectory(this.GetDownloadPath());
         }
         System.IO.File.WriteAllText(Path.Combine(this.GetDownloadPath(), string.Format("{0}.version", this.ModName)), "Do not delete this file, it is required to maintain this mod's version");
         Thread.Sleep(50);
         DateTime now = DateTime.Now;
         while (System.IO.File.Exists(path))
         {
             try
             {
                 System.IO.File.Delete(path);
             }
             catch
             {
                 if ((DateTime.Now - now) > TimeSpan.FromSeconds(3.0))
                 {
                     break;
                 }
                 Thread.Sleep(50);
             }
         }
         return true;
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
         return false;
     }
 }
예제 #38
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if(components != null)
                {
                    components.Dispose();
                }

                _CancelProcessAction = null;

                if(_StatusProvider != null)
                {
                    _StatusProvider.StatusChanged -= ProgressReported;
                    _StatusProvider = null;
                }
            }
            base.Dispose(disposing);
        }
예제 #39
0
 public static void CalculateAvatars(IStatusProvider statusProvider)
 {
     DateTime now = DateTime.Now;
     StringBuilder sql = new StringBuilder(100);
     ClearCachedData();
     try
     {
         if (statusProvider != null)
         {
             statusProvider.SetStatus("Clearing old temp data if it exists", new object[0]);
         }
         Thread.Sleep(500);
         sql.AppendFormat("DROP TABLE IF EXISTS temp_player_ids;", new object[0]);
         sql.AppendFormat("DROP TABLE IF EXISTS old_player_avatar;", new object[0]);
         sql.AppendFormat("DROP TABLE IF EXISTS temp_player_avatar;", new object[0]);
         sql.AppendFormat("DROP TABLE IF EXISTS temp_tournament_results;", new object[0]);
         sql.AppendFormat("CREATE TABLE temp_player_ids (", new object[0]);
         sql.AppendFormat("player_id INTEGER UNSIGNED NOT NULL,", new object[0]);
         sql.AppendFormat("PRIMARY KEY(player_id)", new object[0]);
         sql.AppendFormat(") SELECT principal AS player_id FROM principal_info;", new object[0]);
         ExecuteQuery(sql);
         sql.AppendFormat("CREATE TABLE temp_tournament_results ", new object[0]);
         sql.AppendFormat("SELECT tournaments.tournament_id, new.principal_id, ", new object[0]);
         sql.AppendFormat("(SELECT count(*) FROM tournament_round old WHERE old.tournament_id = tournaments.tournament_id AND ", new object[0]);
         sql.AppendFormat("old.round = tournaments.round AND ", new object[0]);
         sql.AppendFormat("( (old.wins + (0.5 * old.draws)) >  (new.wins + (0.5 * new.draws))  OR ", new object[0]);
         sql.AppendFormat("( (old.wins + (0.5 * old.draws)) =  (new.wins + (0.5 * new.draws)) AND (old.seed < new.seed) ) ) ) + 1 as finish_pos ", new object[0]);
         sql.AppendFormat("FROM tournaments, tournament_round new ", new object[0]);
         sql.AppendFormat("WHERE ", new object[0]);
         sql.AppendFormat("tournaments.tournament_id = new.tournament_id ", new object[0]);
         sql.AppendFormat("AND ", new object[0]);
         sql.AppendFormat("tournaments.round = new.round ", new object[0]);
         sql.AppendFormat("ORDER BY tournaments.tournament_id DESC, (wins + (0.5 * draws)) DESC, seed ASC;", new object[0]);
         sql.AppendFormat("ALTER TABLE temp_tournament_results ADD index temp_tournament_results_ix1 (principal_id, finish_pos);", new object[0]);
         ExecuteQuery(sql);
         if (statusProvider != null)
         {
             statusProvider.SetStatus("Creating temp schema for avatars", new object[0]);
         }
         Thread.Sleep(500);
         sql.AppendFormat("CREATE TABLE temp_player_avatar (", new object[0]);
         sql.AppendFormat("player_avatar_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,", new object[0]);
         sql.AppendFormat("player_id INTEGER UNSIGNED NULL,", new object[0]);
         sql.AppendFormat("avatar_id INTEGER UNSIGNED NULL,", new object[0]);
         sql.AppendFormat("manual_assignment BOOL NULL DEFAULT 0,", new object[0]);
         sql.AppendFormat("PRIMARY KEY(player_avatar_id),", new object[0]);
         sql.AppendFormat("UNIQUE INDEX temp_player_avatar_index3199(player_id, avatar_id),", new object[0]);
         sql.AppendFormat("INDEX temp_player_avatar_index3203(avatar_id),", new object[0]);
         sql.AppendFormat("INDEX temp_player_avatar_index3208(manual_assignment)", new object[0]);
         sql.AppendFormat(") SELECT * FROM player_avatar WHERE manual_assignment = 1;", new object[0]);
         ExecuteQuery(sql);
         foreach (Avatar avatar in AllAvatars.Values)
         {
             if (((avatar.AchievementQuery != null) && (avatar.AchievementQuery.Length >= 1)) && (avatar.AchievementQuery != "(null)"))
             {
                 DateTime time2 = DateTime.Now;
                 if (statusProvider != null)
                 {
                     statusProvider.SetStatus("Calculating achievement status for avatar: {0}", new object[] { avatar.Description });
                 }
                 sql.AppendFormat("INSERT INTO temp_player_avatar (player_id, avatar_id, manual_assignment) (SELECT player_id, {0}, 0 FROM temp_player_ids WHERE ({1}) > 0);", avatar.ID, avatar.AchievementQuery);
                 ExecuteQuery(sql);
                 TimeSpan span = (TimeSpan) (DateTime.Now - time2);
                 if (statusProvider != null)
                 {
                     statusProvider.SetStatus("Finished calculating avatar: {0} in {1} seconds", new object[] { avatar.Description, span.TotalSeconds });
                 }
                 Thread.Sleep(500);
             }
         }
         if (statusProvider != null)
         {
             statusProvider.SetStatus("Removing unachieved display avatars", new object[0]);
         }
         sql.AppendFormat("UPDATE player_display_awards SET avatar = 0 WHERE ", new object[0]);
         sql.AppendFormat("(SELECT COUNT(*) FROM temp_player_avatar WHERE ", new object[0]);
         sql.AppendFormat("temp_player_avatar.player_id = player_display_awards.player_id AND ", new object[0]);
         sql.AppendFormat("temp_player_avatar.avatar_id = player_display_awards.avatar) = 0;", new object[0]);
         ExecuteQuery(sql);
         if (statusProvider != null)
         {
             statusProvider.SetStatus("Moving temp avatar data to live data", new object[0]);
         }
         Thread.Sleep(0x3e8);
         sql.AppendFormat("RENAME TABLE player_avatar TO old_player_avatar, temp_player_avatar TO player_avatar;", new object[0]);
         ExecuteQuery(sql);
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine("Failed to calculate player awards due to the following exception:", new object[0]);
         ErrorLog.WriteLine(exception);
     }
     finally
     {
         if (statusProvider != null)
         {
             statusProvider.SetStatus("Deleting old data", new object[0]);
         }
         sql.AppendFormat("DROP TABLE IF EXISTS old_player_avatar;", new object[0]);
         sql.AppendFormat("DROP TABLE IF EXISTS temp_player_ids;", new object[0]);
         sql.AppendFormat("DROP TABLE IF EXISTS temp_tournament_results;", new object[0]);
         ExecuteQuery(sql);
         TimeSpan span2 = (TimeSpan) (DateTime.Now - now);
         if (statusProvider != null)
         {
             statusProvider.SetStatus("Awards processing completed in {0} seconds", 0x1388, new object[] { span2.TotalSeconds });
         }
     }
 }
예제 #40
0
		public StatusUpdaterService() {
			_nestWebService = ServiceContainer.GetService<INestWebService>();
			_delayedStatusProvider = ServiceContainer.GetService<IStatusProvider>();
			_updateStatusTimer = ServiceContainer.GetService<ITimer>();
			_updateStatusTimer.SetCallback(OnTimerTick);
		}
예제 #41
0
 public static void CheckForUpdates(IAdditionalContent content, IStatusProvider statusProvider)
 {
     if ((!CheckingforUpdates && DownloadsEnabled) && !IsDownloadingContent(content))
     {
         ThreadPool.QueueUserWorkItem(delegate (object s) {
             try
             {
                 mCheckingForUpdates = true;
                 statusProvider.SetStatus("<LOC>Checking for updates...", new object[0]);
                 if (BeginCheckForUpdates != null)
                 {
                     BeginCheckForUpdates(new ContentOperationCallbackArgs(content, null));
                 }
                 DataList data = new QuazalQuery("GetLatestContentVersion", new object[] { content.Name, content.TypeID }).GetData();
                 if (data.Count < 1)
                 {
                     statusProvider.SetStatus("<LOC>No updates found.", 0xbb8, new object[0]);
                     mCheckingForUpdates = false;
                     if (FinishCheckForUpdates != null)
                     {
                         FinishCheckForUpdates(new ContentOperationCallbackArgs(content, null, false, new object[0]));
                     }
                 }
                 else
                 {
                     int contentId = int.Parse(data[0]["content_id"]);
                     int num2 = int.Parse(data[0]["version"]);
                     if ((int.Parse(data[0]["has_current"]) > 0) || (content.Version == num2))
                     {
                         statusProvider.SetStatus("<LOC>{0} is up to date.", 0xbb8, new object[] { content.Name });
                         mCheckingForUpdates = false;
                         if (FinishCheckForUpdates != null)
                         {
                             FinishCheckForUpdates(new ContentOperationCallbackArgs(content, null, true, new object[0]));
                         }
                     }
                     else
                     {
                         statusProvider.SetStatus("<LOC>Update found, preparing to download...", new object[0]);
                         FinishDownloadContent = (ContentOperationCallback) Delegate.Combine(FinishDownloadContent, new ContentOperationCallback(AdditionalContent.AdditionalContent_FinishDownloadContent));
                         DownloadUpdate(contentId, statusProvider);
                         mCheckingForUpdates = false;
                         if (FinishCheckForUpdates != null)
                         {
                             FinishCheckForUpdates(new ContentOperationCallbackArgs(content, null, true, new object[0]));
                         }
                     }
                 }
             }
             catch (Exception exception)
             {
                 ErrorLog.WriteLine(exception);
                 statusProvider.SetStatus("<LOC>An error occurred while checking for updates, please try again.", 0xbb8, new object[0]);
                 mCheckingForUpdates = false;
                 if (FinishCheckForUpdates != null)
                 {
                     FinishCheckForUpdates(new ContentOperationCallbackArgs(content, null, true, new object[0]));
                 }
             }
         });
     }
 }
예제 #42
0
 public static void ReCalculateAllAwards(IStatusProvider statusProvider)
 {
     DateTime now = DateTime.Now;
     StringBuilder sql = new StringBuilder(100);
     string str = "temp_player_awards";
     string str2 = "old_player_awards";
     Avatar.ClearCachedData();
     AwardCategory.ClearCachedData();
     AwardSet.ClearCachedData();
     GPG.Multiplayer.Statistics.Award.ClearCachedData();
     try
     {
         if (statusProvider != null)
         {
             statusProvider.SetStatus("Clearing old temp data if it exists", new object[0]);
         }
         Thread.Sleep(500);
         sql.AppendFormat("DROP TABLE IF EXISTS temp_player_ids;", new object[0]);
         sql.AppendFormat("DROP TABLE IF EXISTS {0};", str2);
         sql.AppendFormat("DROP TABLE IF EXISTS {0};", str);
         sql.AppendFormat("DROP TABLE IF EXISTS old_player_avatar;", new object[0]);
         sql.AppendFormat("DROP TABLE IF EXISTS temp_player_avatar;", new object[0]);
         sql.AppendFormat("DROP TABLE IF EXISTS temp_tournament_results;", new object[0]);
         sql.AppendFormat("CREATE TABLE temp_player_ids (", new object[0]);
         sql.AppendFormat("player_id INTEGER UNSIGNED NOT NULL,", new object[0]);
         sql.AppendFormat("PRIMARY KEY(player_id)", new object[0]);
         sql.AppendFormat(") SELECT principal AS player_id FROM principal_info;", new object[0]);
         ExecuteQuery(sql);
         sql.AppendFormat("UPDATE tournaments SET round = (SELECT max(wins + losses + draws) FROM tournament_round WHERE tournament_round.tournament_id = tournaments.tournament_id) WHERE (SELECT max(wins + losses + draws) FROM tournament_round WHERE tournament_round.tournament_id = tournaments.tournament_id) is not null", new object[0]);
         ExecuteQuery(sql);
         sql.AppendFormat("CREATE TABLE temp_tournament_results ", new object[0]);
         sql.AppendFormat("SELECT tournaments.tournament_id, new.principal_id, ", new object[0]);
         sql.AppendFormat("(SELECT count(*) FROM tournament_round old WHERE old.tournament_id = tournaments.tournament_id AND ", new object[0]);
         sql.AppendFormat("old.round = tournaments.round AND ", new object[0]);
         sql.AppendFormat("( (old.wins + (0.5 * old.draws)) >  (new.wins + (0.5 * new.draws))  OR ", new object[0]);
         sql.AppendFormat("( (old.wins + (0.5 * old.draws)) =  (new.wins + (0.5 * new.draws)) AND (old.seed < new.seed) ) ) ) + 1 as finish_pos ", new object[0]);
         sql.AppendFormat("FROM tournaments, tournament_round new ", new object[0]);
         sql.AppendFormat("WHERE ", new object[0]);
         sql.AppendFormat("tournaments.tournament_id = new.tournament_id ", new object[0]);
         sql.AppendFormat("AND ", new object[0]);
         sql.AppendFormat("tournaments.round = new.round ", new object[0]);
         sql.AppendFormat("ORDER BY tournaments.tournament_id DESC, (wins + (0.5 * draws)) DESC, seed ASC;", new object[0]);
         sql.AppendFormat("ALTER TABLE temp_tournament_results ADD index temp_tournament_results_ix1 (principal_id, finish_pos);", new object[0]);
         ExecuteQuery(sql);
         if (statusProvider != null)
         {
             statusProvider.SetStatus("Creating temp schema for avatars", new object[0]);
         }
         Thread.Sleep(500);
         sql.AppendFormat("CREATE TABLE temp_player_avatar (", new object[0]);
         sql.AppendFormat("player_avatar_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,", new object[0]);
         sql.AppendFormat("player_id INTEGER UNSIGNED NULL,", new object[0]);
         sql.AppendFormat("avatar_id INTEGER UNSIGNED NULL,", new object[0]);
         sql.AppendFormat("manual_assignment BOOL NULL DEFAULT 0,", new object[0]);
         sql.AppendFormat("PRIMARY KEY(player_avatar_id),", new object[0]);
         sql.AppendFormat("UNIQUE INDEX temp_player_avatar_index3199(player_id, avatar_id),", new object[0]);
         sql.AppendFormat("INDEX temp_player_avatar_index3203(avatar_id),", new object[0]);
         sql.AppendFormat("INDEX temp_player_avatar_index3208(manual_assignment)", new object[0]);
         sql.AppendFormat(");", new object[0]);
         ExecuteQuery(sql);
         foreach (Avatar avatar in Avatar.AllAvatars.Values)
         {
             if (((avatar.AchievementQuery != null) && (avatar.AchievementQuery.Length >= 1)) && (avatar.AchievementQuery != "(null)"))
             {
                 DateTime time2 = DateTime.Now;
                 if (statusProvider != null)
                 {
                     statusProvider.SetStatus("Calculating achievement status for avatar: {0}", new object[] { avatar.Description });
                 }
                 sql.AppendFormat("INSERT INTO temp_player_avatar (player_id, avatar_id, manual_assignment) (SELECT player_id, {0}, 0 FROM temp_player_ids WHERE ({1}) > 0);", avatar.ID, avatar.AchievementQuery);
                 ExecuteQuery(sql);
                 TimeSpan span = (TimeSpan) (DateTime.Now - time2);
                 if (statusProvider != null)
                 {
                     statusProvider.SetStatus("Finished calculating avatar: {0} in {1} seconds", new object[] { avatar.Description, span.TotalSeconds });
                 }
                 Thread.Sleep(500);
             }
         }
         if (statusProvider != null)
         {
             statusProvider.SetStatus("Fetching manual assigments for avatars.", new object[0]);
         }
         sql.AppendFormat("REPLACE INTO temp_player_avatar (player_id, avatar_id, manual_assignment) ", new object[0]);
         sql.AppendFormat("SELECT player_id, avatar_id, manual_assignment FROM player_avatar WHERE manual_assignment = 1", new object[0]);
         ExecuteQuery(sql);
         if (statusProvider != null)
         {
             statusProvider.SetStatus("Clearing player_avatars where the avatar no longer exists for the player.", new object[0]);
         }
         sql.AppendFormat("UPDATE player_display_awards ", new object[0]);
         sql.AppendFormat("LEFT OUTER JOIN temp_player_avatar ON ", new object[0]);
         sql.AppendFormat("  player_display_awards.avatar = temp_player_avatar.avatar_id AND player_display_awards.player_id = temp_player_avatar.player_id ", new object[0]);
         sql.AppendFormat("SET player_display_awards.avatar = temp_player_avatar.avatar_id ", new object[0]);
         ExecuteQuery(sql);
         if (statusProvider != null)
         {
             statusProvider.SetStatus("Moving temp avatar data to live data", new object[0]);
         }
         Thread.Sleep(0x3e8);
         sql.AppendFormat("RENAME TABLE player_avatar TO old_player_avatar, temp_player_avatar TO player_avatar;", new object[0]);
         ExecuteQuery(sql);
         if (statusProvider != null)
         {
             statusProvider.SetStatus("Creating temp schema for awards", new object[0]);
         }
         sql.AppendFormat("CREATE TABLE {0} (", str);
         sql.AppendFormat("player_award_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,", new object[0]);
         sql.AppendFormat("player_id INTEGER UNSIGNED NULL,", new object[0]);
         sql.AppendFormat("award_id INTEGER UNSIGNED NULL,", new object[0]);
         sql.AppendFormat("progress INTEGER UNSIGNED NULL DEFAULT 0,", new object[0]);
         sql.AppendFormat("is_achieved BOOL NULL DEFAULT 0,", new object[0]);
         sql.AppendFormat("show_progress BOOL NULL DEFAULT 0,", new object[0]);
         sql.AppendFormat("PRIMARY KEY(player_award_id),", new object[0]);
         sql.AppendFormat("INDEX temp_player_award_status_index3095(player_id),", new object[0]);
         sql.AppendFormat("INDEX temp_player_award_status_index3101(is_achieved),", new object[0]);
         sql.AppendFormat("INDEX temp_player_award_status_index3102(show_progress),", new object[0]);
         sql.AppendFormat("UNIQUE INDEX temp_player_award_index3141(player_id, award_id)", new object[0]);
         sql.AppendFormat(");", new object[0]);
         ExecuteQuery(sql);
         if (statusProvider != null)
         {
             statusProvider.SetStatus("Creating temp units agg table", new object[0]);
         }
         sql.AppendFormat("DROP TABLE IF EXISTS temp_player_units;", new object[0]);
         sql.AppendFormat("CREATE TABLE temp_player_units (", new object[0]);
         sql.AppendFormat("principal_id INT NOT NULL,", new object[0]);
         sql.AppendFormat("amount INT NOT NULL,", new object[0]);
         sql.AppendFormat("category VARCHAR(10) NOT NULL,", new object[0]);
         sql.AppendFormat("PRIMARY KEY(category, principal_id),", new object[0]);
         sql.AppendFormat("INDEX temp_player_units_ix1(category, amount, principal_id)", new object[0]);
         sql.AppendFormat(");", new object[0]);
         ExecuteQuery(sql);
         sql.AppendFormat("INSERT INTO temp_player_units (category, principal_id, amount) ", new object[0]);
         sql.AppendFormat("(SELECT 'aeonexp', principal_id, SUM(built) FROM player_units  WHERE unit_id in ('UAL0401', 'UAS0401', 'UAA0310') GROUP BY principal_id);", new object[0]);
         ExecuteQuery(sql);
         sql.AppendFormat("INSERT INTO temp_player_units (category, principal_id, amount) ", new object[0]);
         sql.AppendFormat("(SELECT 'cybranexp', principal_id, SUM(built) FROM player_units  WHERE unit_id in ('URA0401', 'URL0401', 'URL0402') GROUP BY principal_id);", new object[0]);
         ExecuteQuery(sql);
         sql.AppendFormat("INSERT INTO temp_player_units (category, principal_id, amount) ", new object[0]);
         sql.AppendFormat("(SELECT 'uefexp', principal_id, SUM(built) FROM player_units  WHERE unit_id in ('UEB2401', 'UEL0401', 'UES0401') GROUP BY principal_id);", new object[0]);
         ExecuteQuery(sql);
         sql.AppendFormat("INSERT INTO temp_player_units (category, principal_id, amount) ", new object[0]);
         sql.AppendFormat("(SELECT 'airbuilt', principal_id, SUM(built) FROM player_units  WHERE unit_id like ('URA%') OR unit_id like ('UEA%') OR unit_id like ('UAA%') GROUP BY principal_id);", new object[0]);
         ExecuteQuery(sql);
         sql.AppendFormat("INSERT INTO temp_player_units (category, principal_id, amount) ", new object[0]);
         sql.AppendFormat("(SELECT 'landbuilt', principal_id, SUM(built) FROM player_units  WHERE unit_id like ('URL%') OR unit_id like ('UEL%') OR unit_id like ('UAL%') GROUP BY principal_id);", new object[0]);
         ExecuteQuery(sql);
         sql.AppendFormat("INSERT INTO temp_player_units (category, principal_id, amount) ", new object[0]);
         sql.AppendFormat("(SELECT 'seabuilt', principal_id, SUM(built) FROM player_units  WHERE unit_id like ('URS%') OR unit_id like ('UES%') OR unit_id like ('UAS%') GROUP BY principal_id);", new object[0]);
         ExecuteQuery(sql);
         sql.AppendFormat("INSERT INTO temp_player_units (category, principal_id, amount) ", new object[0]);
         sql.AppendFormat("(SELECT 'built', principal_id, SUM(built) FROM player_units GROUP BY principal_id);", new object[0]);
         ExecuteQuery(sql);
         sql.AppendFormat("INSERT INTO temp_player_units (category, principal_id, amount) ", new object[0]);
         sql.AppendFormat("(SELECT 'killed', principal_id, SUM(killed) FROM player_units GROUP BY principal_id);", new object[0]);
         ExecuteQuery(sql);
         sql.AppendFormat("INSERT INTO temp_player_units (category, principal_id, amount) ", new object[0]);
         sql.AppendFormat("(SELECT 'civkilled', principal_id, SUM(killed) FROM player_units  WHERE unit_id like ('URC%') OR unit_id like ('UEC%') OR unit_id like ('UAC%') GROUP BY principal_id);", new object[0]);
         ExecuteQuery(sql);
         if (statusProvider != null)
         {
             statusProvider.SetStatus("Creating temp ratings table", new object[0]);
         }
         sql.AppendFormat("DROP TABLE IF EXISTS temp_ratings_for_awards;", new object[0]);
         sql.AppendFormat("CREATE TABLE temp_ratings_for_awards SELECT * FROM ratings", new object[0]);
         ExecuteQuery(sql);
         sql.AppendFormat("ALTER TABLE temp_ratings_for_awards ADD INDEX temp_ratings_for_awards_ix1 (principal_id, category, team_name)", new object[0]);
         ExecuteQuery(sql);
         sql.AppendFormat("ALTER TABLE temp_ratings_for_awards ADD INDEX temp_ratings_for_awards_ix2 (rank, category, principal_id", new object[0]);
         ExecuteQuery(sql);
         sql.AppendFormat("ALTER TABLE temp_ratings_for_awards ADD INDEX temp_ratings_for_awards_ix3 (team_name, principal_id, category)", new object[0]);
         ExecuteQuery(sql);
         foreach (GPG.Multiplayer.Statistics.Award award in GPG.Multiplayer.Statistics.Award.AllAwards.Values)
         {
             if ((award.AchievementQuery == null) || (award.AchievementQuery.Length <= 0))
             {
                 continue;
             }
             DateTime time3 = DateTime.Now;
             if (award.AwardSet != null)
             {
                 if (statusProvider != null)
                 {
                     statusProvider.SetStatus("Calculating achievement status for award: {0}, {1}", new object[] { award.AwardSet.Name, award.AwardDegree });
                 }
             }
             else if (statusProvider != null)
             {
                 statusProvider.SetStatus("Calculating achievement status for award: {0}, {1}", new object[] { "Unknown Award Set", award.AwardDegree });
             }
             string str3 = award.AchievementQuery.Replace("ratings", "temp_ratings_for_awards");
             sql.AppendFormat("INSERT INTO {0} (player_id, award_id, is_achieved) (SELECT player_id, {1}, 1 FROM temp_player_ids WHERE ({2}) > 0);", str, award.ID, str3);
             if (statusProvider != null)
             {
                 statusProvider.SetStatus(sql.ToString(), new object[0]);
             }
             ExecuteQuery(sql);
             TimeSpan span2 = (TimeSpan) (DateTime.Now - time3);
             if (statusProvider != null)
             {
                 statusProvider.SetStatus("Finished calculating award: {0}, {1} in {2} seconds", new object[] { award.AwardSet.Name, award.AwardDegree, span2.TotalSeconds });
             }
             Thread.Sleep(500);
         }
         if (statusProvider != null)
         {
             statusProvider.SetStatus("Clearing player_display_awards where the award no longer exists for the player.", new object[0]);
         }
         sql.AppendFormat("UPDATE player_display_awards SET ", new object[0]);
         sql.AppendFormat("award1 = (SELECT award_id FROM {0} WHERE player_display_awards.player_id = {0}.player_id AND award1 = award_id LIMIT 1), ", str);
         sql.AppendFormat("award2 = (SELECT award_id FROM {0} WHERE player_display_awards.player_id = {0}.player_id AND award2 = award_id LIMIT 1), ", str);
         sql.AppendFormat("award3 = (SELECT award_id FROM {0} WHERE player_display_awards.player_id = {0}.player_id AND award3 = award_id LIMIT 1) ", str);
         ExecuteQuery(sql);
         if (statusProvider != null)
         {
             statusProvider.SetStatus("Moving temp data to live data", new object[0]);
         }
         sql.AppendFormat("RENAME TABLE player_award TO {0}, {1} TO player_award;", str2, str);
         ExecuteQuery(sql);
         if (statusProvider != null)
         {
             statusProvider.SetStatus("Inserting Player Display record for new players.", new object[0]);
         }
         sql.AppendFormat("INSERT INTO player_display_awards (player_id) SELECT principal AS player_id FROM principal_info where (SELECT COUNT(*) FROM player_display_awards WHERE player_id = principal) = 0", new object[0]);
         ExecuteQuery(sql);
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine("Failed to calculate player awards due to the following exception:", new object[0]);
         ErrorLog.WriteLine(exception);
     }
     finally
     {
         if (statusProvider != null)
         {
             statusProvider.SetStatus("Deleting old data", new object[0]);
         }
         sql.AppendFormat("DROP TABLE IF EXISTS {0};", str2);
         sql.AppendFormat("DROP TABLE IF EXISTS old_player_avatar;", new object[0]);
         sql.AppendFormat("DROP TABLE IF EXISTS temp_player_ids;", new object[0]);
         sql.AppendFormat("DROP TABLE IF EXISTS temp_ratings_for_awards;", new object[0]);
         ExecuteQuery(sql);
         sql.AppendFormat("DROP TABLE IF EXISTS tournament_final_results;", new object[0]);
         sql.AppendFormat("RENAME TABLE temp_tournament_results TO tournament_final_results", new object[0]);
         ExecuteQuery(sql);
         TimeSpan span3 = (TimeSpan) (DateTime.Now - now);
         if (statusProvider != null)
         {
             statusProvider.SetStatus("Awards processing completed in {0} seconds", 0x1388, new object[] { span3.TotalSeconds });
         }
     }
 }
예제 #43
0
 public bool SaveDownload(IStatusProvider statusProvider)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #44
0
 public bool SaveDownload(IStatusProvider statusProvider)
 {
     Exception exception;
     try
     {
         if (!base.ContentType.CurrentUserCanDownload)
         {
             return false;
         }
         string downloadPath = this.GetDownloadPath();
         string path = string.Format(@"{0}\content.partial", downloadPath);
         if (!File.Exists(path))
         {
             ErrorLog.WriteLine("The expected download file: {0} was not found.", new object[] { path });
             if (statusProvider != null)
             {
                 statusProvider.SetStatus("<LOC>An error occurred while downloading file, please try again.", 0xbb8, new object[0]);
             }
             return false;
         }
         statusProvider.SetStatus("<LOC>Extracting File(s)...", new object[0]);
         Compression.Unzip(path);
         File.Delete(path);
         try
         {
             this.Run();
         }
         catch (Exception exception1)
         {
             exception = exception1;
             ErrorLog.WriteLine(exception);
         }
         return true;
     }
     catch (Exception exception2)
     {
         exception = exception2;
         ErrorLog.WriteLine(exception);
         return false;
     }
 }
예제 #45
0
 public static void InitStatusProvider(IStatusProvider provider)
 {
     StatusProvider = provider;
 }
예제 #46
0
 public bool SaveDownload(IStatusProvider statusProvider)
 {
     try
     {
         string unzipPath;
         if (this.ExtractToSupcom)
         {
             if (((GameInformation.SelectedGame.GameLocation == null) || (GameInformation.SelectedGame.GameLocation.Length < 1)) || !File.Exists(GameInformation.SelectedGame.GameLocation))
             {
                 GameInformation.SelectedGame.GameLocation = null;
                 if (!Program.MainForm.LocateExe("SupremeCommander", true))
                 {
                     return false;
                 }
             }
             unzipPath = Path.GetDirectoryName(GameInformation.SelectedGame.GameLocation);
         }
         else
         {
             unzipPath = this.GetDownloadPath();
         }
         string path = string.Format(@"{0}\content.partial", this.GetDownloadPath());
         if (!File.Exists(path))
         {
             ErrorLog.WriteLine("The expected download file: {0} was not found.", new object[] { path });
             if (statusProvider != null)
             {
                 statusProvider.SetStatus("<LOC>An error occurred while downloading file, please try again.", 0xbb8, new object[0]);
             }
             return false;
         }
         statusProvider.SetStatus("<LOC>Extracting File(s)...", new object[0]);
         Compression.Unzip(path, this.GetDownloadPath());
         File.Delete(path);
         if (this.ExtractToSupcom)
         {
             string sourceFileName = Path.Combine(this.GetDownloadPath(), this.ExeName);
             foreach (string str3 in Directory.GetFiles(this.GetDownloadPath()))
             {
                 if (str3 == sourceFileName)
                 {
                     if (File.Exists(Path.Combine(unzipPath, this.ExeName)))
                     {
                         File.Delete(Path.Combine(unzipPath, this.ExeName));
                     }
                     File.Move(sourceFileName, Path.Combine(unzipPath, this.ExeName));
                 }
             }
             FileUtil.CreateShortcut(Path.Combine(unzipPath, this.ExeName), Path.Combine(this.GetDownloadPath(), base.Name.Trim(Path.GetInvalidPathChars())));
         }
         Program.MainForm.BeginInvoke((VGen0)delegate {
             if (new DlgYesNo(Program.MainForm, "<LOC>Create Shortcut?", "<LOC>Would you like to create a desktop shortcut this tool?").ShowDialog() == DialogResult.Yes)
             {
                 string str = string.Format("{0} v{1}", this.Name, this.Version).Trim(Path.GetInvalidPathChars());
                 FileUtil.CreateShortcut(Path.Combine(unzipPath, this.ExeName), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), str));
             }
         });
         return true;
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
         return false;
     }
 }
예제 #47
0
 public bool SaveDownload(IStatusProvider statusProvider)
 {
     WebDownloader downloader = new WebDownloader();
     downloader.OnDownloadCompleted += new AsyncCompletedEventHandler(this.FinishedDownloader);
     downloader.BeginDownloadFile(this.GetDirectURL(), this.GetLocalPatchFile(), true);
     return true;
 }
예제 #48
0
 public bool SaveDownload(IStatusProvider statusProvider)
 {
     if (!base.ContentType.CurrentUserCanDownload)
     {
         if (statusProvider != null)
         {
             statusProvider.SetStatus("<LOC>You do not have permission to download this content", new object[0]);
         }
         return false;
     }
     try
     {
         string path = this.GetDownloadPath() + @"\content.partial";
         if (!System.IO.File.Exists(path))
         {
             ErrorLog.WriteLine("The expected download file: {0} was not found.", new object[] { path });
             if (statusProvider != null)
             {
                 statusProvider.SetStatus("<LOC>An error occurred while downloading file, please try again.", 0xbb8, new object[0]);
             }
             return false;
         }
         statusProvider.SetStatus("<LOC>Extracting File(s)...", new object[0]);
         Compression.Unzip(path);
         Thread.Sleep(50);
         DateTime now = DateTime.Now;
         while (System.IO.File.Exists(path))
         {
             try
             {
                 System.IO.File.Delete(path);
             }
             catch
             {
                 if ((DateTime.Now - now) > TimeSpan.FromSeconds(5.0))
                 {
                     break;
                 }
                 Thread.Sleep(50);
             }
         }
         return true;
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
         return false;
     }
 }
예제 #49
0
		public NestViewModel() {
			if (DesignerProperties.IsInDesignTool)
				return;

			_statusProvider = ServiceContainer.GetService<IStatusProvider>();
			_sessionProvider = ServiceContainer.GetService<ISessionProvider>();
			_nestWebService = ServiceContainer.GetService<INestWebService>();
			_statusUpdater = ServiceContainer.GetService<IStatusUpdaterService>();
			_analyticsService = ServiceContainer.GetService<IAnalyticsService>();
			_statusProvider.StatusUpdated += OnStatusUpdated;
		}