using System;
using System.Collections.Generic;
using System.Linq;
///
/// 任务卡实例
///
public class TaskCardVo : ItemVo
{
///
/// 任务状态(1完成/0未完成)
///
public Enum_TaskCardStateType state;
///
/// 当前任务步骤数据
///
public List curSteps;
///
/// 排序后的任务步骤数据
///
///
public List GetOrderedSteps()
{
var li = curSteps.OrderBy(st => st.progress()).ToList();
if (this.state >= Enum_TaskCardStateType.finish)
{
li.Reverse();
}
return li;
}
public sm_item_taskcard mo => sm_item_taskcard.GetMoById(int.Parse(this.typeId));
///
/// 找到任务卡的终点步骤
///
///
public ListFinialSteps()=>mo.tasksteps.Split(',').ToList()
.ConvertAll(s=>sm_task_step.GetMoByID(int.Parse(s)).FinalStep());
///
/// 当前任务步骤索引
///
[Obsolete("已过时,curSteps变为并行的,所以这个字段已无意义.-gwang 2020.12.25", true)]
public int curStepIndex = 0;
[Obsolete("前往数据迁移到任务步骤上了. gwang-2020年12月22日10:49", true)]
public GotoParaser Goto => new GotoParaser(mo.goto_module);
}
#region 内部类
///
/// 跳转类型参数拆分
///
public class GotoParaser
{
private string _goto_str;
private Enum_GotoType _goto;
private List _paras;
public GotoParaser(string goto_module_string)
{
this._goto_str = goto_module_string;
var arr = _goto_str.Split(':');
if (arr.Length > 0)
{
if (arr[0] != "")
{
_goto = (Enum_GotoType)Convert.ToInt32(arr[0]);
}
else
{
_goto = (Enum_GotoType)0;
}
}
else
{ // 如果字符串是空的设置默认值
_goto = (Enum_GotoType)0;
}
_paras = new List();
if (arr.Length > 1)
{
_paras.AddRange(arr[1].Split(',').ToList());//.ConvertAll(s => Convert.ToInt32(s)));
}
}
public Enum_GotoType GotoType => _goto;
public List Params => _paras;
}
#endregion
///
/// 任务步骤实例数据
///
public class Ins_TaskStepVo
{
///
/// 模板数据ID
///
public int typeId = 0;
///
/// 当前计数
///
public int cur = 0;
///
/// start/finish act已执行(0:startAct未执行,1:StartAct已执行且finishAct未执行,2:finishAct已执行)
///
public int actState = 0;
///
/// start/finish act 的执行状态
///
///
public EActionState ActionState() => (EActionState)actState;
///
/// 是否需要执行StartAction
///
///
public bool ShouldDoStartAction() => actState < 1 && mo().StartAction.cmd != 0;
///
/// 是否需要执行FinishAction
///
///
public bool ShouldDoFinishAction() => actState <= 1 && isFinish() && mo().FinishAction.cmd != 0;
///
/// 快速访问模板数据
///
///
public sm_task_step mo() => sm_task_step.GetMoByID(this.typeId);
///
/// 计数最大值
///
///
public int max()
{
return mo().num;
}
///
/// 将条件参数拆分成字符串数组
///
///
private string[] paras() => mo().paras.Split(',');
///
/// 当前进度
///
///
public float progress() => (float)cur / max();
///
/// 是否完成
///
///
public bool isFinish() => cur >= max();
///
/// 任务进度提示字符串
///
///
public string ProgressInfo() => $"{mo().des} ({cur}/{max()}).";
///
/// 前往数据
///
public GotoParaser Goto => new GotoParaser(mo().goto_module);
///
///
///
public enum EActionState
{
///
/// startAction未完成
///
StartActionUndone = 0,
///
/// StartAction已经完成,并且finishAction未完成
///
StartActionOkAndFinishActionUndone = 1,
///
/// finishAction也已经完成
///
FinishActionOk = 2
}
}