void app_UpdateFinish() { //解压下载后的文件 WriteLog.WriteLogFile("下载完成" + app.FinalZipName); string path = app.FinalZipName; if (File.Exists(path)) { WriteLog.WriteLogFile("找到下载文件" + app.FinalZipName); //后改的 先解压滤波zip植入ini然后再重新压缩 string dirEcgPath = Application.StartupPath + "\\" + "autoupload"; if (!Directory.Exists(dirEcgPath)) { Directory.CreateDirectory(dirEcgPath); } string dirEcgPath2 = Application.StartupPath + "\\" + "program"; if (!Directory.Exists(dirEcgPath2)) { Directory.CreateDirectory(dirEcgPath2); } //开始解压压缩包 MyFuncUtil.UnRarOrZip(dirEcgPath, path, true, ""); try { MyFuncUtil.killProcess("wlxm"); System.Threading.Thread.Sleep(1000 * 10); WriteLog.WriteLogFile("如果有,关闭旧的wlxm"); //复制新文件替换旧文件 DirectoryInfo TheFolder = new DirectoryInfo(dirEcgPath); foreach (FileInfo NextFile in TheFolder.GetFiles()) { File.Copy(NextFile.FullName, Application.StartupPath + "\\program\\" + NextFile.Name, true); } Directory.Delete(dirEcgPath, true); File.Delete(path); //覆盖完成 重新启动程序 WriteLog.WriteLogFile("启动wlxm"); path = Application.StartupPath + "\\program"; System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.FileName = "wlxm.exe"; process.StartInfo.WorkingDirectory = path;//要掉用得exe路径例如:"C:\windows"; process.StartInfo.CreateNoWindow = true; process.Start(); } catch (Exception) { WriteLog.WriteLogFile("请关闭系统在执行更新操作!"); } } }
/* * USE [yiquan] * GO * SET ANSI_NULLS ON * GO * SET QUOTED_IDENTIFIER ON * GO * SET ANSI_PADDING ON * GO * CREATE TABLE [dbo].[zhanghao]( * [name] [varchar](50) NULL, * [pwd] [varchar](50) NULL, * [yxbz] [char](1) NULL, * [dengluzhong] [char](1) NULL, * [dqindex] [int] NULL, * [pcname] [varchar](50) NULL, * [img] [varchar](50) NULL, * [imgtime] [date] NULL, * [daydenglu] [text] NULL, * [yimai] [char](1) NULL * ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] * * GO * * SET ANSI_PADDING OFF * GO */ /// <summary> /// 单例模式====双层互锁 /// </summary> /// <returns></returns> public static SqlHelp GetInstance() { if (mysql == null) { lock (obj) { mysql = new SqlHelp(); string connString = null; if (MyFuncUtil.getMachineName().ToLower().Equals("wlzhongkong") || MyFuncUtil.getMachineName().ToLower().Equals("wlbgs")) { connString = "Data Source=" + MyFuncUtil.getMachineName().ToLower() + @"\SQLEXPRESS;Initial Catalog=yiquan;User ID=sa;Password=123456"; } else { connString = @"Data Source=192.168.4.44;Initial Catalog=yiquan;User ID=sa;Password=123456"; } conn = new SqlConnection(connString); } } return(mysql); }
public void shouhuzhong() { MyFuncUtilNoJingTai my = new MyFuncUtilNoJingTai(); long ks = my.GetTimestamp(); long ks2 = my.GetTimestamp(); long ks3 = my.GetTimestamp(); long ks4 = my.GetTimestamp(); long ks5 = my.GetTimestamp(); long ks6 = my.GetTimestamp(); long ks7 = my.GetTimestamp(); long ks8 = my.GetTimestamp(); long ks9 = my.GetTimestamp(); int duokai = 0; int ksgx = 0; int ksck = 0; while (true) { if (ksgx == 0) { System.Threading.Thread.Sleep(1000 * 10); ksgx = 1; WriteLog.WriteLogFile("第一次打开要更新" + System.IO.File.Exists(System.Windows.Forms.Application.StartupPath + "\\program\\wlxm.exe") + " " + System.Windows.Forms.Application.StartupPath + "\\program\\wlxm.exe"); UpdateCaoZuo sh = new UpdateCaoZuo(); sh.updateWlxm(); } if (ksck == 0) { System.Threading.Thread.Sleep(1000 * 30); ksck = 1; WriteLog.WriteLogFile("第一次打开要看否打开了wlxm" + System.IO.File.Exists(System.Windows.Forms.Application.StartupPath + "\\program\\wlxm.exe") + " " + System.Windows.Forms.Application.StartupPath + "\\program\\wlxm.exe"); bool t = false; string appname = "wlxm"; int a = 0; Process[] processes = Process.GetProcessesByName(appname); foreach (Process process in processes) { if (a == 0 && process.ProcessName == appname) { t = true; a = 1; break; } } if (!t) { string appNamec = System.Windows.Forms.Application.StartupPath + "\\program\\wlxm.exe"; WriteLog.WriteLogFile("wlxm位置" + System.Windows.Forms.Application.StartupPath + "\\program\\wlxm.exe"); if (System.IO.File.Exists(System.Windows.Forms.Application.StartupPath + "\\program\\wlxm.exe")) { WriteLog.WriteLogFile("wlxm找到文件位置"); Process p = new Process(); p.StartInfo.FileName = appNamec; //启动程序 p.Start(); ks2 = my.GetTimestamp();//关机项重新计时 WriteLog.WriteLogFile("结束打开wlxm"); } } } long js = my.GetTimestamp(); //只是说明还活着 if ((js - ks) > 1000 * 60 * 5) { ks = my.GetTimestamp(); ShouHu s = new ShouHu(); s.wohaihuozhe(); } //长时间没有数则重启 1号机之外的机器1个半小时 if (!MyFuncUtil.getMachineName().ToUpper().Equals("1HAO") && (js - ks2) > 1000 * 60 * 90) { ks2 = my.GetTimestamp(); ShouHu s = new ShouHu(); bool t = s.panDuanChongQi(MyFuncUtil.getMachineName()); t = false; if (!MyFuncUtil.getMachineName().ToLower().Equals("wlzhongkong") && t) { WriteLog.WriteLogFile("重启啦!!!"); System.Diagnostics.Process.Start("shutdown.exe", "-r -f -t 15"); } } //长时间没有数则重启 1号机 1个半小时 if (MyFuncUtil.getMachineName().ToUpper().Equals("1HAO") && (js - ks2) > 1000 * 60 * 90) { ks2 = my.GetTimestamp(); ShouHu s = new ShouHu(); bool t = s.panDuanChongQi(MyFuncUtil.getMachineName()); t = false; if (!MyFuncUtil.getMachineName().ToLower().Equals("wlzhongkong") && t) { WriteLog.WriteLogFile("重启啦!!!"); System.Diagnostics.Process.Start("shutdown.exe", "-r -f -t 15"); } } //定时更新运行情况 if ((js - ks3) > 1000 * 60 * 20) { ks3 = MyFuncUtil.GetTimestamp(); DateTime dt = getYunXingQkLasttime(); TimeSpan span = DateTime.Now.Subtract(dt); //WriteLog.WriteLogFile("准备更新与上次统计相比,间隔 " + span.Minutes + "分钟"); if (span.Hours >= 1) { //WriteLog.WriteLogFile("与上次统计相比,间隔 " + span.Minutes + "分钟"); //gxYunXingQk("jingjieguanfang"); } } //检测wlxm if ((js - ks4) > 1000 * 60 * 10) { ks4 = MyFuncUtil.GetTimestamp(); Process current = Process.GetCurrentProcess(); string appname = "wlxm"; bool t = false; Process[] processes = Process.GetProcessesByName(appname); int a = 0; foreach (Process process in processes) { if (a == 0 && process.ProcessName == appname) { t = true; a = 1; break; } } if (!t) { ks8 = MyFuncUtil.GetTimestamp(); string appNamec = System.Windows.Forms.Application.StartupPath + "\\program\\wlxm.exe"; WriteLog.WriteLogFile("wlxm位置" + System.Windows.Forms.Application.StartupPath + "\\program\\wlxm.exe"); if (System.IO.File.Exists(System.Windows.Forms.Application.StartupPath + "\\program\\wlxm.exe")) { WriteLog.WriteLogFile("wlxm找到文件位置"); Process p = new Process(); p.StartInfo.FileName = appNamec; //启动程序 p.Start(); ks2 = my.GetTimestamp();//关机项重新计时 WriteLog.WriteLogFile("结束打开wlxm"); } } } //检测多开器 if ((js - ks5) > 1000 * 60 * 20) { ks5 = MyFuncUtil.GetTimestamp(); Process current = Process.GetCurrentProcess(); string appname = "dnmultiplayer"; bool t = false; Process[] processes = Process.GetProcessesByName(appname); foreach (Process process in processes) { if (process.ProcessName == appname) { t = true; duokai = 0; break; } } if (!t) { System.Threading.Thread.Sleep(30000); Process p = new Process(); p.StartInfo.FileName = @"D:\ChangZhi\dnplayer2\dnmultiplayer.exe"; //启动程序 p.Start(); WriteLog.WriteLogFile("结束打开多开器2"); System.Threading.Thread.Sleep(10000); } processes = Process.GetProcessesByName(appname); foreach (Process process in processes) { if (process.ProcessName == appname) { t = true; duokai = 0; break; } } if (!t) { duokai++; } if (!MyFuncUtil.getMachineName().ToLower().Equals("wlzhongkong") && duokai > 1) { WriteLog.WriteLogFile("dnmultiplayer不存在了"); //WriteLog.WriteLogFile("重启啦!!!"); //System.Diagnostics.Process.Start("shutdown.exe", "-r -f -t 15"); //WriteLog.WriteLogFile("结束打开dnmultiplayer"); } } //检测wlxm if ((js - ks6) > 1000 * 60 * 10) { ks6 = MyFuncUtil.GetTimestamp(); UpdateCaoZuo sh = new UpdateCaoZuo(); sh.updateWlxm(); } if ((js - ks7) > 1000 * 60 * 45) { ks7 = my.GetTimestamp(); ShouHu s = new ShouHu(); bool t = s.panDuanChongQi(MyFuncUtil.getMachineName()); t = false; if (t) { ks8 = MyFuncUtil.GetTimestamp(); MyFuncUtil.killProcess("wlxm"); System.Threading.Thread.Sleep(1000 * 50); string appname = "wlxm"; bool t1 = false; Process[] processes = Process.GetProcessesByName(appname); int a = 0; foreach (Process process in processes) { if (a == 0 && process.ProcessName == appname) { t1 = true; a = 1; break; } } if (!t1) { string appNamec = System.Windows.Forms.Application.StartupPath + "\\program\\wlxm.exe"; WriteLog.WriteLogFile("wlxm位置" + System.Windows.Forms.Application.StartupPath + "\\program\\wlxm.exe"); if (System.IO.File.Exists(System.Windows.Forms.Application.StartupPath + "\\program\\wlxm.exe")) { WriteLog.WriteLogFile("wlxm找到文件位置"); Process p = new Process(); p.StartInfo.FileName = appNamec; //启动程序 p.Start(); ks2 = my.GetTimestamp();//关机项重新计时 WriteLog.WriteLogFile("结束打开wlxm"); } } } } if ((js - ks8) > 1000 * 60 * 20) { ks8 = MyFuncUtil.GetTimestamp(); string dir = "C:\\mylog\\" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + "\\"; if (System.IO.Directory.Exists(dir))//文件夹是否存在 { System.IO.FileInfo[] fis = new System.IO.DirectoryInfo(dir).GetFiles(); int isalive = 0; if (fis != null && fis.Count() > 0) { for (int i1 = 0; i1 < fis.Length; i1++) { TimeSpan span = DateTime.Now.Subtract(fis[i1].LastWriteTime); if (span.TotalMinutes > 30) { isalive++; } } } if (isalive > 5) { WriteLog.WriteLogFile("超过5个模拟器长时间不更新了"); MyFuncUtil.killProcess("wlxm"); string appname = "wlxm"; Process[] processes = Process.GetProcessesByName(appname); int a = 0; bool t1 = false; foreach (Process process in processes) { if (a == 0 && process.ProcessName == appname) { t1 = true; a = 1; break; } } if (!t1) { string appNamec = System.Windows.Forms.Application.StartupPath + "\\program\\wlxm.exe"; WriteLog.WriteLogFile("wlxm位置" + System.Windows.Forms.Application.StartupPath + "\\program\\wlxm.exe"); if (System.IO.File.Exists(System.Windows.Forms.Application.StartupPath + "\\program\\wlxm.exe")) { WriteLog.WriteLogFile("wlxm找到文件位置"); Process p = new Process(); p.StartInfo.FileName = appNamec; //启动程序 p.Start(); ks2 = my.GetTimestamp();//关机项重新计时 WriteLog.WriteLogFile("结束打开wlxm"); } } } } } if ((js - ks9) > 1000 * 60 * 20) { ks9 = MyFuncUtil.GetTimestamp(); string dir = "d:\\mylog\\" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + "\\"; if (System.IO.Directory.Exists(dir))//文件夹是否存在 { System.IO.FileInfo[] fis = new System.IO.DirectoryInfo(dir).GetFiles(); int isalive = 0; if (fis != null && fis.Count() > 0) { for (int i1 = 0; i1 < fis.Length; i1++) { TimeSpan span = DateTime.Now.Subtract(fis[i1].LastWriteTime); if (span.TotalMinutes > 30) { isalive++; } } } if (isalive > 0) { WriteLog.WriteLogFile("wlsh长时间不更新了"); MyFuncUtil.killProcess("wlsh"); string appname = "wlsh"; Process[] processes = Process.GetProcessesByName(appname); int a = 0; bool t1 = false; foreach (Process process in processes) { if (a == 0 && process.ProcessName == appname) { t1 = true; a = 1; break; } } if (!t1) { string appNamec = System.Windows.Forms.Application.StartupPath + "\\wlsh.exe"; WriteLog.WriteLogFile("wlsh位置" + System.Windows.Forms.Application.StartupPath + "\\wlsh.exe"); if (System.IO.File.Exists(System.Windows.Forms.Application.StartupPath + "\\wlsh.exe")) { WriteLog.WriteLogFile("wlsh找到文件位置"); Process p = new Process(); p.StartInfo.FileName = appNamec; //启动程序 p.Start(); ks2 = my.GetTimestamp();//关机项重新计时 WriteLog.WriteLogFile("结束打开wlsh"); } } } } } } }
public void wohaihuozhe() { WriteLog.WriteLogFile("生命的迹象 " + MyFuncUtil.suijishu(1, 100)); }