コード例 #1
0
        protected override void OnStart(string[] args)
        {
            try
            {
                Thread.CurrentPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());

                ServiceController serviceController_obj = new ServiceController("YakSys RCT Server");

                if (!File.Exists(Application.StartupPath + "\\YakSysRctServerLib.dll"))
                {
                    try
                    {
                        MessageBox.Show(null, ServerStringFactory.GetString(36, ServerSettingsEnvironment.CurrentLanguage), ServerStringFactory.GetString(37, ServerSettingsEnvironment.CurrentLanguage), MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1);

                        serviceController_obj.Refresh();

                        serviceController_obj.Stop();
                    }
                    catch
                    {
                    }

                    return;
                }

                new Thread(new ThreadStart(WatchProcWindowModule)).Start();

                YakSys.XMLConfigImporter.YakSysServerDBEnvironment.LoadXMLDataFile(Application.StartupPath + "\\YakSysServerDB", false);

                NetworkSecurity.LoadSecurityDB(new YakSysServerDBEnvironment().GetSecurityDataBase());

                NetworkSecurity.LoadAccessRestrictionRulesDB(new YakSysServerDBEnvironment().GetAccessRestrictionRules());

                NETRemotingInteractionLayer.StartNETRemotingHost(5550);

                NetworkStatusAndStatistics.ServerStatus = ServerStringFactory.GetString(7, ServerSettingsEnvironment.CurrentLanguage);

                if (ServerSettingsEnvironment.StartServerAtRun == true)
                {
                    if (NetworkSecurity.UserAccount.UsersAccounts.Count == 0)
                    {
                        MessageBox.Show(ServerStringFactory.GetString(69, ServerSettingsEnvironment.CurrentLanguage), ServerStringFactory.GetString(1, ServerSettingsEnvironment.CurrentLanguage), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        try
                        {
                            obj_NetworkAction.StartServer(ServerSettingsEnvironment.ServerPort);//IPC call
                        }
                        catch { }
                        string string_ConnectingServiceHost = CSP.ConnectingServiceProvider.GetCommonCSPIPString();
                    }
                }
            }
            catch (Exception e)
            {
                // MessageBox.Show("Starting YakSys Server Service failed");
            }
        }
コード例 #2
0
        private void button_StartYakSysRCT_Click(object sender, EventArgs e)
        {
            try
            {
                Thread.CurrentPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());

                System.Threading.Thread.Sleep(1000);

                ServiceController serviceController_obj = new ServiceController("YakSys RCT Server");

                if (!File.Exists(Application.StartupPath + "\\YakSysRctServerLib.dll"))
                {
                    try
                    {
                        MessageBox.Show(null, ServerStringFactory.GetString(36, ServerSettingsEnvironment.CurrentLanguage), ServerStringFactory.GetString(37, ServerSettingsEnvironment.CurrentLanguage), MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1);
                    }
                    catch
                    {
                    }

                    return;
                }

                new Thread(new ThreadStart(WatchProcWindowModule)).Start();

                YakSys.XMLConfigImporter.YakSysServerDBEnvironment.LoadXMLDataFile(Application.StartupPath + "\\YakSysServerDB", false);

                YakSys.Server_Core.NetworkSecurity.LoadSecurityDB(new YakSysServerDBEnvironment().GetSecurityDataBase());

                YakSys.Server_Core.NetworkSecurity.LoadAccessRestrictionRulesDB(new YakSysServerDBEnvironment().GetAccessRestrictionRules());

                NETRemotingInteractionLayer.StartNETRemotingHost(5550);

                NetworkStatusAndStatistics.ServerStatus = ServerStringFactory.GetString(7, ServerSettingsEnvironment.CurrentLanguage);



                //!!! ошибка, не считывается DB сервера, не назначается true StartServerAtRun и соответственно не входит в старот сервера. а вообще стартует. почему не отвечает после рефакторинга GUI не понятно
                if (ServerSettingsEnvironment.StartServerAtRun == true)
                {
                    if (NetworkSecurity.UserAccount.UsersAccounts.Count == 0)
                    {
                        MessageBox.Show(ServerStringFactory.GetString(69, ServerSettingsEnvironment.CurrentLanguage), ServerStringFactory.GetString(1, ServerSettingsEnvironment.CurrentLanguage), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        obj_NetworkAction.StartServer(ServerSettingsEnvironment.ServerPort);//IPC call

                        string string_ConnectingServiceHost = CSP.ConnectingServiceProvider.GetCommonCSPIPString();
                    }
                }
            }
            catch (Exception)
            {
                // MessageBox.Show("Starting YakSys Server Service failed");
            }
        }