Ejemplo n.º 1
0
 public LicenseServerOperation(string strFilePath)
 {
     strXmlFilePath = strFilePath + "\\UMP.Server\\Args02.UMP.xml";
     xmlDoc         = new XmlDocument();
     xmlDoc.Load(strXmlFilePath);
     xmlOperator = new XMLOperator(xmlDoc);
 }
Ejemplo n.º 2
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            // Get all information in textbox
            string deviceName = textBox1.Text;
            string deviceIp   = textBox2.Text;
            string deviceUser = textBox3.Text;
            string devicePwd  = textBox4.Text;

            if (deviceName != "" && DataValidator.IsIP(deviceIp) && deviceUser != "" && devicePwd != "")
            {
                if (!XMLOperator.isDeviceExists(deviceName))
                {
                    Device tempDevice = new Device(deviceName, deviceIp, deviceUser, devicePwd);

                    XMLOperator.WriteDevice(tempDevice);
                }
                else
                {
                    MessageBox.Show("此设备已存在", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("输入信息不合法", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 3
0
        public static string GetVoiceServerHostByModuleNumber(int strModuleNumber)
        {
            string strHost = string.Empty;

            try
            {
                DirectoryInfo dir = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\VoiceCyber\\UMP\\config");
                if (!dir.Exists)
                {
                    return(strHost);
                }
                string   strFileName        = string.Format("umpparam_voc{0:0000}.xml", strModuleNumber);
                string   strVoiceleFilePath = dir.FullName + "\\" + strFileName;
                FileInfo fileInfo           = new FileInfo(strVoiceleFilePath);
                if (!fileInfo.Exists)
                {
                    return(strHost);
                }
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(strVoiceleFilePath);
                XMLOperator xmlOperator = new XMLOperator(xmlDoc);
                XmlNode     hostNode    = xmlOperator.SelectNode("Configurations/Configuration/Sites/Site/VoiceServers/VoiceServer/HostAddress", "");
                strHost = xmlOperator.SelectAttrib(hostNode, "Value");
                string LStrVerificationCode101 = Common.CreateVerificationCode(EncryptionAndDecryption.UMPKeyAndIVType.M101);
                strHost = EncryptionAndDecryption.EncryptDecryptString(strHost, LStrVerificationCode101, EncryptionAndDecryption.UMPKeyAndIVType.M101);
                string str = strHost;
            }
            catch (Exception ex)
            {
            }
            return(strHost);
        }
        private void btn_OK_Click(object sender, EventArgs e)
        {
            // Get all information in textbox
            string belongDevice = textBox1.Text;
            string programName  = textBox2.Text;
            string programPath  = textBox3.Text;
            string programArgs  = textBox4.Text;

            if (programName != "" && DataValidator.IsFilePath(programPath))
            {
                if (!XMLOperator.isProgramExists(belongDevice, programName))
                {
                    Bases.Program tempProgram = new Bases.Program(programName, programPath, programArgs, belongDevice);

                    XMLOperator.WriteProgram(tempProgram);
                }
                else
                {
                    MessageBox.Show("该程序已存在", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("输入信息不合法", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 5
0
 private void btn_OK_Click(object sender, EventArgs e)
 {
     if (textBox1.Text != "")
     {
         if (!XMLOperator.isGroupExists(textBox1.Text))
         {
             Group tempGroup = new Group(textBox1.Text);
             foreach (string content in listBox1.Items)
             {
                 string[] tempArray = content.Split(new char[2] {
                     '(', ')'
                 });
                 tempGroup.AddProgram(tempArray[1], tempArray[0]);
             }
             XMLOperator.WriteGroup(tempGroup);
         }
         else
         {
             MessageBox.Show("该分组已存在", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     else
     {
         MessageBox.Show("输入信息不合法", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Ejemplo n.º 6
0
        private string Run()
        {
            if (0 == _orderNo.Length)
            {
                return("0");
            }


            // 获取 32位字符
            nonce_str = (new RandomStringLine(32)).Value;



            XMLOperator _xml = new XMLOperator();

            _xml.SetValue("appid", appid);
            _xml.SetValue("mch_id", mch_id);
            _xml.SetValue("out_trade_no", _orderNo);
            _xml.SetValue("nonce_str", nonce_str);
            _xml.SetValue("sign", Getsign());     // 获取签名

            string _strXML          = _xml.ToXml();
            string _unifiedorderUrl = "https://api.mch.weixin.qq.com/pay/orderquery";
            string _xmlResult       = PostXmltoUrl(_unifiedorderUrl, _strXML);

            return(_xmlResult);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 启动当前选择的程序
        /// </summary>
        private void 启动ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            mCurConfig = XMLOperator.GetConfigs();

            string url = generateURL(mCurConfig, mCurDevice, mCurProgram);

            textBox8.Text = SendRequest(url, TIMEOUT, "GET");
        }
Ejemplo n.º 8
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            mConfig.IsGUI    = checkBox1.Checked;
            mConfig.IsWait   = checkBox2.Checked;
            mConfig.IsSystem = checkBox3.Checked;

            XMLOperator.UpdateConfig(mConfig);
        }
Ejemplo n.º 9
0
 public MainForm()
 {
     instance = this;
     InitializeComponent();
     XMLOperator.Initialize();
     BindTreeView();
     mCurConfig = XMLOperator.GetConfigs();
 }
 /// <summary>
 /// 更新分组信息
 /// </summary>
 private void btn_OK_Click(object sender, EventArgs e)
 {
     mGroup.Clear();
     foreach (string content in listBox1.Items)
     {
         string[] tempArray = content.Split(new char[2] {
             '(', ')'
         });
         mGroup.AddProgram(tempArray[1], tempArray[0]);
     }
     XMLOperator.UpdateGroup(mGroup);
 }
Ejemplo n.º 11
0
        /// <summary>
        /// 构造将要发送的URL
        /// </summary>
        /// <param name="config">启动配置</param>
        /// <param name="device">程序所属的设备</param>
        /// <param name="program">选中的程序</param>
        /// <returns>URL</returns>
        private string generateURL(Configs config, Device device, Bases.Program program)
        {
            string result = "";
            string host   = "http://" + XMLOperator.GetHost() + "/PsExecProject/index.php";

            result  = host + "?r=" + device.DeviceIP + "&u=" + device.DeviceUser + "&p=" + device.DevicePwd;
            result += config.IsGUI ? "&i=1" : "&i=0";
            result += config.IsWait ? "&w=1" : "&w=0";
            result += config.IsSystem ? "&s=1" : "&s=0";
            result += "&e=" + HttpUtility.UrlEncode(program.Path) + "&args=" + HttpUtility.UrlEncode(program.Args);

            return(result);
        }
Ejemplo n.º 12
0
        private void 启动设置ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            StartupConfigForm startupConfigForm = new StartupConfigForm();
            DialogResult      dr = startupConfigForm.ShowDialog();

            if (dr == DialogResult.OK)
            {
                mCurConfig = XMLOperator.GetConfigs();
            }
            if (dr == DialogResult.Cancel)
            {
                // Do nothing
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 启动分组中所有的程序
        /// </summary>
        private void 启动ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            mCurConfig = XMLOperator.GetConfigs();

            List <Bases.Program> launchingPrograms = XMLOperator.GetProgramsFromGroup(mCurGroup.groupName);

            foreach (Bases.Program program in launchingPrograms)
            {
                Device device = XMLOperator.GetDevice(program.BelongDevice);
                string url    = generateURL(mCurConfig, device, program);
                textBox8.Text = SendRequest(url, TIMEOUT, "GET");
                Thread.Sleep(10);
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 删除分组下的所有程序
        /// </summary>
        private void  除所有程序ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("是否要删除该分组的所有程序?(无法回退该操作)", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (dr == DialogResult.Yes)
            {
                XMLOperator.DeleteProgramsInGroup(mCurGroup.groupName);
                RefreshTreeView();
            }

            if (dr == DialogResult.No)
            {
                // Do nothing
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 删除当前设备以及当前设备下的程序
        /// </summary>
        private void  除ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("是否要删除该设备及其所有程序?(无法回退该操作)", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (dr == DialogResult.Yes)
            {
                XMLOperator.DeleteDevice(mCurDevice.DeviceName);
                RefreshTreeView();
            }

            if (dr == DialogResult.No)
            {
                // Do nothing
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 第一次启动时添加xml地初始数据(弃用)
        /// </summary>
        private void GenerateInfo()
        {
            Configs myConfig = new Configs(true, false, true);
            Device  myDevice = new Device("Default Device", "192.168.1.118", "Learun", "116219");

            Bases.Program program1 = new Bases.Program("InternetExporer", "C:\\\\Program Files (x86)\\\\Internet Explorer\\\\iexplore.exe", "http://www.baidu.com", "Default Device");
            Bases.Program program2 = new Bases.Program("Media Player", "C:\\\\Program Files (x86)\\\\Windows Media PLayer\\\\wmplayer.exe", "C:\\\\Users\\\\Learun\\\\Documents\\\\Scrats.mp4", "Default Device");

            XMLOperator.WriteConfig(myConfig);
            XMLOperator.WriteDevice(myDevice);
            try
            {
                XMLOperator.WriteProgram(program1);
                XMLOperator.WriteProgram(program2);
            }catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Ejemplo n.º 17
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            // Get all information in textbox
            string deviceName = textBox1.Text;
            string deviceIP   = textBox2.Text;
            string deviceUser = textBox3.Text;
            string devicePwd  = textBox4.Text;

            if (deviceName != "" && DataValidator.IsIP(deviceIP) && devicePwd != "" && deviceUser != "")
            {
                Device updatingDevice = new Device(deviceName, deviceIP, deviceUser, devicePwd);

                XMLOperator.UpdateDevice(updatingDevice);
            }
            else
            {
                MessageBox.Show("输入信息不合法", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 获得所有已经连接过的服务器配置信息
        /// </summary>
        /// <returns></returns>
        public static List <ServerInfomation> GetAllServerInfo()
        {
            List <ServerInfomation> lstResult = new List <ServerInfomation>();
            bool isExists = CheckFileExists();

            if (isExists)
            {
                XMLOperator xmlOperator = new XMLOperator(App.GStrLoginUserApplicationDataPath + "\\UMP.PF.MAMT\\ServerConfig.xml");
                DataSet     ds          = xmlOperator.GetDs("Root");
                if (ds.Tables.Count > 0)
                {
                    ServerInfomation server;
                    DataRow          row = null;
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        row             = ds.Tables[0].Rows[i];
                        server          = new ServerInfomation();
                        server.Host     = row["Host"].ToString();
                        server.Port     = row["Port"].ToString();
                        server.UserName = row["Username"].ToString();
                        lstResult.Add(server);
                    }
                }
                else
                {
                    ServerInfomation server = new ServerInfomation();
                    server.Host     = "127.0.0.1";
                    server.Port     = "8081";
                    server.UserName = "******";
                    lstResult.Add(server);
                }
            }
            else
            {
                ServerInfomation server = new ServerInfomation();
                server.Host     = "127.0.0.1";
                server.Port     = "8081";
                server.UserName = "******";
                lstResult.Add(server);
            }
            return(lstResult);
        }
Ejemplo n.º 19
0
        private void refreshProgram(string deviceName, string programName)
        {
            // Set program groupbox's visibility to true, the other one is false.
            groupBox2.Visible = true;
            groupBox1.Visible = false;

            // Refresh Program's information
            Bases.Program tempProgram = XMLOperator.GetProgram(deviceName, programName);
            mCurProgram = tempProgram;
            try
            {
                textBox5.Text = tempProgram.Name;
                textBox6.Text = tempProgram.Path;
                textBox7.Text = tempProgram.Args;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Ejemplo n.º 20
0
        private void refreshDevice(string deviceName)
        {
            // Set device groupbox's visibility to true, the other one is false.
            groupBox1.Visible = true;
            groupBox2.Visible = false;

            // Refresh Device's information
            Device tempDevice = XMLOperator.GetDevice(deviceName);

            mCurDevice = tempDevice;
            try
            {
                textBox1.Text = tempDevice.DeviceName;
                textBox2.Text = tempDevice.DeviceIP;
                textBox3.Text = tempDevice.DeviceUser;
                textBox4.Text = tempDevice.DevicePwd;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        ///  更新配置文件
        /// </summary>
        /// <returns></returns>
        public static int UpdateConfigFile(string strHost, string strPort, string strUsername)
        {
            int         iResult     = 0;
            XMLOperator xmlOperator = new XMLOperator(App.GStrLoginUserApplicationDataPath + "\\UMP.PF.MAMT\\ServerConfig.xml");
            XmlNode     node        = xmlOperator.SelectNode("Root/Server/Host", strHost);

            if (node == null)
            {
                iResult = AddServer(strHost, strPort, strUsername, xmlOperator);
            }
            else
            {
                XmlNodeList childNodes = node.ParentNode.ChildNodes;
                bool        isSuccess  = true;
                for (int i = 0; i < childNodes.Count; i++)
                {
                    if (childNodes[i].Name == "Port")
                    {
                        isSuccess = xmlOperator.UpdateNode(childNodes[i], strPort);
                    }
                    else if (childNodes[i].Name == "Username")
                    {
                        isSuccess = xmlOperator.UpdateNode(childNodes[i], strUsername);
                    }
                    if (isSuccess && iResult == 0)
                    {
                        iResult = 0;
                    }
                    else
                    {
                        iResult = -1;
                    }
                }

                xmlOperator.Save(App.GStrLoginUserApplicationDataPath + "\\UMP.PF.MAMT\\ServerConfig.xml");
            }
            return(iResult);
        }
        private void btn_OK_Click(object sender, EventArgs e)
        {
            string ip   = textBox1.Text.Trim();
            string port = textBox2.Text.Trim();

            try
            {
                if (DataValidator.IsIP(ip) && DataValidator.IsValidPort(Convert.ToInt32(port)))
                {
                    string result = textBox1.Text.Trim() + ":" + textBox2.Text.Trim();
                    XMLOperator.UpdateHost(result);
                }
                else
                {
                    MessageBox.Show("参数不合法", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }catch (OverflowException ex)
            {
                MessageBox.Show("参数不合法", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }catch (FormatException ex)
            {
            }
        }
        /// <summary>
        /// 为程序列表绑定数据
        /// </summary>
        private void BindTreeView()
        {
            treeCombo.TreeView.LabelEdit = false;

            TreeNode root = new TreeNode();

            root.Tag  = "Root";
            root.Text = "我的程序";

            // 添加设备以及相关程序信息
            // 添加第一级节点(设备节点)
            //      添加第二级节点(程序节点)
            // 注意Count和Capacity的不同
            devices = XMLOperator.GetDevices();
            for (int i = 0; i < devices.Count; i++)
            {
                TreeNode curBranch = new TreeNode();
                Device   curDevice = devices[i];
                curBranch.Text = curDevice.DeviceName;
                curBranch.Tag  = "Device";
                programs       = XMLOperator.GetPrograms(curDevice.DeviceName);
                for (int j = 0; j < programs.Count; j++)
                {
                    TreeNode      pLeaf      = new TreeNode();
                    Bases.Program curProgram = programs[j];
                    pLeaf.Text = curProgram.Name;
                    pLeaf.Tag  = "Program";
                    curBranch.Nodes.Add(pLeaf);
                }
                root.Nodes.Add(curBranch);
                programs.Clear();
            }

            treeCombo.TreeView.Nodes.Add(root);
            this.Controls.Add(treeCombo);
        }
 private void InitializeInfos()
 {
     String[] tempArray = XMLOperator.GetHost().Split(':');
     textBox1.Text = tempArray[0];
     textBox2.Text = tempArray[1];
 }
Ejemplo n.º 25
0
        /// <summary>
        /// 添加服务器配置
        /// </summary>
        /// <param name="strHost"></param>
        /// <param name="strPort"></param>
        /// <param name="strUsername"></param>
        /// <returns></returns>
        public static int AddServer(string strHost, string strPort, string strUsername, XMLOperator xmlOperator)
        {
            int           iResult     = 0;
            List <string> lstElements = new List <string>();

            lstElements.Add("Host");
            lstElements.Add("Port");
            lstElements.Add("Username");
            List <string> lstContents = new List <string>();

            lstContents.Add(strHost);
            lstContents.Add(strPort);
            lstContents.Add(strUsername);
            xmlOperator.InsertNode("Root", "Server", lstElements, lstContents);
            xmlOperator.Save(App.GStrLoginUserApplicationDataPath + "\\UMP.PF.MAMT\\ServerConfig.xml");
            return(iResult);
        }
Ejemplo n.º 26
0
        private void Run()
        {
            // 获取 32位字符
            nonce_str = (new RandomStringLine(32)).Value;

            // 建立 XML
            XMLOperator _xml = new XMLOperator();

            _xml.SetValue("appid", appid);
            _xml.SetValue("mch_id", mch_id);
            _xml.SetValue("nonce_str", nonce_str);
            _xml.SetValue("body", body);
            _xml.SetValue("out_trade_no", out_trade_no);
            _xml.SetValue("total_fee", total_fee);
            _xml.SetValue("spbill_create_ip", spbill_create_ip);
            _xml.SetValue("notify_url", notify_url);
            _xml.SetValue("trade_type", trade_type);
            _xml.SetValue("sign", Getsign());                   // 获取签名

            string _strXML          = _xml.ToXml();
            string _unifiedorderUrl = "https://api.mch.weixin.qq.com/pay/unifiedorder";
            string _xmlResult       = (new PostXmltoUrl(_unifiedorderUrl, _strXML)).ReturnValue;

            WxPayData data = new WxPayData();

            data.FromXml(_xmlResult);


            string return_code = data.GetValue("return_code").ToString().Trim();


            if ("SUCCESS" != return_code)
            {
                // 支付功能关闭
                returnResult = new SortedDictionary <string, string>
                {
                    { "sign", "0x10320002" },
                    { "info", "支付功能关闭!" }
                };

                return;
            }

            if (0 <= _xmlResult.IndexOf("err_code_des", StringComparison.Ordinal))
            {
                returnResult = new SortedDictionary <string, string>
                {
                    { "sign", "0x10320002" },
                    { "info", data.GetValue("err_code_des").ToString().Trim() }
                };

                return;
            }


            string _rTimeStamp = (new DateTimeOffset(DateTime.Now)).ToUnixTimeSeconds().ToString();
            string _rNonceStr  = (new RandomStringLine(32)).Value.ToUpper();
            string _rPackAge   = "prepay_id=" + data.GetValue("prepay_id").ToString().Trim();
            string _paySign    = "";

            _2codeUrl = null == data.GetValue("code_url") ? "" : data.GetValue("code_url").ToString().Trim();


            _paySign += "appId=" + WxPayConfig.APPID;
            _paySign += "&nonceStr=" + _rNonceStr;
            _paySign += "&package=" + _rPackAge;
            _paySign += "&signType=MD5";
            _paySign += "&timeStamp=" + _rTimeStamp;
            _paySign += "&key=" + WxPayConfig.KEY;


            _paySign = MD5Util.GetMD5(_paySign, "utf-8").ToUpper();      // 进行 MD5 加密


            returnResult = new SortedDictionary <string, string>
            {
                { "sign", "0x10320000" },
                { "appId", WxPayConfig.APPID },       // 小程序ID
                { "timeStamp", _rTimeStamp },         // 时间戳
                { "nonceStr", _rNonceStr },           // 随机串
                { "package", _rPackAge },             // 数据包
                { "signType", "MD5" },                // 签名方式
                { "paySign", _paySign },              // 签名
                { "2codeUrl", _2codeUrl }             // 二维码链接
            };
        }
Ejemplo n.º 27
0
        /// <summary>
        /// 为TreeView绑定数据源
        /// </summary>
        private void BindTreeView()
        {
            // Cannot Edit
            treeView1.LabelEdit = false;

            // 添加根节点
            TreeNode root = new TreeNode();

            root.Text = "我的程序";
            root.Tag  = "Root";
            TreeNode root2 = new TreeNode();

            root2.Text = "我的分组";
            root2.Tag  = "GroupRoot";

            // 添加设备以及相关程序信息
            // 添加第一级节点(设备节点)
            //      添加第二级节点(程序节点)
            // 注意Count和Capacity的不同
            devices = XMLOperator.GetDevices();
            for (int i = 0; i < devices.Count; i++)
            {
                TreeNode curBranch = new TreeNode();
                Device   curDevice = devices[i];
                curBranch.Text = curDevice.DeviceName;
                curBranch.Tag  = "Device";
                programs       = XMLOperator.GetPrograms(curDevice.DeviceName);
                //Console.WriteLine("The Capacity of programs is "+programs.Capacity);
                for (int j = 0; j < programs.Count; j++)
                {
                    TreeNode pLeaf = new TreeNode();
                    //Console.WriteLine("j is " + j.ToString());
                    Bases.Program curProgram = programs[j];
                    pLeaf.Text = curProgram.Name;
                    pLeaf.Tag  = "Program";
                    curBranch.Nodes.Add(pLeaf);
                }
                root.Nodes.Add(curBranch);
                programs.Clear();
            }

            // 添加分组以及分组下程序信息
            // 添加第一级节点(分组节点)
            //      添加第二级节点(程序节点)
            groups = XMLOperator.GetGroups();
            for (int i = 0; i < groups.Count; i++)
            {
                TreeNode curBranch = new TreeNode();
                Group    curGroup  = groups[i];
                curBranch.Text = curGroup.groupName;
                curBranch.Tag  = "Group";
                programs       = XMLOperator.GetProgramsFromGroup(curGroup.groupName);
                for (int j = 0; j < programs.Count; j++)
                {
                    TreeNode      pLeaf      = new TreeNode();
                    Bases.Program curProgram = programs[j];
                    pLeaf.Text = curProgram.Name + "(" + curProgram.BelongDevice + ")";
                    pLeaf.Tag  = "GroupItem";
                    curBranch.Nodes.Add(pLeaf);
                }
                root2.Nodes.Add(curBranch);
                programs.Clear();
            }

            treeView1.Nodes.Add(root);
            treeView1.Nodes.Add(root2);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// 为树状图中的节点设置点击行为
        /// </summary>
        private void treeView1_MouseUp(object sender, MouseEventArgs e)
        {
            // After right-clicking the node, show the options according to its tag
            if (e.Button == MouseButtons.Right)
            {
                treeView1.SelectedNode = treeView1.GetNodeAt(e.X, e.Y);

                if (treeView1.SelectedNode != null)
                {
                    switch (treeView1.SelectedNode.Tag)
                    {
                    case "Device":
                        contextMenuDevice.Show(treeView1, e.Location);
                        break;

                    case "Program":
                        contextMenuProgram.Show(treeView1, e.Location);
                        break;

                    case "Root":
                        contextMenuRoot.Show(treeView1, e.Location);
                        break;

                    case "GroupRoot":
                        contextMenuGroupRoot.Show(treeView1, e.Location);
                        break;

                    case "Group":
                        contextMenuGroup.Show(treeView1, e.Location);
                        break;

                    default:
                        break;
                    }
                }
            }

            // After left-clicking the node, show the detailed information according to its tag.
            if (e.Button == MouseButtons.Left)
            {
                treeView1.SelectedNode = treeView1.GetNodeAt(e.X, e.Y);

                if (treeView1.SelectedNode != null)
                {
                    switch (treeView1.SelectedNode.Tag)
                    {
                    case "Device":
                        refreshDevice(treeView1.SelectedNode.Text);
                        break;

                    case "Program":
                        refreshProgram(treeView1.SelectedNode.Parent.Text, treeView1.SelectedNode.Text);
                        break;

                    case "GroupItem":
                        mCurGroup = XMLOperator.GetGroup(treeView1.SelectedNode.Parent.Text);
                        string   groupInfo = treeView1.SelectedNode.Text;
                        string[] tempArray = groupInfo.Split(new char[2] {
                            '(', ')'
                        });
                        refreshProgram(tempArray[1], tempArray[0]);
                        break;

                    case "Group":
                        mCurGroup = XMLOperator.GetGroup(treeView1.SelectedNode.Text);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Ejemplo n.º 29
0
        public static void StartBackupMachine(string strSourceKey, string strTargetKey)
        {
            DirectoryInfo dir = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\VoiceCyber\\UMP\\config");

            if (!dir.Exists)
            {
                return;
            }
            FileInfo[]  lstFileList = dir.GetFiles("*.xml");
            XmlDocument xmlDoc      = null;
            XMLOperator xmlOperator = null;

            foreach (FileInfo file in lstFileList)
            {
                //如果不是参数的xml 跳过
                if (!file.Name.ToLower().StartsWith("umpparam_"))
                {
                    continue;
                }
                xmlDoc = new XmlDocument();
                xmlDoc.Load(file.FullName);
                xmlOperator = new XMLOperator(xmlDoc);
                #region 修改备机xml部分
                XmlNode node = xmlOperator.SelectNodeByAttribute("Configurations/Configuration/Sites/Site/VoiceServers/VoiceServer", "ModuleNumber", strSourceKey);
                if (node != null)
                {
                    string strStandByRole = xmlOperator.SelectAttrib(node, "StandByRole");
                    if (!strStandByRole.Equals("3"))
                    {
                        break;
                    }
                    //查找这个属性 如果返回值为空 表示没有这个属性
                    string strAttrContent = xmlOperator.SelectAttrib(node, "ReplaceModuleNumber");
                    if (string.IsNullOrEmpty(strAttrContent))
                    {
                        //没有这个属性 则增加
                        xmlOperator.InsertAttrib(node, "ReplaceModuleNumber", strTargetKey);
                    }
                    else
                    {
                        bool bo = xmlOperator.UpdateAttrib(node, "ReplaceModuleNumber", strTargetKey);
                    }
                }

                #endregion

                #region 修改主机xml部分
                node = xmlOperator.SelectNodeByAttribute("Configurations/Configuration/Sites/Site/VoiceServers/VoiceServer", "ModuleNumber", strTargetKey);
                if (node != null)
                {
                    string strStandByRole = xmlOperator.SelectAttrib(node, "StandByRole");
                    if (!strStandByRole.Equals("0"))
                    {
                        break;
                    }
                    //查找这个属性 如果返回值为空 表示没有这个属性
                    string strAttrContent = xmlOperator.SelectAttrib(node, "ReplaceModuleNumber");
                    if (string.IsNullOrEmpty(strAttrContent))
                    {
                        //没有这个属性 则增加
                        xmlOperator.InsertAttrib(node, "ReplaceModuleNumber", strSourceKey);
                    }
                    else
                    {
                        bool bo = xmlOperator.UpdateAttrib(node, "ReplaceModuleNumber", strSourceKey);
                    }
                }

                #endregion

                xmlOperator.Save(file.FullName);
            }
        }