Beispiel #1
0
        public static string CreateFirstProfileUser()
        {
            string strPath = "";

            try
            {
                strPath = HttpContext.Current.Request.PhysicalApplicationPath + string.Format(ResourcePathUrl.FolderUser, EncDec.Encrypt(HttpContext.Current.Session["loginid"].ToString()));
                if (!Directory.Exists(strPath))
                {
                    //tao cau truc thu muc profile
                    Directory.CreateDirectory(strPath);
                    //tao file index.html trong
                    FunctionsFile.WriteFile(strPath + "index.html", "");
                    //tao thu muc config
                    Directory.CreateDirectory(strPath + "Config/");
                    //tao file index.html trong
                    FunctionsFile.WriteFile(strPath + "Config/index.html", "");
                    //tao thu muc uploads
                    Directory.CreateDirectory(strPath + "Uploads/");
                    //tao file index.html trong
                    FunctionsFile.WriteFile(strPath + "Uploads/index.html", "");
                    //tao thu muc uploads
                    Directory.CreateDirectory(strPath + "Temps/");
                    //tao file index.html trong
                    FunctionsFile.WriteFile(strPath + "Temps/index.html", "");
                }
                _logger.Info(strPath);
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }
            return(strPath);
        }
Beispiel #2
0
        public static void SubscribeDoSomething(object query)
        {
            int num = 0;

            Log4Net.Info($"TestPubSub_通道订阅_{num}");
            num += 1;
        }
Beispiel #3
0
        public static void MemberChannel_SubscribeDoSomething(object query)
        {
            query = query as string;
            int num = 0;

            Log4Net.Info($"MemberChannel_SubscribeDoSomething_{query}_{num}");
            num += 1;
        }
Beispiel #4
0
 // GET: Home
 public ActionResult Index()
 {
     Log4Net.Info(this, "信息");
     Log4Net.Debug(this, "调试");
     Log4Net.Error(this, "错误");
     Log4Net.Fatal(this, "失败");
     Log4Net.Warn(this, "警告");
     return(View());
 }
Beispiel #5
0
 private void TestLog4Net()
 {
     Log4Net.Debug("debug log");
     Log4Net.Info("info log");
     Log4Net.Warn("Warn log");
     Log4Net.Error("Error log");
     Log4Net.Fatal("Fatal log");
     Log4Net.DebugInfo("Debug log{0}", 2);
 }
Beispiel #6
0
        /// <summary>
        /// Doc du lieu file config
        /// </summary>
        /// <returns></returns>
        public List <string> ReadXMLCorsConfig()
        {
            List <string> lstOrigin = new List <string>();

            try
            {
                XDocument doc = new XDocument(_strPath);
                IEnumerable <XElement> origins = doc.Descendants("origins");
                _logger.Info(origins.Count());
                lstOrigin = (from n in origins.Elements("origin")
                             select n.ToString()).ToList();
                _logger.Info(lstOrigin.Count);
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }
            return(lstOrigin);
        }
Beispiel #7
0
        public ActionResult AccessDenied(string pageUrl)
        {
            if (!IsLogged())
            {
                return(BackToLogin());
            }
            //var currentCustomer = _workContext.CurrentCustomer;
            //if (currentCustomer == null || currentCustomer.IsGuest())
            //{
            //    _logger.Information(string.Format("Access denied to anonymous request on {0}", pageUrl));
            //    return View();
            //}

            logger.Info(string.Format("Access denied to user #{0} '{1}' on {2}", "", "", pageUrl));


            return(View());
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            Log4Net.InitLogger();
            SetLang(System.Globalization.CultureInfo.CurrentCulture.Name);
            //Console.WriteLine("WCF服务启动中...");
            Log4Net.Info(typeof(Program), "WCF服务启动中...", true);

            List <ServiceInfo> serviceInfoList = new List <ServiceInfo>();

            serviceInfoList = ServiceManager.Instance.ServiceProvider();
            ServiceManager.Instance.OpenService(serviceInfoList);
            Console.WriteLine("按Q键退出程序...");
            while (Console.ReadLine() == "C")
            {
                ServiceManager.Instance.CloseService(serviceInfoList);
            }
            while (Console.ReadLine() != "Q")
            {
                continue;
            }
        }
Beispiel #9
0
        /// <summary>
        /// 通过group和name判断是要执行哪个任务  具体(任务执行逻辑)业务逻辑写后面
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task Execute(IJobExecutionContext context)
        {
            await Task.Run(() =>
            {
                var name  = context.JobDetail.Key.Name;
                var group = context.JobDetail.Key.Group;
                if (group == "xx1" && name == "xx2")
                {
                    //do something
                }

                if (group == "xx2" && name == "xx3")
                {
                    //do something also
                }
                //组:z,名称c
                if (group.Equals("z") && name.Equals("c"))
                {
                    Log4Net.Info($"你好棒");
                }
                Log4Net.Info($"执行任务_Name:{name}_Grop:{group}");
            });
        }
 public async Task Log(string request)
 {
     Log4Net.Info(request);
 }
 public void Info(object message)
 {
     Count(Level.Info); Log4Net.Info(message);
 }
 public void Info(object message, Exception exception)
 {
     Count(Level.Info); Log4Net.Info(message, exception);
 }
Beispiel #13
0
        /// <summary>
        /// Constructor with sqlConfig file.
        /// </summary>
        /// <param name="sqlMapConfig">SQLConfig file</param>
        public SQLMapEmployee(string sqlMapConfig)
        {
            logger.Start("Constructor SQLMap - Map du lieu");
            try
            {
                logger.Param("Loi kết nối tới database", sqlMapConfig);
                //create SQLMapper from SQLConfig file
                this.str_SqlMapConfig = sqlMapConfig;
                DomSqlMapBuilder cDom = new DomSqlMapBuilder();
                sqlMapEmployee = (SqlMapper)cDom.Configure(sqlMapConfig);
                sqlMapEmployee.DataSource.ConnectionString = "Data Source=10.84.0.31;Initial Catalog=MixHRM_2017;User ID= HRM;Password=HRm11@122";//EncryptData(sqlMapEmployee.DataSource.ConnectionString);

                logger.Info("Creating SQLMapper sucessfull");
            }
            catch (SqlException ex)
            {
                logger.Error(ex.ToString());
            }
            logger.End("Constructor SQLMap");
        }
Beispiel #14
0
        public ActionResult Login(TaiKhoanModels model, string returnUrl, string captcha)
        {
            _logger.Start("Login");
            bool bCaptcha = false;

            ViewBag.isNhapCaptcha = false;
            LoginServices service = new LoginServices();

            try
            {
                //neu so lan user dang nhap vuot qua gioi han se bi lock
                if (Session[strSessionLoginFail] == null)
                {
                    Session[strSessionLoginFail] = 0;
                }
                int loginFail = (int)Session[strSessionLoginFail];
                if (!string.IsNullOrEmpty(captcha) && !string.IsNullOrWhiteSpace(captcha))
                {
                    if (captcha == Session[strSessionCaptcha].ToString())
                    {
                        bCaptcha = true;
                    }
                }
                if (loginFail < RICONS.Core.Constants.CST_Common.CST_Lock || bCaptcha)
                {
                    #region kiem tra user login tren he thong AD admin
                    bool   validAD          = false;
                    string matkhaudangnnhap = model.matkhau;
                    string tendangnhap      = model.tendangnhap.Trim().Split('@')[0].ToLower();
                    var    passWordDecrypt  = EncDec.DecryptStringAES(model.matkhau);
                    try
                    {
                        using (PrincipalContext context = new PrincipalContext(ContextType.Domain, "newtecons.vn", tendangnhap, passWordDecrypt))
                        {
                            validAD = context.ValidateCredentials(tendangnhap, passWordDecrypt);
                            UserPrincipal user_ad = UserPrincipal.FindByIdentity(context, IdentityType.SamAccountName, tendangnhap);
                            if (validAD)
                            {
                                #region
                                var user = service.GetLoginData(new M_TaiKhoan()
                                {
                                    tendangnhap = tendangnhap,
                                    xoa         = CST_Common.CST_NOT_DELETE,
                                    kichhoat    = CST_Common.CST_ACTIVE
                                });
                                TaiKhoanServices serTaiKhoan = new TaiKhoanServices();
                                TaiKhoanModels   modeltk     = new TaiKhoanModels();
                                // Lay du lieu employee
                                //var dlemployee = serTaiKhoan.GetDataEmployee(tendangnhap);
                                if (user == null)
                                {
                                    #region
                                    //if (dlemployee != null)
                                    //{
                                    //    modeltk.manhansu = dlemployee.manhansu;
                                    //    modeltk.hoten = dlemployee.hoten;
                                    //    modeltk.machucdanh = dlemployee.machucdanh;
                                    //    modeltk.tenchucdanh = dlemployee.tenchucdanh;
                                    //    modeltk.maphongban = dlemployee.maphongban;

                                    //    if (dlemployee.phongban_congtruong.ToString().ToLower() == "false")
                                    //        modeltk.phongban_congtruong = "0";
                                    //    else modeltk.phongban_congtruong = "1";

                                    //}
                                    modeltk.tendangnhap = tendangnhap;
                                    model.madonvi       = 1;
                                    modeltk.thudientu   = user_ad.EmailAddress;
                                    modeltk.chucdanhkpi = "1";
                                    bool kq = serTaiKhoan.AddUser(modeltk, 0);
                                    user = service.GetLoginData(new M_TaiKhoan()
                                    {
                                        tendangnhap = tendangnhap,
                                        xoa         = CST_Common.CST_NOT_DELETE,
                                        kichhoat    = CST_Common.CST_ACTIVE
                                    });
                                    #endregion
                                }
                                //else if (dlemployee != null)
                                //{
                                //    //Cập nhật manhansu,machucdanh,maphongban
                                //    user.manhansu = dlemployee.manhansu;
                                //    user.maphongban = dlemployee.maphongban;
                                //    user.machucdanh = dlemployee.machucdanh;
                                //    user.tenchucdanh = dlemployee.tenchucdanh;
                                //    user.hoten = dlemployee.hoten;
                                //    user.sodienthoai = dlemployee.sodienthoai;
                                //    user.thudientu = user_ad.EmailAddress;
                                //    user.ngaysinh = dlemployee.ngaysinh;
                                //    user.chucdanhkpi = user.chucdanhkpi;
                                //    if(dlemployee.phongban_congtruong.ToString().ToLower()=="false")
                                //        user.phongban_congtruong = "0";
                                //    else user.phongban_congtruong = "1";

                                //    if (user.chucdanhkpi.Trim() == "" || user.chucdanhkpi == null)
                                //        user.chucdanhkpi = "1";
                                //    bool kqcapnhat = serTaiKhoan.Updatemanhansu(user.mataikhoan, user.manhansu, user.machucdanh.ToString(), user.maphongban, user.hoten, user.chucdanhkpi, user.phongban_congtruong);
                                //}
                                var lstPhongBanDonVis = serTaiKhoan.SelectPhongBanDonVi(new M_TaiKhoan()
                                {
                                    mataikhoan = user.mataikhoan
                                });
                                user.phongBanDonVis = lstPhongBanDonVis;
                                AddSession(user);
                                UpdateLoginState(tendangnhap, false, loginFail);
                                //chuyen trang
                                _logger.End("Login");
                                return(RedirectToAction("Index", "WeedMeeting"));

                                //return RedirectToLocal(returnUrl);
                                #endregion
                            }
                            else if (!validAD)
                            {
                                #region
                                var user = service.GetLoginData(new M_TaiKhoan()
                                {
                                    tendangnhap = model.tendangnhap,
                                    matkhau     = EncDec.EncodePassword(passWordDecrypt),
                                    xoa         = CST_Common.CST_NOT_DELETE,
                                    kichhoat    = CST_Common.CST_ACTIVE
                                });
                                if (user != null)
                                {
                                    TaiKhoanServices serTaiKhoan = new TaiKhoanServices();
                                    var lstPhongBanDonVis        = serTaiKhoan.SelectPhongBanDonVi(new M_TaiKhoan()
                                    {
                                        mataikhoan = user.mataikhoan
                                    });
                                    user.phongBanDonVis = lstPhongBanDonVis;
                                    AddSession(user);
                                    UpdateLoginState(model.tendangnhap, false, loginFail);
                                    _logger.End("Login");
                                    return(RedirectToAction("Index", "WeedMeeting"));
                                }
                                else
                                {
                                    try
                                    {
                                        UpdateLoginState(model.tendangnhap, true, loginFail);
                                    }
                                    catch (Exception ex)
                                    {
                                        _logger.Error(ex);
                                    }
                                }
                                #endregion
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        validAD = false;
                        _logger.Info(ex);
                    }
                    #endregion

                    #region kiem tra user login local

                    if (!validAD)
                    {
                        var user = service.GetLoginData(new M_TaiKhoan()
                        {
                            tendangnhap = model.tendangnhap,
                            matkhau     = EncDec.EncodePassword(passWordDecrypt),
                            xoa         = CST_Common.CST_NOT_DELETE,
                            kichhoat    = CST_Common.CST_ACTIVE
                        });
                        if (user != null)
                        {
                            TaiKhoanServices serTaiKhoan = new TaiKhoanServices();
                            var lstPhongBanDonVis        = serTaiKhoan.SelectPhongBanDonVi(new M_TaiKhoan()
                            {
                                mataikhoan = user.mataikhoan
                            });
                            user.phongBanDonVis = lstPhongBanDonVis;
                            AddSession(user);
                            UpdateLoginState(model.tendangnhap, false, loginFail);
                            _logger.End("Login");
                            return(RedirectToAction("Index", "WeedMeeting"));
                        }
                        else
                        {
                            try
                            {
                                UpdateLoginState(model.tendangnhap, true, loginFail);
                            }
                            catch (Exception ex)
                            {
                                _logger.Error(ex);
                            }
                        }
                    }
                    #endregion
                }
                else
                {
                    ViewBag.isNhapCaptcha = true;
                    UpdateLoginState(model.tendangnhap, true, loginFail);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                _logger.End("CheckLogin");
            }
            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Beispiel #15
0
        /// <summary>
        /// Constructor with sqlConfig file.
        /// </summary>
        /// <param name="sqlMapConfig">SQLConfig file</param>
        public SQLMap(string sqlMapConfig)
        {
            logger.Start("Constructor SQLMap - Map du lieu");
            try
            {
                logger.Param("Loi kết nối tới database", sqlMapConfig);
                //create SQLMapper from SQLConfig file
                this.str_SqlMapConfig = sqlMapConfig;
                DomSqlMapBuilder cDom = new DomSqlMapBuilder();
                sqlMap = (SqlMapper)cDom.Configure(sqlMapConfig);
                sqlMap.DataSource.ConnectionString = EncryptData(sqlMap.DataSource.ConnectionString);

                logger.Info("Creating SQLMapper sucessfull");
            }
            catch (SqlException ex)
            {
                logger.Error(ex.ToString());
            }
            logger.End("Constructor SQLMap");
        }