Пример #1
0
      internal void Handle(UpdateSettingsSection input) {
         using (var dbConn = DatabaseManager.DbConn()) {
            dbConn.BeginTransaction();

            var s = new SettingInfo();

            s.DriverId = input.DriverId;
            s.ApplicationId = input.ApplicationId;
            s.Name = input.Section;
            s.Value = _format(input.Values);
            s.DataSource = DataSources.Driver;

            dbConn.ExecuteBpl(new SettingSave(s));

            dbConn.CommitTransaction();
         }

         Reply(true);
      }
Пример #2
0
      private void _handleUpdateSessionData(UpdateSessionData updateSessionData, OscarSessionData session, Action<LoginResult> onResult) {
         Log.Info("Session Update: Start");
         var result = new LoginResult { SessionToken = CryptServices.Encode(session), Status = LoginStatus.SessionBlocked };

         if (session.IsExpired(SessionTimeout)) {
            Log.Warn("Session Update: Session is expired. Create valid session first");
            onResult(result);
         } else {
            var values = new ParameterSet();
            values.Parameters.Add(new Parameter { Name = _dVehicle, Value = updateSessionData.UserVehicle });
            values.Parameters.Add(new Parameter { Name = _dLocale, Value = updateSessionData.UserLocale.Name });

            var preferences = new UpdateSettingsSection {
               DriverId = session.UserId,
               Values = values,
               Section = _dSessionSection
            };

            Services.Invoke(preferences, o => {
               if (o) {
                  session.VehicleId = updateSessionData.UserVehicle;
                  session.UserLocale = updateSessionData.UserLocale;

                  result.SessionToken = CryptServices.Encode(session);
                  result.Status = LoginStatus.Success;
               } else {
                  Log.Warn("Session Update: Unable to update session data");
               }
               onResult(result);
            }, e => {
               Log.Warn("Session Update: Error processing set preference request {0}", e);
               onResult(result);
            });
         }
      }