Example #1
0
        private void LaunchOnStartupMenuItem_Checked(object sender, RoutedEventArgs e)
        {
            RegistryKey run = RegistryTool.GetRunRegistryKey(true);

            RegistryTool.ActOnRegistryKey(run,
                                          x => x.SetValue("NeedABreak", System.Reflection.Assembly.GetExecutingAssembly().Location));
        }
Example #2
0
        // 支付结果处理逻辑
        private void PayResult(string param)
        {
            string isSuccess = WebTool.getNodeData(param, "isSuccess", false).ToLower();

            if (isSuccess.Equals("true"))
            {
                string serial = MachineInfo_Serial.RegSerial(SoftName);
                RegistryTool.RegistrySave(AuthorName + @"\" + SoftName + @"\Set", "Serial", serial);
                MessageBox.Show("恭喜,您已成功注册!(即时注册)");
            }
        }
Example #3
0
        private string checkLocalVersion()
        {
            RegistryTool rt = new RegistryTool("Palette");
            string       v  = rt.readString("VERSION");

            if (v.Equals(RegistryTool.DEFAULT))
            {
                return("0");
            }

            return(v);
        }
Example #4
0
        /// <summary>
        ///  从注册表载入信息,判断用户是否已经注册
        /// </summary>
        /// <returns></returns>
        public bool IsRegUser()
        {
            // 检测本地注册信息,
            // 若已经注册成功
            bool containsSerial = RegistryTool.RegistryCotains(AuthorName + @"\" + SoftName + @"\Set", "Serial");

            //mainForm.F.RegistryRemove(AuthorName + @"\easyIcon\Set", "Serial");
            if (containsSerial)
            {
                // 优先判断本地注册表数据
                string serial = RegistryTool.RegistryStrValue(AuthorName + @"\" + SoftName + @"\Set", "Serial");
                if (!serial.Equals("") && serial.Equals(MachineInfo_Serial.RegSerial(SoftName)))
                {
                    if (Timer_CheckOnlineRegister.Enabled)
                    {
                        Timer_CheckOnlineRegister.Enabled = false;                                      // 停止计时查询逻辑
                    }
                    if (this.needRegCallBack != null)
                    {
                        this.needRegCallBack("end");                               //4、若已注册,则执行结束逻辑
                    }
                    return(true);
                }
            }

            // 若未注册,则弹出网络提示
            bool available = System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable();

            if (!available)
            {
                MessageBox.Show("网络不可用,无法获取软件状态信息\r\n请先连接网络后,再使用此工具");
                Application.Exit(); // 自动退出应用
                return(false);      // 网络未连接视作未注册用户
            }

            // 若未注册成功,在线检测是否需要注册
            bool isNeed = needRegister();

            if (this.needRegCallBack != null)   // 2、先检测是否需要注册
            {
                if (isNeed)
                {
                    this.needRegCallBack("yes");
                }
                else
                {
                    this.needRegCallBack("no");
                }
            }

            return(!isNeed); // 若不需要注册,则视作已注册用户
        }
Example #5
0
        private void updateLocalVersion(string version, string lversion)
        {
            RegistryTool rt = new RegistryTool("Palette");

            if (!rt.writeString("VERSION", version))
            {
                log.Error("Fallo la actualización de la version en el registry.");
            }
            if (!rt.writeString("LAST_VERSION", lversion))
            {
                log.Error("Fallo la actualización de la version anterior en el registry.");
            }
        }
Example #6
0
        private void LoadRegistryConfig()
        {
            RegistryKey run = RegistryTool.GetRunRegistryKey(false);

            RegistryTool.ActOnRegistryKey(run, x =>
            {
                string needABreak = (string)run.GetValue("NeedABreak");

                if (needABreak != null)
                {
                    LaunchOnStartupMenuItem.IsChecked = true;
                }
            });

            LaunchOnStartupMenuItem.Checked   += LaunchOnStartupMenuItem_Checked;
            LaunchOnStartupMenuItem.Unchecked += LaunchOnStartupMenuItem_Unchecked;
        }
Example #7
0
        private void CheckBox_Checked(object sender, RoutedEventArgs e)
        {
            System.Windows.Controls.CheckBox cb = sender as System.Windows.Controls.CheckBox;

            bool result = cb.IsChecked ?? false;

            if (result != cData.IsStartRun)
            {
                if (!PermissionTool.IsAdministrator())
                {
                    System.Windows.MessageBox.Show("请以管理员权限运行再设置开机启动");
                    return;
                }
                else
                {
                    RegistryTool.SelfRunning(cb.IsChecked ?? true, "PersonalGrowthSystem", PathTool.GetFullPath());
                    cData.IsStartRun = result;
                }
            }
        }
Example #8
0
        /// <summary>
        /// 在线注册逻辑,自动检测是否已在线注册,若已经注册,则完成本地注册逻辑。
        /// 启动后首次,通过接口发送软件启动信息至服务器;
        /// 再次检测时,在查询本地注册信息之后,若未注册则在线查询。
        /// 通过needRegCallBack执行回调处理逻辑
        /// </summary>
        public void RegLogic_Online(NeedRegisterCallBack needRegCallBack = null)
        {
            if (needRegCallBack != null)
            {
                this.needRegCallBack = needRegCallBack;                             // 记录回调处理逻辑
            }
            string onlineSerial = "";

            // 0、发送软件启动信息至服务器
            bool isFirst = isFirstGetOnlineSerial;

            if (isFirst)
            {
                // 获取序列号信息
                onlineSerial = GetOnlineSerial(MachineInfo_Serial.MachineSerial(), SoftName, MachineInfo_Serial.ComputerName(), MachineInfo_Serial.UserName(), "");

                // 显示软件msg信息
                string SoftExt = ExtInfo("msg");
                showExtMessage("SoftExt", SoftExt);

                // 显示机器软件对应的msg信息
                string MachineSoftMsg = GetValue("msg", MachineInfo_Serial.MachineSerial(), SoftName);
                showExtMessage("MachineSoftMsg", MachineSoftMsg);
            }

            if (!this.IsRegUser())      // 1、若本地未注册
            {
                if (!isFirst)
                {
                    onlineSerial = GetOnlineSerial(MachineInfo_Serial.MachineSerial(), SoftName, MachineInfo_Serial.ComputerName(), MachineInfo_Serial.UserName(), "");
                }

                // 2、则查询是否已在线注册
                if (!onlineSerial.Equals("") && onlineSerial.Equals(MachineInfo_Serial.RegSerial(SoftName)))
                {
                    RegistryTool.RegistrySave(AuthorName + @"\" + SoftName + @"\Set", "Serial", onlineSerial);
                    MessageBox.Show("恭喜,您已成功注册!(异步注册)\r\n\r\n即便重装系统,也无需再次注册.\r\nCopyright ©  2018 Scimence");
                }
            }
        }
Example #9
0
 public MainWindow()
 {
     InitializeComponent();
     EndpointURL.IsEnabled   = false;
     ConnectButton.IsEnabled = false;
     StatusLabel.Content     = "Hello";
     RegistryTool.SetUrlHandler();
     if (Environment.GetCommandLineArgs().Count() > 1)
     {
         var paramsList = Environment.GetCommandLineArgs().Last().Replace("k1://", "").Replace("/", "").Split(':').ToList();
         if (paramsList.First() == "lock")
         {
             Endpoint lockInfo;
             try
             {
                 StatusLabel.Content = String.Format("Connecting");
                 lockInfo            = Backend.GetLockInfo(Guid.Parse(paramsList.Last()));
                 SshWrapper w      = new SshWrapper(lockInfo);
                 string     result = w.Connect();
                 StatusLabel.Content = String.Format("Connected" + Environment.NewLine + result);
             } catch (Exception ex)
             {
                 StatusLabel.Content = String.Format("Error: {0}", ex.Message);
             }
         }
         else
         {
             StatusLabel.Content += "No endpoint id";
         }
     }
     else
     {
         StatusLabel.Content     = "No link" + Environment.NewLine + "Enter link in field below";
         EndpointURL.IsEnabled   = true;
         ConnectButton.IsEnabled = true;
     };
 }
Example #10
0
        /// <summary>
        /// 显示软件公告信息
        /// </summary>
        public void showExtMessage(string key, string msg)
        {
            //string msg = ExtInfo("msg").Replace("\\r", "\r").Replace("\\n", "\n").Replace("\\t", "\t");
            msg = msg.Replace("\\r", "\r").Replace("\\n", "\n").Replace("\\t", "\t");
            if (msg.Equals(""))
            {
                return;                     // 若无公告信息,则返回
            }
            else
            {
                bool contains = RegistryTool.RegistryCotains(AuthorName + @"\" + SoftName + @"\Set", key);
                if (contains)
                {
                    string preMsg = RegistryTool.RegistryStrValue(AuthorName + @"\" + SoftName + @"\Set", key);
                    if (!preMsg.Equals("") && preMsg.Equals(msg))
                    {
                        return;
                    }
                }
            }

            MessageBox.Show(msg);
            RegistryTool.RegistrySave(AuthorName + @"\" + SoftName + @"\Set", key, msg);
        }
Example #11
0
        private void LaunchOnStartupMenuItem_Unchecked(object sender, RoutedEventArgs e)
        {
            RegistryKey run = RegistryTool.GetRunRegistryKey(true);

            RegistryTool.ActOnRegistryKey(run, x => x.DeleteValue("NeedABreak"));
        }