示例#1
0
 public user getDataUserData(string username)
 {
     try
     {
         _userDataService = IoC.Resolve <IuserService>();
         string key      = "USERDATA_" + username;
         user   userdata = GetRedis <user>(key);
         if (userdata != null)
         {
             return(userdata);
         }
         else
         {
             userdata = _userDataService.GetByName(username);
             if (userdata != null)
             {
                 PushRedis <user>("USERDATA" + username, userdata);
             }
             return(userdata);
         }
     }
     catch (Exception ex)
     {
         log.Error(ex.Message);
         var userdata = _userDataService.GetByName(username);
         return(userdata);
     }
 }
示例#2
0
 public AccountController()
 {
     NguoidungService      = IoC.Resolve <INGUOIDUNGService>();
     _iLogSystemService    = IoC.Resolve <ILogSystemService>();
     UserDataService       = IoC.Resolve <IuserService>();
     authenticationService = IoC.Resolve <FanxiAuthenticationBase>();
 }
示例#3
0
        public ActionResult ServiceRoleIndex(string username, int?page)
        {
            IRBACRoleProvider _RoleProvider    = IoC.Resolve <IRBACRoleProvider>();
            IuserService      _userService     = IoC.Resolve <IuserService>();
            int               defautPageSize   = 10;
            int               currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            Company           currentCom       = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            IQueryable <user> query            = _userService.Query.Where(p => p.GroupName.Equals(currentCom.id.ToString()));
            IList <user>      lst;
            int               total = 0;
            List <String>     temp  = new List <String>(_RoleProvider.GetUsersInRole("ServiceRole"));

            if (!string.IsNullOrWhiteSpace(username))
            {
                query = query.Where(u => u.username.ToUpper().Contains(username.ToUpper().Trim()) && temp.Contains(u.username)).OrderByDescending(i => i.userid);
                total = query.Count();
                lst   = query.Skip(currentPageIndex * defautPageSize).Take(defautPageSize).ToList();
            }
            else
            {
                query = query.Where(u => temp.Contains(u.username)).OrderByDescending(i => i.userid);
                total = query.Count();
                lst   = query.Skip(currentPageIndex * defautPageSize).Take(defautPageSize).ToList();
            }
            IPagedList <user> model = new PagedList <user>(lst, currentPageIndex, defautPageSize, total);

            ViewData["username"] = username;
            return(View(model));
        }
示例#4
0
 private void KhoiTao()
 {
     _iNguoidungService = IoC.Resolve <INGUOIDUNGService>();
     _userDataService   = IoC.Resolve <IuserService>();
     _iDonviService     = IoC.Resolve <IDM_DONVIService>();
     _iDmcosokcbServcie = IoC.Resolve <IDMCOSOKCBService>();
     _iRoleService      = IoC.Resolve <IroleService>();
 }
示例#5
0
 public RBACServiceProvider(string mApplicationName, string mSessionFactoryConfigPath)
 {
     App           = new ApplicationsService(mSessionFactoryConfigPath).GetByName(mApplicationName);
     UserSrv       = new userService(mSessionFactoryConfigPath);
     RoleSrv       = new roleService(mSessionFactoryConfigPath);
     OperationSrv  = new operationService(mSessionFactoryConfigPath);
     ObjectSrv     = new objectService(mSessionFactoryConfigPath);
     PermissionSrv = new permissionService(mSessionFactoryConfigPath);
 }
示例#6
0
        public JsonResult SearchByAccountName(string searchText)
        {
            Company      _currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            IuserService _SvcUser    = IoC.Resolve <IuserService>();
            IList <user> lst         = _SvcUser.GetbyHQuery("select u from user u where u.GroupName = :comid AND u.username like :searchText AND u.username Not IN (select AccountName from Customer)", new SQLParam("comid", _currentCom.id), new SQLParam("searchText", "%" + searchText + "%"));
            var          qr          = from u in lst select(new { u.username });

            return(Json(qr, JsonRequestBehavior.AllowGet));
        }
 public RBACServiceProvider(string mApplicationName, string mSessionFactoryConfigPath)
 {
     App = new ApplicationsService(mSessionFactoryConfigPath).GetByName(mApplicationName);
     UserSrv = new userService(mSessionFactoryConfigPath);
     RoleSrv = new roleService(mSessionFactoryConfigPath);
     OperationSrv = new operationService(mSessionFactoryConfigPath);
     ObjectSrv = new objectService(mSessionFactoryConfigPath);
     PermissionSrv = new permissionService(mSessionFactoryConfigPath);
 }
 public RBACMembershipProvider(string mApplicationName, string mSessionFactoryConfigPath)
 {
     _SessionFactoryConfigPath = mSessionFactoryConfigPath;
     ApplicationName = mApplicationName;
     UserSrv = new userService(mSessionFactoryConfigPath);
     RoleSrv = new roleService(mSessionFactoryConfigPath);
     OperationSrv = new operationService(mSessionFactoryConfigPath);
     ObjectSrv = new objectService(mSessionFactoryConfigPath);
     PermissionSrv = new permissionService(mSessionFactoryConfigPath);
 }
 public RBACMembershipProvider(string mApplicationName, string mSessionFactoryConfigPath)
 {
     _SessionFactoryConfigPath = mSessionFactoryConfigPath;
     ApplicationName           = mApplicationName;
     UserSrv       = new userService(mSessionFactoryConfigPath);
     RoleSrv       = new roleService(mSessionFactoryConfigPath);
     OperationSrv  = new operationService(mSessionFactoryConfigPath);
     ObjectSrv     = new objectService(mSessionFactoryConfigPath);
     PermissionSrv = new permissionService(mSessionFactoryConfigPath);
 }
示例#10
0
        public ActionResult NewServiceRole()
        {
            IRBACRoleProvider _RoleProvider = IoC.Resolve <IRBACRoleProvider>();
            IuserService      _userService  = IoC.Resolve <IuserService>();
            user    _model     = new user();
            Company currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany;

            _model.GroupName           = currentCom.id.ToString();
            ViewData["RetypePassword"] = _model.password;
            return(View(_model));
        }
示例#11
0
 private user GetUserPPid(int pid, IuserService userService)
 {
     if (pid != 0)
     {
         var item = userService.LoadEntities(n => n.id == pid).FirstOrDefault();
         if (item != null && item.pid != 0)
         {
             return(userService.LoadEntities(n => n.id == item.pid).FirstOrDefault());
         }
         return(null);
     }
     return(null);
 }
示例#12
0
 public QuanLyNguoiDungController()
 {
     CurrentNguoidung    = ((EISContext)FXContext.Current).CurrentNguoidung;
     UserDataService     = IoC.Resolve <IuserService>();
     RoleService         = IoC.Resolve <IroleService>();
     DmcosokcbService    = IoC.Resolve <IDMCOSOKCBService>();
     Nguoidung           = IoC.Resolve <INGUOIDUNGService>();
     DmDonviService      = IoC.Resolve <IDM_DONVIService>();
     ApplicationsService = IoC.Resolve <IApplicationsService>();
     _iLogSystemService  = IoC.Resolve <ILogSystemService>();
     TypeRoleService     = IoC.Resolve <ITYPE_ROLEService>();
     GetValueCommon();
 }
示例#13
0
        public ActionResult New()
        {
            IRBACRoleProvider _RoleProvider = IoC.Resolve <IRBACRoleProvider>();
            IuserService      _userService  = IoC.Resolve <IuserService>();
            user _model = new user();

            _model.IsApproved = true;
            AccountModels model = new AccountModels();
            List <String> lst   = new List <string>(_RoleProvider.GetAllRoles());

            model.RetypePassword = _model.password = "";
            model.AllRoles       = lst.ToArray();
            model.UserRoles      = new string[] { };
            model.tmpUser        = _model;
            return(View(model));
        }
 public ThongTinTaiKhoanController()
 {
     try
     {
         UserDataService  = IoC.Resolve <IuserService>();
         nguoidung        = ((EIS.Core.EISContext)FX.Context.FXContext.Current).CurrentNguoidung;
         usercurent       = UserDataService.GetByName(nguoidung.TENDANGNHAP);
         userModel        = GetUserModel();
         ViewBag.Username = nguoidung.TENDANGNHAP;
         ViewBag.Ten      = nguoidung.TEN;
     }
     catch (Exception e)
     {
         log.Error(e.StackTrace + e.Message);
         ViewData["EditError"] = e.Message;
     }
 }
示例#15
0
        public ActionResult Index(IndexAccountModel model, int?page)
        {
            IuserService      _userService     = IoC.Resolve <IuserService>();
            int               defautPageSize   = 10;
            int               currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            IQueryable <user> query            = _userService.Query.Where(u => u.GroupName == null || u.GroupName == "0");
            IList <user>      lst;
            int               total = 0;

            if (!string.IsNullOrWhiteSpace(model.username))
            {
                query = query.Where(u => u.username.Contains(model.username.Trim()));
            }
            total = query.Count();
            query = query.OrderByDescending(i => i.userid);
            lst   = query.Skip(currentPageIndex * defautPageSize).Take(defautPageSize).ToList();
            model.PageListUser = new PagedList <user>(lst, currentPageIndex, defautPageSize, total);
            return(View(model));
        }
示例#16
0
        public ActionResult Reset(string username)
        {
            ResetModel mm = new ResetModel();

            try
            {
                IuserService _userService    = IoC.Resolve <IuserService>();
                Company      _currentCompany = ((EInvoiceContext)FXContext.Current).CurrentCompany;
                user         model           = _userService.Query.Where(u => u.GroupName.Equals(_currentCompany.id.ToString()) && u.username == username).FirstOrDefault();
                if (model != null)
                {
                    string randompass = IdentityManagement.WebProviders.RBACMembershipProvider.CreateRandomPassword(8);
                    IService.IRegisterEmailService emailSrv      = FX.Core.IoC.Resolve <IService.IRegisterEmailService>();
                    Dictionary <string, string>    subjectParams = new Dictionary <string, string>(1);
                    subjectParams.Add("$subject", "");
                    Dictionary <string, string> bodyParams = new Dictionary <string, string>(3);
                    bodyParams.Add("$password", randompass);
                    bodyParams.Add("$site", FX.Utils.UrlUtil.GetSiteUrl());
                    emailSrv.ProcessEmail("*****@*****.**", model.email, "ResetPassword", subjectParams, bodyParams);
                    model.password = GeneratorPassword.EncodePassword(randompass, model.PasswordFormat, model.PasswordSalt);//FormsAuthentication.HashPasswordForStoringInConfigFile(randompass, "MD5");
                    model.LastPasswordChangedDate = DateTime.Now;
                    _userService.Save(model);
                    _userService.CommitChanges();
                    mm.lblErrorMessage = "Kiểm tra email để lấy mật khẩu của bạn.";
                    return(View("ResetPassword", mm));
                }
                mm.lblErrorMessage = "Tài khoản không tồn tại trên hệ thống";
                return(View("ResetPassword", mm));
            }
            catch (Exception ex)
            {
                log.Error(ex);
                ResetModel model = new ResetModel();
                model.lblErrorMessage = "Tài khoản không tồn tại trên hệ thống";
                return(View("ResetPassword", mm));
            }
        }
示例#17
0
        public string DoCheckPermission(string username, string pmsname)
        {
            IuserService UserDataService = IoC.Resolve <IuserService>();
            string       results         = "NotOK";
            var          _lstRoles       = UserDataService.Query.Where(m => m.username == username).FirstOrDefault().Roles;

            if (_lstRoles.Any())
            {
                foreach (var item in _lstRoles)
                {
                    var _lstpms = item.Permissions.Select(m => m.name).ToList();
                    if (_lstpms.Any())
                    {
                        bool _checkLstPms = _lstpms.Contains(pmsname);
                        if (_checkLstPms)
                        {
                            results = "OK";
                            return(results);
                        }
                    }
                }
            }
            return(results);
        }
        private bool IsAuthenticated(HttpActionContext actionContext)
        {
            var headers = actionContext.Request.Headers;

            var authenticationString = GetHttpRequestHeader(headers, AuthenticationHeaderName);

            if (string.IsNullOrEmpty(authenticationString))
            {
                return(false);
            }

            var authenticationParts = authenticationString.Split(new[] { ":" }, StringSplitOptions.RemoveEmptyEntries);

            if (authenticationParts == null || authenticationParts.Count() == 0)
            {
                return(false);
            }
            var    nonce = authenticationParts[1];
            var    epoch = authenticationParts[2];
            string data  = String.Format("{0}{1}{2}", actionContext.Request.Method.ToString().ToUpper(), epoch, nonce);

            var signature = authenticationParts[0];

            if (!SecurityManager.IsTokenValid(data, signature, nonce, epoch))
            {
                return(false);
            }

            var agentString = GetHttpRequestHeader(headers, AgentHeaderName);

            if (agentString != null && agentString.Equals(AgentHeaderValue))
            {
                if (authenticationParts.Length < 4)
                {
                    return(false);
                }
                var accname = authenticationParts[3];
                EInvoice.Core.Domain.Company _currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany;
                if (_currentCom == null)
                {
                    return(false);
                }
                string       GroupName = _currentCom.id.ToString();
                IuserService userSrv   = IoC.Resolve <IuserService>();
                user         tempUser  = userSrv.Query.Where(u => u.username == accname && u.IsApproved && !u.IsLockedOut && u.GroupName.Equals(GroupName)).FirstOrDefault();
                if (tempUser == null)
                {
                    return(false);
                }
                IList <FanxiPermission> fxPer      = new List <FanxiPermission>();
                UserIdentity            tempId     = new UserIdentity(accname, fxPer, new string[] { "Printer" });
                FanxiPrincipal          _principal = new FanxiPrincipal(tempId);
                HttpContext.Current.User = _principal;
                tempId.Roles             = tempUser.Roles.Select(p => p.name).ToArray();
                if (_Roles != null && _Roles.Length > 0)
                {
                    IEnumerable <string> TempRoles = (from r in tempId.Roles where _Roles.Contains(r) select r);
                    if (TempRoles == null || TempRoles.Count() == 0)
                    {
                        return(false);
                    }
                }
                if (_Permissions != null && _Permissions.Length > 0)
                {
                    List <string> HasPermission = new List <string>();
                    IList <IdentityManagement.Domain.role> roles = FX.Core.IoC.Resolve <IroleService>().Query.Where(p => tempId.Roles.Contains(p.name)).ToList();
                    foreach (var r in roles)
                    {
                        foreach (var per in r.Permissions)
                        {
                            if (HasPermission.Contains(per.name))
                            {
                                continue;
                            }
                            HasPermission.Add(per.name);
                        }
                    }
                    string[] TempPer = (from per in _Permissions where (!HasPermission.Contains(per)) select per).ToArray();
                    if (TempPer != null && TempPer.Length > 0)
                    {
                        return(false);
                    }
                }
                return(true);
            }
            if (authenticationParts.Length != 5)
            {
                return(false);
            }
            var username = authenticationParts[3];
            var password = authenticationParts[4];

            //Kiểm tra username và pass có tồn tại trong db
            if (!isAccountCorrect(username, password))
            {
                return(false);
            }
            return(true);
        }
 public AccountController(IuserService us)
 {
     this.us = us;
 }
示例#20
0
        public ActionResult LogOn(LogOnModel _model, string captch)
        {
            if (string.IsNullOrWhiteSpace(captch))
            {
                _model.lblErrorMessage = "Nhập đúng mã xác thực.";
                _model.Password        = "";
                return(View(_model));
            }
            bool cv = CaptchaController.IsValidCaptchaValue(captch);

            if (!cv)
            {
                _model.lblErrorMessage = "Nhập đúng mã xác thực.";
                _model.Password        = "";
                return(View(_model));
            }
            log.Info("Login: "******"LogOn:" + HttpContext.User.Identity.Name + ", Date:" + DateTime.Now);
                        if (!string.IsNullOrWhiteSpace(_model.ReturnUrl) && Url.IsLocalUrl(_model.ReturnUrl))
                        {
                            return(Redirect(_model.ReturnUrl));
                        }
                        return(Redirect("/"));
                    }
                    else
                    {
                        IuserService userSrv  = IoC.Resolve <IuserService>();
                        var          currComp = ((EInvoiceContext)FXContext.Current).CurrentCompany;
                        user         TempUser = userSrv.Query.Where(u => u.username == _model.UserName && u.GroupName.Equals(currComp.id.ToString())).FirstOrDefault();
                        if (TempUser != null)
                        {
                            if (TempUser.IsLockedOut)
                            {
                                _model.lblErrorMessage = "Tài khoản đã bị khóa.";
                            }
                            else
                            {
                                if (!_model.IsThread)
                                {
                                    if (TempUser.FailedPasswordAttemptCount > 0)
                                    {
                                        TempUser.FailedPasswordAttemptCount = 0;
                                        userSrv.Save(TempUser);
                                        userSrv.CommitChanges();
                                    }
                                    _model.lblErrorMessage = Resources.Message.User_MesWrongAccOrPass;
                                    _model.Password        = "";
                                    _model.IsThread        = true;
                                    return(View(_model));
                                }
                                if (TempUser.FailedPasswordAttemptCount == 4)
                                {
                                    TempUser.IsLockedOut = true;
                                }
                                TempUser.FailedPasswordAttemptCount++;
                                _model.lblErrorMessage = Resources.Message.User_MesWrongAccOrPass;
                                userSrv.Save(TempUser);
                                userSrv.CommitChanges();
                            }
                            _model.Password = "";
                            return(View(_model));
                        }
                        _model.lblErrorMessage = Resources.Message.User_MesWrongAccOrPass;
                        _model.Password        = "";
                        return(View(_model));
                    }
                }
                else
                {
                    _model.Password = "";
                    return(View("LogOn", _model));
                }
            }
            catch (Exception ex)
            {
                log.Error("Error", ex);
                _model.lblErrorMessage = Resources.Message.User_MesWrongAccOrPass;
                _model.Password        = "";
                return(View("LogOn", _model));
            }
        }
 public userController(IuserService service)
 {
     _service = service;
 }
示例#22
0
 public UsersController(DataContxt context, IuserService userService, ITokenService tokenService)
 {
     _context      = context;
     _userService  = userService;
     _tokenService = tokenService;
 }
示例#23
0
 public UserController(IuserService userService)
 {
     this.UserService = userService;
 }
示例#24
0
 public UserRule(IuserService _service)
 {
     this._service = _service;
 }
示例#25
0
        public string UpdateCus(ApiPublish publish)
        {
            IuserService          _userSvc  = IoC.Resolve <IuserService>();
            ICustomerService      _cusSvc   = IoC.Resolve <ICustomerService>();
            IApplicationsService  _appSvc   = IoC.Resolve <IApplicationsService>();
            IRegisterEmailService _emailSvc = IoC.Resolve <IRegisterEmailService>();
            ILog log = LogManager.GetLogger(typeof(PublishController));

            try
            {
                log.Info("updateCus DATA:" + publish.xmlData);

                //check valiadate xml
                XmlSchemaValidator validator = new XmlSchemaValidator();
                //XMLCusData = convertSpecialCharacter(XMLCusData);
                if (!validator.ValidXmlDoc(publish.xmlData, "", AppDomain.CurrentDomain.BaseDirectory + @"XMLValidate\CustomerValidate.xsd"))
                {
                    log.Error("updateCus ERR:3-UpdateCus " + validator.ValidationError);
                    return("ERR:3");//du lieu dau vao khong hop le
                }

                if (publish.convert == 1)
                {
                    publish.xmlData = DataHelper.convertTCVN3ToUnicode(publish.xmlData);
                }

                Applications _app = _appSvc.GetByName("EInvoice");  //Chu y fix cung phu hop voi services.config/IRBACMembershipProvider

                EInvoiceContext _Einvoicecontext = (EInvoiceContext)FXContext.Current;
                Company         _currentCom      = _Einvoicecontext.CurrentCompany;

                // get dữ liệu từ string xml
                XElement xelement = XElement.Parse(publish.xmlData);

                List <XElement> cusLst  = (from item in xelement.Elements("Customer") select item).ToList();
                List <string>   codeLst = (from item in cusLst select item.Element("Code").Value).ToList();

                string defaultPass = (_currentCom.Config.ContainsKey("SetDefaultCusPass")) ? _currentCom.Config["SetDefaultCusPass"] : "******";
                string labelEmail  = _currentCom.Config.Keys.Contains("LabelMail") ? _currentCom.Config["LabelMail"] : "*****@*****.**";
                string portalLink  = _currentCom.Config.Keys.Contains("PortalLink") ? _currentCom.Config["PortalLink"] : "http://hddt.v-invoice.vn";

                _cusSvc.BeginTran();
                StringBuilder msg = new StringBuilder();
                foreach (var item in cusLst)
                {
                    try
                    {
                        string code    = item.Element("Code").Value.Trim();
                        var    taxCode = Utils.formatTaxcode(item.Element("TaxCode").Value.Trim());

                        var cusDb  = _cusSvc.Query.FirstOrDefault(x => x.Code == code && x.ComID == _currentCom.id);
                        var userDb = _userSvc.Query.FirstOrDefault(x => x.username == code && x.GroupName == _currentCom.id.ToString());

                        // create
                        if (cusDb == null)
                        {
                            if (userDb != null)
                            {
                                msg.AppendFormat("Ma KH: {0}. Khong the tao khach hang do user {0} da ton tai trong he thong.", code).AppendLine();
                                log.WarnFormat("Ma KH: {0}. Khong the tao khach hang do user {0} da ton tai trong he thong.", code);
                                continue;
                            }

                            if (!String.IsNullOrWhiteSpace(taxCode) && _cusSvc.Query.Any(x => x.TaxCode == taxCode && x.ComID == _currentCom.id))
                            {
                                msg.AppendFormat("Ma KH: {0}. Khong the tao khach hang do ma so thue {0} da ton tai trong he thong.", taxCode).AppendLine();
                                log.WarnFormat("Ma KH: {0}. Khong the tao khach hang do ma so thue {1} da ton tai trong he thong.", code, taxCode);
                                continue;
                            }

                            var cus = new Customer
                            {
                                Code            = code,
                                AccountName     = code,
                                TaxCode         = taxCode,
                                Name            = item.Element("Name").Value,
                                Address         = item.Element("Address").Value,
                                BankAccountName = item.Element("BankAccountName").Value,
                                BankName        = item.Element("BankName").Value,
                                BankNumber      = item.Element("BankNumber").Value,
                                Email           = item.Element("Email").Value,
                                Fax             = item.Element("Fax").Value,
                                Phone           = item.Element("Phone").Value,
                                ContactPerson   = item.Element("ContactPerson").Value,
                                RepresentPerson = item.Element("RepresentPerson").Value,
                                CusType         = String.IsNullOrWhiteSpace(item.Element("Name").Value) ? Int32.Parse(item.Element("Name").Value) : 0,
                                DeliverMethod   = 2,
                                ComID           = _currentCom.id
                            };

                            string createCusErr;
                            if (_cusSvc.CreateCus(cus, new Certificate(), _currentCom.id, out createCusErr))
                            {
                                log.Info("updateCus Create Customer by: " + HttpContext.Current.User.Identity.Name + " Info-- TenKhachHang: " + cus.Name + " TaiKhoanKhachHang: " + cus.AccountName + " Email: " + cus.Email);
                                // send Mail--
                                try
                                {
                                    if (!string.IsNullOrEmpty(cus.Email))
                                    {
                                        Dictionary <string, string> subjectParams = new Dictionary <string, string>(1);
                                        subjectParams.Add("$subject", "");
                                        Dictionary <string, string> bodyParams = new Dictionary <string, string>(3);
                                        bodyParams.Add("$company", _currentCom.Name);
                                        bodyParams.Add("$cusname", cus.Name);
                                        bodyParams.Add("$username", cus.AccountName);
                                        bodyParams.Add("$password", defaultPass);
                                        bodyParams.Add("$portalLink", portalLink);
                                        _emailSvc.ProcessEmail(labelEmail, cus.Email, "RegisterCustomer", subjectParams, bodyParams);
                                    }
                                }
                                catch (Exception ex)
                                { log.Warn("updateCus", ex); }
                            }
                            else
                            {
                                msg.AppendFormat("Ma KH: {0}. Khong the tao khach hang {0}. Thong bao loi: {1}", code, createCusErr).AppendLine();
                                log.Warn("updateCus Error: " + createCusErr);
                            }
                        }
                        // update
                        else
                        {
                            // update taxcode
                            if (!String.IsNullOrWhiteSpace(taxCode) && cusDb.TaxCode != taxCode)
                            {
                                if (_cusSvc.Query.Any(x => x.TaxCode == taxCode && x.ComID == _currentCom.id))
                                {
                                    msg.AppendFormat("Ma KH: {0}. Khong the chinh sua thong tin khach hang {0} do ma so thue {1} da ton tai trong he thong.", code, taxCode).AppendLine();
                                    continue;
                                }

                                cusDb.TaxCode = taxCode;
                            }

                            cusDb.Name            = item.Element("Name").Value;
                            cusDb.Address         = item.Element("Address").Value;
                            cusDb.BankAccountName = item.Element("BankAccountName").Value;
                            cusDb.BankName        = item.Element("BankName").Value;
                            cusDb.BankNumber      = item.Element("BankNumber").Value;
                            cusDb.Email           = item.Element("Email").Value;
                            cusDb.Fax             = item.Element("Fax").Value;
                            cusDb.Phone           = item.Element("Phone").Value;
                            cusDb.ContactPerson   = item.Element("ContactPerson").Value;
                            cusDb.RepresentPerson = item.Element("RepresentPerson").Value;
                            cusDb.CusType         = String.IsNullOrWhiteSpace(item.Element("Name").Value) ? Int32.Parse(item.Element("Name").Value) : 0;
                        }
                    }
                    catch (Exception ex)
                    {
                        _cusSvc.RolbackTran();
                        log.Error("Loi tao hoac cap nhat khach hang: " + item.Element("Code"), ex);
                        return("ERR:2");//loi cap nhat khach hang le vao csdl
                    }
                }

                _cusSvc.CommitTran();
                return("OK:" + msg);
            }
            catch (Exception ex)
            {
                log.Error("updateCus: " + ex);
                throw ex;
            }
        }
示例#26
0
        public ActionResult Create(user _model, string RetypePassword, string[] AssignRoles)
        {
            IRBACRoleProvider       _RoleProvider       = IoC.Resolve <IRBACRoleProvider>();
            IuserService            _userService        = IoC.Resolve <IuserService>();
            IRBACMembershipProvider _MemberShipProvider = IoC.Resolve <IRBACMembershipProvider>();
            AccountModels           model = new AccountModels();

            if (string.IsNullOrWhiteSpace(_model.username))
            {
                Messages.AddErrorMessage("Cần nhập những thông tin bắt buộc.");
                List <String> lst = new List <string>(_RoleProvider.GetAllRoles());
                model.RetypePassword = _model.password = "";
                model.AllRoles       = lst.ToArray();
                model.UserRoles      = AssignRoles ?? new string[] { };
                model.tmpUser        = _model;
                return(View("New", model));
            }
            try
            {
                string status = "";
                AssignRoles = AssignRoles ?? new string[] { };
                if (!_model.password.Equals(RetypePassword))
                {
                    Messages.AddErrorMessage("Nhập đúng mật khẩu của bạn.");
                    List <String> lst = new List <string>(_RoleProvider.GetAllRoles());
                    model.RetypePassword = _model.password = "";
                    model.AllRoles       = lst.ToArray();
                    model.UserRoles      = new string[] { };
                    model.tmpUser        = _model;
                    return(View("New", model));
                }
                else
                {
                    _MemberShipProvider.CreateUser(_model.username, _model.password, _model.email, _model.PasswordQuestion, _model.PasswordAnswer, _model.IsApproved, null, out status);
                    if (status != "Success")
                    {
                        List <String> lst = new List <string>(_RoleProvider.GetAllRoles());
                        model.RetypePassword = _model.password = "";
                        model.AllRoles       = lst.ToArray();
                        model.UserRoles      = new string[] { };
                        model.tmpUser        = _model;
                        Messages.AddErrorMessage("Tài khoản đã có trên hệ thống hoặc dữ liệu không hợp lệ.");
                        return(View("New", model));
                    }
                    if (AssignRoles == null)
                    {
                        Messages.AddFlashMessage("Bạn tạo tài khoản thành công nhưng chưa phân quyền!");
                        return(RedirectToAction("index"));
                    }
                    _RoleProvider.UpdateUsersToRoles(_model.username, AssignRoles);
                    Messages.AddFlashMessage("Tạo tài khoản thành công.");

                    logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "User - Create : " + string.Format("Create: {0} by {1}", _model.username, HttpContext.User.Identity.Name), "Create User Success ", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);

                    return(RedirectToAction("index"));
                }
            }
            catch (Exception ex)
            {
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "User - Create ", "Create User Error: " + ex, LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);

                Messages.AddErrorMessage("Chưa tạo được người dùng.");
                List <String> lst = new List <string>(_RoleProvider.GetAllRoles());
                model.RetypePassword = _model.password = "";
                model.AllRoles       = lst.ToArray();
                model.UserRoles      = new string[] { };
                model.tmpUser        = _model;
                return(View("New", model));
            }
        }
示例#27
0
 public NGUOIDUNGService(string sessionFactoryConfigPath)
     : base(sessionFactoryConfigPath)
 {
     _donviSvc     = IoC.Resolve <IDM_DONVIService>();
     _iuserService = IoC.Resolve <IuserService>();
 }
示例#28
0
 public AccountController(IuserService userService)
 {
     _userService = userService;
 }
示例#29
0
 public HomeController(IuserService iuserService)
 {
     _iuserService = iuserService;
 }