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(); } }
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; } }
public void Initialize() { OnBeforeDatabaseAccess(); if (Initializing == null) { return; } if (InvalidateCache != null) { foreach (var ic in InvalidateCache.GetInvocationListTyped()) { using (HeavyProfiler.Log("InvalidateCache", () => ic.Method.DeclaringType !.ToString())) ic(); } } using (ExecutionMode.Global()) foreach (var init in Initializing.GetInvocationListTyped()) { using (HeavyProfiler.Log("Initialize", () => init.Method.DeclaringType !.ToString())) init(); } Initializing = null; }
public async Task <IActionResult> GetChinesePostman() { // var graph = Initializing.CreateGraph(@"../Graph/_ChinesePostman.txt"); var matrix = new int[8, 8] { { 0, 0, 0, 0, 86, 94, 51, 82 }, { 0, 0, 81, 0, 20, 87, 0, 0 }, { 0, 81, 0, 83, 41, 0, 0, 0 }, { 0, 0, 83, 0, 8, 0, 0, 0 }, { 86, 20, 41, 8, 0, 40, 0, 54 }, { 94, 87, 0, 0, 40, 0, 89, 0 }, { 51, 0, 0, 0, 0, 89, 0, 18 }, { 82, 0, 0, 0, 54, 0, 18, 0 }, }; var graph = Initializing.CreateGraph(matrix); Graph newGraph = new Graph(); if (!ChinesePostman.ChinesePostman.IsEvenDegree(graph.Nodes)) { var oddNodes = OddFinder.FindOddNodes(graph.Nodes); newGraph = ChinesePostman.ChinesePostman.PairingOddVertices(graph, oddNodes); } var eulerianPath = ChinesePostman.ChinesePostman.FindEulerianPath(newGraph); newGraph.Nodes = eulerianPath.ToArray(); List <Graph> fullResponse = new List <Graph> { graph, newGraph }; return(Ok(fullResponse)); }
public async Task <IActionResult> GetKruskal() { // var graph = Initializing.CreateGraph(@"../Graph/_Kruskal.txt"); var matrix = new int[8, 8] { { 0, 3, 0, 0, 0, 34, 0, 80 }, { 3, 0, 0, 1, 0, 0, 0, 68 }, { 0, 0, 0, 0, 23, 0, 12, 0 }, { 0, 1, 0, 0, 53, 0, 0, 39 }, { 0, 0, 23, 53, 0, 0, 68, 14 }, { 34, 0, 0, 0, 0, 0, 0, 25 }, { 0, 0, 12, 0, 68, 0, 0, 99 }, { 80, 68, 0, 39, 14, 25, 99, 0 }, }; var graph = Initializing.CreateGraph(matrix); var graphToReturn = KruskalAlgorithm.KruskalSolve(graph); List <Graph> listGraph = new List <Graph> { graph, graphToReturn }; return(Ok(listGraph)); }
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); }
/// <summary> /// The initialize. /// </summary> private void Initialize() { var args = new VirtualContentEventArgs(_parent); Initializing.RaiseEvent(args, this); _parent = args.Parent; //// http://issues.merchello.com/youtrack/issue/M-878 _allLanguages = ApplicationContext.Current.Services.LocalizationService.GetAllLanguages().ToArray(); _parentCulture = _parent != null?_parent.GetCulture().Name : string.Empty; _defaultStoreLanguage = StringExtensions.IsNullOrWhiteSpace(this._parentCulture) ? _storeSettingService.GetByKey(Constants.StoreSettingKeys.DefaultExtendedContentCulture).Value : _parentCulture; _detachedContentTypes = new Lazy <IEnumerable <IDetachedContentType> >(() => _detachedContentTypeService.GetAll().Where(x => x.ContentTypeKey != null)); if (_allLanguages.Any()) { _defaultStoreLanguage = _allLanguages.Any(x => x.CultureInfo.Name == _defaultStoreLanguage) ? _defaultStoreLanguage : _allLanguages.First().CultureInfo.Name; } }
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(); }
/// <summary> /// The initialize. /// </summary> private void Initialize() { var args = new VirtualContentEventArgs(_parent); Initializing.RaiseEvent(args, this); _parent = args.Parent; }
protected internal virtual void OnInitializing(object sender, IInitializingEventArgs <TService> e) { if (!Enabled) { return; } Initializing?.Invoke(sender, e); }
public static void GetBoruvka() { var graph = Initializing.CreateGraph(@"./_First.txt"); var graphToReturn = BoruvkasAlgorithm.BoruvkaSolve(graph); System.Console.WriteLine("\n"); ConsolePrint.HeaderPrint("Boruvka's method minimum spanning tree"); ConsolePrint.PrintGraph(graph); ConsolePrint.PrintGraph(graphToReturn, "New Graph Edges"); }
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}"); } }
public async Task <IActionResult> GetKruskal() { var graph = Initializing.CreateGraph(@"../Graph/_Kruskal.txt"); var graphToReturn = KruskalAlgorithm.KruskalSolve(graph); List <Graph> listGraph = new List <Graph> { graph, graphToReturn }; return(Ok(listGraph)); }
public void Initialize() { if (m_isInitialized) { return; } Initializing.Raise(this, EventArgs.Empty); InitializeResources(); Initialized.Raise(this, EventArgs.Empty); m_isInitialized = true; }
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); }
public static void GetBoruvka() { var graph = Initializing.CreateGraph(@"./boruvkas.txt"); var matrix = Initializing.CreateMatrix(@"./boruvkas.txt"); var graphToReturn = Boruvkas.BoruvkasSolve(graph); System.Console.WriteLine("\n"); MyPrinter.HeaderPrint("Minimum spanning tree by Boruvka's method"); MyPrinter.PrintMatrix(matrix, "Started instance:"); System.Console.WriteLine($"\t Edges count in started instance: {graph.EdgesCount}"); System.Console.WriteLine($"\t Nodes count in started instance: {graph.VerticesCount}\n"); // MyPrinter.PrintGraph(graph, "Started graph:"); MyPrinter.PrintGraph(graphToReturn, "New minimized graph:"); }
public static void GetSalesman() { var graph = Initializing.CreateGraph(@"./_Third.txt"); var matrix = Initializing.CreateMatrix(@"./_Third.txt"); BnB_matrix brunchAndBound = new BnB_matrix(); var edges = brunchAndBound.BranchAndBound(matrix); System.Console.WriteLine("\n"); ConsolePrint.HeaderPrint("Salesman problem"); ConsolePrint.PrintGraph(graph); ConsolePrint.PrintPath(edges); }
public static void GetMaxFlowByFF() { var graph = Initializing.CreateGraph(@"./_Fourth.txt"); FlowCalc flowCalc = new FlowCalc(graph); var flow = flowCalc.FindMaximumFlow(); var maxFlow = flow.Where(e => e.Edge.Destination == graph.Nodes.Last().Id).Sum(x => x.Flow); System.Console.WriteLine("\n"); ConsolePrint.HeaderPrint("Max flow"); ConsolePrint.PrintGraph(graph); ConsolePrint.PrintFlow(graph.Edges, flow.ToArray()); System.Console.WriteLine($"\t\tMAXIMUM FLOW = {maxFlow}\n\n"); }
public static void GetSalesman() { var graph = Initializing.CreateGraph(@"./salesman.txt"); var matrix = Initializing.CreateMatrix(@"./salesman.txt"); System.Console.WriteLine("\n"); MyPrinter.HeaderPrint("Salesman problem\n"); MyPrinter.PrintMatrix(matrix, "Matrix instance\n"); BranchAndBoundSolver brunchAndBound = new BranchAndBoundSolver(); var edges = brunchAndBound.BranchAndBound(matrix); // MyPrinter.PrintGraph(graph, "Graph instance"); MyPrinter.PrintPath(edges); }
public void Initialize() { OnBeforeDatabaseAccess(); if (Initializing == null) { return; } using (ExecutionMode.Global()) foreach (var item in Initializing.GetInvocationListTyped()) { item(); } Initializing = null; }
public static void GetMaxFlowByFF() { var graph = Initializing.CreateGraph(@"./flow.txt"); var matrix = Initializing.CreateMatrix(@"./flow.txt"); FlowFinder FlowFinder = new FlowFinder(graph); var flow = FlowFinder.FindMaximumFlow(); var maxFlow = flow.Where(e => e.Edge.Destination == graph.Nodes.Last().Id).Sum(x => x.Flow); System.Console.WriteLine("\n"); MyPrinter.HeaderPrint("Max flow"); MyPrinter.PrintMatrix(matrix, "Matrix instance"); // MyPrinter.PrintGraph(graph, "Edges instance"); MyPrinter.PrintFlow(graph.Edges, flow.ToArray()); System.Console.WriteLine($"\n\t\tmax flow = {maxFlow}\n\n"); }
public void Initialize() { OnBeforeDatabaseAccess(); if (Initializing == null) { return; } using (ExecutionMode.Global()) foreach (var item in Initializing.GetInvocationListTyped()) { using (HeavyProfiler.Log("Initialize", () => item.Method.DeclaringType.ToString())) item(); } Initializing = null; }
internal void Initialize() { if (!initialized) { if (!Server.OfflineMode) { QueryToken.EntityExtensions = DynamicQueryServer.GetExtensionToken; } CompleteQuerySettings(); TaskSearchWindow += TaskSetIconSearchWindow; Initializing?.Invoke(); initialized = true; } }
public async Task <IActionResult> GetChinesePostman() { var graph = Initializing.CreateGraph(@"../Graph/_ChinesePostman.txt"); Graph newGraph = new Graph(); if (!ChinesePostman.ChinesePostman.IsEvenDegree(graph.Nodes)) { var oddNodes = OddFinder.FindOddNodes(graph.Nodes); newGraph = ChinesePostman.ChinesePostman.PairingOddVertices(graph, oddNodes); } var eulerianPath = ChinesePostman.ChinesePostman.FindEulerianPath(newGraph); newGraph.Nodes = eulerianPath.ToArray(); List <Graph> fullResponse = new List <Graph> { graph, newGraph }; return(Ok(fullResponse)); }
public static void GetChinesePostman() { var graph = Initializing.CreateGraph(@"./_Second.txt"); Graph newGraph = new Graph(); if (!ChinesePostman.IsEvenDegree(graph.Nodes)) { var oddNodes = OddFinder.FindOddNodes(graph.Nodes); newGraph = ChinesePostman.PairingOddVertices(graph, oddNodes); } var eulerianPath = ChinesePostman.FindEulerianPath(newGraph); System.Console.WriteLine("\n"); ConsolePrint.HeaderPrint("Chinese postman problem"); ConsolePrint.PrintGraph(graph); ConsolePrint.ShowAdditionalEdges(graph, newGraph); // ConsolePrint.PrintNodes(graph.Nodes, newGraph.Nodes); ConsolePrint.PrintPath(eulerianPath.ToArray()); }
/// <summary> /// The initialize. /// </summary> private void Initialize() { var args = new VirtualContentEventArgs(_parent); Initializing.RaiseEvent(args, this); _parent = args.Parent; //// http://issues.merchello.com/youtrack/issue/M-878 _allLanguages = ApplicationContext.Current.Services.LocalizationService.GetAllLanguages().ToArray(); _defaultStoreLanguage = _storeSettingService.GetByKey(Constants.StoreSettingKeys.DefaultExtendedContentCulture).Value; if (_allLanguages.Any()) { _defaultStoreLanguage = _allLanguages.Any(x => x.CultureInfo.Name == _defaultStoreLanguage) ? _defaultStoreLanguage : _allLanguages.First().CultureInfo.Name; } }
static void Main() { RegistryKey reg = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true); reg.SetValue("Micro Control", Application.ExecutablePath.ToString()); PathSys pathSys = new PathSys(); Initializing init = new Initializing(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); init.CheckPath("0|0|0|null"); if (init.Settings()[0] != "0") { Application.Run(new mainForm(init.Settings()[0])); } else { Application.Run(new initForm()); } }
public async Task <IActionResult> GetSalesman() { var graph = Initializing.CreateGraph(@"../Graph/_SalesmanProblem.txt"); var matrix = Initializing.CreateMatrix(@"../Graph/_SalesmanProblem.txt"); BnB_matrix brunchAndBound = new BnB_matrix(); var edges = brunchAndBound.BranchAndBound(matrix); var graphToReturn = (Graph)graph.Clone(); graphToReturn.EdgesCount = edges.Length; graphToReturn.Edges = edges; List <Graph> listGraph = new List <Graph> { graph, graphToReturn }; return(Ok(listGraph)); }
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; } }
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); }