Ejemplo n.º 1
0
        public int GetUserAuthority()
        {
            UserAuthority = 0;
            try
            {
                string           IP1             = CNetTools.GetInstance().getLocalIP();
                string           Mac             = CNetTools.GetInstance().getLocalMac();
                string           IP2             = CNetTools.GetInstance().GetExtranetIP();
                CEncryptionTools encryptionTools = new CEncryptionTools(USerial);
                string           UserKey         = string.Format("{0};{1};{2}", IP1, Mac, IP2);
                Mac = encryptionTools.Encode(IP1);
                Mac = encryptionTools.Decode(Mac);
                if (GetSerial() > 0 && Validate())
                {
                    CServers.GetServers().GetUserName();
                    string Authority = CServers.GetServers().GetUserAuthority(USerial, encryptionTools.Encode(UserKey));
                    if (Authority != "-1")
                    {
                        int.TryParse(encryptionTools.Decode(Authority), out UserAuthority);
                    }
                    else
                    {
                        UserAuthority = -1;
                    }

                    string name = CServers.GetServers().GetUserName();
                }
            }
            catch (Exception ex) {
                //MessageBox.Show(ex.ToString());
            }
            return(UserAuthority);
        }
Ejemplo n.º 2
0
 private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (!CCommonPara.mBEnableLock)
     {
         return;
     }
     try
     {
         CServers.GetServers().CloseService();
     }
     catch { }
 }
Ejemplo n.º 3
0
 public bool Validate(MrModuleType power, out bool IsOut)
 {
     try
     {
         ulong ID1 = USerial;
         ulong ID2 = GetSerial();
         IsOut = true;
         CServers.GetServers().GetUserName();
         if (ID2 == 0)
         {
             MessageBox.Show("未检测到加密狗!请确认是否已经插好!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return(false);
         }
         else if (ID1 != ID2)
         {
             MessageBox.Show("在使用中不可以更换加密狗!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return(false);
         }
         else if (Validate())
         {
             if (UserAuthority > 0)
             {
                 if ((UserAuthority & ((int)power)) == ((int)power))
                 {
                     IsOut = false;
                     return(true);
                 }
                 else
                 {
                     MessageBox.Show("该模块需要另外付费购买才能运行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     IsOut = false;
                     return(false);
                 }
             }
         }
         MessageBox.Show("未检测到加密狗!请确认是否已经插好!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return(false);
     }
     catch
     {
         MessageBox.Show("服务器异常,请确认网络或者加密狗", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         IsOut = true;
         return(false);
     }
 }
Ejemplo n.º 4
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            FrmLoad frmLoad = new FrmLoad();

            if (frmLoad.ShowDialog() == DialogResult.Yes)
            {
                UI.FrmConfigure frmcf = new UI.FrmConfigure();
                if (frmcf.ShowDialog() == DialogResult.Yes)
                {
                    Application.Run(new NewMainForm());
                }
                else
                {
                    try
                    {
                        CServers.GetServers().CloseService();
                    }
                    catch { }
                }
            }


            /*
             * int re = CDogTools.GetInstance().GetUserAuthority();
             * if (re >0)
             * {
             *    string a = CDogTools.GetInstance().GetStringData(101);
             *    long b = CDogTools.GetInstance().GetLongData(101);
             *
             *    Application.EnableVisualStyles();
             *    Application.SetCompatibleTextRenderingDefault(false);
             *    Application.Run(new MainForm());
             * }
             * else if( re==-1)
             * {
             *    MessageBox.Show("您的加密狗已经在其他程序中使用,不能重复登录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             * }
             * else
             * {
             *    MessageBox.Show("未检测到加密狗!请确认是否已经插好!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             * }*/
        }
Ejemplo n.º 5
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     //  return;
     timer1.Interval = 1000 * 60 * 1;
     try
     {
         // timer1.Enabled = false;
         if (timer1.Interval < 1000)
         {
             timer1.Interval = 1000 * 60 * 1;
             int re = CDogTools.GetInstance().GetUserAuthority();
             if (re == -1)
             {
                 CServers.GetServers().CloseService();
                 MessageBox.Show("您的加密狗已经在其他程序中使用,不能重复登录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 this.Close();
             }
             else if (re <= 0)
             {
                 CServers.GetServers().CloseService();
                 MessageBox.Show("未检测到加密狗!请确认是否已经插好!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 this.Close();
             }
         }
         else
         {
             if (!CDimTools.GetInstance().IsOut)
             {
                 CServers.GetServers().GetUserName();
             }
             else
             {
                 MessageBox.Show("服务器异常,请确认网络或者加密狗", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 this.Close();
             }
         }
     }
     catch
     {
         MessageBox.Show("服务器异常,请确认网络或者加密狗", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         this.Close();
     }
 }
Ejemplo n.º 6
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (!CCommonPara.mBEnableLock)
            {
                this.DialogResult = DialogResult.Yes;
                this.Close();
                return;
            }
            try
            {
                timer1.Enabled = false;
                int re = CDogTools.GetInstance().GetUserAuthority();
                if (re == -1)
                {
                    MessageBox.Show("您的加密狗已经在其他程序中使用,不能重复登录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    CServers.GetServers().CloseService();
                    this.DialogResult = DialogResult.Cancel;
                    this.Close();
                    return;
                }
                else if (re <= 0)
                {
                    MessageBox.Show("未检测到加密狗!请确认是否已经插好!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    CServers.GetServers().CloseService();
                    this.DialogResult = DialogResult.Cancel;
                    this.Close();
                    return;
                }
            }
            catch
            {
                MessageBox.Show("服务器异常,请确认网络或者加密狗", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.DialogResult = DialogResult.Cancel;
                this.Close();
                return;
            }

            this.DialogResult = DialogResult.Yes;
            this.Close();
        }
Ejemplo n.º 7
0
 static private void StareServer()
 {
     CServers.GetServers();
 }