public async Task Execute() { var storage = new Storage.Storage(); storage.StoreInRoaming(StorageKeys.ReviewDone, true); await Windows.System.Launcher.LaunchUriAsync(ReviewUri); }
public void InitializeTest() { _mockNetworkAdapter = Mock.Of <IHttpNetworkAdapter>(); var storage = new Storage.Storage(new StorageAdapter("test.db")); var ingestion = new IngestionHttp(_mockNetworkAdapter); var channelGroup = new ChannelGroup(ingestion, storage, "app secret"); Crashes.Instance = new Crashes(); Crashes.SetEnabledAsync(true).Wait(); Crashes.Instance.OnChannelGroupReady(channelGroup, "app secret"); }
public AggregationEngine(string path = null) { _path = path ?? Path.GetTempPath(); var storageState = new StorageState(path, new StorageOptions()); if (path == null) storageState.FileSystem = new InMemoryFileSystem("memory"); _storage = new Storage.Storage(storageState); _sequentialUuidGenerator = new SequentialUuidGenerator { EtagBase = 1 }; }
public SettingManager(Storage.Storage storage) { this.Storage = storage; this.Settings = this.Storage.Load <AppSettings>(); if (this.Settings.SelectedLanguage == null) { this.Settings.SelectedLanguage = "ru-ru"; } CultureInfo.CurrentUICulture = new CultureInfo(this.Settings.SelectedLanguage); }
public async Task SetReviewPopup() { var storage = new Storage.Storage(); bool reviewDoneValue = storage.LoadBoolFromRoaming(StorageKeys.ReviewDone); if (reviewDoneValue) { return; } int reviewValue = storage.LoadIntFromRoaming(StorageKeys.Review); if (reviewValue % 4 == 3) { string name = Config.Instance.AppName; MessageDialog reviewPopup; if (Config.Instance.language == Language.Dutch) { reviewPopup = new MessageDialog($"Vind je de {name} app een 5 sterren review waard, druk dan op 'Ja' en laat een review achter in de store. Dit helpt anderen om de {name} app makkelijker te vinden, want hoe beter de reviews hoe gemakkelijker de app te vinden is in de store.", $"Rate & Review {name}"); } else { reviewPopup = new MessageDialog($"Do you think this {name} app is worth 5 stars? Please press 'yes' and leave a review in the store. This helps other people to find the {name} app easier. The more and better the reviews are, the easier it is to find.", $"Rate & Review {name}"); } // Add commands and set their callbacks; both buttons use the same callback function instead of inline event handlers if (Config.Instance.language == Language.Dutch) { reviewPopup.Commands.Add(new UICommand("Ja", new UICommandInvokedHandler(this.CommandInvokedHandler), commandId: 0)); reviewPopup.Commands.Add(new UICommand("Misschien later")); } else { reviewPopup.Commands.Add(new UICommand("Yes", new UICommandInvokedHandler(this.CommandInvokedHandler), commandId: 0)); reviewPopup.Commands.Add(new UICommand("Maybe later")); } // Set the command that will be invoked by default reviewPopup.DefaultCommandIndex = 0; // Set the command to be invoked when escape is pressed reviewPopup.CancelCommandIndex = 1; // Show the message dialog await reviewPopup.ShowAsync(); } storage.StoreInRoaming(StorageKeys.Review, reviewValue + 1); }
public void SaveGoods(IEnumerable <Goods> goodsCollection) { Storage.Storage sto = new Storage.Storage(System.Configuration.ConfigurationManager.ConnectionStrings["eworm"].ConnectionString); foreach (var goods in goodsCollection) { var stoGoods = sto.GetGoodsBySellingUrl(goods.SellingUrl); if (stoGoods != null) { goods.Id = stoGoods.Id; } sto.SaveGoods(goods); } }
public override void FromStorage(Storage.Storage storage, Storage.Records.Optimizer optimizer) { base.FromStorage(storage, optimizer); d_ranges.Clear(); d_numberOfSolutions = 0; // Read ranges from the storage storage.Query("SELECT `parameters`.`name`, `ranges`.`step_repr`, `ranges`.`steps_repr` FROM `ranges` LEFT JOIN `parameters` ON (`parameters`.`id` = `ranges`.`id`) ORDER BY `parameters`.`id`", delegate(IDataReader reader) { string name = (string)reader["name"]; string step = (string)reader["step_repr"]; string steps = (string)reader["steps_repr"]; Parameter parameter = Parameter(name); Range range = new Range(parameter.Name, parameter.Boundary); range.Step.Representation = step; if (!String.IsNullOrEmpty(steps)) { range.Steps = new NumericSetting(); range.Steps.Representation = steps; } d_ranges.Add(range); double[] all = range.ToArray(); if (d_numberOfSolutions == 0) { d_numberOfSolutions = (uint)all.Length; } else { d_numberOfSolutions *= (uint)all.Length; } return(true); }); object val = Storage.QueryValue("SELECT MAX(`index`) FROM `solution`"); if (val != null) { d_currentId = (uint)((Int64)val + 1); } else { d_currentId = 0; } }
public void TestDbInitializationFolderExists() { // Make sure database directory exists before test. if (!Directory.Exists(Constants.AppCenterDatabasePath)) { new DirectoryInfo(Constants.AppCenterDatabasePath).Create(); } using (var storageMock = new Storage.Storage()) { storageMock.WaitOperationsAsync(TimeSpan.FromSeconds(10)).Wait(); // Verify that database is created inside local app data folder, and not locally. Assert.IsTrue(File.Exists(Path.Combine(Constants.LocalAppData, Constants.AppCenterDatabaseFilename))); } }
public void TestCorrectDatabasePathPassedFromStorageInitialization() { // Make sure database does not exist before test. if (File.Exists(Constants.AppCenterDatabasePath)) { File.Delete(Constants.AppCenterDatabasePath); } using (var storageMock = new Storage.Storage()) { storageMock.WaitOperationsAsync(TimeSpan.FromSeconds(10)).Wait(); // Verify that database is created inside local app data folder, and not locally. Assert.IsTrue(File.Exists(Path.Combine(Constants.LocalAppData, Constants.AppCenterDatabaseFilename))); } }
public MainFormPresenter(MainForm form) { storage = new Storage.Storage(); configFile = new ConfigFile(); calculateParams = new CalculateImageParams(); writer = new WriteToFile(); workWithImage = new WorkWithImage(); graphicBuilder = new GraphicsBuilder(); configFile.ReadConfigFile(); filtres = new Filters(configFile.StepMedianFiltr, configFile.StepMovingAverage); formWindow = form; erroreMessage = ""; }
private void StoreStages() { Storage.Storage storage = Job.Optimizer.Storage; storage.Query("DROP TABLE IF EXISTS `stages`"); storage.Query("CREATE TABLE `stages` (`id` INTEGER PRIMARY KEY, `condition` TEXT, `expression` TEXT)"); for (int i = 0; i < d_stages.Count; ++i) { Stage stage = d_stages[i]; storage.Query("INSERT INTO `stages` (`condition`, `expression`) VALUES (@0, @1)", stage.Condition != null ? stage.Condition.Text : null, stage.Expression.Text); } }
private void Init(Storage.Storage existStorage, ConfigFile cnfFile) { presenter = new Presenter.SettingFormPresenter(existStorage, cnfFile, this); SetLanguage(typeof(LoadImageForm), presenter.GetCurrentLanguage()); cbLanguage.DataSource = null; cbLanguage.Items.Clear(); cbLanguage.DataSource = presenter.GetExistLanguage(); cbLanguage.SelectedIndex = -1; tbStepAvarage.Text = presenter.GetStepAvarage(); tbStepMedian.Text = presenter.GetStepMedian(); }
private void StoreConstraints() { Storage.Storage storage = Job.Optimizer.Storage; storage.Query("DROP TABLE IF EXISTS `constraints`"); storage.Query("DROP TABLE IF EXISTS `constraint_parameters`"); storage.Query("DROP TABLE IF EXISTS `constraint_equations`"); storage.Query("DROP TABLE IF EXISTS `constraint_coefficients`"); storage.Query("CREATE TABLE `constraints` (`id` INTEGER PRIMARY KEY)"); storage.Query("CREATE TABLE `constraint_parameters` (`id` INTEGER PRIMARY KEY, `constraint` INT, `parameter` TEXT)"); storage.Query("CREATE TABLE `constraint_equations` (`id` INTEGER PRIMARY KEY, `constraint` INT, `equality` INT, `value` DOUBLE)"); storage.Query("CREATE TABLE `constraint_coefficients` (`id` INTEGER PRIMARY KEY, `equation` INT, `value` DOUBLE)"); for (int i = 0; i < d_constraints.Count; ++i) { ConstraintMatrix cons = d_constraints[i]; storage.Query(@"INSERT INTO `constraints` DEFAULT VALUES"); long cid = storage.LastInsertId; foreach (string p in cons.Parameters) { storage.Query(@"INSERT INTO `constraint_parameters` (`constraint`, `parameter`) VALUES (@0, @1)", cid, p); } foreach (Linear.Constraint eq in cons.Constraints) { storage.Query(@"INSERT INTO `constraint_equations` (`constraint`, `equality`, `value`) VALUES (@0, @1, @2)", cid, eq.Equality ? 1 : 0, eq.Value); long eqid = storage.LastInsertId; foreach (double coefficient in eq.Coefficients) { storage.Query(@"INSERT INTO `constraint_coefficients` (`equation`, `value`) VALUES (@0, @1)", eqid, coefficient); } } } }
public async Task SetReviewPopup() { var storage = new Storage.Storage(); bool reviewDoneValue = storage.LoadBoolFromRoaming(StorageKeys.ReviewDone); if (reviewDoneValue) return; int reviewValue = storage.LoadIntFromRoaming(StorageKeys.Review); if (reviewValue % 4 == 3) { string name = Config.Instance.AppName; MessageDialog reviewPopup; if (Config.Instance.language == Language.Dutch) reviewPopup = new MessageDialog($"Vind je de {name} app een 5 sterren review waard, druk dan op 'Ja' en laat een review achter in de store. Dit helpt anderen om de {name} app makkelijker te vinden, want hoe beter de reviews hoe gemakkelijker de app te vinden is in de store.", $"Rate & Review {name}"); else reviewPopup = new MessageDialog($"Do you think this {name} app is worth 5 stars? Please press 'yes' and leave a review in the store. This helps other people to find the {name} app easier. The more and better the reviews are, the easier it is to find.", $"Rate & Review {name}"); // Add commands and set their callbacks; both buttons use the same callback function instead of inline event handlers if (Config.Instance.language == Language.Dutch) { reviewPopup.Commands.Add(new UICommand("Ja", new UICommandInvokedHandler(this.CommandInvokedHandler), commandId: 0)); reviewPopup.Commands.Add(new UICommand("Misschien later")); } else { reviewPopup.Commands.Add(new UICommand("Yes", new UICommandInvokedHandler(this.CommandInvokedHandler), commandId: 0)); reviewPopup.Commands.Add(new UICommand("Maybe later")); } // Set the command that will be invoked by default reviewPopup.DefaultCommandIndex = 0; // Set the command to be invoked when escape is pressed reviewPopup.CancelCommandIndex = 1; // Show the message dialog await reviewPopup.ShowAsync(); } storage.StoreInRoaming(StorageKeys.Review, reviewValue + 1); }
public override void FromStorage(Storage.Storage storage, Storage.Records.Optimizer optimizer) { base.FromStorage(storage, optimizer); storage.Query("SELECT `id` FROM `constraints` ORDER BY `id`", delegate(IDataReader reader) { ConstraintMatrix cons = new ConstraintMatrix(Job.Optimizer.Configuration.PopulationSize); int consid = reader.GetInt32(0); storage.Query("SELECT `parameter` FROM `constraint_parameters` WHERE `constraint` = @0", delegate(IDataReader rd) { string name = reader.GetString(0); cons.Add(Job.Optimizer.Parameter(name)); d_constraintsFor[name] = cons; return(true); }, consid); storage.Query("SELECT `id`, `equality`, `value` FROM `constraint_equations` WHERE `constraint` = @0 ORDER BY `id`", delegate(IDataReader eqreader) { int eqid = eqreader.GetInt32(0); bool equality = eqreader.GetInt32(1) == 1; double val = eqreader.GetDouble(2); Linear.Vector coefficients = new Linear.Vector(); storage.Query("SELECT `value` FROM `constraint_coefficients` WHERE `equation` = @0 ORDER BY `id`", delegate(IDataReader cfreader) { coefficients.Add(cfreader.GetDouble(0)); return(true); }, eqid); cons.Add(new Linear.Constraint(equality, coefficients, val)); return(true); }, consid); d_constraints.Add(cons); return(true); }); }
public override void FromStorage(Storage.Storage storage, Storage.Records.Optimizer optimizer) { base.FromStorage(storage, optimizer); d_parameterAugmentation = new List <ParameterAugmentation>(Parameters.Count); for (int i = 0; i < Parameters.Count; ++i) { d_parameterAugmentation.Add(null); } Storage.Query("SELECT `name`, `mutation_rate`, `mutation_probability`, `discrete` FROM `parameters` ORDER BY `id`", delegate(IDataReader reader) { string name = reader.GetString(0); object mutrate = reader.GetValue(1); object mutprob = reader.GetValue(2); bool discrete = reader.GetInt32(3) == 1; ParameterAugmentation aug = new ParameterAugmentation(); aug.IsDiscrete = discrete; int idx = Parameters.IndexOf(Parameter(name)); if (mutrate != null) { Biorob.Math.Expression.Create(reader.GetString(1), out aug.MutationRate); } if (mutprob != null) { Biorob.Math.Expression.Create(reader.GetString(2), out aug.MutationProbability); } d_parameterAugmentation[idx] = aug; return(true); }); SetupExpressions(); }
static bool CopyOrPrint(Storage.Storage nh, string ch) { Console.Clear(); if (Convert.ToInt32(ch) == 1) { Console.Write("Enter Information Capacity: "); nh.InformationCapacity = Convert.ToInt32(Console.ReadLine()); nh.Copy(); Thread.Sleep(1000); Console.Clear(); return(true); } else if (Convert.ToInt32(ch) == 2) { nh.PrintDeviceInfo(); Thread.Sleep(1000); Console.Clear(); return(true); } else { throw new Exception("The choose is not valid!"); } }
public ShopProductsServices(Storage.Storage storage) { _storage = storage; }
public void SetStorage(Storage.Storage newStorage) { this.storage = newStorage; }
public override void FromStorage(Storage.Storage storage, Storage.Records.Optimizer optimizer, Storage.Records.Solution solution) { base.FromStorage(storage, optimizer, solution); VelocityFromData(); }
public override void FromStorage(Storage.Storage storage, Storage.Records.Optimizer optimizer, Storage.Records.Solution solution) { base.FromStorage(storage, optimizer, solution); d_bounced = uint.Parse((string)Data["bounced"]); }
public DurableCursor(Uri address, Storage.Storage storage, DateTimeOffset defaultValue) { _address = address ?? throw new ArgumentNullException(nameof(address)); _storage = storage ?? throw new ArgumentNullException(nameof(storage)); _defaultValue = defaultValue; }
public Blobs(Logger logger, string dbUrl, string path, string tempDir) : base(dbUrl) { this.logger = logger; this.dbUrl = dbUrl; this.path = path; this.tempDir = tempDir; this.storage = new Storage.Storage(path, tempDir); cleanThread = new Thread(ThreadStart); cleanThread.Name = "BlobCleanThread"; cleanThread.Start(); BeforeAsync = async(p, c) => await c.EnsureIsSuperAdminAsync(); PostAsync["/"] = async(p, c) => { var fileDefinition = await GetFileDefinitionAsync <Blob>(c); string tempFile; Blob blob; (blob, tempFile) = await PrepareBlobAsync(fileDefinition, fileDefinition.Define); using (var db = await DB.CreateAsync(dbUrl, true)) { blob = await CreateBlobFromTempFileAsync(db, blob, tempFile); await db.CommitAsync(); } c.Response.StatusCode = 200; c.Response.Content = blob.ToJson(); }; DeleteAsync["/{id}"] = async(p, c) => { bool deleted = false; string id = (string)p["id"]; if (id == null) { return; } using (var db = await DB.CreateAsync(dbUrl, true)) { deleted = await DeleteBlobAsync(db, id); await db.CommitAsync(); } if (deleted) { c.Response.StatusCode = 200; c.Response.Content = ""; } }; GetAsync["/{id}/content"] = async(p, c) => { using (var db = await DB.CreateAsync(dbUrl)) { var blob = new Blob { id = (string)p["id"] }; if (await blob.LoadAsync(db)) { var stream = storage[(string)p["id"]]; c.Response.Headers["content-type"] = blob.mimetype; c.Response.StatusCode = 200; c.Response.SupportRanges = true; c.Response.Content = stream; } } }; }