Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            string AuthKey = "AIzaSyDZD29PWZQBmSvW0vAYIu0mvkg2ny5TD9A";
            string PackageName = "com.mydealerlot.mdlmobile";
            string SenderId = "595292508198";
            GcmManagerOptions options = new GcmManagerOptions() { 
                AuthenticationKey = AuthKey, 
                PackageName = PackageName,
                SenderId = SenderId,
                Expect100Continue = false, //default
                UseNagleAlgorithm = false //default
            };

            GcmManager manager = new GcmManager(options);

            GcmMessage message = new GcmMessage().To("RegistrationTokenHere")
                .WithData(new { body = "Client: MR. SMITH, Appointment Time: today 3:00pm", title = "Your Appointment Has Arrived" })
                .WithNotification(new GcmNotification().WithBody("body text here").WithTitle("Title Here"));
               // ;
                //.WithRestrictedPackageName(PackageName).WithTimeToLive(400)
                //.WithIcon("myIcon.png").WithColor("color"));


            Stopwatch watch = new Stopwatch();
            Console.ReadKey();
            //for (int i = 0; i < 10; i++)
            //{
                watch.Start();
                Console.WriteLine("getting instance response");

                GcmMessageResponse response = manager.SendMessage(message);
                //var r = manager.GetInstanceIdResponse(true, "APA91bEVUAdCF4XdfV6cnecuih5SY48lePF8ZCiBgL8fgqRlB9CKlRyZbqOpfOOfP3SkOG2VYH1LDrYi80aotHg1at6QdcDrk_2t1_Iopw7MAkjv0dD-4DCbyqw7qKpF7INfiRQ2u_Ax");
                //Console.WriteLine(r.ToString());

                watch.Stop();
                Console.WriteLine("\nOVERALL: {0}\n\n", watch.Elapsed);
                watch.Reset();
            //}
            
            //bool again = true;
            //while(again)
            //{

            //Console.WriteLine("ready?");
            //Console.ReadLine();
            // var response = manager.SendMessage(message);
            string data = JsonConvert.SerializeObject(message, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore});
            Console.WriteLine(data);
            Debug.WriteLine(data);
            //Console.WriteLine("\n again?");
            //var s = Console.ReadLine();
            //if (s.Contains("no"))
            //    again = false;
            //}
            Console.ReadKey();


        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            string            AuthKey     = "AIzaSyDZD29PWZQBmSvW0vAYIu0mvkg2ny5TD9A";
            string            PackageName = "com.mydealerlot.mdlmobile";
            string            SenderId    = "595292508198";
            GcmManagerOptions options     = new GcmManagerOptions()
            {
                AuthenticationKey = AuthKey,
                PackageName       = PackageName,
                SenderId          = SenderId,
                Expect100Continue = false, //default
                UseNagleAlgorithm = false  //default
            };

            GcmManager manager = new GcmManager(options);

            GcmMessage message = new GcmMessage().To("RegistrationTokenHere")
                                 .WithData(new { body = "Client: MR. SMITH, Appointment Time: today 3:00pm", title = "Your Appointment Has Arrived" })
                                 .WithNotification(new GcmNotification().WithBody("body text here").WithTitle("Title Here"));
            // ;
            //.WithRestrictedPackageName(PackageName).WithTimeToLive(400)
            //.WithIcon("myIcon.png").WithColor("color"));


            Stopwatch watch = new Stopwatch();

            Console.ReadKey();
            //for (int i = 0; i < 10; i++)
            //{
            watch.Start();
            Console.WriteLine("getting instance response");

            GcmMessageResponse response = manager.SendMessage(message);

            //var r = manager.GetInstanceIdResponse(true, "APA91bEVUAdCF4XdfV6cnecuih5SY48lePF8ZCiBgL8fgqRlB9CKlRyZbqOpfOOfP3SkOG2VYH1LDrYi80aotHg1at6QdcDrk_2t1_Iopw7MAkjv0dD-4DCbyqw7qKpF7INfiRQ2u_Ax");
            //Console.WriteLine(r.ToString());

            watch.Stop();
            Console.WriteLine("\nOVERALL: {0}\n\n", watch.Elapsed);
            watch.Reset();
            //}

            //bool again = true;
            //while(again)
            //{

            //Console.WriteLine("ready?");
            //Console.ReadLine();
            // var response = manager.SendMessage(message);
            string data = JsonConvert.SerializeObject(message, Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });

            Console.WriteLine(data);
            Debug.WriteLine(data);
            //Console.WriteLine("\n again?");
            //var s = Console.ReadLine();
            //if (s.Contains("no"))
            //    again = false;
            //}
            Console.ReadKey();
        }
Ejemplo n.º 3
0
        protected override void OnDoWork(DoWorkEventArgs e)
        {
            while (!CancellationPending)
            {
                foreach (var reservation in Reservations)
                {
                    var datetime = reservation.ReservationDateTime;
                    var svcId    = reservation.SvcId;

                    var freeDates = HttpManager.GetFreeSite(datetime.Year.ToString("0000"),
                                                            datetime.Month.ToString("00"), svcId);

                    if (freeDates == null)
                    {
                        continue;
                    }

                    var findDate = freeDates.Where(x => x == datetime.ToString("yyyyMMdd"));

                    string message;

                    if (findDate.Any())
                    {
                        GcmManager.SendNotification("과천" + datetime.ToString("yyyy-MM-dd"), "빈자리");

                        var rsvReqKey = HttpManager.GetRsvReq(Cookie, svcId);
                        Thread.Sleep(10);

                        HttpManager.Step0(Cookie, svcId, rsvReqKey);
                        Thread.Sleep(50);

                        HttpManager.Step1_1(Cookie);
                        Thread.Sleep(100);

                        HttpManager.Step2(Cookie);
                        Thread.Sleep(100);

                        var stepRsvtm = HttpManager.Step2_1(Cookie, svcId, datetime.ToString("yyyyMMdd"));
                        Thread.Sleep(100);

                        var mixData = HttpManager.Step2_2(datetime, stepRsvtm, Cookie);
                        var dcStdSn = mixData.Split('|')[0];
                        var feeTgt  = mixData.Split('|')[1];

                        Thread.Sleep(100);
                        HttpManager.Step3_1(Cookie, svcId, feeTgt, dcStdSn);
                        var mixString = HttpManager.Step3_2(Cookie, svcId, feeTgt, dcStdSn);

                        var array = mixString.Split('|');

                        Thread.Sleep(100);
                        HttpManager.Step4_1(Cookie);
                        string zipcode = "-";
                        try
                        {
                            zipcode = array[4].Substring(0, 3) + "-" + array[4].Substring(3, 3);
                        }
                        catch
                        {
                        }


                        Thread.Sleep(100);
                        HttpManager.Step4_2(Cookie, svcId, zipcode);


                        var result = HttpManager.Step4_3(array[0], array[1], array[2], array[3], zipcode, array[5],
                                                         Cookie);

                        if (result)
                        {
                            message = string.Format("{0} {1} - {2}", "성공", datetime.ToString("MM-dd"),
                                                    DateTime.Now.ToString("MM-dd HH:mm:ss"));

                            ReportProgress(0, message);

                            GcmManager.SendNotification("과천" + message, "캠핑예약");
                            CancelAsync();
                            break;
                        }

                        message = string.Format("{0} {1} - {2}", "실패", datetime.ToString("MM-dd"),
                                                DateTime.Now.ToString("MM-dd HH:mm:ss"));
                    }
                    else
                    {
                        message = string.Format("{0} {1}  - {2}", "실패", datetime.ToString("yyyy-MM-dd"),
                                                DateTime.Now.ToString("MM-dd HH:mm:ss"));
                    }

                    ReportProgress(0, message);

                    Thread.Sleep(100 * Interval);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        private void SyncReservation()
        {
            var reservations =
                (from object item in cbReservation.CheckedItems
                 select new Reservation
            {
                ReservationDateTime = DateTime.Parse(item.ToString().Split('|')[0].Trim()),
                SvcId = item.ToString().Split('|')[1].Trim()
            }).ToList();

            foreach (var reservation in reservations)
            {
                if (btnStartReservation.Text == @"시작")
                {
                    break;
                }

                var reservationDateTime = reservation.ReservationDateTime;
                var svcId = reservation.SvcId;

                var freeDates = HttpManager.GetFreeSite(reservationDateTime.Year.ToString("0000"),
                                                        reservationDateTime.Month.ToString("00"), svcId);

                var findDate = freeDates.Where(x => x == reservationDateTime.ToString("yyyyMMdd"));

                string message;

                if (findDate.Any())
                {
                    var rsvReqKey = HttpManager.GetRsvReq(_cookie, svcId);

                    HttpManager.Step0(_cookie, svcId, rsvReqKey);

                    HttpManager.Step1_1(_cookie);

                    HttpManager.Step2(_cookie);

                    var stepRsvtm = HttpManager.Step2_1(_cookie, svcId, reservationDateTime.ToString("yyyyMMdd"));

                    var mixData = HttpManager.Step2_2(reservationDateTime, stepRsvtm, _cookie);
                    var dcStdSn = mixData.Split('|')[0];
                    var feeTgt  = mixData.Split('|')[1];

                    HttpManager.Step3_1(_cookie, svcId, feeTgt, dcStdSn);
                    var mixString = HttpManager.Step3_2(_cookie, svcId, feeTgt, dcStdSn);

                    var array = mixString.Split('|');

                    HttpManager.Step4_1(_cookie);
                    var zipcode = array[4].Substring(0, 3) + "-" + array[4].Substring(3, 3);
                    HttpManager.Step4_2(_cookie, svcId, zipcode);


                    if (btnStartReservation.Text == @"중지")
                    {
                        break;
                    }
                    var result = HttpManager.Step4_3(array[0], array[1], array[2], array[3], zipcode, array[5],
                                                     _cookie);


                    if (result)
                    {
                        message = string.Format("{0} {1} 예약 - {2}", "성공", reservationDateTime.ToString("MM-dd"),
                                                DateTime.Now.ToString("MM-dd HH:mm:ss"));

                        GcmManager.SendNotification("과천" + message, "캠핑예약");
                        Util.Logging(txtLog, message);
                        break;
                    }

                    message = string.Format("{0} {1} 예약 - {2}", "실패", reservationDateTime.ToString("MM-dd"),
                                            DateTime.Now.ToString("MM-dd HH:mm:ss"));
                    Util.Logging(txtLog, message);
                }
                else
                {
                    message = string.Format("{0} {1} 실패 - {2}", "성공", reservationDateTime.ToString("MM-dd"),
                                            DateTime.Now.ToString("MM-dd HH:mm:ss"));
                    Util.Logging(txtLog, message);
                }

                Thread.Sleep(1000 * (int)numInterval.Value);
            }
        }