Exemplo n.º 1
0
 public override void Load()
 {
     StorageModule[] dbModules = new StorageModule[1] {
         new StorageModule()
     };
     this.Kernel.Load(dbModules);
 }
Exemplo n.º 2
0
        public static void AtomicIsInAzure(this StorageModule self, IAzureStorageConfig storage, Action <DefaultAtomicStorageStrategyBuilder> config)
        {
            var builder = new DefaultAtomicStorageStrategyBuilder();

            config(builder);
            AtomicIsInAzure(self, storage, builder.Build());
        }
Exemplo n.º 3
0
 void AreaView_CurrentChanged(object sender, EventArgs e)
 {
     if (this.AreaView.CurrentItem == null)
     {
         return;
     }
     {
         if (this._StoragePerAreaCol.Count == 0)
         {
             this._StoragePerAreaCol.Add(new StorageModule.Storage(Guid.Empty, "请选择", 0, string.Empty, string.Empty, 42, string.Empty));
         }
         var toBeUserd = this._StoragePerAreaCol.Where(m => m.ID != Guid.Empty).ToArray();
         foreach (var item in toBeUserd)
         {
             this._StoragePerAreaCol.Remove(item);
         }
         var data = StorageModule.GetStorageByArea(ConfigManager.StorageFileName, this.AreaView.CurrentItem.ToString());
         if (data == null)
         {
             return;
         }
         foreach (var item in data)
         {
             this._StoragePerAreaCol.Add(item);
         }
     }
 }
Exemplo n.º 4
0
        public void RemoveTable()
        {
            StorageModule module = (StorageModule)storageTestManager.GetModule(typeof(TestClass));

            module.RemoveDatabaseTable();

            Assert.IsTrue(!File.Exists($@"{ApplicationData.Current.LocalFolder.Path}\{typeof(TestClass).Name}.xml"));
        }
Exemplo n.º 5
0
        public JsonResult Remove(string id)
        {
            var data   = false;
            var module = new StorageModule(CurrentUser);

            data = module.Remove(t => t.Id == id);
            return(Json(new { code = 0, msg = "Ok", data = data }));
        }
Exemplo n.º 6
0
        public void PrepareData()
        {
            storageTestManager = new StorageModuleManager(typeof(XmlDbAccess), ApplicationData.Current.LocalFolder.Path, false);
            storageTestModule  = new StorageModule(typeof(TestClass), typeof(AtomicItemManager));
            storageTestModule2 = new StorageModule(typeof(TestClass2), typeof(AtomicItemManager));

            storageTestManager.RegisterModule(storageTestModule);
            storageTestManager.RegisterModule(storageTestModule2);
        }
Exemplo n.º 7
0
        public JObject GetData(string orgId, string name, int page, int rows)
        {
            var module = new StorageModule(CurrentUser);
            var count  = 0;
            var items  = module.Page(orgId, name, page, rows, out count);
            var json   = TableStorageDataModel.Model.GetJson(items, count, TableStorageHeaderModel.Header);

            return(json);
        }
Exemplo n.º 8
0
        private void RegisterCommand()
        {
            this.StorageQueryCmd = new RelayCommand(() =>
            {
                this._StorageCol.Clear();
                var data = CaculateLibrary.StorageModule.GetStorageByCondition(ConfigManager.StorageFileName, this.Area.Trim(), this.Code.Trim(), this.UserName.Trim(), this.AccountName.Trim(), this.FreeSpace);
                if (data == null)
                {
                    return;
                }
                foreach (var item in data)
                {
                    this._StorageCol.Add(new StorageModel(item));
                }
            });

            this.GoodsQueryCmd = new RelayCommand(() =>
            {
                this._GoodsCol.Clear();
                var data = GoodsModule.GetGoodsByCondition(ConfigManager.GoodsFileName, ConfigManager.StorageFileName, this.GoodsCode, this.GoodsLeftDay, this.GoodsStorage, this.GoodsStorage == Guid.Empty?this.GoodsArea:string.Empty);
                if (data == null)
                {
                    return;
                }
                foreach (var item in data)
                {
                    this._GoodsCol.Add(new GoodsModel(item));
                }
            });

            this.DelStorageCmd = new RelayCommand(() =>
            {
                if (this.StorageView.CurrentItem == null)
                {
                    return;
                }
                StorageModel model = this.StorageView.CurrentItem as StorageModel;
                StorageModule.DelStorage(ConfigManager.StorageFileName, ConfigManager.GoodsFileName, model.ID.ToString());
                this._StorageCol.Remove(model);
                var target = this._GoodsCol.Where(m => m.StorageId == model.ID).ToArray();
                foreach (var item in target)
                {
                    this._GoodsCol.Remove(item);
                }
            });

            this.DelGoodsCmd = new RelayCommand(() =>
            {
                if (this.GoodsView.CurrentItem == null)
                {
                    return;
                }
                GoodsModel model = this.GoodsView.CurrentItem as GoodsModel;
                GoodsModule.DelGoods(ConfigManager.GoodsFileName, model.ID.ToString());
                this._GoodsCol.Remove(model);
            });
        }
Exemplo n.º 9
0
        public void CreateStorageModuleTest()
        {
            AbsolutePathXmlDbAccessTest();

            Assert.IsNull(storageMod);

            storageMod = new StorageModule(typeof(TestClass), typeof(AtomicItemManager));

            Assert.IsNotNull(storageMod);
        }
Exemplo n.º 10
0
        public JsonResult Tree(string orgId)
        {
            var module = new StorageModule(CurrentUser);
            var items  = module.FeatchAll(orgId).Select(t => new ComboTreeModel
            {
                children = new ComboTreeModel[0],
                id       = t.Id,
                text     = t.Name
            });

            return(Json(items, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 11
0
        private void LoadAreaData()
        {
            var data = StorageModule.GetAllAreas(ConfigManager.StorageFileName);

            if (data == null)
            {
                return;
            }
            foreach (var item in data)
            {
                this._AreaCol.Add(item);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Fill selector
        /// </summary>
        /// <param name="selectorContent">Content</param>
        /// <param name="selectedIds">Selected IDs</param>
        private void FillContent(ListView selectorContent, List <int> selectedIds)
        {
            MethodInfo method = typeof(StorageModule).GetMethod("GetAllItems");

            StorageModule linkedModule  = GetLinkedUIModule();
            MethodInfo    genericMethod = method.MakeGenericMethod(linkedModule.ModuleItemType);

            var allItems = Convert.ChangeType(genericMethod.Invoke(linkedModule, null), genericMethod.ReturnType) as IReadOnlyList <AtomicItem>;

            if (selectedIds != null && selectedIds.Count != 0)
            {
                allItems = allItems.Where(x => !selectedIds.Contains(x.Id)).ToList();
            }

            selectorContent.ItemsSource = allItems;
        }
Exemplo n.º 13
0
        public void AddItemIntoDatabase()
        {
            StorageModule module = (StorageModule)storageTestManager.GetModule(typeof(TestClass));

            module.UpdateDatabaseTable();
            TestClass testItem = new TestClass
            {
                IntProp    = 5,
                StringProp = "asd"
            };

            module.AddItem(testItem);

            var item = module.GetItemById <TestClass>(1);

            Assert.AreEqual("asd", item.StringProp);
        }
Exemplo n.º 14
0
 public InternalModules(InternalAccessors accessors, InternalAdditionalLogics additionalLogics, LogicData data, IServerAPI api)
 {
     AchievementModule      = AchievementModule.CreateClient(accessors.AchievementAccessor, additionalLogics.ScorersLogic, additionalLogics.DropLogic, accessors.FormulaController, additionalLogics.ImpactController);
     ActivationModule       = ActivationModule.CreateClient(accessors.FormulaController, additionalLogics.ImpactController, accessors.ExplorerAccessor, accessors.ScorersAccessor, accessors.PlayerAccessor, accessors.UnitsAccessor, additionalLogics.ApplyChangeLogic);
     AutowinModule          = AutowinModule.CreateClient(additionalLogics.ImpactController, accessors.ExplorerAccessor, accessors.ScorersAccessor, additionalLogics.FormulaLogic, additionalLogics.ExplorerLogic);
     BattleModule           = BattleModule.CreateClient(accessors.BattleAccessor, accessors.ExplorerAccessor, accessors.UnitsAccessor, additionalLogics.ContextLogic, additionalLogics.ImpactController, additionalLogics.TriggerLogic, additionalLogics.BattleLogic, additionalLogics.BuffLogic);
     CheatModule            = CheatModule.CreateClient(accessors.UnitsAccessor, accessors.ScorersAccessor, accessors.BattleAccessor, accessors.InventoryAccessor, accessors.PlayerAccessor, accessors.ExplorerAccessor, accessors.LogAccessor, accessors.SettingsAccessor, additionalLogics.ExplorerLogic, additionalLogics.BattleLogic, additionalLogics.ContextLogic, additionalLogics.ImpactController, additionalLogics.DropLogic, additionalLogics.ScorersLogic);
     CutSceneModule         = CutSceneModule.CreateClient(accessors.CutSceneAccessor, additionalLogics.ImpactController, additionalLogics.ApplyChangeLogic);
     EquipmentModule        = EquipmentModule.CreateClient(accessors.InventoryAccessor, accessors.ScorersAccessor, accessors.UnitsAccessor, additionalLogics.ImpactController, additionalLogics.FormulaLogic);
     ExplorerProgressModule = ExplorerProgressModule.CreateClient(accessors.ExplorerAccessor, accessors.InventoryAccessor, accessors.UnitsAccessor, accessors.SettingsAccessor, accessors.ScorersAccessor, accessors.BattleAccessor, additionalLogics.ExplorerLogic, additionalLogics.FormulaLogic, additionalLogics.ImpactController);
     GachaModule            = GachaModule.CreateClient(additionalLogics.ImpactController, accessors.ScorersAccessor, accessors.InventoryAccessor, accessors.UnitsAccessor, accessors.ExplorerAccessor, additionalLogics.DropLogic, accessors.ConditionController, additionalLogics.FormulaLogic);
     SettingsModule         = SettingsModule.CreateClient(accessors.SettingsAccessor, accessors.ScorersAccessor, additionalLogics.ImpactController);
     ShopModule             = ShopModule.CreateClient(accessors.ScorersAccessor, accessors.ShopAccessor, additionalLogics.FormulaLogic, additionalLogics.ImpactController, additionalLogics.ShopLogic, additionalLogics.DropLogic);
     StartSessionModule     = StartSessionModule.CreateClient(accessors.UnitsAccessor, accessors.ScorersAccessor, accessors.BattleAccessor, accessors.InventoryAccessor, accessors.PlayerAccessor, accessors.ExplorerAccessor, accessors.LogAccessor, accessors.SettingsAccessor, accessors.ShopAccessor, accessors.LogAccessor, accessors.AchievementAccessor, additionalLogics.BattleLogic, additionalLogics.ShopLogic, additionalLogics.ExplorerLogic, accessors.FormulaController, additionalLogics.ImpactController);
     StorageModule          = StorageModule.CreateClient(accessors.ScorersAccessor, accessors.InventoryAccessor);
     UnitProgressModule     = UnitProgressModule.CreateClient(accessors.UnitsAccessor, accessors.ScorersAccessor, accessors.BattleAccessor, additionalLogics.FormulaLogic, accessors.PlayerAccessor, additionalLogics.ImpactController);
 }
        public static IStorageRegistry CreateDefaultJsonStorageRegistry(string path)
        {
            var storageRegistry = StorageModule.CreateDefaultStorageRegistry();

            //Projects
            var projectStorage = new ProjectStorage(path + "/" + ProjectsPath + "/data.json");

            projectStorage.Load();
            storageRegistry.Register(projectStorage);

            //Todos
            var todoStorage = new TodoStorage(path + "/" + TodosPath + "/data.json");

            todoStorage.Load();
            storageRegistry.Register(todoStorage);

            return(storageRegistry);
        }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            ISettingsProvider settingsProvider = new SettingsProvider();
            GameSettings      settings         = settingsProvider.Get();
            IPhraseProvider   phraseProvider   = new JsonPhraseProvider(settings.language);
            InputOutputModule ioModule         = new ConsoleIOModule();
            IDoorsGenerater <List <ulong> >       doorsGenerater = new RandomDoorGenetater();
            IStorageModule <ulong, List <ulong> > storage        = new StorageModule();

            Game game = new Game(
                settings: settings,
                phraseProvider: phraseProvider,
                io: ioModule,
                doorsGenerater: doorsGenerater,
                storage: storage
                );

            game.Start();
        }
Exemplo n.º 17
0
 /**
  * Constructor.
  */
 public JobFileIterator(StorageModule s, string filePath) : base(s)
 {
     lock (descriptorsLock) {
         FileStreamRegisteredCounter r;
         if (fileDescriptors.ContainsKey(filePath))
         {
             fileDescriptors.TryGetValue(filePath, out r);
             fileStream = r.FileStream;
             r.Count++;
         }
         else
         {
             //fileStream = File.Open(filePath, FileMode.OpenOrCreate);
             fileStream = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite, System.IO.FileShare.Read);
             fileDescriptors.Add(filePath, new FileStreamRegisteredCounter(fileStream, 1));
         }
     }
     this.filePath = filePath;
     offset        = 0;
 }
Exemplo n.º 18
0
        static void RegisterAtomicStorage(FileStorageConfig cache, StorageModule c)
        {
            c.AtomicIsInFiles(cache.Folder.FullName, cb =>
            {
                cb.CustomSerializer(
                    JsonSerializer.SerializeToStream,
                    JsonSerializer.DeserializeFromStream);
                cb.WhereEntityIs <IEntityBase>();

                cb.FolderForEntity(t => "views/" + t.Name.ToLowerInvariant());
                cb.FolderForSingleton("views");
                cb.NameForSingleton(type => type.Name + ".txt");
                cb.NameForEntity((type, o) =>
                {
                    var id = o as Identity;

                    if (id != null)
                    {
                        return(id.Tag.ToString("000") + "-" + id.Id.ToString().ToLowerInvariant() + ".txt");
                    }
                    return(o.ToString() + ".txt");
                });
            });
        }
Exemplo n.º 19
0
        public JsonResult FormSubmit(string id, string orgId, string name, double lon, double lat)
        {
            var stg = new Storage
            {
                IsDel = (short)DeleteStatus.No,
                Lat   = lat,
                Lon   = lon,
                Name  = name,
                OrgId = orgId
            };
            var data   = false;
            var module = new StorageModule(CurrentUser);

            if (string.IsNullOrWhiteSpace(id))
            {
                data = module.Add(stg);
            }
            if (!string.IsNullOrWhiteSpace(id))
            {
                stg.Id = id;
                data   = module.Modify(stg, t => t.Id == id);
            }
            return(Json(new { code = 0, msg = "Ok", data = data }, "text/html"));
        }
Exemplo n.º 20
0
        /// <summary>
        /// Convert value to value showed in form
        /// </summary>
        /// <param name="prop">Info of property</param>
        /// <param name="value">Value to be converted</param>
        /// <returns>Converted value</returns>
        private static object ConvertValueToFormValue(PropertyInfo prop, object value)
        {
            var linkedTableAttribute = prop.GetCustomAttributes(true).ToList().FirstOrDefault(x => x.GetType() == typeof(LinkedTableAttribute)) as LinkedTableAttribute;

            if (prop.PropertyType == typeof(DateTime))
            {
                var      customization = prop.GetCustomAttributes(true).ToList().FirstOrDefault(x => x.GetType() == typeof(UIParamsAttribute)) as UIParamsAttribute;
                DateTime dateTimeValue = (DateTime)value;

                if (customization == null)
                {
                    throw new Base.Exceptions.MissingRequiredAdditionalDataException("DateTime missing UIParams attribute.");
                }

                CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;

                switch (customization.DateTimeMode)
                {
                case Base.Enum.DatePickerMode.Date:
                    return(dateTimeValue.ToString("d", currentCulture));

                case Base.Enum.DatePickerMode.Time:
                    return(dateTimeValue.ToString("t", currentCulture));

                case Base.Enum.DatePickerMode.DateAndTime:
                    return(dateTimeValue.ToString("g", currentCulture));

                default:
                    throw new Base.Exceptions.UnsuccessfulConversionException("DateTime conversion was unsuccessful.\n" +
                                                                              $"Unsupported DateTIme mode: {customization.DateTimeMode.ToString()}");
                }
            }
            else if (linkedTableAttribute != null)
            {
                switch (linkedTableAttribute.LinkedTableRelation)
                {
                case Base.Enum.LinkedTableRelation.One:

                    var intValue = (int)value;
                    if (intValue == -1)
                    {
                        return("-");
                    }

                    MethodInfo method = typeof(StorageModule).GetMethod("GetItemById");

                    StorageModule linkedModule  = ApplicationBase.Current.ModuleManager.GetModule(linkedTableAttribute.LinkedTableType) as StorageModule;
                    MethodInfo    genericMethod = method.MakeGenericMethod(linkedModule.ModuleItemType);

                    var linkedTableItem = Convert.ChangeType(genericMethod.Invoke(linkedModule, new object[] { intValue }), genericMethod.ReturnType) as AtomicItem;

                    return(linkedTableItem.ToString());

                case Base.Enum.LinkedTableRelation.Many:

                    var intValues = (List <int>)value;
                    if (intValues == null || (intValues != null && intValues.Count == 0))
                    {
                        return new List <string> {
                                   "-"
                        }
                    }
                    ;

                    method = typeof(StorageModule).GetMethod("GetItemById");

                    linkedModule  = ApplicationBase.Current.ModuleManager.GetModule(linkedTableAttribute.LinkedTableType) as StorageModule;
                    genericMethod = method.MakeGenericMethod(linkedModule.ModuleItemType);

                    List <AtomicItem> selectedItems = new List <AtomicItem>();
                    foreach (var selectedItemValue in intValues)
                    {
                        var selectedLinkedTableItem = Convert.ChangeType(genericMethod.Invoke(linkedModule, new object[] { selectedItemValue }), genericMethod.ReturnType) as AtomicItem;

                        selectedItems.Add(selectedLinkedTableItem);
                    }

                    return(selectedItems);

                default:
                    throw new Base.Exceptions.NotSupportedException("Unsupported Linked table relation.");
                }
            }
            else
            {
                return(value);
            }
        }
Exemplo n.º 21
0
 public static void AtomicIsInAzure(this StorageModule self, IAzureStorageConfig storage)
 {
     AtomicIsInAzure(self, storage, builder => { });
 }
Exemplo n.º 22
0
 public static void AtomicIsInAzure(this StorageModule self, IAzureStorageConfig storage, IAtomicStorageStrategy strategy)
 {
     self.AtomicIs(new AzureAtomicStorageFactory(strategy, storage));
 }
Exemplo n.º 23
0
 public static void StreamingIsInAzure(this StorageModule self, IAzureStorageConfig storage)
 {
     self.StreamingIs(new BlobStreamingRoot(storage.CreateBlobClient()));
 }
Exemplo n.º 24
0
        public static ContainerBuilder AddMongoDb(this ContainerBuilder builder, bool seedDatabase, params Assembly[] assemblies)
        {
            builder.RegisterModule(StorageModule.For(assemblies, seedDatabase));

            return(builder);
        }
Exemplo n.º 25
0
 /**
  * Constructor.
  */
 protected FileIterator(StorageModule storage)
 {
     this.storage = storage;
 }
 private static TechType RegisterModule(StorageModule storageModule)
 {
     storageModule.Patch();
     Modules.Add(storageModule.TechType, storageModule);
     return(storageModule.TechType);
 }