Beispiel #1
0
        static async Task <int> Main(string[] args)
        {
            MxReturnCode <int> rc = new MxReturnCode <int>($"{Program.WebAppName} v{Program.WebAppVersion}", 1);

            rc.Init(Assembly.GetExecutingAssembly(), "*****@*****.**", null, null, null, MxMsgs.SupportedCultures);

            Console.WriteLine(rc.GetInvokeDetails());

            var config = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
                         .AddJsonFile("local.settings.json")
                         .Build();
            var conn = config?["ConnectionStrings:DefaultConnection"];  //03-12-18

            if (conn == null)
            {
                rc.SetError(2010101, MxError.Source.AppSetting, "config not built or ConnectionStrings:DefaultConnection not found");
            }
            else
            {
                using (IAdminRepo repo = new AdminRepo(conn))
                {
                    rc += await repo.GetUrdCountAsync();
                }
                if (rc.IsSuccess(true))
                {
                    Console.WriteLine($"Roles found = {rc.GetResult()}");
                    rc.SetResult(0);
                }
            }
            Console.WriteLine(rc.IsError(true) ? rc.GetErrorUserMsg() : $"Hello World!");
            Console.WriteLine(rc.IsError(true) ? rc.GetErrorTechMsg(): "no error");

            return(rc.GetResult());
        }
Beispiel #2
0
        static async Task <int> Main(string[] args) //Uses Dapper/Gdpr.Domain Repository classes to access the database
        {
            MxUserMsg.Init(Assembly.GetExecutingAssembly(), MxMsgs.SupportedCultures);

            MxReturnCode <int> rc = new MxReturnCode <int>(string.Format("{0} v{1}", "ReturnCodeApp()", GetVersion()), 1, "*****@*****.**");

            var config = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
                         .AddJsonFile("local.settings.json")
                         .Build();
            var conn = config?["ConnectionStrings:DefaultConnection"];  //03-12-18

            if (conn == null)
            {
                rc.SetError(2010101, MxError.Source.AppSetting, "config not built or ConnectionStrings:DefaultConnection not found");
            }
            else
            {
                using (IAdminRepository repository = new AdminRepository(conn))
                {
                    rc += await repository.GetRoleCountAsync();
                }
                if (rc.IsSuccess())
                {
                    Console.WriteLine(@"URD Count = {0}", rc.GetResult());
                }
            }
            if (rc.IsError())
            {
                Console.WriteLine(rc.GetErrorUserMsg());
                Console.WriteLine(rc.GetErrorTechMsg());
            }
            else
            {
                Console.WriteLine("ends ok");
            }

            return(rc.IsSuccess() ? 0 : -1);
        }