static void Main(string[] args) { //Console.WriteLine("当前版本:" + JobManager.AppVersion); //Console.WriteLine("正在等待附加进程,,,,,,"); //Console.ReadLine(); // 放在计划任务中执行时,默认的当前目录是 Windows 目录,这个很坑爹!,所以这里要切到程序所在目录。 s_exeWorkingDirectory = Path.GetDirectoryName(typeof(Program).Assembly.Location); Environment.CurrentDirectory = s_exeWorkingDirectory; if (RunOnce.CheckApplicationIsRunning()) { return; } if (ProcessCommandLineArgs(args) == false) { return; } // 尝试删除上一次自动更新遗留的临时文件 UpdateHelper.DeleteTempDirectory(); if (ClientInit() == false) { return; } int selectBranchId = ShowMenu(); if (selectBranchId < 0) { return; } try { CheckAppSettings(); CheckEnvironmentVariable(); ExecuteAllJob(selectBranchId); } catch (Exception ex) { ProcessException(ex); } End(); }
public void Initialize() { try { RunOnce.CheckIfAlreadyRun(); // this does all the work of creating compositions, content types, etc. var contentTreeParser = new ContentTreeParser(_ContentService, _ContentTypeService, _DataTypeService, _FileService, _ContextFactory); // this is simply for the purposes of the test, you could just as easily us a blob of json var contentTree = ContentTreeFactory.GetContentTree(); contentTreeParser.Parse(contentTree); RunOnce.RecordFirstRun(); } catch (OperationCanceledException) { // this just means that the dll has already been run once // you can remove the semaphore file from App_Data\TEMP\SiteBuilder.AlreadyRun // if you want to run the code again, but this might create // extra nodes in the CMS or overwrite files } }
public RunOnceTest() { m_mockCache = new Mock<ICache>(MockBehavior.Strict); m_runOnce = new RunOnce(m_mockCache.Object, g_period); }