Exemple #1
0
        private async Task <Push> InternalSendPushAsync(BasePush parameters, PushTarget target, string identifier)
        {
            switch (target)
            {
            case PushTarget.Device:
                parameters.DeviceIndentifier = identifier;
                break;

            case PushTarget.Email:
                parameters.Email = identifier;
                break;

            case PushTarget.Channel:
                parameters.ChannelTag = identifier;
                break;

            case PushTarget.Client:
                parameters.ClientIdentifier = identifier;
                break;
            }

            var pushModel = await RequestClient.SendAsync <PushModel>("/v2/pushes", HttpMethod.Post, parameters)
                            .ConfigureAwait(false);

            return(new Push(pushModel, RequestClient));
        }
Exemple #2
0
        public void Start()
        {
            serviceIsAlive = new LifeTimeTimer(60);             //	период в секундах для перезаписи файла функционирования

            //========ЗАГАСИЛ=========
            //feedbackIsExist = new ApnsFeedBack(1);	//	период в часах для проверки фидбэка от сервера APNS

            //PushNotificationsLists _listPush;


            enabled = true;
            Console.WriteLine();
            Console.WriteLine($"Сервис {Program.ServiceName} запущен");
#if DEBUG
            Console.WriteLine($"=====================Режим расширеных логов включен================");
#endif
            while (enabled)
            {
                selector = new SelectFromDb();
                if (selector.SelectFromDbMethod())
                {
                    if (PushNotificationsLists.ListNotificationsForSend.Count != 0)
                    {
//#if DEBUG
                        Console.WriteLine($"Количество сообщений для отправки: {PushNotificationsLists.ListNotificationsForSend.Count}");
//#endif
                        foreach (var notification in PushNotificationsLists.ListNotificationsForSend)
                        {
                            pushHandler = new BasePush();
                            pushHandler.PushMethod(notification);
                        }

                        PushNotificationsLists.ListNotificationsForSend.Clear();
                        continue;
                    }
#if DEBUG
                    else
                    {
                        Console.WriteLine($"Количество сообщений для отправки: {PushNotificationsLists.ListNotificationsForSend.Count}");
                    }
#endif
                }

#if DEBUG
                Console.WriteLine();
                Console.WriteLine($"Запускается пайп");
#endif
                BasePipe.ListenPipeMethod();
            }
#if DEBUG
            Console.WriteLine($"bool Enabled ? {enabled}");
#endif
        }