Exemple #1
0
        private static async Task MainAsync()
        {
            DotEnv.AutoConfig();
            using (var services = ConfigureServices())
            {
                var envCheckerService      = services.GetRequiredService <EnvCheckerService>();
                var checkEnvironmentValues = envCheckerService.CheckEnvironmentValues();
                if (checkEnvironmentValues == false)
                {
                    Console.WriteLine("Error: CheckEnvironmentValues ");
                    return;
                }

                var valorantApiService = services.GetRequiredService <ValorantApiService>();

                await using (var db = new DatabaseDbContext())
                {
                    await db.Database.MigrateAsync();
                }

                var discord = services.GetRequiredService <BotService>();
                await discord.StartAsync();


                services.GetRequiredService <PlayerRankChecker>().Start();


                await Task.Delay(-1);
            }
        }
Exemple #2
0
        public void ShouldReturnValidValuesWithAutoConfig()
        {
            var success = DotEnv.AutoConfig();

            success.Should().BeTrue();
            Environment.GetEnvironmentVariable("hello").Should().Be("world");
        }
Exemple #3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            DotEnv.AutoConfig();
        }
Exemple #4
0
        public static TelegramClient NewClient(FileSessionStore session)
        {
            try
            {
                DotEnv.AutoConfig(); //loads environment variables

                int    API_ID   = Int32.Parse(Environment.GetEnvironmentVariable("API_ID"));
                string API_HASH = Environment.GetEnvironmentVariable("API_HASH");
                return(new TelegramClient(API_ID, API_HASH, session, "session"));
            }
            catch (MissingApiConfigurationException ex)
            {
                throw new Exception($"Please add your API settings to the `app.config` file. (More info: {MissingApiConfigurationException.InfoUrl})", ex);
            }
        }
Exemple #5
0
        /// <summary>
        /// einmaliger Aufruf.
        /// </summary>
        /// <param name="options">Optionen.</param>
        protected override void OnConfiguring(DbContextOptionsBuilder options)
        {
            DotEnv.AutoConfig();

            options.UseMySql(
                $"server={Environment.GetEnvironmentVariable("Server")};" +
                $"database={Environment.GetEnvironmentVariable("Database")};" +
                $"user={Environment.GetEnvironmentVariable("User")};" +
                $"password={Environment.GetEnvironmentVariable("Password")}",
                new MySqlServerVersion(new Version(8, 0, 21)), // use MariaDbServerVersion for MariaDB
                mySqlOptions => mySqlOptions
                .CharSetBehavior(CharSetBehavior.NeverAppend))
            // Everything from this point on is optional but helps with debugging.
            .EnableSensitiveDataLogging()
            .EnableDetailedErrors();
        }
        static void Main(string[] args)
        {
            // read
            DotEnv.AutoConfig();
            AmazonDynamoDBClient DynamoDB = null;

            try
            {
                DynamoDB = CreateDynamodbConnection();
            }
            catch (Exception ex)
            {
                Console.WriteLine(String.Format("FAILED to create a DynamoDB client; {0}", ex.Message));

                return;
            }

            ScrapingDLSite instance = new ScrapingDLSite(DynamoDB);

            instance.StartScraping();

            instance.destructor();
        }
Exemple #7
0
 public static void Main(string[] args)
 {
     DotEnv.AutoConfig();
     Parser.Default.ParseArguments <CommandLineConfigurationProvider>(args)
     .WithParsed((conf) => Startup.Bootstrap(conf).Wait());
 }
        static void Main(string[] args)
        {
            DotEnv.AutoConfig();
            var library   = "CDM";
            var docNumber = "8671310";
            var PCDLogin  = new PCDCLIENTLib.PCDLogin();

            var username = Environment.GetEnvironmentVariable("EDOCSUSERNAME");
            var password = Environment.GetEnvironmentVariable("EDOCSPASSWORD");


            var rc = PCDLogin.AddLogin(0, library, username, password);

            rc = PCDLogin.Execute();

            if (rc != 0)
            {
                throw new SystemException();
            }

            var dst = PCDLogin.GetDST();

            Console.WriteLine("The dst is:" + dst);

            var obj = new PCDCLIENTLib.PCDSearch();

            obj.SetDST(dst);
            obj.AddSearchLib(library);
            obj.SetSearchObject("DEF_PROF");
            obj.AddSearchCriteria("DOCNUMBER", docNumber);
            obj.AddReturnProperty("PATH");
            obj.AddReturnProperty("DOCNAME");

            rc = obj.Execute();
            if (rc != 0)
            {
                Console.WriteLine(obj.ErrDescription);
                throw new SystemException();
            }

            obj.SetRow(1);


            var docname = obj.GetPropertyValue("DOCNAME");

            Console.WriteLine("Doc name:" + docname);
            obj.GetPropertyValue("PATH");
            obj.ReleaseResults();


            var sql = new PCDCLIENTLib.PCDSQL();

            sql.SetDST(dst);
            rc = sql.Execute("SELECT PATH FROM DOCSADM.COMPONENTS WHERE DOCNUMBER = " + docNumber);

            if (rc != 0)
            {
                Console.WriteLine(sql.ErrDescription);
                throw new SystemException();
            }

            sql.SetRow(1);
            var path = sql.GetColumnValue(1);

            Console.WriteLine("The path is:" + path);
            var tokens = path.Split('.');

            var fileType = tokens[tokens.Length - 1].ToLower();

            Console.WriteLine("File type:" + fileType);

            obj = new PCDCLIENTLib.PCDSearch();
            obj.SetDST(dst);
            obj.AddSearchLib(library);
            obj.SetSearchObject("cyd_cmnversions");
            obj.AddSearchCriteria("DOCNUMBER", docNumber);
            obj.AddOrderByProperty("VERSION", 0);
            obj.AddReturnProperty("VERSION");
            obj.AddReturnProperty("VERSION_ID");

            rc = obj.Execute();


            if (rc != 0)
            {
                Console.WriteLine(sql.ErrDescription);
                throw new SystemException();
            }

            obj.SetRow(1);
            var version   = obj.GetPropertyValue("VERSION");
            var versionId = obj.GetPropertyValue("VERSION_ID");

            Console.WriteLine("Version: $version Version ID: " + versionId);
            obj.ReleaseResults();

            string ver = "" + versionId;

            var getobj = new PCDCLIENTLib.PCDGetDoc();

            getobj.SetDST(dst);
            getobj.AddSearchCriteria("%TARGET_LIBRARY", library);
            getobj.AddSearchCriteria("%VERSION_ID", ver);
            getobj.AddSearchCriteria("%DOCUMENT_NUMBER", docNumber);
            rc = getobj.Execute();

            if (rc != 0)
            {
                Console.WriteLine(getobj.ErrDescription);
                throw new SystemException();
            }


            getobj.NextRow();

            var filename = docNumber + "." + fileType;

            PCDCLIENTLib.PCDGetStream objPCDGetStream = (PCDCLIENTLib.PCDGetStream)getobj.GetPropertyValue("%CONTENT");
            int nbytes = (int)objPCDGetStream.GetPropertyValue("%ISTREAM_STATSTG_CBSIZE_LOWPART");

            using (Stream to = new FileStream(filename, FileMode.OpenOrCreate))
            {
                int    readCount;
                byte[] buffer = new byte[nbytes];
                buffer = (byte[])objPCDGetStream.Read(nbytes, out readCount);
                to.Write(buffer, 0, readCount);
            }

            Console.Read();
        }
        static void Main(string[] args)
        {
            DotEnv.AutoConfig();

            AnomalyDetectorClient client = new AnomalyDetectorClient(
                new Uri(Environment.GetEnvironmentVariable("ANOMALY_DECTECTOR_API_ENDPOINT")),
                new AzureKeyCredential(Environment.GetEnvironmentVariable("ANOMALY_DECTECTOR_API_KEY")));

            // ref: https://westus2.dev.cognitive.microsoft.com/docs/services/AnomalyDetector/operations/post-timeseries-entire-detect, the request here matches the sample.
            DynamicResponse res = client.DetectEntireSeriesAsync(new
            {
                series = new[] {
                    new {
                        timestamp = "1972-01-01T00:00:00Z",
                        value     = 826
                    },
                    new {
                        timestamp = "1972-02-01T00:00:00Z",
                        value     = 799
                    },
                    new {
                        timestamp = "1972-03-01T00:00:00Z",
                        value     = 890
                    },
                    new {
                        timestamp = "1972-04-01T00:00:00Z",
                        value     = 900
                    },
                    new {
                        timestamp = "1972-05-01T00:00:00Z",
                        value     = 961
                    },
                    new {
                        timestamp = "1972-06-01T00:00:00Z",
                        value     = 935
                    },
                    new {
                        timestamp = "1972-07-01T00:00:00Z",
                        value     = 894
                    },
                    new {
                        timestamp = "1972-08-01T00:00:00Z",
                        value     = 855
                    },
                    new {
                        timestamp = "1972-09-01T00:00:00Z",
                        value     = 809
                    },
                    new {
                        timestamp = "1972-10-01T00:00:00Z",
                        value     = 810
                    },
                    new {
                        timestamp = "1972-11-01T00:00:00Z",
                        value     = 766
                    },
                    new {
                        timestamp = "1972-12-01T00:00:00Z",
                        value     = 805
                    },
                    new {
                        timestamp = "1973-01-01T00:00:00Z",
                        value     = 821
                    },
                    new {
                        timestamp = "1973-02-01T00:00:00Z",
                        value     = 773
                    },
                    new {
                        timestamp = "1973-03-01T00:00:00Z",
                        value     = 883
                    },
                    new {
                        timestamp = "1973-04-01T00:00:00Z",
                        value     = 898
                    },
                    new {
                        timestamp = "1973-05-01T00:00:00Z",
                        value     = 957
                    },
                    new {
                        timestamp = "1973-06-01T00:00:00Z",
                        value     = 924
                    },
                    new {
                        timestamp = "1973-07-01T00:00:00Z",
                        value     = 881
                    },
                    new {
                        timestamp = "1973-08-01T00:00:00Z",
                        value     = 837
                    },
                    new {
                        timestamp = "1973-09-01T00:00:00Z",
                        value     = 784
                    },
                    new {
                        timestamp = "1973-10-01T00:00:00Z",
                        value     = 791
                    },
                    new {
                        timestamp = "1973-11-01T00:00:00Z",
                        value     = 760
                    },
                    new {
                        timestamp = "1973-12-01T00:00:00Z",
                        value     = 802
                    },
                    new {
                        timestamp = "1974-01-01T00:00:00Z",
                        value     = 828
                    },
                    new {
                        timestamp = "1974-02-01T00:00:00Z",
                        value     = 1030
                    },
                    new {
                        timestamp = "1974-03-01T00:00:00Z",
                        value     = 889
                    },
                    new {
                        timestamp = "1974-04-01T00:00:00Z",
                        value     = 902
                    },
                    new {
                        timestamp = "1974-05-01T00:00:00Z",
                        value     = 969
                    },
                    new {
                        timestamp = "1974-06-01T00:00:00Z",
                        value     = 947
                    },
                    new {
                        timestamp = "1974-07-01T00:00:00Z",
                        value     = 908
                    },
                    new {
                        timestamp = "1974-08-01T00:00:00Z",
                        value     = 867
                    },
                    new {
                        timestamp = "1974-09-01T00:00:00Z",
                        value     = 815
                    },
                    new {
                        timestamp = "1974-10-01T00:00:00Z",
                        value     = 812
                    },
                    new {
                        timestamp = "1974-11-01T00:00:00Z",
                        value     = 773
                    },
                    new {
                        timestamp = "1974-12-01T00:00:00Z",
                        value     = 813
                    },
                    new {
                        timestamp = "1975-01-01T00:00:00Z",
                        value     = 834
                    },
                    new {
                        timestamp = "1975-02-01T00:00:00Z",
                        value     = 782
                    },
                    new {
                        timestamp = "1975-03-01T00:00:00Z",
                        value     = 892
                    },
                    new {
                        timestamp = "1975-04-01T00:00:00Z",
                        value     = 903
                    },
                    new {
                        timestamp = "1975-05-01T00:00:00Z",
                        value     = 966
                    },
                    new {
                        timestamp = "1975-06-01T00:00:00Z",
                        value     = 937
                    },
                    new {
                        timestamp = "1975-07-01T00:00:00Z",
                        value     = 896
                    },
                    new {
                        timestamp = "1975-08-01T00:00:00Z",
                        value     = 858
                    },
                    new {
                        timestamp = "1975-09-01T00:00:00Z",
                        value     = 817
                    },
                    new {
                        timestamp = "1975-10-01T00:00:00Z",
                        value     = 827
                    },
                    new {
                        timestamp = "1975-11-01T00:00:00Z",
                        value     = 797
                    },
                    new {
                        timestamp = "1975-12-01T00:00:00Z",
                        value     = 843
                    }
                },
                granularity     = "monthly",
                maxAnomalyRatio = 0.25,
                sensitivity     = 95,
            }).GetAwaiter().GetResult();

            // TODO(matell): This is kinda tedious, I think we need to be able to make this cleaner.
            if (res.GetRawResponse().Status == 200)
            {
                foreach (bool isAnomaly in res.Content.isAnomaly)
                {
                    Console.WriteLine(isAnomaly);
                }
            }
            else if (res.GetRawResponse().Status == 400)
            {
                Console.WriteLine($"Bad request code: {res.Content.code}, message: {res.Content.message}");
            }
        }