コード例 #1
0
ファイル: GetDriverInfo.cs プロジェクト: borkaborka/gmit
      internal void Handle(GetDriverInfo input) {
         using (var dbConn = DatabaseManager.DbConn()) {
            var nInf = dbConn.ExecuteBpl(new DriverGetById { DriverId = input.DriverId });
            if (nInf != null) {
               Log.Trace("User {0} found in local DB. Response.", input.DriverId);

               var contacts = dbConn.ExecuteBpl(new ContactGetById { ContactId = nInf.DriverId });
               if (contacts != null) {
                  foreach (var ci in contacts) {
                     var ct = new Contact();
                     ct.Type = ci.Type;
                     ct.Value = ci.Value;

                     nInf.Contacts.Add(ct);
                  }
               }

               Reply(nInf);
               return;
            }
         }

         //TK: If Tibo/Amdocs is down, uncomment following
         //r(input, new Result<Subscriber> { result = new Subscriber { Id = Mpcr.Core.Language.BplIdentity.Get(input.RegistrationCode) } }, false);
         //return;

         //2: If not found, ask Tibco
         if (OscarServer.UseBackendMasterData) {
            RequestDriverInfo(input.DriverId, true);
         }
      }
コード例 #2
0
      private void _checkDriver(BplIdentity DriverId, string RegistrationCode, AuthorizationSessionKind actionKind, Action<DriverAuthorizationResult> onSuccess, Action<GeneralFailure> onFailure) {

         if (DriverId == null || RegistrationCode.IsEmpty()) {
            Log.Warn("Driver registration: Attempt to check driver with bad arguments. UserId:{0}, UserSsn:{1}", DriverId, RegistrationCode);
            onSuccess(new DriverAuthorizationResult { Result = RegistrationResult.InvalidInformation });
         } else {
            var di = new GetDriverInfo { DriverId = DriverId };
            Services.Invoke(di,
               o => {
                  if (o != null) {
                     if (o.DriverSsn.EqualsIgnoreCase(RegistrationCode)) {
                        Log.Info("Driver registration: Initialized for driver '{0}'.", DriverId);
                        var contacts = o.Contacts.Where(c => c.Type == ContactTypes.MobilePhone || c.Type == ContactTypes.Email).Select(c => c.Clone());
                        var result = new DriverAuthorizationResult { Result = RegistrationResult.Success, Token = _createNewAuthorizationToken(DriverId, contacts, o.Name, actionKind) };
                        result.Contacts.AddRange(contacts);
                        if (result.Contacts.Count > 0) {
                           onSuccess(result);
                        } else {
                           Log.Warn("Driver registration: Driver '{0}' has no valid contact information.", DriverId);
                           onSuccess(new DriverAuthorizationResult { Result = RegistrationResult.InvalidInformation });
                        }

                     } else {
                        Log.Warn("Driver registration: Driver '{0}' SSN ({1}) not matches database value ({2}).", DriverId, RegistrationCode, o.DriverSsn);
                        onSuccess(new DriverAuthorizationResult { Result = RegistrationResult.InvalidInformation });
                     }
                  } else {
                     Log.Warn("Driver registration: Driver '{0}' is not found in database or blocked.", DriverId);
                     onSuccess(new DriverAuthorizationResult { Result = RegistrationResult.ClientBlocked });
                  }
               },
               e => onFailure(e)
            );
         }
      }