コード例 #1
0
ファイル: Program.cs プロジェクト: trueproger/arseniyrep
        public static EmergencyCaseInfo Map(myObject pars)
        {
            var res = new EmergencyCaseInfo();

            res.externalCardId     = pars.card.id;                                                                                                                          //Id в системе ISS
            res.caller.firstName   = pars.ier.fullName.lastName;                                                                                                            // фамилия
            res.caller.lastName    = pars.ier.fullName.firstName;                                                                                                           // имя
            res.caller.midleName   = pars.ier.fullName.middleName;                                                                                                          //отчество
            res.caller.phoneNumber = pars.ier.cgPn;                                                                                                                         // номер
            res.info = pars.card.commonData.typeStr + " " + pars.card.commonData.isDanger + " " + pars.card.commonData.description + " " + pars.card.commonData.timeIsoStr; //информация о происшествии
            res.location.entrance     = pars.card.location.address.porch;                                                                                                   //подьезд
            res.location.highway.km   = pars.card.location.address.distanceInKm;                                                                                            //километр трассы
            res.location.highway.name = pars.card.location.address.road;                                                                                                    //название трассы
            res.location.house        = pars.card.location.address.houseNumber;                                                                                             // номер дома
            string buf  = pars.card.location.coordinates;                                                                                                                   // координаты
            string buff = buf.Replace('.', ',');

            string[] split = buff.Split(' ');
            double   x     = double.Parse(split[0]);
            long     xx    = Convert.ToInt64(x * 3600000);

            res.location.latitude = xx;//широта
            x  = double.Parse(split[1]);
            xx = Convert.ToInt64(x * 3600000);
            res.location.longitude    = xx;                                                                               //долгота
            res.location.locality     = pars.card.location.address.city;                                                  //город
            res.location.municipality = pars.card.location.address.district;                                              //район
            res.location.street       = pars.card.location.address.streetShort + " " + pars.card.location.address.street; //улица


            return(res);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: trueproger/arseniyrep
        private static async Task Listen()
        {
            var listener = new HttpListener();

            listener.Prefixes.Add(@"http://10.1.0.69/");
            listener.Start();

            Console.WriteLine("Ожидание подключений...");

            while (true)
            {
                HttpListenerContext context = await listener.GetContextAsync();

                HttpListenerRequest  request  = context.Request;
                HttpListenerResponse responce = context.Response;
                Stream body = request.InputStream;
                using (var sr = new StreamReader(body, Encoding.UTF8))
                    try
                    {
                        responce.StatusCode = Convert.ToInt32(HttpStatusCode.OK);
                        string str = await sr.ReadToEndAsync();

                        myObject obj = JsonConvert.DeserializeObject <myObject>(str);

                        BasicHttpBinding_IEmergencyCard UPDCase = new BasicHttpBinding_IEmergencyCard();
                        UPDCase.UpdateCase(Map(obj));
                    }
                    catch (Exception ex) { Console.WriteLine(ex.Message); }
                finally
                {
                    responce.Close();
                    body.Close();
                    sr.Close();

                    Console.WriteLine("Сигнал обработан");
                }
            }
        }