/// <summary> /// get D01 data /// </summary> /// <param name="dataModel"></param> /// <returns></returns> public Tuple <bool, List <D01ViewModel> > getD01(D01ViewModel dataModel) { if (db.Flow_Info.Any()) { var query = from q in db.Flow_Info.Where(x => x.Group_Product_Code.StartsWith(dataModel.DebtType)) select q; if (dataModel.PRJID.IsNullOrEmpty() == false) { query = query.Where(x => x.PRJID.Contains(dataModel.PRJID)); } if (dataModel.FLOWID.IsNullOrEmpty() == false) { query = query.Where(x => x.FLOWID.Contains(dataModel.FLOWID)); } if (dataModel.Group_Product_Code.IsNullOrEmpty() == false) { query = query.Where(x => x.Group_Product_Code.Contains(dataModel.Group_Product_Code)); } DateTime tempDate; if (dataModel.Publish_Date.IsNullOrEmpty() == false) { tempDate = DateTime.Parse(dataModel.Publish_Date); query = query.Where(x => x.Publish_Date == tempDate); } return(new Tuple <bool, List <D01ViewModel> >((query.Count() > 0 ? true : false), query.AsEnumerable().OrderBy(x => x.PRJID).ThenBy(x => x.FLOWID).Select(x => { return DbToD01ViewModel(x); }).ToList())); } return(new Tuple <bool, List <D01ViewModel> >(false, new List <D01ViewModel>())); }
public JsonResult GetD01Data(D01ViewModel dataModel) { MSGReturnModel result = new MSGReturnModel(); result.RETURN_FLAG = false; result.DESCRIPTION = Message_Type.not_Find_Any.GetDescription("D01"); if (GroupProductCode.M.ToString().Equals(dataModel.DebtType)) { dataModel.DebtType = GroupProductCode.M.GetDescription(); } else if (GroupProductCode.B.ToString().Equals(dataModel.DebtType)) { dataModel.DebtType = GroupProductCode.B.GetDescription(); } try { var D01Data = D0Repository.getD01(dataModel); result.RETURN_FLAG = D01Data.Item1; result.Datas = Json(D01Data.Item2); } catch (Exception ex) { result.RETURN_FLAG = false; result.DESCRIPTION = ex.Message; } return(Json(result)); }
/// <summary> /// D01 save db /// </summary> /// <param name="dataModel"></param> /// <returns></returns> public MSGReturnModel saveD01(D01ViewModel dataModel) { MSGReturnModel result = new MSGReturnModel(); try { if (dataModel.ActionType == "Add") { if (db.Flow_Info.Where(x => x.PRJID == dataModel.PRJID && x.FLOWID == dataModel.FLOWID).Count() > 0) { result.RETURN_FLAG = false; result.DESCRIPTION = "資料重複:" + dataModel.PRJID + " " + dataModel.FLOWID + " 已存在"; return(result); } db.Flow_Info.Add( new Flow_Info() { PRJID = dataModel.PRJID, FLOWID = dataModel.FLOWID, Group_Product_Code = dataModel.Group_Product_Code, Publish_Date = DateTime.Parse(dataModel.Publish_Date), Apply_On_Date = DateTime.Parse(dataModel.Apply_On_Date), Apply_Off_Date = DateTime.Parse(dataModel.Apply_Off_Date), Issuer = dataModel.Issuer, Memo = dataModel.Memo }); } else if (dataModel.ActionType == "Modify") { Flow_Info oldData = db.Flow_Info.Where(x => x.PRJID == dataModel.PRJID && x.FLOWID == dataModel.FLOWID).FirstOrDefault(); oldData.PRJID = dataModel.PRJID; oldData.FLOWID = dataModel.FLOWID; oldData.Group_Product_Code = dataModel.Group_Product_Code; oldData.Publish_Date = DateTime.Parse(dataModel.Publish_Date); oldData.Apply_On_Date = DateTime.Parse(dataModel.Apply_On_Date); oldData.Apply_Off_Date = DateTime.Parse(dataModel.Apply_Off_Date); oldData.Issuer = dataModel.Issuer; oldData.Memo = dataModel.Memo; } db.SaveChanges(); //Save result.RETURN_FLAG = true; } catch (DbUpdateException ex) { result.RETURN_FLAG = false; result.DESCRIPTION = Message_Type .save_Fail.GetDescription("D01", $"message: {ex.Message}" + $", inner message {ex.InnerException?.InnerException?.Message}"); } return(result); }
public JsonResult SaveD01(D01ViewModel data) { MSGReturnModel result = new MSGReturnModel(); result.RETURN_FLAG = false; result.DESCRIPTION = Message_Type.parameter_Error.GetDescription("D01", result.DESCRIPTION); try { D01ViewModel dataModel = new D01ViewModel(); dataModel.DebtType = data.DebtType; dataModel.ActionType = data.ActionType; dataModel.PRJID = data.PRJID; dataModel.FLOWID = data.FLOWID; dataModel.Group_Product_Code = data.Group_Product_Code; dataModel.Publish_Date = DateTime.Now.ToString("yyyy/MM/dd"); dataModel.Apply_On_Date = data.Apply_On_Date; dataModel.Apply_Off_Date = data.Apply_Off_Date; dataModel.Issuer = Transfer.Controllers.AccountController.CurrentUserName; dataModel.Memo = data.Memo; MSGReturnModel resultSave = D0Repository.saveD01(dataModel); result.RETURN_FLAG = resultSave.RETURN_FLAG; result.DESCRIPTION = Message_Type.save_Success.GetDescription("D01"); if (!result.RETURN_FLAG) { result.DESCRIPTION = Message_Type.save_Fail.GetDescription("D01", resultSave.DESCRIPTION); } } catch (Exception ex) { result.RETURN_FLAG = false; result.DESCRIPTION = ex.Message; } return(Json(result)); }
private string formatEventName(ActionExecutingContext filterContext, string eventName) { if (_controllerName == "A4" && _actionName == "TransferToOther") { var type = filterContext.ActionParameters["type"] as string; var debt = filterContext.ActionParameters["debt"] as string; return(string.Format("{1}{0}({2})", _eventName, type == "All" ? "B01" : type, debt == Debt_Type.M.ToString() ? Debt_Type.M.GetDescription() : Debt_Type.B.GetDescription())); } if (_controllerName == "A5") { if (_actionName == "TransferA57A58") { var date = filterContext.ActionParameters["date"] as string; //report_Date var version = filterContext.ActionParameters["version"] as string; //Version var complement = filterContext.ActionParameters["complement"] as string; //補登信評 bool deleteFlag = (bool)filterContext.ActionParameters["deleteFlag"]; //補登信評 return(string.Format("{0}({1},{2},{3},{4})", _eventName, "報導日:" + date, "版本:" + version, "補登信評:" + complement, "重複執行:" + (deleteFlag ? "是" : "否"))); } } if (_controllerName == "A7" && (_actionName == "GetData" || _actionName == "GetExcel")) { var type = filterContext.ActionParameters["type"] as string; return(string.Format("{0}({1})", _eventName, type)); } if (_controllerName == "A8" && _actionName == "GetData") { var type = filterContext.ActionParameters["type"] as string; return(string.Format("{0}({1})", _eventName, type)); } if (_controllerName == "C0" && (_actionName == "GetC07Data" || _actionName == "GetExcel")) { var debtType = filterContext.ActionParameters["debtType"] as string; return(string.Format("{0}({1})", _eventName, debtType == GroupProductCode.B.ToString() ? Debt_Type.B.GetDescription() : Debt_Type.M.GetDescription())); } if (_controllerName == "D0") { if (_actionName == "GetD01Data") { D01ViewModel dataModel = filterContext.ActionParameters["dataModel"] as D01ViewModel; var debtType = dataModel.DebtType; return(string.Format("{0}({1})", _eventName, debtType == GroupProductCode.B.ToString() ? Debt_Type.B.GetDescription() : Debt_Type.M.GetDescription() )); } else if (_actionName == "SaveD01") { D01ViewModel dataModel = filterContext.ActionParameters["data"] as D01ViewModel; var debtType = dataModel.DebtType; var actionType = dataModel.ActionType; return(string.Format("{1}-{0}({2})", _eventName, actionType == "Add" ? "新增" : "修改", debtType == GroupProductCode.B.ToString() ? Debt_Type.B.GetDescription() : Debt_Type.M.GetDescription() )); } else if (_actionName == "DeleteD01") { string prjid = filterContext.ActionParameters["prjid"] as string; string flowid = filterContext.ActionParameters["flowid"] as string; return(string.Format("{0}({1})", _eventName, "專案名稱:" + prjid + ",流程名稱:" + flowid)); } else if (_actionName == "GetD05Data" || _actionName == "GetGroupProductData") { var debtType = filterContext.ActionParameters["debtType"] as string; return(string.Format("{0}({1})", _eventName, debtType == GroupProductCode.B.ToString() ? Debt_Type.B.GetDescription() : Debt_Type.M.GetDescription() )); } else if (_actionName == "SaveD05" || _actionName == "SaveGroupProduct") { var debtType = filterContext.ActionParameters["debtType"] as string; var actionType = filterContext.ActionParameters["actionType"] as string; return(string.Format("{1}{0}({2})", _eventName, actionType == "Add" ? "新增" : "修改", debtType == GroupProductCode.B.ToString() ? Debt_Type.B.GetDescription() : Debt_Type.M.GetDescription() )); } else if (_actionName == "DeleteD05") { string productCode = filterContext.ActionParameters["productCode"] as string; return(string.Format("{0}({1})", _eventName, "產品:" + productCode)); } else if (_actionName == "DeleteGroupProduct") { string groupProductCode = filterContext.ActionParameters["groupProductCode"] as string; return(string.Format("{0}({1})", _eventName, "產品群代碼:" + groupProductCode)); } } if (_controllerName == "D6") { if (_actionName == "SaveD69") { D69ViewModel dataModel = filterContext.ActionParameters["data"] as D69ViewModel; var actionType = dataModel.ActionType; return(string.Format("{1}-{0}", _eventName, actionType == "Add" ? "新增" : "修改")); } else if (_actionName == "DeleteD69" || _actionName == "SendD69ToAudit") { string ruleID = filterContext.ActionParameters["ruleID"] as string; return(string.Format("{0}({1})", _eventName, "規則編號:" + ruleID)); } else if (_actionName == "SetReview" || _actionName == "SetReviewVersion") { string Reference_Nbr = filterContext.ActionParameters["Reference_Nbr"] as string; string Assessment_Result_Version = filterContext.ActionParameters["Assessment_Result_Version"] as string; return(string.Format("{0}({1})", _eventName, "Ref:" + Reference_Nbr + ",ARV :" + Assessment_Result_Version)); } } if (_controllerName == "D7") { if (_actionName == "GetD70Data") { var type = filterContext.ActionParameters["type"] as string; return(string.Format("{0}({1})", _eventName, type)); } else if (_actionName == "SaveD70") { var type = filterContext.ActionParameters["type"] as string; var actionType = filterContext.ActionParameters["actionType"] as string; return(string.Format("{1}-{0}({2})", _eventName, actionType == "Add" ? "新增" : "修改", type)); } else if (_actionName == "DeleteD70" || _actionName == "SendD70ToAudit" || _actionName == "D70Audit") { var type = filterContext.ActionParameters["type"] as string; string ruleID = filterContext.ActionParameters["ruleID"] as string; return(string.Format("{0}-{1}({2})", _eventName, type, "規則編號:" + ruleID)); } } if (_controllerName == "System") { if (_actionName == "SaveAccount") { var action = filterContext.ActionParameters["action"] as string; return(string.Format("{0}{1}", action == Action_Type.Add.ToString() ? Action_Type.Add.GetDescription() : action == Action_Type.Edit.ToString() ? Action_Type.Edit.GetDescription() : action == Action_Type.Dele.ToString() ? Action_Type.Dele.GetDescription() : Action_Type.View.ToString(), _eventName )); } if (_actionName == "SearchAccountLog") { var type = filterContext.ActionParameters["type"] as string; return(string.Format("{0}({1})", _eventName, type == "User" ? "使用者" : type == "Browser" ? "畫面" : "執行動作" )); } if (_actionName == "SearchAssessment") { bool assessmentFlag = bool.Parse(filterContext.ActionParameters["assessmentFlag"].ToString()); return(string.Format("{0}({1})", _eventName, assessmentFlag ? "資料表編號" : "覆核人員/呈送人員" )); } if (_actionName == "AssessmentSetAdd") { string type = filterContext.ActionParameters["type"] as string; return(string.Format("{0}({1})", _eventName, type == SetAssessmentType.Assessment.ToString() ? "表單" : type == SetAssessmentType.Auditor.ToString() ? SetAssessmentType.Auditor.GetDescription() : SetAssessmentType.Presented.GetDescription() )); } if (_actionName == "AssessmentSetDel") { string type = filterContext.ActionParameters["type"] as string; return(string.Format("{0}({1})", _eventName, type == SetAssessmentType.Assessment.ToString() ? "表單" : type == SetAssessmentType.Auditor.ToString() ? SetAssessmentType.Auditor.GetDescription() : SetAssessmentType.Presented.GetDescription() )); } } if (_controllerName == "Common") { if (_actionName == "GetReport") { var type = filterContext.ActionParameters["data"] as CommonController.reportModel; return(string.Format("{0} ({1})", _eventName, type.title)); } } #region default if (filterContext.ActionParameters.Any()) { System.Collections.Generic.List <string> result = new System.Collections.Generic.List <string>(); foreach (var item in filterContext.ActionParameters) { Type t = item.Value.GetType(); if (t.Equals(typeof(string))) { result.Add($"{item.Key} : {(string)item.Value}"); } else if (t.Equals(typeof(int))) { result.Add($"{item.Key} : {((int)item.Value).ToString()}"); } else if (t.Equals(typeof(bool))) { result.Add($"{item.Key} : {((bool)item.Value).ToString()}"); } else if (t.Equals(typeof(double))) { result.Add($"{item.Key} : {((double)item.Value).ToString()}"); } else if (t.Equals(typeof(DateTime))) { result.Add($"{item.Key} : {((DateTime)item.Value).ToString("yyyy/MM/dd")}"); } } if (result.Any()) { return($"{eventName}({string.Join(",", result)})"); } } #endregion return(eventName); }