コード例 #1
0
 private void AuditUpdateofUser(Guid OrderingUserId, Guid?KeycloakUserId)
 {
     try
     {
         CSLOrderingARCBAL.LinqToSqlDataContext db;
         db = new CSLOrderingARCBAL.LinqToSqlDataContext();
         CSLOrderingARCBAL.User_Migration_KC _usermigration = (from user in db.User_Migration_KCs
                                                               where user.UserId == OrderingUserId
                                                               select user).SingleOrDefault();
         _usermigration.ModifiedOn = System.DateTime.Now;
         db.SubmitChanges();
     }
     catch (Exception objException)
     {
         CSLOrderingARCBAL.LinqToSqlDataContext db;
         db = new CSLOrderingARCBAL.LinqToSqlDataContext();
         db.USP_SaveErrorDetails("Authentication Service", "AuditUpdateofUser" + OrderingUserId.ToString(), Convert.ToString(objException.Message), Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), "", "", false, OrderingUserId.ToString());
     }
 }
コード例 #2
0
 private CSLOrderingARCBAL.User_Migration_KC GetMigratedUserDetail(Guid OrderingUserId)
 {
     CSLOrderingARCBAL.User_Migration_KC _usermigration = null;
     try
     {
         CSLOrderingARCBAL.LinqToSqlDataContext db;
         db             = new CSLOrderingARCBAL.LinqToSqlDataContext();
         _usermigration = (from user in db.User_Migration_KCs
                           where user.UserId == OrderingUserId
                           select user).SingleOrDefault();
         return(_usermigration);
     }
     catch (Exception objException)
     {
         CSLOrderingARCBAL.LinqToSqlDataContext db;
         db = new CSLOrderingARCBAL.LinqToSqlDataContext();
         db.USP_SaveErrorDetails("Authentication Service", "GetKeyCloakUserId" + OrderingUserId.ToString(), Convert.ToString(objException.Message), Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), "", "", false, OrderingUserId.ToString());
     }
     return(_usermigration);
 }
コード例 #3
0
    public void MigratetoKeyCloak(string UserName, string Password, string Email, string FirstName, string LastName, Guid OrderingUserId, DateTime LastPasswordChangedDate)
    {
        try
        {
            CSLOrderingARCBAL.User_Migration_KC _migrateduserdetail = GetMigratedUserDetail(OrderingUserId);
            Guid?KeyCloakUserID = null;

            if (_migrateduserdetail != null)
            {
                if (_migrateduserdetail.ModifiedOn >= LastPasswordChangedDate)
                {  //**User added already and password hasnt been changed since **//
                    return;
                }
                KeyCloakUserID = _migrateduserdetail.KeyCloakUserId;
            }

            string access_token = GetAdminToken().Result;
            if (!string.IsNullOrWhiteSpace(access_token))
            {
                keycloakuser keycloakuser = new keycloakuser(UserName, FirstName, LastName, Email, Password);
                string       JsonObject   = Newtonsoft.Json.JsonConvert.SerializeObject(keycloakuser);
                var          Jsoncontent  = new StringContent(JsonObject, Encoding.UTF8, "application/json");
                Jsoncontent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                if (KeyCloakUserID == null)// ** New User
                {
                    var adduser = AddasNewUser(access_token, OrderingUserId, Jsoncontent).Result;
                }
                else // ** Already in KeyCloak
                {
                    var updateuser = UpdateExistingUser(access_token, OrderingUserId, KeyCloakUserID.ToString(), Jsoncontent).Result;
                }
            }
        }
        catch (Exception objException)
        {
            CSLOrderingARCBAL.LinqToSqlDataContext db;
            db = new CSLOrderingARCBAL.LinqToSqlDataContext();
            db.USP_SaveErrorDetails("Authentication Service", "MigratetoKeyCloak -" + OrderingUserId.ToString(), Convert.ToString(objException.Message), Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), "", "", false, OrderingUserId.ToString());
        }
    }
コード例 #4
0
    private void AuditCreationofUser(Guid OrderingUserId, Guid?KeycloakUserId)
    {
        try {
            CSLOrderingARCBAL.LinqToSqlDataContext db;
            db = new CSLOrderingARCBAL.LinqToSqlDataContext();

            CSLOrderingARCBAL.User_Migration_KC _usermigration = new CSLOrderingARCBAL.User_Migration_KC();
            _usermigration.UserId         = OrderingUserId;
            _usermigration.KeyCloakUserId = KeycloakUserId;
            _usermigration.CreatedOn      = System.DateTime.Now;
            _usermigration.ModifiedOn     = System.DateTime.Now;
            db.User_Migration_KCs.InsertOnSubmit(_usermigration);
            db.SubmitChanges();
        }
        catch (Exception objException)
        {
            CSLOrderingARCBAL.LinqToSqlDataContext db;
            db = new CSLOrderingARCBAL.LinqToSqlDataContext();
            db.USP_SaveErrorDetails("Authentication Service", "AuditCreationofUser" + OrderingUserId.ToString(), Convert.ToString(objException.Message), Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), "", "", false, OrderingUserId.ToString());
        }
    }