Пример #1
0
        private void GetRemoteModule()
        {
            LoginService module = Activator.GetObject(typeof(LoginService)
                     , string.Format("http://{0}:{1}/Srvtools.rem", IP, Port)) as LoginService;
            try
            {
                module.ToString();
                Module = module;
            }
            catch (ThreadAbortException)
            {

            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Пример #2
0
        private bool Register(bool showmessage, String IP, String Port)
        {
            if (IP != "")
            {
                CliUtils.fRemoteIP = IP;
                if (Port == null || Port == "")
                    CliUtils.fRemotePort = 8989;
                else
                    CliUtils.fRemotePort = Convert.ToInt16(Port);
                LoginService loginService = new LoginService(); // Remoting object
            GetLoginService:
                // Try to connect to server, reobtain service from the master server if failed
                try
                {
                    EEPRemoteModule module = Activator.GetObject(typeof(EEPRemoteModule),
                        string.Format("http://{0}:" + CliUtils.fRemotePort + "/InfoRemoteModule.rem", CliUtils.fRemoteIP)) as EEPRemoteModule;
                    // module.ToString(); andy kao modified
                }
                catch
                {
                    loginService.DeRegisterRemoteServer(CliUtils.fRemoteIP, CliUtils.fRemotePort);
                    goto GetLoginService;
                }

                // Register EEPRemoteModule on the server
                WellKnownClientTypeEntry clientEntry = new WellKnownClientTypeEntry(typeof(EEPRemoteModule),
                    string.Format("http://{0}:" + CliUtils.fRemotePort + "/InfoRemoteModule.rem", CliUtils.fRemoteIP));
                RemotingConfiguration.RegisterWellKnownClientType(clientEntry);

                // End Add
                isRegister = true;
            }
            return isRegister;
        }
Пример #3
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            CliUtils.fClientLang = GetClientLanguage();
            String s;
            s = Application.StartupPath + "\\";
            RemotingConfiguration.Configure(s + "EEPNetRunStep.exe.config", true);

            RegistryKey rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\infolight\\eep.net");
            String sPath = (String)rk.GetValue("Server Path");
            rk.Close();
            if (sPath.Length > 0 && sPath[sPath.Length - 1] != '\\') sPath = sPath + "\\";
            string name = "EEPNetRunStep";

            try
            {
                XmlDocument DBXML = new XmlDocument();
                FileStream aFileStream;
                if (!File.Exists(sPath + "Path.xml"))
                {
                    try
                    {
                        aFileStream = new FileStream(sPath + "Path.xml", FileMode.Create, FileAccess.ReadWrite, FileShare.None);
                        try
                        {
                            XmlTextWriter w = new XmlTextWriter(aFileStream, new System.Text.ASCIIEncoding());
                            w.Formatting = Formatting.Indented;
                            w.WriteStartElement("InfolightAutoRunMessage");
                            w.WriteEndElement();
                            w.Close();
                        }
                        finally
                        {
                            aFileStream.Close();
                        }
                    }
                    catch (Exception e)
                    {
                        string str = e.Message;
                    }
                }

                try
                {
                    aFileStream = new FileStream(sPath + "Path.xml", FileMode.Open, FileAccess.ReadWrite, FileShare.None);
                    try
                    {
                        DBXML.Load(aFileStream);
                        XmlNode aNode = null;

                        for (int j = DBXML.DocumentElement.ChildNodes.Count - 1; j >= 0; j--)
                        {
                            if (DBXML.DocumentElement.ChildNodes[j].Attributes["Name"].InnerText.Trim().ToUpper().Equals(name.ToUpper()))
                            {
                                aNode = DBXML.DocumentElement.ChildNodes[j];
                                break;
                            }
                        }

                        if (aNode == null)
                        {

                            XmlElement elem = DBXML.CreateElement("String");

                            XmlAttribute attr = DBXML.CreateAttribute("Name");
                            attr.Value = name;
                            elem.Attributes.Append(attr);

                            attr = DBXML.CreateAttribute("Path");
                            attr.Value = Application.StartupPath;
                            elem.Attributes.Append(attr);

                            DBXML.DocumentElement.AppendChild(elem);
                        }
                        else
                        {
                            aNode.Attributes["Path"].InnerText = Application.StartupPath;
                        }
                    }
                    finally
                    {
                        aFileStream.Close();
                    }
                    DBXML.Save(sPath + "Path.xml");
                }
                catch (Exception e)
                {
                    string str = e.Message;
                }
            }
            finally { }

            LoginService loginService = new LoginService(); // Remoting object

            BeginObtainService:
            // Obtain service from the master server
            string serverIP = "";

            try
            {
                serverIP = loginService.GetServerIP();

            }
            catch (Exception err)
            {
                if ((string.Compare(err.Message.ToLower(), "unable to connect to the remote server") == 0) &&
                    CliUtils.PassByEEPListener())
                {
                    try
                    {
                        CliUtils.EEPListenerService.StartupEEPNetServer();
                    }
                    catch (Exception E)
                    {
                        MessageBox.Show(E.Message);
                        //this.Close();
                        return;
                    }
                    goto BeginObtainService;
                }
                else
                {
                    MessageBox.Show(err.Message);
                    //this.Close();
                    return;
                }
            }

            if (serverIP == null || serverIP.Trim() == "")
            {
                MessageBox.Show("Can not login due to busy service");
                //this.Close();
                return;
            }

            // Try to connect to server, reobtain service from the master server if failed
            try
            {
                EEPRemoteModule module = Activator.GetObject(typeof(EEPRemoteModule),
                    string.Format("http://{0}:8989/InfoRemoteModule.rem", serverIP)) as EEPRemoteModule;
                module.ToString();
            }
            catch
            {
                loginService.DeRegisterRemoteServer(serverIP);
                goto BeginObtainService;
            }

            // Register EEPRemoteModule on the server
            WellKnownClientTypeEntry clientEntry = new WellKnownClientTypeEntry(typeof(EEPRemoteModule),
                string.Format("http://{0}:8989/InfoRemoteModule.rem", serverIP));
            RemotingConfiguration.RegisterWellKnownClientType(clientEntry);

            // End Add
            if (args.Length > 0)
            {
                string[] temp = args[0].Split('!');
                string userMessage = temp[0];
                string[] packageMessage = temp[1].Split(',');
                string interval = temp[2];
                string log = temp[3];
                Mutex m = new Mutex(false, userMessage);
                Application.Run(new frmEEPNetRunStep(userMessage, packageMessage, interval, log));
            }
            else
                Application.Run(new frmEEPNetRunStep());
        }