示例#1
0
        static async Task Main(string[] args)
        {
            using IHost host = CreateHostBuilder(args).Build();
            var services = host.Services;

            using IServiceScope serviceScope = services.CreateScope();
            IServiceProvider provider = serviceScope.ServiceProvider;

            _logger = provider.GetRequiredService <ILogger>();
            _passwordChangeProvider = provider.GetRequiredService <IPasswordChangeProvider>();
            _options = provider.GetRequiredService <IOptions <PasswordChangeOptions> >();

            _logger.Information("----START HAI PHAT LAND ACM----");
            Console.WriteLine("----START HAI PHAT LAND ACM----");
            int backDate = -1;

            try
            {
                //backDate = int.Parse(configuration.GetSection("AppSettings:BackDateSchedule").Value);
                backDate = int.Parse(_options.Value.BackDateSchedule);
            }
            catch (Exception e)
            {
                _logger.Error("Error get value BackDateSchedule: " + e);
            }

            //var listNvs = GetAllNhanVienChuaCoUsername(backDate);
            //_logger.Information("----TỔNG SỐ HỒ SƠ XỬ LÝ: " + listNvs.Count);
            //Console.WriteLine("----TONG HO SO XU LY: " + listNvs.Count);
            //HplServices hplServices = new HplServices(_passwordChangeProvider, _logger);

            //await hplServices.CreateUserAllSys(listNvs);
        }
示例#2
0
 public AbpHplController(ILogger logger, IAbpHplDbContext abpHplDb, IUriService uriService, IOptions <ClientSettings> optionsAccessor, IPasswordChangeProvider passwordChangeProvider)
 {
     _logger                 = logger;
     _abpHplDb               = abpHplDb;
     _uriService             = uriService;
     _options                = optionsAccessor.Value;
     _passwordChangeProvider = passwordChangeProvider;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PasswordController" /> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="optionsAccessor">The options accessor.</param>
 /// <param name="passwordChangeProvider">The password change provider.</param>
 public PasswordController(
     ILogger <PasswordController> logger,
     IOptions <ClientSettings> optionsAccessor,
     IPasswordChangeProvider passwordChangeProvider)
 {
     _logger  = logger;
     _options = optionsAccessor.Value;
     _passwordChangeProvider = passwordChangeProvider;
 }
 public PasswordChangeController(ILogger <PasswordChangeController> logger,
                                 IOptions <PresetOptions> presetOptions,
                                 IPasswordChangeProvider passwordChanger, MfaResolver mfa)
 {
     _logger          = logger;
     _presetOptions   = presetOptions.Value;
     _passwordChanger = passwordChanger;
     _mfa             = mfa;
 }
示例#5
0
        public FormMain(ILogger logger, IOptions <PasswordChangeOptions> options, IPasswordChangeProvider passwordChangeProvider)
        {
            _logger  = logger;
            _options = options.Value;
            _passwordChangeProvider = passwordChangeProvider;
            InitializeComponent();


            //Initialization of _timer
            _timer = new Timer(x => { CallTimerMethode(); }, null, Timeout.Infinite, Timeout.Infinite);
            Setup_Timer();
            Console.ReadKey();
        }
示例#6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PasswordController" /> class.
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="optionsAccessor">The options accessor.</param>
        /// <param name="wordsAccessor">The words accessor.</param>
        /// <param name="passwordChangeProvider">The password change provider.</param>
        public PasswordController(
            ILogger <PasswordController> logger,
            IOptions <ClientSettings> optionsAccessor,
            IPasswordChangeProvider passwordChangeProvider)
        {
            _logger  = logger;
            _options = optionsAccessor.Value;
            _passwordChangeProvider = passwordChangeProvider;

            if (_options.UsePasswordGeneration)
            {
                _rngCsp = new RNGCryptoServiceProvider();
            }
        }
示例#7
0
        static void Main()
        {
            Application.SetHighDpiMode(HighDpiMode.SystemAware);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //var services = new ServiceCollection();
            //ConfigureServices(services);

            //using (ServiceProvider serviceProvider = services.BuildServiceProvider())
            //{
            //    var formMain = serviceProvider.GetRequiredService<FormMain>();
            //    Application.Run(new FormMain(_logger, _options, _passwordChangeProvider));
            //}

            using IHost host = CreateHostBuilder().Build();
            var services = host.Services;

            using IServiceScope serviceScope = services.CreateScope();
            IServiceProvider provider = serviceScope.ServiceProvider;

            _logger = provider.GetRequiredService <ILogger>();
            _passwordChangeProvider = provider.GetRequiredService <IPasswordChangeProvider>();
            _options = provider.GetRequiredService <IOptions <PasswordChangeOptions> >();
            var formMain = provider.GetRequiredService <FormMain>();

            Application.Run(new FormMain(_logger, _options, _passwordChangeProvider));


            //Cách call 2 Dependency Injection
            //var servicesCol = new ServiceCollection();
            //ConfigureServices(servicesCol);
            //using (ServiceProvider serviceProvider = servicesCol.BuildServiceProvider())
            //{
            //    var formMain = serviceProvider.GetRequiredService<FormMain>();
            //    Application.Run(new FormMain(_logger, _options, _passwordChangeProvider));
            //}
        }
示例#8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PasswordController"/> class.
 /// </summary>
 /// <param name="optionsAccessor">The options accessor.</param>
 /// <param name="passwordChangeProvider">The password change provider.</param>
 public PasswordController(IOptions <AppSettings> optionsAccessor, IPasswordChangeProvider passwordChangeProvider)
 {
     _options = optionsAccessor.Value;
     _passwordChangeProvider = passwordChangeProvider;
 }
示例#9
0
        public MainWindow(ILogger logger, IOptions <PasswordChangeOptions> options, IPasswordChangeProvider passwordChangeProvider, IAbpHplDbContext abpHplDb)
        {
            InitializeComponent();

            _logger  = logger;
            _options = options.Value;
            _passwordChangeProvider = passwordChangeProvider;
            _abpHplDb = abpHplDb;

            _logger.Information("MainWindow");

            #region TOOL CHẠY UPDATE LẠI PHÒNG BAN CHO USER TRÊN AD
            //Test 2021-09-15 Test gửi thông báo
            //_ = CallTimerEmailThongBaoUserLoi();

            //CẬP NHẬT LẠI THÔNG TIN USER TRÊN AD(Tool sử dụng một lần)
            //try
            //{
            //    _passwordChangeProvider.CreateAllOuHpl();
            //    //Fullname & Department
            //    var listUser = _passwordChangeProvider.GetAllUserHpl();

            //    _logger.Information("TỔNG SỐ USER AD UPDATE THÔNG TIN: " + listUser.Count);
            //    var cb = _passwordChangeProvider.UpdateUserInfoAd(listUser);
            //}
            //catch (Exception e)
            //{
            //    _logger.Error("Lỗi: " + e);
            //}


            //var listNvs = GetAllNhanVienErrorUser();

            //_logger.Information("----TỔNG SỐ HỒ SƠ TẠO MỚI ĐÃ XỬ LÝ: " + listNvs.Count);
            //WriteToConsole("----TỔNG SỐ HỒ SƠ TẠO MỚI ĐÃ XỬ LÝ: " + listNvs.Count);
            //if (listNvs.Any())
            //{
            //    HplServices hplServices = new HplServices(_passwordChangeProvider, _options, _logger);
            //    hplServices.CreateUserAllSys2(listNvs);
            //}

            //Application.Current.Shutdown();
            #endregion

            //TẠO USER AD, MAIL, UPDATE SALE ONLINE, UPDATE HRM,
            //PHẦN NÀY KHÔNG CHẠY TỰ ĐỘNG NỮA, MÀ SẼ SỬ DỤNG MANUAL TẠI EVENT DepUpdateUserChanged
            #region TẠO USER AD, MAIL, UPDATE SALE ONLINE, UPDATE HRM,
            //_timer = new Timer(async x =>
            //{
            //    _logger.Information("START TASK CREATE USER " + DateTime.Now.ToString("G"));
            //    await CallTimerCreateUser();//TODO

            //    _logger.Information("END TASK CREATE USER " + DateTime.Now.ToString("G"));
            //}, null, Timeout.Infinite, Timeout.Infinite);

            ////DISABLE USER AD, XÓA EMAIL, LOCK SALE ONLINE
            //_timerDis = new Timer(async x =>
            //{
            //    _logger.Information("START TASK DISABLE USER " + DateTime.Now.ToString("G"));
            //    await CallTimerDisableUser();//TODO

            //    _logger.Information("END TASK DISABLE USER " + DateTime.Now.ToString("G"));
            //}, null, Timeout.Infinite, Timeout.Infinite);
            #endregion

            ////THÔNG BÁO NHÂN VIÊN LỖI
            //_timerNotify = new Timer(async x =>
            //{
            //    _logger.Information("START TASK DISABLE USER " + DateTime.Now.ToString("G"));
            //    await CallTimerEmailThongBaoUserLoi();

            //    _logger.Information("END TASK DISABLE USER " + DateTime.Now.ToString("G"));
            //}, null, Timeout.Infinite, Timeout.Infinite);

            //SetupTimer();

            //CẬP NHẬT THAY ĐỔI PHÒNG BAN CỦA NHÂN SỰ Table NsQtChuyenCanBo
            var mapper = new ModelToTableMapper <NsQtChuyenCanBo>();
            mapper.AddMapping(c => c.NhanVienId, "NhanVienId");
            mapper.AddMapping(c => c.PhongBanCuId, "PhongBanCuID");
            mapper.AddMapping(c => c.TenPhongBanCu, "TenPhongBanCu");
            mapper.AddMapping(c => c.PhongBanMoiId, "PhongBanMoiID");
            mapper.AddMapping(c => c.TenPhongBanMoi, "TenPhongBanMoi");
            mapper.AddMapping(c => c.IsDeleted, "IsDeleted");

            _depChuyenPb            = new SqlTableDependency <NsQtChuyenCanBo>(ConHrm, "NS_QTChuyenCanBo", mapper: mapper);
            _depChuyenPb.OnChanged += DepChuyenPbChanged;
            _depChuyenPb.OnError   += DepChuyenPbOnError;
            _depChuyenPb.Start();

            //TẠO/DISABLE USER TOÀN HỆ THỐNG CreateDisableUserManual
            var mapper2 = new ModelToTableMapper <CreateDisableUserManual>();
            mapper2.AddMapping(c => c.Id, "Id");
            mapper2.AddMapping(c => c.ListMaNhanVien, "ListMaNhanVien");
            mapper2.AddMapping(c => c.ActionType, "ActionType");
            mapper2.AddMapping(c => c.DateCreated, "DateCreated");

            _depUpdateUser            = new SqlTableDependency <CreateDisableUserManual>(ConAcm, "CreateDisableUserManuals", mapper: mapper2);
            _depUpdateUser.OnChanged += DepUpdateUserChanged;
            _depUpdateUser.OnError   += DepUpdateUserOnError;
            _depUpdateUser.Start();
        }
示例#10
0
 public ServiceCommon(IOptions <ClientSettings> options, ILogger logger, IPasswordChangeProvider passwordChangeProvider)
 {
     _options = options.Value;
     _logger  = logger;
     _passwordChangeProvider = passwordChangeProvider;
 }