Ejemplo n.º 1
0
        public void Enter(string email, string password)
        {
            if (!string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(password))
            {
                Program.Worker = APIWorker.GetRequest <WorkerViewModel>($"api/worker/login?email={email}&password={password}");
                if (Program.Worker == null)
                {
                    throw new Exception("Неверный email/пароль");
                }

                Response.Redirect("Index");
                return;
            }
            throw new Exception("Введите email, пароль");
        }
Ejemplo n.º 2
0
 public void Register(string fio, string email, string password, string numberPhone)
 {
     if (!string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(password))
     {
         APIWorker.PostRequest("api/worker/register", new WorkerBindingModel
         {
             FIO         = fio,
             Email       = email,
             Password    = password,
             NumberPhone = numberPhone,
         });
         Response.Redirect("Enter");
         return;
     }
     throw new Exception("Введите email и пароль");
 }
Ejemplo n.º 3
0
 public void Privacy(string email, string password)
 {
     if (!string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(password))
     {
         APIWorker.PostRequest("api/worker/updatedata", new WorkerBindingModel
         {
             Id       = Program.Worker.Id,
             Email    = email,
             Password = password,
         });
         Program.Worker.Email    = email;
         Program.Worker.Password = password;
         Response.Redirect("Index");
         return;
     }
     throw new Exception("Введите логин и пароль");
 }
Ejemplo n.º 4
0
		private async void Window_Loaded(object sender, RoutedEventArgs e)
		{
			List<KeyValuePair<string, string>> logindata = new List<KeyValuePair<string, string>>();
			//logindata.Add(new KeyValuePair<string, string>("email", m_UN));
			//logindata.Add(new KeyValuePair<string, string>("password", m_PW));

			m_ApiWorker = new APIWorker();

			//string o = await m_ApiWorker.sendAPI("login", logindata);

			Dictionary<string, string> qd = new Dictionary<string, string>();
			qd.Add("active", "true");
			string o = await m_ApiWorker.queryAPI("rescues", qd);


			JObject jsonRepsonse = JObject.Parse(o);
			List<JToken> tokens = jsonRepsonse["data"].Children().ToList();

			string s = tokens[2].ToString();

			//Models.Api.Rat rat = JsonConvert.DeserializeObject<Models.Api.Rat>(tokens[3].ToString());
		}
Ejemplo n.º 5
0
 public ControllerFormMain(FormMain form)
 {
     this.form = form;
     API       = APIWorker.GetInstance();
     user      = (User)DataStorage.Get("user");
 }
 public ControllerFormAuth(AuthenForm form)
 {
     this.form = form;
     API       = APIWorker.GetInstance();
 }
Ejemplo n.º 7
0
        public DataAccessLevel.Forecast GetForecat(string path, ProgressBar pb)
        {
            DataAccessLevel.SQLiteDatabaseWorker worker   = new DataAccessLevel.SQLiteDatabaseWorker();
            DataAccessLevel.Forecast             forecast = new DataAccessLevel.Forecast();

            // получаем текущий город из настроек

            worker.SetConnect(path);
            DataAccessLevel.SettingsDataContext sdc    = worker.GetSettings(); // текущие настройки
            DataAccessLevel.SettingsDataContext altSet = worker.GetAltSetStr(sdc);
            CurCity = worker.GetCurCityName(sdc.cityID.ToString());
            worker.CloseConnect();

            // CurCity


            // sdc.cityID - id выбранного города
            // sdc.ID - id настройки

            try
            {
                HttpWebRequest reqFP = (HttpWebRequest)HttpWebRequest.Create("http://www.google.com");

                HttpWebResponse rspFP = (HttpWebResponse)reqFP.GetResponse();
                if (HttpStatusCode.OK == rspFP.StatusCode)
                {
                    // HTTP = 200 - Интернет безусловно есть!
                    rspFP.Close();

                    DataAccessLevel.Forecast yandexForecast = new DataAccessLevel.Forecast();
                    DataAccessLevel.Forecast owmForecast    = new DataAccessLevel.Forecast();

                    // DataAccessLevel.CurrentWeather yaCurWeather = new DataAccessLevel.CurrentWeather();
                    // получаем текущее время - нужен id текущий города на яндексе
                    Date_Time.GetTime getter  = new Date_Time.GetTime();
                    DateTime          CurDate = getter.Yandex_Time(sdc.cityID);

                    CurData = CurDate;

                    // получаем город по ид яндекса GetCityByYaId
                    worker.SetConnect(path);
                    DataAccessLevel.CitiesDataContext city = worker.GetCityByYaId(sdc.cityID.ToString());
                    worker.CloseConnect();

                    // получаем прогнозы
                    // получаем прогноз с яндекса
                    Yandex.YandexMethods yaworker2 = new Yandex.YandexMethods();
                    yaworker2.GetYandexForecast(sdc.cityID.ToString(), yandexForecast);
                    // с owm
                    OpenWeatherMap.APIWorker owmworker = new APIWorker();
                    owmForecast = owmworker.GetWeather(city.name, city.owmID);

                    switch (sdc.sourceID)
                    {
                    case 1:
                        // owm
                        worker.SetConnect(path);
                        worker.SaveForecast(owmForecast, pb, sdc);
                        worker.SaveForecast(yandexForecast, pb, altSet);
                        worker.CloseConnect();
                        break;

                    case 2:
                        // ya
                        worker.SetConnect(path);
                        worker.SaveForecast(owmForecast, pb, altSet);
                        worker.SaveForecast(yandexForecast, pb, sdc);
                        worker.CloseConnect();
                        return(yandexForecast);
                    }

                    worker.SetConnect(path);
                    forecast = worker.GetForecast(CurDate);
                    worker.CloseConnect();

                    // if (sdc.sourceID == 2)
                    //    forecast.curWeather = yaCurWeather;

                    return(forecast);


                    // switch (sdc.sourceID)
                    // {
                    //     case 1: // owm
                    //         // получаем город по ид яндекса GetCityByYaId
                    //         worker.SetConnect(path);
                    //         DataAccessLevel.CitiesDataContext city = worker.GetCityByYaId(sdc.cityID.ToString());
                    //         worker.CloseConnect();
                    //         // получаем прогноз owm по названию или owmid
                    //         OpenWeatherMap.APIWorker owmworker = new APIWorker();
                    //         DataAccessLevel.Forecast owmForecast = owmworker.GetWeather(city.name, city.owmID);

                    //         // получаем прогноз с яндекса
                    //         Yandex.YandexMethods yaworker2 = new Yandex.YandexMethods();
                    //         yaworker2.GetYandexForecast(sdc.cityID.ToString(), yandexForecast);

                    //         // сохраняем в базу
                    //         worker.SetConnect(path);
                    //         worker.SaveForecast(yandexForecast, pb, altSet);
                    //         worker.CloseConnect();

                    //         // сохраняем в базу
                    //         worker.SetConnect(path);
                    //         worker.SaveForecast(owmForecast, pb);
                    //         worker.CloseConnect();

                    //         break;
                    //     case 2: // яндекс
                    //         // получаем прогноз с яндекса (по ID города яндекса)
                    //         Yandex.YandexMethods yaworker = new Yandex.YandexMethods();
                    //         yaworker.GetYandexForecast(sdc.cityID.ToString(), yandexForecast);

                    //         // сохраняем в базу
                    //         worker.SetConnect(path);
                    //         worker.SaveForecast(yandexForecast, pb);
                    //         worker.CloseConnect();
                    //         //break;
                    //         //yaCurWeather = yandexForecast.curWeather;
                    //         return yandexForecast;
                    //         //break;
                    //     default:
                    //         break;
                    // }


                    // // получаем прогноз из базы по установленному в настройках серверу

                    // worker.SetConnect(path);
                    // forecast = worker.GetForecast(CurDate);
                    // worker.CloseConnect();

                    //// if (sdc.sourceID == 2)
                    // //    forecast.curWeather = yaCurWeather;

                    // return forecast;
                }


                else
                {
                    CurData = DateTime.Now;
                    // сервер вернул отрицательный ответ, возможно что инета нет
                    rspFP.Close();
                    MessageBox.Show("Подключение к интернету ограничено, данные могут быть неточными");

                    // получаем прогноз из базы по установленному в настройках серверу

                    worker.SetConnect(path);
                    forecast = worker.GetForecast(DateTime.Now);
                    worker.CloseConnect();

                    return(forecast);
                }
            }
            catch (WebException)
            {
                CurData = DateTime.Now;
                // Ошибка, значит интернета у нас нет. Плачем :'(
                MessageBox.Show("Невозможно подключиться к интернету, данные могут быть неточными");

                // получаем прогноз из базы по установленному в настройках серверу

                worker.SetConnect(path);
                forecast = worker.GetForecast(DateTime.Now);
                worker.CloseConnect();

                return(forecast);
            }
        }
Ejemplo n.º 8
0
        public decimal Bind(int request)
        {
            RequestViewModel Request = APIWorker.GetRequest <RequestViewModel>($"api/main/getrequestnl?Id={request}");

            return(Request.RequestCost);
        }
Ejemplo n.º 9
0
 public IActionResult BindCost(int id)
 {
     ViewBag.Cost    = APIWorker.GetRequest <WorkerViewModel>($"api/main/getcosts?costId={id}");
     ViewBag.Request = APIWorker.GetRequest <List <RequestViewModel> >($"api/main/GetRequestList");
     return(View());
 }
Ejemplo n.º 10
0
 public IActionResult UpdateCost(int id)
 {
     ViewBag.Cost = APIWorker.GetRequest <CostViewModel>($"api/main/getcosts?costId={id}");
     return(View());
 }
Ejemplo n.º 11
0
 public IActionResult UpdateWork(int id)
 {
     ViewBag.Works = APIWorker.GetRequest <WorkerViewModel>($"api/main/getworks?workId={id}");
     return(View());
 }