示例#1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseRewriter(new RewriteOptions()
                            .AddRedirect("^index(.html?)?$", "/")
                            );

            var dir = new SystemDirectory(Di <ITaskHelper>(app), Di <CmdLineOptions>(app).AccessLogDirectory);

            app.UseAccessLog(dir);

            app.UseResponseCompression();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(name: "default", template: "{controller}/{action}/{id?}");
            });

            //app.UseBlazor<Client.Program>();
        }
示例#2
0
        public StacksContainer()
        {
            InitializeComponent();

            try
            {
                this.deserialize();
            }
            catch {}

            Locations.CollectionChanged += new NotifyCollectionChangedEventHandler(locations_CollectionChanged);

            // Add some default folders on FirstRun
            if (Properties.Settings.Default.IsFirstRun == true)
            {
                // Check for Documents Folder
                String myDocsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                if (Directory.Exists(myDocsPath)) {
                    SystemDirectory myDocsSysDir = new SystemDirectory(myDocsPath, Dispatcher.CurrentDispatcher);
                    // Don't duplicate defaults
                    if (!Locations.Contains(myDocsSysDir)) {
                        Locations.Add(myDocsSysDir);
                    }
                }
                // Check for Downloads folder
                String downloadsPath = System.Environment.GetEnvironmentVariable("USERPROFILE") +@"\Downloads";
                if (Directory.Exists(downloadsPath)) {
                    SystemDirectory downloadsSysDir = new SystemDirectory(downloadsPath, Dispatcher.CurrentDispatcher);
                    // Don't duplicate defaults
                    if (!Locations.Contains(downloadsSysDir)) {
                        Locations.Add(downloadsSysDir);
                    }
                }
            }
        }
示例#3
0
 string PathFromDirectory(SystemDirectory dir)
 {
     return(dir == SystemDirectory.Cache
    ? FileSystem.CacheDirectory
    : dir == SystemDirectory.Internal ? FileSystem.AppDataDirectory
    : Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).AbsolutePath);
 }
示例#4
0
        public DirectoryInfo GetSystemDirectory(SystemDirectory toGet)
        {
            switch (toGet)
            {
            case SystemDirectory.Logs:
                return(new DirectoryInfo(Paths.LogPath));

            case SystemDirectory.Data:
                return(new DirectoryInfo(Paths.DataPath));

            case SystemDirectory.Saves:
                return(new DirectoryInfo(Paths.SavePath));

            case SystemDirectory.Profiles:
                return(new DirectoryInfo(Paths.ProfilePath));

            case SystemDirectory.CacheSave:
                return(new DirectoryInfo(Paths.CacheSavePath));

            case SystemDirectory.LocalSaves:
                return(new DirectoryInfo(Paths.LocalSavePath));
            }

            Debug.Log.Error("Directories.GetDirectory()", "No directory found with enum " + toGet + " - returning null");
            return(null);
        }
示例#5
0
        public ShowFuelInstHhCur(Options opts)
        {
            var taskHelper = SystemTaskHelper.Instance;
            var dir        = new SystemDirectory(taskHelper, opts.DataDirectory);

            _datastoreReader = new FuelInstHhCur.Reader(taskHelper, dir);
            _count           = opts.Count;
        }
        public DesktopIcons()
        {
            InitializeComponent();

            String desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                if (Directory.Exists(desktopPath)) {
                    SystemDirectory desktopSysDir = new SystemDirectory(desktopPath, Dispatcher.CurrentDispatcher);
                    Locations.Add(desktopSysDir);
                }
        }
示例#7
0
        static async Task <int> GetFreq(GetFreqOptions opts)
        {
            var taskHelper = SystemTaskHelper.Instance;
            var downloader = new ElexonDownloader(taskHelper, opts.ElexonApiKey);
            var dir        = new SystemDirectory(taskHelper, opts.DataDirectory);
            var fetch      = new FetchFreq(taskHelper, downloader, dir, SystemTime.Instance);
            await fetch.Start(opts.GetImmediately);

            return(0);
        }
示例#8
0
        static async Task <int> GetGasFlow(GetGasFlowOptions opts)
        {
            var taskHelper = SystemTaskHelper.Instance;
            var downloader = new SoapDownloader(taskHelper);
            var dir        = new SystemDirectory(taskHelper, opts.DataDirectory);
            var fetch      = new FetchGasFlow(taskHelper, downloader, dir, SystemTime.Instance);
            await fetch.Start(opts.GetImmediately);

            return(0);
        }
示例#9
0
        static async Task <int> GetB1610(GetB1610Options opts)
        {
            var taskHelper = SystemTaskHelper.Instance;
            var downloader = new ElexonDownloader(taskHelper, opts.ElexonApiKey);
            var dir        = new SystemDirectory(taskHelper, opts.DataDirectory);
            var fetch      = new FetchB1610(taskHelper, downloader, dir, SystemTime.Instance, opts.ErrorLogFilename);
            await fetch.Start();

            return(0);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="layout"></param>
        /// <returns></returns>
        public static bool SaveLayout(this IProfileLayoutControl layout)
        {
            if (string.IsNullOrEmpty(layout.LayoutFilePath))
            {
                return(false);
            }

            string fileName = SystemDirectory.GetDirectory(DataDirectoryType.User, layout.LayoutFilePath);

            Feng.Utils.IOHelper.TryCreateDirectory(fileName);
            AMS.Profile.IProfile profile = new AMS.Profile.Xml(fileName);
            return(layout.SaveLayout(profile));
        }
        public GetFuelInstHhCur(Options opts)
        {
            var taskHelper = SystemTaskHelper.Instance;

            _scheduler = new Scheduler(SystemTime.Instance, taskHelper);
            var elexonDownloader = new ElexonDownloader(taskHelper, opts.ElexonApiKey);

            _fuelInstHhCur = new FuelInstHhCur(taskHelper, elexonDownloader);
            var dir = new SystemDirectory(taskHelper, opts.DataDirectory);

            _datastoreWriter = new FuelInstHhCur.Writer(taskHelper, dir);
            _getImmediately  = opts.GetImmediately;
        }
示例#12
0
        public static bool AddLocation(string path)
        {
            if (Directory.Exists(path))
            {
                SystemDirectory dir = new SystemDirectory(path, Dispatcher.CurrentDispatcher);

                if (!StackLocations.Contains(dir))
                {
                    StackLocations.Add(dir);
                    return(true);
                }
            }

            return(false);
        }
示例#13
0
        static async Task <int> ShowFreq(ShowFreqOptions opts)
        {
            var taskHelper = SystemTaskHelper.Instance;
            var dir        = new SystemDirectory(taskHelper, opts.DataDirectory);
            var reader     = new Freq.Reader(taskHelper, dir);
            var count      = opts.Count;
            var totalCount = (int)await reader.CountAsync();

            Console.WriteLine($"Grid Frequency count: {totalCount}");
            Console.WriteLine($"Latest {count} data readings:");
            var data = await reader.ReadAsync(totalCount - count, totalCount);

            data.ForEach(r => Console.WriteLine(r));
            return(0);
        }
        public static void PerformDirectoryAction(string action, SystemDirectory directory, Window window)
        {
            switch (action)
            {
            case DirectoryActions.New:
                window.Activate();
                // watch for new file to be created so we can perform an action
                directory.FileCreated += ShellNew_FileCreated;
                break;

            case DirectoryActions.Paste:
                directory.PasteFromClipboard();
                break;
            }
        }
示例#15
0
        static async Task <int> ShowGasFlow(ShowGasFlowOptions opts)
        {
            var taskHelper = SystemTaskHelper.Instance;
            var dir        = new SystemDirectory(taskHelper, opts.DataDirectory);
            var reader     = new InstantaneousFlow.Reader(taskHelper, dir);
            var strings    = new Strings(taskHelper, dir);
            var count      = opts.Count;
            var totalCount = (int)await reader.CountAsync();

            Console.WriteLine($"Gas-flow data count: {totalCount}");
            Console.WriteLine($"Latest {count} data readings:");
            var data = await reader.ReadAsync(totalCount - count, totalCount);

            data.ForEach(r => Console.WriteLine(r.ToString(strings)));
            return(0);
        }
示例#16
0
        public DesktopIcons()
        {
            InitializeComponent();
            // Sets the Theme for Cairo
            string theme = Properties.Settings.Default.CairoTheme;
            if (theme != "Cairo.xaml")
            {
                ResourceDictionary CairoDictionary = (ResourceDictionary)XamlReader.Load(System.Xml.XmlReader.Create(AppDomain.CurrentDomain.BaseDirectory + theme));
                this.Resources.MergedDictionaries[0] = CairoDictionary;
            }

            String desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                if (Directory.Exists(desktopPath)) {
                    SystemDirectory desktopSysDir = new SystemDirectory(desktopPath, Dispatcher.CurrentDispatcher);
                    Locations.Add(desktopSysDir);
                }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="layout"></param>
        /// <returns></returns>
        public static bool LoadLayout(this IProfileLayoutControl layout)
        {
            if (string.IsNullOrEmpty(layout.LayoutFilePath))
            {
                return(false);
            }

            AMS.Profile.IProfile profile = new AMS.Profile.Xml(SystemDirectory.GetDirectory(DataDirectoryType.User, layout.LayoutFilePath));
            if (layout.LoadLayout(profile))
            {
                return(true);
            }
            else
            {
                profile = new AMS.Profile.Xml(SystemDirectory.GetDirectory(DataDirectoryType.Global, layout.LayoutFilePath));
                return(layout.LoadLayout(profile));
            }
        }
示例#18
0
        private static void deserializeStacks()
        {
            if (Interop.Shell.Exists(stackConfigFile))
            {
                System.Xml.XmlReader reader        = System.Xml.XmlReader.Create(stackConfigFile);
                List <String>        locationPaths = serializer.Deserialize(reader) as List <String>;
                foreach (String path in locationPaths)
                {
                    StacksManager.AddLocation(path);
                }
                reader.Close();
            }
            else
            {
                // Add some default folders on FirstRun

                // Check for Documents Folder
                String myDocsPath = Interop.KnownFolders.GetPath(Interop.KnownFolder.Documents);
                if (Directory.Exists(myDocsPath))
                {
                    SystemDirectory myDocsSysDir = new SystemDirectory(myDocsPath, Dispatcher.CurrentDispatcher);
                    // Don't duplicate defaults
                    if (!StackLocations.Contains(myDocsSysDir))
                    {
                        StackLocations.Add(myDocsSysDir);
                    }
                }
                // Check for Downloads folder
                String downloadsPath = Interop.KnownFolders.GetPath(Interop.KnownFolder.Downloads);
                if (Directory.Exists(downloadsPath))
                {
                    SystemDirectory downloadsSysDir = new SystemDirectory(downloadsPath, Dispatcher.CurrentDispatcher);
                    // Don't duplicate defaults
                    if (!StackLocations.Contains(downloadsSysDir))
                    {
                        StackLocations.Add(downloadsSysDir);
                    }
                }

                // save
                serializeStacks();
            }
        }
示例#19
0
        public ShellContextMenu(SystemDirectory directory, FolderItemSelectAction folderItemSelected)
        {
            lock (Shell.ComLock)
            {
                this.CreateHandle(new CreateParams());
                this.directory = directory;
                this.folder    = directory.FullName;

                this.parent            = getParentDir(this.folder);
                this.parentShellFolder = getParentShellFolder(this.folder);
                this.folderPidl        = pathToFullPidl(this.folder);
                this.folderRelPidl     = pathToRelPidl(this.folder);
                this.x = Cursor.Position.X;
                this.y = Cursor.Position.Y;

                this.folderItemSelected = folderItemSelected;

                ShowFolderMenu();
            }
        }
示例#20
0
        public StacksContainer()
        {
            InitializeComponent();
            // Sets the Theme for Cairo
            string theme = Properties.Settings.Default.CairoTheme;
            if (theme != "Cairo.xaml")
            {
                ResourceDictionary CairoDictionary = (ResourceDictionary)XamlReader.Load(System.Xml.XmlReader.Create(AppDomain.CurrentDomain.BaseDirectory + theme));
                this.Resources.MergedDictionaries[0] = CairoDictionary;
            }
            try
            {
                this.deserialize();
            }
            catch {}

            Locations.CollectionChanged += new NotifyCollectionChangedEventHandler(locations_CollectionChanged);

            // Add some default folders on FirstRun
            if (Properties.Settings.Default.IsFirstRun == true)
            {
                // Check for Documents Folder
                String myDocsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                if (Directory.Exists(myDocsPath)) {
                    SystemDirectory myDocsSysDir = new SystemDirectory(myDocsPath, Dispatcher.CurrentDispatcher);
                    // Don't duplicate defaults
                    if (!Locations.Contains(myDocsSysDir)) {
                        Locations.Add(myDocsSysDir);
                    }
                }
                // Check for Downloads folder
                String downloadsPath = System.Environment.GetEnvironmentVariable("USERPROFILE") +@"\Downloads";
                if (Directory.Exists(downloadsPath)) {
                    SystemDirectory downloadsSysDir = new SystemDirectory(downloadsPath, Dispatcher.CurrentDispatcher);
                    // Don't duplicate defaults
                    if (!Locations.Contains(downloadsSysDir)) {
                        Locations.Add(downloadsSysDir);
                    }
                }
            }
        }
示例#21
0
        public string Save(SystemDirectory dir, string filename, byte[] content, string folder = null)
        {
            var path = PathFromDirectory(dir);

            if (!string.IsNullOrEmpty(folder))
            {
                path = Path.Combine(path, folder);
            }

            path = Path.Combine(path, filename);

            FileInfo info = new FileInfo(path);

            if (!info.Directory.Exists)
            {
                info.Directory.Create();
            }

            File.WriteAllBytes(info.FullName, content);
            return(path);
        }
示例#22
0
        private static List<string> FetchStartupApps()
        {
            List<string> startupApps = new List<string>();

            // HKLM Run
            foreach(string keyString in hklmStartupKeys)
            {
                RegistryKey key;

                key = Registry.LocalMachine.OpenSubKey(keyString, false);

                if(key.ValueCount > 0)
                {
                    foreach(string valueName in key.GetValueNames())
                        startupApps.Add(((string)key.GetValue(valueName)).Replace("\"", ""));
                }

                key.Close();
            }

            // HKCU Run
            foreach (string keyString in hkcuStartupKeys)
            {
                RegistryKey key;

                if (keyString.Contains("RunOnce"))
                    key = Registry.CurrentUser.OpenSubKey(keyString, true);
                else
                    key = Registry.CurrentUser.OpenSubKey(keyString, false);

                if (key.ValueCount > 0)
                {
                    foreach (string valueName in key.GetValueNames())
                    {
                        startupApps.Add(((string)key.GetValue(valueName)).Replace("\"", ""));

                        // if this is a runonce key, remove the value after we grab it
                        if (keyString.Contains("RunOnce"))
                        {
                            try
                            {
                                key.DeleteValue(valueName);
                            }
                            catch { }
                        }
                    }
                }

                key.Close();
            }

            // Common Start Menu - Startup folder
            SystemDirectory comStartupDir = new SystemDirectory(Environment.GetFolderPath(Environment.SpecialFolder.CommonStartup), Dispatcher.CurrentDispatcher);

            foreach(SystemFile startupFile in comStartupDir.Files)
            {
                startupApps.Add(startupFile.FullName);
            }

            // Start Menu - Startup folder
            SystemDirectory startupDir = new SystemDirectory(Environment.GetFolderPath(Environment.SpecialFolder.Startup), Dispatcher.CurrentDispatcher);

            foreach (SystemFile startupFile in startupDir.Files)
            {
                startupApps.Add(startupFile.FullName);
            }

            return startupApps;
        }
示例#23
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();

            services.AddResponseCompression(options =>
            {
                options.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(new[]
                {
                    MediaTypeNames.Application.Octet,
                    WasmMediaTypeNames.Application.Wasm,
                });
            });

            services.AddSingleton <ITime>(SystemTime.Instance);
            services.AddSingleton <ITaskHelper>(SystemTaskHelper.Instance);

            services.AddSingleton <Db <FuelInstHhCur.Data> >(svcs =>
            {
                var taskHelper = svcs.GetRequiredService <ITaskHelper>();
                var options    = svcs.GetRequiredService <CmdLineOptions>();
                var dir        = new SystemDirectory(taskHelper, options.FuelInstHhCurDataDirectory);
                var reader     = new FuelInstHhCur.Reader(taskHelper, dir);
                return(new Db <FuelInstHhCur.Data>(taskHelper, reader));
            });
            services.AddSingleton <Db <Freq.Data> >(svcs =>
            {
                var taskHelper = svcs.GetRequiredService <ITaskHelper>();
                var options    = svcs.GetRequiredService <CmdLineOptions>();
                var dir        = new SystemDirectory(taskHelper, options.FreqDataDirectory);
                var reader     = new Freq.Reader(taskHelper, dir);
                return(new Db <Freq.Data>(taskHelper, reader));
            });
            services.AddSingleton <InstantaneousFlow.Reader>(svcs =>
            {
                var taskHelper = svcs.GetRequiredService <ITaskHelper>();
                var options    = svcs.GetRequiredService <CmdLineOptions>();
                var dir        = new SystemDirectory(taskHelper, options.GasFlowDataDirectory);
                return(new InstantaneousFlow.Reader(taskHelper, dir));
            });
            services.AddSingleton <Db <InstantaneousFlow.Data> >(svcs =>
            {
                var taskHelper = svcs.GetRequiredService <ITaskHelper>();
                var reader     = svcs.GetRequiredService <InstantaneousFlow.Reader>();
                return(new Db <InstantaneousFlow.Data>(taskHelper, reader));
            });
            services.AddSingleton <Db <B1610.Data> >(svcs =>
            {
                var taskHelper = svcs.GetRequiredService <ITaskHelper>();
                var options    = svcs.GetRequiredService <CmdLineOptions>();
                var dir        = new SystemDirectory(taskHelper, options.B1610DataDirectory);
                var reader     = new B1610.Reader(taskHelper, dir);
                return(new Db <B1610.Data>(taskHelper, reader));
            });
            services.AddSingleton <Db <PhyBmData.FpnData> >(svcs =>
            {
                var taskHelper = svcs.GetRequiredService <ITaskHelper>();
                var options    = svcs.GetRequiredService <CmdLineOptions>();
                var dir        = new SystemDirectory(taskHelper, options.FpnDataDirectory);
                var reader     = new PhyBmData.FpnReader(taskHelper, dir);
                return(new Db <PhyBmData.FpnData>(taskHelper, reader, pollInterval: Duration.FromMinutes(5)));
            });

            services.AddSingleton <PostBag>();
        }
示例#24
0
 string PathFromDirectory(SystemDirectory dir)
 {
     return(dir == SystemDirectory.Cache
    ? FileSystem.CacheDirectory
    : FileSystem.AppDataDirectory);
 }