static void Main(string[] args) { //string mac = DeviceHelper.GetCpuID(); //Console.WriteLine(mac); string mCode = RegInfo.GetMachineCode(); Console.WriteLine("机器码:" + mCode); DateTime overTime = DateTime.Now; string regCode = RegInfo.CreateRegisterCode(mCode, DateTime.Now); int year = int.Parse(overTime.Year.ToString().Substring(2)) + 33; int month = overTime.Month + 21; int day = overTime.Day + 54; int section = mCode.Length / 4; Console.WriteLine("注册码:" + regCode); Console.WriteLine(year); Console.WriteLine(month); Console.WriteLine(day); DateTime time = DateTime.Now; bool resu = RegInfo.CheckRegister(regCode, ref time); Console.WriteLine(resu); Console.ReadKey(); }
public static void UnregisterAddIn(Type t) { RegInfo info = new RegInfo(t); using (RegistryKey keyClsid = Registry.ClassesRoot.OpenSubKey(@"CLSID\" + info.AddInGuid, true)) { keyClsid.DeleteSubKey(@"Implemented Categories\{39AD2B5C-7A29-11D6-8E0A-0010B541CAA8}"); keyClsid.DeleteSubKey("Settings"); keyClsid.DeleteSubKey("Description"); } }
public static void RegisterAddIn( Type t, SupportedSoftwareVersionEnum supportedSoftwareVersion, string softwareVersion, bool loadOnStartup, string addinVersion) { RegInfo info = new RegInfo(t); using (RegistryKey keyClsid = Registry.ClassesRoot.CreateSubKey(@"CLSID\" + info.AddInGuid)) { keyClsid.SetValue(null, info.Title); keyClsid.CreateSubKey(@"Implemented Categories\{39AD2B5C-7A29-11D6-8E0A-0010B541CAA8}"); using (RegistryKey keySettings = keyClsid.CreateSubKey("Settings")) { keySettings.SetValue("AddInType", "Standard"); keySettings.SetValue("LoadOnStartup", (loadOnStartup ? "1" : "0")); switch (supportedSoftwareVersion) { case SupportedSoftwareVersionEnum.kSupportedSoftwareVersionEqualTo: keySettings.SetValue("SupportedSoftwareVersionEqualTo", softwareVersion); break; case SupportedSoftwareVersionEnum.kSupportedSoftwareVersionGreaterThan: keySettings.SetValue("SupportedSoftwareVersionGreaterThan", softwareVersion); break; case SupportedSoftwareVersionEnum.kSupportedSoftwareVersionLessThan: keySettings.SetValue("SupportedSoftwareVersionLessThan", softwareVersion); break; case SupportedSoftwareVersionEnum.kSupportedSoftwareVersionNotEqualTo: keySettings.SetValue("SupportedSoftwareVersionNotEqualTo", softwareVersion); break; default: keySettings.SetValue("SupportedSoftwareVersionGreaterThan", softwareVersion); break; } keySettings.SetValue("Version", addinVersion); } using (RegistryKey keyDescription = keyClsid.CreateSubKey("Description")) { keyDescription.SetValue(null, info.Description); } } }
/// <summary> /// Creates dto based on validated information /// </summary> /// <param name="user"> Validated registeration information </param> /// <param name="geoCoordinates"> Validated Geocoordinates based on the location of registration information </param> /// <returns> The gateway DTO needed to create the user in the database </returns> public RegGatewayDTO CreateGatewayDTO(RegInfo user, WebAPIGeocode geoCoordinates) { var hmac = new HMAC256(); var salt = hmac.GenerateSalt(); // Returns null if salt was not generated (empty string) if (salt.Equals("")) { return(null); } var hashDTO = new HashDTO() { Original = user.UserCredInfo.Password + salt }; var hashPassword = hmac.Hash(hashDTO); // Return null if hash was not generated (empty string) if (hashPassword.Equals("")) { return(null); } var questions = new List <string>(); var answers = new List <string>(); foreach (SecurityQuestion QandA in user.SecurityQandAs) { questions.Add(QandA.Question); // hashes the answer to the security question var hmacDTO = new HashDTO() { Original = QandA.Answer }; var hashAnswer = hmac.Hash(hmacDTO); // returns null if hash was not generated if (hashAnswer.Equals("")) { return(null); } answers.Add(hashAnswer); } // Maps data to the dto for the gateway var mappedDTO = new RegGatewayDTO() { UserName = user.UserCredInfo.Username, Password = hashPassword, FirstName = user.UserProfile.FirstName, LastName = user.UserProfile.LastName, Type = user.UserProfile.UserType, Skill = user.UserProfile.Skill, Address = geoCoordinates.Street, City = geoCoordinates.City, State = geoCoordinates.State, Zipcode = geoCoordinates.ZipCode, Longitude = geoCoordinates.Longitude, Latitude = geoCoordinates.Latitude, UserClaims = new SetDefaultClaims().GetDefaultClaims(), Salt = salt, Questions = questions, Answers = answers }; return(mappedDTO); }
public ExternalResResTake() { RegInfo = new RegInfo(); }
public static IMqtt CreateClientWithAppkey(string yunbaAppkey) { var appConfig = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location); RegInfo regInfo = new RegInfo(); if (appConfig.AppSettings.Settings["username"] != null) regInfo.username = appConfig.AppSettings.Settings["username"].Value; if (appConfig.AppSettings.Settings["password"] != null) regInfo.password = appConfig.AppSettings.Settings["password"].Value; if (appConfig.AppSettings.Settings["client_id"] != null) regInfo.clientId = appConfig.AppSettings.Settings["client_id"].Value; if (regInfo.username == "" || regInfo.password == "" || regInfo.clientId == "") { try { regInfo = GetRegInfoWithAppkey(yunbaAppkey); if (regInfo.username == null || regInfo.password == null || regInfo.clientId == null) throw new Exception("username or password or client_id is null."); } catch (Exception e) { Log.Write(LogLevel.ERROR, e.ToString()); throw e; } if (appConfig.AppSettings.Settings["username"] == null) appConfig.AppSettings.Settings.Add("username", regInfo.username); else appConfig.AppSettings.Settings["username"].Value = regInfo.username; if (appConfig.AppSettings.Settings["password"] == null) appConfig.AppSettings.Settings.Add("password", regInfo.password); else appConfig.AppSettings.Settings["password"].Value = regInfo.password; if (appConfig.AppSettings.Settings["client_id"] == null) appConfig.AppSettings.Settings.Add("client_id", regInfo.clientId); else appConfig.AppSettings.Settings["client_id"].Value = regInfo.clientId; appConfig.Save(ConfigurationSaveMode.Full, true); ConfigurationManager.RefreshSection("appSettings"); } string host = null; try { host = GetHostWithAppkey(yunbaAppkey); if (host == null) throw new Exception("host is null."); } catch(Exception e) { Log.Write(LogLevel.ERROR, e.ToString()); throw e; } Log.Write(LogLevel.INFO, "host: " + host); Log.Write(LogLevel.INFO, "client id: " + regInfo.clientId); return new Mqtt(host, regInfo.clientId, regInfo.username, regInfo.password, null); }
private void FrmMain_Shown(object sender, EventArgs e) { RegInfo regInfo = null; if (Register.Validate.Check(true, out regInfo)) { if (regInfo.RegBase.OrganizationCode != ConfigurationManager.AppSettings["AreaNo"]) { MessageBox.Show("非授权的机构编码,请核对!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(0); } else { var strReg = string.Format("授权给:{0} 机构编码:{1} 到期时间:{2}", regInfo.RegBase.OrganizationName, regInfo.RegBase.OrganizationCode, Convert.ToDateTime(regInfo.RegBase.ExpiryDate).ToString("yyyy-MM-dd")); this.labRegInfo.Text = strReg; } } else { Environment.Exit(0); } new Thread(() => { while (true) { Thread.Sleep(1000 * 60 * 60 * 24); if (!Register.Validate.Check(false)) { Environment.Exit(0); } } }) { IsBackground = true }.Start(); actServiceState = (name, state) => { this.lvService.Items[name].SubItems[3].Text = state; }; actLog = (name, log) => { this.txtLog.AppendText(string.Format("{0} - {1}\r\n{2}\r\n", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), name, log)); }; var position = this.tabServer.Location; position.Offset(this.tabPerformance.Bounds.Location); this.viewerHost = new ViewerHost(); this.viewerHost.Visible = false; this.viewerHost.Location = position; this.viewerHost.Size = this.tabPerformance.Size; this.viewerHost.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom; this.Controls.Add(this.viewerHost); this.viewerHost.BringToFront(); this.viewerHost.AppFileName = AppDomain.CurrentDomain.BaseDirectory + "Viewer\\FlowViewer.exe"; this.viewerHost.Start(Process.GetCurrentProcess().Id.ToString()); //handleCreate this.tabServer.SelectedTab = this.tabLog; this.tabServer.SelectedTab = this.tabMain; this.lvClient.ListViewItemSorter = new ListViewItemComparer <int>(0); this.InitService(); this.tsStart.PerformClick(); this.Close(); }
public Service(RegInfo regInfo) { RegInfo = regInfo; }
/* public SoftInfo soft=new SoftInfo(); private void InitSoftInfo() { soft.ChangeLogPath = "c:\\changelog.log"; soft.Company = "fm-company"; soft.Developer = "austin chen"; soft.Email = "*****@*****.**"; soft.IsDeploy = true; soft.IsGlobalization = true; soft.MainVersion = "1.0.0.1"; soft.Name = "��УԤ¼��ϵͳ"; soft.Tel = "15912345678"; soft.Url = "http://www.hutong.com"; RegInfo reginfo=new RegInfo(); reginfo.BeginDate=new DateTime(2007,12,12); reginfo.LastDate=new DateTime(2008,1,1); reginfo.MachineCode="machinecode"; reginfo.RegCode="regcode"; reginfo.UserName="******"; reginfo.UseTimes=100; soft.RegInfo = reginfo; PluginInfo plugin1 = new PluginInfo(); plugin1.CategoryIndex = 1; plugin1.ChangeLogPath = "plugin1.changelog.log"; plugin1.Company = "plugin1company"; plugin1.Developer = "develper1"; plugin1.Email = "email"; // plugin1.Img = null; plugin1.IsDeploy = false; plugin1.IsGlobalization = false; plugin1.MainVersion="2.0.0.5"; plugin1.Method = "method"; plugin1.Name = "plugin1"; plugin1.Text = "�����"; plugin1.Url = "pluginurl"; plugin1.Tel = "tel"; soft.Plugins.Add(plugin1); PluginInfo plugin2 = new PluginInfo(); plugin2.CategoryIndex = 2; plugin2.ChangeLogPath = "plugin2.changelog.log"; plugin2.Company = "plugin2company"; plugin2.Developer = "develper2"; plugin2.Email = "email"; //plugin2.Img = null; plugin2.IsDeploy = false; plugin2.IsGlobalization = false; plugin2.MainVersion = "2.0.0.5"; plugin2.Method = "method"; plugin2.Name = "plugin2"; plugin2.Text = "�����2"; plugin2.Url = "pluginurl"; plugin2.Tel = "tel"; soft.Plugins.Add(plugin2); } * */ private void button1_Click(object sender, EventArgs e) { try { /* PluginInfo plugin2 = new PluginInfo(); plugin2.CategoryIndex = 2; plugin2.ChangeLogPath = "plugin2.changelog.log"; plugin2.Company = "plugin2company"; plugin2.Developer = "develper2"; plugin2.Email = "email"; //plugin2.Img = null; plugin2.IsDeploy = false; plugin2.IsGlobalization = false; plugin2.MainVersion = "2.0.0.5"; plugin2.Method = "method"; plugin2.Name = "plugin2"; plugin2.Text = "�����2"; plugin2.Url = "pluginurl"; plugin2.Tel = "tel"; this.textBox1.Text = SerializeHelper.SerializeToXml(plugin2); * */ SoftInfo soft = new SoftInfo(); soft.ChangeLogPath = "c:\\changelog.log"; soft.Company = "fm-company"; soft.Developer = "austin chen"; soft.Email = "*****@*****.**"; soft.IsDeploy = true; soft.IsGlobalization = true; soft.MainVersion = "1.0.0.1"; soft.Name = "��УԤ¼��ϵͳ"; soft.Tel = "15912345678"; soft.Url = "http://www.hutong.com"; RegInfo reginfo = new RegInfo(); reginfo.BeginDate = new DateTime(2007, 12, 12); reginfo.LastDate = new DateTime(2008, 1, 1); reginfo.MachineCode = "machinecode"; reginfo.RegCode = "regcode"; reginfo.UserName = "******"; reginfo.UseTimes = 100; soft.RegInfo = reginfo; PluginInfo plugin1 = new PluginInfo(); plugin1.CategoryIndex = 1; plugin1.ChangeLogPath = "plugin1.changelog.log"; plugin1.Company = "plugin1company"; plugin1.Developer = "develper1"; plugin1.Email = "email"; // plugin1.Img = null; plugin1.IsDeploy = false; plugin1.IsGlobalization = false; plugin1.MainVersion = "2.0.0.5"; plugin1.Method = "method"; plugin1.Name = "plugin1"; plugin1.Text = "�����"; plugin1.Url = "pluginurl"; plugin1.Tel = "tel"; soft.Plugins.Add(plugin1); PluginInfo plugin2 = new PluginInfo(); plugin2.CategoryIndex = 2; plugin2.ChangeLogPath = "plugin2.changelog.log"; plugin2.Company = "plugin2company"; plugin2.Developer = "develper2"; plugin2.Email = "email"; //plugin2.Img = null; plugin2.IsDeploy = false; plugin2.IsGlobalization = false; plugin2.MainVersion = "2.0.0.5"; plugin2.Method = "method"; plugin2.Name = "plugin2"; plugin2.Text = "�����2"; plugin2.Url = "pluginurl"; plugin2.Tel = "tel"; soft.Plugins.Add(plugin2); // string temp = "<![CDATA[" + SerializeHelper.SerializeToXml(soft) + "]]>"; // SerializeSupport support = new SerializeSupport(); // support.data = temp; // this.textBox1.Text = SerializeHelper.SerializeToXml(support); this.textBox1.Text = SerializeHelper.SerializeToXml(soft); } catch (Exception ex) { System.Console.Write(ex.StackTrace); string tmp = ""; } }
public static IMqtt CreateClientWithAppkey(string yunbaAppkey) { var appConfig = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location); RegInfo regInfo = new RegInfo(); if (appConfig.AppSettings.Settings["username"] != null) { regInfo.username = appConfig.AppSettings.Settings["username"].Value; } if (appConfig.AppSettings.Settings["password"] != null) { regInfo.password = appConfig.AppSettings.Settings["password"].Value; } if (appConfig.AppSettings.Settings["client_id"] != null) { regInfo.clientId = appConfig.AppSettings.Settings["client_id"].Value; } if (regInfo.username == "" || regInfo.password == "" || regInfo.clientId == "") { try { regInfo = GetRegInfoWithAppkey(yunbaAppkey); if (regInfo.username == null || regInfo.password == null || regInfo.clientId == null) { throw new Exception("username or password or client_id is null."); } } catch (Exception e) { Log.Write(LogLevel.ERROR, e.ToString()); throw e; } if (appConfig.AppSettings.Settings["username"] == null) { appConfig.AppSettings.Settings.Add("username", regInfo.username); } else { appConfig.AppSettings.Settings["username"].Value = regInfo.username; } if (appConfig.AppSettings.Settings["password"] == null) { appConfig.AppSettings.Settings.Add("password", regInfo.password); } else { appConfig.AppSettings.Settings["password"].Value = regInfo.password; } if (appConfig.AppSettings.Settings["client_id"] == null) { appConfig.AppSettings.Settings.Add("client_id", regInfo.clientId); } else { appConfig.AppSettings.Settings["client_id"].Value = regInfo.clientId; } appConfig.Save(ConfigurationSaveMode.Full, true); ConfigurationManager.RefreshSection("appSettings"); } string host = null; try { host = GetHostWithAppkey(yunbaAppkey); if (host == null) { throw new Exception("host is null."); } } catch (Exception e) { Log.Write(LogLevel.ERROR, e.ToString()); throw e; } Log.Write(LogLevel.INFO, "host: " + host); Log.Write(LogLevel.INFO, "client id: " + regInfo.clientId); return(new Mqtt(host, regInfo.clientId, regInfo.username, regInfo.password, null)); }
/* public SoftInfo soft=new SoftInfo(); * * private void InitSoftInfo() * { * soft.ChangeLogPath = "c:\\changelog.log"; * soft.Company = "fm-company"; * soft.Developer = "austin chen"; * soft.Email = "*****@*****.**"; * soft.IsDeploy = true; * soft.IsGlobalization = true; * soft.MainVersion = "1.0.0.1"; * soft.Name = "驾校预录入系统"; * soft.Tel = "15912345678"; * soft.Url = "http://www.hutong.com"; * RegInfo reginfo=new RegInfo(); * reginfo.BeginDate=new DateTime(2007,12,12); * reginfo.LastDate=new DateTime(2008,1,1); * reginfo.MachineCode="machinecode"; * reginfo.RegCode="regcode"; * reginfo.UserName="******"; * reginfo.UseTimes=100; * soft.RegInfo = reginfo; * PluginInfo plugin1 = new PluginInfo(); * plugin1.CategoryIndex = 1; * plugin1.ChangeLogPath = "plugin1.changelog.log"; * plugin1.Company = "plugin1company"; * plugin1.Developer = "develper1"; * plugin1.Email = "email"; * // plugin1.Img = null; * plugin1.IsDeploy = false; * plugin1.IsGlobalization = false; * plugin1.MainVersion="2.0.0.5"; * plugin1.Method = "method"; * plugin1.Name = "plugin1"; * plugin1.Text = "生活工具"; * plugin1.Url = "pluginurl"; * plugin1.Tel = "tel"; * soft.Plugins.Add(plugin1); * * PluginInfo plugin2 = new PluginInfo(); * plugin2.CategoryIndex = 2; * plugin2.ChangeLogPath = "plugin2.changelog.log"; * plugin2.Company = "plugin2company"; * plugin2.Developer = "develper2"; * plugin2.Email = "email"; * //plugin2.Img = null; * plugin2.IsDeploy = false; * plugin2.IsGlobalization = false; * plugin2.MainVersion = "2.0.0.5"; * plugin2.Method = "method"; * plugin2.Name = "plugin2"; * plugin2.Text = "生活工具2"; * plugin2.Url = "pluginurl"; * plugin2.Tel = "tel"; * * soft.Plugins.Add(plugin2); * } * */ private void button1_Click(object sender, EventArgs e) { try { /* * PluginInfo plugin2 = new PluginInfo(); * plugin2.CategoryIndex = 2; * plugin2.ChangeLogPath = "plugin2.changelog.log"; * plugin2.Company = "plugin2company"; * plugin2.Developer = "develper2"; * plugin2.Email = "email"; * //plugin2.Img = null; * plugin2.IsDeploy = false; * plugin2.IsGlobalization = false; * plugin2.MainVersion = "2.0.0.5"; * plugin2.Method = "method"; * plugin2.Name = "plugin2"; * plugin2.Text = "生活工具2"; * plugin2.Url = "pluginurl"; * plugin2.Tel = "tel"; * * this.textBox1.Text = SerializeHelper.SerializeToXml(plugin2); * */ SoftInfo soft = new SoftInfo(); soft.ChangeLogPath = "c:\\changelog.log"; soft.Company = "fm-company"; soft.Developer = "austin chen"; soft.Email = "*****@*****.**"; soft.IsDeploy = true; soft.IsGlobalization = true; soft.MainVersion = "1.0.0.1"; soft.Name = "驾校预录入系统"; soft.Tel = "15912345678"; soft.Url = "http://www.hutong.com"; RegInfo reginfo = new RegInfo(); reginfo.BeginDate = new DateTime(2007, 12, 12); reginfo.LastDate = new DateTime(2008, 1, 1); reginfo.MachineCode = "machinecode"; reginfo.RegCode = "regcode"; reginfo.UserName = "******"; reginfo.UseTimes = 100; soft.RegInfo = reginfo; PluginInfo plugin1 = new PluginInfo(); plugin1.CategoryIndex = 1; plugin1.ChangeLogPath = "plugin1.changelog.log"; plugin1.Company = "plugin1company"; plugin1.Developer = "develper1"; plugin1.Email = "email"; // plugin1.Img = null; plugin1.IsDeploy = false; plugin1.IsGlobalization = false; plugin1.MainVersion = "2.0.0.5"; plugin1.Method = "method"; plugin1.Name = "plugin1"; plugin1.Text = "生活工具"; plugin1.Url = "pluginurl"; plugin1.Tel = "tel"; soft.Plugins.Add(plugin1); PluginInfo plugin2 = new PluginInfo(); plugin2.CategoryIndex = 2; plugin2.ChangeLogPath = "plugin2.changelog.log"; plugin2.Company = "plugin2company"; plugin2.Developer = "develper2"; plugin2.Email = "email"; //plugin2.Img = null; plugin2.IsDeploy = false; plugin2.IsGlobalization = false; plugin2.MainVersion = "2.0.0.5"; plugin2.Method = "method"; plugin2.Name = "plugin2"; plugin2.Text = "生活工具2"; plugin2.Url = "pluginurl"; plugin2.Tel = "tel"; soft.Plugins.Add(plugin2); // string temp = "<![CDATA[" + SerializeHelper.SerializeToXml(soft) + "]]>"; // SerializeSupport support = new SerializeSupport(); // support.data = temp; // this.textBox1.Text = SerializeHelper.SerializeToXml(support); this.textBox1.Text = SerializeHelper.SerializeToXml(soft); } catch (Exception ex) { System.Console.Write(ex.StackTrace); string tmp = ""; } }
public byte getAddrByTxtName(string Name) { RegInfo info = ListRegInfo.Find(x => x.txtName.Contains(Name)); return((byte)info.Reg); }
public uint getRangeByTxtName(string Name) { RegInfo info = ListRegInfo.Find(x => x.txtName.Contains(Name)); return(getShiftRange(info.Mask)); }