Exemplo n.º 1
0
        public static void CheckText(long id, string text)
        {
            string res;

            if (!string.IsNullOrEmpty(DataConstants.GetLocationBySearchTag(text)?.Id))
            {
                RemoteDataManager.GetInstance().GetEventsHereNow(id, DataConstants.GetLocationBySearchTag(text).Id, DataConstants.Now, "NL");
            }
            else
            {
                if (ReplyStore == null)
                {
                    InitReplies();
                }

                res = GetResponse(text);
                if (res != null && res.Length > 3)
                {
                    RMmanager.SendTextMessage(id, res);
                }
                if (res.Length < 4)
                {
                    RMmanager.SendTextMessage(id, DataConstants.GetMessage("INVALID_INPUT", "NL"));
                }
                RemoteDataManager.GetInstance().GetEventByName(text, id, "NL");
            }
        }
Exemplo n.º 2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException += UnhandledExceptionHandler;

            Portfolio = new Portfolio(IoC.GetInstance <IEventPublisher>());

            TimerManager = new TimerManager(IoC.GetInstance <IEventPublisher>());

            ConfigurationManager = new ConfigurationManager(
                IoC.GetInstance <IEventPublisher>(),
                IoC.GetInstance <IFileService>());

            ConfigurationManager.Init();

            DataManager = new RemoteDataManager(IoC.GetInstance <IEventPublisher>());

            DataManager.Init();
            DataManager.UpdateAllAccounts();

            var window = new MainWindow
            {
                DataContext = ServiceLocator.Current.GetInstance <MainViewModel>()
            };

            Current.MainWindow = window;
            Current.MainWindow.Show();

            base.OnStartup(e);
        }
Exemplo n.º 3
0
        public void handle(Messaging message)
        {
            try
            {
                long        id      = message.sender.id;
                PayloadData payload = new PayloadData(message.postback.payload);
                //Console.WriteLine(payload);
                switch (payload.Payload)
                {
                case "GET_STARTED_PAYLOAD":
                    rmanager.SendWelcomeMessage(id, payload.Language);
                    break;

                case "SEND_LOCATION_CHOICE":
                    rmanager.SendLocationsChoice(id, payload.Language);
                    break;

                // tijd keuze extra
                case "SEND_DATE_CHOICE":
                    rmanager.SendDateChoice(message.sender.id, payload.Language);
                    break;

                case "DEVELOPER_DEFINED_DATE_SPECIFIC":
                    rmanager.SendDayOption(message.sender.id, payload.Language);
                    break;

                case "SEND_LANGUAGE_OPTIONS":
                    rmanager.ChangeLanguage(message.sender.id);
                    break;

                case "GET_TOILET":
                    string[]           co       = payload.Value.Split(':');
                    SearchableLocation location = DataConstants.GetClosestsToilet(double.Parse(co[0]), double.Parse(co[1]));
                    // Console.WriteLine($"Closest location found: {location.PrettyName} ");
                    rmanager.SendGenericMessage(LocationFactory.MakeLocationResponse(id, location.Lat, location.Lon, payload.Language));
                    break;

                case "SET_LANGUAGE":
                    rmanager.SendWelcomeMessage(id, payload.Value);
                    break;

                case "GET_USER_LOCATION":
                    if (!string.IsNullOrWhiteSpace(payload.Value) && payload.Value == "true")
                    {
                        TempUserData.Instance.Add(id, payload.Language, true);
                    }
                    else
                    {
                        TempUserData.Instance.Add(id, payload.Language, false);
                    }
                    rmanager.SendGetLocationButton(message.sender.id, payload.Language);
                    break;

                case "DEVELOPER_DEFINED_SEARCHFALSE":
                    rmanager.SendInfoForEnding(message.sender.id, payload.Language);
                    break;

                case "GET_EVENT_HERE_NOW":
                    rmanager.SendLocationQuery(id, int.Parse(payload.Value), payload.Language);
                    break;

                case "DEVELOPER_DEFINED_LOCATION":
                    if (payload.Value != "ALL")
                    {
                        RemoteDataManager.GetInstance().GetEventsHereNow(id, DataConstants.GetLocation(payload.Value).Id, DataConstants.Now, payload.Language);
                    }
                    else
                    {
                        RemoteDataManager.GetInstance().GetEventsNow(id, payload.Language, DataConstants.Now);
                    }
                    break;

                case "DEVELOPER_DEFINED_DAY":
                    rmanager.SendTimePeriod(id, payload.Value, payload.Language);
                    break;

                case "DEVELOPER_DEFINED_COORDINATES":
                    string[] data = payload.Value.Split(':');
                    List <SearchableLocation> locatio = DataConstants.GetClosestLocation(new Coordinates {
                        lat = double.Parse(data[1]), lon = double.Parse(data[0])
                    }, 3);
                    // Console.WriteLine($"Closest location found: {location.PrettyName} ");
                    rmanager.SendLocationResult(id, locatio, payload.Language);
                    break;

                case "DEVELOPER_DEFINED_DESCRIPTION":
                    rmanager.SendTextMessage(id, payload.Value);
                    break;

                case "DEVELOPER_DEFINED_HOURS":
                    string[] dat = payload.Value.Split('|');
                    rmanager.SendHoursChoice(id, dat[0], dat[1], payload.Language);
                    break;

                case "DEVELOPER_DEFINED_HOURS_COMP":
                    string[] da = payload.Value.Split('|');
                    payload.Value = $"{da[1]}{da[0]}:00+02:00";
                    //rmanager.SendTextMessage(id, value);
                    //Console.WriteLine("Datum: " + payload.Value);
                    RemoteDataManager.GetInstance().GetEventsAtTime(id, payload.Value, payload.Language);
                    break;

                case "DEVELOPER_DEFINED_NEXT":
                    // moet nog normaal gezet worden maar voor test gevallen is het deze tijd
                    int pos = payload.Value.IndexOf("-_-");
                    RemoteDataManager.GetInstance().GetNextEvents(payload.Value.Substring(0, pos), payload.Value.Substring(pos + 3), 3, id, payload.Language);
                    break;

                default:
                    //do nothing
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }