Exemplo n.º 1
0
        //public MongoContext(string connectionString, string dbName)
        //{
        //    _client = new MongoClient(connectionString);
        //    _database = _client.GetDatabase(dbName);
        //}

        public MongoContextBase()
        {
            string connectionString = ConfigGetter.GetSectionFromJson("MongoSettings:ConnectionString");
            string dbName           = ConfigGetter.GetSectionFromJson("MongoSettings:DbName");

            _client   = new MongoClient(connectionString);
            _database = _client.GetDatabase(dbName);
        }
Exemplo n.º 2
0
        public void AddNote(Models.Note note)
        {
            List <Models.Note> Notes = GetNote();

            Notes.Add(note);

            using var writer = File.CreateText(ConfigGetter.GetNotePath());
            writer.Write(JsonConvert.SerializeObject(Notes, Formatting.Indented));
        }
Exemplo n.º 3
0
        public static void AddWelcome(Models.Welcome welcome)
        {
            List <Models.Welcome> Welcomes = GetWelcome();

            Welcomes.Add(welcome);

            using var writer = File.CreateText(ConfigGetter.GetWelcomePath());
            writer.Write(JsonConvert.SerializeObject(Welcomes, Formatting.Indented));
        }
Exemplo n.º 4
0
        public static void AddFilter(Models.Filter filter)
        {
            List <Models.Filter> Filters = GetFilter();

            Filters.Add(filter);

            using var writer = File.CreateText(ConfigGetter.GetFilterPath());
            writer.Write(JsonConvert.SerializeObject(Filters, Formatting.Indented));
        }
Exemplo n.º 5
0
        private void OpenConfigItem_Click(object sender, EventArgs e)
        {
            ConfigGetter cg = new ConfigGetter();

            if (cg.ShowDialog() != DialogResult.OK && string.IsNullOrEmpty(cg.Dev))
            {
                return;
            }
            string Auther = cg.Dev;

            Auther = Auther.Replace(' ', '_');
            if (Auther.Length > 25)
            {
                Auther = Auther.Remove(25);
            }
            string AutherPath = Path.Combine(LocalAppData, Auther);

            try
            {
                string[] ConfigPaths =
                    Directory.GetFiles(
                        AutherPath
                        , "user.config",
                        SearchOption.AllDirectories);
                //辞書リセットと作成
                od.Clear();
                ConfigList.Items.Clear();
                foreach (string FullPath in ConfigPaths)
                {
                    Uri LocalDataPath = new Uri(AutherPath),
                                ConfigPath;
                    DirectoryInfo di = Directory.GetParent(FullPath);
                    ConfigPath = new Uri(di.ToString());
                    string relatepath = HttpUtility.UrlDecode(
                        LocalDataPath.MakeRelativeUri(ConfigPath).ToString()).Replace('/', '\\');
                    od.Add(relatepath, FullPath);
                    ConfigList.Items.Add(relatepath);
                }
            }
            catch (DirectoryNotFoundException)
            {
                MessageBox.Show("設定ファイルが見つからなかったよ。(´・ω・)",
                                "ねぇよwww", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            catch (Exception b)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("別の原因で処理が継続できないみたい。");
                sb.AppendLine("下に診断書みたいなの書いておくから自己解決できるなら自己解決を、出来ないなら開発者に問い合わせてね。");
                sb.AppendLine();
                sb.AppendLine(b.ToString());
                MessageBox.Show(sb.ToString(), "処理が継続不能", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            vozBot = new TelegramBotClient(ConfigGetter.GetAPI());
            var me = vozBot.GetMeAsync().Result;

            Console.WriteLine($"Hello, World! I am user {me.Id} and my name is {me.FirstName}.");

            vozBot.OnMessage += Bot_OnMessage;
            vozBot.StartReceiving();
            Thread.Sleep(int.MaxValue);
        }
Exemplo n.º 7
0
        public async Task <UserAccountBO> CheckUserAccount(string email, string password)
        {
            var         encryptedPassword = Crypto.Encrypt(password, ConfigGetter.GetSectionFromJson("CryptoKey"));
            Task <User> userTask          = _userRepository.GetAsync(u => u.Email == email && u.Password == encryptedPassword);
            User        user = await userTask;

            if (user != null)
            {
                return(_mapper.Map <UserAccountBO>(user));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 8
0
        public static void AddBio(Models.Bio bio)
        {
            List <Models.Bio> Bios = GetBio();

            foreach (var existedBio in Bios)
            {
                if (existedBio.UserId == bio.UserId)
                {
                    Bios.Remove(existedBio);
                    break;
                }
            }
            Bios.Add(bio);

            using var writer = File.CreateText(ConfigGetter.GetBioPath());
            writer.Write(JsonConvert.SerializeObject(Bios, Formatting.Indented));
        }
Exemplo n.º 9
0
        public string Authenticate(UserAccountBO userAccount)
        {
            var tokenHandler    = new JwtSecurityTokenHandler();
            var key             = Encoding.ASCII.GetBytes(ConfigGetter.GetSectionFromJson("SecretKey"));
            var tokenDescriptor = new SecurityTokenDescriptor
            {
                Subject = new ClaimsIdentity(new Claim[]
                {
                    new Claim(ClaimTypes.Email, userAccount.Email),
                    new Claim(ClaimTypes.Role, UserRoleNames.GetRoleName(userAccount.RoleId))
                }),
                Expires            = DateTime.UtcNow.AddDays(Convert.ToInt32(ConfigGetter.GetSectionFromJson("TokenExpiresDay"))),
                SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature)
            };
            var token    = tokenHandler.CreateToken(tokenDescriptor);
            var tokenStr = tokenHandler.WriteToken(token);

            return(tokenStr);
        }
Exemplo n.º 10
0
        static void Main()
        {
            if (!mutex.WaitOne(TimeSpan.FromSeconds(1), false))
            {
                MessageBox.Show("Application is already running!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Helpers.DataBaseHelper.CreateDatabase();

            Application.ThreadException += Application_ThreadException;

            if (!ConfigGetter.GetConfigDetails())
            {
                MessageBox.Show("[Config Getter] Unable to load configuration details.");
                return;
            }
            GenerateReport.GenerateUngeneratedReport();
            Application.Run(new MainForm());
            mutex.ReleaseMutex();
        }
Exemplo n.º 11
0
 public static List <Models.Admin> GetAdmin()
 {
     using var reader = File.OpenText(ConfigGetter.GetAdminPath());
     return(JsonConvert.DeserializeObject <List <Models.Admin> >(reader.ReadToEnd()));
 }
Exemplo n.º 12
0
 public static void UpdateAdmin(List <Models.Admin> admins)
 {
     using var writer = File.CreateText(ConfigGetter.GetAdminPath());
     writer.Write(JsonConvert.SerializeObject(admins, Formatting.Indented));
 }
Exemplo n.º 13
0
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 {
     optionsBuilder.UseSqlServer(ConfigGetter.GetSectionFromJson(_connectionStringName));
 }
Exemplo n.º 14
0
        private static Func <string, object, ConfigurationSafeHandle, object> GetRetriever <T>(ConfigGetter <T> getter)
        {
            return((key, defaultValue, handle) =>
            {
                T value;
                var res = getter(out value, handle, key);
                if (res == (int)GitErrorCode.GIT_ENOTFOUND)
                {
                    return defaultValue;
                }

                Ensure.Success(res);
                return value;
            });
        }
Exemplo n.º 15
0
 public string Decrypt(CryptoModel model)
 {
     return(Crypto.Decrypt(model.Encrypted, ConfigGetter.GetSectionFromJson("CryptoKey")));
 }