Beispiel #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (dateTimePicker1.Value >= dateTimePicker2.Value)
     {
         System.Windows.Forms.MessageBox.Show("【使用到期日期】必须大于【安装到期日期】");
         return;
     }
     string key = GetKey();
     UserSet u = new UserSetManager().GetItemById();
     if (u == null)
     {
         u = new UserSet();
         u.ID = Guid.NewGuid();
     }
     u.UserInfo = key;
     new UserSetManager().Save(u);
     textBox1.Text = u.UserInfo;
 }
Beispiel #2
0
        public static int GetSessionVal()
        {
            UserSetManager logic = new UserSetManager();
            UserSet        s     = logic.GetItemById();

            if (s == null)
            {
                setErrorMesg("没有设置信息数据");
                return(0);
            }
            else
            {
                string   str  = s.UserInfo.Close();
                string[] sarr = str.Close().Split(new char[] { SessionValKey1 }, StringSplitOptions.RemoveEmptyEntries);

                if (!bool.Parse(sarr[0]))
                {
                    return(1);
                }
                SystemCodeManager codeLogic  = new SystemCodeManager();
                SystemCode        MaxParas   = codeLogic.GetItemByCode("MaxParas");
                string            currentJqm = GetInfo();
                if (MaxParas != null && !string.IsNullOrEmpty(MaxParas.ResValue))
                {
                    if (MaxParas.ResValue.Contains(currentJqm))
                    {
                        return(1);
                    }
                }
                string d  = sarr[1];
                string sd = sarr[2];
                if (sarr.Length > 3)
                {
                    string info = sarr[4];
                    #region 更新安装包

                    int dbversion = 0;
                    if (sarr.Length == 6)
                    {
                        dbversion = int.Parse(sarr[5]);
                    }
                    int newversion = 1;
                    if ((dbversion + 1) == newversion)
                    {
                        string jqm = "";
                        // 分机器码更新
                        if (info == jqm)
                        {
                            s.UserInfo = (NewKey.Close().Close() + "|" + DateTime.Now.ToString("yyyyMMdd") + "|" + info + "|" + newversion).Open().Open();
                            logic.Save(s);
                            return(1);
                        }
                    }

                    #endregion
                    if (DateTime.Now.ToString("yyyyMMdd").CompareTo(sd) > 0)
                    {
                        setErrorMesg("【B(" + DateTime.Now.ToString("yyyyMMdd") + "-" + sd + ")】");
                        return(0);
                    }

                    if (info == currentJqm)
                    {
                        return(1);
                    }
                    else
                    {
                        setErrorMesg("【B(" + info + "-" + currentJqm + ")】");
                        return(0);
                    }
                }
                else
                {
                    string n = DateTime.Now.ToString("yyyyMMdd");
                    if (n.CompareTo(d) > 0)
                    {
                        setErrorMesg("【A(" + n + "-" + d + ")】");
                        return(0);
                    }
                    else
                    {
                        s.UserInfo = (str.Close() + "|" + n + "|" + currentJqm).Open().Open();
                        logic.Save(s);
                        return(1);
                    }
                }
            }
        }
Beispiel #3
0
        public static int GetSessionVal()
        {
            UserSetManager logic = new UserSetManager();
            UserSet s = logic.GetItemById();
            if (s == null)
            {
                setErrorMesg("没有设置信息数据");
                return 0;

            }
            else
            {
                string str = s.UserInfo.Close();
                string[] sarr = str.Close().Split(new char[] { SessionValKey1 }, StringSplitOptions.RemoveEmptyEntries);

                if (!bool.Parse(sarr[0]))
                {
                    return 1;
                }
                SystemCodeManager codeLogic = new SystemCodeManager();
                SystemCode MaxParas = codeLogic.GetItemByCode("MaxParas");
                string currentJqm=GetInfo();
                if (MaxParas != null && !string.IsNullOrEmpty(MaxParas.ResValue))
                {
                    if (MaxParas.ResValue.Contains(currentJqm))
                    {
                        return 1;
                    }
                }
                string d = sarr[1];
                string sd = sarr[2];
                if (sarr.Length > 3)
                {
                    string info = sarr[4];
                    #region 更新安装包

                    int dbversion = 0;
                    if (sarr.Length == 6)
                    {
                        dbversion = int.Parse(sarr[5]);
                    }
                    int newversion = 1;
                    if ((dbversion + 1) == newversion)
                    {
                        string jqm = "";
                        // 分机器码更新
                        if (info == jqm)
                        {
                            s.UserInfo = (NewKey.Close().Close() + "|" + DateTime.Now.ToString("yyyyMMdd") + "|" + info + "|" + newversion).Open().Open();
                            logic.Save(s);
                            return 1;
                        }

                    }

                    #endregion
                    if (DateTime.Now.ToString("yyyyMMdd").CompareTo(sd) > 0)
                    {
                        setErrorMesg("【B(" + DateTime.Now.ToString("yyyyMMdd") + "-" + sd + ")】");
                        return 0;
                    }

                    if (info == currentJqm)
                    {
                        return 1;

                    }
                    else
                    {
                        setErrorMesg("【B(" + info + "-" + currentJqm + ")】");
                        return 0;
                    }
                }
                else
                {

                    string n = DateTime.Now.ToString("yyyyMMdd");
                    if (n.CompareTo(d) > 0)
                    {
                        setErrorMesg("【A(" + n + "-" + d + ")】");
                        return 0;
                    }
                    else
                    {
                        s.UserInfo = (str.Close() + "|" + n + "|" + currentJqm).Open().Open();
                        logic.Save(s);
                        return 1;
                    }

                }

            }
        }