public UpdateEvent(PatchTask task, float progress, State state, Action action) { this.task = task; this.progress = progress; this.state = state; this.action = action; }
internal void Deploy(DeviceType device) { if (m_xap == null) { throw new InvalidOperationException("Target application is not selected."); } var hookProvider = new HookProvider( m_view.GetLogMethodNames(), m_view.GetLogParameterValues(), m_view.GetLogReturnValues(), m_view.GetHooks() ); PatchTask patchTask = new PatchTask( m_xap, hookProvider, device, AddOutputText, ResetButton ); var context = TaskScheduler.FromCurrentSynchronizationContext(); Task.Factory.StartNew(patchTask.Run) .ContinueWith(t => { if (t.IsFaulted) { HandleError(t.Exception.InnerException); } }, context ); }
public void Test_PatchTask_Creation() { PatchTask task = new PatchTask(); Assert.NotNull(task); Assert.NotNull(task.PatchSubGrids); Assert.True(0 == task.PatchSubGrids.Count, "Patched subgrid count not 0 after creation"); }
public void closeTask(string name) { PatchTask pt = getTask(name); if (pt == null) { return; } pt.stop(); mTasks.Remove(pt); }
public void Test_PatchTask_TransferResponse_FailWithAbortSignal() { var pipeLine = new Mock <ISubGridPipelineBase>(); pipeLine.Setup(mk => mk.Aborted).Returns(true); PatchTask task = new PatchTask { PipeLine = pipeLine.Object }; task.TransferResponse(new IClientLeafSubGrid[] { }).Should().BeFalse(); }
public bool hasRunningTask(bool includeBackground = false) { for (int i = 0; i < mTasks.Count; ++i) { PatchTask pt = mTasks[i]; if (!includeBackground && pt.runInBackground) { continue; } if (pt.isRunning) { return(true); } } return(false); }
public PatchTask checkVersion(int newVersion, string url) {//version.xml只能在进入游戏前下载 initUrl(mNewVersion, url); if (ResLoad.version >= newVersion) { return(null); } mNewVersion = newVersion; initUrl(mNewVersion, url); PatchTask pt = getTask("init"); if (pt == null) { mTasks.Add(pt = new PatchTask("init", ResLoad.part)); } Log.i("pullVersion:" + ResLoad.version + "->" + newVersion, Log.Tag.Update); return(pt); }
//name=null will stop all task void stopTask(string name = null) { if (name != null) { for (int i = 0; i < mTasks.Count; ++i) { mTasks[i].stop(); } } else { PatchTask pt = mTasks.Find(delegate(PatchTask obj){ return(obj.mName == name); }); if (pt != null) { pt.stop(); } } }
public PatchTask getTask(string name, int[] downParts = null) { PatchTask pt = mTasks.Find(delegate(PatchTask obj){ return(obj.mName == name); }); if (downParts != null && pt == null) { if (mUrl == null) { throw new Exception("url not set, please checkVersion first"); } if (ResLoad.version != mNewVersion) { throw new Exception("version.xml is not match version, please checkVersion first"); } pt = new PatchTask(name, downParts); mTasks.Add(pt); } return(pt); }
public void Test_PatchTask_TransferResponse() { var pipeLine = new Mock <ISubGridPipelineBase>(); pipeLine.Setup(mk => mk.Aborted).Returns(false); PatchTask task = new PatchTask { PipeLine = pipeLine.Object }; ClientHeightLeafSubGrid transferSubgrid = new ClientHeightLeafSubGrid(null, null, 0, 1, 0); task.TransferResponse(new IClientLeafSubGrid[] { transferSubgrid }); Assert.True(task.PatchSubGrids.Count == 1, $"Count of transferred subgrids not 1 as expected (= {task.PatchSubGrids.Count}"); Assert.True(task.PatchSubGrids[0] == transferSubgrid, $"Transferred subgrid is not the same as the one passed into the task."); }
/// <summary> /// Runs all install tasks. Takes chosen install groups into account /// </summary> /// <param name="patch"></param> /// <param name="log"></param> /// <param name="culture"></param> /// <param name="isInstall"></param> /// <param name="chosenInstallGroups"></param> public static void RunAll(PCH patch, Log log, DB.Culture culture, bool isInstall, List <string> chosenInstallGroups) { try { // 1. Preparatory : folders try { // Setting transversal values if (patch == null) { throw new Exception("No patch specified."); } _CurrentPatch = patch; if (log != null) { _Log = log; } if (string.IsNullOrEmpty(Tools.TduPath)) { throw new Exception("Invalid TDU install path specified."); } _Culture = culture; _InstallGroups = chosenInstallGroups; // Go! PreparatoryTask.Run(); } catch (Exception ex) { Log.Error("Install error when executing preparatory task.", ex); throw; } // 2. Running patch try { PatchTask.Run(); } catch (Exception ex) { Log.Error("Error when running core patch instructions.", ex); throw; } // 3. Finalization try { FinalizationTask.Run(isInstall); } catch (Exception ex) { Log.Error("Error when executing finalization task.", ex); throw; } } catch (Exception ex) { if (isInstall) { throw new Exception("Current patch can't be installed:\r\n" + ex.Message, ex); } throw new Exception("Current patch can't be uninstalled:\r\n" + ex.Message, ex); } }
internal void Deploy(DeviceType device) { if (m_xap == null) { throw new InvalidOperationException("Target application is not selected."); } var hookProvider = new HookProvider( m_view.GetLogMethodNames(), m_view.GetLogParameterValues(), m_view.GetLogReturnValues(), m_view.GetHooks() ); PatchTask patchTask = new PatchTask( m_xap, hookProvider, device, AddOutputText, ResetButton ); var context = TaskScheduler.FromCurrentSynchronizationContext(); Task.Factory.StartNew(patchTask.Run) .ContinueWith(t => { if (t.IsFaulted) { HandleError(t.Exception.InnerException); } }, context ); }