コード例 #1
0
        private void btnActivate_Click(object sender, EventArgs e)
        {
            var          file          = System.IO.Path.Combine(Application.StartupPath, "vgs.dll");
            SecurityFile _SecurityFile = new SecurityFile(file);

            if (File.Exists(file))
            {
                string key  = string.Format("{0}-{1}-{2}-{3}", tb1.Text, tb2.Text, tb3.Text, tb4.Text);
                string code = _SecurityFile.Convert(key);
                _SecurityFile.Read();
                if (code == _SecurityFile.AuthenticationCode)
                {
                    _SecurityFile.Date          = DateTime.Now;
                    _SecurityFile.Authenticated = true;
                    _SecurityFile.Activate("VHF");
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("无效的序列号!", "许可", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("许可文件缺失,程序无法启动!", "许可", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
        public IEnumerable<ISecurity> GetDataAll()
        {
            string filePath = PathHelper.SecurityFile;

            List<SecurityItem> result = new List<SecurityItem>();
            if (File.Exists(filePath))
            {
                var file = new SecurityFile(filePath);
                result.AddRange(file.ReadAll().Distinct());
            }

            return result.Cast<ISecurity>();
        }
コード例 #3
0
        public IEnumerable<ISecurity> GetData(IEnumerable<string> stockCodes)
        {
            string filePath = PathHelper.SecurityFile;
            if (File.Exists(filePath))
            {
                var file = new SecurityFile(filePath);
                var lstSel = from it in file.ReadAll().Distinct()
                             where stockCodes.Contains(it.Code)
                             select it;
                return lstSel.Cast<ISecurity>();
            }

            return null;
        }
コード例 #4
0
        public ISecurity GetData(string stockCode)
        {
            string filePath = PathHelper.SecurityFile;

            if (File.Exists(filePath))
            {
                var file = new SecurityFile(filePath);
                var lstAll = file.ReadAll().Distinct();
                var it = lstAll.SingleOrDefault(x => x.Code == stockCode);

                if (string.IsNullOrEmpty(it.Code.Trim()))
                    return null;

                return it;
            }

            return null;
        }
コード例 #5
0
        public bool CheckLicense()
        {
            bool   ischecked = false;
            string path      = Path.Combine(this.ApplicationPath, "vgs.dll");

            if (File.Exists(path))
            {
                SecurityFile _SecurityFile = new SecurityFile(path);
                _SecurityFile.Validate();
                ischecked = _SecurityFile.Authenticated;
                if (ischecked)
                {
                    //update datetime
                    _SecurityFile.Date = System.DateTime.Now;
                    _SecurityFile.Update("VHF");
                }
            }
            return(ischecked);
        }