/// <summary> /// Initializes a new instance of the <see cref="ProjectionBase{TState}"/> class. /// </summary> /// <param name="eventStore">Event store service</param> /// <param name="log">Log service</param> /// <param name="activeTimeline">Timeline service</param> /// <param name="streamLocator">Stream locator</param> public ProjectionBase(IEventStore <IAggregate> eventStore, ILog log, ITimeline activeTimeline, IStreamLocator streamLocator) { EventStore = eventStore; Log = log; ActiveTimeline = activeTimeline; _streamLocator = streamLocator; CancellationSource = new RepeatableCancellationTokenSource(); _start = new Lazy <Task>(() => Task.Run(Start)); var options = new DataflowOptions { RecommendedParallelismIfMultiThreaded = 1 }; Build = new BuildFlow(options, this); StatusSubject.Where(s => s != Sleeping) .Subscribe(s => Log?.Info($"[{Timeline}]{GetType().GetFriendlyName()}/{RuntimeHelpers.GetHashCode(this)}/ : {s.ToString()}")); }
/// <summary> /// 开始构建流 /// </summary> void OnFlow_Begin() { //开始的时候,检查状态 if (CheckPackingAssetPackignFlow()) { return; } else if (!CheckBuildProjectFlow()) { currBuildFlow = BuildFlow.BuilFlow_None; LastBuildFlow = BuildFlow.BuilFlow_None; if (NeedToExitEditor) { EditorApplication.Exit(0); } } }
void UpdateBuildFlow() { TimeSpan s = new TimeSpan(DateTime.Now.Ticks - currDelayToPackageTicks); if (s.TotalSeconds < 2.0f) { return; } //没有任何东西,不需要打包 if (!File.Exists(GetCommand_BuildingReleaseProjectPath64()) && !File.Exists(GetCommand_BuildingReleaseProjectPath()) && !File.Exists(GetCommand_BuildingDebugProjectPath64()) && !File.Exists(GetCommand_BuildingDebugProjectPath()) && !File.Exists(GetCommand_PackingAssetsPath64()) && !File.Exists(GetCommand_PackingAssetsPath()) ) { return; } if (currBuildFlow == LastBuildFlow) { return; } LastBuildFlow = currBuildFlow; bool is64Bit = File.Exists(GetCommand_BuildingDebugProjectPath64()) || File.Exists(GetCommand_BuildingReleaseProjectPath64()) || File.Exists(GetCommand_PackingAssetsPath64()); bool isDebug = File.Exists(GetCommand_BuildingDebugProjectPath()) || File.Exists(GetCommand_BuildingDebugProjectPath64()); switch (currBuildFlow) { case BuildFlow.BuilFlow_Begin: OnFlow_Begin(); break; case BuildFlow.BuildFlow_BuildingEXE: OnFlow_OnBuildingEXE(isDebug, is64Bit); break; case BuildFlow.BuildFlow_PackingAssetPackage: OnFlow_PackingAssetPackage(is64Bit); break; } }
bool CheckPackingAssetPackignFlow() { /* 1.首先检查是否处于打包流程 * 如果处于打包流程,看看是否打包失败,如果打包失败的,要还原对应的文件 * 然后重新开始打包 */ if (IsCommandOnPackingAssetPackage()) { if (File.Exists(GetBuildFlowPackingAssetPackageFaildPath())) { CopyFileHelper(GetBuildFlowPackageListPath(), GetEditorAssetPackagePatchRoot() + AssetBundleManager.AssetPackageListPatch); currBuildFlow = BuildFlow.BuildFlow_PackingAssetPackage; DeleteFileHelper(GetBuildFlowPackingAssetPackageFaildPath()); DeleteFileHelper(GetBuildFlowPackageListPath()); return(true); } } /** * 2.检查是否完成了打包,但是没有进行buildexe,就又来打包一次 * 这个时候就要还原文件 * 然后重新开始打包 */ if (IsCommandOnPackingAssetPackage()) { if (File.Exists(GetBuildFlowPackingAssetPackageSuccessdPath())) { CopyFileHelper(GetBuildFlowPackageListPath(), GetEditorAssetPackagePatchRoot() + AssetBundleManager.AssetPackageListPatch); currBuildFlow = BuildFlow.BuildFlow_PackingAssetPackage; DeleteFileHelper(GetBuildFlowPackingAssetPackageSuccessdPath()); DeleteFileHelper(GetBuildFlowPackageListPath()); return(true); } } /** * 3.检查打包的时候是否carsh了 * 这个时候就要还原文件 * 然后重新开始打包 */ if (IsCommandOnPackingAssetPackage()) { if (File.Exists(GetBuildFlowPackingAssetPackageCarshFlagsPath())) { CopyFileHelper(GetBuildFlowPackageListPath(), GetEditorAssetPackagePatchRoot() + AssetBundleManager.AssetPackageListPatch); currBuildFlow = BuildFlow.BuildFlow_PackingAssetPackage; DeleteFileHelper(GetBuildFlowPackingAssetPackageCarshFlagsPath()); DeleteFileHelper(GetBuildFlowPackageListPath()); return(true); } } /** * 4.需要打包,但是没有成功,没有失败,那就是一个全新的。 * 直接开始打包 */ if (IsCommandOnPackingAssetPackage()) { currBuildFlow = BuildFlow.BuildFlow_PackingAssetPackage; return(true); } return(false); }
void StartBuildFlow() { currBuildFlow = BuildFlow.BuilFlow_Begin; LastBuildFlow = BuildFlow.BuilFlow_None; }
bool CheckBuildProjectFlow() { /* 1.首先检查是否打资源包的时候是否carsh了,如果carsh了,弹框提示重新打包资源,退出 */ if (IsCommandOnBuildEXE()) { if (File.Exists(GetBuildFlowPackingAssetPackageCarshFlagsPath())) { ReleaseBuildingEXECommand(); EditorUtility.DisplayDialog("发布错误", "资源打包时Unity崩溃,请重新进行资源打包后再发布,如果想强制发布请删除文件夹:" + GetBuildFlowFloderPathRoot() + ",但会出现很多问题", "确定"); return(false); } } /* 资源打包失败,先询问一下 */ if (IsCommandOnBuildEXE()) { if (File.Exists(GetBuildFlowPackingAssetPackageFaildPath())) { //外部层序的话,由外部判断 if (File.Exists(GetRunFromOutSideProgramPath())) { CopyFileHelper(GetBuildFlowFloderPathRoot() + ResDetailFileName, GetClient_GamePathRoot() + ResDetailFileName); currBuildFlow = BuildFlow.BuildFlow_BuildingEXE; return(true); } if (EditorUtility.DisplayDialog("发布警告", "资源发布的时候发生了一些错误,如果要强制发布项目的话,可能会造成一些资源丢失或者崩溃,是否需要发布?", "是", "否")) { CopyFileHelper(GetBuildFlowFloderPathRoot() + ResDetailFileName, GetClient_GamePathRoot() + ResDetailFileName); currBuildFlow = BuildFlow.BuildFlow_BuildingEXE; return(true); } return(false); } } /* 2.首先检查是否处于发布流程 * 如果处于发布流程,看看是否发布失败,如果发布失败的,要还原对应的文件 * 然后重新开始发布 */ if (IsCommandOnBuildEXE()) { if (File.Exists(GetBuildFlowBuildProjectFaildPath())) { CopyFileHelper(GetBuildFlowFloderPathRoot() + ResDetailFileName, GetClient_GamePathRoot() + ResDetailFileName); currBuildFlow = BuildFlow.BuildFlow_BuildingEXE; DeleteFileHelper(GetBuildFlowBuildProjectFaildPath()); DeleteFileHelper(GetBuildFlowFloderPathRoot() + ResDetailFileName); return(true); } } /* 2.再检查发布的时候是不是崩溃了要还原对应的文件 * 然后重新开始发布 */ if (IsCommandOnBuildEXE()) { if (File.Exists(GetBuildProjectCarshFlagsPath())) { CopyFileHelper(GetBuildFlowFloderPathRoot() + ResDetailFileName, GetClient_GamePathRoot() + ResDetailFileName); currBuildFlow = BuildFlow.BuildFlow_BuildingEXE; DeleteFileHelper(GetBuildFlowBuildProjectFaildPath()); DeleteFileHelper(GetBuildFlowFloderPathRoot() + ResDetailFileName); return(true); } } /** * 4.需要发布,但是没有失败(对发布来说,发布成功就结束了整个流程了),那就是一个全新的。 * 直接开始打包 */ if (IsCommandOnBuildEXE()) { currBuildFlow = BuildFlow.BuildFlow_BuildingEXE; return(true); } return(false); }