private static void AddinMenuUpdates(SyncModel syncModel, int fromVersion) { IStoreMenuThumbnailsDataService dataService = AndroAdminDataAccessFactory.GetStoreMenuThumbnailDAO(); IEnumerable <AndroAdminDataAccess.Domain.StoreMenu> menuChanges = dataService.GetStoreMenuChangesAfterDataVersion(fromVersion); IEnumerable <AndroAdminDataAccess.Domain.StoreMenuThumbnails> thumbnailChanges = dataService.GetStoreMenuThumbnailChangesAfterDataVersion(fromVersion); foreach (var change in menuChanges) { syncModel.MenuUpdates.MenuChanges.Add(new CloudSyncModel.Menus.StoreMenuUpdate() { AndromediaSiteId = change.AndromedaSiteId, Data = change.MenuData, Id = change.Id, LastUpdated = change.LastUpdated, MenuType = change.MenuType, Version = change.Version, }); } foreach (var change in thumbnailChanges) { syncModel.MenuUpdates.MenuThumbnailChanges.Add(new CloudSyncModel.Menus.StoreMenuUpdate() { Id = change.Id, LastUpdated = change.LastUpdate, AndromediaSiteId = change.AndromediaSiteId, Data = change.Data, MenuType = change.MenuType }); } }
private static void AddInHostV2List( SyncModel syncModel, int fromVersion) { IHostTypesDataService hostTypesDataService = AndroAdminDataAccessFactory.GetHostTypesDataService(); IHostV2DataService hostV2DataService = AndroAdminDataAccessFactory.GetHostV2DataService(); IHostV2ForStoreDataService hostV2ForStore = AndroAdminDataAccessFactory.GetHostV2ForStoreDataService(); IHostV2ForApplicationDataService hostV2ForApplication = AndroAdminDataAccessFactory.GetHostV2ForApplicationDataService(); var hosts = hostV2DataService.List(e => e.DataVersion > fromVersion); var activeHosts = hosts.Where(e => e.Enabled); var disabledHosts = hosts.Where(e => !e.Enabled); var deletedHosts = hostV2DataService.ListDeleted(e => e.DataVersion > fromVersion); var hosttypes = hostTypesDataService.List(e => true); var hostApplications = hostV2ForApplication.ListHostConnections(e => e.HostV2.Any(hostV2 => hostV2.DataVersion > fromVersion)); var hostStores = hostV2ForStore.ListHostConnections(e => e.HostV2.Any(hostV2 => hostV2.DataVersion > fromVersion)); syncModel.HostV2Models = new CloudSyncModel.HostV2.HostV2Models() { //full list of host types that are available HostTypes = hosttypes.Select(e => e.Name).ToList(), //actual list of active, available hosts Hosts = activeHosts.Select(hostV2 => hostV2.ToSyncModel()).ToList(), //any hosts that must be removed (disabled for maintenance or removed completely, even the ones that may even be back later) DeletedHosts = disabledHosts.Union(deletedHosts).Select(hostV2 => hostV2.ToSyncModel()).ToList(), //store specific links to the hosts StoreLinks = hostStores.Select(e => e.ToSyncModel()).ToList(), //application specific links to the hosts ApplicationLinks = hostApplications.Select(e => e.ToSyncModel()).ToList() }; }
public async Task <bool> Sync([FromBody] SyncModel sync) { try { switch (sync.Method) { case 11: case 12: _appService.Set(_serializer.Deserialize <AppDto>(sync.Body)); return(await Task.FromResult(true)); case 13: _appService.Remove(sync.Body); return(true); case 21: case 22: SyncCus(sync); return(true); case 23: _customerService.Remove(sync.Body); return(true); default: return(false); } } catch (Exception ex) { Logger.Error($"同步发生异常:{ex}"); return(false); } }
private static void AddLoyalty(SyncModel syncModel, int fromVersion) { LoyaltyDataService loyaltyDataService = new LoyaltyDataService(); var storeLoyaltyRecords = loyaltyDataService.List(e => e.DataVersion > fromVersion); if (!storeLoyaltyRecords.Any()) { return; } syncModel.LoyaltyUpdates = new CloudSyncModel.Loyalty.LoyaltyUpdates(); var fillMe = syncModel.LoyaltyUpdates.AddOrUpdate ?? (syncModel.LoyaltyUpdates.AddOrUpdate = new List <CloudSyncModel.Loyalty.StoreLoyaltySyncModel>()); var deleteMe = syncModel.LoyaltyUpdates.TryToRemove ?? (syncModel.LoyaltyUpdates.TryToRemove = new List <Guid>()); foreach (var storeLoyalty in storeLoyaltyRecords) { dynamic config = JsonConvert.DeserializeObject(storeLoyalty.Configuration ?? "{}"); if (config.Enabled != null && config.Enabled.Value) { fillMe.Add(storeLoyalty.ToSyncModel()); } else { deleteMe.Add(storeLoyalty.Id); } } }
public IActionResult AddNewCharacterSyncModel() { Character character = new Character { Id = Guid.NewGuid(), Name = "New Character", Skills = new Skills(), Attributes = new Attributes(), Ammo = new Ammo(), CharacterGear = new List <Gear>(), Armor = new List <Armor>(), Weapons = new List <Weapon>(), Talents = new List <Talent>(), PsychicPowers = new List <PyschicPower>(), }; SyncModel syncModel = new SyncModel { Id = character.Id, LastUpdateDateTime = DateTime.Now, ModelType = ModelType.Character, Json = JsonConvert.SerializeObject(character) }; using (SyncDbContext context = _dbFactory.CreateDbContext()) { context.Add(syncModel); context.SaveChanges(); return(Ok()); } }
public async Task <ActionResult <SyncModel> > GetData(int index) { string req = _repo.GetDataUri(index); int loopcount = 1; while (req == null) { req = _repo.GetDataUri(index + loopcount); loopcount++; } Uri requestString = new Uri(req); HttpResponseMessage message = new HttpResponseMessage(); SyncModel model = new SyncModel(); try { message = await client.GetAsync(requestString); message.EnsureSuccessStatusCode(); string body = await message.Content.ReadAsStringAsync(); JObject buffer = JObject.Parse(body); IList <JToken> entries = buffer["entries"].Children().ToList(); model.Items = entries; model.Count = entries.Count; } catch (Exception) { } return(model); }
protected override void OnInit() { model = SceneController.instance.GetModel <SceneModel>(SceneModel.name); syncModel = SyncController.instance.GetModel <SyncModel>(SyncModel.name); playerModel = PlayerController.instance.GetModel <PlayerModel>(PlayerModel.name); AddCommand(LOAD_SCENE, LoadScene); }
public void DeleteSyncModelById(Guid id) { SyncModel syncModel = _context.SyncModels.FirstOrDefault(x => x.Id == id); _context.SyncModels.Remove(syncModel); _context.SaveChanges(); }
public static CoreModel ConvertSyncModelToCoreModel <CoreModel>(this SyncModel syncModel) where CoreModel : ICoreCharacterModel { JObject jsonCharacter = JObject.Parse(syncModel.Json); CoreModel coreModel = jsonCharacter.ToObject <CoreModel>(); return(coreModel); }
public CoreModel GetCoreModelById <CoreModel>(Guid id) where CoreModel : ICoreCharacterModel { SyncModel syncModel = _context.SyncModels.Find(id); CoreModel coreModel = syncModel.ConvertSyncModelToCoreModel <CoreModel>(); return(coreModel); }
public void UpdateCoreModel <CoreModel>(CoreModel coreModel) where CoreModel : ICoreCharacterModel { SyncModel syncModel = _context.SyncModels.Find(coreModel.Id); syncModel.LastUpdateDateTime = DateTime.Now; syncModel.Json = JsonConvert.SerializeObject(coreModel); _context.SyncModels.Update(syncModel); _context.SaveChanges(); }
public async Task <SyncJobCompositeModel> MakeSyncJobCompositeModelAsync(SyncModel syncModel) { var instance = await _instanceRepository.GetByIdAsync(syncModel.InstanceId); return(new SyncJobCompositeModel { SyncModel = syncModel, InstanceModel = instance }); }
private void ShowSyncView() { App.FirstRun = false; _syncModel = CreateSyncModel(); _syncViewModel = new SyncViewModel(_syncModel); View.Content = new SyncView() { DataContext = _syncViewModel }; }
public static string TryGetExportSyncXml(int fromVersion, int masterVersion, out string syncXml) { SyncModel syncModel = new SyncModel(); // The current data version syncModel.FromDataVersion = fromVersion; syncModel.ToDataVersion = masterVersion; // Get the store DAO IStoreDAO storeDao = AndroAdminDataAccessFactory.GetStoreDAO(); // Get the partner DAO IPartnerDAO partnerDao = AndroAdminDataAccessFactory.GetPartnerDAO(); // Get the store payment provider DAO IStorePaymentProviderDAO storePaymentProviderDao = AndroAdminDataAccessFactory.GetStorePaymentProviderDAO(); //get the list of hosts, host types and connections based on version. //var a = AndroAdminDataAccessFactory.gethost if (SyncHelper.ConnectionStringOverride != null) { storeDao.ConnectionStringOverride = SyncHelper.ConnectionStringOverride; partnerDao.ConnectionStringOverride = SyncHelper.ConnectionStringOverride; storePaymentProviderDao.ConnectionStringOverride = SyncHelper.ConnectionStringOverride; } AndroAdminSyncHelper.AddInStoreUpdates(storeDao, syncModel, fromVersion); AndroAdminSyncHelper.AddInPartnerUpdates(partnerDao, storeDao, syncModel, fromVersion); AndroAdminSyncHelper.AddInStorePaymentProviders(storePaymentProviderDao, syncModel, fromVersion); AndroAdminSyncHelper.AddInHubTasks(syncModel, fromVersion); //Menu updates as pushed on by MyAndromeda. AndroAdminSyncHelper.AddinMenuUpdates(syncModel, fromVersion); //Host V2 changes AndroAdminSyncHelper.AddInHostV2List(syncModel, fromVersion); AndroAdminSyncHelper.AddInStoreDevices(syncModel, fromVersion); // Serialize the sync model to XML ////add delivery areas to sync model //AndroAdminSyncHelper.AddDeliveryAreas(syncModel, fromVersion); //add postcodeSectors to sync model AndroAdminSyncHelper.AddPostCodeSectors(syncModel, fromVersion); AndroAdminSyncHelper.AddLoyalty(syncModel, fromVersion); syncXml = SerializeHelper.Serialize <SyncModel>(syncModel); return(string.Empty); }
public SyncModel CreateModel(int instanceId, string instanceName, SyncModel previousSync) { return(new SyncModel { InstanceId = instanceId, Created = DateTime.Now, Name = $"Sync for {instanceName}", State = SyncState.Queued, SearchStartDate = previousSync?.Started }); }
public HttpResponseMessage GetAsyncNotes(SyncModel model) { SyncModel syncModel = new SyncModel(); var notes = NotesRepository.HasChanges(AccountRepository.GetIdByUserName(User.Identity.Name), model).ToList(); syncModel.NoteModels = notes; syncModel.LastModify = DateTime.Now.ToString("G"); var response = Request.CreateResponse(HttpStatusCode.OK, syncModel); return(response); }
private static void AddInStoreDevices(SyncModel syncModel, int fromVersion) { IStoreDevicesDataService storeDevicesDataService = new StoreDevicesDataService(); IDevicesDataService devicesDataService = new DevicesDataService(); IExternalApiDataService externalApiDataService = new ExternalApiDataService(); var updatedExternalApis = externalApiDataService.List(e => e.DataVersion > fromVersion); var updatedDevices = devicesDataService.List(e => e.DataVersion > fromVersion); var allUpdatedStoreDevices = storeDevicesDataService.Query(e => e.DataVersion > fromVersion); var model = syncModel.StoreDeviceModels ?? (syncModel.StoreDeviceModels = new StoreDevicesModels()); //add or update model.ExternalApis = updatedExternalApis.Select(e => e.ToSyncModel()).ToList(); model.Devices = updatedDevices.Select(e => e.ToSyncModel()).ToList(); model.SiteDevices = new List <SiteDeviceScaffold>(); //model.SiteDevices = storeDevices.Select(e => e.ToSyncModel()).ToList(); //models to remove model.RemovedExternalApis = externalApiDataService .ListRemoved(e => e.DataVersion > fromVersion) .Select(e => e.ToSyncModel()) .ToList(); model.RemovedDevices = devicesDataService .ListRemoved(e => e.DataVersion > fromVersion) .Select(e => e.ToSyncModel()) .ToList(); model.RemovedSiteDevices = new List <SiteDeviceScaffold>(); //model.RemovedSiteDevices = storeDevicesDataService // .ListRemoved(e => e.DataVersion > fromVersion) // .Select(e => e.ToSyncModel()) // .ToList(); //a oddity arises if there is ever more than one device, and that store device is changed. foreach (var deviceGroup in allUpdatedStoreDevices.GroupBy(e => e.StoreId)) { //ignore the above, just interested in the stores as we are going to send all of them up. var storeDevices = storeDevicesDataService.Query(e => e.StoreId == deviceGroup.Key).ToList(); //remove all of them on ACS as its impossible to tell which item has switched on device changes. var remove = storeDevices.Select(e => e.ToSyncModel()).ToArray(); //and ... then add all those which are still not removed var addOrUpdate = storeDevices.Where(e => !e.Removed).Select(e => e.ToSyncModel()).ToArray(); //add to the export feed. model.RemovedSiteDevices.AddRange(remove); model.SiteDevices.AddRange(addOrUpdate); } //all done. }
public IActionResult GetSyncModelsSinceLastSyncTime(Guid id) { using (SyncDbContext context = _dbFactory.CreateDbContext()) { SyncModel syncModel = context.SyncModels.Find(id); context.Remove(syncModel); context.SaveChanges(); return(Ok()); } }
private SyncModel CreateTarget(SyncSettings settings) { _repository.Setup(m => m.Load()).Returns(settings); var target = new SyncModel( _repository.Object, _messenger.Object, _file.Object, _directory.Object, _watcherFactory.Object, _fileInfoFactory.Object); return(target); }
public MainWindow() { InitializeComponent(); try { Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException; this.syncModel = new SyncModel(this); // to remember ListCollectionView var accounts = storageManager.GetAccounts(); var lastAccount = accounts?.Accounts?.OrderByDescending(o => o.LastLoginDate).FirstOrDefault(); this.View = new UserLoginModel(async(model) => { try { ValidateCredentials(model); var account = await Login(model); await Loged(account); this.CreateWalletButton = new IconButtonModel((b) => CreateWalletAsync(model), IconType.Plus); return(null); } catch (Exception e) { return(e.Message); } }, () => Environment.Exit(0)) { UserName = lastAccount?.UserName }; Header = new WalletTabsModel(); DonateCommand = new ActionCommand(o => (this.View as IOpenDonation)?.OpenDonation()); this.SettingsButton = new IconButtonModel((b) => MessageBox.Show("Comming soon. Check donation details", "Comming"), IconType.Settings); } catch (Exception e) { MessageBox.Show(e.Message); throw; } this.DataContext = this; }
public void Present(string settingsPath) { _settingsPath = settingsPath; _syncModel = CreateSyncModel(); if (_syncModel.Settings.Rules.Any()) { ShowSyncView(); } else { ShowWelcomeView(); } Show(); }
public static int SendClipboard(int UserId, string cleanClipboard) { // Business Logic to add the content on the database SyncModel sync = new SyncModel(); SyncUser myUser = new SyncUser() { UserId = UserId, ClipboardData = cleanClipboard }; sync.SyncUsers.Add(myUser); sync.SaveChanges(); return(myUser.UserId); }
public CoreModel AddCoreModel <CoreModel>(CoreModel coreModel, ModelType modelType) where CoreModel : ICoreCharacterModel { SyncModel newModel = new SyncModel { Id = coreModel.Id, Json = JsonConvert.SerializeObject(coreModel), LastUpdateDateTime = DateTime.Now, ModelType = modelType }; _context.SyncModels.Add(newModel); _context.SaveChanges(); coreModel.Id = newModel.Id; return(coreModel); }
public SyncViewModel(SyncModel model) { _model = model; _model.InitialCopyFailed += OnInitialCopyFailed; Rules = new ObservableCollection <SyncRuleViewModel>(); foreach (var rule in _model.Settings.Rules) { Rules.Add(new SyncRuleViewModel(rule)); } Messenger.Default.Register <LogMessage>(this, OnLogMessageReceived); Messenger.Default.Register <RuleEnabledMessage>(this, OnRuleEnabled); UpdateSyncButtonText(); _gitInfoTimer = new Timer(OnGitInfoTimer); _gitInfoTimer.Change(TimeSpan.FromSeconds(0), TimeSpan.FromMilliseconds(-1)); }
public Boolean UpdateTrackInspection(SyncModel equip) { DAL.TRACK_INSPECTION record = new DAL.TRACK_INSPECTION(); record.LeftShoeNo = equip.leftShoeNo; record.RightShoeNo = equip.rightShoeNo; var inspectionRecord = _context.TRACK_INSPECTION.Where(m => m.inspection_auto == _InspectionAuto).FirstOrDefault(); if (inspectionRecord == null) return false; inspectionRecord.LeftShoeNo = equip.leftShoeNo; inspectionRecord.RightShoeNo = equip.rightShoeNo; _context.SaveChanges(); return true; }
public void GetSyncNote_NotNotesInLocal_OK() { // Arrange var timeSync = new DateTime(2016, 03, 01, 01, 01, 01, 01); SyncModel syncModel = new SyncModel() { LastModify = timeSync.ToString("G"), NoteModels = new List <NoteModel>() }; // Act HttpResponseMessage actionResult = _notesController.GetAsyncNotes(syncModel); var contentResult = JsonConvert.DeserializeObject <SyncModel>(actionResult.Content.ReadAsStringAsync().Result); // Assert Assert.AreEqual(HttpStatusCode.OK, actionResult.StatusCode); Assert.IsNotNull(contentResult.LastModify); CollectionAssert.AreEquivalent(_notesRepository.All(0).Where(x => (x.Create > timeSync) || (x.Update > timeSync) || (x.Delete > timeSync)).ToList(), contentResult.NoteModels); }
public async Task <IActionResult> SaveItdOrderAsync(SyncModel syncmodel) { for (var i = 0; i < syncmodel.Orders.Count; i++) { var order = mapper.Map <Order>(syncmodel.Orders[i]); order.Tenant = syncmodel.Tenant; orderRepository.SyncOrdersAsync(order); } _logger.LogInformation("starting api"); try { //var res = true; return(Ok("Ok")); } catch (Exception ex) { return(BadRequest("Error")); } }
public static string ImportSyncXml(string syncXml, Action <string> successMessages = null, Action <string> failureMessages = null) { SyncModel syncModel = new SyncModel(); string errorMessage = SerializeHelper.Deserialize <SyncModel>(syncXml, out syncModel); if (errorMessage.Length == 0) { // Import the sync XML ISyncDataAccess syncDataAccess = new SyncDataAccess(); if (SyncHelper.ConnectionStringOverride != null) { syncDataAccess.ConnectionStringOverride = SyncHelper.ConnectionStringOverride; } return(syncDataAccess.Sync(syncModel, successMessages, failureMessages)); } return(errorMessage); }
protected override void OnInit() { upLoadWarp = new ProtoUdpWarp(); upDateWarp = new ProtoUdpWarp(); model = SyncController.instance.GetModel <SyncModel>(SyncModel.name); Global.instance.AddUpdateFunction(SendSyncObjectList); inputModel = InputController.instance.GetModel <InputModel>(InputModel.name); //同步玩家输入 RegisterSendProto(ProtoIDCfg.SYNC_INPUT, SendSyncInput); RegisterListenProto(ProtoIDCfg.SYNC_INPUT, OnSyncInput); //更新同步对象 RegisterListenProto(ProtoIDCfg.SYNC_OBJECTS, OnSyncObjectList); //移除对象 RegisterSendProto(ProtoIDCfg.REMOVE_OBJECTS, ReqRemoveObject); RegisterListenProto(ProtoIDCfg.REMOVE_OBJECTS, OnRemoveObject); //同步对象行为 RegisterSendProto(ProtoIDCfg.OBJECT_ACTION, ReqObjectAction); RegisterListenProto(ProtoIDCfg.OBJECT_ACTION, OnObjectAction); }
private static void AddPostCodeSectors(SyncModel syncModel, int fromVersion) { DeliveryAreaDataService deliveryAreaDataService = new DeliveryAreaDataService(); var postCodeSectors = deliveryAreaDataService.GetListPostCodes(e => e.DataVersion > fromVersion).ToList(); var model = syncModel.PostCodeSectors ?? (syncModel.PostCodeSectors = new List <PostCodeSector>()); foreach (var postcode in postCodeSectors) { CloudSyncModel.PostCodeSector postCodeSector = new CloudSyncModel.PostCodeSector { DeliveryZoneId = postcode.DeliveryZoneId, Id = postcode.Id, IsSelected = postcode.IsSelected, PostCodeSectorName = postcode.PostCodeSector1, StoreId = postcode.DeliveryZoneName.Store.ExternalId }; syncModel.PostCodeSectors.Add(postCodeSector); } }
public SourceGraphSqlModel(SyncModel model, IShellContext context, DataSyncSqlModel dataSync) { _model = model; if (!model.Sources.Any()) { throw new IncorrectRdsDefinitionException("LGM-00000 There are no available sources entities. Try to add source."); } foreach (var item in model.Sources) { var src = new SourceEntitySqlModel(item, dataSync); Entities.Add(src); src.SqlAlias = item.Alias ?? "src_" + Entities.Count; src.InitializeQuerySource(item.DataSource, context, context.Replace(item.SourceTableVariable), context.Replace(item.SourceQueryVariable)); src.MaterializeIfNeeded(); foreach (var colItem in item.Columns) { string alias = colItem.AliasOrName; if (!Columns.ContainsKey(alias)) { Columns[alias] = new SourceColumnSqlModel { Alias = alias, }; } Columns[alias].DbshColumns.Add(colItem); Columns[alias].Entities.Add(src); src.Columns.Add(Columns[alias]); if (!String.IsNullOrEmpty(colItem.Filter)) { Columns[alias].Filters.Add(colItem.Filter); if (colItem.FilterType != Driver.Common.FilterParser.FilterParser.ExpressionType.None) { Columns[alias].FilterType = colItem.FilterType; } } } } }
public DataSyncSqlModel(SyncModel model, IShellContext context, bool allowExternalSources, string providerString) { _model = model; _allowExternalSources = allowExternalSources; foreach(var param in model.Parameters) { Parameters.Add(new ParameterModel { DataType = context.Replace(param.DataType), DefaultValue = context.Replace(param.DefaultValue), Name = context.Replace(param.Name), }); } ProviderString = providerString; TargetStructure = context.GetDatabaseStructure(providerString); if (_model.IsFlatSync) { foreach (var src in _model.Sources) { var entity = new SourceEntitySqlModel(src, this); entity.LoadFlatColumns(); FlatSources.Add(entity); entity.SqlAlias = src.Alias ?? "src_" + FlatSources.Count; entity.InitializeQuerySource(src.DataSource, context, src.SourceTableVariable, src.SourceQueryVariable); entity.MaterializeIfNeeded(); } } else { SourceGraphModel = new SourceGraphSqlModel(model, context, this); foreach(var col in SourceGraphModel.Columns.Values) { col.CompileFilter(); } } foreach (var entity in model.Targets) { Entities.Add(new TargetEntitySqlModel(this, entity, context)); } foreach (var fk in model.TargetReferences) { var sourceReplaced = context.Replace(fk.Source); var sourceEntity = FindTarget(sourceReplaced); string targetReplaced = context.Replace(fk.Target); var targetEntity = FindTarget(targetReplaced); if (sourceEntity == null) throw new Exception($"DBSH-00000 Source entity {sourceReplaced} not found"); if (targetEntity == null) throw new Exception($"DBSH-00219 Target entity {targetReplaced} not found"); sourceEntity.AddReference(fk, targetEntity); } PartialSortEntitiesByRefs(); foreach (var entity in Entities) { entity.CreateJoinModel(); } foreach (var entity in Entities) { entity.TestCorrectness(); } }