private void MoveForward() { switch (this.Direction) { case RoverDirection.N: this.Y += 1; FlowPath.Add(new RoverPoints(X, Y)); break; case RoverDirection.S: this.Y -= 1; FlowPath.Add(new RoverPoints(X, Y)); break; case RoverDirection.E: this.X += 1; FlowPath.Add(new RoverPoints(X, Y)); break; case RoverDirection.W: this.X -= 1; FlowPath.Add(new RoverPoints(X, Y)); break; default: break; } }
// Download Route Task FlowPath public FlowPath GetFlowPath(string fID, int FlowCode, int State, string strAction) { //http://localhost:56491/api/Task/getFlowPath?fID=A38AFFA3-4F99-447A-93F3-72FE3207DE1A&FlowCode=1001001&State=10&strAction=A string ApiUrl = _routeswebsite + @"/api/task/getFlowPath?fID=" + fID + "&FlowCode=" + FlowCode.ToString() + "&State=" + State.ToString() + "&strAction=" + strAction; string response = GetWebResponse(ApiUrl); var fp = Newtonsoft.Json.JsonConvert.DeserializeObject(response); FlowPath objfp = (FlowPath)Newtonsoft.Json.JsonConvert.DeserializeObject <FlowPath>(fp.ToString()); return(objfp); }
// // GET: /F_CERL/Edit/5 public f_cerl CheckAndPushTask(FormCollection fc, f_cerl f_cerl) { string strAction = f_cerl.Action; string ListAssignTo = ""; HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); StringBuilder vchSet = new StringBuilder(); FlowPath fp = GetFlowPath(f_cerl.fID, f_cerl.FlowCode, f_cerl.State, f_cerl.Action);// 取得下一關的State if (fp == null) { return(f_cerl); } if (f_cerl.State >= 1000) { strAction = ""; return(f_cerl); } if (fp != null) { if (f_cerl.LocalSupervisor == null) { f_cerl.LocalSupervisor = "IEC970209"; } vchSet.Append(Method.BuildXML(fp.outState.ToString(), "outState")); vchSet.Append(Method.BuildXML(f_cerl.Supervisor, "Supervisor")); vchSet.Append(Method.BuildXML(f_cerl.LocalSupervisor, "LocalSupervisor")); vchSet.Append(Method.BuildXML(f_cerl.LabMember, "LabMember")); vchSet.Append(Method.BuildXML(f_cerl.Applicant, "Applicant")); vchSet.Append(Method.BuildXML(f_cerl.Manager, "Manager")); vchSet.Append(Method.BuildXML(f_cerl.Action, "")); GetListAssignTo(fp.outState, vchSet.ToString(), out ListAssignTo); //取得下一關的收件人 f_cerl.ListAssignTo = ListAssignTo; if (ListAssignTo != "") { response = PostFormDataToRoute(fc, f_cerl); //Push Task, Send Task mail by AssignTo } f_cerl.State = int.Parse(fp.outState.ToString()); } return(f_cerl); }
// // Test: /DownloadJson/ /* * FlowPath objfp = (FlowPath)Newtonsoft.Json.JsonConvert.DeserializeObject(response); * JavaScriptSerializer jsonSerializer = new JavaScriptSerializer(); * FlowPath fp = (FlowPath)jsonSerializer.DeserializeObject(response); * * var objfp = jsonSerializer.DeserializeObject(response); * jsonSerializer.ConvertToType(objfp, typeof(FlowPath)); * var fp = Newtonsoft.Json.JsonConvert.DeserializeObject<IEnumerable<FlowPath>>(response); * * JsonTextReader reader = new JsonTextReader(); * var fp = (FlowPath)jsonSerializer.DeserializeObject(response); * byte[] data = System.Text.Encoding.Default.GetBytes(JsonString); */ // Download Route Task FlowPath public FlowPath GetFlowPath(string fID, int FlowCode, int State, string strAction) { //http://localhost:56491/api/Task/getFlowPath?fID=A38AFFA3-4F99-447A-93F3-72FE3207DE1A&FlowCode=1001001&State=10&strAction=A string ApiUrl = @"http://*****:*****@"IEC\mdcadmin", "manager"); //var obj = client.DownloadData(ApiUrl); string response = client.DownloadString(ApiUrl); var fp = Newtonsoft.Json.JsonConvert.DeserializeObject(response); FlowPath objfp = (FlowPath)Newtonsoft.Json.JsonConvert.DeserializeObject <FlowPath>(fp.ToString()); return(objfp); }; }
public string SendMail(FlowPath fp, string fID) { string fnSendMail = "RouteWork_SendMail(FlowPath fp, string fID)"; int errorline = 312; int inState = int.Parse(fp.inState.ToString()); //http://iec1-aptest.iec.inventec/CERLLAB/F_CERL/DetailsLAB/ string FormUrl = _cerllabwebsite + @"/F_CERL/EditLAB/"; string Form1Url = _cerllabwebsite + @"/F_CERL/EditLAB/"; string Form2Url = _cerllabwebsite + @"/F_CERL/DetailsLAB/"; string newLine2 = "<br />\r\n"; string newLine = "\r\n"; StringBuilder Body = new StringBuilder(); FormUrl = (fp.outState >= 1000) ? Form2Url : Form1Url; vFCERL fcerl = db.vFCERL.Where(x => x.fID == fID).FirstOrDefault(); string editor = db.userprofile.Where(x => x.BadgeCode == UserId).Select(x => x.ChtName).FirstOrDefault(); string ID = fcerl.ID.ToString(); try { string tableStyle = "table-layout: fixed;width:100%;border:1px solid;"; string thStyle = "color:#ffffff;background:#0078ae;font-weight:bold;width:30%;border:1px solid;"; string tdStyle = "width:70%;border:1px solid;"; Body.Append(Method.BuildXML2(Method.BuildXML2("簽核者", "th", thStyle) + Method.BuildXML2(editor, "td", tdStyle), "tr")); Body.Append(Method.BuildXML2(Method.BuildXML2("UID", "th", thStyle) + Method.BuildXML2(fcerl.UID, "td", tdStyle), "tr")); Body.Append(Method.BuildXML2(Method.BuildXML2("Case ID", "th", thStyle) + Method.BuildXML2(fcerl.CaseID, "td", tdStyle), "tr")); Body.Append(Method.BuildXML2(Method.BuildXML2("申請人", "th", thStyle) + Method.BuildXML2(fcerl.Applicant, "td", tdStyle), "tr")); Body.Append(Method.BuildXML2(Method.BuildXML2("Background Desc.", "th", thStyle) + Method.BuildXML2(fcerl.BackgroundDesc, "td", tdStyle), "tr")); Body.Append(Method.BuildXML2(Method.BuildXML2("Tester", "th", thStyle) + Method.BuildXML2(fcerl.LabMember, "td", tdStyle), "tr")); Body.Append(Method.BuildXML2(Method.BuildXML2("Analysis Result", "th", thStyle) + Method.BuildXML2(fcerl.AnalysisResult, "td", tdStyle), "tr")); Body.Append(Method.BuildXML2(Method.BuildXML2("Comment", "th", thStyle) + Method.BuildXML2(fcerl.Comment, "td", tdStyle), "tr")); Body.Append(Method.BuildXML2(Method.BuildXML2("已完成階段", "th", thStyle) + Method.BuildXML2(fp.inStateName, "td", tdStyle), "tr")); Body.Append(Method.BuildXML2(Method.BuildXML2("下個階段", "th", thStyle) + Method.BuildXML2(fp.outStateName, "td", tdStyle), "tr")); string EmailTitile = ""; string outStateTitle = fp.outStateName; StringBuilder classstyle = new StringBuilder("<style type='text/css'>"); classstyle.Append("table{table-layout: fixed;width:100%;border:1px solid;}"); classstyle.Append("th{color:#ffffff;background:#0078ae;font-weight:bold;width:30%;border:1px solid;}"); classstyle.Append("td{width:70%;border:1px solid;}"); classstyle.Append("</style>"); string tmpBody = "<table style='" + tableStyle + "'>" + Body.ToString() + "</table>"; Body.Clear(); Body.Append(classstyle.ToString()); Body.Append("您有一張 "); Body.Append(outStateTitle); Body.Append(" 的" + fcerl.ParentTestItem + "表單"); Body.Append(tmpBody); Body.Append(newLine2); Body.Append(Method.BuildXML2(Method.BuildXML2("請進入此網址查看<a href='" + FormUrl + ID + "'>CERLLAB</a>", "td"), "tr")); EmailTitile = Constant.MailTest + "[" + fcerl.UID + ", " + fcerl.CaseID + "] CERLLAB " + outStateTitle + " 通知"; var maillist = edb.FnGetMailList(fcerl.ListAssignTo).Select(v => v.Email).ToList(); //var maillist = db.mail_test.Select(v => v.Email).ToList(); errorline = 364; List <string> conItemList = new List <string>(); foreach (var item in maillist) { conItemList.Add(item); } errorline = 370; List <string> CCUserList = new List <string>(); var sfauserList = db.s_form_authority.Where(x => x.fID == fcerl.fID && x.outState == fp.outState); string ccmailcontext = ""; if (sfauserList != null) { if (sfauserList.Count() > 0) { var sfauser = sfauserList.FirstOrDefault(); if (sfauser.MemberCodeList != null) { ccmailcontext = sfauser.MemberCodeList; } } } errorline = 384; if (ccmailcontext != null) { if (ccmailcontext.Trim().Length > 0) { maillist = edb.FnGetMailList2(ccmailcontext).Select(x => x.Email).ToList(); foreach (var item in maillist) { CCUserList.Add(item); } } } errorline = 396; try { errorline = 399; Method.SendMail(conItemList, CCUserList, EmailTitile, Body.ToString()); } catch (Exception ex) { string msg = ex.Message; StringBuilder sb = new StringBuilder(); sb.Append("Issue at line 406: occur error after line " + errorline.ToString() + msg); sb.Append(newLine); sb.Append(fcerl.ID + " " + fcerl.State); syserrdb.InitErrorData(Src: fnSendMail, content: sb.ToString(), editor: UserId); conItemList.Clear(); conItemList.Add(Constant.DefaultMailBcc); CCUserList.Clear(); Body.Append(newLine); Body.Append(ex.Message); Method.SendMail(conItemList, CCUserList, EmailTitile, Body.ToString()); } } catch (Exception ex) { string msg = ex.Message; StringBuilder sb = new StringBuilder(); sb.Append("Issue at line 423: occur error after line " + errorline.ToString() + msg); sb.Append(newLine); sb.Append(fcerl.ID + " " + fcerl.State); syserrdb.InitErrorData(Src: fnSendMail, content: sb.ToString(), editor: UserId); } return(Body.ToString()); }
public f_cerl CheckAndPushTask(FormCollection fc, f_cerl f_cerl) { string fnCheckAndPushTask = "RouteWork_CheckAndPushTask"; string UserId = f_cerl.editor; string strAction = f_cerl.Action; string ListAssignTo = ""; int errorline = 233; try { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); StringBuilder vchSet = new StringBuilder(); errorline = 238; FlowPath fp = GetFlowPath(f_cerl.fID, f_cerl.FlowCode, f_cerl.State, f_cerl.Action); // 取得下一關的State errorline = 240; if (fp == null) { return(f_cerl); } if (f_cerl.State >= 1000) { strAction = ""; return(f_cerl); } errorline = 249; if (fp != null) { if (f_cerl.LocalSupervisor == null) { f_cerl.LocalSupervisor = db.vUsers.Where(u => u.RoleId == 20).Select(v => v.BadgeCode).FirstOrDefault();//"IEC970209"; } errorline = 254; if (f_cerl.Manager == null) { f_cerl.Manager = f_cerl.Applicant; } errorline = 257; vchSet.Append(Method.BuildXML(fp.outState.ToString(), "outState")); vchSet.Append(Method.BuildXML(f_cerl.TestItem.ToString(), "TestItem")); vchSet.Append(Method.BuildXML(f_cerl.Supervisor, "Supervisor")); vchSet.Append(Method.BuildXML(f_cerl.LocalSupervisor, "LocalSupervisor")); vchSet.Append(Method.BuildXML(f_cerl.LabMember, "LabMember")); vchSet.Append(Method.BuildXML(f_cerl.Applicant, "Applicant")); vchSet.Append(Method.BuildXML(f_cerl.Manager, "Manager")); vchSet.Append(Method.BuildXML(f_cerl.Action, "")); errorline = 266; GetListAssignTo(fp.outState, vchSet.ToString(), out ListAssignTo); //取得下一關的收件人 f_cerl.ListAssignTo = ListAssignTo; errorline = 269; if (ListAssignTo != "") { errorline = 272; response = PostFormDataToRoute(fc, f_cerl); //Push Task, Send Task mail by AssignTo f_cerl.State = int.Parse(fp.outState.ToString()); db.Entry(f_cerl).State = EntityState.Modified; db.SaveChanges(); errorline = 278; SendMail(fp, f_cerl.fID); errorline = 280; } errorline = 282; } f_cerl.Comment = ""; } catch (Exception ex) { string msg = ex.Message; string newLine = "\r\n"; StringBuilder sb = new StringBuilder(); sb.Append("Issue at line 291: occur error after line " + errorline.ToString() + msg); sb.Append(newLine); sb.Append(f_cerl.ID + " " + f_cerl.State); syserrdb.InitErrorData(Src: fnCheckAndPushTask, content: sb.ToString(), editor: UserId); } return(f_cerl); }