Пример #1
0
        public virtual int IsLoginActive(int department_id, int user_id, string user_name)
        {
            int _result = -1;

            Micajah.Common.Bll.Providers.LoginProvider _login = new Micajah.Common.Bll.Providers.LoginProvider();
            Guid _loginId = _login.GetLoginId(user_name);

            if (_loginId == Guid.Empty)
            {
                return(_result);
            }

            MC3DeptInfo _instInfo = GetInstanceInfoByDepartmentId(department_id);

            if (_login.LoginIsActiveInOrganization(_loginId, _instInfo.OrganizationId))
            {
                _result = 1;
            }
            else
            {
                _result = 0;
            }

            Database db = GetDatabase();

            string sqlCommand = "SELECT btUserInactive FROM tbl_LoginCompanyJunc WHERE company_id =" + department_id.ToString() + " AND id =" + user_id.ToString();

            DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand);

            IDataReader _reader = base.LoadFromSqlReader(dbCommand);

            if (_reader != null)
            {
                while (_reader.Read())
                {
                    bool _res = (bool)_reader[0];
                    if (!_res)
                    {
                        _result = 1;
                    }
                    else
                    {
                        _result = 0;
                    }

                    break;
                }
                ;

                _reader.Close();
            }
            ;

            return(_result);
        }
Пример #2
0
        public object Any(Ping ping)
        {
            if (string.IsNullOrWhiteSpace(ping.name))
            {
                return("All OK!");
            }
            string email = ping.name;

            Micajah.Common.Bll.Providers.LoginProvider lp = new Micajah.Common.Bll.Providers.LoginProvider();
            string paid     = "false";
            var    login_id = lp.GetLoginId(email);

            if (login_id != Guid.Empty)
            {
                var orgs = lp.GetOrganizationsByLoginId(login_id);
                paid = "lead";
                if (orgs.Count > 1)
                {
                    paid = "opportunity";
                }
                foreach (var o in orgs)
                {
                    if (lp.LoginIsOrganizationAdministrator(login_id, o.OrganizationId))
                    {
                        var insts = lp.GetLoginInstances(login_id, o.OrganizationId).FirstOrDefault(i => i.BillingPlan == BillingPlan.Paid && i.CreditCardStatus == CreditCardStatus.Registered);
                        if (insts != null)
                        {
                            paid = "customer";
                            break;
                        }
                        insts = lp.GetLoginInstances(login_id, o.OrganizationId).FirstOrDefault(i => i.BillingPlan == BillingPlan.Paid && i.CreditCardStatus == CreditCardStatus.Expired);
                        if (insts != null)
                        {
                            paid = "ex-customer";
                            break;
                        }
                        if (o.Expired || o.ExpirationTime.HasValue && (o.ExpirationTime.Value - DateTime.UtcNow).Days < 0)
                        {
                            paid = "expired";
                        }
                    }
                }
            }

            /*
             * var org = Micajah.Common.Bll.Providers.OrganizationProvider.GetOrganizationByPseudoId("ncg1in");
             * var inst = Micajah.Common.Bll.Providers.InstanceProvider.GetInstanceByPseudoId("8d1rag", org.OrganizationId);
             * string url = lp.GetLoginUrl("*****@*****.**", true, org.OrganizationId, inst.InstanceId, "");
             */
            return(paid);

            return("All OK!");
        }
Пример #3
0
        public object Any(Organizations request)
        {
            Micajah.Common.Bll.Providers.LoginProvider lp = new Micajah.Common.Bll.Providers.LoginProvider();
            ApiUser hdUser = new ApiUser(request.api_token);

            Micajah.Common.Bll.OrganizationCollection orgsMc = lp.GetOrganizationsByLoginId(hdUser.LoginId);
            List <Organization> orgs = new List <Organization>(orgsMc.Count);

            foreach (Micajah.Common.Bll.Organization orgMc in orgsMc)
            {
                try
                {
                    orgs.Add(new Organization(orgMc, lp.GetLoginInstances(hdUser.LoginId, orgMc.OrganizationId)));
                }
                catch
                { }
            }
            return(orgs);
        }
Пример #4
0
        public object Any(Login request)
        {
            var    basicAuth         = base.Request.GetBasicAuthUserAndPassword();
            string basicAuthEmail    = "";
            string basicAuthPassword = "";

            if (basicAuth != null)
            {
                basicAuthEmail    = basicAuth.Value.Key;
                basicAuthPassword = basicAuth.Value.Value;
            }
            string userName = request.username ?? basicAuthEmail;
            string userPass = request.password ?? basicAuthPassword;

            if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(userPass))
            {
                base.Response.AddHeader(HttpHeaders.WwwAuthenticate, "Basic realm=\"/login\"");
                throw new HttpError(HttpStatusCode.Forbidden, "Incorrect login/password.");
            }
            if (!ApiUser.ValidateStatic(userName, userPass))
            {
                throw new HttpError(HttpStatusCode.Forbidden, "Login or Password is not correct.");
            }
            Micajah.Common.Bll.Providers.LoginProvider lp = new Micajah.Common.Bll.Providers.LoginProvider();
            string api_token = lp.GetToken(userName);

            if (string.IsNullOrEmpty(api_token))
            {
                throw new HttpError(HttpStatusCode.Forbidden, "User is not correct or inactive.");
            }
            var hdUser = new ApiUser(api_token);

            return(new LoginResponse {
                api_token = api_token
            });
        }
Пример #5
0
        public virtual string UpdateLogin(
                        int code,
                        int DId,
                        int UId,
                        string user_email_old,
                        string user_password,
                        string user_firstname,
                        string user_lastname,
                        string user_title,
                        string user_email,
                        string Phone,
                        string MobilePhone,
                        int location_id,
                        string user_room,
                        int intUserType,
                        byte tintLevel,
                        string user_note,
                        bool btUpdateAcct,
                        int intAcctId,
                        int intAcctLocId,
                        int intSupGroupId,
                        bool btCallCentreRep,
                        string vchOrganization,
                        string LdapUserSID,
                        string LdapUserAccount
            )
        {
            string _result = string.Empty;
            MC3DeptInfo _instInfo = GetInstanceInfoByDepartmentId(DId);

            Micajah.Common.Bll.Providers.LoginProvider _login = new Micajah.Common.Bll.Providers.LoginProvider();
            Guid _loginId = _login.GetLoginId(user_email_old);

            System.Collections.ArrayList groupIdList = bigWebApps.bigWebDesk.Data.Logins.GetUserGroups(_instInfo.OrganizationId, _instInfo.InstanceId, intUserType, _loginId);

            Exception error = null;

            try
            {
                if (_loginId == Guid.Empty)
                    Micajah.Common.Bll.Providers.UserProvider.AddUserToOrganization(user_email_old, user_email, user_firstname, user_lastname, null, Phone, MobilePhone, null, user_title, null, null, null, null, null, null, null, Micajah.Common.Bll.Support.ConvertListToString(groupIdList), _instInfo.OrganizationId, user_password, false, false);
                else
                {
                    Micajah.Common.Bll.Providers.UserProvider.UpdateUser(_loginId, user_email, user_firstname, user_lastname, null, Phone, MobilePhone, null, user_title, null, null, null, null, null, null, null, null, null, null, groupIdList, _instInfo.OrganizationId, false);

                    if (!string.IsNullOrEmpty(user_password))
                    {
                        _login.ChangePassword(_loginId, user_password);
                    }
                }
            }
            catch (System.Net.Mail.SmtpException ex)
            {
                error = ex;
            }

            //  Create the Database object, using the default database service. The
            //  default database service is determined through configuration.
            Database db = GetDatabase();

            string sqlCommand = this.SchemaStoredProcedureWithSeparator + "sp_UpdateLogin";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

            // Add procedure parameters
            db.AddInParameter(dbCommand, "code", DbType.Int32, code);
            db.AddInParameter(dbCommand, "DId", DbType.Int32, DId);
            db.AddInParameter(dbCommand, "UId", DbType.Int32, UId);
            db.AddInParameter(dbCommand, "user_password", DbType.AnsiString, user_password);
            db.AddInParameter(dbCommand, "user_firstname", DbType.AnsiString, user_firstname);
            db.AddInParameter(dbCommand, "user_lastname", DbType.AnsiString, user_lastname);
            db.AddInParameter(dbCommand, "user_title", DbType.AnsiString, user_title);
            db.AddInParameter(dbCommand, "user_email", DbType.AnsiString, user_email);
            db.AddInParameter(dbCommand, "Phone", DbType.AnsiString, Phone);
            db.AddInParameter(dbCommand, "MobilePhone", DbType.AnsiString, MobilePhone);
            db.AddInParameter(dbCommand, "location_id", DbType.Int32, location_id);

            if (user_room.Length > 0)
                db.AddInParameter(dbCommand, "user_room", DbType.AnsiString, user_room);
            else
                db.AddInParameter(dbCommand, "user_room", DbType.AnsiString, DBNull);

            db.AddInParameter(dbCommand, "intUserType", DbType.Int32, intUserType);

            if (tintLevel > 0)
                db.AddInParameter(dbCommand, "tintLevel", DbType.Byte, tintLevel);
            else
                db.AddInParameter(dbCommand, "tintLevel", DbType.Byte, DBNull);

            db.AddInParameter(dbCommand, "user_note", DbType.AnsiString, user_note);
            db.AddInParameter(dbCommand, "btUpdateAcct", DbType.Boolean, btUpdateAcct);

            if (intAcctId > 0)
                db.AddInParameter(dbCommand, "intAcctId", DbType.Int32, intAcctId);
            else
                db.AddInParameter(dbCommand, "intAcctId", DbType.Int32, DBNull);

            if (intAcctLocId > 0)
                db.AddInParameter(dbCommand, "intAcctLocId", DbType.Int32, intAcctLocId);
            else
                db.AddInParameter(dbCommand, "intAcctLocId", DbType.Int32, DBNull);

            if (intSupGroupId > 0)
                db.AddInParameter(dbCommand, "intSupGroupId", DbType.Int32, intSupGroupId);
            else
                db.AddInParameter(dbCommand, "intSupGroupId", DbType.Int32, DBNull);

            db.AddInParameter(dbCommand, "btCallCentreRep", DbType.Boolean, btCallCentreRep);

            if (vchOrganization.Length > 0)
                db.AddInParameter(dbCommand, "vchOrganization", DbType.AnsiString, vchOrganization);
            else
                db.AddInParameter(dbCommand, "vchOrganization", DbType.AnsiString, DBNull);

            if (LdapUserSID.Length > 0)
                db.AddInParameter(dbCommand, "LdapUserSID", DbType.AnsiString, LdapUserSID);
            else
                db.AddInParameter(dbCommand, "LdapUserSID", DbType.AnsiString, DBNull);

            if (LdapUserAccount.Length > 0)
                db.AddInParameter(dbCommand, "LdapUserAccount", DbType.AnsiString, LdapUserAccount);
            else
                db.AddInParameter(dbCommand, "LdapUserAccount", DbType.AnsiString, DBNull);

            //NOT SUPPORTED BY EASY OBJECTS
            //db.AddOutParameter(dbCommand, "@RETURN_VALUE", DbType.Int32, DBNull);

            base.LoadFromSqlNoExec(dbCommand);

            /*
            int ErrorCode=0;

            string _error_code = db.GetParameterValue(dbCommand, "@RETURN_VALUE").ToString();
            if (_error_code.Length > 0)
                ErrorCode = Int32.Parse(_error_code);
            else
                ErrorCode = 0;

            if (ErrorCode == 1)
                _result = "Email adress: " + user_email +" already exist.";
            */

            if (error != null)
                throw error;

            return _result;
        }
Пример #6
0
        public virtual int IsLoginExist(string user_sid, string user_name, string user_password, bool is_exist, int user_external_id)
        {
            int _result = -1;

            Database db = GetDatabase();

            string sqlCommand = string.Empty;

            if (user_name.Length > 0)
            {
                Micajah.Common.Bll.Providers.LoginProvider _login = new Micajah.Common.Bll.Providers.LoginProvider();
                if (!_login.LoginNameExists(user_name)) return _result;

                if (!is_exist)
                    sqlCommand = "Select Id from tbl_Logins where Email = '" + user_name.Replace("'", "''") + "' AND Password = '******'", "''") + "'";
                else
                    sqlCommand = "Select Id from tbl_Logins where Email = '" + user_name.Replace("'", "''") + "'";

                if (user_external_id > 0)
                    sqlCommand += " AND Id = " + user_external_id.ToString();

                DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand);

                IDataReader _reader = base.LoadFromSqlReader(dbCommand);

                if (_reader != null)
                {
                    while (_reader.Read())
                    {
                        _result = (int)_reader[0];
                        break;
                    };

                    _reader.Close();
                }
            }

            if ((is_exist) && (_result == -1))
            {
                if (user_sid.Length > 0)
                {
                    sqlCommand = "Select Id from tbl_Logins where LdapUserSID = '" + user_sid + "'";
                    DbCommand _ldap_command = db.GetSqlStringCommand(sqlCommand);

                    IDataReader _ldap_reader = base.LoadFromSqlReader(_ldap_command);

                    if (_ldap_reader != null)
                    {
                        while (_ldap_reader.Read())
                        {
                            _result = (int)_ldap_reader[0];
                            break;
                        };

                        _ldap_reader.Close();
                    };

                };
            };

            return _result;
        }
Пример #7
0
        public virtual int IsLoginActive(int department_id, int user_id, string user_name)
        {
            int _result = -1;

            Micajah.Common.Bll.Providers.LoginProvider _login = new Micajah.Common.Bll.Providers.LoginProvider();
            Guid _loginId = _login.GetLoginId(user_name);
            if (_loginId == Guid.Empty) return _result;

            MC3DeptInfo _instInfo = GetInstanceInfoByDepartmentId(department_id);

            if (_login.LoginIsActiveInOrganization(_loginId, _instInfo.OrganizationId))
                _result = 1;
            else
                _result = 0;

            Database db = GetDatabase();

            string sqlCommand = "SELECT btUserInactive FROM tbl_LoginCompanyJunc WHERE company_id =" + department_id.ToString() + " AND id =" + user_id.ToString();

            DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand);

            IDataReader _reader = base.LoadFromSqlReader(dbCommand);

            if (_reader != null)
            {
                while (_reader.Read())
                {
                    bool _res = (bool)_reader[0];
                    if (!_res)
                        _result = 1;
                    else
                        _result = 0;

                    break;
                };

                _reader.Close();
            };

            return _result;
        }
Пример #8
0
        public virtual bool InactivateLogin(
                int UId,
                int DId,
                bool btAllTkt,
                string user_name
        )
        {
            bool _result = true;

            MC3DeptInfo _instInfo = GetInstanceInfoByDepartmentId(DId);
            if (_instInfo.OrganizationId == Guid.Empty) return false;

            Micajah.Common.Bll.Providers.LoginProvider _login = new Micajah.Common.Bll.Providers.LoginProvider();
            Guid _userId = _login.GetLoginId(user_name);
            if (_userId == Guid.Empty) return false;

            Micajah.Common.Bll.Organization _org = Micajah.Common.Bll.Providers.OrganizationProvider.GetOrganization(_instInfo.OrganizationId);
            if (_org == null) return false;
            Micajah.Common.Bll.Providers.UserProvider.UpdateUserActive(_userId, _org.OrganizationId, false);

            //  Create the Database object, using the default database service. The
            //  default database service is determined through configuration.
            Database db = GetDatabase();

            string sqlCommand = this.SchemaStoredProcedureWithSeparator + "sp_InactivateLogin";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

            // Add procedure parameters
            db.AddInParameter(dbCommand, "UId", DbType.Int32, UId);
            db.AddInParameter(dbCommand, "DId", DbType.Int32, DId);
            db.AddInParameter(dbCommand, "btAllTkt", DbType.Boolean, btAllTkt);

            base.LoadFromSqlNoExec(dbCommand);

            /*
            int ErrorCode = 0;

            string _error_code = db.GetParameterValue(dbCommand, "@RETURN_VALUE").ToString();
            if (_error_code.Length > 0)
                ErrorCode = Int32.Parse(_error_code);
            else
                ErrorCode = 0;

            if (ErrorCode == 1)
                _result = true;
            */

            return _result;
        }
Пример #9
0
        public static int UpdateLogin(
                        Guid OrgId,
                        Guid InstId,
                        int code,
                        int DId,
                        ref int UId,
                        string user_password,
                        string user_firstname,
                        string user_lastname,
                        string user_title,
                        string user_email,
                        string Phone,
                        string MobilePhone,
                        int location_id,
                        string user_room,
                        int intUserType,
                        byte tintLevel,
                        string user_note,
                        bool btUpdateAcct,
                        int intAcctId,
                        int intAcctLocId,
                        int intSupGroupId,
                        bool btCallCentreRep,
                        string vchOrganization,
                        string LdapUserSID,
                        string LdapUserAccount,
                        string MobileEmail,
                        int MobileEmailType,
                        bool IsOrgAdmin
            )
        {
            string _old_email = user_email;

            if (UId != 0)
            {
                DataRow _row = SelectUserDetails(DId, UId);
                _old_email = _row["Email"].ToString();
            }

            Micajah.Common.Bll.Providers.LoginProvider _login = new Micajah.Common.Bll.Providers.LoginProvider();
            Guid LoginId = _login.GetLoginId(_old_email);

            System.Collections.ArrayList userGroupIdList = GetUserGroups(OrgId, InstId, intUserType, LoginId);

            if (IsOrgAdmin && !userGroupIdList.Contains(Guid.Empty)) userGroupIdList.Add(Guid.Empty);
            else if (!IsOrgAdmin && userGroupIdList.Contains(Guid.Empty)) userGroupIdList.Remove(Guid.Empty);

            Exception error = null;

            if (LoginId == Guid.Empty)
            {
                try
                {
                    Micajah.Common.Bll.Providers.UserProvider.AddUserToOrganization(_old_email, user_email, user_firstname, user_lastname, null, Phone, MobilePhone, null, user_title, null, null, null, null, null, null, null, Micajah.Common.Bll.Support.ConvertListToString(userGroupIdList), OrgId, user_password, false, true);
                }
                catch (ArgumentException)
                {
                    return 1;
                }
                catch (System.Net.Mail.SmtpException ex)
                {
                    error = ex;
                }
            }
            else
            {
                try
                {
                    Micajah.Common.Bll.Providers.UserProvider.UpdateUser(LoginId, user_email, user_firstname, user_lastname, null, Phone, MobilePhone, null, user_title, null, null, null, null, null, null, null, null, null, null, userGroupIdList, OrgId, true);
                }
                catch (ArgumentException)
                {
                    return 1;
                }
                catch (System.Net.Mail.SmtpException ex)
                {
                    error = ex;
                }

                if (!string.IsNullOrEmpty(user_password))
                    _login.ChangePassword(LoginId, user_password, false);
            }

            SqlParameter pReturnValue = new SqlParameter("@RETURN_VALUE", SqlDbType.Int);
            pReturnValue.Direction = ParameterDirection.ReturnValue;

            SqlParameter pUId = new SqlParameter("@UId", SqlDbType.Int);
            pUId.Direction = ParameterDirection.InputOutput;
            pUId.Value = UId;

            SqlParameter pUserPassword = new SqlParameter("@user_password", SqlDbType.NVarChar, 50);
            if (user_password.Length > 0) pUserPassword.Value = user_password;
            else pUserPassword.Value = DBNull.Value;

            SqlParameter pUserRoom = new SqlParameter("@user_room", DBNull.Value);
            if (user_room.Length > 0)
                pUserRoom.Value = user_room;

            SqlParameter pLevel = new SqlParameter("@tintLevel", DBNull.Value);
            if (tintLevel > 0)
                pLevel.Value = tintLevel;

            SqlParameter pAccountId = new SqlParameter("@intAcctId", DBNull.Value);
            if (intAcctId > 0)
                pAccountId.Value = intAcctId;

            SqlParameter pAccountLocId = new SqlParameter("@intAcctLocId", DBNull.Value);
            if (intAcctLocId > 0)
                pAccountLocId.Value = intAcctLocId;

            SqlParameter pSupGroupId = new SqlParameter("@intSupGroupId", DBNull.Value);
            if (intSupGroupId > 0)
                pSupGroupId.Value = intSupGroupId;

            SqlParameter pOrganization = new SqlParameter("@vchOrganization", DBNull.Value);
            if (vchOrganization.Length > 0)
                pOrganization.Value = vchOrganization;

            SqlParameter pLdapUserSID = new SqlParameter("@LdapUserSID", DBNull.Value);
            if (LdapUserSID.Length > 0)
                pLdapUserSID.Value = LdapUserSID;

            SqlParameter pLdapUserAccount = new SqlParameter("@LdapUserAccount", DBNull.Value);
            if (LdapUserAccount.Length > 0)
                pLdapUserAccount.Value = LdapUserAccount;
            SqlParameter pMobileEmail = new SqlParameter("@MobileEmail", SqlDbType.NVarChar, 50);
            if (MobileEmail.Length > 0) pMobileEmail.Value = MobileEmail;
            SqlParameter pMobileEmailType = new SqlParameter("MobileEmailType", SqlDbType.TinyInt);
            pMobileEmailType.Value = MobileEmailType;
            UpdateData("sp_UpdateLogin",
                new SqlParameter[] {
                    pReturnValue,
                    new SqlParameter("@DId", DId),
                    pUId,
                    new SqlParameter("@code", code),
                    pUserPassword,
                    new SqlParameter("@user_firstname", user_firstname),
                    new SqlParameter("@user_lastname", user_lastname),
                    new SqlParameter("@user_title", user_title),
                    new SqlParameter("@user_email", user_email),
                    new SqlParameter("@Phone", Phone),
                    new SqlParameter("@MobilePhone", MobilePhone),
                    new SqlParameter("@location_id", location_id),
                    new SqlParameter("@user_note", user_note),
                    new SqlParameter("@btUpdateAcct", btUpdateAcct),
                    new SqlParameter("@intUserType", intUserType),
                    new SqlParameter("@btCallCentreRep", btCallCentreRep),
                    pUserRoom,
                    pLevel,
                    pAccountId,
                    pAccountLocId,
                    pSupGroupId,
                    pOrganization,
                    pLdapUserSID,
                    pLdapUserAccount,
                    pMobileEmail,
                    pMobileEmailType}, OrgId);

            UId = (int)pUId.Value;

            if (error != null)
                throw error;

            return (int)pReturnValue.Value;
        }
Пример #10
0
 public static System.Collections.ArrayList GetUserGroups(Guid orgId, Guid instId, int userTypeId, string loginName)
 {
     Micajah.Common.Bll.Providers.LoginProvider login = new Micajah.Common.Bll.Providers.LoginProvider();
     return GetUserGroups(orgId, instId, userTypeId, login.GetLoginId(loginName));
 }
Пример #11
0
        public static int UpdateProfile(Guid OrgId, Guid InstId, int DeptID, int UserID, string firstName, string lastName,
                                        string email, string title, string password, string phone,
                                        string mobilePhone, int creationCatId, string mobileEmail, int mobileEmailType, string timeZoneId, int? timeFormatId, int? dateFormat)
        {
            DataRow _row = SelectUserDetails(OrgId, DeptID, UserID);
            string _old_email = _row["Email"].ToString();
            int _userType = (int)_row["UserType_Id"];

            Micajah.Common.Bll.Providers.LoginProvider _login = new Micajah.Common.Bll.Providers.LoginProvider();
            Guid _loginId = _login.GetLoginId(_old_email);

            System.Collections.ArrayList userGroupIdList = GetUserGroups(OrgId, InstId, _userType, _loginId);

            Exception error = null;

            try
            {
                Micajah.Common.Bll.Providers.UserProvider.UpdateUser(_loginId, email, firstName, lastName, null, phone, mobilePhone, null, title, null, null, null, null, null, null, null, timeZoneId, timeFormatId, dateFormat, userGroupIdList, OrgId, true);
            }
            catch (ArgumentException)
            {
                return 1;
            }
            catch (System.Net.Mail.SmtpException ex)
            {
                error = ex;
            }

            if (!string.IsNullOrEmpty(password))
                _login.ChangePassword(_loginId, password, false, false);

            SqlParameter pReturnValue = new SqlParameter("@RETURN_VALUE", SqlDbType.Int);
            pReturnValue.Direction = ParameterDirection.ReturnValue;

            SqlParameter pPassword = new SqlParameter("@password", DBNull.Value);

            SqlParameter pMobileEmail = new SqlParameter("@MobileEmail", SqlDbType.NVarChar, 50);
            if (mobileEmail.Length > 0) pMobileEmail.Value = mobileEmail;
            else pMobileEmail.Value = DBNull.Value;
            SqlParameter pMobileEmailType = new SqlParameter("@MobileEmailType", SqlDbType.TinyInt);
            pMobileEmailType.Value = mobileEmailType;

            if (password != null && password != string.Empty)
                pPassword.Value = password;

            UpdateData("sp_UpdateUserProfile",
                new SqlParameter[] {
                    new SqlParameter("@DId", DeptID),
                    new SqlParameter("@UId", UserID),
                    new SqlParameter("@firstname", firstName),
                    new SqlParameter("@lastname", lastName),
                    new SqlParameter("@email", email),
                    new SqlParameter("@Title", title),
                    pPassword,
                    new SqlParameter("@phone", phone),
                    new SqlParameter("@MobilePhone", mobilePhone),
                    new SqlParameter("@creationCatId", creationCatId),
                    pMobileEmail,
                    pMobileEmailType,
                    pReturnValue
                }, OrgId
            );

            if (error != null)
                throw error;

            return (int)pReturnValue.Value;
        }
Пример #12
0
        public virtual bool InactivateLogin
        (
            int UId,
            int DId,
            bool btAllTkt,
            string user_name
        )
        {
            bool _result = true;

            MC3DeptInfo _instInfo = GetInstanceInfoByDepartmentId(DId);

            if (_instInfo.OrganizationId == Guid.Empty)
            {
                return(false);
            }

            Micajah.Common.Bll.Providers.LoginProvider _login = new Micajah.Common.Bll.Providers.LoginProvider();
            Guid _userId = _login.GetLoginId(user_name);

            if (_userId == Guid.Empty)
            {
                return(false);
            }

            Micajah.Common.Bll.Organization _org = Micajah.Common.Bll.Providers.OrganizationProvider.GetOrganization(_instInfo.OrganizationId);
            if (_org == null)
            {
                return(false);
            }
            Micajah.Common.Bll.Providers.UserProvider.UpdateUserActive(_userId, _org.OrganizationId, false);

            //  Create the Database object, using the default database service. The
            //  default database service is determined through configuration.
            Database db = GetDatabase();

            string    sqlCommand = this.SchemaStoredProcedureWithSeparator + "sp_InactivateLogin";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            // Add procedure parameters
            db.AddInParameter(dbCommand, "UId", DbType.Int32, UId);
            db.AddInParameter(dbCommand, "DId", DbType.Int32, DId);
            db.AddInParameter(dbCommand, "btAllTkt", DbType.Boolean, btAllTkt);

            base.LoadFromSqlNoExec(dbCommand);

            /*
             * int ErrorCode = 0;
             *
             * string _error_code = db.GetParameterValue(dbCommand, "@RETURN_VALUE").ToString();
             * if (_error_code.Length > 0)
             *  ErrorCode = Int32.Parse(_error_code);
             * else
             *  ErrorCode = 0;
             *
             * if (ErrorCode == 1)
             *  _result = true;
             */

            return(_result);
        }
Пример #13
0
        public virtual int IsLoginExist(string user_sid, string user_name, string user_password, bool is_exist, int user_external_id)
        {
            int _result = -1;

            Database db = GetDatabase();

            string sqlCommand = string.Empty;

            if (user_name.Length > 0)
            {
                Micajah.Common.Bll.Providers.LoginProvider _login = new Micajah.Common.Bll.Providers.LoginProvider();
                if (!_login.LoginNameExists(user_name))
                {
                    return(_result);
                }

                if (!is_exist)
                {
                    sqlCommand = "Select Id from tbl_Logins where Email = '" + user_name.Replace("'", "''") + "' AND Password = '******'", "''") + "'";
                }
                else
                {
                    sqlCommand = "Select Id from tbl_Logins where Email = '" + user_name.Replace("'", "''") + "'";
                }

                if (user_external_id > 0)
                {
                    sqlCommand += " AND Id = " + user_external_id.ToString();
                }

                DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand);

                IDataReader _reader = base.LoadFromSqlReader(dbCommand);

                if (_reader != null)
                {
                    while (_reader.Read())
                    {
                        _result = (int)_reader[0];
                        break;
                    }
                    ;

                    _reader.Close();
                }
            }

            if ((is_exist) && (_result == -1))
            {
                if (user_sid.Length > 0)
                {
                    sqlCommand = "Select Id from tbl_Logins where LdapUserSID = '" + user_sid + "'";
                    DbCommand _ldap_command = db.GetSqlStringCommand(sqlCommand);

                    IDataReader _ldap_reader = base.LoadFromSqlReader(_ldap_command);

                    if (_ldap_reader != null)
                    {
                        while (_ldap_reader.Read())
                        {
                            _result = (int)_ldap_reader[0];
                            break;
                        }
                        ;

                        _ldap_reader.Close();
                    }
                    ;
                }
                ;
            }
            ;

            return(_result);
        }
Пример #14
0
        public virtual string UpdateLogin(
            int code,
            int DId,
            int UId,
            string user_email_old,
            string user_password,
            string user_firstname,
            string user_lastname,
            string user_title,
            string user_email,
            string Phone,
            string MobilePhone,
            int location_id,
            string user_room,
            int intUserType,
            byte tintLevel,
            string user_note,
            bool btUpdateAcct,
            int intAcctId,
            int intAcctLocId,
            int intSupGroupId,
            bool btCallCentreRep,
            string vchOrganization,
            string LdapUserSID,
            string LdapUserAccount
            )
        {
            string      _result   = string.Empty;
            MC3DeptInfo _instInfo = GetInstanceInfoByDepartmentId(DId);

            Micajah.Common.Bll.Providers.LoginProvider _login = new Micajah.Common.Bll.Providers.LoginProvider();
            Guid _loginId = _login.GetLoginId(user_email_old);

            System.Collections.ArrayList groupIdList = bigWebApps.bigWebDesk.Data.Logins.GetUserGroups(_instInfo.OrganizationId, _instInfo.InstanceId, intUserType, _loginId);

            Exception error = null;

            try
            {
                if (_loginId == Guid.Empty)
                {
                    Micajah.Common.Bll.Providers.UserProvider.AddUserToOrganization(user_email_old, user_email, user_firstname, user_lastname, null, Phone, MobilePhone, null, user_title, null, null, null, null, null, null, null, Micajah.Common.Bll.Support.ConvertListToString(groupIdList), _instInfo.OrganizationId, user_password, false, false);
                }
                else
                {
                    Micajah.Common.Bll.Providers.UserProvider.UpdateUser(_loginId, user_email, user_firstname, user_lastname, null, Phone, MobilePhone, null, user_title, null, null, null, null, null, null, null, null, null, null, groupIdList, _instInfo.OrganizationId, false);

                    if (!string.IsNullOrEmpty(user_password))
                    {
                        _login.ChangePassword(_loginId, user_password);
                    }
                }
            }
            catch (System.Net.Mail.SmtpException ex)
            {
                error = ex;
            }

            //  Create the Database object, using the default database service. The
            //  default database service is determined through configuration.
            Database db = GetDatabase();

            string    sqlCommand = this.SchemaStoredProcedureWithSeparator + "sp_UpdateLogin";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            // Add procedure parameters
            db.AddInParameter(dbCommand, "code", DbType.Int32, code);
            db.AddInParameter(dbCommand, "DId", DbType.Int32, DId);
            db.AddInParameter(dbCommand, "UId", DbType.Int32, UId);
            db.AddInParameter(dbCommand, "user_password", DbType.AnsiString, user_password);
            db.AddInParameter(dbCommand, "user_firstname", DbType.AnsiString, user_firstname);
            db.AddInParameter(dbCommand, "user_lastname", DbType.AnsiString, user_lastname);
            db.AddInParameter(dbCommand, "user_title", DbType.AnsiString, user_title);
            db.AddInParameter(dbCommand, "user_email", DbType.AnsiString, user_email);
            db.AddInParameter(dbCommand, "Phone", DbType.AnsiString, Phone);
            db.AddInParameter(dbCommand, "MobilePhone", DbType.AnsiString, MobilePhone);
            db.AddInParameter(dbCommand, "location_id", DbType.Int32, location_id);

            if (user_room.Length > 0)
            {
                db.AddInParameter(dbCommand, "user_room", DbType.AnsiString, user_room);
            }
            else
            {
                db.AddInParameter(dbCommand, "user_room", DbType.AnsiString, DBNull);
            }

            db.AddInParameter(dbCommand, "intUserType", DbType.Int32, intUserType);

            if (tintLevel > 0)
            {
                db.AddInParameter(dbCommand, "tintLevel", DbType.Byte, tintLevel);
            }
            else
            {
                db.AddInParameter(dbCommand, "tintLevel", DbType.Byte, DBNull);
            }

            db.AddInParameter(dbCommand, "user_note", DbType.AnsiString, user_note);
            db.AddInParameter(dbCommand, "btUpdateAcct", DbType.Boolean, btUpdateAcct);

            if (intAcctId > 0)
            {
                db.AddInParameter(dbCommand, "intAcctId", DbType.Int32, intAcctId);
            }
            else
            {
                db.AddInParameter(dbCommand, "intAcctId", DbType.Int32, DBNull);
            }

            if (intAcctLocId > 0)
            {
                db.AddInParameter(dbCommand, "intAcctLocId", DbType.Int32, intAcctLocId);
            }
            else
            {
                db.AddInParameter(dbCommand, "intAcctLocId", DbType.Int32, DBNull);
            }

            if (intSupGroupId > 0)
            {
                db.AddInParameter(dbCommand, "intSupGroupId", DbType.Int32, intSupGroupId);
            }
            else
            {
                db.AddInParameter(dbCommand, "intSupGroupId", DbType.Int32, DBNull);
            }

            db.AddInParameter(dbCommand, "btCallCentreRep", DbType.Boolean, btCallCentreRep);

            if (vchOrganization.Length > 0)
            {
                db.AddInParameter(dbCommand, "vchOrganization", DbType.AnsiString, vchOrganization);
            }
            else
            {
                db.AddInParameter(dbCommand, "vchOrganization", DbType.AnsiString, DBNull);
            }

            if (LdapUserSID.Length > 0)
            {
                db.AddInParameter(dbCommand, "LdapUserSID", DbType.AnsiString, LdapUserSID);
            }
            else
            {
                db.AddInParameter(dbCommand, "LdapUserSID", DbType.AnsiString, DBNull);
            }

            if (LdapUserAccount.Length > 0)
            {
                db.AddInParameter(dbCommand, "LdapUserAccount", DbType.AnsiString, LdapUserAccount);
            }
            else
            {
                db.AddInParameter(dbCommand, "LdapUserAccount", DbType.AnsiString, DBNull);
            }

            //NOT SUPPORTED BY EASY OBJECTS
            //db.AddOutParameter(dbCommand, "@RETURN_VALUE", DbType.Int32, DBNull);

            base.LoadFromSqlNoExec(dbCommand);


            /*
             * int ErrorCode=0;
             *
             * string _error_code = db.GetParameterValue(dbCommand, "@RETURN_VALUE").ToString();
             * if (_error_code.Length > 0)
             *  ErrorCode = Int32.Parse(_error_code);
             * else
             *  ErrorCode = 0;
             *
             * if (ErrorCode == 1)
             *  _result = "Email adress: " + user_email +" already exist.";
             */

            if (error != null)
            {
                throw error;
            }

            return(_result);
        }