示例#1
0
        /// <summary>
        /// Handles the Click event of the btnBuilder control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void btnBuilder_Click(object sender, EventArgs e)
        {
            try {
                TEACrypter Crypter = new TEACrypter();
                byte[]     keys    = TEACrypter.MD5(Encoding.Default.GetBytes(string.Format(@"{0}", this.txtCode.Text)));
                //byte[] Result = Crypter.Encrypt(Encoding.Default.GetBytes(this.txtCode.Text), keys);



                AsyncLicenceKey Key = new AsyncLicenceKey()
                {
                    Company            = txtCompany.Text,
                    ExpireDate         = this.PickerExpire.Value,
                    Key                = keys,
                    MaxAsync           = int.Parse(txtASyncCount.Value.ToString()),
                    MaxTSession        = int.Parse(txtMaxTSession.Value.ToString()),
                    AllowDatabase      = chkAllowDb.Checked,
                    MaxCommandPerMonth = int.Parse(maskedTextBox1.Text),
                    connectionString   = this.txtConnectString.Text,
                    providerName       = this.txtProviderName.Text,
                    AllowAfterValidate = true,
                    AllowIntercept     = chkAllowInter.Checked,
                    RemainingMinutes   = ((TimeSpan)(this.PickerExpire.Value - DateTime.Now)).TotalMinutes,
                    AllowDbLog         = checkBox1.Checked
                };

                byte[] Buffer = Key.XmlSerialize(keys, this.txtFileName.Text);
                MessageBox.Show(string.Format(@"授权文件{0}已经生成!", txtFileName.Text), "授权提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
        /// <summary>
        /// Handles the Click event of the btnBuilder control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void btnBuilder_Click(object sender, EventArgs e)
        {
            try {
                TEACrypter Crypter = new TEACrypter();
                byte[] keys = TEACrypter.MD5(Encoding.Default.GetBytes(string.Format(@"{0}", this.txtCode.Text)));
                //byte[] Result = Crypter.Encrypt(Encoding.Default.GetBytes(this.txtCode.Text), keys);

                AsyncLicenceKey Key = new AsyncLicenceKey() {
                    Company = txtCompany.Text,
                    ExpireDate = this.PickerExpire.Value,
                    Key = keys,
                    MaxAsync = int.Parse(txtASyncCount.Value.ToString()),
                    MaxTSession = int.Parse(txtMaxTSession.Value.ToString()),
                    AllowDatabase = chkAllowDb.Checked,
                    MaxCommandPerMonth = int.Parse(maskedTextBox1.Text),
                    connectionString = this.txtConnectString.Text,
                    providerName = this.txtProviderName.Text,
                    AllowAfterValidate = true,
                    AllowIntercept = chkAllowInter.Checked,
                    RemainingMinutes = ((TimeSpan)(this.PickerExpire.Value - DateTime.Now)).TotalMinutes,
                    AllowDbLog = checkBox1.Checked
                };

                byte[] Buffer = Key.XmlSerialize(keys, this.txtFileName.Text);
                MessageBox.Show(string.Format(@"授权文件{0}已经生成!", txtFileName.Text), "授权提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#3
0
 /// <summary>
 /// 开始线程.
 /// </summary>
 /// <param name="SESSION">会话端.</param>
 /// <param name="InPacket">入口数据包.</param>
 /// <param name="OutPacket">出口数据包.</param>
 /// <param name="Key">The key.</param>
 protected abstract void ExecutePlugIn(eTerm443Async SESSION, eTerm443Packet InPacket, eTerm443Packet OutPacket, AsyncLicenceKey Key);
示例#4
0
 /// <summary>
 /// Invokes the base.
 /// </summary>
 /// <param name="SESSION">The SESSION.</param>
 /// <param name="InPacket">The in packet.</param>
 /// <param name="OutPacket">The out packet.</param>
 /// <param name="Key">The key.</param>
 private void InvokeBase(eTerm443Async SESSION, eTerm443Packet InPacket, eTerm443Packet OutPacket, AsyncLicenceKey Key)
 {
     if (!ValidatePlugIn(SESSION, InPacket, OutPacket, Key))
     {
         return;
     }
     ExecutePlugIn(SESSION, InPacket, OutPacket, Key);
 }
示例#5
0
 /// <summary>
 /// 验证可用性.
 /// </summary>
 /// <param name="SESSION">The SESSION.</param>
 /// <param name="InPacket">The in packet.</param>
 /// <param name="OutPacket">The out packet.</param>
 /// <param name="Key">The key.</param>
 /// <returns></returns>
 protected abstract bool ValidatePlugIn(eTerm363Session SESSION, eTerm363Packet InPacket, eTerm363Packet OutPacket, AsyncLicenceKey Key);
示例#6
0
 /// <summary>
 /// 开始线程.
 /// </summary>
 /// <param name="callBack">The call back.</param>
 /// <param name="Session">The session.</param>
 /// <param name="InPacket">The in packet.</param>
 /// <param name="OutPacket">The out packet.</param>
 /// <param name="Key">The key.</param>
 /// <returns></returns>
 public IAsyncResult BeginExecute(AsyncCallback callBack, eTerm363Session Session, eTerm363Packet InPacket, eTerm363Packet OutPacket, AsyncLicenceKey Key)
 {
     try {
         return(__Invoke.BeginInvoke(Session, InPacket, OutPacket, Key, callBack, Session));
     }
     catch (Exception e) {
         // Hide inside method invoking stack
         throw e;
     }
 }
示例#7
0
 /// <summary>
 /// 开始线程.
 /// </summary>
 /// <param name="SESSION">会话端.</param>
 /// <param name="InPacket">入口数据包.</param>
 /// <param name="OutPacket">出口数据包.</param>
 /// <param name="Key">The key.</param>
 protected abstract void ExecutePlugIn(eTerm363Session SESSION, eTerm363Packet InPacket, eTerm363Packet OutPacket, AsyncLicenceKey Key);
示例#8
0
 /// <summary>
 /// Invokes the base.
 /// </summary>
 /// <param name="SESSION">The SESSION.</param>
 /// <param name="InPacket">The in packet.</param>
 /// <param name="OutPacket">The out packet.</param>
 /// <param name="Key">The key.</param>
 private void InvokeBase(eTerm363Session SESSION, eTerm363Packet InPacket, eTerm363Packet OutPacket, AsyncLicenceKey Key)
 {
     if (!ValidatePlugIn(SESSION, InPacket, OutPacket, Key))
     {
         SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, @"服务器不允许该插件"));
         return;
     }
     ExecutePlugIn(SESSION, InPacket, OutPacket, Key);
 }
示例#9
0
 /// <summary>
 /// 验证可用性.
 /// </summary>
 /// <param name="SESSION">The SESSION.</param>
 /// <param name="InPacket">The in packet.</param>
 /// <param name="OutPacket">The out packet.</param>
 /// <param name="Key">The key.</param>
 /// <returns></returns>
 protected abstract bool ValidatePlugIn(eTerm443Async SESSION, eTerm443Packet InPacket, eTerm443Packet OutPacket, AsyncLicenceKey Key);
示例#10
0
        /// <summary>
        /// Validates the net.
        /// </summary>
        /// <returns></returns>
        private bool ValidateNet(string Identification)
        {
            __flag = true;
            byte[] buffer;
            LicenceBody = new AsyncLicenceKey();
            byte[] KeyNumbers=Encoding.Default.GetBytes(@"eTermASyncSDK3.0&[email protected]#20859fk27)7361");
            try
            {
                __serialNumber = GetCpuSN();
                //string SingleKey = string.Format(@"{0}", __serialNumber);
                __identification = Identification;

                StringBuilder sb = new StringBuilder();
                foreach (byte SnByte in TEACrypter.MD5(TEACrypter.MD5(Encoding.Default.GetBytes(__serialNumber))))
                {
                    sb.Append(String.Format("{0:X}", SnByte).PadLeft(2, '0'));
                }
                __serialNumber =sb.ToString();

                __secreteKey = TEACrypter.MD5(Encoding.Default.GetBytes(Encrypt(__serialNumber)));
                using (FileStream fs = new FileStream(Identification, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    BinaryReader br = new BinaryReader(fs);
                    buffer = new byte[fs.Length];
                    br.Read(buffer, 0, buffer.Length);
                    LicenceBody = LicenceBody.DeXmlSerialize(KeyNumbers, buffer);
                    __flag = CompareBytes(LicenceBody.Key, __secreteKey);
                    __flag = __flag && LicenceBody.ExpireDate >= DateTime.Now;
                    __flag = __flag && LicenceBody.RemainingMinutes > 0;
                }
            }
            catch
            {
                __flag = false;
            }
            return __flag;
        }