public List <AirPort> GetAirPort(string catAirPorCode, string connectionName)
        {
            Database  db        = DatabaseFactory.CreateDatabase(connectionName);
            DbCommand dbCommand = db.GetStoredProcCommand(Resources.AirPortResources.SP_GetAirPort);

            db.AddInParameter(dbCommand, Resources.AirPortResources.PARAM_QUERY, DbType.String, catAirPorCode);

            List <AirPort> AirPortList = new List <AirPort>();

            using (IDataReader dr = db.ExecuteReader(dbCommand))
            {
                int _catcitid   = dr.GetOrdinal(Resources.AirPortResources.PARAM_CATCITID);
                int _catcitname = dr.GetOrdinal(Resources.AirPortResources.PARAM_CATCITNAME);
                int _catcouid   = dr.GetOrdinal(Resources.AirPortResources.PARAM_CATCOUID);
                int _catcouname = dr.GetOrdinal(Resources.AirPortResources.PARAM_CATCOUNAME);
                //No se ingresaron nullables por que las columnas de las tablas no aceptan nulos
                while (dr.Read())
                {
                    AirPort item = new AirPort();
                    item.CatCitId   = dr.GetString(_catcitid);
                    item.CatCitName = dr.GetString(_catcitname);
                    item.CatCouId   = dr.GetString(_catcouid);
                    item.CatCouName = (dr[_catcouname] == DBNull.Value) ? Types.StringNullValue : dr.GetString(_catcouname);
                    AirPortList.Add(item);
                }
            }

            return(AirPortList);
        }
Beispiel #2
0
        private void deleteButton_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Ви дійсно хочете видалити даний аеропорт?", "Підтвердіть видалення", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);

            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                int     selectedID = (int)airPortListDataGridView.SelectedRows[0].Cells[0].Value;
                AirPort airport    = new AirPort();
                airport.AirPortID = selectedID;
                airport.DeleteAirport();
                if (airport.e != null)
                {
                    //547
                    if (airport.e.ErrorCode == 547)
                    {
                        MessageBox.Show("Не можу видалити аеропорт. З вибранием аеропортом пов'язані інші дані.", "Помилка при виданені", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show("Неідома помилка, можливо сервер недоступний. Зверніться до адмінітратора.", "Помилка при виданені", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                RefreshItems();
            }
        }
Beispiel #3
0
 public Route(AirPort s, AirPort e)
 {
     start = s;
     end   = e;
     start.outAirports.Add(end);
     end.inAirports.Add(start);
 }
        public void Post([FromBody] JObject data)
        {
            string apiKeyData       = Request.Headers["Authorization"];
            string sessionData      = Request.Headers["User-Authentication"];
            string timeStamp        = Request.Headers["Timestamp"];
            int    gradeRestriction = 2;

            if (security.IsAuthorised(timeStamp, apiKeyData, sessionData, gradeRestriction))
            {
                AirPort AirPort;
                try
                {
                    AirPort = data["AirPort"].ToObject <AirPort>();
                }
                catch
                {
                    Response.StatusCode = (int)HttpStatusCode.BadRequest;
                    return;
                }

                try
                {
                    AirPort newAirPort = TicketDb.AirPortAdd(AirPort.Name, AirPort.Country, AirPort.UTCOffset);
                }
                catch
                {
                    Response.StatusCode = (int)HttpStatusCode.BadRequest;
                }
            }
            else
            {
                Response.StatusCode = (int)HttpStatusCode.Unauthorized;
                return;
            }
        }
        public static double GetDistance(AirPort departureAirport, AirPort arrivalAirport)
        {
            var sCoord = new GeoCoordinate(departureAirport.Latitude, departureAirport.Longitude);
            var eCoord = new GeoCoordinate(arrivalAirport.Latitude, arrivalAirport.Longitude);

            return(sCoord.GetDistanceTo(eCoord));
        }
        public ActionResult Create(AirPort airPort)
        {
            bool                  flag     = false;
            List <string>         listId   = new List <string>();
            IEnumerable <AirPort> airPorts = _AirPortService.GetAll();

            foreach (AirPort x in airPorts)
            {
                if (airPort.Id == x.Id)
                {
                    flag = true;
                    break;
                }
            }

            if (ModelState.IsValid)
            {
                if (flag == true)
                {
                    ModelState.AddModelError("airportId", "ID is exist");
                    return(View(airPort));
                }
                else
                {
                    _AirPortService.Create(airPort);
                    return(RedirectToAction("Index"));
                }
            }

            return(View(airPort));
        }
        public string Get(int id)
        {
            string apiKeyData  = Request.Headers["Authorization"];
            string sessionData = Request.Headers["User-Authentication"];
            string timeStamp   = Request.Headers["Timestamp"];

            int gradeRestriction = 1;

            if (security.IsAuthorised(timeStamp, apiKeyData, sessionData, gradeRestriction))
            {
                AirPort AirPort     = new AirPort();
                AirPort queryResult = TicketDb.AirPortFind(id);
                if (queryResult != null)
                {
                    AirPort = queryResult;
                    return(JsonConvert.SerializeObject(AirPort));
                }
                else
                {
                    Response.StatusCode = (int)HttpStatusCode.NoContent;
                    return("that AirPort does not exsist");
                }
            }
            else
            {
                Response.StatusCode = (int)HttpStatusCode.Unauthorized;
                return("access denied");
            }
        }
Beispiel #8
0
        public void AcquireWorking()
        {
            AirPort a = new AirPort();
            Plane   p = a.AcquirePlane();

            Assert.IsNotNull(p);
        }
Beispiel #9
0
    private void DrawOneLine(AirPort start, AirPort end)
    {
        LineRenderer lineRender;

        if (_lines.ContainsKey(end.GetHashCode()))
        {
            lineRender = _lines[end.GetHashCode()];
        }
        else
        {
            lineRender = new GameObject("linerender").AddComponent <LineRenderer>();
            lineRender.transform.parent = obj;
            _lines[end.GetHashCode()]   = lineRender;

            lineRender.startWidth        = 0.05f;
            lineRender.endWidth          = 0.05f;
            lineRender.material          = new Material(Shader.Find("Legacy Shaders/Particles/Additive"));
            lineRender.receiveShadows    = false;
            lineRender.shadowCastingMode = ShadowCastingMode.Off;
            lineRender.startColor        = Color.yellow;
            lineRender.endColor          = Color.yellow;
        }

        float angle = Vector3.Angle(start.position, end.position);
        float k     = 1f; //角度太大曲线会穿过地球。

        if (angle <= 60)
        {
            k = 1.1f;
        }
        else if (angle > 60 && angle < 120)
        {
            k = 1.3f;
        }
        else if (angle >= 120 && angle < 160)
        {
            k = 1.5f;
        }
        else if (angle >= 160)
        {
            k = 1.8f;
        }


        //确定bezier中间的两个点, 曲线不能太直会穿过地面,也不能太弯会不美观,所以用 k 调整一下。
        Vector3 p1 = Quaternion.AngleAxis(angle * 0.3f, Vector3.Cross(start.position, end.position)) * start.position * k;
        Vector3 p2 = Quaternion.AngleAxis(-angle * 0.3f, Vector3.Cross(start.position, end.position)) * end.position * k;

        lineRender.positionCount = 100;

        for (int i = 1; i <= 100; i++)
        {
            //参数的取值范围 0 - 1 返回曲线没一点的位置
            //为了精确这里使用i * 0.01 得到当前点的坐标
            Vector3 vec = Bezier.Bezier_3(start.position, p1, p2, end.position, (float)(i * 0.01));
            //把每条线段绘制出来 完成白塞尔曲线的绘制
            lineRender.SetPosition(i - 1, vec);
        }
    }
Beispiel #10
0
 private void CheckAirportFully(AirPort ap)
 {
     if (ap.LinkedCount() == MAX_ROUTE_PER_AIRPORT)
     {
         _airPorts.Remove(ap);
         _fullyAirPorts.Add(ap);
     }
 }
        // GET: AirPorts/Delete/5
        public ActionResult Delete(string id)
        {
            AirPort airPort = _AirPortService.GetById(id);

            if (airPort == null)
            {
                return(HttpNotFound());
            }
            return(View(airPort));
        }
Beispiel #12
0
        public void ReleaseWorking()
        {
            AirPort a = new AirPort();
            Plane   p = a.AcquirePlane();

            Assert.IsNotNull(p);

            Assert.ThrowsException <ArgumentException>(() =>
            {
                a.ReleaseReusable(new Plane());
            });
        }
Beispiel #13
0
        private void addAirportsToComboBox(int CityID)
        {
            AirPortList apl    = AirPortList.GetRefAirportListByCity(CityID);
            AirPort     apinfo = new AirPort();

            apinfo.AirPortID   = 0;
            apinfo.AirPortName = "Виберіть аеропорт...";
            apl.Insert(0, apinfo);
            airportComboBox.DataSource    = null;
            airportComboBox.DataSource    = apl;
            airportComboBox.DisplayMember = "AirPortName";
            airportComboBox.ValueMember   = "AirPortID";
        }
Beispiel #14
0
        public void Valid_AirPort_Create()
        {
            //Arrange
            AirPort c = new AirPort()
            {
                Id = "AP00001", Name = "VN", RunwaySize = 12, MaxFWParkingPlace = 5, MaxRWParkingPlace = 10
            };

            //Act
            var result = (RedirectToRouteResult)objController.Create(c);

            //Assert
            _airportServiceMock.Verify(m => m.Create(c), Times.Once);
            Assert.AreEqual("Index", result.RouteValues["action"]);
        }
Beispiel #15
0
        public void Invalid_AirPort_Create()
        {
            // Arrange
            AirPort c = new AirPort()
            {
                Id = "", Name = "VN", RunwaySize = 12, MaxFWParkingPlace = 5, MaxRWParkingPlace = 10
            };

            objController.ModelState.AddModelError("Error", "Something went wrong");

            //Act
            var result = (ViewResult)objController.Create(c);

            //Assert
            _airportServiceMock.Verify(m => m.Create(c), Times.Never);
            Assert.AreEqual("", result.ViewName);
        }
Beispiel #16
0
    private void GenRouteMap()
    {
        ClearRouteMap();
        while (_routeMap.Count < ROUTE_COUNT)
        {
            AirPort start = _airPorts[UnityEngine.Random.Range(0, _airPorts.Count)];
            AirPort end   = _airPorts[UnityEngine.Random.Range(0, _airPorts.Count)];
            if (start == end || HasSameRoute(start, end))
            {
                continue;
            }

            Route r = new Route(start, end);
            _routeMap.Add(r);

            CheckAirportFully(start);
            CheckAirportFully(end);
        }
    }
Beispiel #17
0
        public void CapacityWorking()
        {
            AirPort      a      = new AirPort();
            List <Plane> planes = new List <Plane>();

            for (int i = 0; i < 10; i++)
            {
                planes.Add(a.AcquirePlane());
            }

            for (int i = 0; i < 10; i++)
            {
                Assert.IsNotNull(planes[i]);
            }

            Assert.ThrowsException <ArgumentException>(() =>
            {
                Plane temp = a.AcquirePlane();
            });
        }
Beispiel #18
0
    private void InitAirportsPos()
    {
        ClearAirPorts();
        //随机出机场点坐标
        Vector3 randPos = new Vector3(EARTH_RADIUS, 0, 0);

        while (_airPorts.Count < airportsCount)
        {
            randPos = Quaternion.Euler(UnityEngine.Random.Range(30, 330), UnityEngine.Random.Range(30, 330),
                                       UnityEngine.Random.Range(30, 330)) * randPos;
            if (IsPointTooNear(randPos))
            {
                continue;
            }
            Transform newObj = GameObject.Instantiate(airportsRoot.GetChild(0), airportsRoot);
            newObj.transform.position = randPos;
            AirPort a = new AirPort(newObj);
            _airPorts.Add(a);
        }
    }
        public ActionResult Delete(string id, FormCollection data)
        {
            AirPort airport = _AirPortService.GetById(id);
            //Get all airplane with airportId = id
            IEnumerable <AirPlane> airplanes = _AirPlaneService.GetAll().Where(i => i.AirPortId == id);

            //Get all helicopter with airportId = id
            IEnumerable <Helicopter> helicopters = _HelicopterService.GetAll().Where(i => i.AirPortId == id);

            List <string> listIdAirplane   = new List <string>();
            List <string> listIdHelicopter = new List <string>();

            //Remove relationship
            foreach (AirPlane airplane in airplanes)
            {
                listIdAirplane.Add(airplane.Id);
            }
            foreach (Helicopter helicopter in helicopters)
            {
                listIdHelicopter.Add(helicopter.Id);
            }

            foreach (string i in listIdHelicopter)
            {
                //do some thing
                Helicopter helicopter = _HelicopterService.GetById(i);
                helicopter.AirPortId = null;
                _HelicopterService.Update(helicopter);
            }
            foreach (string i in listIdAirplane)
            {
                //do some thing
                AirPlane airplane = _AirPlaneService.GetById(i);
                airplane.AirPortId = null;
                _AirPlaneService.Update(airplane);
            }

            _AirPortService.Delete(airport);
            return(RedirectToAction("Index"));
        }
Beispiel #20
0
        private void EditFlightForm_Load(object sender, EventArgs e)
        {
            //для всіх
            PlaneList _PlaneList = PlaneList.GetRefPlanesList();

            planecomboBox.DataSource    = _PlaneList;
            planecomboBox.DisplayMember = "PlaneNumber";
            planecomboBox.ValueMember   = "PlaneID";

            AircompaniesList _AircompaniesList = AircompaniesList.GetRefAircompaniesList();

            aircompanycomboBox.DataSource    = _AircompaniesList;
            aircompanycomboBox.DisplayMember = "AirCompanyName";
            aircompanycomboBox.ValueMember   = "AirCompanyID";

            if (act == Action.Insert)
            {
                //для вставки
                CountriesList _countriesList = CountriesList.GetRefCountriesList();
                countrycomboBox.DataSource    = _countriesList;
                countrycomboBox.DisplayMember = "CountryName";
                countrycomboBox.ValueMember   = "CountryID";

                int _selectedCountry = (int)countrycomboBox.SelectedValue;

                CitiesList _citiesList = CitiesList.GetCitiesListByCountry(_selectedCountry);
                citycomboBox.DataSource    = _citiesList;
                citycomboBox.DisplayMember = "CityName";
                citycomboBox.ValueMember   = "CityID";

                int _selectedCity = (int)citycomboBox.SelectedValue;

                AirPortList _airportList = AirPortList.GetRefAirportListByCity(_selectedCity);
                airportcomboBox.DataSource    = _airportList;
                airportcomboBox.DisplayMember = "AirportName";
                airportcomboBox.ValueMember   = "AirportID";

                flightTypecomboBox.SelectedIndex = 0;

                _loaded = true;
            }

            if (act == Action.Update)
            {
                //для оновлення
                try
                {
                    aircompanycomboBox.SelectedValue = Flight.FlightAircompanyID;
                    planecomboBox.SelectedValue      = Flight.FlightPlaneID;

                    AirPort _apinfo = new AirPort();
                    _apinfo.GetAirport(Flight.FlightAirPortID);
                    City _City = new City();
                    _City.GetCity(_apinfo.AirPortCityID);

                    CountriesList _countriesList = CountriesList.GetRefCountriesList();
                    countrycomboBox.DataSource    = _countriesList;
                    countrycomboBox.DisplayMember = "CountryName";
                    countrycomboBox.ValueMember   = "CountryID";
                    countrycomboBox.SelectedValue = _City.CountryID;

                    CitiesList _citiesList = CitiesList.GetCitiesListByCountry(_City.CountryID);
                    citycomboBox.DataSource    = _citiesList;
                    citycomboBox.DisplayMember = "CityName";
                    citycomboBox.ValueMember   = "CityID";
                    citycomboBox.SelectedValue = _apinfo.AirPortCityID;

                    AirPortList _airportList = AirPortList.GetRefAirportListByCity(_apinfo.AirPortCityID);
                    airportcomboBox.DataSource    = _airportList;
                    airportcomboBox.DisplayMember = "AirportName";
                    airportcomboBox.ValueMember   = "AirportID";
                    airportcomboBox.SelectedValue = _apinfo.AirPortID;

                    if (Flight.FlightType == "Вхідний")
                    {
                        flightTypecomboBox.SelectedIndex = 0;
                    }
                    else if (Flight.FlightType == "Вихідний")
                    {
                        flightTypecomboBox.SelectedIndex = 1;
                    }

                    startdateTimePicker.Value = Flight.FlightDateTimeStart;
                    DateTime _tempDuration = Convert.ToDateTime("1900-01-01 " + Flight.FlightDuration);
                    economnumericUpDown.Value   = Flight.FlightPriceEconom;
                    businessnumericUpDown.Value = Flight.FlightPriceBusiness;
                    firstnumericUpDown.Value    = Flight.FlightPriceFirst;

                    numOfFlishgslabel.Visible = false;
                    periodicitylabel.Visible  = false;

                    numOfFlightsnumericUpDown.Visible = false;
                    periodicitydateTimePicker.Visible = false;

                    if (Config.HasUserAccess("UpdateFlight"))
                    {
                        okButton.Visible = true;
                    }
                    else
                    {
                        okButton.Visible = false;
                    }

                    _loaded = true;
                }
                catch (Exception)
                {
                    _error = true;
                }
            }
        }
Beispiel #21
0
        public List <AirPort> FillAirports()
        {
            List <AirPort> list = new List <AirPort>();

            if (this.ConnectioString != null)
            {
                try
                {
                    using (var conn = new SQLiteConnection(this.ConnectioString))
                    {
                        conn.Open();

                        SQLiteCommand    cmd = new SQLiteCommand(@"SELECT * FROM AIRPORT", conn);
                        SQLiteDataReader r   = cmd.ExecuteReader();

                        while (r.Read())
                        {
                            AirPort a = new AirPort();
                            a.airport_id             = r.GetInt64(0);
                            a.file_id                = r.GetInt64(1);
                            a.ident                  = r.GetString(2);
                            a.icao                   = r.GetValue(3) != DBNull.Value ? r.GetString(3) : "";
                            a.iata                   = r.GetValue(4) != DBNull.Value ? r.GetString(4) : "";
                            a.xpident                = r.GetValue(5) != DBNull.Value ? r.GetString(5) : "";
                            a.name                   = r.GetValue(6) != DBNull.Value ? r.GetString(6) : "";
                            a.city                   = r.GetValue(7) != DBNull.Value ? r.GetString(7) : "";
                            a.state                  = r.GetValue(8) != DBNull.Value ? r.GetString(8) : "";
                            a.country                = r.GetValue(9) != DBNull.Value ? r.GetString(9) : "";
                            a.region                 = r.GetValue(10) != DBNull.Value ? r.GetString(10) : "";
                            a.flatten                = r.GetValue(11) != DBNull.Value ? r.GetInt64(11) : 0;
                            a.fuel_flags             = r.GetInt64(12);
                            a.has_avgas              = r.GetInt64(13);
                            a.has_jetfuel            = r.GetInt64(14);
                            a.has_tower_object       = r.GetInt64(15);
                            a.tower_frequency        = r.GetValue(16) != DBNull.Value ? r.GetInt64(16) : 0;
                            a.atis_frequency         = r.GetValue(17) != DBNull.Value ? r.GetInt64(17) : 0;
                            a.awos_frequency         = r.GetValue(18) != DBNull.Value ? r.GetInt64(18) : 0;
                            a.asos_frequency         = r.GetValue(19) != DBNull.Value ? r.GetInt64(19) : 0;
                            a.unicom_frequency       = r.GetValue(20) != DBNull.Value ? r.GetInt64(20) : 0;
                            a.is_closed              = r.GetInt64(21);
                            a.is_military            = r.GetInt64(22);
                            a.is_addon               = r.GetInt64(23);
                            a.num_com                = r.GetInt64(24);
                            a.num_parking_gate       = r.GetInt64(25);
                            a.num_parking_ga_ramp    = r.GetInt64(26);
                            a.num_parking_cargo      = r.GetInt64(27);
                            a.num_parking_mil_cargo  = r.GetInt64(28);
                            a.num_parking_mil_combat = r.GetInt64(29);
                            a.num_approach           = r.GetInt64(30);
                            a.num_runway_hard        = r.GetInt64(31);
                            a.num_runway_soft        = r.GetInt64(32);
                            a.num_runway_water       = r.GetInt64(33);
                            a.num_runway_light       = r.GetInt64(34);
                            a.num_runway_end_closed  = r.GetInt64(35);
                            a.num_runway_end_vasi    = r.GetInt64(36);
                            a.num_runway_end_als     = r.GetInt64(37);
                            a.num_runway_end_ils     = r.GetValue(38) != DBNull.Value ? r.GetInt64(38) : 0;
                            a.num_apron              = r.GetInt64(39);
                            a.num_taxi_path          = r.GetInt64(40);
                            a.num_helipad            = r.GetInt64(41);
                            a.num_jetway             = r.GetInt64(42);
                            a.num_starts             = r.GetInt64(43);
                            a.longest_runway_length  = r.GetInt64(44);
                            a.longest_runway_width   = r.GetInt64(45);
                            a.longest_runway_heading = r.GetDouble(46);
                            a.longest_runway_surface = r.GetValue(47) != DBNull.Value ? r.GetString(47) : "";
                            a.num_runways            = r.GetInt64(48);
                            a.largest_parking_ramp   = r.GetValue(49) != DBNull.Value ? r.GetString(49) : "";
                            a.largest_parking_gate   = r.GetValue(50) != DBNull.Value ? r.GetString(50) : "";
                            a.rating                 = r.GetInt64(51);
                            a.is_3d                  = r.GetInt64(52);
                            a.scenery_local_path     = r.GetString(53);
                            a.bgl_filename           = r.GetString(54);
                            a.left_lonx              = r.GetDouble(55);
                            a.top_laty               = r.GetDouble(56);
                            a.right_lonx             = r.GetDouble(57);
                            a.bottom_laty            = r.GetDouble(58);
                            a.mag_var                = r.GetDouble(59);
                            a.tower_altitude         = r.GetValue(60) != DBNull.Value ? r.GetInt64(60) : 0;
                            a.tower_lonx             = r.GetValue(61) != DBNull.Value ? r.GetDouble(61) : 0;
                            a.tower_laty             = r.GetValue(62) != DBNull.Value ? r.GetDouble(62) : 0;
                            a.transition_altitude    = r.GetValue(63) != DBNull.Value ? r.GetInt64(63) : 0;
                            a.altitude               = r.GetInt64(64);
                            a.lonx                   = r.GetDouble(65);
                            a.laty                   = r.GetDouble(66);

                            list.Add(a);
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
            return(list);
        }
Beispiel #22
0
        public ActionResult ColectFlightDataFlightPost()
        {
            Guid newGuid = Guid.NewGuid();

            var jsonString         = Request.Form["jsonAirport"];
            var jsonAirCompany     = Request.Form["jsonAirComapany"];
            var issueDepartureCode = Request.Form["Flight"];
            var nubmer             = Request.Form["FlightNumber"];
            var nubmers            = Request.Form["FlightNumbers"];
            var date  = Request.Form["Date"];
            var dates = Request.Form["Dates"];

            string[] flightNumbers = nubmers != null?nubmers.Split(',') : new string[]
            {
                nubmer, ""
            };
            string[] flightDates = dates != null?dates.Split(',') : new string[]
            {
                date, ""
            };

            var json = new JavaScriptSerializer();

            Airport[] airports   = json.Deserialize <Airport[]>(jsonString);
            Airline   airCompany = json.Deserialize <Airline>(jsonAirCompany);

            Claim claim = new Claim
            {
                ClaimId           = Guid.NewGuid(),
                State             = ClaimStatus.Pending,
                UserId            = null,
                DateCreated       = DateTime.Now,
                Type              = ProblemType.Pending,
                AirCompany        = airCompany.name,
                AirCompanyCountry = airCompany.country,
                AirCompanyCode    = airCompany.iata
            };

            if (issueDepartureCode == null)
            {
                issueDepartureCode = airports[0].iata;
            }

            int number = 1;

            airports.ToList().ForEach(a =>
            {
                AirPort airport = new AirPort
                {
                    Id           = Guid.NewGuid(),
                    ap_name      = a.ap_name,
                    city         = a.city,
                    country      = a.country,
                    elevation    = int.Parse(a.elevation),
                    iata         = a.iata,
                    number       = number,
                    name         = a.name,
                    timezone     = 0,
                    icao         = "",
                    type         = "",
                    x            = double.Parse(a.x),
                    y            = double.Parse(a.y),
                    FlightNumber = airports.Length == number ? (nubmer != null ? nubmer : "") : flightNumbers[number - 1],
                    FlightDate   = airports.Length == number ? (date != null ? date : "") : flightDates[number - 1],
                    startIssue   = (number == 1 && airports.Length == 2) || (a.iata == issueDepartureCode)
                };
                number++;
                claim.AirPorts.Add(airport);
            });

            double allDistance   = 0;
            double issuDistance  = 0;
            bool   flag          = false;
            var    claimAirPorts = claim.AirPorts.ToArray();

            for (int i = 0; i < claimAirPorts.Length - 1; i++)
            {
                var sCoord = new GeoCoordinate(claimAirPorts[i].y, claimAirPorts[i].x);
                var eCoord = new GeoCoordinate(claimAirPorts[i + 1].y, claimAirPorts[i + 1].x);

                var d = sCoord.GetDistanceTo(eCoord);
                claimAirPorts[i].distanceToNext = d;
                allDistance += d;
                flag         = flag || (claimAirPorts[i].iata == issueDepartureCode);
                if (flag)
                {
                    issuDistance += d;
                }
            }

            claim.issueDistance = issuDistance;
            claim.allDistance   = allDistance;

            // Check EU flagth
            IsEUFlight isEUFlight = IsEUFlight.NonEU;

            if (claim.AirPorts.All(a => CommonHeppler.IsEuCountryByName(a.country)))
            {
                isEUFlight = IsEUFlight.EU;
            }
            else if (claim.AirPorts.Any(a => CommonHeppler.IsEuCountryByName(a.country)))
            {
                isEUFlight = IsEUFlight.EUMixed;
            }

            double distance = (claim.Type == ProblemType.Delay) ? claim.allDistance : claim.issueDistance;

            FlightType flightType = FlightType.NotSupported;

            if (isEUFlight == IsEUFlight.NonEU)
            {
                flightType = FlightType.NotSupported;
            }
            else if (distance <= 1500000)
            {
                flightType = FlightType.F1500;
            }
            else if (distance <= 3500000 || isEUFlight == IsEUFlight.EU)
            {
                flightType = FlightType.FTo3500;
            }
            else
            {
                flightType = FlightType.FmoreThen3500;
            }

            claim.IsEUFlight = isEUFlight;
            claim.FlightType = flightType;

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                dc.Claims.Add(claim);
                dc.SaveChanges();
            }

            return(View("ColectData", claim));
        }
Beispiel #23
0
        public ActionResult CheckDirctFlightPost(string FlightNumber, string Date)
        {
            // testing
            Claim c = null;
            Guid  g = new Guid("ecbc3e69-71c0-4fab-971d-3acc3bd98480");

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                c = dc.Claims.Where(cl => cl.ClaimId == g).SingleOrDefault();


                ViewBag.IsEu         = c.AirPorts.Any(a => CommonHeppler.IsEuCountry(a.countryCode));
                ViewBag.delayMessage = (c.issueDistance < 1500000 ? "Полета ви закъсня ли с повече от 2 часа?" :
                                        (c.issueDistance < 3500000 || ViewBag.IsEu ? "Полета ви закъсня ли с повече от 3 часа?" : "Полета ви закъсня ли с повече от 3 часа ?"));
            }
            return(View("ColectData", c));

            var model = new VMDirectFlight()
            {
                date        = Date,
                number      = FlightNumber,
                numberError = ""
            };
            var arr  = Date.Split('.');
            var day  = int.Parse(arr[0]);
            var mont = int.Parse(arr[1]);
            var year = int.Parse(arr[2]);

            FlightStatus fligth = CommonHeppler.GetFlight(FlightNumber, Date);

            if (fligth.flightStatuses.Length == 0)
            {
                model.commonError = "Невалидна комбинция от номер и дата на полета";
                return(View("DirectFlight", model));
            }

            var AirLine = fligth.appendix.airlines.ToList().Find(a => a.iata == fligth.flightStatuses[0].primaryCarrierFsCode);

            Claim claim = new Claim
            {
                ClaimId           = Guid.NewGuid(),
                FlightDate        = Date,
                State             = ClaimStatus.Accepted,
                UserId            = User.Identity.IsAuthenticated ? User.Identity.Name : null,
                DateCreated       = DateTime.Now,
                Type              = ProblemType.Pending,
                FlightNumber      = FlightNumber,
                AirCompany        = AirLine.name,
                AirCompanyCountry = ""
            };

            int number = 0;

            fligth.appendix.airports.ToList().ForEach(a =>
            {
                double distance = 0;
                if (number > 0)
                {
                    var sCoord = new GeoCoordinate(fligth.appendix.airports[number - 1].longitude, fligth.appendix.airports[number - 1].latitude);
                    var eCoord = new GeoCoordinate(fligth.appendix.airports[number].longitude, fligth.appendix.airports[number].latitude);

                    distance = sCoord.GetDistanceTo(eCoord);
                }
                AirPort airport = new AirPort
                {
                    Id             = Guid.NewGuid(),
                    ap_name        = a.name,
                    city           = a.city,
                    cityCode       = a.cityCode,
                    country        = a.countryName,
                    countryCode    = a.countryCode,
                    elevation      = a.elevationFeet,
                    iata           = a.iata,
                    number         = number,
                    name           = a.name,
                    timezone       = 0,
                    icao           = a.icao,
                    type           = "",
                    x              = a.latitude,
                    y              = a.longitude,
                    distanceToNext = distance
                };
                number++;
                claim.AirPorts.Add(airport);
            });

            claim.allDistance = claim.AirPorts.Sum(a => a.distanceToNext);

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                dc.Claims.Add(claim);
                dc.SaveChanges();
            }

            return(View("ColectData", claim));
        }
        //Export file CSV
        public void ExportCSV(string id)
        {
            AirPort airPort = _AirPortService.GetById(id);
            //Get IEnumerable AirPlane and Helicopter
            IEnumerable <AirPlane>   airPlanes   = _AirPlaneService.GetAll().Where(i => i.AirPortId == id);
            IEnumerable <Helicopter> helicopters = _HelicopterService.GetAll().Where(i => i.AirPortId == id);

            //Check an airPort is valid
            int numOfAirPlane   = 0;
            int numOfHelicopter = 0;

            foreach (var x in airPlanes)
            {
                numOfAirPlane++;
            }
            foreach (var x in helicopters)
            {
                numOfHelicopter++;
            }

            //check airport isvalid.
            if (numOfAirPlane >= 5 && numOfHelicopter >= 10)
            {
                StringWriter sw = new StringWriter();
                Response.ClearContent();
                Response.AddHeader("content-disposition", "attachment;filename=ExportAirport.csv");
                Response.ContentType = "text/csv";

                sw.WriteLine(string.Format("{0},{1},{2},{3},{4}",
                                           airPort.Id, airPort.Name, airPort.RunwaySize, airPort.MaxFWParkingPlace, airPort.MaxRWParkingPlace));

                foreach (AirPlane airPlane in airPlanes)
                {
                    sw.WriteLine(string.Format("{0},{1},{2},{3},{4},{5},{6},{7}",
                                               airPlane.Id,
                                               airPlane.Model,
                                               airPlane.AirPlaneType,
                                               airPlane.CruiseSpeed,
                                               airPlane.EmptyWeight,
                                               airPlane.MaxTakeoffWeight,
                                               airPlane.MinNeededRunwaySize,
                                               airPlane.FlyMethod
                                               ));
                }

                foreach (Helicopter helicopter in helicopters)
                {
                    sw.WriteLine(string.Format("{0},{1},{2},{3},{4},{5},{6}",
                                               helicopter.Id,
                                               helicopter.Model,
                                               helicopter.CruiseSpeed,
                                               helicopter.EmptyWeight,
                                               helicopter.MaxTakeoffWeight,
                                               helicopter.Range,
                                               helicopter.FlyMethod
                                               ));
                }

                Response.Write(sw.ToString());
                Response.End();
            }
        }
Beispiel #25
0
        public ActionResult RegisterClaimSave(string category)
        {
            ViewBag.category = category;

            string BordCardUrl         = "";
            string BookConfirmationUrl = "";

            if (Request.Files["BordCard"].ContentLength > 0)
            {
                var file = Request.Files["BordCard"];
                var name = Guid.NewGuid() + "." + file.FileName.Split('.')[1];
                BordCardUrl = $"/UserDocuments/{name}";
                file.SaveAs(Server.MapPath("~/UserDocuments/" + name));
            }
            if (Request.Files["BookConfirmation"].ContentLength > 0)
            {
                var file = Request.Files["BookConfirmation"];
                var name = Guid.NewGuid() + "." + file.FileName.Split('.')[1];
                BookConfirmationUrl = $"/UserDocuments/{name}";
                file.SaveAs(Server.MapPath("~/UserDocuments/" + name));
            }

            Guid   newGuid     = Guid.NewGuid();
            string AttorneyUrl = $"/UserDocuments/{newGuid}.pdf";

            var jsonString = Request.Form["json"];

            var        json = new JavaScriptSerializer();
            Rootobject data = json.Deserialize <Rootobject>(jsonString);


            Claim claim = new Claim
            {
                ClaimId = Guid.NewGuid(),
                State   = ClaimStatus.Pending,

                UserId      = null,
                DateCreated = DateTime.Now,


                Type         = ProblemType.Cancel,
                FlightNumber = Request.Form["FlightNumber"],


                AirCompany        = data.airline.al_name,
                AirCompanyCountry = data.airline.country,
                AdditionalInfo    = Request.Form["AdditionalInfo"],
                Confirm           = Request.Form["Confirm"],

                SignitureImage = Request.Form["SignitureImage"],
                AttorneyUrl    = AttorneyUrl
            };

            int number = 1;

            data.airports.ToList().ForEach(a =>
            {
                AirPort airport = new AirPort
                {
                    Id        = Guid.NewGuid(),
                    ap_name   = a.ap_name,
                    city      = a.city,
                    country   = a.country,
                    elevation = int.Parse(a.elevation),
                    iata      = a.iata,
                    number    = number,
                    name      = a.name,
                    timezone  = double.Parse(a.timezone),
                    icao      = a.icao,
                    type      = a.type,
                    x         = double.Parse(a.x),
                    y         = double.Parse(a.y)
                };
                number++;

                claim.AirPorts.Add(airport);
            });

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                dc.Claims.Add(claim);
                dc.SaveChanges();
            }

            string port = Request.Url.Port == 80 ? string.Empty : $":{Request.Url.Port.ToString()}";

            String url = $"{Request.Url.Scheme}://{Request.Url.Host}{port}/attorattorneyPdf-09-234-5644-34e5345-2343246neyPdf/{claim.ClaimId}";

            SelectPdf.HtmlToPdf   converter = new SelectPdf.HtmlToPdf();
            SelectPdf.PdfDocument doc       = converter.ConvertUrl(url);
            doc.Save(Server.MapPath($"~/UserDocuments/{newGuid}.pdf"));
            doc.Close();

            LogWithUser("temp", "temp");

            return(Redirect($"/обезщетение-списък/{claim.ClaimId}"));
        }
Beispiel #26
0
 /// <summary>
 /// Create an airport
 /// </summary>
 /// <param name="airport"></param>
 public void Create(AirPort airport)
 {
     _airportRepository.Create(airport);
 }
Beispiel #27
0
 /// <summary>
 /// Update an airport
 /// </summary>
 /// <param name="airport"></param>
 public void Update(AirPort airport)
 {
     _airportRepository.Update(airport);
 }
Beispiel #28
0
 // 为了不重复画线,两个站点之间只有一个 单向 路线
 private bool HasSameRoute(AirPort a, AirPort b)
 {
     return(a.inAirports.Contains(b) || a.outAirports.Contains(b));
 }