您的位置:首页 > 移动开发 > Unity3D

构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(46)-工作流设计-设计分支

2015-05-08 11:56 417 查看
系列目录

步骤设置完毕之后,就要设置好流转了,比如财务申请大于50000元(请假天数>5天)要总经理审批,否则财务审批之后就结束了。

[SupportFilter(ActionName = "Edit")]
public ActionResult StepRuleList(string stepId,string formId)
{
//获取现有的步骤
GridPager pager = new GridPager()
{
rows = 1000,
page = 1,
sort = "Id",
order = "desc"
};

Flow_FormModel flowFormModel = m_BLL.GetById(formId);
List<Flow_FormAttrModel>  attrList = new List<Flow_FormAttrModel>();//获取表单关联的字段
attrList = GetAttrList(flowFormModel);
List<Flow_StepModel> stepList = stepBLL.GetList(ref pager, formId);

ViewBag.StepId = stepId;
ViewBag.AttrList = attrList;
ViewBag.StepList = stepList;
return View();
}
[HttpPost]
[SupportFilter(ActionName = "Edit")]
public JsonResult GetStepRuleList(string stepId)
{
List<Flow_StepRuleModel> stepList = stepRuleBLL.GetList(stepId);
int i =1;
var json = new
{
rows = (from r in stepList
select new Flow_StepRuleModel()
{
Mes="分支"+(i++),
Id = r.Id,
StepId = r.StepId,
AttrId = r.AttrId,
AttrName = r.AttrName,
Operator = r.Operator,
Result = r.Result,
NextStep = r.NextStep,
NextStepName = r.NextStepName,
Action = "<a href='#' title='删除' class='icon-remove' onclick='DeleteEvent(\""+r.Id+"\")'></a>"

}).ToArray()

};

return Json(json);
}

[HttpPost]
[SupportFilter(ActionName = "Edit")]
public JsonResult CreateStepEvent(Flow_StepRuleModel model)
{
model.Id = ResultHelper.NewId;
if (model != null && ModelState.IsValid)
{

if (stepRuleBLL.Create(ref errors, model))
{
LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",StepId" + model.Id, "成功", "创建", "Flow_StepRule");
return Json(JsonHandler.CreateMessage(1, Suggestion.InsertSucceed, model.Id));
}
else
{
string ErrorCol = errors.Error;
LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",StepId" + model.Id + "," + ErrorCol, "失败", "创建", "Flow_StepRule");
return Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail + ErrorCol));
}
}
else
{
return Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail));
}
}

[HttpPost]
[SupportFilter(ActionName = "Edit")]
public JsonResult DeleteStepRule(string id)
{
if (!string.IsNullOrWhiteSpace(id))
{
if (stepRuleBLL.Delete(ref errors, id))
{
LogHandler.WriteServiceLog(GetUserId(), "Id:" + id, "成功", "删除", "Flow_StepRule");
return Json(JsonHandler.CreateMessage(1, Suggestion.DeleteSucceed));
}
else
{
string ErrorCol = errors.Error;
LogHandler.WriteServiceLog(GetUserId(), "Id" + id + "," + ErrorCol, "失败", "删除", "Flow_StepRule");
return Json(JsonHandler.CreateMessage(0, Suggestion.DeleteFail + ErrorCol));
}
}
else
{
return Json(JsonHandler.CreateMessage(0, Suggestion.DeleteFail));
}

}
//获取已经添加的字段
private List<Flow_FormAttrModel> GetAttrList(Flow_FormModel model)
{
List<Flow_FormAttrModel> list = new List<Flow_FormAttrModel>();
Flow_FormAttrModel attrModel = new Flow_FormAttrModel();
#region 处理字段
//获得对象的类型,myClass1
Type formType = model.GetType();
//查找名称为"MyProperty1"的属性
string[] arrStr = { "AttrA", "AttrB", "AttrC", "AttrD", "AttrE", "AttrF", "AttrG", "AttrH", "AttrI", "AttrJ", "AttrK"
, "AttrL", "AttrM", "AttrN", "AttrO", "AttrP", "AttrQ", "AttrR", "AttrS", "AttrT", "AttrU"
, "AttrV", "AttrW", "AttrX", "AttrY", "AttrZ"};
foreach (string str in arrStr)
{
object o = formType.GetProperty(str).GetValue(model, null);
if (o != null)
{
//查找model类的Class对象的"str"属性的值
attrModel = attrBLL.GetById(o.ToString());
list.Add(attrModel);
}
}
#endregion
return list;
}


StepRuleList Action
写了这么多都是为了填充这种主从表关系的数据,目前为止都很容易消化。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐