/// <summary>
        /// 
        /// </summary>
        /// <param name="args"></param>
        public void Main(string[] args)
        {
            bool loadCs = false;
            try
            {
                //if (args.Length < 2)
                //{
                //    MessageForm.ShowError("运行应用程序错误!");
                //    return;
                //}

                ProgramHelper.InitProgram();

                loadCs = SecurityHelper.LoadConnectionStrings();
                SecurityHelper.SelectAutomaticServer();
                //SecutiryHelper.SaveConnectionStrings("connectionStrings.config", "Data\\Dbs.dat");

                bool outerLogin = true;
                Dictionary<string, string> dictArgs = Feng.Utils.StringHelper.ParseCommandLineArgs(args);
                if (dictArgs.ContainsKey("username") && dictArgs["username"] == "anonymous"
                    && dictArgs.ContainsKey("password") && dictArgs["password"] == "nowandfuture")
                {
                    outerLogin = false;
                }
                // no more parameters
                if (dictArgs.Count == 0)
                {
                    outerLogin = false;
                }

                if (outerLogin)
                {
                    if (!dictArgs.ContainsKey("username") || !dictArgs.ContainsKey("password"))
                        return;

                    var p = LoginHelper.Login(dictArgs["username"], dictArgs["password"]);
                    if (p == null)
                        return;

                    System.Threading.Thread.CurrentPrincipal = p;
                }
                else
                {
                    using (LoginForm frm = new LoginForm())
                    {
                        if (frm.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }
                    }
                }

                UserActions.Instance.LoginUser();

                RunProgram();

                //if (outerLogin)
                //{
                //    string fileName = "Feng.Run.exe.config";
                //    if (System.IO.File.Exists(fileName))
                //    {
                //        System.IO.File.Delete(fileName);
                //    }
                //}
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "出现严重错误,程序将关闭!");
            }
            finally
            {
                SecurityHelper.DeselectAutomaticServer();

                if (loadCs)
                {
                    SecurityHelper.RemoveConnectionStrings();
                }
            }
        }
        private void tsmRelogin_Click(object sender, EventArgs e)
        {
            using (LoginForm frm = new LoginForm(false))
            {
                if (frm.ShowDialog(this) == DialogResult.OK)
                {
                    UserActions.Instance.LogoutUser();

                    tsmCloseAll_Click(tsmCloseAll, System.EventArgs.Empty);

                    SystemDirectory.Clear();
                    SystemProfileFile.Clear();

                    UserActions.Instance.LoginUser();

                    ResetPerUser();
                }
            }
        }