/// <summary> /// 任务的开启 /// </summary> /// <param name="taskid"></param> /// <returns></returns> public bool Start() { lock (_locktag) { if (TaskRunTimeInfo != null) { throw new Exception("采集任务已启动,启动失败"); } TaskRunTimeInfo = new TaskRuntimeInfo(); SqlHelper.ExcuteSql(CoreGlobalConfig.PlatformManageConnectString, (c) => { tb_cluster_collect_version_dal versiondal = new tb_cluster_collect_version_dal(); TaskRunTimeInfo.TaskVersionModel = versiondal.GetCurrentVersion(c); }); string filelocalcachepath = AppDomain.CurrentDomain.BaseDirectory.TrimEnd('\\') + "\\" + GlobalConfig.TaskDllCompressFileCacheDir + @"\" + TaskRunTimeInfo.TaskVersionModel.versionnum + @"\" + TaskRunTimeInfo.TaskVersionModel.zipfilename; string fileinstallpath = AppDomain.CurrentDomain.BaseDirectory.TrimEnd('\\') + "\\" + GlobalConfig.TaskDllDir + @"\"; string fileinstallmainclassdllpath = fileinstallpath + @"\" + "Dyd.BaseService.Monitor.Collect.exe"; XXF.Common.IOHelper.CreateDirectory(filelocalcachepath); XXF.Common.IOHelper.CreateDirectory(fileinstallpath); System.IO.File.WriteAllBytes(filelocalcachepath, TaskRunTimeInfo.TaskVersionModel.zipfile); CompressHelper.UnCompress(filelocalcachepath, fileinstallpath); try { var dlltask = new AppDomainLoader <BaseCollectMonitorDll>().Load(fileinstallmainclassdllpath, "Dyd.BaseService.Monitor.Collect.CollectMonitorDll", out TaskRunTimeInfo.Domain); dlltask.PlatformManageConnectString = CoreGlobalConfig.PlatformManageConnectString; dlltask.ServerIP = GlobalConfig.ServerIP; dlltask.TryStart(); LogHelper.Log("采集任务启动成功"); return(true); } catch (Exception exp) { DisposeTask(); throw exp; } } }