private async void btnSubmit_Clicked(object sender, EventArgs e)
        {
            slForm.IsVisible     = false;
            aiActivity.IsRunning = true;
            var response = await RockClient.LogIn(username.Text, password.Text);

            switch (response)
            {
            case LoginResponse.Error:
                aiActivity.IsRunning = false;
                slForm.IsVisible     = true;
                App.Current.MainPage.DisplayAlert("Log-in Error", "There was an issue with your log-in attempt. Please try again later. (Sorry)", "OK");
                break;

            case LoginResponse.Failure:
                aiActivity.IsRunning = false;
                slForm.IsVisible     = true;
                App.Current.MainPage.DisplayAlert("Log-in Error", "Your username or password was incorrect.", "OK");
                break;

            case LoginResponse.Success:
                AvalancheNavigation.Footer = null;
                App.Current.MainPage       = new AvalanchePage();
                AvalancheNavigation.RequestNewRckipid();
                FCMHelper.RegisterFCMToken();
                break;

            default:
                break;
            }
        }
        private async void btnPin_Clicked(object sender, EventArgs e)
        {
            slPin.IsVisible     = false;
            slLoading.IsVisible = true;

            var response = await RockClient.LogIn("__PHONENUMBER__+1" + phoneNumber, ePin.Text);

            switch (response)
            {
            case LoginResponse.Error:
                App.Current.MainPage.DisplayAlert("Log-in Error", "There was an issue with your log-in attempt. Please try again later. (Sorry)", "OK");
                slPin.IsVisible     = true;
                slLoading.IsVisible = false;
                break;

            case LoginResponse.Failure:
                App.Current.MainPage.DisplayAlert("Log-in Error", "Phone number and pin did not match. Please try again.", "OK");
                slPin.IsVisible     = true;
                slLoading.IsVisible = false;
                break;

            case LoginResponse.Success:
                AvalancheNavigation.Footer = null;
                App.Current.MainPage       = new AvalanchePage();
                AvalancheNavigation.RequestNewRckipid();
                FCMHelper.RegisterFCMToken();
                break;

            default:
                break;
            }
        }
Пример #3
0
 public void DidReceiveRegistrationToken(Messaging messaging, string fcmToken)
 {
     Console.WriteLine(fcmToken);
     FCMHelper.RegisterFCMToken(fcmToken);
 }
Пример #4
0
 void SendRegistrationToServer(string token)
 {
     FCMHelper.RegisterFCMToken(token);
 }
Пример #5
0
        public static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += AppDomain_CurrentDomain_UnhandledException;
            AppDomain.CurrentDomain.ProcessExit        += CurrentDomain_ProcessExit;
            try {
                IniConfigSource configFile = new IniConfigSource(ConfigFile);
                configFile.Reload();
                IConfig config = configFile.Configs ["General"];
                server = config.GetString("server");
                port   = config.GetString("port", "3306");
                user   = config.GetString("user");
                pass   = config.GetString("password");
                db     = config.GetString("database");
                firebaseServerApiToken = config.GetString("server_api_token");
                firebaseSenderId       = config.GetString("firebase_sender");
                servicePort            = config.GetString("service_port");
                serviceHostName        = config.GetString("service_host_name");

                OsmService.ConfigureService(configFile);
            } catch (Exception ex) {
                logger.Fatal(ex, "Ошибка чтения конфигурационного файла.");
                return;
            }

            WebServiceHost OsmHost = new WebServiceHost(typeof(OsmService));

            logger.Info(String.Format("Создаем и запускаем службы..."));
            try {
                var conStrBuilder = new MySqlConnectionStringBuilder();
                conStrBuilder.Server   = server;
                conStrBuilder.Port     = UInt32.Parse(port);
                conStrBuilder.Database = db;
                conStrBuilder.UserID   = user;
                conStrBuilder.Password = pass;
                conStrBuilder.SslMode  = MySqlSslMode.None;

                QSMain.ConnectionString = conStrBuilder.GetConnectionString(true);
                var db_config = FluentNHibernate.Cfg.Db.MySQLConfiguration.Standard
                                .Dialect <NHibernate.Spatial.Dialect.MySQL57SpatialDialect>()
                                .ConnectionString(QSMain.ConnectionString);

                OrmConfig.ConfigureOrm(db_config,
                                       new System.Reflection.Assembly[] {
                    System.Reflection.Assembly.GetAssembly(typeof(Vodovoz.HibernateMapping.OrganizationMap)),
                    System.Reflection.Assembly.GetAssembly(typeof(QSBanks.QSBanksMain)),
                    System.Reflection.Assembly.GetAssembly(typeof(QSContacts.QSContactsMain)),
                    System.Reflection.Assembly.GetAssembly(typeof(EmailService.Email))
                });

                MainSupport.LoadBaseParameters();

                FCMHelper.Configure(firebaseServerApiToken, firebaseSenderId);

                ServiceHost    ChatHost          = new ServiceHost(typeof(ChatService));
                ServiceHost    AndroidDriverHost = new ServiceHost(typeof(AndroidDriverService));
                ServiceHost    EmailSendingHost  = new ServiceHost(typeof(EmailService.EmailService));
                WebServiceHost MailjetEventsHost = new WebServiceHost(typeof(EmailService.EmailService));
                WebServiceHost MobileHost        = new WebServiceHost(typeof(MobileService));

                ChatHost.AddServiceEndpoint(
                    typeof(IChatService),
                    new BasicHttpBinding(),
                    String.Format("http://{0}:{1}/ChatService", serviceHostName, servicePort)
                    );
                AndroidDriverHost.AddServiceEndpoint(
                    typeof(IAndroidDriverService),
                    new BasicHttpBinding(),
                    String.Format("http://{0}:{1}/AndroidDriverService", serviceHostName, servicePort)
                    );
                EmailSendingHost.AddServiceEndpoint(
                    typeof(IEmailService),
                    new BasicHttpBinding(),
                    String.Format("http://{0}:{1}/EmailService", serviceHostName, servicePort)
                    );
                MailjetEventsHost.AddServiceEndpoint(
                    typeof(IMailjetEventService),
                    new WebHttpBinding(),
                    String.Format("http://{0}:{1}/Mailjet", serviceHostName, servicePort)
                    );

                MobileService.BaseUrl = String.Format("http://{0}:{1}/Mobile", serviceHostName, servicePort);
                MobileHost.AddServiceEndpoint(
                    typeof(IMobileService),
                    new WebHttpBinding(),
                    MobileService.BaseUrl
                    );

                OsmWorker.ServiceHost = serviceHostName;
                OsmWorker.ServicePort = Int32.Parse(servicePort);
                OsmHost.AddServiceEndpoint(typeof(IOsmService), new WebHttpBinding(), OsmWorker.ServiceAddress);

                //FIXME Тут добавлен без дебага, потому что без него не работает отдача изображений в потоке. Метод Stream GetImage(string filename)
                // Просто не смог быстро разобраться. А конкретнее нужна строка reply = TraceMessage (reply.CreateBufferedCopy (int.MaxValue), Action.Send);
                // видимо она как то обрабатывает сообщение.
                MobileHost.Description.Behaviors.Add(new PreFilter());

                                #if DEBUG
                ChatHost.Description.Behaviors.Add(new PreFilter());
                AndroidDriverHost.Description.Behaviors.Add(new PreFilter());
                EmailSendingHost.Description.Behaviors.Add(new PreFilter());
                MailjetEventsHost.Description.Behaviors.Add(new PreFilter());
                OsmHost.Description.Behaviors.Add(new PreFilter());
                                #endif

                ChatHost.Open();
                AndroidDriverHost.Open();
                EmailSendingHost.Open();
                MailjetEventsHost.Open();
                MobileHost.Open();
                OsmHost.Open();

                //Запускаем таймеры рутины
                OrderRoutineTimer          = new System.Timers.Timer(120000);        //2 минуты
                OrderRoutineTimer.Elapsed += OrderRoutineTimer_Elapsed;
                OrderRoutineTimer.Start();
                TrackRoutineTimer          = new System.Timers.Timer(30000);        //30 секунд
                TrackRoutineTimer.Elapsed += TrackRoutineTimer_Elapsed;
                TrackRoutineTimer.Start();

                logger.Info("Server started.");

                UnixSignal[] signals =
                {
                    new UnixSignal(Signum.SIGINT),
                    new UnixSignal(Signum.SIGHUP),
                    new UnixSignal(Signum.SIGTERM)
                };
                UnixSignal.WaitAny(signals);
            } catch (Exception e) {
                logger.Fatal(e);
            } finally {
                if (OsmHost.State == CommunicationState.Opened)
                {
                    OsmHost.Close();
                }

                if (Environment.OSVersion.Platform == PlatformID.Unix)
                {
                    Thread.CurrentThread.Abort();
                }
                Environment.Exit(0);
            }
        }