public void GetMacAddressTest() { var macStr = "04-D9-F5-AC-87-D4"; var mac = MacHelper.GetMacAddress(); Assert.AreEqual(macStr, mac); }
private void OperateMacId(string operation) { lblDbOperationSTatus.Text = ""; bool isSuccess; drVwMacIdAssigned.DataSource = MacHelper.OperateMacId(((Distributor)cmbUserList.SelectedItem).Dist_Id, txtAddMacId.Text, txtMacIdType.Text, txtStartFormName.Text, txtRemarks.Text, operation, out isSuccess); lblDbOperationSTatus.Text = isSuccess ? "DB Operation Successful" : "DB Operation Failed"; }
private void buttonGetMac_Click(object sender, EventArgs e) { try { string str = MacHelper.cpuId(); string str2 = MacHelper.baseId(); this.textBoxInput.Text = str.Insert(5, str2.Substring(str2.Length - 6, 4)); } catch (Exception exception) { this.textBoxInput.Text = exception.ToString(); } }
public IPlatformHandle CreateControl(bool isSecond, IPlatformHandle parent, Func<IPlatformHandle> createDefault) { // Note: We are using MonoMac for example purposes // It shouldn't be used in production apps MacHelper.EnsureInitialized(); var webView = new WebView(); Dispatcher.UIThread.Post(() => { webView.MainFrame.LoadRequest(new NSUrlRequest(new NSUrl( isSecond ? "https://bing.com" : "https://google.com/"))); }); return new MacOSViewHandle(webView); }
private void Initialize() { OnSysteminfo = new RelayCommand(() => { LicenseSource.Mac = MacHelper.GetMacAddress(); LicenseSource.CPU = Win32Helper.GetCpuID(); }); OnSignFile = new RelayCommand(() => { this.ViewConfirm("确定生成新的公/私钥文件至Key文件夹,操作会覆盖替换原文件(是/否)?", () => { if (LicenseFileHelper.SavePemKeyFile(PublicKeyFilePath, PrivateKeyFilePath)) { AppEvent.ProcessStart.SendAction <TParam <string, Action> >(this, new TParam <string, Action>() { Param1 = System.IO.Path.GetDirectoryName(PublicKeyFilePath) }); } else { this.ViewMessage("密钥文件保存失败"); } }); }); OnGenerateLic = new RelayCommand(() => { if (LicenseSource.Product.IsEmpty() || LicenseSource.Edition.IsEmpty() || LicenseSource.Email.IsEmpty() || LicenseSource.Mobile.IsEmpty() || LicenseSource.Mac.IsEmpty() || LicenseSource.CPU.IsEmpty() || LicenseSource.UseTimes.IsEmpty() || LicenseSource.ExpirationTime.IsEmpty() || LicenseSource.IsTrial.IsEmpty()) { this.ViewMessage("请输入内容(标识、邮箱、手机,Mac地址,CPU,使用次数,过期时间等信息)"); return; } var licenseModel = new LicenseModel() { Product = LicenseSource.Product, Edition = LicenseSource.Edition, Email = LicenseSource.Email, Mobile = LicenseSource.Mobile, Mac = LicenseSource.Mac, CPU = LicenseSource.CPU, UseTimes = LicenseSource.UseTimes, ExpirationTime = LicenseSource.ExpirationTime, IsTrial = LicenseSource.IsTrial }; var filePath = string.Format(LicenseFilePathFormat, (LicenseSource.Mac + LicenseSource.CPU).Replace("-", "")); if (LicenseFileHelper.SavePemLicenseFile(licenseModel, filePath, PrivateKeyFilePath)) { this.ViewMessage("授权文件保存成功", () => { AppEvent.ProcessStart.SendAction <TParam <string, Action> >(this, new TParam <string, Action>() { Param1 = System.IO.Path.GetDirectoryName(filePath) }); }); } else { this.ViewMessage("授权文件保存失败"); } }); OnVerifyLic = new RelayCommand(() => { if (LicenseSource.Mac.IsEmpty() || LicenseSource.CPU.IsEmpty()) { this.ViewMessage("信息错误"); return; } var filePath = string.Format(LicenseFilePathFormat, (LicenseSource.Mac + LicenseSource.CPU).Replace("-", "")); if (!File.Exists(filePath)) { this.ViewMessage("未找到授权文件"); return; } var model = LicenseFileHelper.GetPemLicense(filePath, PublicKeyFilePath); if (model.IsNull()) { this.ViewMessage("授权文件错误"); return; } this.ViewMessage("授权文件校验通过"); }); OnOpenFileDic = new RelayCommand(() => { AppEvent.ProcessStart.SendAction <TParam <string, Action> >(this, new TParam <string, Action>() { Param1 = System.IO.Path.GetDirectoryName(PublicKeyFilePath), Param2 = null }); }); }