Exemplo n.º 1
0
        private void ToolStripMenuItemRegister_Click(object sender, EventArgs e)
        {
            FormRegister dlg    = new FormRegister();
            string       strMac = CGeneralFunction.GetMACaddressOne();

            SimpleScrypt SScrypt = new SimpleScrypt();

            dlg.CodeNO = SScrypt.Encrypt(strMac);
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                //实现注册代码,有待修改
                MessageBox.Show("程序必须重新启动!");
                CAppOption.RegKeyNO = dlg.KeyNO;
                CAppOption.SaveData();
                CAppOption.SaveKeyNO();

                Application.Exit();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 加载数据
        /// </summary>
        public static void LoadData()
        {
            string szOptionFile;

            szOptionFile = System.Windows.Forms.Application.StartupPath + "\\Option.dat";
            if (System.IO.File.Exists(szOptionFile))
            {
                System.Text.StringBuilder szValue = new System.Text.StringBuilder("", 256);

                int iRet;
                iRet = PlatformInvokeKernel32.GetPrivateProfileString("App", "AppStyle", iAppStyle.ToString(), szValue, 256, szOptionFile);
                try
                {
                    iAppStyle = Convert.ToInt32(szValue.ToString());
                }
                catch
                {
                }

                iRet = PlatformInvokeKernel32.GetPrivateProfileString("Windows", "Style", iFormStyle.ToString(), szValue, 256, szOptionFile);

                try
                {
                    iFormStyle = Convert.ToInt32(szValue.ToString());
                }
                catch
                {
                }
                iRet = PlatformInvokeKernel32.GetPrivateProfileString("Windows", "SortStyle", iSortStyle.ToString(), szValue, 256, szOptionFile);

                try
                {
                    iSortStyle = Convert.ToInt32(szValue.ToString());
                }
                catch
                {
                }
                iRet = PlatformInvokeKernel32.GetPrivateProfileString("Windows", "NumberFormat", NumberFormat, szValue, 256, szOptionFile);

                NumberFormat = szValue.ToString();
                if (NumberFormat == "")
                {
                    NumberFormat = "0.00";
                }

                iRet = PlatformInvokeKernel32.GetPrivateProfileString("Windows", "MoneyFormat", MoneyFormat, szValue, 256, szOptionFile);

                MoneyFormat = szValue.ToString();
                if (MoneyFormat == "")
                {
                    MoneyFormat = "0.00";
                }

                iRet = PlatformInvokeKernel32.GetPrivateProfileString("Windows", "PageRowCount", PageRowCount.ToString(), szValue, 256, szOptionFile);

                try
                {
                    PageRowCount = Convert.ToInt32(szValue.ToString());
                    if (PageRowCount < 10)
                    {
                        PageRowCount = 22;
                    }
                }
                catch
                {
                    PageRowCount = 22;
                }

                iRet      = PlatformInvokeKernel32.GetPrivateProfileString("App", "Idiograph", "", szValue, 256, szOptionFile);
                Idiograph = szValue.ToString();

                //注册码
                iRet         = PlatformInvokeKernel32.GetPrivateProfileString("Register", "Code", "", szValue, 256, szOptionFile);
                RegisterCode = szValue.ToString();

                iRet         = PlatformInvokeKernel32.GetPrivateProfileString("Register", "User", "", szValue, 256, szOptionFile);
                RegisterUser = szValue.ToString();

                string[] MacList = CGeneralFunction.GetMac();
                ChefMonitor.CGlobalInstance.Instance.FileLogger.WriteLog(YyLogger.LogSeverity.info, "配置加载", string.Format("Mac:{0}", MacList[0]));

                if (MacList.Length > 0)
                {
                    SimpleScrypt SScrypt = new SimpleScrypt();
                    if (SScrypt.Encrypt(MacList[0]) == RegisterCode)
                    {
                        bRegister = true;
                    }
                    if (!string.IsNullOrEmpty(RegisterUser) && SScrypt.Encrypt(RegisterUser) == RegisterCode)
                    {
                        bRegister = true;
                    }
#if DEBUG
                    if (bRegister == false)
                    {
                        ChefMonitor.CGlobalInstance.Instance.FileLogger.WriteLog(YyLogger.LogSeverity.info, "配置加载", string.Format("RegisterCode:{0}", SScrypt.Encrypt(MacList[0])));
                        ChefMonitor.CGlobalInstance.Instance.FileLogger.WriteLog(YyLogger.LogSeverity.info, "配置加载", string.Format("RegisterCode:{0}", SScrypt.Encrypt(RegisterUser)));
                    }
#endif
                }
            }
            WindowStyleMan.LoadData();


            RegistryKey oRegSoft;
            oRegSoft = Registry.LocalMachine.OpenSubKey("SOFTWARE", true);
            if (oRegSoft == null)
            {
                //建立
                oRegSoft = Registry.LocalMachine.CreateSubKey("SOFTWARE");
            }

            RegistryKey oRegTemp = oRegSoft.OpenSubKey(Application.ProductName, true);
            if (oRegTemp == null)
            {
                oRegTemp = oRegSoft.CreateSubKey(Application.ProductName);
            }
            m_sUser = (string)oRegTemp.GetValue("User", "Admin");

            m_sPwd = ""; //20090110修改,不再
                         //m_sPwd=Decrypt((string)oRegTemp.GetValue("Pwd",""));

            m_sDbConnectString = CYyScrypt.Decrypt((string)oRegTemp.GetValue("DbConnect", CYyScrypt.Encrypt(m_sDbConnectString)));
            m_bSavePwd         = Convert.ToBoolean(oRegTemp.GetValue("SavePwd", true));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 加载数据
        /// </summary>
        public static void LoadData()
        {
            string szOptionFile;

            szOptionFile = System.Windows.Forms.Application.StartupPath + "\\Option.dat";
            if (System.IO.File.Exists(szOptionFile))
            {
                System.Text.StringBuilder szValue = new System.Text.StringBuilder("", 256);

                int iRet;
                iRet = PlatformInvokeKernel32.GetPrivateProfileString("App", "AppStyle", iAppStyle.ToString(), szValue, 256, szOptionFile);
                try
                {
                    iAppStyle = Convert.ToInt32(szValue.ToString());
                }
                catch
                {
                }

                iRet = PlatformInvokeKernel32.GetPrivateProfileString("Windows", "Style", iFormStyle.ToString(), szValue, 256, szOptionFile);

                try
                {
                    iFormStyle = Convert.ToInt32(szValue.ToString());
                }
                catch
                {
                }
                iRet = PlatformInvokeKernel32.GetPrivateProfileString("Windows", "SortStyle", iSortStyle.ToString(), szValue, 256, szOptionFile);

                try
                {
                    iSortStyle = Convert.ToInt32(szValue.ToString());
                }
                catch
                {
                }
                iRet = PlatformInvokeKernel32.GetPrivateProfileString("Windows", "NumberFormat", NumberFormat, szValue, 256, szOptionFile);

                NumberFormat = szValue.ToString();
                if (NumberFormat == "")
                {
                    NumberFormat = "0.00";
                }

                iRet = PlatformInvokeKernel32.GetPrivateProfileString("Windows", "MoneyFormat", MoneyFormat, szValue, 256, szOptionFile);

                MoneyFormat = szValue.ToString();
                if (MoneyFormat == "")
                {
                    MoneyFormat = "0.00";
                }

                iRet = PlatformInvokeKernel32.GetPrivateProfileString("Windows", "PageRowCount", PageRowCount.ToString(), szValue, 256, szOptionFile);

                try
                {
                    PageRowCount = Convert.ToInt32(szValue.ToString());
                    if (PageRowCount < 10)
                    {
                        PageRowCount = 22;
                    }
                }
                catch
                {
                    PageRowCount = 22;
                }

                iRet      = PlatformInvokeKernel32.GetPrivateProfileString("App", "Idiograph", "", szValue, 256, szOptionFile);
                Idiograph = szValue.ToString();

                //注册码
                iRet         = PlatformInvokeKernel32.GetPrivateProfileString("Register", "Code", "", szValue, 256, szOptionFile);
                RegisterCode = szValue.ToString();

                iRet         = PlatformInvokeKernel32.GetPrivateProfileString("Register", "User", "", szValue, 256, szOptionFile);
                RegisterUser = szValue.ToString();

                string strMac = CGeneralFunction.GetMACaddressOne();
                Restaurant.CGlobalInstance.Instance.FileLogger.WriteLog(YyLogger.LogSeverity.info, "配置加载", string.Format("Mac:{0}", strMac));

                if (strMac.Length > 0)
                {
                    SimpleScrypt SScrypt = new SimpleScrypt();
                    if (SScrypt.Encrypt(strMac) == RegisterCode)
                    {
                        bRegister = true;
                    }
                    if (!string.IsNullOrEmpty(RegisterUser) && SScrypt.Encrypt(RegisterUser) == RegisterCode)
                    {
                        bRegister = true;
                    }
#if DEBUG
                    if (bRegister == false)
                    {
                        Restaurant.CGlobalInstance.Instance.FileLogger.WriteLog(YyLogger.LogSeverity.info, "配置加载", string.Format("RegisterCode:{0}", SScrypt.Encrypt(strMac)));
                        Restaurant.CGlobalInstance.Instance.FileLogger.WriteLog(YyLogger.LogSeverity.info, "配置加载", string.Format("RegisterCode:{0}", SScrypt.Encrypt(RegisterUser)));
                    }
#endif
                }
            }
            WindowStyleMan.LoadData();


            RegistryKey oRegSoft;
            oRegSoft = Registry.LocalMachine.OpenSubKey("SOFTWARE", true);
            if (oRegSoft == null)
            {
                //建立
                oRegSoft = Registry.LocalMachine.CreateSubKey("SOFTWARE");
            }

            RegistryKey oRegTemp = oRegSoft.OpenSubKey(Application.ProductName, true);
            if (oRegTemp == null)
            {
                oRegTemp = oRegSoft.CreateSubKey(Application.ProductName);
            }
            m_sUser = (string)oRegTemp.GetValue("User", "Admin");

            m_sPwd = ""; //20090110修改,不再
                         //m_sPwd=Decrypt((string)oRegTemp.GetValue("Pwd",""));

            //Jet的开发已经停止了,所以没有64位的版本。
            //Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\DB\Restaurant.mdb;Persist Security Info=False;Jet OLEDB:DataBase Password=legahero123
            //Provider=Microsoft.ACE.OLEDB.12.0;Data Source=d:\DB\Restaurant.accdb;Persist Security Info=False;Jet OLEDB:DataBase Password=legahero123
            string strAcc = "";//CYyScrypt.Encrypt(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Restaurant.mdb;Persist Security Info=False;Jet OLEDB:DataBase Password=legahero123");
            strAcc = "501D3F1847F9C54142AA6F0AF66D6F44C616C01EE400418CDAC8F89571A22E17D16E33A09E861EB9B253E258914D771FFDFDD75238B3085A49A885C62DFDF07D28F5DB62128B2D2D56D99B6571A27D9997C8EC446A5486366356281FBA2054D696DB7FA70E84BE91652FD7E333AA30A4DCEF7FE9D96538F2A43E3AA1777167209D4FE216F3A74373F152199CF089A987E707D7313E695522A798E4F5CAB316C1D1F72C51761BA18CA5BA726083D45D667DCA404A0CB8A5152BDCC50131A32A2BF554FCFF4FCE7AD9CC98DD954F54B177ED27D8D45E46078D704C8A83E3C4F0A8ED4E069B18936EB1998A7C72599628214665452AE7F5E217D98DD2674884";

#if TMPRELEASE
            //单机版
            m_sDbConnectString = CYyScrypt.Decrypt(strAcc);
#else
            m_sDbConnectString = CYyScrypt.Decrypt((string)oRegTemp.GetValue("DbConnect", CYyScrypt.Encrypt(m_sDbConnectString)));
#endif
            m_bSavePwd = Convert.ToBoolean(oRegTemp.GetValue("SavePwd", true));
        }