Пример #1
0
        public void Backup(string filePath, string srcFolder, byte[] archHeader)
        {
            Initializing?.Invoke();

            FilesBag bag = CreateBag(srcFolder);

            FileStream fsDest = null;

            try
            {
                fsDest = File.Create(filePath);
                var writer = new RawDataWriter(fsDest, Encoding.UTF8);
                writer.Write(Signature);
                writer.Write(DateTime.Now);
                writer.Write(archHeader.Length);
                writer.Write(archHeader);

                Compressing?.Invoke();
                bag.Compress(fsDest);

                Done?.Invoke();
            }
            catch
            {
                if (fsDest != null)
                {
                    fsDest.Dispose();
                    File.Delete(filePath);
                }

                throw;
            }
        }
Пример #2
0
        public BigInteger CalculateAsync(int pNumber, CancellationToken CT)
        {
            if (pNumber < 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            Initializing?.Invoke(this, new EventArgs());
            Stopwatch myWatch = new Stopwatch();

            myWatch.Start();
            // exemple while
            BigInteger result = 1;

            /*{
             *  int decrement = pNumber;
             *  while (decrement > 1)
             *  {
             *      result = result * decrement;
             *      //pNumber = pNumber - 1; // solution étendue
             *      decrement -= 1; // solution abrégée
             *                      //pNumber--;  // solution courte postfixée
             *                      //--pNumber;  // solution courte prefixée
             *  }
             * }*/
            //exemple for
            result = 1;
            for (int decrement = pNumber;
                 decrement > 1;
                 decrement--)
            {
                if (CT.IsCancellationRequested)
                {
                    myWatch.Stop();


                    if (Cancelled != null)
                    {
                        CancelledEventArgs CEA = new CancelledEventArgs(pNumber, myWatch.Elapsed);
                        Cancelled(this, CEA);
                    }
                    return(-1);
                }

                if (Progressing != null)
                {
                    ProgressingEventArgs PEA = new ProgressingEventArgs(pNumber, pNumber - decrement + 1);
                    OnProgressing(PEA);
                }
                Thread.Sleep(50);
                result = result * decrement;
            }
            myWatch.Stop();
            if (Completed != null)
            {
                CompletedEventArgs CEA = new CompletedEventArgs(pNumber, result, myWatch.Elapsed);
                OnCompleted(CEA);
            }
            return(result);
        }
Пример #3
0
        protected virtual void OnInitialize(object sender, EventArgs e)
        {
            Initializing?.Invoke();

            var scale = 100d;

            rectSizes = Enumerable.Range(0, 2000).Select(p => new vec2((float)(rand.NextDouble() * scale), (float)(rand.NextDouble() * scale))).ToArray();

            var total = 0.0f;

            foreach (var col in Columns)
            {
                total += col.Width;
            }

            TotalWidth = total;

            total = 0;
            foreach (var row in Rows)
            {
                total += row.Height;
            }

            TotalHeight = total;

            font = new FntFontData(OpenGL, FntPath);

            spriteBatch = new SpriteBatch(OpenGL, 100000);

            Initialized?.Invoke();
        }
Пример #4
0
        public void Restore(string filePath, string destFolder)
        {
            Initializing?.Invoke();

            using (FileStream fs = File.OpenRead(filePath))
            {
                var    reader = new RawDataReader(fs, Encoding.UTF8);
                byte[] sign   = Signature;

                foreach (byte b in sign)
                {
                    if (reader.ReadByte() != b)
                    {
                        throw new CorruptedFileException(filePath);
                    }
                }

                reader.ReadTime();           //ignore creation time
                int headerLen = reader.ReadInt();
                reader.ReadBytes(headerLen); //ignore header

                Restoring?.Invoke();
                var bag = new FilesBag();

                Clean(destFolder);

                bag.Decompress(fs, destFolder);

                Done?.Invoke();
            }
        }
Пример #5
0
 protected internal virtual void OnInitializing(object sender, IInitializingEventArgs <TService> e)
 {
     if (!Enabled)
     {
         return;
     }
     Initializing?.Invoke(sender, e);
 }
 internal static void OnInitializing(object sender, InitializingEventArgs eventArg)
 {
     try
     {
         Initializing?.Invoke(sender, eventArg);
     }
     catch (Exception exp)
     {
         Logger.Error($"Exception occured in {nameof(OnInitializing)} event handler: {exp}");
     }
 }
Пример #7
0
        public async Task Start()
        {
            Log.Information("Starting GridDomain node {Id}", Id);

            _stopping             = false;
            EventsAdaptersCatalog = new EventsAdaptersCatalog();
            _containerBuilder     = new ContainerBuilder();

            System = _actorSystemFactory.Create();
            System.RegisterOnTermination(OnSystemTermination);

            System.InitLocalTransportExtension();
            Transport = System.GetTransport();

            _containerBuilder.Register(new GridNodeContainerConfiguration(Transport, Log));
            _waiterFactory = new MessageWaiterFactory(System, Transport, DefaultTimeout);

            Initializing.Invoke(this, this);

            System.InitDomainEventsSerialization(EventsAdaptersCatalog);

            ActorTransportProxy = System.ActorOf(Props.Create(() => new LocalTransportProxyActor()), nameof(ActorTransportProxy));

            //var appInsightsConfig = AppInsightsConfigSection.Default ?? new DefaultAppInsightsConfiguration();
            //var perfCountersConfig = AppInsightsConfigSection.Default ?? new DefaultAppInsightsConfiguration();
            //
            //if(appInsightsConfig.IsEnabled)
            //{
            //    var monitor = new ActorAppInsightsMonitor(appInsightsConfig.Key);
            //    ActorMonitoringExtension.RegisterMonitor(System, monitor);
            //}
            //if(perfCountersConfig.IsEnabled)
            //    ActorMonitoringExtension.RegisterMonitor(System, new ActorPerformanceCountersMonitor());

            _commandExecutor = await CreateCommandExecutor();

            _containerBuilder.RegisterInstance(_commandExecutor);

            var domainBuilder = CreateDomainBuilder();

            domainBuilder.Configure(_containerBuilder);

            Container = _containerBuilder.Build();
            System.AddDependencyResolver(new AutoFacDependencyResolver(Container, System));
            domainBuilder.Configure(Pipe);
            var nodeController = System.ActorOf(Props.Create(() => new GridNodeController(Pipe.CommandExecutor, ActorTransportProxy)), nameof(GridNodeController));

            await nodeController.Ask <GridNodeController.Alive>(GridNodeController.HeartBeat.Instance);

            Log.Information("GridDomain node {Id} started at home {Home}", Id, System.Settings.Home);
        }
Пример #8
0
        internal void Initialize()
        {
            if (!initialized)
            {
                if (!Server.OfflineMode)
                {
                    QueryToken.EntityExtensions = DynamicQueryServer.GetExtensionToken;
                }

                CompleteQuerySettings();

                TaskSearchWindow += TaskSetIconSearchWindow;

                Initializing?.Invoke();

                initialized = true;
            }
        }
Пример #9
0
        FilesBag CreateBag(string srcFolder)
        {
            Initializing?.Invoke();

            var bag = new FilesBag();

            string[] files = Directory.GetFiles(srcFolder);

            foreach (string file in files)
            {
                bag.Add(file);
            }

            string[] folders = Directory.GetDirectories(srcFolder);

            foreach (string folder in folders)
            {
                AddFiles(bag, folder, srcFolder);
            }

            return(bag);
        }
Пример #10
0
        public List <int> GetAllPrimesBelowNumber(int pNumber)
        {
            if (pNumber < 1)
            {
                throw new ArgumentOutOfRangeException();
            }
            Initializing?.Invoke(this, new EventArgs());
            List <int> allPrimes = new List <int>();

            for (int current = 1; current < pNumber; current++)
            {
                bool isPrime = IsPrimeNumber(current);
                if (isPrime)
                {
                    Thread.Sleep(10);
                    allPrimes.Add(current);
                    Progressing?.Invoke(this, new ProgressingEventArgs(pNumber, current));
                }
            }
            Completed?.Invoke(this, new PrimeCompletedEventArgs(pNumber, allPrimes, new TimeSpan(0)));
            return(allPrimes);
        }
Пример #11
0
        internal void Initialize()
        {
            if (!initialized)
            {
                if (!Server.OfflineMode)
                {
                    //Looking for a better place to do this
                    PropertyRoute.SetFindImplementationsCallback(Navigator.FindImplementations);
                }

                EventManager.RegisterClassHandler(typeof(TextBox), TextBox.GotFocusEvent, new RoutedEventHandler(TextBox_GotFocus));


                TaskNormalWindow += TaskSetIconNormalWindow;

                TaskNormalWindow += TaskSetLabelNormalWindow;

                Initializing?.Invoke();

                initialized = true;
            }
        }
Пример #12
0
        public BigInteger CalculateAsync(int pNumber)
        {
            if (pNumber < 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            Initializing?.Invoke(this, new EventArgs());
            Stopwatch myWatch = new Stopwatch();

            myWatch.Start();
            // exemple while
            BigInteger result = 1;

            //exemple for
            result = 1;
            for (int decrement = pNumber;
                 decrement > 1;
                 decrement--)
            {
                if (Progressing != null)
                {
                    ProgressingEventArgs PEA = new ProgressingEventArgs(pNumber, pNumber - decrement + 1);
                    OnProgressing(PEA);
                }
                Thread.Sleep(50);
                result = result * decrement;
            }
            myWatch.Stop();
            if (Completed != null)
            {
                CompletedEventArgs CEA = new CompletedEventArgs(pNumber, result, myWatch.Elapsed);
                OnCompleted(CEA);
            }
            return(result);
        }
Пример #13
0
 internal void OnInitializing(EntityAppInitStep step)
 {
     Initializing?.Invoke(_app, new AppInitEventArgs(_app, step));
 }
Пример #14
0
        public override void Initialize()
        {
            AvaloniaXamlLoader.Load(this);

            Initializing?.Invoke(this, EventArgs.Empty);
        }
Пример #15
0
 protected internal virtual void OnInitializing()
 {
     Initializing?.Invoke(this, EventArgs.Empty);
 }
Пример #16
0
 internal static void OnInitializing(HttpModuleInitializingEventArgs args)
 {
     Initializing?.Invoke(args.Module, args);
 }
Пример #17
0
 internal void OnInitializing()
 {
     Initializing?.Invoke(null, new InitializingSwitchEventArgs(this));
     TraceUtils.VerifyAttributes(Attributes, GetSupportedAttributes(), this);
 }
Пример #18
0
 protected void OnInitializing()
 {
     Initializing?.Invoke(this);
 }
Пример #19
0
 protected override void OnInitializing()
 {
     base.OnInitializing();
     Initializing?.Invoke(this);
 }
Пример #20
0
 public void Initialize()
 {
     Initializing?.Invoke(this, this);
 }
Пример #21
0
        public override void Initialize()
        {
            AvaloniaXamlLoader.Load(this);

            Initializing?.Invoke(this, null);
        }
Пример #22
0
 internal static void Awake(ManSplashScreen manager)
 {
     Initialized = true;
     Initializing?.Invoke(manager);
 }
Пример #23
0
 /// <summary>
 /// Called when the tab page is created.
 /// </summary>
 public virtual void Initialize()
 {
     TheWindow.TabUpdate += MainViewModel_TabUpdate;
     Initializing?.Invoke(this, EventArgs.Empty);
 }