示例#1
0
        private void updateElectButton_Click(object sender, EventArgs e)
        {
            try {
                this.label4.Text = GlobalData.user.RoomId + "";
                if (GlobalData.user.RoomId.Equals(0))
                {
                    MessageBox.Show("更新失败,未完善宿舍号");
                    return;
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(typeof(ElectricityCharges), ex);
                MessageBox.Show("更新失败,未完善宿舍号");
                return;
            }
            InvokeExe invokeExe        = new InvokeExe();
            string    filePath         = Application.StartupPath.Substring(0, Application.StartupPath.Length - 10) + "\\Properties\\Search_Electricity\\dist\\getElect.exe";
            string    workingDirectory = Application.StartupPath.Substring(0, Application.StartupPath.Length - 10) + "\\Properties\\Search_Electricity\\dist\\";

            string[] param = { GlobalData.user.RoomId + "" };
            string   res   = "";

            try
            {
                res = invokeExe.invoke(filePath, workingDirectory, param);
                this.label5.Text = res.Substring(16, 7);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(typeof(ElectricityCharges), ex);
                MessageBox.Show("更新失败");
                return;
            }
            String time = DateTime.Now.ToString();

            this.dateTimePicker1.Text = time;
            ElectInfo info = new ElectInfo();

            info.Time  = time;
            info.Elect = res.Substring(16, 7);
            XmlOperator <ElectInfo> xmlOperator = new XmlOperator <ElectInfo>();
            string infoPath = "";

            try
            {
                infoPath = Application.StartupPath.Substring(0, Application.StartupPath.Length - 10) + "\\Properties\\Search_Electricity\\" + GlobalData.user.RoomId + "Info.xml";
                xmlOperator.saveXML(infoPath, info);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(typeof(ElectricityCharges), ex);
                MessageBox.Show("读取宿舍号失败");
            }
            string path = Application.StartupPath.Substring(0, Application.StartupPath.Length - 10) + "\\Properties\\Search_Electricity\\dist\\" + "ElectInfo.txt";

            drawCurve(path);
            LogHelper.WriteLog(typeof(ElectricityCharges), "  " + info.ToString());
            MessageBox.Show("电费更新成功!");
        }
示例#2
0
        public void updateElectButtonTest()
        {
            InvokeExe invokeExe        = new InvokeExe();
            string    filePath         = "../../../WindowsFormsApp1/Properties/Search_Electricity/dist/getElect.exe";
            string    workingDirectory = "../../../WindowsFormsApp1/Properties/Search_Electricity/dist/";

            string[] param = { "3307" };
            string   res   = "";

            res = invokeExe.invoke(filePath, workingDirectory, param);
            Assert.IsFalse(res.Equals(""));
        }