/// <summary> /// Get the Lowest Remaining Grace Period in Days /// </summary> /// <param name="licenses">List of Licenses to Check</param> /// <returns>Number of Days Remaining for the License that will expire first</returns> public static int LowestGraceDays(LicenseList licenses) { // Store Lowest Grace Period int lowestDays = 30; // Get List of All Licensed Licenses List <LicenseInstance> licenseFilter = licenses.GetListLicensed(); // Remove Permanently Activated Licenses foreach (LicenseInstance license in licenses.GetListPermanentlyActivated()) { if (licenseFilter.Contains(license)) { licenseFilter.Remove(license); } } // Check which license has the lowest remaining Grace Period foreach (LicenseInstance license in licenseFilter) { if (license.RemainingGraceDays >= lowestDays) { continue; } lowestDays = Convert.ToInt32(license.RemainingGraceDays); } return(lowestDays); }
public MainWindow() { InitializeComponent(); LicenseList.LoadLicenseList(LicenseDirectory); LicenseList.PushToComboBox(LicenseListComboBox); }
internal override object[] GetRow() { MedicalCertList medicalCertList = MedicalCertList.getInstance(); MedicalCert medicalCert = medicalCertList.getItem(this); string medicalCertStatus = ((medicalCert == null) || (!medicalCert.IsActual())) ? "нет" : "есть"; LicenseList licenseList = LicenseList.getInstance(); DriverLicense license = licenseList.getItem(this); string licenseStatus = ((license == null) || (!license.IsActual())) ? "нет" : "есть"; DriverCarList driverCarList = DriverCarList.getInstance(); Car car = driverCarList.GetCar(this); return(new object[] { Id, 0, GetName(NameType.Full), licenseStatus, medicalCertStatus, (car == null) ? "нет автомобиля" : car.ToString(), Region.Name, CompanyName, Status }); }
public formLicenseList(Driver driver) { InitializeComponent(); _driver = driver; _licencesList = LicenseList.getInstance(); }
public static LicenseList getInstance() { if (_uniqueInstance == null) _uniqueInstance = new LicenseList(); return _uniqueInstance; }
/// <summary> /// Check all Licenses for eligible Microsoft Windows Phone Activation and prompt for the Activation Code /// </summary> /// <param name="licenses">List of All Microsoft Windows Licenses</param> /// <param name="window">Active GUI Window</param> /// <returns>Activation Result of all Microsoft Windows Licenses</returns> public static string PhoneActivationQueryWindows(LicenseList licenses, IWin32Window window) { if (licenses is LicenseListOffice) { throw new ApplicationException("Cannot perform Microsoft Windows Phone Activation using Microsoft Office LicenseList!"); } return(PhoneActivationQuery(licenses, window)); }
/// <summary> /// Attempt Activation on each Microsoft Office License in a List /// </summary> /// <param name="licenses">List of all Licenses</param> /// <param name="minimalOutput">Reduce the Amount of Output During Activation</param> /// <param name="kmsServer">KMS Host to Connect To</param> /// <param name="kmsPort">KMS Port to Connect To</param> /// <param name="kmsPid">KMS PID to apply to KMSEmulator</param> /// <param name="kmsHwid">KMS Hardware ID to apply to KMSEmulator</param> /// <param name="useKMSEmulator">Start a KMSEmulator Process</param> /// <param name="removeKMSConnection">Remove KMS Host and Port after Activation</param> /// <param name="killProcessOnPort">Force Start KMSEmulator by Killing Other Processes usign the KMS Port</param> /// <param name="useDLLInjection">Use DLL Injection to Force Localhost KMS Activation</param> /// <param name="useTAPAdapter">Use TAP Adapter to Force Localhost KMS Activation</param> /// <param name="useWinDivert">Use WinDivert Client to Force Localhost KMS Activation</param> /// <param name="localHostBypassIPAddress">IP Address of TAP Adapter NIC or WinDivert Client</param> /// <param name="localHostBypassIPSubnet">Subnet Mask for TAP Adapter or WinDivert Client Network</param> /// <returns>Activation Result of all Microsoft Office Licenses</returns> public static string AttemptActivationOffice(LicenseList licenses, bool minimalOutput = false, string kmsServer = "127.0.0.2", int kmsPort = 1688, string kmsPid = "RandomKMSPID", string kmsHwid = "364F463A8863D35F", bool useKMSEmulator = true, bool removeKMSConnection = false, bool killProcessOnPort = false, bool useDLLInjection = false, bool useTAPAdapter = false, bool useWinDivert = false, string localHostBypassIPAddress = "10.3.0.1", string localHostBypassIPSubnet = "255.255.255.0") { // Call Windows if Microsoft Office uses Windows Licensing Services if (OfficeVersion.IsOfficeSPP()) { return(AttemptActivation(licenses, "SoftwareLicensingProduct.ID=", minimalOutput, kmsServer, kmsPort, kmsPid, kmsHwid, useKMSEmulator, removeKMSConnection, killProcessOnPort, useDLLInjection, useTAPAdapter, useWinDivert, localHostBypassIPAddress, localHostBypassIPSubnet)); } return(AttemptActivation(licenses, "OfficeSoftwareProtectionProduct.ID=", minimalOutput, kmsServer, kmsPort, kmsPid, kmsHwid, useKMSEmulator, removeKMSConnection, killProcessOnPort, useDLLInjection, useTAPAdapter, useWinDivert, localHostBypassIPAddress, localHostBypassIPSubnet)); }
private void FillDriverLicense() { LicenseList licencesList = LicenseList.getInstance(); DriverLicense driverLicense = licencesList.getItem(_driver); if (driverLicense != null) { licenceInfo.Text = driverLicense.ToString(); } }
private void driverLicenseToolStripMenuItem_Click(object sender, EventArgs e) { DTP dtp = _dtpList.getItem(Convert.ToInt32(_dgvDTP.Rows[_dgvDTP.SelectedCells[0].RowIndex].Cells[0].Value)); Driver driver = _driverCarList.GetDriver(dtp.Car, dtp.Date); LicenseList licencesList = LicenseList.getInstance(); DriverLicense driverLicense = licencesList.getItem(driver); WorkWithFiles.OpenFile(driverLicense.File); }
public override void Save() { DeleteFile(File); File = WorkWithFiles.fileCopyByID(File, "drivers", Driver.ID, "DriverLicense", Number); ExecSave(); LicenseList licenseList = LicenseList.getInstance(); licenseList.Add(this); }
private async void InsertLicenseClick(object sender, RoutedEventArgs e) { if (LicenseListComboBox.SelectedIndex != -1) { if (FileList.Items.Count > 0) { var boxResult = await this.ShowMessageAsync("Are you sure?", "We will now insert the license into all the files listed, are you sure?", MessageDialogStyle.AffirmativeAndNegative); if (boxResult != MessageDialogResult.Affirmative) { return; } var path = LicenseListComboBox.SelectedItem.ToString(); LicensePrinter.Email = EmailTextBlock.Text; LicensePrinter.Name = NameTextBlock.Text; LicensePrinter.Date = DateTextBlock.Text; var success = LicensePrinter.PrintLicense(LicenseList.GetFullFilename(path), CodeFileList.GetFiles()); if (success) { await this.ShowMessageAsync("Finished!", "We have inserted the license into all source files!"); } else { await this.ShowMessageAsync("Error!", "The program encountered an error and hasnt stamped the license."); } } else { await this.ShowMessageAsync("No Files!", "Please open some files to insert the license into."); } } else { await this.ShowMessageAsync("No License", "Please choose a license push it to your source files."); } }
private ToolStripMenuItem CreateShowDriverLicense() { ToolStripMenuItem item = CreateItem("Водительское удостоверение"); item.Click += delegate { if (_dgvMain.GetID() == 0) { return; } DateTime date = DateTime.Today; if (_mainStatus.Get() == Status.DTP) { DTPList dtpList = DTPList.getInstance(); DTP dtp = dtpList.getItem(_dgvMain.GetID()); date = dtp.Date; } Car car = _dgvMain.GetCar(); if (car == null) { return; } DriverCarList driverCarList = DriverCarList.getInstance(); Driver driver = driverCarList.GetDriver(car, date); LicenseList licencesList = LicenseList.getInstance(); DriverLicense driverLicense = licencesList.getItem(driver); if ((driverLicense != null) && (!string.IsNullOrEmpty(driverLicense.File))) { WorkWithFiles.openFile(driverLicense.File); } }; return(item); }
private void formatDGV() { _dgvDrivers.Columns[0].Visible = false; ResizeDGV(); foreach (DataGridViewRow row in _dgvDrivers.Rows) { int idDriver = 0; int.TryParse(row.Cells[0].Value.ToString(), out idDriver); Driver driver = driverList.getItem(idDriver); LicenseList licenseList = LicenseList.getInstance(); DriverLicense license = licenseList.getItem(driver); MedicalCertList medicalCertList = MedicalCertList.getInstance(); MedicalCert medicalCert = medicalCertList.getItem(driver); if (!license.IsActual() || !medicalCert.IsActual()) { row.DefaultCellStyle.BackColor = Color.LightYellow; } if (driver.Fired) { row.DefaultCellStyle.ForeColor = Color.Red; } if (((driver.OwnerID < 3) && (string.IsNullOrEmpty(driver.Number))) || (driver.Decret)) { row.DefaultCellStyle.ForeColor = Color.Blue; } if (driver.OwnerID > 2) { row.DefaultCellStyle.ForeColor = BBColors.bbGreen1; } } }
/// <summary> /// View the Status and Information of all Licenses /// </summary> /// <param name="licenses">List of all LicenseInstance</param> /// <param name="showCMID">Display Client Machine ID Once</param> /// <param name="showUnlicensed">Show Licenses with no installed Product Keys</param> /// <returns>String Representation of all Licenses</returns> public static string CheckActivation(LicenseList licenses, bool showCMID = false, bool showUnlicensed = false) { using (StringWriter output = new StringWriter()) { // Show Activation Errors if No Licenses or Keys Exist if (licenses.GetListLicensed().Count == 0 && licenses.GetListUnlicensed().Count > 0 && !showUnlicensed) { return(LicenseErrorCode.ErrKeyless); } if (licenses.GetListLicensed().Count == 0 && licenses.GetListUnlicensed().Count == 0) { return(LicenseErrorCode.ErrBroken); } // Show CMID if (showCMID) { output.WriteLine("---------------------------------------"); output.WriteLine("CMID: " + licenses.GetCMID()); } // Show Active Licenses foreach (LicenseInstance license in licenses.GetListLicensed()) { output.WriteLine("---------------------------------------"); output.WriteLine(license.ToString()); } // Show Inactive Licenses if (showUnlicensed) { foreach (LicenseInstance license in licenses.GetListUnlicensed()) { output.WriteLine("---------------------------------------"); output.WriteLine(license.ToString()); } } output.Write("---------------------------------------"); return(output.ToString()); } }
/// <summary> /// Install KMS Keys Automatically and Perform Activation of All KMS Licenses /// </summary> /// <param name="licenses">List of all Licenses</param> /// <param name="minimalOutput">Reduce the Amount of Output During Activation</param> /// <param name="kmsServer">KMS Host to Connect To</param> /// <param name="kmsPort">KMS Port to Connect To</param> /// <param name="kmsPid">KMS PID to apply to KMSEmulator</param> /// <param name="kmsHwid">KMS Hardware ID to apply to KMSEmulator</param> /// <param name="useKMSEmulator">Start a KMSEmulator Process</param> /// <param name="removeKMSConnection">Remove KMS Host and Port after Activation</param> /// <param name="killProcessOnPort">Force Start KMSEmulator by Killing Other Processes usign the KMS Port</param> /// <param name="useDLLInjection">Use DLL Injection to Force Localhost KMS Activation</param> /// <param name="useTAPAdapter">Use TAP Adapter to Force Localhost KMS Activation</param> /// <param name="useWinDivert">Use WinDivert Client to Force Localhost KMS Activation</param> /// <param name="localHostBypassIPAddress">IP Address of TAP Adapter NIC or WinDivert Client</param> /// <param name="localHostBypassIPSubnet">Subnet Mask for TAP Adapter or WinDivert Client Network</param> /// <returns>Activation Result of all KMS Licenses</returns> public static string RunEZActivator(LicenseList licenses, bool minimalOutput = true, string kmsServer = "127.0.0.2", int kmsPort = 1688, string kmsPid = "RandomKMSPID", string kmsHwid = "364F463A8863D35F", bool useKMSEmulator = true, bool removeKMSConnection = false, bool killProcessOnPort = false, bool useDLLInjection = false, bool useTAPAdapter = false, bool useWinDivert = false, string localHostBypassIPAddress = "10.3.0.1", string localHostBypassIPSubnet = "255.255.255.0") { // Show Activation Errors if No Licenses Exist if (licenses.GetListUnlicensed().Count == 0 && licenses.GetListLicensed().Count == 0) { return(LicenseErrorCode.ErrBroken); } // Show Activation Errors if No KMS Licenses Exist if (licenses.GetListKMS().Count == 0) { return(LicenseErrorCode.ErrNoKMS); } using (StringWriter output = new StringWriter()) { // Activated Windows Check if (licenses is LicenseListWindows && licenses.GetListPermanentlyActivated().Count > 0) { output.WriteLine("----------------------------------------"); output.WriteLine("Windows is already permanently activated."); output.WriteLine("----------------------------------------"); return(output.ToString()); } // Get All Possible KMS Keys KeyList keys = new KeyList(); if (licenses is LicenseListOffice) { keys = KeyBase.GetApplicableKeysList(OfficeVersion.GetOfficeName()); } else if (licenses is LicenseListWindows) { keys = KeyBase.GetApplicableKeysList(OSVersion.GetWindowsName()); } // Remove Trial Keys bool removedTrialKeys = false; output.WriteLine("----------------------------------------"); output.WriteLine("Removing Any Trial/Grace Keys."); foreach (LicenseInstance licenseKeys in licenses.GetListLicensed()) { if (licenseKeys.LicenseDescription.ToUpper().Contains("TRIAL") || licenseKeys.LicenseDescription.ToUpper().Contains("GRACE")) { if (licenses is LicenseListOffice) { KeyInstaller.UnInstallKeyByKeyOffice(licenseKeys.PartialProductKey); output.WriteLine("Removed Key for: " + licenseKeys.LicenseFamily + " (" + licenseKeys.PartialProductKey + ")."); removedTrialKeys = true; } else if (licenses is LicenseListWindows) { KeyInstaller.UnInstallKeyByKeyOffice(licenseKeys.PartialProductKey); output.WriteLine("Removed Key for: " + licenseKeys.LicenseFamily + " (" + licenseKeys.PartialProductKey + ")."); removedTrialKeys = true; } } } if (removedTrialKeys) { licenses.Refresh(); } // Install Uninstalled KMS Keys by SKUID Match bool installedKMSKeys = false; output.WriteLine("----------------------------------------"); output.WriteLine("Installing Any Matching Volume Keys."); if (licenses is LicenseListWindows && OSVersion.GetWindowsNumber() >= 10 && OSVersion.GetWindowsBuildNumber() >= 14393) { // Determine KMS Key if (licenses.GetListLicensed().Count > 0) { // SKU Match Existing Key foreach (LicenseInstance license in licenses.GetListLicensed()) { string editionId = license.LicenseFamily; try { // Check Key bool installKey = true; List <string> skuidListMatched = keys.GetSKUIDs(editionId); foreach (LicenseInstance licensed in licenses.GetListLicensed()) { if (skuidListMatched.Contains(licensed.SKUID)) { installKey = false; break; } } // Install Key if (installKey) { // Get All SKUIDs List <string> skuidListAll = new List <string>(); foreach (LicenseInstance licensed in licenses.GetListFull()) { skuidListAll.Add(licensed.SKUID); } // Get Matched Key foreach (string skuid in skuidListMatched) { if (skuidListAll.Contains(skuid)) { output.WriteLine("Installing " + keys.GetProductName(skuid) + " KMS Key (" + keys.GetProductKey(skuid) + ")."); KeyInstaller.InstallKeyWindows(keys.GetProductKey(skuid)); output.WriteLine("<Product key installation successful>"); installedKMSKeys = true; break; } } } } catch (Exception ex) { output.WriteLine(ex.Message); } } } else { // Edition ID Check using (RegistryKey registrySubKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64).OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", true)) { if (registrySubKey != null && registrySubKey.GetValue("EditionID") != null) { string editionId = registrySubKey.GetValue("EditionID").ToString(); try { if (keys.GetProductKey(editionId) != string.Empty) { output.WriteLine("Installing " + keys.GetProductName(editionId) + " KMS Key (" + keys.GetProductKey(editionId) + ")."); KeyInstaller.InstallKeyWindows(keys.GetProductKey(editionId)); output.WriteLine("<Product key installation successful>"); installedKMSKeys = true; } } catch (Exception ex) { output.WriteLine(ex.Message); } } } } } else { foreach (LicenseInstance license in licenses.GetListUnlicensed()) { if (keys.GetSKUIDs().Contains(license.SKUID)) { try { output.WriteLine("Installing " + keys.GetProductName(license.SKUID) + " KMS Key (" + keys.GetProductKey(license.SKUID) + ")."); if (licenses is LicenseListOffice) { KeyInstaller.InstallKeyOffice(keys.GetProductKey(license.SKUID)); output.WriteLine("<Product key installation successful>"); installedKMSKeys = true; } else if (licenses is LicenseListWindows) { KeyInstaller.InstallKeyWindows(keys.GetProductKey(license.SKUID)); output.WriteLine("<Product key installation successful>"); installedKMSKeys = true; } } catch (Exception ex) { output.WriteLine(ex.Message); } } } } output.WriteLine("----------------------------------------"); if (installedKMSKeys) { licenses.Refresh(); } // Perform Activation if (licenses is LicenseListOffice) { output.WriteLine("Attempting To Activate Microsoft Office"); output.Write(ActivationState.AttemptActivationOffice(licenses, minimalOutput, kmsServer, kmsPort, kmsPid, kmsHwid, useKMSEmulator, removeKMSConnection, killProcessOnPort, useDLLInjection, useTAPAdapter, useWinDivert, localHostBypassIPAddress, localHostBypassIPSubnet)); } else if (licenses is LicenseListWindows) { output.WriteLine("Attempting To Activate Microsoft Windows"); output.Write(ActivationState.AttemptActivationWindows(licenses, minimalOutput, kmsServer, kmsPort, kmsPid, kmsHwid, useKMSEmulator, removeKMSConnection, killProcessOnPort, useDLLInjection, useTAPAdapter, useWinDivert, localHostBypassIPAddress, localHostBypassIPSubnet)); } return(output.ToString()); } }
public void RefreshLicenseList() { LicenseList.LoadLicenseList(LicenseDirectory); LicenseList.PushToComboBox(LicenseListComboBox); }
/// <summary> /// Check all Licenses for eligible Phone Activation and prompt for the Activation Code /// </summary> /// <param name="licenses">List of All Licenses</param> /// <param name="window">Active GUI Window</param> /// <returns>Activation Result of all Licenses</returns> private static string PhoneActivationQuery(LicenseList licenses, IWin32Window window) { using (StringWriter output = new StringWriter()) { // Get Unactivated Licenses List <LicenseInstance> licenseFilter = licenses.GetListUnactivated(); // Remove KMS Licenses foreach (LicenseInstance license in licenses.GetListKMS()) { if (licenseFilter.Contains(license)) { licenseFilter.Remove(license); } } // Remove Unlicensed Licenses foreach (LicenseInstance license in licenses.GetListUnlicensed()) { if (licenseFilter.Contains(license)) { licenseFilter.Remove(license); } } // Activate Each License and Save ConfirmationID output.WriteLine("---Processing--------------------------"); output.Write("----------------------------------------"); // Return if No Licenses are Applicable if (licenseFilter.Count == 0) { output.WriteLine(); output.Write("<No applicable products detected>" + Environment.NewLine + "----------------------------------------"); return(output.ToString()); } // Phone Activate All Licenses foreach (LicenseInstance license in licenseFilter) { // Set Activation Success Flag bool success = false; // Get Confirmation ID string currentCID = AskForConfirmationID(license.OfflineInstallationID, window); if (String.IsNullOrWhiteSpace(currentCID)) { output.WriteLine(); output.Write("Blank or invalid Confirmation ID!" + Environment.NewLine + "----------------------------------------"); continue; } output.WriteLine(); output.WriteLine("Installed product key detected - attempting to activate the following product:"); output.WriteLine("Name: " + license.LicenseName); output.WriteLine("Description: " + license.LicenseDescription); output.WriteLine("SKU ID: " + license.SKUID); output.WriteLine("Last 5 characters of installed product key: " + license.PartialProductKey); if (licenses is LicenseListOffice) { success = PhoneActivationOffice(currentCID, license.OfflineInstallationID, license.SKUID); } else if (licenses is LicenseListWindows) { success = PhoneActivationWindows(currentCID, license.OfflineInstallationID, license.SKUID); } // Check if Successful Activation if (success) { SaveConfirmationID(license.OfflineInstallationID, currentCID); output.Write("<Product activation successful>" + Environment.NewLine + "----------------------------------------"); } else { output.Write("<Product activation failed>" + Environment.NewLine + "----------------------------------------"); } } return(output.ToString()); } }
/* Старое извещение * public void showNotice(DTP dtp) * { * _excelDoc = openDocumentExcel("Извещение о страховом случае"); * * Owners owners = Owners.getInstance(); * * _excelDoc.setValue(7, 4, owners.getItem(Convert.ToInt32(_car.ownerID))); * _excelDoc.setValue(8, 5, "а/я 34, 196128"); * _excelDoc.setValue(9, 6, "320-40-04"); * * DriverCarList driverCarList = DriverCarList.getInstance(); * Driver driver = driverCarList.GetDriver(_car, dtp.Date); * * PassportList passportList = PassportList.getInstance(); * Passport passport = passportList.getLastPassport(driver); * * if (passport.Number != string.Empty) * { * string number = passport.Number; * string[] numbers = number.Split(' '); * * _excelDoc.setValue(11, 2, numbers[0]); * _excelDoc.setValue(11, 5, numbers[1]); * * _excelDoc.setValue(12, 2, passport.GiveOrg); * _excelDoc.setValue(13, 3, passport.GiveDate.ToShortDateString()); * } * * PolicyList policyList = PolicyList.getInstance(); * Policy policy = policyList.getItem(_car, PolicyType.КАСКО); * _excelDoc.setValue(15, 5, policy.Number); * * _excelDoc.setValue(17, 5, string.Concat(_car.Mark.Name, " ", _car.info.Model)); * _excelDoc.setValue(19, 5, _car.Grz); * _excelDoc.setValue(21, 5, _car.vin); * * _excelDoc.setValue(23, 5, dtp.Date.ToShortDateString()); * * _excelDoc.setValue(28, 1, driver.GetName(NameType.Full)); * * Regions regions = Regions.getInstance(); * * _excelDoc.setValue(30, 2, regions.getItem(Convert.ToInt32(dtp.IDRegion))); * _excelDoc.setValue(32, 13, dtp.Damage); * _excelDoc.setValue(34, 1, dtp.Facts); * * SsDTP ssDTP = SsDTPList.getInstance().getItem(_car.Mark); * * _excelDoc.setValue(63, 11, ssDTP.ServiceStantion); * * DateTime date = DateTime.Today; * MyDateTime myDate = new MyDateTime(date.ToShortDateString()); * * _excelDoc.setValue(71, 3, string.Concat("« ", date.Day.ToString(), " »")); * _excelDoc.setValue(71, 4, myDate.MonthToStringGenitive()); * _excelDoc.setValue(71, 8, date.Year.ToString().Substring(2, 2)); * * _excelDoc.Show(); * } * */ public void CreateWaybill(DateTime date, Driver driver = null) { date = new DateTime(date.Year, date.Month, 1); if (driver == null) { var driverCarList = DriverCarList.getInstance(); driver = driverCarList.GetDriver(_car, date); if (driver == null) { driver = driverCarList.GetDriver(_car); var invoiceList = InvoiceList.getInstance(); var invoice = invoiceList.getItem(_car); if (!string.IsNullOrEmpty(invoice?.DateMove)) { DateTime.TryParse(invoice.DateMove, out DateTime dateMove); if (dateMove.Year == date.Year && dateMove.Month == date.Month) { date = new DateTime(date.Year, date.Month, dateMove.Day); } } } } _excelDoc = openDocumentExcel("Путевой лист"); _excelDoc.setValue(4, 28, _car.BBNumber); var myDate = new MyDateTime(date.ToShortDateString()); _excelDoc.setValue(4, 39, driver.Id + "/01/" + myDate.MonthSlashYear()); _excelDoc.setValue(6, 15, myDate.DaysRange); _excelDoc.setValue(6, 19, myDate.MonthToStringNominative()); _excelDoc.setValue(6, 32, date.Year.ToString()); _excelDoc.setValue(29, 35, _car.info.Grade.EngineType.ShortName); var mml = new MileageMonthList(_car.Id, date.Year + "-" + date.Month + "-01"); /* Из файла Татьяны Мироновой пробег за месяц */ _excelDoc.setValue(19, 39, mml.PSN); _excelDoc.setValue(33, 41, mml.Gas); _excelDoc.setValue(35, 41, mml.GasBegin); _excelDoc.setValue(36, 41, mml.GasEnd); _excelDoc.setValue(37, 41, mml.GasNorm); _excelDoc.setValue(38, 41, mml.GasNorm); _excelDoc.setValue(43, 39, mml.PSK); _excelDoc.setValue(41, 59, mml.Mileage); var owners = Owners.getInstance(); var owner = owners.getItem(1); _excelDoc.setValue(8, 8, owner); _excelDoc.setValue(10, 11, string.Concat(_car.Mark.Name, " ", _car.info.Model)); _excelDoc.setValue(11, 17, _car.Grz); _excelDoc.setValue(12, 6, driver.GetName(NameType.Full)); _excelDoc.setValue(44, 16, driver.GetName(NameType.Short)); _excelDoc.setValue(26, 40, driver.GetName(NameType.Short)); var licencesList = LicenseList.getInstance(); var driverLicense = licencesList.getItem(driver); _excelDoc.setValue(14, 10, driverLicense.Number); _excelDoc.setValue(20, 9, owner); string suppyAddressName; if (driver.suppyAddress != string.Empty) { suppyAddressName = driver.suppyAddress; } else { var suppyAddressList = SuppyAddressList.getInstance(); var suppyAddress = suppyAddressList.getItemByRegion(driver.Region.Id); if (suppyAddress != null) { suppyAddressName = suppyAddress.ToString(); } else { var passportList = PassportList.getInstance(); var passport = passportList.getLastPassport(driver); suppyAddressName = passport.Address; } } var suppyAddressName2 = string.Empty; if (suppyAddressName.Length > 40) { for (var i = 30; i < suppyAddressName.Length; i++) { if (suppyAddressName[i] == ' ') { suppyAddressName2 = suppyAddressName.Substring(i, suppyAddressName.Length - i); suppyAddressName = suppyAddressName.Substring(0, i); } } } _excelDoc.setValue(25, 8, suppyAddressName); _excelDoc.setValue(26, 1, suppyAddressName2); string mechanicName; var employeesList = EmployeesList.getInstance(); var accountant = employeesList.getItem(driver.Region, "Бухгалтер Б.Браун"); if (driver.IsOne) { mechanicName = driver.GetName(NameType.Short); } else { var mechanic = employeesList.getItem(driver.Region, "Механик", true); mechanicName = mechanic == null ? driver.GetName(NameType.Short) : mechanic.Name; } var dispatcher = employeesList.getItem(driver.Region, "Диспечер-нарядчик"); var dispatcherName = dispatcher.Name; _excelDoc.setValue(22, 40, mechanicName); _excelDoc.setValue(44, 40, mechanicName); _excelDoc.setValue(31, 18, dispatcherName); _excelDoc.setValue(35, 18, dispatcherName); _excelDoc.setValue(43, 72, accountant.Name); }
private void Setup() { dialog.Filter = "XML files (*.xml)|*.xml"; openDialog.Filter = "XML files (*.xml)|*.xml"; lstProduct = ObjectXMLSerializer<ProductList>.Load("products.xml",new Type[]{ typeof(Product)}); lstCustomers = ObjectXMLSerializer<CustomerList>.Load("customers.xml", new Type[] { typeof(Customer) }); lstLicenses = ObjectXMLSerializer<LicenseList>.Load("licenses.xml", new Type[] { typeof(License) }); }
static void Main(string[] args) { DataBase.InitDataBase(); Provider.InitSQLProvider(); LogManager.Logger.Debug("Program started"); /* старые командировки */ //IExcelImporter importer = new BusinessTripFromExcelFile { FilePath = @"\\bbmru08\depts\Accounting\Командировки\Реестр_" + DateTime.Today.Year + ".xls" }; //BusinessTripFromExcelFile importer1 = new BusinessTripFromExcelFile { FilePath = @"\\bbmru08\1cv77\Autoexchange\Lotus\BBAuto" }; //importer1.StartImport(); //LogManager.Logger.Debug("BusinessTrip loading done"); ///* Сделать загрузку вручную */ ////importer = new MileageMonthFromExcelFile { FilePath = @"J:\Hospital Care\Kasyanova Tatyana\Отчёты\Командировки в BBAuto\Загрузка Перечень сотрудников для заполнения ПЛ на мес.xlsx" }; ////importer.StartImport(); ////LogManager.Logger.Debug("Mileage Month loading done"); IExcelImporter importer = new EmployeesFrom1C { FilePath = @"\\bbmru08\1cv77\Autoexchange\Lotus\BBAuto" }; importer.StartImport(); LogManager.Logger.Debug("EmployeesFrom1C loading done"); //importer = new TabelFrom1C { FilePath = @"\\bbmru08\1cv77\Autoexchange\Lotus\BBAuto\Time" }; //importer.StartImport(); //LogManager.Logger.Debug("TabelFrom1C loading done"); var medicalCertList = MedicalCertList.getInstance(); var medicalCertSender = new NotificationSender(medicalCertList); //medicalCertSender.SendNotification(); //medicalCertSender.ClearStopIfNeed(); medicalCertSender.SendNotificationOverdue(); //medicalCertSender.SendNotificationNotExist(); //LogManager.Logger.Debug("MedicalCerts sent"); var licenseList = LicenseList.getInstance(); var licenceSender = new NotificationSender(licenseList); //licenceSender.SendNotification(); licenceSender.SendNotificationOverdue(); licenceSender.SendNotificationNotExist(); LogManager.Logger.Debug("Licenses sent"); //var policySender = new PolicyListSender(); //policySender.SendNotification(); //LogManager.Logger.Debug("Policies sent"); //var diagCardSender = new DiagCardSender(); //diagCardSender.SendNotification(); //LogManager.Logger.Debug("DiagCards sent"); //var violationSender = new ViolationSender(); //violationSender.SendNotification(); //LogManager.Logger.Debug("Violations sent"); //var accountSender = new AccountSender(); //accountSender.SendNotification(); //LogManager.Logger.Debug("Accounts sent"); LogManager.Logger.Debug("Program finished"); }
/// <summary> /// Attempt Activation on each License in a List /// </summary> /// <param name="licenses">List of all Licenses</param> /// <param name="minimalOutput">Reduce the Amount of Output During Activation</param> /// <param name="wmiInfo">WMI Provider and associated data to attempt Activation</param> /// <param name="kmsServer">KMS Host to Connect To</param> /// <param name="kmsPort">KMS Port to Connect To</param> /// <param name="kmsPid">KMS PID to apply to KMSEmulator</param> /// <param name="kmsHwid">KMS Hardware ID to apply to KMSEmulator</param> /// <param name="useKMSEmulator">Start a KMSEmulator Process</param> /// <param name="removeKMSConnection">Remove KMS Host and Port after Activation</param> /// <param name="killProcessOnPort">Force Start KMSEmulator by Killing Other Processes usign the KMS Port</param> /// <param name="useDLLInjection">Use DLL Injection to Force Localhost KMS Activation</param> /// <param name="useTAPAdapter">Use TAP Adapter to Force Localhost KMS Activation</param> /// <param name="useWinDivert">Use WinDivert Client to Force Localhost KMS Activation</param> /// <param name="localHostBypassIPAddress">IP Address of TAP Adapter NIC or WinDivert Client</param> /// <param name="localHostBypassIPSubnet">Subnet Mask for TAP Adapter or WinDivert Client Network</param> /// <returns>Activation Result of all Licenses</returns> private static string AttemptActivation(LicenseList licenses, string wmiInfo, bool minimalOutput = false, string kmsServer = "127.0.0.2", int kmsPort = 1688, string kmsPid = "RandomKMSPID", string kmsHwid = "364F463A8863D35F", bool useKMSEmulator = true, bool removeKMSConnection = false, bool killProcessOnPort = false, bool useDLLInjection = false, bool useTAPAdapter = false, bool useWinDivert = false, string localHostBypassIPAddress = "10.3.0.1", string localHostBypassIPSubnet = "255.255.255.0") { using (StringWriter output = new StringWriter()) { // Show Activation Errors if No Licenses or Keys Exist if (licenses.GetListUnlicensed().Count == 0 && licenses.GetListLicensed().Count == 0) { return(LicenseErrorCode.ErrBroken); } if (licenses.GetListUnlicensed().Count > 0 && licenses.GetListLicensed().Count == 0) { return(LicenseErrorCode.ErrKeyless); } // Get Firewall Parameters string programName = CommonUtilities.EscapePath(System.Reflection.Assembly.GetEntryAssembly().GetName().Name); string programLocation = CommonUtilities.EscapePath(Process.GetCurrentProcess().MainModule.FileName); // Delete Block Firewall Rules CommonUtilities.ExecuteCommand("netsh advfirewall firewall delete rule name=all program=" + programLocation, true); CommonUtilities.ExecuteCommand("netsh advfirewall firewall delete rule name=all localport=" + kmsPort, true); // Add Allow Firewall Rules CommonUtilities.ExecuteCommand("netsh advfirewall firewall add rule name=" + programName + " dir=in program=" + programLocation + " localport=" + kmsPort + " protocol=TCP action=allow remoteip=any", true); CommonUtilities.ExecuteCommand("netsh advfirewall firewall add rule name=" + programName + " dir=out program=" + programLocation + " localport=" + kmsPort + " protocol=TCP action=allow remoteip=any", true); // Setup Localhost Bypass for KMS V6 if (OSVersion.GetWindowsNumber() >= 6.3 && ((licenses is LicenseListOffice && OfficeVersion.GetOfficeNumber() >= 15) || (licenses is LicenseListWindows))) { // Disable KMS Online Validation KMSConnection.DisableKMSGenuineChecks(); // Use Localhost Bypass for Loopback IP Addresses or Machine Name if (Regex.IsMatch(kmsServer.ToLower(), @"^(127(\.\d+){1,3}|[0:]+1|localhost)$") || String.Compare(kmsServer, Environment.MachineName, StringComparison.InvariantCultureIgnoreCase) == 0) { if (useDLLInjection) { // Disable Other Bypasses useTAPAdapter = false; useWinDivert = false; try { KMSDLLInjection.Initialize(localHostBypassIPAddress); /* * if (!KMSDLLInjection.LoadDLL()) * { * output.WriteLine("Failed to inject LocalHost Bypass DLL."); * } * else * { * kmsServer = localHostBypassIPAddress; * } */ KMSDLLInjection.LoadDLLIFEO(); kmsServer = localHostBypassIPAddress; } catch (Exception ex) { output.WriteLine("Failed to inject LocalHost Bypass DLL."); output.WriteLine(ex.Message); } } else if (useTAPAdapter) { // Disable Other Bypasses useWinDivert = false; // Check Installed TAP Adapter Count if (KMSTAPDriver.GetTAPDeviceCount() > 1) { output.WriteLine("WARNING: You have more than 1 TAP Adapter installed."); } // Initialize TAP Driver KMSTAPDriver.Initialize(localHostBypassIPAddress, localHostBypassIPSubnet); // Check and Set IP Address string tapIP = KMSTAPDriver.GetTAPDeviceIPAddress(); string tapSubnet = KMSTAPDriver.GetTAPDeviceIPSubnet(); if (tapIP == string.Empty || Regex.IsMatch(tapIP, @"^(169\.254\.([0,1]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\.([0,1]?[0-9]{1,2}|2[0-4][0-9]|25[0-5]))$")) { output.WriteLine("Failed to set IP Address on TAP Adapter. It may already be in use."); } else if (tapIP != localHostBypassIPAddress || tapSubnet != localHostBypassIPSubnet) { KMSTAPDriver.SetTAPDeviceIPConfiguration(localHostBypassIPAddress, localHostBypassIPSubnet); output.WriteLine("Failed to update IP Address Configuration on TAP Adapter."); } else { // Set KMS Server to Valid TAP IP Address kmsServer = KMSTAPDriver.GetTAPDeviceUsableIPAddress(); // Start TAP Listener KMSTAPDriver.Start(); } } else if (useWinDivert) { // Start WinDivert KMSWinDivert.StartWinDivertClient(localHostBypassIPAddress, localHostBypassIPSubnet); kmsServer = localHostBypassIPAddress; } } else { // Disable Localhost Bypass useDLLInjection = false; useTAPAdapter = false; useWinDivert = false; } } else { // Disable Localhost Bypass useDLLInjection = false; useTAPAdapter = false; useWinDivert = false; } // Set KMS Server try { if (licenses is LicenseListOffice) { KMSConnection.SetKMSHostOffice(licenses, kmsServer); } else if (licenses is LicenseListWindows) { KMSConnection.SetKMSHostWindows(licenses, kmsServer); } } catch (Exception ex) { output.WriteLine("Failed to set KMS Host!"); output.WriteLine(ex.Message); } // Set KMS Port try { if (licenses is LicenseListOffice) { KMSConnection.SetKMSPortOffice(licenses, kmsPort.ToString(CultureInfo.InvariantCulture)); } else if (licenses is LicenseListWindows) { KMSConnection.SetKMSPortWindows(licenses, kmsPort.ToString(CultureInfo.InvariantCulture)); } } catch (Exception ex) { output.WriteLine("Failed to set KMS Port"); output.WriteLine(ex.Message); } // Start KMSEmulator if (useKMSEmulator) { try { // Set KMS Server Settings KMSServerSettings settings = new KMSServerSettings { KillProcessOnPort = killProcessOnPort, Port = kmsPort }; // Handle KMS PID Generation if (kmsPid == "ReuseKMSPID") { // Check Licenses for Existing KMS PID foreach (LicenseInstance license in licenses.GetListLicensed()) { if (!String.IsNullOrWhiteSpace(license.KMSServerExtendedPID)) { // Found Existing KMS PID kmsPid = license.KMSServerExtendedPID; settings.DefaultKMSPID = license.KMSServerExtendedPID; settings.GenerateRandomKMSPID = false; break; } } // Did Not Find Existing KMS PID if (kmsPid == "ReuseKMSPID") { // Generate Random KMS PID settings.GenerateRandomKMSPID = true; } } else if (kmsPid == "RandomKMSPID") { // Generate Random KMS PID settings.GenerateRandomKMSPID = true; } else { // Use Static KMS PID settings.GenerateRandomKMSPID = false; // Set Static KMS PID if it is not Default KMS PID if (kmsPid != "DefaultKMSPID") { settings.DefaultKMSPID = kmsPid; } } // Handle KMS HWID settings.DefaultKMSHWID = kmsHwid; // Handle Client Count if (licenses is LicenseListOffice || OSVersion.IsWindowsServer()) { settings.CurrentClientCount = 5; } else { settings.CurrentClientCount = 25; } // Start KMS Server KMSServer.Start(null, settings); } catch (SocketException) { output.WriteLine("Failed to start KMS Emulator!"); output.WriteLine("KMS Port may be in use."); } catch (Exception ex) { output.WriteLine("Failed to start KMS Emulator!"); output.WriteLine(ex.Message); } } // Attempt Activation on Each License if (minimalOutput == false) { output.WriteLine("---Processing--------------------------"); output.WriteLine("----------------------------------------"); } bool firstLine = true; foreach (LicenseInstance license in licenses.GetListLicensed()) { // Add Extra Line if Needed if (firstLine) { firstLine = false; } else { output.WriteLine(); } if (minimalOutput == false) { output.WriteLine("Installed product key detected - attempting to activate the following product:"); output.WriteLine("Name: " + license.LicenseName); output.WriteLine("Description: " + license.LicenseDescription); output.WriteLine("Family: " + license.LicenseFamily); output.WriteLine("SKU ID: " + license.SKUID); output.WriteLine("Last 5 characters of installed product key: " + license.PartialProductKey); } else { output.WriteLine("Attempting to Activate " + license.LicenseFamily); } using (ManagementObject classInstance = new ManagementObject("root\\CIMV2", wmiInfo + "'" + license.SKUID + "'", null)) { string errorCode = string.Empty; for (int i = 0; i < 10; i++) { try { classInstance.InvokeMethod("Activate", null, null); output.WriteLine("<Product activation successful>"); output.Write("----------------------------------------"); errorCode = string.Empty; break; } catch (COMException ex) { // Get Activation Error errorCode = "0x" + ex.ErrorCode.ToString("X8"); if (errorCode == "0xC004F074" && (useDLLInjection || useTAPAdapter || useWinDivert)) { if (useDLLInjection) { // Kill KMS Connection Broker CommonUtilities.KillProcess("SppExtComObj"); } continue; } break; } } // Show Activation Error if (errorCode != string.Empty) { output.WriteLine("ERROR CODE: " + errorCode); output.WriteLine("ERROR TEXT: " + LicenseErrorCode.GetErrorDescription(errorCode)); if (errorCode == "0xC004F059" || errorCode == "0xC004F035") { output.WriteLine("WARNING: It will be impossible to activate via KMS due to OEM BIOS issues."); } output.WriteLine("<Product activation failed>"); output.Write("----------------------------------------"); } } } // Stop LocalHost Bypass if (useDLLInjection) { /* * if (!KMSDLLInjection.UnloadDLL()) * { * output.Write(Environment.NewLine + "Failed to eject LocalHost Bypass DLL."); * } */ try { KMSDLLInjection.UnloadDLLIFEO(); } catch (Exception ex) { output.Write(Environment.NewLine + "Failed to eject LocalHost Bypass DLL."); output.Write(Environment.NewLine + ex.Message); } } else if (useTAPAdapter) { KMSTAPDriver.Unload(); } else if (useWinDivert) { KMSWinDivert.StopWinDivertClient(); } // Stop KMSEmulator if (useKMSEmulator) { try { KMSServer.Stop(); } catch (Exception ex) { output.WriteLine("Failed to stop KMS Emulator!"); output.WriteLine(ex.Message); } } // Remove KMS Server if (removeKMSConnection) { // Remove KMS Host try { if (licenses is LicenseListOffice) { KMSConnection.RemoveKMSHostOffice(licenses); } else if (licenses is LicenseListWindows) { KMSConnection.RemoveKMSHostWindows(licenses); } } catch (Exception ex) { output.WriteLine("Failed to remove KMS Host from registry!"); output.WriteLine(ex.Message); } // Remove KMS Port try { if (licenses is LicenseListOffice) { KMSConnection.RemoveKMSPortOffice(licenses); } else if (licenses is LicenseListWindows) { KMSConnection.RemoveKMSPortWindows(licenses); } } catch (Exception ex) { output.WriteLine("Failed to remove KMS Port from registry!"); output.WriteLine(ex.Message); } } // Delete Allow Firewall Rules CommonUtilities.ExecuteCommand("netsh advfirewall firewall delete rule name=" + programName, true); // Read WinDivert Log if (useWinDivert && KMSWinDivert.Log != string.Empty) { return(KMSWinDivert.Log + output); } return(output.ToString()); } }