EMSV1.5.0能源管理系統(tǒng) 軟件源代碼V1.00_第1頁
EMSV1.5.0能源管理系統(tǒng) 軟件源代碼V1.00_第2頁
EMSV1.5.0能源管理系統(tǒng) 軟件源代碼V1.00_第3頁
EMSV1.5.0能源管理系統(tǒng) 軟件源代碼V1.00_第4頁
EMSV1.5.0能源管理系統(tǒng) 軟件源代碼V1.00_第5頁
已閱讀5頁,還剩80頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

EMSV1.5.0能源管理系統(tǒng)軟件源代碼文件編號(hào)生效日期受控編號(hào)保密級(jí)別一級(jí)版本號(hào)V1.00修改次數(shù)總頁數(shù)85正文81附錄無編制項(xiàng)目組各成員審核批準(zhǔn)(版權(quán)所有,翻版必究)

評(píng)審記錄對(duì)《EMSV1.5.0能源管理系統(tǒng)軟件源代碼V1.00》的評(píng)審意見上述問題修改驗(yàn)證后,由驗(yàn)證后,本文件即可發(fā)布。評(píng)審人員簽字:?jiǎn)栴}修改驗(yàn)證結(jié)果:驗(yàn)證人簽字:時(shí)間:年月日 變更日志編號(hào)版本修改內(nèi)容修改人修改日期1V1.00初稿項(xiàng)目組各成員2017-10-30

目錄1. EMS1.5.0代碼審核報(bào)告 51.1 集成管理工具 51.2 變壓器負(fù)載率報(bào)告 631.3 滑動(dòng)能耗分析 681.4 碳排放 731.5 App接口 81

EMS1.5.0代碼審核報(bào)告集成管理工具usingFramework.Common;usingFramework.Configuration;usingFramework.Data;usingFramework.DataConfiguration;usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.IO;usingSystem.Linq;usingSystem.ServiceProcess;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;usingSystem.Xml;usingSystem.ServiceModel;usingSystem.Configuration;usingIOMSRegister;namespaceIntegrateManageTool{publicpartialclassForm1:Form{IntegrateManageTool.BLL.CommonBllbll=newBLL.CommonBll();boolisFirstInit=false;publicForm1(){InitializeComponent();//防止線程間訪問出錯(cuò),臨時(shí)加此屬性。終極解決辦法是委托或使用BackgroundWorker控件屈云明20170719DataGridView.CheckForIllegalCrossThreadCalls=false;}///<summary>///主畫面加載///</summary>///<paramname="sender"></param>///<paramname="e"></param>privatevoidForm1_Load(objectsender,EventArgse){Common.WriteLog.CreateLog("開始啟動(dòng)集成管理工具");try{this.btnRefreshAll.Image=Image.FromFile(System.Windows.Forms.Application.StartupPath+"\\Resources\\refresh.png");this.btnAdd.Image=Image.FromFile(System.Windows.Forms.Application.StartupPath+"\\Resources\\add.png");this.btnStart.Image=Image.FromFile(System.Windows.Forms.Application.StartupPath+"\\Resources\\start.png");this.btnRestart.Image=Image.FromFile(System.Windows.Forms.Application.StartupPath+"\\Resources\\restart.png");this.btnDelete.Image=Image.FromFile(System.Windows.Forms.Application.StartupPath+"\\Resources\\delete.png");this.btnClose.Image=Image.FromFile(System.Windows.Forms.Application.StartupPath+"\\Resources\\close.png");this.btnApply.Image=Image.FromFile(System.Windows.Forms.Application.StartupPath+"\\Resources\\save.png");this.btnQuit.Image=Image.FromFile(System.Windows.Forms.Application.StartupPath+"\\Resources\\power.png");this.btnWcfOpen.Image=Image.FromFile(System.Windows.Forms.Application.StartupPath+"\\Resources\\startservice.png");this.btnWcfClose.Image=Image.FromFile(System.Windows.Forms.Application.StartupPath+"\\Resources\\stopservice.png");this.btnInstall.Image=Image.FromFile(System.Windows.Forms.Application.StartupPath+"\\Resources\\install.png");this.btnModeSwitch.Image=Image.FromFile(System.Windows.Forms.Application.StartupPath+"\\Resources\\setting.png");this.btnReadMe.Image=Image.FromFile(System.Windows.Forms.Application.StartupPath+"\\Resources\\help.png");//先加載Program.config里面的程序。若在數(shù)據(jù)庫中沒有就先保存入數(shù)據(jù)庫。后面一律以數(shù)據(jù)庫保存的為準(zhǔn)LoadXmlProgramToDatabase();//調(diào)用刷新按鈕事件初始化數(shù)據(jù)this.btnRefreshAll_Click(null,null);System.Threading.Thread.Sleep(1000);//先把集成管理工具的數(shù)據(jù)庫批量適用到所有工具this.ModifyDataSrc();System.Threading.Thread.Sleep(1000);//調(diào)用刷新按鈕事件初始化數(shù)據(jù)this.btnRefreshAll_Click(null,null);//定期檢查進(jìn)程或服務(wù)是否正常ScheduleWork();//高級(jí)功能根據(jù)配置顯示if(System.Configuration.ConfigurationManager.AppSettings["IsShowAdvancedFunction"].ToLower().Equals("false")){this.groupBox3.Visible=false;this.btnModeSwitch.Visible=false;this.btnInstall.Visible=false;this.label1.Location=newPoint(this.label1.Location.X,480);this.label2.Location=newPoint(this.label2.Location.X,500);this.btnReadMe.Location=newPoint(this.btnReadMe.Location.X,480);this.btnQuit.Location=newPoint(this.btnQuit.Location.X,480);}}catch(Exceptionex){Common.WriteLog.CreateLog("啟動(dòng)異常:"+ex.Message);MessageBox.Show("啟動(dòng)異常:"+ex.Message,"出錯(cuò)啦",MessageBoxButtons.OK,MessageBoxIcon.Error);}Common.WriteLog.CreateLog("啟動(dòng)成功");//開始服務(wù)this.Start();}///<summary>///先把集成管理工具的數(shù)據(jù)庫批量適用到所有工具///</summary>privatevoidModifyDataSrc(){if(isFirstInit){//當(dāng)存在數(shù)據(jù)時(shí),認(rèn)為不是初始化,批量修改數(shù)據(jù)的操作return;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%//初始化把數(shù)據(jù)庫全部修改一遍//修改數(shù)據(jù)庫連接//先判斷數(shù)據(jù)庫配置文件是否存在stringconnectstringTmp=string.Empty;if(System.IO.File.Exists(Application.StartupPath+"\\"+GlobalConfigurationSource.GlobalAppSettings["DatabaseListFile"])){//加載數(shù)據(jù)源DatabaseListdatabaseList=XmlHelper.XmlDeserializeFromFile<DatabaseList>(Application.StartupPath+"\\"+GlobalConfigurationSource.GlobalAppSettings["DatabaseListFile"],Encoding.UTF8);if(!string.IsNullOrEmpty(databaseList.MDatabaseInstances[0].ConnectionString)){connectstringTmp=databaseList.MDatabaseInstances[0].ConnectionString;}}else{//文件不存在的情況下記錄日志后繼續(xù)執(zhí)行MessageBox.Show("不存在數(shù)據(jù)庫文件!請(qǐng)檢查。"+Application.StartupPath+"\\"+GlobalConfigurationSource.GlobalAppSettings["DatabaseListFile"]);}for(inti=0;i<this.dgvExeList.Rows.Count;i++){//必須有數(shù)據(jù)源才需要修改屈云明20170720if(dgvExeList.Rows[i].Cells["是否有數(shù)據(jù)源"].Value.Equals(1)){//必須名稱有值的數(shù)據(jù)才有意義if(dgvExeList.Rows[i].Cells["名稱"].Value!=null){XmlDocumentxml2=newXmlDocument();xml2.Load(this.dgvExeList.Rows[i].Cells["路徑"].Value.ToString()+"configs\\Database.config");XmlNodexnTmp=xml2.DocumentElement;foreach(XmlNodenodeinxnTmp.ChildNodes){if(node.Name=="database"){foreach(XmlNodenode2innode.ChildNodes){node2.InnerText=connectstringTmp;}}}xml2.Save(this.dgvExeList.Rows[i].Cells["路徑"].Value.ToString()+"configs\\Database.config");}}}//%%%%%%%%%%%%%%%%%%%%%%%%%%%}///<summary>///把Program.config里面配置的程序加載入數(shù)據(jù)庫///</summary>privatevoidLoadXmlProgramToDatabase(){isFirstInit=bll.IsHaveDataInDB();if(isFirstInit){//當(dāng)存在數(shù)據(jù)時(shí),認(rèn)為不是初始化,跳過讀取Program.config的邏輯return;}//@@@@@@@@@@@@@@@@@@@@@@@@@@@@//tobecontinued把xml序列化為二進(jìn)制對(duì)象,使用時(shí)再從二進(jìn)制對(duì)象反序列化為xml。目的是防止用戶來修改//夏工的意思是初始化文件裝機(jī)時(shí)肯定存在,且永遠(yuǎn)只用一次。不考慮其他異常情況if(!System.IO.File.Exists(System.Windows.Forms.Application.StartupPath+"\\configs\\Program.config")){MessageBox.Show("執(zhí)行路徑根目錄下找不到Program.config文件,請(qǐng)仔細(xì)檢查\r\n路徑:"+Application.StartupPath+"\\configs","文件未找到",MessageBoxButtons.OK,MessageBoxIcon.Error);return;}List<Model.ManageConfig>lstMc=newList<Model.ManageConfig>();XmlDocumentdoc=newXmlDocument();doc.Load(System.Windows.Forms.Application.StartupPath+"\\configs\\Program.config");XmlNodexn=doc.SelectSingleNode("configuration");DirectoryInfoinfo=newDirectoryInfo(Application.StartupPath);stringparentPath=info.Parent.FullName;foreach(XmlNodexn1inxn){if(xn1.OuterXml.Contains("!--")){continue;}if(xn1.Name.Equals("add")){Model.ManageConfigmc=newModel.ManageConfig();mc.Cname=xn1.SelectSingleNode("@name").InnerText;mc.ExePath=parentPath+xn1.SelectSingleNode("@relativePath").InnerText;mc.WorkType=int.Parse(xn1.SelectSingleNode("@workType").InnerText);mc.ServiceName=xn1.SelectSingleNode("@serviceName").InnerText;//存在某些程序不需要數(shù)據(jù)庫配置屈云明20170720mc.IsHaveDataSrc=int.Parse(xn1.SelectSingleNode("@isHaveDataSrc").InnerText);mc.Comments="根據(jù)Program.config自動(dòng)添加的";lstMc.Add(mc);}}//保存入數(shù)據(jù)庫stringerrInfo=string.Empty;//返回0表示插入失敗if(this.bll.BatchInsertIntoIntegrateManageConfig(lstMc,referrInfo)==0){Common.WriteLog.CreateLog("把Program.config的插入數(shù)據(jù)庫失敗。"+errInfo);MessageBox.Show("把Program.config的插入數(shù)據(jù)庫失敗。"+errInfo,"出錯(cuò)了",MessageBoxButtons.OK,MessageBoxIcon.Error);}//@@@@@@@@@@@@@@@@@@@@@@@@@@@@}privatevoidScheduleWork(){try{//設(shè)定固定時(shí)間檢查進(jìn)程是否存在,并記錄日志vartimer=newSystem.Timers.Timer{Interval=int.Parse(System.Configuration.ConfigurationManager.AppSettings["checkFrenquency"])*1000,Enabled=true,AutoReset=true};timer.Elapsed+=(sender,e)=>{boolisHaveUninstallService=false;boolisHaveStoppedData=false;if(this.btnModeSwitch.Text.Equals("手動(dòng)模式中")){Common.WriteLog.CreateLog("當(dāng)前在"+this.btnModeSwitch.Text+",跳過定期檢查并啟動(dòng)已停止的程序功能");return;}elseif(this.btnModeSwitch.Text.Equals("自動(dòng)模式中")){Common.WriteLog.CreateLog("當(dāng)前在"+this.btnModeSwitch.Text+",即將檢查并啟動(dòng)已停止的程序");}else{Common.WriteLog.CreateLog("當(dāng)前既不是手動(dòng)模式,也不是自動(dòng)模式。這是非常嚴(yán)重的問題,請(qǐng)聯(lián)系程序開發(fā)人員!");return;}//#########################//先刷新grid的狀態(tài)for(inti=0;i<this.dgvExeList.RowCount;i++){if(this.dgvExeList.Rows[i].Cells["類型"].Value.ToString().Equals(Model.EnumWorkType.WorkType.應(yīng)用程序.ToString())){//狀態(tài)實(shí)時(shí)獲取boolbInTaskMgr=Common.Function.isExistInTaskMgr(this.dgvExeList.Rows[i].Cells["名稱"].Value.ToString().Trim());stringsStatus=string.Empty;if(bInTaskMgr){sStatus="Running";this.dgvExeList.Rows[i].DefaultCellStyle.BackColor=Color.White;}else{sStatus="Stopped";this.dgvExeList.Rows[i].DefaultCellStyle.BackColor=Color.Red;Common.WriteLog.CreateLog("自動(dòng)偵測(cè)到應(yīng)用程序"+this.dgvExeList.Rows[i].Cells["名稱"].Value.ToString()+"進(jìn)程已經(jīng)不存在于任務(wù)管理器中");}this.dgvExeList.Rows[i].Cells["狀態(tài)"].Value=sStatus;//狀態(tài)實(shí)時(shí)獲取}elseif(this.dgvExeList.Rows[i].Cells["類型"].Value.ToString().Equals(Model.EnumWorkType.WorkType.服務(wù)程序.ToString())){//當(dāng)服務(wù)程序的服務(wù)名稱沒有時(shí),提示if(string.IsNullOrEmpty(this.dgvExeList.Rows[i].Cells["服務(wù)名稱"].Value.ToString().Trim())){Common.WriteLog.CreateLog("加載"+this.dgvExeList.Rows[i].Cells["服務(wù)名稱"].Value.ToString().Trim()+"時(shí)出錯(cuò),服務(wù)名稱為空。請(qǐng)檢查");}else{stringsStatus=string.Empty;if(Common.Function.IsExistsService(this.dgvExeList.Rows[i].Cells["服務(wù)名稱"].Value.ToString().Trim())){sStatus=Common.Function.GetServiceState(this.dgvExeList.Rows[i].Cells["服務(wù)名稱"].Value.ToString().Trim()).ToString();}else{sStatus="未安裝";Common.WriteLog.CreateLog("自動(dòng)偵測(cè)到服務(wù)程序"+this.dgvExeList.Rows[i].Cells["服務(wù)名稱"].Value.ToString()+"沒有安裝");}this.dgvExeList.Rows[i].Cells["狀態(tài)"].Value=sStatus;//狀態(tài)實(shí)時(shí)獲取if(!sStatus.Equals("Running")){Common.WriteLog.CreateLog("自動(dòng)偵測(cè)到服務(wù)程序"+this.dgvExeList.Rows[i].Cells["服務(wù)名稱"].Value.ToString()+"的狀態(tài)為"+sStatus);}}}else{Common.WriteLog.CreateLog("程序"+this.dgvExeList.Rows[i].Cells["名稱"].Value.ToString()+"類型不是應(yīng)用程序也不是服務(wù)程序!");this.dgvExeList.Rows[i].DefaultCellStyle.BackColor=Color.Red;continue;}}//#########################//先判斷有無未安裝的服務(wù)for(inti=0;i<this.dgvExeList.RowCount;i++){if(this.dgvExeList.Rows[i].Cells["類型"].Value.ToString().Equals(Model.EnumWorkType.WorkType.服務(wù)程序.ToString())){if(this.dgvExeList.Rows[i].Cells["狀態(tài)"].Value.ToString().Equals("未安裝")){DataGridViewCheckBoxCellcheckCell=(DataGridViewCheckBoxCell)dgvExeList.Rows[i].Cells["選擇"];checkCell.Value=true;isHaveUninstallService=true;}}}//存在未安裝的服務(wù)if(isHaveUninstallService){this.btnInstall_Click(null,null);}else{//若無未安裝的服務(wù),則檢查有無stopped的程序for(inti=0;i<this.dgvExeList.RowCount;i++){if(this.dgvExeList.Rows[i].Cells["狀態(tài)"].Value.ToString().Equals("Stopped")){DataGridViewCheckBoxCellcheckCell=(DataGridViewCheckBoxCell)dgvExeList.Rows[i].Cells["選擇"];checkCell.Value=true;isHaveStoppedData=true;}}//存在則把停止的程序啟動(dòng)if(isHaveStoppedData){timer.Stop();this.btnStart_Click(null,null);timer.Start();}}};}catch(Exceptionex){Common.WriteLog.CreateLog("ScheduleWork方法出現(xiàn)異常:"+ex.Message);}}///<summary>///全部刷新按鈕按下后,從數(shù)據(jù)庫和配置文件中重載所有參數(shù)///</summary>///<paramname="sender"></param>///<paramname="e"></param>privatevoidbtnRefreshAll_Click(objectsender,EventArgse){//先不用綁定數(shù)據(jù)源,直接賦值靈活點(diǎn)//this.dgvExeList.DataSource=bll.GetAllExe();//實(shí)現(xiàn)要清空表格,不然刷新時(shí)返回0條數(shù)據(jù)不會(huì)重繪表格this.dgvExeList.Rows.Clear();List<Model.ManageConfig>list=bll.GetAllExe();//grid好像不能把列數(shù)變?yōu)?this.dgvExeList.RowCount=(list.Count==0)?1:list.Count;intindex=0;foreach(Model.ManageConfigmcinlist){try{DataGridViewCheckBoxCellcb=newDataGridViewCheckBoxCell(false);cb.Value=false;this.dgvExeList.Rows[index].Cells["選擇"]=cb;this.dgvExeList.Rows[index].Cells["名稱"].Value=mc.Cname;this.dgvExeList.Rows[index].Cells["類型"].Value=(mc.WorkType==1)?Model.EnumWorkType.WorkType.應(yīng)用程序:Model.EnumWorkType.WorkType.服務(wù)程序;this.dgvExeList.Rows[index].Cells["路徑"].Value=mc.ExePath;this.dgvExeList.Rows[index].Cells["備注"].Value=mc.Comments;this.dgvExeList.Rows[index].Cells["主鍵"].Value=mc.ObjectId;this.dgvExeList.Rows[index].Cells["服務(wù)名稱"].Value=mc.ServiceName;this.dgvExeList.Rows[index].Cells["是否有數(shù)據(jù)源"].Value=mc.IsHaveDataSrc;//##################//必須存在數(shù)據(jù)源的情況下才需要讀取配置文件屈云明20170720if(this.dgvExeList.Rows[index].Cells["是否有數(shù)據(jù)源"].Value.Equals(1)){//先判斷數(shù)據(jù)庫配置文件是否存在if(System.IO.File.Exists(mc.ExePath+GlobalConfigurationSource.GlobalAppSettings["DatabaseListFile"])){//加載數(shù)據(jù)源DatabaseListdatabaseList=XmlHelper.XmlDeserializeFromFile<DatabaseList>(mc.ExePath+"\\"+GlobalConfigurationSource.GlobalAppSettings["DatabaseListFile"],Encoding.UTF8);if(!string.IsNullOrEmpty(databaseList.MDatabaseInstances[0].ConnectionString)){this.dgvExeList.Rows[index].Cells["數(shù)據(jù)源"].Value=databaseList.MDatabaseInstances[0].ConnectionString;}}else{//文件不存在的情況下記錄日志后繼續(xù)執(zhí)行Common.WriteLog.CreateLog("不存在文件!請(qǐng)檢查。"+mc.ExePath+"\\"+GlobalConfigurationSource.GlobalAppSettings["DatabaseListFile"]);this.dgvExeList.Rows[index].DefaultCellStyle.BackColor=Color.Red;}}//##################//@@@@@@@@@@@@@@@@@@@@@@@@if(this.dgvExeList.Rows[index].Cells["類型"].Value.ToString().Equals(Model.EnumWorkType.WorkType.應(yīng)用程序.ToString())){//狀態(tài)實(shí)時(shí)獲取boolbInTaskMgr=Common.Function.isExistInTaskMgr(mc.Cname.Trim());stringsStatus=string.Empty;if(bInTaskMgr){sStatus="Running";this.dgvExeList.Rows[index].DefaultCellStyle.BackColor=Color.White;}else{sStatus="Stopped";this.dgvExeList.Rows[index].DefaultCellStyle.BackColor=Color.Red;}this.dgvExeList.Rows[index].Cells["狀態(tài)"].Value=sStatus;//狀態(tài)實(shí)時(shí)獲取}elseif(this.dgvExeList.Rows[index].Cells["類型"].Value.ToString().Equals(Model.EnumWorkType.WorkType.服務(wù)程序.ToString())){//當(dāng)服務(wù)程序的服務(wù)名稱沒有時(shí),提示if(string.IsNullOrEmpty(mc.ServiceName)){Common.WriteLog.CreateLog("加載"+mc.Cname+"時(shí)出錯(cuò),服務(wù)名稱為空。請(qǐng)檢查");}else{stringsStatus=string.Empty;if(Common.Function.IsExistsService(mc.ServiceName.Trim())){sStatus=Common.Function.GetServiceState(mc.ServiceName.Trim()).ToString();if(sStatus.Equals("Running")){this.dgvExeList.Rows[index].DefaultCellStyle.BackColor=Color.White;}else{this.dgvExeList.Rows[index].DefaultCellStyle.BackColor=Color.Red;}}else{sStatus="未安裝";this.dgvExeList.Rows[index].DefaultCellStyle.BackColor=Color.Red;}this.dgvExeList.Rows[index].Cells["狀態(tài)"].Value=sStatus;//狀態(tài)實(shí)時(shí)獲取}}else{Common.WriteLog.CreateLog("程序"+this.dgvExeList.Rows[index].Cells["名稱"].Value.ToString()+"類型不是應(yīng)用程序也不是服務(wù)程序!");this.dgvExeList.Rows[index].DefaultCellStyle.BackColor=Color.Red;continue;}//@@@@@@@@@@@@@@@@@@@@@@@@index++;}catch(Exceptionex){Common.WriteLog.CreateLog("加載"+mc.Cname+"時(shí)出錯(cuò),請(qǐng)檢查"+ex.Message);continue;}}}///<summary>///彈出新增畫面///</summary>///<paramname="sender"></param>///<paramname="e"></param>privatevoidbtnAdd_Click(objectsender,EventArgse){frmAddOrModifyfrm=newfrmAddOrModify();frm.StrIndicator="Add";if(frm.ShowDialog().Equals(DialogResult.OK)){//刷新this.btnRefreshAll_Click(null,null);}else{//取消按鈕,什么也不做}}///<summary>///退出工具///</summary>///<paramname="sender"></param>///<paramname="e"></param>privatevoidbtnQuit_Click(objectsender,EventArgse){//會(huì)觸發(fā)formclosig事件,那邊會(huì)記錄日志this.Close();}///<summary>///各種按鈕的點(diǎn)擊事件///</summary>///<paramname="sender"></param>///<paramname="e"></param>privatevoiddgvExeList_CellClick(objectsender,DataGridViewCellEventArgse){try{//點(diǎn)擊列頭或行頭,不執(zhí)行任何邏輯if(e.RowIndex==-1||e.ColumnIndex==-1){return;}//選擇列if(this.dgvExeList.Columns[e.ColumnIndex].Name.Equals("選擇")){DataGridViewCheckBoxCellcheckCell=(DataGridViewCheckBoxCell)dgvExeList.Rows[e.RowIndex].Cells["選擇"];Booleanflag=Convert.ToBoolean(checkCell.Value);checkCell.Value=!flag;}elseif(this.dgvExeList.Columns[e.ColumnIndex].Name.Equals("安裝")){//第7列是安裝列。只有服務(wù)程序才需要安裝if(this.dgvExeList.Rows[e.RowIndex].Cells["類型"].Value.ToString()==Model.EnumWorkType.WorkType.應(yīng)用程序.ToString()){MessageBox.Show(this.dgvExeList.Rows[e.RowIndex].Cells["名稱"].Value.ToString()+"是應(yīng)用程序,不需要安裝","不需要安裝",MessageBoxButtons.OK,MessageBoxIcon.Information);return;}elseif(this.dgvExeList.Rows[e.RowIndex].Cells["類型"].Value.ToString()==Model.EnumWorkType.WorkType.服務(wù)程序.ToString()){if(Common.Function.IsExistsService(dgvExeList.Rows[e.RowIndex].Cells["服務(wù)名稱"].Value.ToString())){MessageBox.Show("已經(jīng)存在名稱為"+dgvExeList.Rows[e.RowIndex].Cells["服務(wù)名稱"].Value.ToString()+"的服務(wù),不能重復(fù)安裝","安裝失敗",MessageBoxButtons.OK,MessageBoxIcon.Error);return;}//顯示等待框//this.Cursor=System.Windows.Forms.Cursors.WaitCursor;//調(diào)用命令安裝windows服務(wù)stringstrTmp=string.Empty;if(!dgvExeList.Rows[e.RowIndex].Cells["路徑"].Value.ToString().EndsWith("\\")&&!dgvExeList.Rows[e.RowIndex].Cells["名稱"].Value.ToString().EndsWith("\\")){strTmp=dgvExeList.Rows[e.RowIndex].Cells["路徑"].Value.ToString()+"\\"+dgvExeList.Rows[e.RowIndex].Cells["名稱"].Value.ToString();}else{strTmp=dgvExeList.Rows[e.RowIndex].Cells["路徑"].Value.ToString()+dgvExeList.Rows[e.RowIndex].Cells["名稱"].Value.ToString();}//替換為sccreate命令創(chuàng)建,因?yàn)榇嗣羁梢宰远x服務(wù)名稱屈云明20170721//stringstr=@"%windir%\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe"+strTmp;stringstr=@"sccreate"+dgvExeList.Rows[e.RowIndex].Cells["服務(wù)名稱"].Value.ToString()+"binpath="+strTmp;System.Diagnostics.Processp=newSystem.Diagnostics.Process();p.StartInfo.FileName="cmd.exe";p.StartInfo.UseShellExecute=false;//是否使用操作系統(tǒng)shell啟動(dòng)p.StartInfo.RedirectStandardInput=true;//接受來自調(diào)用程序的輸入信息p.StartInfo.RedirectStandardOutput=true;//由調(diào)用程序獲取輸出信息p.StartInfo.RedirectStandardError=true;//重定向標(biāo)準(zhǔn)錯(cuò)誤輸出p.StartInfo.CreateNoWindow=true;//不顯示程序窗口p.Start();//啟動(dòng)程序//向cmd窗口發(fā)送輸

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論