private void button_Click(object sender, EventArgs e) { if (sender.Equals(this.buttonUpdate)) { if (this.textexApplicationRoleName.Text.Trim() != "" && this.textexApplicationRolePassword.Text.Trim() != "") { IBaseRepository baseRepository = CommonNinject.Kernel.Get <IBaseRepository>(); if (baseRepository.UpdateApplicationRole(SecurePassword.Encrypt(this.textexApplicationRoleName.Text.Trim()), SecurePassword.Encrypt(this.textexApplicationRolePassword.Text.Trim())) == 1) { this.DialogResult = DialogResult.OK; } else { throw new Exception("Fail to update application role."); } } } else if (sender.Equals(this.buttonApplicationRoleRequired) || sender.Equals(this.buttonApplicationRoleIgnored)) { CommonConfigs.AddUpdateAppSetting("ApplicationRoleRequired", sender.Equals(this.buttonApplicationRoleRequired) ? "true" : "false"); CustomMsgBox.Show(this, "Please open your program again in order to take new effect.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.DialogResult = DialogResult.Cancel; } else { this.DialogResult = DialogResult.Cancel; } }
public Reviewer[] GetWorkingReviewers(CommonConfigs commonConfigs) { using (var dbContext = new AARPDbContext()) { return(dbContext.Reviewers .Where(rvr => rvr.IsInWorkingHours(commonConfigs.StartTimeOfDay, commonConfigs.EndTimeOfDay, commonConfigs.EnabledDays)) .ToArray()); } }
public static (IActorRef, ActorSystem) CreatePluginSystem(string actorSystemName, ILoggerFactory loggerFactory) { var logger = loggerFactory.GetLogger(); Log.Logger = logger; var system = ActorSystem.Create(actorSystemName, CommonConfigs.BasicConfig()); var registry = system.ActorOf <PluginRegistry>("plugin-registry"); return(registry, system); }
private void buttonDownload_Click(object sender, EventArgs e) { try { throw new Exception("Please open your program again in order to update new version." + "\r\n" + "\r\n" + "Contact your admin for more information. Thank you!" + "\r\n" + "\r\n" + "\r\n" + "\r\n" + "Vui lòng mở lại phần mềm để cập nhật phiên bản mới nhất. Cám ơn."); } catch (Exception exception) { CommonConfigs.AddUpdateAppSetting("VersionID", "-9"); ExceptionHandlers.ShowExceptionMessageBox(this, exception); this.DialogResult = DialogResult.Cancel; } }
public void LoggingConfiguration() { var level = LogLevelEnum.WARNING; var loggerName = "Name"; var loggerBinary = "Binary"; var mock = new Mock <ILoggingConfig>(); mock.Setup(x => x.LogLevel).Returns(level); mock.Setup(x => x.LoggerClassName).Returns(loggerName); mock.Setup(x => x.LoggerBinaryName).Returns(loggerBinary); var cfg = CommonConfigs.CreateLoggingConfig(mock.Object); cfg.GetString("akka.loglevel").Should().Be(level.ToString()); cfg.GetStringList("akka.loggers").Should().BeEquivalentTo(new[] { $"{loggerName}, {loggerBinary}" }); }
private void buttonApplicationRole_Click(object sender, EventArgs e) { if (sender.Equals(this.buttonApplicationRoleRequired) || sender.Equals(this.buttonApplicationRoleIgnored)) { CommonConfigs.AddUpdateAppSetting("ApplicationRoleRequired", sender.Equals(this.buttonApplicationRoleRequired) ? "true" : "false"); CustomMsgBox.Show(this, "Please open your program again in order to take new effect.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.DialogResult = DialogResult.Cancel; } if (sender.Equals(this.buttonConnectServer)) { ConnectServer connectServer = new ConnectServer(true); DialogResult dialogResult = connectServer.ShowDialog(); connectServer.Dispose(); if (dialogResult == System.Windows.Forms.DialogResult.OK) { CustomMsgBox.Show(this, "Please open your program again in order to take new effect.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.DialogResult = DialogResult.Cancel; } } }
private bool VersionValidate() { try { foreach (GlobalVariables.FillingLine fillingLine in Enum.GetValues(typeof(GlobalVariables.FillingLine))) { this.baseRepository.ExecuteStoreCommand("UPDATE Configs SET VersionID = " + GlobalVariables.ConfigVersionID((int)fillingLine) + " WHERE ConfigID = " + (int)fillingLine + " AND VersionID < " + GlobalVariables.ConfigVersionID((int)fillingLine), new ObjectParameter[] { }); } if (this.baseRepository.VersionValidate(GlobalVariables.ConfigID, GlobalVariables.ConfigVersionID(GlobalVariables.ConfigID))) { CommonConfigs.AddUpdateAppSetting("VersionID", GlobalVariables.ConfigVersionID(GlobalVariables.ConfigID).ToString()); } return(true); } catch (Exception exception) { CommonConfigs.AddUpdateAppSetting("VersionID", "-9"); throw exception; } }
private void buttonLoginExit_Click(object sender, EventArgs e) { try { if (!(GlobalVariables.ConfigID == (int)GlobalEnums.NmvnTaskID.Lavie || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Smallpack || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Pail || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.BatchMaster)) { CustomMsgBox.Show(this, "Sorry, can not open this application." + "\r\n" + "\r\n" + "Call 0919 878 329 for more information. Thanks!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Stop); this.DialogResult = DialogResult.Cancel; return; } if (sender.Equals(this.buttonExit)) { this.DialogResult = DialogResult.Cancel; return; } if (this.comboBoxEmployeeID.SelectedIndex >= 0) { ActiveUser activeUser = this.comboBoxEmployeeID.SelectedItem as ActiveUser; if (activeUser != null) { UserAPIs userAPIs = new UserAPIs(CommonNinject.Kernel.Get <IUserAPIRepository>()); string passwordHash = userAPIs.GetPasswordHash(activeUser.UserID); if (passwordHash != "") { passwordHash = SecurePassword.Decrypt(passwordHash); } if (this.textPassword.Text != passwordHash) { throw new Exception("Sai mật khẩu. Vui lòng nhập lại mật khẩu trước khi tiếp tục."); } ContextAttributes.User = new UserInformation(activeUser.UserID, activeUser.OrganizationalUnitID, activeUser.LocationID, activeUser.LocationName, activeUser.UserName, activeUser.SecurityIdentifier, activeUser.FullyQualifiedUserName, activeUser.IsDatabaseAdmin, new DateTime()); if (this.comboFillingLineID.Visible && (this.comboFillingLineID.SelectedIndex < 0 || this.comboBoxAutonicsPortName.SelectedIndex < 0)) { throw new System.ArgumentException("Vui lòng chọn chuyền sản xuất (NOF1, NOF2, NOF...), và chọn đúng cổng COM để chạy phần mềm"); // || (this.comboFillingLineID.Enabled && (GlobalVariables.ProductionLine)this.comboFillingLineID.SelectedValue == GlobalVariables.ProductionLine.SERVER) } if (this.comboFillingLineID.Visible) { GlobalVariables.FillingLineID = (GlobalVariables.FillingLine) this.comboFillingLineID.SelectedValue; GlobalVariables.FillingLineCode = ((FillingLineBase)this.comboFillingLineID.SelectedItem).Code; GlobalVariables.FillingLineName = ((FillingLineBase)this.comboFillingLineID.SelectedItem).Name; GlobalVariables.FillingLineFactoryCode = ((FillingLineBase)this.comboFillingLineID.SelectedItem).FactoryCode; } else { GlobalVariables.FillingLineID = GlobalVariables.FillingLine.None; } GlobalVariables.ComportName = (string)this.comboBoxAutonicsPortName.SelectedValue; CommonConfigs.AddUpdateAppSetting("ConfigID", (GlobalVariables.ConfigID).ToString()); CommonConfigs.AddUpdateAppSetting("ComportName", GlobalVariables.ComportName); //CommonConfigs.AddUpdateAppSetting("ReportServerUrl", GlobalVariables.ReportServerUrl); //WILL BE REMOVE THIS LINE GlobalVariables.ReportServerUrl = CommonConfigs.ReadSetting("ReportServerUrl"); this.VersionValidate(); #region EMPTY DATABASE if (false && this.checkEmptyData.Checked) { this.baseRepository.ExecuteStoreCommand("UPDATE GoodsReceipts SET PickupID = NULL, GoodsIssueID = NULL, WarehouseAdjustmentID = NULL", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("UPDATE GoodsReceiptDetails SET PickupDetailID = NULL, PickupID = NULL, GoodsIssueTransferDetailID = NULL, GoodsIssueID = NULL, WarehouseAdjustmentDetailID = NULL, WarehouseAdjustmentID = NULL", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM WarehouseAdjustmentDetails", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('WarehouseAdjustmentDetails', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM WarehouseAdjustments", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('WarehouseAdjustments', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM GoodsIssueTransferDetails", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('GoodsIssueTransferDetails', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM GoodsIssueDetails", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('GoodsIssueDetails', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM GoodsIssues", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('GoodsIssues', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM TransferOrderDetails", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('TransferOrderDetails', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM TransferOrders", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('TransferOrders', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM DeliveryAdviceDetails", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('DeliveryAdviceDetails', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM DeliveryAdvices", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('DeliveryAdvices', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM SalesOrderDetails", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('SalesOrderDetails', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM SalesOrders", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('SalesOrders', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM GoodsReceiptDetails", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('GoodsReceiptDetails', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM GoodsReceipts", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('GoodsReceipts', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM PickupDetails", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('PickupDetails', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM Pickups", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Pickups', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM Packs", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Packs', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM Cartons", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Cartons', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM Pallets", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Pallets', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM Batches", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Batches', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM Lots", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Lots', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM BatchMasters", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('BatchMasters', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM Commodities", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Commodities', RESEED, 0)", new ObjectParameter[] { }); } #endregion if (this.baseRepository.AutoUpdates(sender.Equals(this.buttonLoginRestore))) { this.DialogResult = DialogResult.OK; } else { CustomMsgBox.Show(this, "The program on this computer must be updated to the latest version." + "\r\n" + "\r\n" + "Contact your administrator for more information.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Stop); this.buttonDownload_Click(this.buttonDownload, new EventArgs()); } } } } catch (Exception exception) { ExceptionHandlers.ShowExceptionMessageBox(this, exception); this.DialogResult = DialogResult.None; } }
public static PluginSystem NewPluginSystem(string systemName) { var config = CommonConfigs.BasicConfig(); return(NewPluginSystem(systemName, config)); }
static void Main() { const string applicationName = "TotalSmartCodingSolution"; bool createdNew; mutex = new Mutex(true, applicationName, out createdNew); if (!createdNew) { return; } //app is already running! Exiting the application Registries.ProductName = Application.ProductName.ToUpper(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); AutoMapperConfig.SetupMappings(); //string ApplicationRoleRequired = "false"; //COMMENT ON 11-JUL-2018: NOT USE ApplicationRoleRequired. JUST REMOVE THIS COMMENT ONLY -> TO USE ApplicationRoleRequired (GET ApplicationRoleRequired OPTION FROM CONFIG SETTING BY THE FOLLOWING CommonConfigs.ReadSetting("ApplicationRoleRequired")). string ApplicationRoleRequired = CommonConfigs.ReadSetting("ApplicationRoleRequired"); ApplicationRoles.Required = true; ApplicationRoles.Name = ""; ApplicationRoles.Password = ""; bool applicationRoleRequired = false; if (bool.TryParse(ApplicationRoleRequired, out applicationRoleRequired)) { ApplicationRoles.Required = applicationRoleRequired; } TrialConnects trialConnects = new TrialConnects(); DialogResult trialConnectResult = trialConnects.Connected(); if (trialConnectResult == DialogResult.Yes) { Logon logon = new Logon(); if (logon.ShowDialog() == DialogResult.OK) { if (!GlobalEnums.CBPP) { LegalNotice legalNotice = new LegalNotice(); legalNotice.ShowDialog(); legalNotice.Dispose(); } if (GlobalVariables.FillingLineID == GlobalVariables.FillingLine.Smallpack || GlobalVariables.FillingLineID == GlobalVariables.FillingLine.Pail || GlobalVariables.FillingLineID == GlobalVariables.FillingLine.Medium4L || GlobalVariables.FillingLineID == GlobalVariables.FillingLine.Import || GlobalVariables.FillingLineID == GlobalVariables.FillingLine.Drum) { Application.Run(new MasterMDI(GlobalEnums.NmvnTaskID.SmartCoding, new SmartCoding())); } else { if (GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Pickup) { Application.Run(new MasterMDI(GlobalEnums.NmvnTaskID.Pickups, new Pickups())); } else if (GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.GoodsIssue) { Application.Run(new MasterMDI(GlobalEnums.NmvnTaskID.GoodsIssues, new GoodsIssues())); } else { Application.Run(new MasterMDI()); } } } logon.Dispose(); } else if (trialConnectResult == DialogResult.No) { if (ApplicationRoles.Required) { ConnectServer connectServer = new ConnectServer(false); connectServer.ShowDialog(); connectServer.Dispose(); } else if (CustomMsgBox.Show(new Form(), "Do you want to specify new application role and password?", "Warning", MessageBoxButtons.YesNoCancel) == DialogResult.Yes) { ConnectServer connectServer = new ConnectServer(true); connectServer.ShowDialog(); connectServer.Dispose(); } } }
static void Main(string[] args) { var numArgs = 2; if (args.Length < numArgs) { Log.Fatal("Cluster Bootstrapper does not have the correct number of arguments. Expected at least {ExpectedArguments} but received {NumberOfArguments}", numArgs, args.Length); var count = 1; foreach (var arg in args) { Log.Information("Arg[{ArgumentIndex}]:{Argument}", count, arg); Log.CloseAndFlush(); } return; } var loggerFactory = new ElasticSearchLoggerFactory(new Uri("http://*****:*****@{hostname}:4053"; // Create the system and actors var cfg = CommonConfigs.BasicConfig() // Supress JSON warning .WithFallback(ClusterNodeConstants.DefaultConfig()) // With default actor props factory .WithFallback( ClusterConfigs.CreateClusterConfig( new DefaultClusterConfig( hostname, 0, seedNodes: new[] { seedNode }, roles: roles.Select(x => (Key: x, Value: 0)).ToDictionary(x => x.Key, x => x.Value) ) ) ) .WithFallback(CommonConfigs.CreateLoggingConfig(new SerilogConfig())); // Serilog logging var system = ActorSystem.Create(systemName, cfg); var configurator = system.ActorOf(Props.Create(() => new NodeConfigurator()), "configurator"); Console.CancelKeyPress += async(sender, eventArgs) => { Console.WriteLine("Stopping Cluster Worker..."); await CoordinatedShutdown.Get(system).Run(); }; // Waits until service is terminated and then exits the program system.WhenTerminated.Wait(); logger.Information("Cluster Worker stopped"); Log.CloseAndFlush(); }
static void Main() { var loggerFactory = new ElasticSearchLoggerFactory(new Uri("http://*****:*****@{hostname}:{port}"; // Create the system and actors var cfg = CommonConfigs.BasicConfig() // Supress JSON warning .WithFallback(ClusterNodeConstants.DefaultConfig()) // With default actor props factory .WithFallback( ClusterConfigs.CreateClusterConfig( new DefaultClusterConfig( hostname, port, // hostname and any port seedNodes: new [] { selfSeedNode }, // Seed nodes roles: roles ) ) ) .WithFallback(CommonConfigs.CreateLoggingConfig(new SerilogConfig())); // Serilog logging var system = ActorSystem.Create(systemName, cfg); // // Create configurations var workerNodeConfig = new SystemConfiguration( new RandomLoggerActorConfiguration("LoggerOne", TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(3), "Logs"), new RandomLoggerActorConfiguration("LoggerTwo", TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(3), "Logs"), new RandomLoggerActorConfiguration("LoggerThree", TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(3), "Logs"), new RandomLoggerActorConfiguration("LoggerFour", TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(3), "Logs"), new RandomLoggerActorConfiguration("LoggerFive", TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(3), "Logs") ); var listenerNodeConfig = new SystemConfiguration(new LogConfirmationActorConfiguration("ListenerPlugin", "Logs")); var targetNode = $"akka.tcp://{ClusterNodeConstants.DefaultSystemName}@{hostname}:4053"; var clientSettings = ClusterClientSettings.Create(system) .WithInitialContacts( new[] { ActorPath.Parse(targetNode + "/system/receptionist") }.ToImmutableHashSet() ); var clusterClient = system.ActorOf(ClusterClient.Props(clientSettings), "cluster-client"); // Publishes to given topic clusterClient.Tell(new ClusterClient.Publish("client-messages", new ConfigureRoles(workerNodeConfig, "worker"))); clusterClient.Tell(new ClusterClient.Publish("client-messages", new ConfigureRoles(listenerNodeConfig, "listener"))); // // Sends direct to known singleton proxy // clusterClient.Tell(new ClusterClient.Send("/user/manager", new ConfigureRoles(workerNodeConfig, "worker"))); // clusterClient.Tell(new ClusterClient.Send("/user/manager", new ConfigureRoles(listenerNodeConfig, "listener"))); Console.CancelKeyPress += async(sender, eventArgs) => { Console.WriteLine("Stopping Cluster Bootstrapper..."); await CoordinatedShutdown.Get(system).Run(); }; // Waits until service is terminated and then exits the program system.WhenTerminated.Wait(); logger.Information("Cluster Bootstrapper stopped"); Log.CloseAndFlush(); }
public void BasicConfigTest() { var cfg = CommonConfigs.BasicConfig(); cfg.GetBoolean("akka.suppress-json-serializer-warning").Should().Be(true); }
private void PublicApplicationLogon_Load(object sender, EventArgs e) { #region TEST //// List of strings for your names //List<string> allUsers = new List<string>(); //// create your domain context and define the OU container to search in //PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "DOMAINNAME", // "OU=SomeOU,dc=YourCompany,dc=com"); //// define a "query-by-example" principal - here, we search for a UserPrincipal (user) //UserPrincipal qbeUser = new UserPrincipal(ctx); //// create your principal searcher passing in the QBE principal //PrincipalSearcher srch = new PrincipalSearcher(qbeUser); //// find all matches //foreach (var found in srch.FindAll()) //{ // // do whatever here - "found" is of type "Principal" - it could be user, group, computer..... // allUsers.Add(found.DisplayName); //} //using (var context = new PrincipalContext(ContextType.Domain, "yourdomain.com")) //{ // using (var searcher = new PrincipalSearcher(new UserPrincipal(context))) // { // foreach (var result in searcher.FindAll()) // { // DirectoryEntry de = result.GetUnderlyingObject() as DirectoryEntry; // Console.WriteLine("First Name: " + de.Properties["givenName"].Value); // Console.WriteLine("Last Name : " + de.Properties["sn"].Value); // Console.WriteLine("SAM account name : " + de.Properties["samAccountName"].Value); // Console.WriteLine("User principal name: " + de.Properties["userPrincipalName"].Value); // Console.WriteLine(); // } // } //} //Console.ReadLine(); ////string plainText = "Lê Minh Hiệp"; ////// Convert the plain string pwd into bytes //////byte[] plainTextBytes = UnicodeEncoding.Unicode.GetBytes(plainText); //////System.Security.Cryptography.HashAlgorithm hashAlgo = new System.Security.Cryptography.SHA256Managed(); //////byte[] hash = hashAlgo.ComputeHash(plainTextBytes); ////byte[] data = UnicodeEncoding.Unicode.GetBytes(plainText); ////data = new System.Security.Cryptography.SHA256Managed().ComputeHash(data); ////String hash = UnicodeEncoding.Unicode.GetString(data); //////CustomMsgBox.Show(hash); #endregion TEST ////JUST FOR 4L FillingLine ONLY. SHOULD REMOVE NEXT TIME //CommonConfigs.AddUpdateAppSetting("ConfigID", ((int)GlobalVariables.FillingLine.Import).ToString()); try { if (!(int.TryParse(CommonConfigs.ReadSetting("ConfigID"), out GlobalVariables.ConfigID))) { throw new Exception("Please check ConfigID value in config file."); } UserPrincipal currentUserPrincipal = UserPrincipal.Current; if (currentUserPrincipal == null || currentUserPrincipal.Sid == null) { throw new Exception("Sorry, can not get current user principal!"); } this.baseRepository = CommonNinject.Kernel.Get <IBaseRepository>(); UserAPIs userAPIs = new UserAPIs(CommonNinject.Kernel.Get <IUserAPIRepository>()); IList <ActiveUser> activeUsers = userAPIs.GetActiveUsers(GlobalEnums.CBPP ? "S-1-5-21-2058209122-1687518253-2045704780-1001" : currentUserPrincipal.Sid.Value); if (activeUsers.Count > 0) { if (GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Smallpack || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Pail || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Medium4L || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Import || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Drum) { int?accessLevel = this.baseRepository.TotalSmartCodingEntities.GetAccessLevel(activeUsers[0].UserID, (int)TotalBase.Enums.GlobalEnums.NmvnTaskID.SmartCoding + (int)GlobalVariables.ConfigID, 0).Single(); if (accessLevel != (int)TotalBase.Enums.GlobalEnums.AccessLevel.Editable) { activeUsers = new List <ActiveUser>(); } this.comboUserID.Enabled = false; } else { this.Height = this.Height - 80; } } if (activeUsers.Count > 0) { this.comboSecurityIdentifier.Items.Add(activeUsers[0].UserName); this.comboSecurityIdentifier.SelectedIndex = 0; this.comboUserID.DataSource = activeUsers; this.comboUserID.DisplayMember = CommonExpressions.PropertyName <ActiveUser>(p => p.FullyQualifiedOrganizationalUnitName); this.comboUserID.ValueMember = CommonExpressions.PropertyName <ActiveUser>(p => p.UserID); FillingLineAPIs fillingLineAPIs = new FillingLineAPIs(CommonNinject.Kernel.Get <IFillingLineAPIRepository>()); this.comboFillingLineID.DataSource = fillingLineAPIs.GetFillingLineBases(); this.comboFillingLineID.DisplayMember = CommonExpressions.PropertyName <FillingLineBase>(p => p.Name); this.comboFillingLineID.ValueMember = CommonExpressions.PropertyName <FillingLineBase>(p => p.FillingLineID); if (GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Smallpack || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Pail || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Medium4L || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Import || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Drum) { this.comboFillingLineID.SelectedValue = GlobalVariables.ConfigID; } if (!(GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Smallpack || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Pail || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Medium4L || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Import || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Drum)) { this.labelFillingLineID.Visible = false; this.comboFillingLineID.Visible = false; } if (GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Drum) { this.checkGlobalDrumWithDigit.Visible = true; } this.comboComportName.DataSource = System.IO.Ports.SerialPort.GetPortNames(); if (this.comboComportName.Items.Count == 0) { this.comboComportName.DataSource = null; this.comboComportName.Items.Add("COM0"); } string comportName = CommonConfigs.ReadSetting("ComportName"); if (this.comboComportName.Items.IndexOf(comportName) >= 0) { this.comboComportName.SelectedIndex = this.comboComportName.Items.IndexOf(comportName); } this.buttonDownload.Visible = true; this.buttonLoginRestore.Visible = activeUsers[0].IsDatabaseAdmin; this.buttonConnectServer.Visible = activeUsers[0].IsDatabaseAdmin; this.buttonWebapi.Visible = activeUsers[0].IsDatabaseAdmin; this.buttonApplicationRoleIgnored.Visible = activeUsers[0].IsDatabaseAdmin; this.separatorResetApplicationRole.Visible = activeUsers[0].IsDatabaseAdmin; } else { this.comboSecurityIdentifier.Visible = false; this.comboUserID.Visible = false; this.comboFillingLineID.Visible = false; this.labelUserID.Visible = false; this.labelFillingLineID.Visible = false; this.labelSecurityIdentifier.Text = "\r\n" + "Sorry, user: "******"\r\n" + "Don't have permission to run this program." + "\r\n" + "\r\n" + "Contact your admin for more information. Thank you!" + "\r\n" + "\r\n" + "\r\n" + "Xin lỗi, bạn chưa được cấp quyền sử dụng phần mềm này."; this.buttonLogin.Visible = false; } if (ApplicationRoles.ExceptionMessage != null && ApplicationRoles.ExceptionMessage != "") { CustomMsgBox.Show(this, ApplicationRoles.ExceptionMessage, "Warning", MessageBoxButtons.OK); } this.buttonApplicationRoleRequired.Visible = !ApplicationRoles.Required; this.buttonApplicationRoleIgnored.Visible = ApplicationRoles.Required; } catch (Exception exception) { ExceptionHandlers.ShowExceptionMessageBox(this, exception); } }
private void buttonLoginExit_Click(object sender, EventArgs e) { try { if (sender.Equals(this.buttonExit)) { this.DialogResult = DialogResult.Cancel; return; } if (this.comboUserID.SelectedIndex >= 0) { ActiveUser activeUser = this.comboUserID.SelectedItem as ActiveUser; if (activeUser != null) { ContextAttributes.LocalIPAddress = this.GetLocalIPAddress(); ContextAttributes.User = new UserInformation(activeUser.UserID, activeUser.OrganizationalUnitID, activeUser.LocationID, activeUser.LocationName, activeUser.UserName, activeUser.SecurityIdentifier, activeUser.FullyQualifiedUserName, activeUser.IsDatabaseAdmin, new DateTime()); if (this.comboFillingLineID.Visible && (this.comboFillingLineID.SelectedIndex < 0 || this.comboComportName.SelectedIndex < 0)) { throw new System.ArgumentException("Vui lòng chọn chuyền sản xuất (NOF1, NOF2, NOF...), và chọn đúng cổng COM để chạy phần mềm"); // || (this.comboFillingLineID.Enabled && (GlobalVariables.ProductionLine)this.comboFillingLineID.SelectedValue == GlobalVariables.ProductionLine.SERVER) } if (this.comboFillingLineID.Visible) { GlobalVariables.FillingLineID = (GlobalVariables.FillingLine) this.comboFillingLineID.SelectedValue; GlobalVariables.FillingLineCode = ((FillingLineBase)this.comboFillingLineID.SelectedItem).Code; GlobalVariables.FillingLineName = ((FillingLineBase)this.comboFillingLineID.SelectedItem).Name; } else { GlobalVariables.FillingLineID = GlobalVariables.FillingLine.None; } if (GlobalVariables.FillingLineID == GlobalVariables.FillingLine.Drum) { TotalBase.Enums.GlobalEnums.GlobalDrumWithDigit = this.checkGlobalDrumWithDigit.Checked; } GlobalVariables.ComportName = (string)this.comboComportName.SelectedValue; CommonConfigs.AddUpdateAppSetting("ConfigID", (GlobalVariables.ConfigID).ToString()); CommonConfigs.AddUpdateAppSetting("ComportName", GlobalVariables.ComportName); if (CommonConfigs.ReadSetting("ReportServerUrl") == "") { CommonConfigs.AddUpdateAppSetting("ReportServerUrl", GlobalVariables.ReportServerUrl); //INIT NEW Setting IN CONFIG FILE } GlobalVariables.ReportServerUrl = CommonConfigs.ReadSetting("ReportServerUrl"); this.VersionValidate(); #region EMPTY DATABASE if (false && this.checkEmptyData.Checked) { this.baseRepository.ExecuteStoreCommand("DELETE FROM WarehouseAdjustmentDetails", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('WarehouseAdjustmentDetails', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM WarehouseAdjustments", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('WarehouseAdjustments', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM GoodsIssueTransferDetails", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('GoodsIssueTransferDetails', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM GoodsIssueDetails", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('GoodsIssueDetails', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM GoodsIssues", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('GoodsIssues', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM TransferOrderDetails", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('TransferOrderDetails', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM TransferOrders", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('TransferOrders', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM DeliveryAdviceDetails", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('DeliveryAdviceDetails', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM DeliveryAdvices", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('DeliveryAdvices', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM SalesOrderDetails", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('SalesOrderDetails', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM SalesOrders", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('SalesOrders', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM GoodsReceiptDetails", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('GoodsReceiptDetails', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM GoodsReceipts", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('GoodsReceipts', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM PickupDetails", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('PickupDetails', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM Pickups", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Pickups', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM Packs", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Packs', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM Cartons", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Cartons', RESEED, 0)", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DELETE FROM Pallets", new ObjectParameter[] { }); this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Pallets', RESEED, 0)", new ObjectParameter[] { }); //this.baseRepository.ExecuteStoreCommand("DELETE FROM Batches", new ObjectParameter[] { }); //this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Batches', RESEED, 0)", new ObjectParameter[] { }); //this.baseRepository.ExecuteStoreCommand("DELETE FROM Commodities", new ObjectParameter[] { }); //this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Commodities', RESEED, 0)", new ObjectParameter[] { }); } #endregion if (this.baseRepository.AutoUpdates(sender.Equals(this.buttonLoginRestore))) { this.DialogResult = DialogResult.OK; } else { CustomMsgBox.Show(this, "The program on this computer must be updated to the latest version." + "\r\n" + "\r\n" + "Contact your administrator for more information.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Stop); this.buttonDownload_Click(this.buttonDownload, new EventArgs()); } SmartLogDTO.Init(); } } } catch (Exception exception) { ExceptionHandlers.ShowExceptionMessageBox(this, exception); this.DialogResult = DialogResult.None; } }
//private CommonMetaList commonMetaList; private void PublicApplicationLogon_Load(object sender, EventArgs e) { #region TEST //// List of strings for your names //List<string> allUsers = new List<string>(); //// create your domain context and define the OU container to search in //PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "DOMAINNAME", // "OU=SomeOU,dc=YourCompany,dc=com"); //// define a "query-by-example" principal - here, we search for a UserPrincipal (user) //UserPrincipal qbeUser = new UserPrincipal(ctx); //// create your principal searcher passing in the QBE principal //PrincipalSearcher srch = new PrincipalSearcher(qbeUser); //// find all matches //foreach (var found in srch.FindAll()) //{ // // do whatever here - "found" is of type "Principal" - it could be user, group, computer..... // allUsers.Add(found.DisplayName); //} //using (var context = new PrincipalContext(ContextType.Domain, "yourdomain.com")) //{ // using (var searcher = new PrincipalSearcher(new UserPrincipal(context))) // { // foreach (var result in searcher.FindAll()) // { // DirectoryEntry de = result.GetUnderlyingObject() as DirectoryEntry; // Console.WriteLine("First Name: " + de.Properties["givenName"].Value); // Console.WriteLine("Last Name : " + de.Properties["sn"].Value); // Console.WriteLine("SAM account name : " + de.Properties["samAccountName"].Value); // Console.WriteLine("User principal name: " + de.Properties["userPrincipalName"].Value); // Console.WriteLine(); // } // } //} //Console.ReadLine(); ////////string plainText = "Lê Minh Hiệp"; ////////// Convert the plain string pwd into bytes //////////byte[] plainTextBytes = UnicodeEncoding.Unicode.GetBytes(plainText); //////////System.Security.Cryptography.HashAlgorithm hashAlgo = new System.Security.Cryptography.SHA256Managed(); //////////byte[] hash = hashAlgo.ComputeHash(plainTextBytes); ////////byte[] data = UnicodeEncoding.Unicode.GetBytes(plainText); ////////data = new System.Security.Cryptography.SHA256Managed().ComputeHash(data); ////////String hash = UnicodeEncoding.Unicode.GetString(data); //////////CustomMsgBox.Show(hash); #endregion TEST try { int.TryParse(CommonConfigs.ReadSetting("ConfigID"), out GlobalVariables.ConfigID); UserPrincipal currentUserPrincipal = UserPrincipal.Current; if (currentUserPrincipal == null || currentUserPrincipal.Sid == null) { throw new Exception("Sorry, can not get current user principal!"); } this.baseRepository = CommonNinject.Kernel.Get <IBaseRepository>(); UserAPIs userAPIs = new UserAPIs(CommonNinject.Kernel.Get <IUserAPIRepository>()); IList <ActiveUser> activeUsers = userAPIs.GetActiveUsers(GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Smallpack || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Pail ? "S-1-5-21-705987929-4194781227-356911358-1001" : "S-1-5-21-2907738014-1953812902-1740135539-2132-NTF"); //currentUserPrincipal.Sid.Value //throw new Exception(currentUserPrincipal.Sid.Value); if (activeUsers.Count > 0) { this.comboBoxEmployeeID.DataSource = activeUsers; this.comboBoxEmployeeID.DisplayMember = CommonExpressions.PropertyName <ActiveUser>(p => p.FullyQualifiedUserName); this.comboBoxEmployeeID.ValueMember = CommonExpressions.PropertyName <ActiveUser>(p => p.UserID); FillingLineAPIs fillingLineAPIs = new FillingLineAPIs(CommonNinject.Kernel.Get <IFillingLineAPIRepository>()); this.comboFillingLineID.DataSource = fillingLineAPIs.GetFillingLineBases(); this.comboFillingLineID.DisplayMember = CommonExpressions.PropertyName <FillingLineBase>(p => p.Name); this.comboFillingLineID.ValueMember = CommonExpressions.PropertyName <FillingLineBase>(p => p.FillingLineID); if (GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Smallpack || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Pail || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Drum) { this.comboFillingLineID.SelectedValue = GlobalVariables.ConfigID; } if (!(GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Smallpack || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Pail || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Drum)) { this.lbProductionLineID.Visible = false; this.comboFillingLineID.Visible = false; this.labelPassword.Top = this.lbEmployeeID.Top; this.textPassword.Top = this.comboBoxEmployeeID.Top; this.lbEmployeeID.Top = this.lbProductionLineID.Top; this.comboBoxEmployeeID.Top = this.comboFillingLineID.Top; } this.comboBoxAutonicsPortName.DataSource = System.IO.Ports.SerialPort.GetPortNames(); if (this.comboBoxAutonicsPortName.Items.Count == 0) { this.comboBoxAutonicsPortName.DataSource = null; this.comboBoxAutonicsPortName.Items.Add("COM0"); } string comportName = CommonConfigs.ReadSetting("ComportName"); if (this.comboBoxAutonicsPortName.Items.IndexOf(comportName) >= 0) { this.comboBoxAutonicsPortName.SelectedIndex = this.comboBoxAutonicsPortName.Items.IndexOf(comportName); } this.buttonDownload.Visible = true; this.buttonLoginRestore.Visible = activeUsers[0].IsDatabaseAdmin; } else { this.comboFillingLineID.Visible = false; this.comboBoxEmployeeID.Visible = false; this.lbEmployeeID.Visible = false; this.lbProductionLineID.Text = "\r\n" + "Sorry, user: "******"\r\n" + "Don't have permission to run this program." + "\r\n" + "\r\n" + "Contact your admin for more information. Thank you!" + "\r\n" + "\r\n" + "\r\n" + "Xin lỗi, bạn chưa được cấp quyền sử dụng phần mềm này."; this.buttonLogin.Visible = false; } } catch (Exception exception) { ExceptionHandlers.ShowExceptionMessageBox(this, exception); } }
private static void Run() { Log.Logger = LoggerFactory.Logger; Console.WriteLine("AkkaLibrary Test Harness."); var exitEvent = new ManualResetEvent(false); Console.CancelKeyPress += (sender, eventArgs) => { eventArgs.Cancel = true; exitEvent.Set(); }; var pluginSystem = PluginSystemFactory.NewPluginSystem("TestActorSystem", CommonConfigs.BasicConfig()); var registry = pluginSystem.PluginRegistryRef; var system = pluginSystem.System; //=================================================== var config = new TestPluginConfiguration { Name = "test-plugin" }; var testPlugin = pluginSystem.CreatePlugin(config); //=================================================== Console.WriteLine("Press Ctrl+C to terminate."); exitEvent.WaitOne(); var terminateTask = system.Terminate(); var success = terminateTask.Wait(TimeSpan.FromSeconds(5)); Log.Information($"Actor system terminated {(success ? "successfully" : "unsuccessfully")}."); Log.CloseAndFlush(); }