Exemplo n.º 1
0
        public SwitchCoreServer()
        {
            InitializeComponent();

            MyCall += new u2ec.OnChangeDevList(SwitchCoreServer_MyCall);
            u2ec.SetCallBackOnChangeDevList(MyCall);

            syspath = Environment.CurrentDirectory + "\\config.ini";
            licf    = new LoadIniConfigFile(syspath);
            Trace.WriteLine("Load Syspath configpath.ini file status is:--- --- " + licf.initConfig().ToString());

            heartbeat = new Heartbeat(licf.Ic.Heartbeat.Hbpath);

            //获取所有的共享设备
            showshared();
            //判断是否有共享的设备,如果没有共享的设备,则判断是否配置文件有配置端口,如果有则开放该接口共享
            if (lssharedport.Count < 1)
            {
                if (!licf.Ic.Server.Port.Equals(0))
                {
                    u2ec.ClientAddRemoteDevManually(licf.Ic.Server.Port.ToString());
                    showshared();
                    int SelectedIndex = 0;
                    u2ec.ClientStartRemoteDev(HandleClient, SelectedIndex, true, "");
                }
                else
                {
                    MessageBox.Show("connect error,system config is null");
                }
            }
            txt_port_stat.Text = "没有监听的接口状态";
            for (int i = 0; i < lssharedport.Count; i++)
            {
                if (getPortStat(i).Split('/')[1].Equals(licf.Ic.Server.Port.ToString()))
                {
                    txt_port_stat.Text      = getPortStat(i);
                    txt_connectcontext.Text = lssharedport[i];
                }
            }

            //进入正常运行,判断端口状态
            //监控程序运行

            SwitchCoreServer_MyCall();

            Console.WriteLine("System start finished in" + DateTime.Now.ToString());
            Trace.WriteLine("System start finished in" + DateTime.Now.ToString());
        }
Exemplo n.º 2
0
        public SmallAnt()
        {
            InitializeComponent();

            //绑定设备变化监控操作过程接口
            MyCall += new u2ec.OnChangeDevList(OnChangeDevList_MyCall);
            u2ec.SetCallBackOnChangeDevList(MyCall);

            //设置本地系统配置文件路径
            syspath = Environment.CurrentDirectory + "\\config.ini";
            //加载系统配置文件
            licf = new LoadIniConfigFile(syspath);
            Trace.WriteLine("Load Syspath configpath.ini file status is:--- " + DateTime.Now.ToString() + " --- " + licf.initConfig().ToString());

            //端口在这里,还是单机单端口版本
            lbl_confport.Text = licf.Ic.Server.Port.ToString();
            //初始化其余端口状态数值
            lbl_kpDelay.Text    = licf.Ic.Delay.Time.ToString();
            lbl_listenport.Text = licf.Ic.Listen.Port.ToString();
            this.Text           = this.Text + "【" + licf.Ic.Heartbeat.Nsrsbh + ":" + licf.Ic.Heartbeat.Kjh + "】";
            connectingLock      = cb_waitclock.Checked;

            //心跳机制
            heartbeat = new Heartbeat(licf.Ic.Heartbeat.Hbpath);

            //刷新显示目前所有共享设备状态
            showshared();

            ///
            /// 判断是否有共享的设备,如果没有共享的设备,则判断是否配置文件有配置端口
            /// 如果有端口则开放该端口进行共享
            /// 这里有逻辑问题!!!!!!
            ///
            if (lssharedport.Count < 1)
            {
                if (!licf.Ic.Server.Port.Equals(0))
                {
                    u2ec.ClientAddRemoteDevManually(licf.Ic.Server.Port.ToString());
                    showshared();
                    int SelectedIndex = 0;
                    u2ec.ClientStartRemoteDev(HandleClient, SelectedIndex, true, "");
                }
                else
                {
                    Trace.WriteLine("init connect error,system config ini file is has null value");
                    MessageBox.Show(small_ant.Properties.Resources.iniPortError, small_ant.Properties.Resources.errorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            lbl_port_stat.Text = "没有监听的接口状态";
            for (int i = 0; i < lssharedport.Count; i++)
            {
                btn_getstatus_Click(i, null);
                if (statusfull.Split('/')[1].Equals(licf.Ic.Server.Port.ToString()))
                {
                    lbl_port_stat.Text      = statusfull;
                    lbl_connectcontext.Text = lssharedport[i];
                }
            }


            //进入正常运行,判断端口状态
            //监控程序运行

            OnChangeDevList_MyCall();
        }
Exemplo n.º 3
0
        private void button3_Click(object sender, EventArgs e)
        {
            LoadIniConfigFile licf = new LoadIniConfigFile(Environment.CurrentDirectory + "\\config.ini");

            MessageBox.Show(licf.initConfig().ToString());
            MessageBox.Show(licf.Ic.Heartbeat.Hbpath);

            //OPini.InitSystem();

            //MessageBox.Show(this.node.Nodes.Count.ToString());

            //SwitchCoreServer_MyCall();

            //showshared();

            //try
            //{
            //    MessageBox.Show(dictionary["s-0"]);
            //    MessageBox.Show(dictionary["s-1"]);
            //    MessageBox.Show(dictionary["s-2"]);
            //}
            //catch (KeyNotFoundException ex) {
            //    Console.Write(ex.Message);
            //}

            //Process[] procs = Process.GetProcesses();
            //listBoxP.Items.Clear();
            //for (int i = 0; i < procs.Length; i++)
            //{
            //    Process q = procs[i];
            //    listBoxP.Items.Add(q.ProcessName);
            //}



            //Process p = procs[0];
            //int procId = p.Id;
            //Process p2 = Process.GetProcessById(procId);

            //String sn = dictionary["s-0"];
            //String[] spi = sn.Split('\\');
            //if (spi.Length > 1)
            //{
            //    MessageBox.Show(spi[1]);
            //}

            //System.Diagnostics.Process p = new System.Diagnostics.Process();
            //p.StartInfo.FileName = "cmd.exe";
            //p.StartInfo.UseShellExecute = false;    //是否使用操作系统shell启动
            //p.StartInfo.RedirectStandardInput = true;//接受来自调用程序的输入信息
            //p.StartInfo.RedirectStandardOutput = false;//由调用程序获取输出信息
            //p.StartInfo.RedirectStandardError = false;//重定向标准错误输出
            //p.StartInfo.CreateNoWindow = false;//不显示程序窗口
            //p.Start();//启动程序

            ////向cmd窗口发送输入信息
            //p.StandardInput.WriteLine(dictionary["s-0"]);

            //p.StandardInput.AutoFlush = true;
            ////p.StandardInput.WriteLine("exit");
            ////向标准输入写入要执行的命令。这里使用&是批处理命令的符号,表示前面一个命令不管是否执行成功都执行后面(exit)命令,如果不执行exit命令,后面调用ReadToEnd()方法会假死
            ////同类的符号还有&&和||前者表示必须前一个命令执行成功才会执行后面的命令,后者表示必须前一个命令执行失败才会执行后面的命令



            ////获取cmd窗口的输出信息
            ////string output = p.StandardOutput.ReadToEnd();

            ////StreamReader reader = p.StandardOutput;
            ////string line=reader.ReadLine();
            ////while (!reader.EndOfStream)
            ////{
            ////    str += line + "  ";
            ////    line = reader.ReadLine();
            ////}

            //p.WaitForExit();//等待程序执行完退出进程
            //p.Close();

            //MessageBox.Show(output);
            //Console.WriteLine(output);

            //MessageBox.Show(dictionary["s-0"]);
            //Process.Start(@"C:\Users\BJZS\Desktop\startup - 快捷方式.lnk");

            //try
            //{
            //    System.Diagnostics.Process[] ps = System.Diagnostics.Process.GetProcessesByName(dictionary["p-0"]);
            //    foreach (System.Diagnostics.Process p in ps)
            //    {
            //        p.Kill();
            //    }
            //}
            //catch (Exception ex)
            //{
            //    throw ex;
            //}

            //Process.Start(dictionary["s-0"]);

            //Thread threadC = new Thread(closeApp);
            //threadC.Start(dictionary);
        }