コード例 #1
0
ファイル: WebAPI.cs プロジェクト: nazrulcse/epose
        public static HttpResponseMessage getRequest(String action_url, String model)
        {
            DepartmentSettings.getData();
            string URL           = API + "" + action_url;
            string urlParameters = "?department_id=" + DepartmentSettings.DepartmentId;

            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(URL);
            Console.WriteLine("API URL: " + URL + urlParameters);
            // Add an Accept header for JSON format.
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));
            // List data response.
            try
            {
                HttpResponseMessage response = client.GetAsync(urlParameters).Result;  // Blocking call!
                return(response);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message.ToString());
                return(client.GetAsync(urlParameters).Result);
            }
        }
コード例 #2
0
        public static void webAcknowledgement(String log_ids)
        {
            if (log_ids != "")
            {
                log_ids = log_ids.Substring(0, (log_ids.Length - 1));
                DepartmentSettings.getData();
                String API           = "http://159.89.170.58/api/v1";
                string URL           = API + "" + "/activities/remove";
                string urlParameters = "?department_id=" + DepartmentSettings.DepartmentId + "&activity_ids=" + log_ids;

                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri(URL);
                Console.WriteLine("API URL: " + URL + urlParameters);
                // Add an Accept header for JSON format.
                client.DefaultRequestHeaders.Accept.Add(
                    new MediaTypeWithQualityHeaderValue("application/json"));
                // List data response.
                try
                {
                    HttpResponseMessage response = client.DeleteAsync(urlParameters).Result;  // Blocking call!
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error: " + ex.Message.ToString());
                }
            }
        }
コード例 #3
0
        public static void Menu()
        {
            while (true)
            {
                Console.Clear();
                int            counter = 1;
                ConsoleKeyInfo keyInfo = new ConsoleKeyInfo();
                while (keyInfo.Key != ConsoleKey.Enter)
                {
                    ClearMiddle();
                    ShowBorder();
                    if (counter == 1)
                    {
                        Console.BackgroundColor = ConsoleColor.DarkBlue;
                    }
                    Console.SetCursorPosition(45, 10);
                    Console.WriteLine("1. Додати елемент");
                    Console.BackgroundColor = ConsoleColor.Black;

                    if (counter == 2)
                    {
                        Console.BackgroundColor = ConsoleColor.DarkBlue;
                    }
                    Console.SetCursorPosition(45, 11);
                    Console.WriteLine("2. Показати усі елементи");
                    Console.BackgroundColor = ConsoleColor.Black;

                    if (counter == 3)
                    {
                        Console.BackgroundColor = ConsoleColor.DarkBlue;
                    }
                    Console.SetCursorPosition(45, 12);
                    Console.WriteLine("3. Видалити елемент");
                    Console.BackgroundColor = ConsoleColor.Black;

                    if (counter == 4)
                    {
                        Console.BackgroundColor = ConsoleColor.DarkBlue;
                    }
                    Console.SetCursorPosition(45, 13);
                    Console.WriteLine("4. Редагувати елемент");
                    Console.BackgroundColor = ConsoleColor.Black;

                    if (counter == 5)
                    {
                        Console.BackgroundColor = ConsoleColor.DarkBlue;
                    }
                    Console.SetCursorPosition(45, 14);
                    Console.WriteLine("5. Вийти");
                    Console.BackgroundColor = ConsoleColor.Black;
                    Console.SetCursorPosition(0, 0);

                    keyInfo = Console.ReadKey();

                    switch (keyInfo.Key)
                    {
                    case ConsoleKey.UpArrow:
                    {
                        if (counter > 1)
                        {
                            counter--;
                        }
                        else
                        {
                            counter = 5;
                        }
                        break;
                    }

                    case ConsoleKey.DownArrow:
                    {
                        if (counter < 5)
                        {
                            counter++;
                        }
                        else
                        {
                            counter = 1;
                        }
                        break;
                    }
                    }
                }
                Console.Clear();
                switch (counter)
                {
                case 1: { DepartmentSettings.AddToDataBase(); break; }

                case 2: { DepartmentSettings.ReadAll(); break; }

                case 3: { DepartmentSettings.DeleteElement(); break; }

                case 4: { DepartmentSettings.ReplaceElement(); break; }

                case 5: { return; }
                }
            }
        }
コード例 #4
0
 public DepartmentController(DepartmentContext context, IOptionsSnapshot <DepartmentSettings> settings)
 {
     this._departmentContext = context ?? throw new ArgumentNullException(nameof(context));
     this._settings          = settings.Value;
     ((DbContext)context).ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
 }