Exemplo n.º 1
0
        public async Task <Responses.Watcher> UpdateWatcher(UpdateWatcher request)
        {
            // Get watcher
            var watcher = await _watcherRepository.GetSingle(request.WatcherId);

            // Throw NotFound if it does not exist
            if (watcher == null)
            {
                throw new NotFoundException(WatcherMessage.WatcherNotFound);
            }

            // Update watcher
            watcher.Update(request.Buy, request.Sell, request.Enabled);

            // Update
            _watcherRepository.Update(watcher);

            // Save
            await _dbContext.SaveChangesAsync();

            // Log into Splunk
            _logger.LogSplunkInformation(request);

            // Response
            var response = _mapper.Map <Responses.Watcher>(watcher);

            // Return
            return(response);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> UpdateWatcher(string watcherId, [FromBody] UpdateWatcher request)
        {
            // Reponse
            request.WatcherId = watcherId;
            var response = await _watcherService.UpdateWatcher(request);

            // Return
            return(Ok(response));
        }
Exemplo n.º 3
0
        //ROM読みこみに伴うシステムの初期化.
        static void InitSystem(string fullfilename)
        {
            Log.Notify("InitSystem:", Path.GetFileName(ROM.Filename), "ver:", ROM.RomInfo.VersionToFilename(), "length:", ROM.Data.Length.ToString("X"), "FEBuilderGBA:", U.getVersion());

            //Undoバッファの準備
            Undo = new Undo();


            //数を求める部分はあまりにたくさん呼び出すのでキャッシュすることにしました.
            InputFormRef.ClearCacheDataCount();
            //パッチのインストールの是非の判定 FE8には策パッチがあるのでキャッシュする.
            PatchForm.ClearCheckIF();

            if (fullfilename != "")
            {
                //変更監視
                UpdateWatcher.RegistMain(fullfilename);
            }


            //tbl適応判定
            OptionForm.AutoUpdateTBLOption();

            //システム側のテキストエンコード どうやってUnicodeにするかどうか.
            ReBuildSystemTextEncoder();

            //FEテキストエンコード用のハフマンツリーマップの構成
            ReBuildFETextEncoder();

            //イベントの読込
            ReLoadEventScript();

            //イベント条件の解釈リスト
            EventCondForm.PreLoadResource(U.ConfigDataFilename("eventcond_"));

            //AI1 と 2, 3
            EventUnitForm.PreLoadResourceAI1(U.ConfigDataFilename("ai1_"));
            EventUnitForm.PreLoadResourceAI2(U.ConfigDataFilename("ai2_"));
            EventUnitForm.PreLoadResourceAI3(U.ConfigDataFilename("ai3_"));

            //SondEffectリスト
            SongTableForm.PreLoadResource(U.ConfigDataFilename("sound_"));
            //UnitActionリスト
            UnitActionPointerForm.PreLoadResource(U.ConfigDataFilename("unitaction_"));

            //ROM内アニメ
            ImageRomAnimeForm.PreLoadResource();
            ImageTSAAnimeForm.PreLoadResource();
            if (Program.ROM.RomInfo.version() == 8)
            {
                ImageTSAAnime2Form.PreLoadResource();
            }

            //MODの読込.
            ReLoadMod();

            //新規に追加ユニットリストキャッシュの削除
            EventUnitForm.ClearNewData();

            //システムアイコンキャッシュのクリア
            ImageSystemIconForm.ClearCache();

            //EVENTとASMのキャッシュをクリア
            AsmMapFileAsmCache = new FEBuilderGBA.AsmMapFileAsmCache();
            //asm mapキャッシュの更新.
            AsmMapFileAsmCache.ClearCache();

            //RAM
            ReBuildRAM();

            if (fullfilename != "" &&
                fullfilename != Program.Config.at("Last_Rom_Filename"))
            {//最後に開いたファイル名を保存する.
                Program.Config["Last_Rom_Filename"] = fullfilename;
                Program.Config.Save();
            }
            //Log.Notify("InitSystem:Complate");
        }
Exemplo n.º 4
0
        public ContactsManager(ICore core, ISynchronizeInvoke syncInvoke)
        {
            Core = core;

            _contactsWrapper = new ObservableDictionaryValuesMapperConverter <Contact, IContact>(_contacts);
            _tagsWrapper     = new ObservableDictionaryValuesMapperConverter <TagLocal, IContactTagLocal>(_tags);

            var dbPath = string.Format("{0}{1}contactpoint{1}{2}", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Path.DirectorySeparatorChar, "address_book.s3db");

#if CONTACTS_DEBUG
            if (File.Exists(dbPath))
            {
                File.Delete(dbPath);
            }
#endif

            if (!File.Exists(dbPath))
            {
                CreateDatabase(dbPath);
            }
            else
            {
                if (!InitializeConnection(dbPath))
                {
                    Logger.LogWarn("Error loading ContactsManager - continue without Contacts API");
                    return;
                }
            }

            var contacts = new Dictionary <long, Contact>();
            using (new EnsuredResourceCriticalOperation(_sqlConnection))
            {
                DatabaseSchema.Upgrade(_sqlConnection);

                #region Load address books

                Logger.LogNotice("Loading Address Books");
                using (var command = _sqlConnection.CreateCommand())
                {
                    command.CommandText = @"select id, name, lastupdate, key from addressbooks";

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            _addressBooks.Add(
                                new AddressBookLocal(
                                    this,
                                    reader.GetInt32(0),
                                    Guid.Parse(reader.GetString(3)),
                                    reader.GetString(1)
                                    )
                            {
                                LastUpdate =
                                    reader.IsDBNull(2)
                                                ? DateTime.Now - TimeSpan.FromDays(365)
                                                : reader.GetDateTime(2)
                            });
                        }
                    }
                }

                #endregion

                #region Load tags

                Logger.LogNotice("Loading Tags");
                using (var command = _sqlConnection.CreateCommand())
                {
                    command.CommandText =
                        @"select id, name, key, color, version_tag, addressbook_id from tags where is_deleted = 0";

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var addressBookId = reader.GetInt64(5);
                            var addressBook   = AddressBooks.FirstOrDefault(x => x.Id == addressBookId);
                            if (addressBook == null)
                            {
                                continue;
                            }

                            var tag = new TagLocal(reader.GetInt64(0), addressBook, this)
                            {
                                Name       = reader.GetString(1),
                                Key        = reader.GetStringSafe(2),
                                Color      = reader.GetStringSafe(3),
                                VersionKey = reader.GetStringSafe(4),
                                IsDeleted  = false
                            };

                            tag.ResetIsChanged();

                            _tags.Add(tag.Id, tag);
                        }
                    }
                }

                #endregion

                #region Load contacts

                Logger.LogNotice("Loading Contacts");
                using (var command = _sqlConnection.CreateCommand())
                {
                    command.CommandText = @"select id, first_name, last_name, middle_name, company from contacts";

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var id      = reader.GetInt32(0);
                            var contact = new Contact(this, id)
                            {
                                FirstName  = reader.GetStringSafe(1),
                                LastName   = reader.GetStringSafe(2),
                                MiddleName = reader.GetStringSafe(3),
                                Company    = reader.GetStringSafe(4)
                            };

                            contacts.Add(id, contact);
                        }
                    }
                }

                #endregion

                #region Load contact infos links for contacts

                Logger.LogNotice("Loading Contact Links");
                var contactInfoIdsContacts = new Dictionary <long, Contact>();
                using (var command = _sqlConnection.CreateCommand())
                {
                    command.CommandText = @"select contact_info_id, contact_id from contacts_links";

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var contactInfoId = reader.GetInt64(0);
                            if (contactInfoIdsContacts.ContainsKey(contactInfoId))
                            {
                                continue;
                            }

                            var contactId = reader.GetInt64(1);

                            if (!contacts.ContainsKey(contactId))
                            {
                                continue;
                            }

                            contactInfoIdsContacts.Add(contactInfoId, contacts[contactId]);
                        }
                    }
                }

                #endregion

                #region Load contact infos

                Logger.LogNotice("Loading Contact details");
                var contactInfos = new Dictionary <long, ContactInfoLocal>();
                using (var command = _sqlConnection.CreateCommand())
                {
                    command.CommandText =
                        @"select id, first_name, last_name, middle_name, company, job_title, addressbook_id, key, note, version_tag from contact_infos where is_deleted = 0";

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var id            = reader.GetInt64(0);
                            var addressBookId = reader.GetInt64(6);
                            var addressBook   = _addressBooks.FirstOrDefault(x => x.Id == addressBookId);

                            if (addressBook == null)
                            {
                                continue;
                            }
                            if (!contactInfoIdsContacts.ContainsKey(id))
                            {
                                continue;
                            }

                            var contactInfo = new ContactInfoLocal(id, addressBook, this)
                            {
                                FirstName  = reader.GetStringSafe(1),
                                LastName   = reader.GetStringSafe(2),
                                MiddleName = reader.GetStringSafe(3),
                                Company    = reader.GetStringSafe(4),
                                JobTitle   = reader.GetStringSafe(5),
                                Key        = reader.GetString(7),
                                Note       = reader.GetStringSafe(8),
                                VersionKey = reader.GetStringSafe(9),
                                Contact    = contactInfoIdsContacts[id],
                                IsDeleted  = false
                            };

                            contactInfos.Add(id, contactInfo);
                            contactInfo.ResetIsChanged();

                            contactInfoIdsContacts[id].ContactInfos.Add(contactInfo);
                        }
                    }
                }

                #endregion

                #region Load phone numbers

                Logger.LogNotice("Loading Phone Numbers");
                using (var command = _sqlConnection.CreateCommand())
                {
                    command.CommandText =
                        @"select id, number, comment, key, version_tag, contact_info_id from contact_info_phones";

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var contactInfoId = reader.GetInt64(5);
                            if (!contactInfos.ContainsKey(contactInfoId))
                            {
                                continue;
                            }

                            var number = new ContactPhoneLocal(reader.GetInt64(0),
                                                               contactInfos[contactInfoId].AddressBook)
                            {
                                Number     = reader.GetString(1),
                                Comment    = reader.GetStringSafe(2),
                                Key        = reader.GetStringSafe(3),
                                VersionKey = reader.GetStringSafe(4)
                            };

                            number.ResetIsChanged();

                            contactInfos[contactInfoId].PhoneNumbers.Add(number);
                            contactInfos[contactInfoId].ResetIsChanged();
                        }
                    }
                }

                #endregion

                #region Load emails

                Logger.LogNotice("Loading Emails");
                using (var command = _sqlConnection.CreateCommand())
                {
                    command.CommandText =
                        @"select id, email, comment, key, version_tag, contact_info_id from contact_info_emails";

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var contactInfoId = reader.GetInt64(5);
                            if (!contactInfos.ContainsKey(contactInfoId))
                            {
                                continue;
                            }

                            var email = new ContactEmailLocal(reader.GetInt64(0),
                                                              contactInfos[contactInfoId].AddressBook)
                            {
                                Email      = reader.GetString(1),
                                Comment    = reader.GetStringSafe(2),
                                Key        = reader.GetStringSafe(3),
                                VersionKey = reader.GetStringSafe(4)
                            };

                            email.ResetIsChanged();

                            contactInfos[contactInfoId].Emails.Add(email);
                            contactInfos[contactInfoId].ResetIsChanged();
                        }
                    }
                }

                #endregion

                #region Fill tags links on contacts infos

                Logger.LogNotice("Loading Tag links");
                using (var command = _sqlConnection.CreateCommand())
                {
                    command.CommandText = @"select tag_id, contact_info_id from tags_links";

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var tagId         = reader.GetInt32(0);
                            var contactInfoId = reader.GetInt32(1);

                            if (!_tags.ContainsKey(tagId))
                            {
                                continue;
                            }
                            if (!contactInfos.ContainsKey(contactInfoId))
                            {
                                continue;
                            }

                            contactInfos[contactInfoId].Tags.Add(_tags[tagId]);
                            contactInfos[contactInfoId].ResetIsChanged();

                            if (!_contactsTags.ContainsKey(tagId))
                            {
                                _contactsTags.Add(tagId, new List <IContact>());
                            }

                            _contactsTags[tagId].Add(contactInfoIdsContacts[contactInfoId]);
                        }
                    }
                }

                #endregion
            }

            // Fill contacts into main collection
            foreach (var item in contacts)
            {
                _contacts.Add(item.Key, item.Value);
            }

            Logger.LogNotice("Starting update watcher");
            _updateWatcher = new UpdateWatcher(this, syncInvoke);
        }