Exemplo n.º 1
0
        /// <summary>
        /// 检查加密狗
        /// </summary>
        /// <returns></returns>
        public static bool Check()
        {
            bool result = true;

            SoftDogReader reader = new SoftDogReader();
            SoftDogInfo   info   = null;

            try
            {
                info = reader.ReadDog();
                if (info == null)
                {
                    MessageBox.Show(Resource1.FrmMain_SoftDogError, Resource1.Form_Alert);
                    result = false;
                }
                else if ((info.SoftwareList & SoftwareType.TYPE_PARK) == 0)  //没有写停车场权限
                {
                    MessageBox.Show(Resource1.FrmMain_SoftDogNoRights, Resource1.Form_Alert);
                    result = false;
                }
                else if (info.ExpiredDate.AddDays(15) < DateTime.Today)
                {
                    MessageBox.Show(Resource1.FrmMain_SoftDogExpired, Resource1.Form_Alert);
                    result = false;
                }
            }
            catch (InvalidOperationException ex)
            {
                Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
                result = false;
            }

            return(result);
        }
Exemplo n.º 2
0
 private void btnRead_Click(object sender, EventArgs e)
 {
     try
     {
         SoftDogInfo info = _Writer.ReadDog();
         if (info != null)
         {
             ShowDog(info);
             MessageBox.Show("读狗成功");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 3
0
 private void btnRead_Click(object sender, EventArgs e)
 {
     try
     {
         SoftDogInfo info = _Writer.ReadDog();
         txtProjectID.IntergerValue = info.ProjectNo;
         this.chk学生体测.Checked       = (info.SoftwareList & SoftwareType.TYPE_汇海学生体测软件) == SoftwareType.TYPE_汇海学生体测软件;
         this.chk汇海中考软件.Checked     = (info.SoftwareList & SoftwareType.TYPE_汇海中考软件) == SoftwareType.TYPE_汇海中考软件;
         this.chk国民体测.Checked       = (info.SoftwareList & SoftwareType.TYPE_汇海国民体测软件) == SoftwareType.TYPE_汇海国民体测软件;
         this.chk运动会.Checked        = (info.SoftwareList & SoftwareType.TYPE_汇海运动会软件) == SoftwareType.TYPE_汇海运动会软件;
         dtStart.Value = info.StartDate;
         dtEnd.Value   = info.ExpiredDate;
         MessageBox.Show("读狗成功");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 4
0
        private bool _HasGenerateResult  = false; //是否已经自动生成了考勤结果,用于自动生成考勤结果
        #endregion

        #region 私有方法
        private void ReadSoftDog()
        {
            SoftDogReader reader = new SoftDogReader();
            SoftDogInfo   info   = null;
            bool          ret    = true;

            try
            {
                info = reader.ReadDog();
                if (info == null)
                {
                    MessageBox.Show(LJH.Attendance.UI.Properties.Resources.FrmMain_SoftDogError, LJH.Attendance.UI.Properties.Resources.Form_Alert);
                    ret = false;
                }
                else if ((info.SoftwareList & SoftwareType.TYPE_TA) == 0)  //没有写考勤软件权限
                {
                    MessageBox.Show(LJH.Attendance.UI.Properties.Resources.FrmMain_SoftDogNoRights, LJH.Attendance.UI.Properties.Resources.Form_Alert);
                    ret = false;
                }
                else if (info.ExpiredDate < DateTime.Today && info.ExpiredDate.AddDays(15) >= DateTime.Today) //已经过期
                {
                    DateTime expire = info.ExpiredDate.AddDays(15);
                    TimeSpan ts     = new TimeSpan(expire.Ticks - DateTime.Today.Ticks);
                    MessageBox.Show(string.Format(LJH.Attendance.UI.Properties.Resources.FrmMain_SoftDogExpiredAlert, (int)(ts.TotalDays + 1)), LJH.Attendance.UI.Properties.Resources.Form_Alert);
                }
                else if (info.ExpiredDate.AddDays(15) < DateTime.Today)
                {
                    MessageBox.Show(LJH.Attendance.UI.Properties.Resources.FrmMain_SoftDogExpired, LJH.Attendance.UI.Properties.Resources.Form_Alert);
                    ret = false;
                }
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show(ex.Message);
                ret = false;
            }

            if (!ret)
            {
                System.Environment.Exit(0);
            }
        }
Exemplo n.º 5
0
        private void ReadSoftDog()
        {
            string skey = AppSettings.Current.GetConfigContent("SKey");

            if (string.IsNullOrEmpty(skey))
            {
                skey = @"#i~xnUc4RH1G@\)$&7z6qv9xy@~<mTR5nUR?OU}jh`4r<qN>:*xZwz~E$0";
                AppSettings.Current.SaveConfig("SKey", skey);
            }
            SoftDogReader reader = new SoftDogReader(skey);

            try
            {
                _SoftDog = reader.ReadDog();
                if (_SoftDog == null)
                {
                    MessageBox.Show("加密狗访问错误:没有找到加密狗。如果加密狗已经插上,则可能是加密狗还没有加密,请先联系厂家进行加密!", "注意");
                    System.Environment.Exit(0);
                }
                else if ((_SoftDog.SoftwareList & SoftwareType.TYPE_Inventory) == 0)  //没有写停车场权限
                {
                    MessageBox.Show("加密狗权限不足:原因可能是加密狗中没有开放进销存软件权限,请联系厂家开放相应的权限!", "注意");
                    System.Environment.Exit(0);
                }
                else if (_SoftDog.ExpiredDate < DateTime.Today && _SoftDog.ExpiredDate.AddDays(15) >= DateTime.Today) //已经过期
                {
                    DateTime expire = _SoftDog.ExpiredDate.AddDays(15);
                    TimeSpan ts     = new TimeSpan(expire.Ticks - DateTime.Today.Ticks);
                    MessageBox.Show(string.Format("软件已经过期,还可以再试用 {0} 天,请尽快与供应商联系延长您的软件使用期!", (int)(ts.TotalDays + 1)), "注意");
                }
                else if (_SoftDog.ExpiredDate.AddDays(15) < DateTime.Today)
                {
                    MessageBox.Show("软件已经过期,请联系厂家延长期限!", "注意");
                    System.Environment.Exit(0);
                }
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show(ex.Message);
                System.Environment.Exit(0);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 检查停车场加密狗权限
        /// </summary>
        /// <returns></returns>
        public static bool VerifyRight()
        {
            SoftDogReader reader = new SoftDogReader();
            SoftDogInfo   info   = null;

            try
            {
                info = reader.ReadDog();
                if (info == null)
                {
                    MessageBox.Show(Resource1.FrmMain_SoftDogError, Resource1.Form_Alert);
                    return(false);
                }
                else if ((info.SoftwareList & SoftwareType.TYPE_PARK) == 0)  //没有写停车场权限
                {
                    MessageBox.Show(Resource1.FrmMain_SoftDogNoRights, Resource1.Form_Alert);
                    return(false);
                }
                else if (info.ExpiredDate < DateTime.Today && info.ExpiredDate.AddDays(15) >= DateTime.Today) //已经过期
                {
                    DateTime expire = info.ExpiredDate.AddDays(15);
                    TimeSpan ts     = new TimeSpan(expire.Ticks - DateTime.Today.Ticks);
                    MessageBox.Show(string.Format(Resource1.FrmMain_SoftDogExpiredAlert, (int)(ts.TotalDays + 1)), Resource1.Form_Alert);
                }
                else if (info.ExpiredDate.AddDays(15) < DateTime.Today)
                {
                    MessageBox.Show(Resource1.FrmMain_SoftDogExpired, Resource1.Form_Alert);
                    return(false);
                }
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }

            return(true);
        }
Exemplo n.º 7
0
 private void button1_Click(object sender, EventArgs e)
 {
     SoftDogReader reader = new SoftDogReader();
     SoftDogInfo   dog    = reader.ReadDog();
 }