Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            IWebHost webHost = null;

            try
            {
                webHost = CreateWebHostBuilder(args)

                          // Although you can put the following configuration to CreateWebHostBuilder,
                          // I suggest putting these configurations outside. Because these configuration
                          // is either supplement configuration (Logging) or highly related to certain
                          // environment. We can configure these aspects in the unit test base class.
                          .UseWebAppLogger()
                          .UseHttpClient()
                          .Build();
            }
            catch (Exception error)
            {
                // Some project template initializes the configuration at the entry point of the
                // program to create a logger instance. This is not feasible for certain
                // environment. For example. If the application is hosted on IIS Server. The
                // GetCurrentDirectory method will returns the work's base address rather than the
                // application content root.
                //
                // So my recommendation is to create a temporary logger to record issues happened
                // during web host initialization. Then just abandoned the logger as soon as the
                // web host is ready. Since it is most possible that the logger will record fatal
                // errors, it is better set a global wide sink to ensure the logs are recorded.
                // (e.g. OS Event Sink, or local file system).
                using (IEmergencyLogger logger = EmergencyLoggerFactory.Create())
                {
                    logger.Fatal(
                        error,
                        "An error occured during initialization with start args {args}",
                        (object)args);
                }
            }

            webHost?.Run();
        }
        public static void Main(string[] args)
        {
            Console.WriteLine("BEGIN Main()");
            // initialize variables
            int SleeptimeWhileStarting = 0;
            int SleeptimeWhileClosing  = 0;

            string tempstring = Environment.GetEnvironmentVariable("ASPNETCORE_TOKEN");

            if (!string.IsNullOrEmpty(tempstring))
            {
                InprocessMode = false;
                tempstring    = null;
            }
            else
            {
                InprocessMode = true;
            }

            tempstring = Environment.GetEnvironmentVariable("ANCMTestStartUpDelay");
            if (!string.IsNullOrEmpty(tempstring))
            {
                SleeptimeWhileStarting         = Convert.ToInt32(tempstring);
                Startup.SleeptimeWhileStarting = SleeptimeWhileStarting;
                Console.WriteLine("SleeptimeWhileStarting: " + Startup.SleeptimeWhileStarting);
                tempstring = null;
            }

            tempstring = Environment.GetEnvironmentVariable("ANCMTestShutdownDelay");
            if (!string.IsNullOrEmpty(tempstring))
            {
                SleeptimeWhileClosing         = Convert.ToInt32(tempstring);
                Startup.SleeptimeWhileClosing = SleeptimeWhileClosing;
                Console.WriteLine("SleeptimeWhileClosing: " + Startup.SleeptimeWhileClosing);
            }

            // Build WebHost
            IWebHost        host               = null;
            IWebHostBuilder builder            = null;
            string          startUpClassString = Environment.GetEnvironmentVariable("ANCMTestStartupClassName");

            if (!string.IsNullOrEmpty(startUpClassString))
            {
                Console.WriteLine("ANCMTestStartupClassName: " + startUpClassString);
                IConfiguration config = new ConfigurationBuilder()
                                        .AddCommandLine(args)
                                        .Build();

                if (startUpClassString == "StartupHTTPS")
                {
                    // load .\testresources\testcert.pfx
                    string pfxPassword = "******";
                    if (File.Exists(@".\TestResources\testcert.pfx"))
                    {
                        Console.WriteLine("Certificate file found");
                        _x509Certificate2 = new X509Certificate2(@".\TestResources\testcert.pfx", pfxPassword);
                    }
                    else
                    {
                        Console.WriteLine("Error!!! Certificate file not found");
                        //throw new Exception("Error!!! Certificate file not found");
                    }
                }
                else if (startUpClassString == "StartupCompressionCaching" || startUpClassString == "StartupNoCompressionCaching")
                {
                    if (startUpClassString == "StartupNoCompressionCaching")
                    {
                        StartupCompressionCaching.CompressionMode = false;
                    }
                    host = CreateDefaultBuilder(args)
                           .UseConfiguration(config)
                           // BUGBUG below line is commented out because it causes 404 error with inprocess mode
                           //.UseContentRoot(Directory.GetCurrentDirectory())
                           .UseStartup <StartupCompressionCaching>()
                           .Build();
                }
                else if (startUpClassString == "StartupHelloWorld")
                {
                    host = CreateDefaultBuilder(args)
                           .UseConfiguration(config)
                           .UseStartup <StartupHelloWorld>()
                           .Build();
                }
                else if (startUpClassString == "StartupNtlmAuthentication")
                {
                    host = CreateDefaultBuilder(args)
                           .UseConfiguration(config)
                           .UseStartup <StartupNtlmAuthentication>()
                           .Build();
                }
                else if (startUpClassString == "StartupWithShutdownDisabled")
                {
                    builder = new WebHostBuilder()
                              .UseKestrel()
                              .ConfigureServices(services =>
                    {
                        const string PairingToken = "TOKEN";

                        string paringToken = null;
                        if (InprocessMode)
                        {
                            Console.WriteLine("Don't use IISMiddleware for inprocess mode");
                            paringToken = null;
                        }
                        else
                        {
                            Console.WriteLine("Use IISMiddleware for outofprocess mode");
                            paringToken = builder.GetSetting(PairingToken) ?? Environment.GetEnvironmentVariable($"ASPNETCORE_{PairingToken}");
                        }
                        services.AddSingleton <IStartupFilter>(
                            new IISSetupFilter(paringToken)
                            );
                    })
                              .UseConfiguration(config)
                              .UseStartup <Startup>();

                    host = builder.Build();
                }
                else
                {
                    throw new Exception("Invalid startup class name : " + startUpClassString);
                }
            }

            if (host == null)
            {
                host = CreateDefaultBuilder(args)
                       .UseStartup <Startup>()
                       .Build();
            }

            // Initialize AppLifeTime events handler
            AppLifetime = (IApplicationLifetime)host.Services.GetService(typeof(IApplicationLifetime));
            AppLifetime.ApplicationStarted.Register(
                () =>
            {
                Thread.Sleep(1000);
                Console.WriteLine("AppLifetime.ApplicationStarted.Register()");
            }
                );
            AppLifetime.ApplicationStopping.Register(
                () =>
            {
                tempstring = Environment.GetEnvironmentVariable("ANCMTestDisableWebCocketConnectionsCloseAll");
                if (string.IsNullOrEmpty(tempstring))
                {
                    Console.WriteLine("Begin: WebSocketConnections");
                    WebSocketConnections.CloseAll();
                    Console.WriteLine("End: WebSocketConnections");
                }

                Console.WriteLine("Begin: AppLifetime.ApplicationStopping.Register(), sleeping " + Startup.SleeptimeWhileClosing / 2);
                Thread.Sleep(Startup.SleeptimeWhileClosing);
                Startup.SleeptimeWhileClosing = 0;
                Console.WriteLine("End: AppLifetime.ApplicationStopping.Register()");
            }
                );
            AppLifetime.ApplicationStopped.Register(
                () =>
            {
                Console.WriteLine("AppLifetime.ApplicationStopped.Register()");
            }
                );

            // run
            try
            {
                Console.WriteLine("BEGIN Main::Run()");
                host.Run();
                Console.WriteLine("END Main::Run()");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception error!!! " + ex.Message);
            }

            // Sleep before finishing
            if (Startup.SleeptimeWhileClosing > 0)
            {
                Console.WriteLine("Begin: SleeptimeWhileClosing " + Startup.SleeptimeWhileClosing);
                Thread.Sleep(Startup.SleeptimeWhileClosing);
                Console.WriteLine("End: SleeptimeWhileClosing");
            }
            Console.WriteLine("END Main()");
        }
Ejemplo n.º 3
0
 public void Run()
 {
     _host.Run();
 }
Ejemplo n.º 4
0
 public void Run() => _webHost.Run();
Ejemplo n.º 5
0
        public static void Main(string[] args)
        {
            IWebHost host = CreateWebHostBuilder(args).Build();

            host.Run();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Triggered when http connect button is hit
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_connectHttp_Click(object sender, RoutedEventArgs e)
        {
            int port = int.Parse(this.textBox_httpPort.Text);

            if (AspThread == null)
            {
                var tmpLogArgs = new TCSMessageEventArgs();
                tmpLogArgs.Message   = string.Format("Starting ASP.NET WebAPI to listen for incoming requests.");
                tmpLogArgs.Verbosity = Verbosity.Important;
                tmpLogArgs.Category  = LogTextCategory.Info;
                tmpLogArgs.Recipient = Recipient.HttpServerTextBox;
                tmpLogArgs.When      = DateTime.Now;
                Logging.SendMessage(tmpLogArgs);

                AspThread = new Thread(p => {
                    AspHost = WebAPISession.RunAsp((int)p);
                    AspHost.Run();
                });
                AspThread.Start(port);


                tmpLogArgs.When = DateTime.Now;
                string hostName = Dns.GetHostName();
                tmpLogArgs.Message  = "..Done! Available request routes: ";
                tmpLogArgs.Message += Logging.NewLineTab + "http://" + hostName + ":" + port + "/twincat/";
                tmpLogArgs.Message += Logging.NewLineTab + "http://localhost:" + port + "/twincat/";
                tmpLogArgs.Message += Logging.NewLineTab + "http://127.0.0.1:" + port + "/twincat/";

                foreach (IPAddress ip in Dns.GetHostAddresses(hostName))
                {
                    if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                    {
                        tmpLogArgs.Message += Logging.NewLineTab + "http://" + ip.ToString() + ":" + port + "/twincat/";
                    }
                }

                tmpLogArgs.Verbosity = Verbosity.Verbose;
                Logging.SendMessage(tmpLogArgs);
            }

            else
            {
                AspHost?.StopAsync().Wait();
                AspThread?.Abort();
                AspThread = null;
            }


            if (InternalServer == null || InternalServer.listener == null || !InternalServer.listener.IsListening || !InternalServer.Running)
            {
                HttpThread = new Thread(p => { InternalServer.Start((int)p); });
                HttpThread.Start(port + 1);
            }

            else
            {
                Task.Run(new Action(() =>
                {
                    try
                    {
                        //will throw an error, bc it's shutting down the server it actively tries to call
                        InternalWorkerClient.GetAsync("http://localhost:" + InternalServer.Port.ToString() + "/btn_shutdown").Wait();
                    }
                    finally
                    {
                        HttpThread?.Abort();
                    }
                }));
            }
        }
Ejemplo n.º 7
0
        public static void Main(string[] args)
        {
            IWebHost webHost = BuildWebHost(args);

            webHost.Run();
        }
Ejemplo n.º 8
0
        public static void Main(string[] args)
        {
            IWebHost host = WebHost.CreateDefaultBuilder(args).UseStartup <Startup>().Build();

            host.Run();
        }
Ejemplo n.º 9
0
 public static void Main(string[] args)
 {
     AppDomain.CurrentDomain.ProcessExit += OnTermination;
     _webHost = BuildWebHost(args);
     _webHost.Run();
 }
Ejemplo n.º 10
0
 protected virtual void Run(IWebHost host)
 {
     Logger.Information <ProgramBase>("starting");
     host.Run();
     Logger.Information <ProgramBase>("finished");
 }
Ejemplo n.º 11
0
        public static void Main(string[] args)
        {
            IWebHost webHost = CreateWebHostBuilder(args).Build();

            using (IServiceScope service = webHost.Services.CreateScope())
            {
                using (AutoEntity db = service.ServiceProvider.GetRequiredService <AutoEntity>())
                {
                    //if (!db.Languages.Any())
                    //{
                    //    Language language = new Language()
                    //    {
                    //        Key = "en",
                    //        Value = "1"
                    //    };
                    //    Language language2 = new Language()
                    //    {
                    //        Key = "ru",
                    //        Value = "2"
                    //    };
                    //    Language language3 = new Language()
                    //    {
                    //        Key = "ger",
                    //        Value = "3"
                    //    };

                    //    db.Languages.AddRange(language, language2, language3);
                    //    db.SaveChanges();
                    //}
                    //if (!db.Categories.Any())
                    //{
                    //    var category = new Category()
                    //    {
                    //        Name = "Citroen",
                    //    };

                    //    db.Categories.Add(category);
                    //    db.SaveChanges();
                    //}
                    //if (!db.CategoryLanguages.Any())
                    //{
                    //    var categoryLanguegae = new CategoryLanguage()
                    //    {
                    //        CategoryId = 1,
                    //        LanguageId = 1
                    //    };
                    //    db.CategoryLanguages.Add(categoryLanguegae);
                    //    db.SaveChanges();
                    //}

                    //if (!db.SubCategories.Any())
                    //{
                    //    SubCategory subCategory = new SubCategory()
                    //    {
                    //        Name = "Engine Lubrication",
                    //    };

                    //    db.SubCategories.Add(subCategory);
                    //    db.SaveChanges();
                    //}
                    //if (!db.SubCategoryLanguages.Any())
                    //{
                    //    SubCategoryLanguage subCategoryLanguage = new SubCategoryLanguage()
                    //    {
                    //        SubCategoryId = 1,
                    //        LanguageId = 1
                    //    };
                    //    db.SubCategoryLanguages.Add(subCategoryLanguage);
                    //    db.SaveChanges();
                    //}
                    //if (!db.Products.Any())
                    //{
                    //    Product product = new Product()
                    //    {
                    //        SubCategoryId = 1,
                    //    };


                    //    db.Products.Add(product);
                    //    db.SaveChanges();
                    //}
                    //if (!db.ProductCategories.Any())
                    //{
                    //    ProductCategory pr = new ProductCategory()
                    //    {
                    //        CategoryId = 1,
                    //        ProductId = 1
                    //    };

                    //    db.ProductCategories.Add(pr);
                    //    db.SaveChanges();
                    //}
                    //if (!db.ProductLanguages.Any())
                    //{
                    //    ProductLanguage productLanguage = new ProductLanguage()
                    //    {
                    //        ProductId = 1,
                    //        LanguageId = 1
                    //    };
                    //    db.ProductLanguages.Add(productLanguage);
                    //}
                    //if (!db.RealPartNos.Any())
                    //{
                    //    RealPartNo realPartNo = new RealPartNo()
                    //    {
                    //        Name = "000 018 07 02",
                    //        ProductId = 1
                    //    };
                    //    db.RealPartNos.Add(realPartNo);
                    //    db.SaveChanges();
                    //}


                    AdminCreater.CreatAsync(service, db).Wait();
                }
            }
            webHost.Run();
        }
Ejemplo n.º 12
0
        public static void Main(string[] args)
        {
            ProcessEnvironmentVariables();

            ProcessCommandArgs(args);

            ValidateParameters();

            Smoker = new Smoker.Test(Config.FileList, Config.Host);

            // run one test iteration
            if (!Config.RunLoop && !Config.RunWeb)
            {
                if (!Smoker.Run().Result)
                {
                    Environment.Exit(-1);
                }

                return;
            }

            IWebHost host = null;

            // configure web server
            if (Config.RunWeb)
            {
                // use the default web host builder + startup
                IWebHostBuilder builder = WebHost.CreateDefaultBuilder(args)
                                          .UseKestrel()
                                          .UseStartup <Startup>()
                                          .UseUrls("http://*:4122/");

                // build the host
                host = builder.Build();
            }

            using (CancellationTokenSource ctCancel = new CancellationTokenSource())
            {
                // setup ctl c handler
                Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e)
                {
                    e.Cancel = true;
                    ctCancel.Cancel();

                    Console.WriteLine("Ctl-C Pressed - Starting shutdown ...");

                    // give threads a chance to shutdown
                    Thread.Sleep(500);

                    // end the app
                    Environment.Exit(0);
                };

                // run tests in config.RunLoop
                if (Config.RunLoop)
                {
                    TaskRunner tr;

                    for (int i = 0; i < Config.Threads; i++)
                    {
                        tr = new TaskRunner {
                            TokenSource = ctCancel
                        };

                        tr.Task = Smoker.RunLoop(i, App.Config, tr.TokenSource.Token);

                        TaskRunners.Add(tr);
                    }
                }

                // run the web server
                if (Config.RunWeb)
                {
                    try
                    {
                        Console.WriteLine($"Version: {Helium.Version.AssemblyVersion}");

                        host.Run();
                        Console.WriteLine("Web server shutdown");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine($"Web Server Exception\n{ex}");
                    }

                    return;
                }

                // run the task loop
                if (Config.RunLoop && TaskRunners.Count > 0)
                {
                    // Wait for all tasks to complete
                    List <Task> tasks = new List <Task>();

                    foreach (var trun in TaskRunners)
                    {
                        tasks.Add(trun.Task);
                    }

                    // wait for ctrl c
                    Task.WaitAll(tasks.ToArray());
                }
            }
        }
Ejemplo n.º 13
0
        public static void Main(string[] args)
        {
            IWebHost webHost = CreateWebHostBuilder(args).Build();

            using (IServiceScope scopedService = webHost.Services.CreateScope())
            {
                using (EvekilEntity dbContext = scopedService.ServiceProvider.GetRequiredService <EvekilEntity>())
                {
                    if (!dbContext.Languages.Any())
                    {
                        #region Languages
                        Language en = new Language()
                        {
                            Key   = "en",
                            Value = "English"
                        };
                        Language az = new Language()
                        {
                            Key   = "az",
                            Value = "Azerbaijan"
                        };
                        #endregion
                        dbContext.Languages.AddRange(en, az);
                        dbContext.SaveChanges();
                    }
                    if (!dbContext.Advocates.Any())
                    {
                        #region Advocates
                        Advocate NihadAliyev = new Advocate()
                        {
                            Name    = "Nihad",
                            Surname = "Əliyev",
                            Email   = "*****@*****.**",
                            Phone   = 0502503575
                        };
                        #endregion
                        dbContext.Advocates.Add(NihadAliyev);
                        dbContext.SaveChanges();
                    }
                    if (!dbContext.Categories.Any())
                    {
                        #region Categories
                        Category category = new Category()
                        {
                            PhotoPath = "hr1.jpg",
                            Visibilty = true
                        };
                        Category category2 = new Category()
                        {
                            PhotoPath = "hr1.jpg",
                            Visibilty = true
                        };
                        Category category3 = new Category()
                        {
                            PhotoPath = "hr1.jpg",
                            Visibilty = true
                        };
                        Category category4 = new Category()
                        {
                            PhotoPath = "hr1.jpg",
                            Visibilty = true
                        };
                        dbContext.Categories.AddRange(category, category2, category3, category4);
                        dbContext.SaveChanges();


                        CategoryLanguage IR = new CategoryLanguage()
                        {
                            Name        = "İnsan Resursları",
                            Description = @"Bu bölmədə kadrlar şöbəsinin faəliyyətinə aid müxtəlif sənəd nümunələri, o cümlədən əmr formaları, əmək müqavilələri, əmək müqavilələrinə əlavələr, vəzifə təlimatları, aktlar, izahat formaları, ərizələr, əmr kitabları və s. yerləşdirilmişdir.
                                           Diqqətinizə təqdim edilən bu sənəd nümunələri Azərbaycan Respublikasında fəaliyyət göstərən müxtəlif təşkilatlar tərəfindən istifadə edilməkdədir.",
                            CategoryId  = 1,
                            LanguageId  = 2
                        };
                        CategoryLanguage MS = new CategoryLanguage()
                        {
                            Name        = "Məhkəmə Sənədləri",
                            Description = @"Əsasən mülki və iqtisadi mübahisələr üzrə məhkəməyə qədər və məhkəmə araşdırması dövründə tərtib edilən sənəd nümunələri bu bölmədə sizin diqqətinizə təqdim edilir.
                                            Sənəd nümunələri arasında təmənnasız təqdim edilən bəzi iddia ərizələri formaları ilə yanaşı, müxtəlif məzmunlu və formalı vəsatətlər, apellyasiya şikayətləri, kassasiya şikayətləri formaları və s. mövcuddur. Sənəd nümunələri Azərbaycan Respublikası Vəkillər Kollegiyasının üzvləri tərəfindən tərtib edilmişdir. Sənəd nümunələrindən real məhkəmə işlərində istifadə edilmişdir.",
                            CategoryId  = 2,
                            LanguageId  = 2
                        };
                        CategoryLanguage M = new CategoryLanguage()
                        {
                            Name        = "Müqavilələr",
                            Description = @"Azərbaycan Respublikasının qanunvericiliyinə uyğun tərtib edilən müxtəlif müqavilə növləri. Təqdim edilən bütün müqavilə növləri təcrübədə istifadə edilmişdir.
                                           Müqavilələr arasında tez-tez istifadə edilən alğı-satqı, bağışlama, podrat, xidmət müqavilələri ilə yanaşı Azərbaycan işgüzar adətlərində yeni-yeni rast gəlinən autsorsinq, birgə əməliyyat sazişləri nümunələri də daxil edilmişdir.",
                            CategoryId  = 3,
                            LanguageId  = 2
                        };
                        CategoryLanguage SS = new CategoryLanguage()
                        {
                            Name        = "Sair Sənədlər",
                            Description = @"Yuxarıdakı təsnifata yer almamış sənəd nümunələrini hazırki bölmədə yerləşdirərək diqqətinizə çatdırırıq. Bu bölmədə hüquqi şəxsin təsis sənədləri nümunələri, informasiya sorğuları, şikayət ərizələri, prtokol formaları, etibarnamələr, müraciət ərizələri və s. sənəd nümunələri yerləşdirilmişdir.
                                           We understand business. That's why we begin every project with a workshop — crafting a one-of-a-kind, unique strategy that is designed to help you win.",
                            CategoryId  = 4,
                            LanguageId  = 2
                        };
                        #endregion
                        dbContext.CategoryLanguages.AddRange(IR, M, MS, SS);
                        dbContext.SaveChanges();
                    }
                    if (!dbContext.Subcategories.Any())
                    {
                        #region Subcategories

                        #region InsanResurslariSubcategoriyasi
                        Subcategory _EM = new Subcategory()
                        {
                            CategoryId = 1
                        };
                        Subcategory _EF = new Subcategory()
                        {
                            CategoryId = 1
                        };
                        Subcategory _VT = new Subcategory()
                        {
                            CategoryId = 1
                        };
                        Subcategory _E = new Subcategory()
                        {
                            CategoryId = 1
                        };
                        Subcategory _EK = new Subcategory()
                        {
                            CategoryId = 1
                        };
                        Subcategory _EV = new Subcategory()
                        {
                            CategoryId = 1
                        };
                        Subcategory _A = new Subcategory()
                        {
                            CategoryId = 1
                        };
                        dbContext.Subcategories.AddRange(_EM, _EF, _VT, _E, _EK, _EV, _A);
                        dbContext.SaveChanges();

                        SubcategoryLanguage EM = new SubcategoryLanguage()
                        {
                            Name          = "Əmək Müqaviləsi",
                            SubcategoryId = 1,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage EF = new SubcategoryLanguage()
                        {
                            Name          = "Əmr Formaları",
                            SubcategoryId = 2,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage VT = new SubcategoryLanguage()
                        {
                            Name          = "Vəzifə Təlimatları",
                            SubcategoryId = 3,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage E = new SubcategoryLanguage()
                        {
                            Name          = "Ərizələr",
                            SubcategoryId = 4,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage EK = new SubcategoryLanguage()
                        {
                            Name          = "Əmr Kitabları",
                            SubcategoryId = 5,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage EV = new SubcategoryLanguage()
                        {
                            Name          = "Ezamiyyə Vərəqələri",
                            SubcategoryId = 6,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage A = new SubcategoryLanguage()
                        {
                            Name          = "Aktlar",
                            SubcategoryId = 7,
                            LanguageId    = 2
                        };
                        #endregion

                        #region MehkemeSenedleriSubcategoriyasi
                        Subcategory _IE = new Subcategory()
                        {
                            CategoryId = 2
                        };
                        Subcategory _AS = new Subcategory()
                        {
                            CategoryId = 2
                        };
                        Subcategory _KS = new Subcategory()
                        {
                            CategoryId = 2
                        };
                        Subcategory _V = new Subcategory()
                        {
                            CategoryId = 2
                        };
                        Subcategory _BS = new Subcategory()
                        {
                            CategoryId = 2
                        };
                        Subcategory _QIE = new Subcategory()
                        {
                            CategoryId = 2
                        };
                        Subcategory _ET = new Subcategory()
                        {
                            CategoryId = 2
                        };
                        dbContext.Subcategories.AddRange(_IE, _AS, _KS, _V, _BS, _QIE, _ET);
                        dbContext.SaveChanges();

                        SubcategoryLanguage IE = new SubcategoryLanguage()
                        {
                            Name          = "İddia Ərizələri",
                            SubcategoryId = 8,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage AS = new SubcategoryLanguage()
                        {
                            Name          = "Apelyasiya Şikayətləri",
                            SubcategoryId = 9,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage KS = new SubcategoryLanguage()
                        {
                            Name          = "Kassasiya Şikayətləri",
                            SubcategoryId = 10,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage V = new SubcategoryLanguage()
                        {
                            Name          = "Vəsatətlər",
                            SubcategoryId = 11,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage BS = new SubcategoryLanguage()
                        {
                            Name          = "Barışıq Sazişləri",
                            SubcategoryId = 12,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage QIE = new SubcategoryLanguage()
                        {
                            Name          = "Qarşılıqlı İddia Ərizələri",
                            SubcategoryId = 13,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage ET = new SubcategoryLanguage()
                        {
                            Name          = "Etirazlar",
                            SubcategoryId = 14,
                            LanguageId    = 2
                        };
                        #endregion

                        #region MuqavilelerSubcategoriyasi
                        Subcategory _ASM = new Subcategory()
                        {
                            CategoryId = 3
                        };
                        Subcategory _PM = new Subcategory()
                        {
                            CategoryId = 3
                        };
                        Subcategory _XM = new Subcategory()
                        {
                            CategoryId = 3
                        };
                        Subcategory _BM = new Subcategory()
                        {
                            CategoryId = 3
                        };
                        Subcategory _DM = new Subcategory()
                        {
                            CategoryId = 3
                        };
                        Subcategory _ME = new Subcategory()
                        {
                            CategoryId = 3
                        };
                        Subcategory _IM = new Subcategory()
                        {
                            CategoryId = 3
                        };
                        dbContext.Subcategories.AddRange(_ASM, _PM, _XM, _BM, _DM, _ME, _IM);
                        dbContext.SaveChanges();

                        SubcategoryLanguage ASM = new SubcategoryLanguage()
                        {
                            Name          = "Alğı-satqı Müqavilələri",
                            SubcategoryId = 15,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage PM = new SubcategoryLanguage()
                        {
                            Name          = "Podrat Müqavilələri",
                            SubcategoryId = 16,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage XM = new SubcategoryLanguage()
                        {
                            Name          = "Xidmət Müqavilələri",
                            SubcategoryId = 17,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage BM = new SubcategoryLanguage()
                        {
                            Name          = "Borc Müqavilələri",
                            SubcategoryId = 18,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage DM = new SubcategoryLanguage()
                        {
                            Name          = "Daşınma Müqavilələri",
                            SubcategoryId = 19,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage ME = new SubcategoryLanguage()
                        {
                            Name          = "Müqavilələrə Əlavələr",
                            SubcategoryId = 20,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage IM = new SubcategoryLanguage()
                        {
                            Name = "İcarə Müqavilələri" +
                                   "",
                            SubcategoryId = 21,
                            LanguageId    = 2
                        };
                        #endregion

                        #region SairSenedlerSubcategoriyasi
                        Subcategory _HSUY = new Subcategory()
                        {
                            CategoryId = 4
                        };
                        Subcategory _EUMEF = new Subcategory()
                        {
                            CategoryId = 4
                        };
                        Subcategory _ES = new Subcategory()
                        {
                            CategoryId = 4
                        };
                        Subcategory _TQ = new Subcategory()
                        {
                            CategoryId = 4
                        };
                        Subcategory _VF = new Subcategory()
                        {
                            CategoryId = 4
                        };
                        Subcategory _Akt = new Subcategory()
                        {
                            CategoryId = 4
                        };
                        Subcategory _QF = new Subcategory()
                        {
                            CategoryId = 4
                        };
                        dbContext.Subcategories.AddRange(_HSUY, _EUMEF, _ES, _TQ, _VF, _Akt, _QF);
                        dbContext.SaveChanges();

                        SubcategoryLanguage HSUY = new SubcategoryLanguage()
                        {
                            Name          = "Hüquqi Şəxsin Ümumi Yığıncağının Qərarı",
                            SubcategoryId = 22,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage EUMEF = new SubcategoryLanguage()
                        {
                            Name          = "Əfv üçün Müraciət Ərizə Forması",
                            SubcategoryId = 23,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage ES = new SubcategoryLanguage()
                        {
                            Name          = "Etibarnamələr",
                            SubcategoryId = 24,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage TQ = new SubcategoryLanguage()
                        {
                            Name          = "Təsisçinin Qərarı",
                            SubcategoryId = 25,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage VF = new SubcategoryLanguage()
                        {
                            Name          = "Vəsiyyətnamə Formaları",
                            SubcategoryId = 26,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage Akt = new SubcategoryLanguage()
                        {
                            Name          = "Aktlar",
                            SubcategoryId = 27,
                            LanguageId    = 2
                        };
                        SubcategoryLanguage QF = new SubcategoryLanguage()
                        {
                            Name          = "Qərar Formaları",
                            SubcategoryId = 28,
                            LanguageId    = 2
                        };
                        #endregion
                        #endregion
                        dbContext.SubcategoryLanguages.AddRange(EM, EF, VT, E, EK, EV, A, IE, AS, KS, V, BS, QIE, ET, ASM, PM, XM, BM, DM, ME, IM, HSUY, EUMEF, ES, TQ, VF, Akt, QF);
                        dbContext.SaveChanges();
                    }
                    //   UserAndRoleCreater.CreateAsync(scopedService, dbContext).Wait();
                }
            }

            webHost.Run();
        }
Ejemplo n.º 14
0
        public static void Main(string[] args)
        {
            IWebHost webHost = BuildWebHost(args);

            using (IServiceScope scope = webHost.Services.CreateScope())
            {
                IServiceProvider serviceProvider = scope.ServiceProvider;
                try
                {
                    AppDbContext appDbContext = serviceProvider.GetRequiredService <AppDbContext>();
                    DbInitializer.Seed(appDbContext);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }

            using (IServiceScope scope = webHost.Services.CreateScope())
            {
                IServiceProvider serviceProvider = scope.ServiceProvider;
                try
                {
                    UserManager <ApplicationUser> userManager = serviceProvider.GetRequiredService <UserManager <ApplicationUser> >();

                    if (userManager.FindByNameAsync("admin").Result == null)
                    {
                        var            adminApplicationUser = new ApplicationUser("admin");
                        IdentityResult identityResult       = userManager.CreateAsync(adminApplicationUser, "12345").Result;

                        if (!identityResult.Succeeded)
                        {
                            throw new Exception("admin cannot be inserted");
                        }
                    }

                    RoleManager <IdentityRole> roleManager = serviceProvider.GetRequiredService <RoleManager <IdentityRole> >();

                    if (roleManager.FindByNameAsync("Administrators").Result == null)
                    {
                        IdentityResult identityResult = roleManager.CreateAsync(new IdentityRole("Administrators")).Result;

                        if (!identityResult.Succeeded)
                        {
                            throw new Exception("admin role cannot be inserted");
                        }
                    }

                    ApplicationUser admin = userManager.FindByNameAsync("admin").Result;
                    if (!userManager.IsInRoleAsync(admin, "Administrators").Result)
                    {
                        IdentityResult identityResult = userManager.AddToRoleAsync(admin, "Administrators").Result;

                        if (!identityResult.Succeeded)
                        {
                            throw new Exception("admin user cannot be added to admin role");
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }

            webHost.Run();
        }
Ejemplo n.º 15
0
        public static void Main(string[] args)
        {
            IWebHost webHost = CreateWebHostBuilder(args).Build();

            using (IServiceScope scopedService = webHost.Services.CreateScope())
            {
                using (EvekilDb dbContext = scopedService.ServiceProvider.GetRequiredService <EvekilDb>())
                {
                    if (!dbContext.Advocates.Any())
                    {
                        #region Advocates
                        Advocate NihadAliyev = new Advocate()
                        {
                            Name    = "Nihad",
                            Surname = "Əliyev",
                            Email   = "*****@*****.**",
                            Phone   = 0502503575
                        };
                        #endregion
                        dbContext.Advocates.Add(NihadAliyev);
                        dbContext.SaveChanges();
                    }
                    if (!dbContext.Subcategories.Any() && !dbContext.Categories.Any())
                    {
                        #region Categories
                        Category IR = new Category()
                        {
                            Name        = "İnsan Resursları",
                            Description = @"Bu bölmədə kadrlar şöbəsinin faəliyyətinə aid müxtəlif sənəd nümunələri, o cümlədən əmr formaları, əmək müqavilələri, əmək müqavilələrinə əlavələr, vəzifə təlimatları, aktlar, izahat formaları, ərizələr, əmr kitabları və s. yerləşdirilmişdir.
                                           Diqqətinizə təqdim edilən bu sənəd nümunələri Azərbaycan Respublikasında fəaliyyət göstərən müxtəlif təşkilatlar tərəfindən istifadə edilməkdədir.",
                            Visibilty   = true,
                            PhotoPath   = "hr1.jpg"
                        };
                        Category MS = new Category()
                        {
                            Name        = "Məhkəmə Sənədləri",
                            Description = @"Əsasən mülki və iqtisadi mübahisələr üzrə məhkəməyə qədər və məhkəmə araşdırması dövründə tərtib edilən sənəd nümunələri bu bölmədə sizin diqqətinizə təqdim edilir.
                            Sənəd nümunələri arasında təmənnasız təqdim edilən bəzi iddia ərizələri formaları ilə yanaşı, müxtəlif məzmunlu və formalı vəsatətlər, apellyasiya şikayətləri, kassasiya şikayətləri formaları və s. mövcuddur. Sənəd nümunələri Azərbaycan Respublikası Vəkillər Kollegiyasının üzvləri tərəfindən tərtib edilmişdir. Sənəd nümunələrindən real məhkəmə işlərində istifadə edilmişdir.",
                            Visibilty   = true,
                            PhotoPath   = "mehkeme1.jpg"
                        };
                        Category M = new Category()
                        {
                            Name        = "Müqavilələr",
                            Description = @"Azərbaycan Respublikasının qanunvericiliyinə uyğun tərtib edilən müxtəlif müqavilə növləri. Təqdim edilən bütün müqavilə növləri təcrübədə istifadə edilmişdir.
                                           Müqavilələr arasında tez-tez istifadə edilən alğı-satqı, bağışlama, podrat, xidmət müqavilələri ilə yanaşı Azərbaycan işgüzar adətlərində yeni-yeni rast gəlinən autsorsinq, birgə əməliyyat sazişləri nümunələri də daxil edilmişdir.",
                            Visibilty   = true,
                            PhotoPath   = "muqavile3.jpg"
                        };
                        Category SS = new Category()
                        {
                            Name        = "Sair Sənədlər",
                            Description = @"Yuxarıdakı təsnifata yer almamış sənəd nümunələrini hazırki bölmədə yerləşdirərək diqqətinizə çatdırırıq. Bu bölmədə hüquqi şəxsin təsis sənədləri nümunələri, informasiya sorğuları, şikayət ərizələri, prtokol formaları, etibarnamələr, müraciət ərizələri və s. sənəd nümunələri yerləşdirilmişdir.
                                           We understand business. That's why we begin every project with a workshop — crafting a one-of-a-kind, unique strategy that is designed to help you win.",
                            Visibilty   = true,
                            PhotoPath   = "sair.jpg"
                        };
                        #endregion

                        dbContext.Categories.AddRange(IR, M, MS, SS);
                        dbContext.SaveChanges();

                        #region Subcategories

                        #region InsanResurslariSubcategoriyasi
                        Subcategory EM = new Subcategory()
                        {
                            Name     = "Əmək Müqaviləsi",
                            Category = IR
                        };
                        Subcategory EF = new Subcategory()
                        {
                            Name     = "Əmr Formaları",
                            Category = IR
                        };
                        Subcategory VT = new Subcategory()
                        {
                            Name     = "Vəzifə Təlimatları",
                            Category = IR
                        };
                        Subcategory E = new Subcategory()
                        {
                            Name     = "Ərizələr",
                            Category = IR
                        };
                        Subcategory EK = new Subcategory()
                        {
                            Name     = "Əmr Kitabları",
                            Category = IR
                        };
                        Subcategory EV = new Subcategory()
                        {
                            Name     = "Ezamiyyə Vərəqələri",
                            Category = IR
                        };
                        Subcategory A = new Subcategory()
                        {
                            Name     = "Aktlar",
                            Category = IR
                        };

                        #endregion
                        #region MehkemeSenedleriSubcategoriyasi
                        Subcategory IE = new Subcategory()
                        {
                            Name     = "İddia Ərizələri",
                            Category = MS
                        };
                        Subcategory AS = new Subcategory()
                        {
                            Name     = "Apelyasiya Şikayətləri",
                            Category = MS
                        };
                        Subcategory KS = new Subcategory()
                        {
                            Name     = "Kassasiya Şikayətləri",
                            Category = MS
                        };
                        Subcategory V = new Subcategory()
                        {
                            Name     = "Vəsatətlər",
                            Category = MS
                        };
                        Subcategory BS = new Subcategory()
                        {
                            Name     = "Barışıq Sazişləri",
                            Category = MS
                        };
                        Subcategory QIE = new Subcategory()
                        {
                            Name     = "Qarşılıqlı İddia Ərizələri",
                            Category = MS
                        };
                        Subcategory ET = new Subcategory()
                        {
                            Name     = "Etirazlar",
                            Category = MS
                        };
                        #endregion
                        #region MuqavilelerSubcategoriyasi
                        Subcategory ASM = new Subcategory()
                        {
                            Name     = "Alğı-satqı Müqavilələri",
                            Category = M
                        };
                        Subcategory PM = new Subcategory()
                        {
                            Name     = "Podrat Müqavilələri",
                            Category = M
                        };
                        Subcategory XM = new Subcategory()
                        {
                            Name     = "Xidmət Müqavilələri",
                            Category = M
                        };
                        Subcategory BM = new Subcategory()
                        {
                            Name     = "Borc Müqavilələri",
                            Category = M
                        };
                        Subcategory DM = new Subcategory()
                        {
                            Name     = "Daşınma Müqavilələri",
                            Category = M
                        };
                        Subcategory ME = new Subcategory()
                        {
                            Name     = "Müqavilələrə Əlavələr",
                            Category = M
                        };
                        Subcategory IM = new Subcategory()
                        {
                            Name = "İcarə Müqavilələri" +
                                   "",
                            Category = M
                        };
                        #endregion
                        #region SairSenedlerSubcategoriyasi
                        Subcategory HSUY = new Subcategory()
                        {
                            Name     = "Hüquqi Şəxsin Ümumi Yığıncağının Qərarı",
                            Category = SS
                        };
                        Subcategory EUMEF = new Subcategory()
                        {
                            Name     = "Əfv üçün Müraciət Ərizə Forması",
                            Category = SS
                        };
                        Subcategory ES = new Subcategory()
                        {
                            Name     = "Etibarnamələr",
                            Category = SS
                        };
                        Subcategory TQ = new Subcategory()
                        {
                            Name     = "Təsisçinin Qərarı",
                            Category = SS
                        };
                        Subcategory VF = new Subcategory()
                        {
                            Name     = "Vəsiyyətnamə Formaları",
                            Category = SS
                        };
                        Subcategory Akt = new Subcategory()
                        {
                            Name     = "Aktlar",
                            Category = SS
                        };
                        Subcategory QF = new Subcategory()
                        {
                            Name     = "Qərar Formaları",
                            Category = SS
                        };
                        #endregion
                        #endregion
                        dbContext.Subcategories.AddRange(EM, EF, VT, E, EK, EV, A, IE, AS, KS, V, BS, QIE, ET, ASM, PM, XM, BM, DM, ME, IM, HSUY, EUMEF, ES, TQ, VF, Akt, QF);
                        dbContext.SaveChanges();
                    }
                    UserAndRoleCreater.CreateAsync(scopedService, dbContext).Wait();
                }
            }

            webHost.Run();
        }