Пример #1
0
 private string _format(ParameterSet set) {
    var f = new BplJsonFormatter { PrettyPrint = false, StronglyTyped = true, SkipDefaults = false };
    if (f.Format(set)) {
       return f.Output;
    }
    return null;
 }
Пример #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);
            });
         }
      }