public ActionResult Register(string phone, string password, string code) { account_member member = entity.account_member.FirstOrDefault(p => p.phone == phone); if (member == null) { SMSTool tool = new SMSTool(); bool codeResult = tool.CheckCode(phone, code); if (codeResult == true) { account_member new_member = new account_member() { enable = true, password = DESTool.Encrypt(password), phone = phone, sys_datetime = DateTime.Now, }; entity.account_member.Add(new_member); if (entity.SaveChanges() > 0) { HttpContext.Session["tpmember"] = new_member; MessageTool.SendMessage(new_member.id, "系统通知", "恭喜您注册成功!"); return(Json(true, JsonRequestBehavior.AllowGet)); } return(Json("用户创建失败", JsonRequestBehavior.AllowGet)); } return(Json("验证码无效")); } return(Json("账号已被注册", JsonRequestBehavior.AllowGet)); }
/// <summary> /// 获取角色信息 /// </summary> public byte[] GetCharacterListInfo(byte[] _data, ClientPeer _client, MainServer _server) { List <CharacterInfo> info = mCharacter.GetCharacterInfoByAccountId(_client.MySQLConn, _client.GetCurAccount.AccountId); if (info.Count > 0) { return(MessageTool.ProtoBufDataSerialize(info)); } else { CharacterInfo infoInit = new CharacterInfo() { AccountId = _client.GetCurAccount.AccountId, CharacterId = 1001, CurExp = 0, CurStrength = 0, Level = 1, Name = "默认名称", Coin = 0 }; info = new List <CharacterInfo>(); info.Add(infoInit); mCharacter.UpdateOrAddCharacter(_client.MySQLConn, infoInit, true); return(MessageTool.ProtoBufDataSerialize(info)); } }
private void RunTimer() { Thread.Sleep(1000); for (int i = 10; i > 0; i--) { BroadcastMessage(null, ActionCode.ShowTimer, MessageTool.ProtoBufDataSerialize(i)); Thread.Sleep(1000); } BroadcastMessage(null, ActionCode.StartPlay, MessageTool.ProtoBufDataSerialize("strat")); }
public byte[] GetInventoryListInfo(byte[] _data, ClientPeer _client, MainServer _server) { List <InventoryInfo> receive = mInv.GetInventoryListInfo(_client.MySQLConn, _client.GetCurAccount.AccountId); if (receive.Count > 0) { return(MessageTool.ProtoBufDataSerialize(receive)); } MSGCallBack send = new MSGCallBack(ReturnCode.Fail); return(MessageTool.ProtoBufDataSerialize(send)); }
public void Send(ActionCode actionCode, byte[] data) { try { byte[] bytes = MessageTool.PackData(actionCode, data); mClientSock.Send(bytes); } catch (Exception e) { Console.WriteLine("无法发送消息:" + e); } }
public ActionResult WxPayNotify() { WxPayData notifyData = GetNotifyData(); //检查支付结果中transaction_id是否存在 if (!notifyData.IsSet("transaction_id")) { //若transaction_id不存在,则立即返回结果给微信支付后台 WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "支付结果中微信订单号不存在"); HttpContext.Response.Write(res.ToXml()); HttpContext.Response.End(); } string transaction_id = notifyData.GetValue("transaction_id").ToString(); //查询订单,判断订单真实性 if (!QueryOrder(transaction_id)) { //若订单查询失败,则立即返回结果给微信支付后台 WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "订单查询失败"); HttpContext.Response.Write(res.ToXml()); HttpContext.Response.End(); } //查询订单成功 else { WxPayData res = new WxPayData(); res.SetValue("return_code", "SUCCESS"); res.SetValue("return_msg", "OK"); HttpContext.Response.Write(res.ToXml()); HttpContext.Response.End(); //本地业务处理 string number = notifyData.GetValue("out_trade_no").ToString(); pay_order order = entity.pay_order.FirstOrDefault(p => p.number == number); module_product product = entity.module_product.FirstOrDefault(p => p.id == order.product_id); if (order.state_pay != true) { order.pay_time = DateTime.Now; order.state_pay = true; int result = entity.SaveChanges(); MessageTool.SendMessage(order.member_id.Value, "购买通知", "您已成功购买【" + product.name + "】!"); //页面同步跳转 //var hub = GlobalHost.ConnectionManager.GetHubContext<WxPayHub>().Clients.Client("12");//此处需要找到一种方法进行一对一通讯,暂时没想到办法 var hub = GlobalHost.ConnectionManager.GetHubContext <WxPayHub>().Clients; hub.All.payResult("success"); } } return(null); }
public byte[] UpdateImgInfo(byte[] _data, ClientPeer _client, MainServer _server) { ImgInfo receive = MessageTool.ProtoBufDataDeSerialize <ImgInfo>(_data); receive = new ImgInfo() { AccountId = _client.GetCurAccount.AccountId, ImgId = receive.ImgId, ImgPath = _client.ImgPathDic[receive.ImgId] }; ImgInfo send = mImgDao.AddOrUpdateImgInfo(_client.MySQLConn, receive, false); return(MessageTool.ProtoBufDataSerialize(send)); }
public byte[] GetRoomList(byte[] _data, ClientPeer _client, MainServer _server) { List <RoomInfo> send = room.GetRoomListInfo(_client.MySQLConn); for (int i = 0; i < send.Count; i++) { _server.RoomList.Add(new RoomManager(_server)); } for (int i = 0; i < _server.RoomList.Count; i++) { _server.RoomList[i].SetRoomData(send[i]); } return(MessageTool.ProtoBufDataSerialize(send)); }
public ClientPeer(Socket _socket, MainServer _server) { mMsg = new MessageTool(); mClientSock = _socket; this.mServer = _server; mMysqlConn = ConnHelper.Connect(); ImgPathDic = new Dictionary <int, string>() { { 1001, "iiefrqwrief" }, { 1002, "iiefrqwrief" }, { 1003, "iiefrqwrief" }, { 1004, "iiefrqwrief" }, }; }
public byte[] GetImgInfo(byte[] _data, ClientPeer _client, MainServer _server) { ImgInfo img = mImgDao.GetImgInfo(_client.MySQLConn, _client.GetCurAccount.AccountId); if (img == null) { img = new ImgInfo() { AccountId = _client.GetCurAccount.AccountId, ImgId = 1001, ImgPath = _client.ImgPathDic[1001] }; mImgDao.AddOrUpdateImgInfo(_client.MySQLConn, img, true); } return(MessageTool.ProtoBufDataSerialize(img)); }
/// <summary> /// 更新人物信息 /// </summary> public byte[] UpdateCharacterListInfo(byte[] _data, ClientPeer _client, MainServer _server) { CharacterInfo receive = MessageTool.ProtoBufDataDeSerialize <CharacterInfo>(_data); CharacterInfo info = mCharacter.UpdateOrAddCharacter(_client.MySQLConn, receive, false); MSGCallBack send = null; if (info != null) { send = new MSGCallBack(ReturnCode.Success); } else { send = new MSGCallBack(ReturnCode.Fail); } return(MessageTool.ProtoBufDataSerialize(send)); }
public ActionResult AliPayNotify() { /* 实际验证过程建议商户添加以下校验。 * 1、商户需要验证该通知数据中的out_trade_no是否为商户系统中创建的订单号, * 2、判断total_amount是否确实为该订单的实际金额(即商户订单创建时的金额), * 3、校验通知中的seller_id(或者seller_email) 是否为out_trade_no这笔单据的对应的操作方(有的时候,一个商户可能有多个seller_id/seller_email) * 4、验证app_id是否为该商户本身。 */ Dictionary <string, string> sArray = GetRequestPost(); //本地业务处理 string number = sArray["out_trade_no"]; pay_order order = entity.pay_order.FirstOrDefault(p => p.number == number); module_product product = entity.module_product.FirstOrDefault(p => p.id == order.product_id); if (order.state_pay != true) { order.pay_time = DateTime.Now; order.state_pay = true; int result = entity.SaveChanges(); MessageTool.SendMessage(order.member_id.Value, "购买通知", "您已成功购买【" + product.name + "】!"); } //本地业务处理 结束 if (sArray.Count != 0) { bool flag = AlipaySignature.RSACheckV1(sArray, Config.alipay_public_key, Config.charset, Config.sign_type, false); if (flag) { //交易状态 //判断该笔订单是否在商户网站中已经做过处理 //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 //请务必判断请求时的total_amount与通知时获取的total_fee为一致的 //如果有做过处理,不执行商户的业务程序 //注意: //退款日期超过可退款期限后(如三个月可退款),支付宝系统发送该交易状态通知 string trade_status = Request.Form["trade_status"]; Response.Write("success"); } else { Response.Write("fail"); } } return(null); }
public byte[] Login(byte[] data, ClientPeer client, MainServer server) { AccountInfo recive = MessageTool.ProtoBufDataDeSerialize <AccountInfo>(data); AccountInfo user = mAccount.VerifyUser(client.MySQLConn, recive.AccountName, recive.Password); MSGCallBack msg; if (user == null) { msg = new MSGCallBack(ReturnCode.Fail); } else { client.IsOnLine = true; client.SetCurAccountData(user); msg = new MSGCallBack(ReturnCode.Success); } return(MessageTool.ProtoBufDataSerialize(msg)); }
public byte[] Register(byte[] data, ClientPeer client, MainServer server) { AccountInfo recive = MessageTool.ProtoBufDataDeSerialize <AccountInfo>(data); bool res = mAccount.GetAccountByAccountId(client.MySQLConn, recive.AccountId); MSGCallBack msg; if (res) { msg = new MSGCallBack(ReturnCode.Fail); } else { mAccount.AddAccount(client.MySQLConn, recive.AccountId, recive.AccountName, recive.Password, 1001, client.ImgPathDic[1001]); client.IsOnLine = true; msg = new MSGCallBack(ReturnCode.Success); } return(MessageTool.ProtoBufDataSerialize(msg)); }
/// <summary> /// 匹配 /// </summary> public byte[] SatrtMatchingPlayer(byte[] _data, ClientPeer _client, MainServer _server) { _client.IsMatching = true; List <ClientPeer> matchList = new List <ClientPeer>(); do { foreach (var account in _server.OnLineAccountList) { if (account.IsMatching) { matchList.Add(account); } } } while (matchList.Count < 3); if (matchList.Count >= 3) { room = _server.CreatRoom(matchList); } return(MessageTool.ProtoBufDataSerialize("goLobby")); }
public byte[] JoinRoom(byte[] _data, ClientPeer _client, MainServer _server) { RoomInfo roomInfo = MessageTool.ProtoBufDataDeSerialize <RoomInfo>(_data); MSGCallBack sendMsg = null; foreach (var room in _server.RoomList) { if (roomInfo.RoomId == room.GetRoonInfo.RoomId) { if (room.GetRoonInfo.TotalNum >= room.GetRoonInfo.PlayerNum) { _server.JoinRoom(_client, room); sendMsg = new MSGCallBack(ReturnCode.Success); } else { sendMsg = new MSGCallBack(ReturnCode.Fail); } } } return(MessageTool.ProtoBufDataSerialize(sendMsg)); }
public void Start(Action <SM> send) { try { tcpListener.Start(); while (start) { TcpClient tcpClient = tcpListener.AcceptTcpClient(); MessageTool tool = new MessageTool(tcpClient); ReceiveMessage += tool.Send; tool.End((s) => { ReceiveMessage += tool.Send; }); tool.Receive += send; } } catch (Exception ex) { MessageBox.Show(ex.Message); Application.Exit(); } }
public byte[] UpdateInventoryListInfo(byte[] _data, ClientPeer _client, MainServer _server) { List <InventoryInfo> inv = MessageTool.ProtoBufDataDeSerialize <List <InventoryInfo> >(_data); MSGCallBack send = null; if (!isAdded) { for (int i = 0; i < inv.Count; i++) { mInv.AddOrUpdateInventoryInfo(_client.MySQLConn, inv[i], true); } isAdded = true; send = new MSGCallBack(ReturnCode.Success); } else { for (int i = 0; i < inv.Count; i++) { mInv.AddOrUpdateInventoryInfo(_client.MySQLConn, inv[i], false); } send = new MSGCallBack(ReturnCode.Success); } return(MessageTool.ProtoBufDataSerialize(send)); }
private void AcceptCallBack(IAsyncResult ar) { if (ar.AsyncWaitHandle.WaitOne(5000)) { if (IsRunning) { Socket server = (Socket)ar.AsyncState; Socket clientSocket = server.EndAccept(ar); if (mClientCount <= mMaxClient) { client = new ClientPeer(clientSocket, this); lock (mClientList) { mClientList.Add(client); mClientCount++; Console.WriteLine("一个客户端连接进来了"); mMsg = new MessageTool(client, this); } client.RecvDataBuffer = new byte[mMsg.DataBytesMaxLength]; //开始接受来自该客户端的数据 clientSocket.BeginReceive(client.RecvDataBuffer, 0, client.RecvDataBuffer.Length, SocketFlags.None, new AsyncCallback(HandleDataReceived), client); mServerSock.BeginAccept(new AsyncCallback(AcceptCallBack), mServerSock); } else { Console.WriteLine("服务器爆满"); } } } else { Console.WriteLine("超时"); } }
public void Start() { tcp.Connect(ConfigurationManager.AppSettings["address"], int.Parse(ConfigurationManager.AppSettings["port"])); mt = new MessageTool(tcp); mt.Receive += Receive; }
private static int LogStep(ref Step[,] canvasMatrix, Step step, int curRow, int threadCol, int indentLevel, out string log, out string functions) { int nextRow = curRow; log = ""; functions = ""; string indentString = new string(' ', indentLevel * 4); if (step.Description.Length > 0) { log = "\r\n\r\n" + indentString + "/*" + step.Description + "*/";// + ((log.Length > 0) ? ("\r\n" + log) : ("")); } else { log = "";//"\r\n";// +log; } switch (step.ToolName) { case "NullTool": { log = ""; return(nextRow); } case "NoOpTool": { if (step.Enabled == false) { log += "\r\n" + indentString + "// " + "/*" + step.StepName.Replace("_x0020_", "_") + "*/"; } else { log += "\r\n" + indentString + "/*NOP: " + step.StepName.Replace("_x0020_", "_") + "*/"; } return(nextRow); } case "CaseTool": { int width = step.StepWidth; int height = step.StepHeight; log += "\r\n" + indentString + "/*" + step.ToolName + ": " + step.StepName + "*/"; string caselog; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); Step[,] caseMatrix = MatrixTransformations.ResizeArray <Step>(ref canvasMatrix, curRow, threadCol, Math.Min(curRow + height - 1, canvasMatrix.GetLength(0) - 1), canvasMatrix.GetLength(1) - 1); CaseTool.CaseToTxt(ref caseMatrix, 0, indentLevel + ((eh.Length > 0) ? 1 : 0), height, width, out caselog, out functions); nextRow = curRow + height; if (step.Enabled == false) { log += "\r\n" + indentString + "// " + caselog.Replace("\r\n", "\r\n// "); } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + caselog; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + caselog; } } return(nextRow); } case "VariableTool": { string varlog, varfunction; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); VariableTool.SetVariableToTxt(step, indentLevel + ((eh.Length > 0) ? 1 : 0), out varlog, out varfunction); if (step.Enabled == false) { log += "\r\n" + indentString + "//" + varlog; } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + varlog; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + varlog; } } if (varfunction.Length > 0) { if (step.Enabled == false) { functions += "\r\n" + "// " + varfunction.Replace("\r\n", "\r\n// "); } else { functions += "\r\n" + varfunction; } } return(nextRow); } case "PaWTestTool": case "MethodTool": case "TestTool": case "Mouse": case "Keyboard": case "Inspect": { string testlog, dummy; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); TestTool.TestToTxt(step.StepXmlNode, indentLevel + ((eh.Length > 0) ? 1 : 0), out testlog, out dummy); if (step.ToolName == "TestTool" || step.ToolName == "PaWTestTool") { XmlNode path = step.StepXmlNode.SelectSingleNode(".//*[@Key='ResourceFullName']"); if (path != null) { string p; if (path.Attributes["Value"] != null) { p = path.Attributes["Value"].Value; } else { p = path.SelectSingleNode(".//*[@Key='Value']/@Value").Value; } log += "\r\n" + indentString + "/*" + "Path: " + p.Replace(".tsdrv", "") + " */"; } } if (step.Enabled == false) { log += "\r\n" + indentString + "//" + step.StepName.Replace("_x0020_", "_") + testlog; } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + step.StepName.Replace("_x0020_", "_") + testlog; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + step.StepName.Replace("_x0020_", "_") + testlog; } } return(nextRow); } case "AttributeTool": { string alog, dummy; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); AttributeTool.AttributeToTxt(step.StepXmlNode, indentLevel + ((eh.Length > 0) ? 1 : 0), out alog, out dummy); if (step.Enabled == false) { log += "\r\n" + indentString + "//" + step.StepName.Replace("_x0020_", "_") + alog; } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + step.StepName.Replace("_x0020_", "_") + alog; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + step.StepName.Replace("_x0020_", "_") + alog; } } return(nextRow); } case "CaptureImageTool": { string cilog, dummy; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); CaptureImageTool.CaptureImageToTxt(step.StepXmlNode, indentLevel + ((eh.Length > 0) ? 1 : 0), out cilog, out dummy); if (step.Enabled == false) { log += "\r\n" + indentString + "//" + step.StepName.Replace("_x0020_", "_") + cilog; } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + step.StepName.Replace("_x0020_", "_") + cilog; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + step.StepName.Replace("_x0020_", "_") + cilog; } } return(nextRow); } case "CriteriaTool": { string clog, cfunction; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); CriteriaTool.CriteriaToTxt(step, indentLevel + ((eh.Length > 0) ? 1 : 0), out clog, out cfunction); if (step.Enabled == false) { log += "\r\n" + indentString + "//" + step.StepName.Replace("_x0020_", "_") + clog; } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + step.StepName.Replace("_x0020_", "_") + clog; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + step.StepName.Replace("_x0020_", "_") + clog; } } if (cfunction.Length > 0) { if (step.Enabled == false) { functions += "\r\n" + "// " + cfunction.Replace("\r\n", "\r\n// "); } else { functions += "\r\n" + cfunction; } } return(nextRow); } case "ScripterTool": case "PaWScripterTool": { string slog, dummy; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); ScripterTool.ScripterToTxt(step.StepXmlNode, indentLevel + ((eh.Length > 0) ? 1 : 0), out slog, out dummy); XmlNode path = step.StepXmlNode.SelectSingleNode(".//*[@Key='ResourceFullName']"); if (path != null) { string p; if (path.Attributes["Value"] != null) { p = path.Attributes["Value"].Value; } else { p = path.SelectSingleNode(".//*[@Key='Value']/@Value").Value; } log += "\r\n" + indentString + "/* " + "Path: " + p.Replace(".tsscript", "") + " */"; } if (step.Enabled == false) { log += "\r\n" + indentString + "//" + step.StepName.Replace("_x0020_", "_") + slog; } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + step.StepName.Replace("_x0020_", "_") + slog; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + step.StepName.Replace("_x0020_", "_") + slog; } } return(nextRow); } case "CommandTool": { string clog, cfunction; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); CommandTool.CommandToTxt(step, indentLevel + ((eh.Length > 0) ? 1 : 0), out clog, out cfunction); if (step.Enabled == false) { log += "\r\n" + indentString + "//" + step.StepName.Replace("_x0020_", "_") + clog; } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + step.StepName.Replace("_x0020_", "_") + clog; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + step.StepName.Replace("_x0020_", "_") + clog; } } if (cfunction.Length > 0) { if (step.Enabled == false) { functions += "\r\n" + "// " + cfunction.Replace("\r\n", "\r\n// "); } else { functions += "\r\n" + cfunction; } } return(nextRow); } case "TerminalCommandTool": { string clog, cfunction; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); TerminalCommandTool.CommandToTxt(step, indentLevel + ((eh.Length > 0) ? 1 : 0), out clog, out cfunction); if (step.Enabled == false) { log += "\r\n" + indentString + "//" + step.StepName.Replace("_x0020_", "_") + clog; } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + step.StepName.Replace("_x0020_", "_") + clog; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + step.StepName.Replace("_x0020_", "_") + clog; } } if (cfunction.Length > 0) { if (step.Enabled == false) { functions += "\r\n" + "// " + cfunction.Replace("\r\n", "\r\n// "); } else { functions += "\r\n" + cfunction; } } return(nextRow); } case "WriteTool": { string clog, cfunction; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); WriteTool.WriteToTxt(step, indentLevel + ((eh.Length > 0) ? 1 : 0), out clog, out cfunction); if (step.Enabled == false) { log += "\r\n" + indentString + "//" + step.StepName.Replace("_x0020_", "_") + clog; } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + step.StepName.Replace("_x0020_", "_") + clog; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + step.StepName.Replace("_x0020_", "_") + clog; } } if (cfunction.Length > 0) { if (step.Enabled == false) { functions += "\r\n" + "// " + cfunction.Replace("\r\n", "\r\n// "); } else { functions += "\r\n" + cfunction; } } return(nextRow); } case "ReadTool": { string clog, cfunction; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); ReadTool.ReadToTxt(step, indentLevel + ((eh.Length > 0) ? 1 : 0), out clog, out cfunction); if (step.Enabled == false) { log += "\r\n" + indentString + "//" + step.StepName.Replace("_x0020_", "_") + clog; } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + step.StepName.Replace("_x0020_", "_") + clog; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + step.StepName.Replace("_x0020_", "_") + clog; } } if (cfunction.Length > 0) { if (step.Enabled == false) { functions += "\r\n" + "// " + cfunction.Replace("\r\n", "\r\n// "); } else { functions += "\r\n" + cfunction; } } return(nextRow); } case "MessageTool": { string clog, cfunction; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); MessageTool.MessageToTxt(step, indentLevel + ((eh.Length > 0) ? 1 : 0), out clog, out cfunction); if (step.Enabled == false) { log += "\r\n" + indentString + "//" + step.StepName.Replace("_x0020_", "_") + clog; } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + step.StepName.Replace("_x0020_", "_") + clog; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + step.StepName.Replace("_x0020_", "_") + clog; } } if (cfunction.Length > 0) { if (step.Enabled == false) { functions += "\r\n" + "// " + cfunction.Replace("\r\n", "\r\n// "); } else { functions += "\r\n" + cfunction; } } return(nextRow); } case "TransformationTool": { string tlog, tfunctions; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); TransformTool.TransformToTxt(step, indentLevel + ((eh.Length > 0) ? 1 : 0), out tlog, out tfunctions); if (step.Enabled == false) { log += "\r\n" + indentString + "//" + step.StepName.Replace("_x0020_", "_") + tlog; } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + step.StepName.Replace("_x0020_", "_") + tlog; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + step.StepName.Replace("_x0020_", "_") + tlog; } } if (tfunctions.Length > 0) { if (step.Enabled == false) { functions += "\r\n" + "// " + tfunctions.Replace("\r\n", "\r\n// "); } else { functions += "\r\n" + tfunctions; } } return(nextRow); } case "SetSessionTool": { string sessionlog, dummy; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); SetSessionTool.SessionToTxt(step, indentLevel + ((eh.Length > 0) ? 1 : 0), out sessionlog, out dummy); log += "\r\n" + indentString + "/*" + step.ToolName + ": " + step.StepName + "*/"; if (step.Enabled == false) { log += "\r\n" + indentString + "//" + step.StepName.Replace("_x0020_", "_") + sessionlog; } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + step.StepName.Replace("_x0020_", "_") + sessionlog; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + step.StepName.Replace("_x0020_", "_") + sessionlog; } } return(nextRow); } case "DelayTool": { string dlog, dummy; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); DelayTool.DelayToTxt(step, indentLevel + ((eh.Length > 0) ? 1 : 0), out dlog, out dummy); if (step.Enabled == false) { log += "\r\n" + indentString + "//" + step.StepName.Replace("_x0020_", "_") + dlog; } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + step.StepName.Replace("_x0020_", "_") + dlog; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + step.StepName.Replace("_x0020_", "_") + dlog; } } return(nextRow); } case "SetEventTool": { string dlog, dummy; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); SetEventTool.SetEventToTxt(step, indentLevel + ((eh.Length > 0) ? 1 : 0), out dlog, out dummy); if (step.Enabled == false) { log += "\r\n" + indentString + "//" + step.StepName.Replace("_x0020_", "_") + dlog; } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + step.StepName.Replace("_x0020_", "_") + dlog; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + step.StepName.Replace("_x0020_", "_") + dlog; } } return(nextRow); } case "WaitForEventTool": { string dlog, dummy; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); WaitForEventTool.WaitForEventToTxt(step, indentLevel + ((eh.Length > 0) ? 1 : 0), out dlog, out dummy); if (step.Enabled == false) { log += "\r\n" + indentString + "//" + step.StepName.Replace("_x0020_", "_") + dlog; } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + step.StepName.Replace("_x0020_", "_") + dlog; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + step.StepName.Replace("_x0020_", "_") + dlog; } } return(nextRow); } case "PassFailTool": { string dlog, dfunc; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); PassFailTool.PassFailToTxt(step, indentLevel + ((eh.Length > 0) ? 1 : 0), out dlog, out dfunc); string tooltype = step.StepXmlNode.SelectSingleNode(".//*[@Key='NotificationType']/@Value").Value; string toolname = "PassFailTool"; switch (tooltype) { case "0": toolname = "Pass"; break; case "1": toolname = "Fail"; break; case "2": toolname = "Text To Report"; break; default: break; } log += "\r\n" + indentString + "/*" + toolname + ": " + step.StepName + "*/"; if (step.Enabled == false) { log += "\r\n" + indentString + "//" + step.StepName.Replace("_x0020_", "_") + dlog; } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + step.StepName.Replace("_x0020_", "_") + dlog; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + step.StepName.Replace("_x0020_", "_") + dlog; } } if (dfunc.Length > 0) { if (step.Enabled == false) { functions += "\r\n" + "// " + dfunc.Replace("\r\n", "\r\n// "); } else { functions += "\r\n" + dfunc; } } return(nextRow); } case "ErrorTool": { string dlog, dummy; ErrorTool.ErrorToTxt(step, indentLevel, out dlog, out dummy); log += "\r\n" + indentString + "/*" + step.ToolName + ": " + step.StepName + "*/"; if (step.Enabled == false) { log += "\r\n" + indentString + "// throw" + step.StepName.Replace("_x0020_", "_") + dlog; } else { log += "\r\n" + indentString + "throw " + step.StepName.Replace("_x0020_", "_") + dlog; } return(nextRow); } case "EndSessionTool": { string dlog, dummy; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); EndSessionTool.EndSessionToTxt(step, indentLevel + ((eh.Length > 0) ? 1 : 0), out dlog, out dummy); log += "\r\n" + indentString + "/*" + step.ToolName + ": " + step.StepName + "*/"; if (step.Enabled == false) { log += "\r\n" + indentString + "//" + step.StepName.Replace("_x0020_", "_") + dlog; } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + step.StepName.Replace("_x0020_", "_") + dlog; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + step.StepName.Replace("_x0020_", "_") + dlog; } } return(nextRow); } case "EndTool": { string dlog, dummy; EndTool.EndToTxt(step, indentLevel, out dlog, out dummy); log += "\r\n" + indentString + "/*" + step.ToolName + ": " + step.StepName + "*/"; if (step.Enabled == false) { log += "\r\n" + indentString + "//" + step.StepName.Replace("_x0020_", "_") + dlog; } else { log += "\r\n" + indentString + step.StepName.Replace("_x0020_", "_") + dlog; } return(nextRow); } case "CodeTool": { string dummy, codefunction; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); CodeTool.CodeToTxt(step, indentLevel + ((eh.Length > 0)?1:0), out dummy, out codefunction); if (step.Enabled == false) { log += "\r\n" + indentString + "//" + step.StepName.Replace("_x0020_", "_") + "()"; } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + step.StepName.Replace("_x0020_", "_") + "()"; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + step.StepName.Replace("_x0020_", "_") + "()"; } } if (codefunction.Length > 0) { if (step.Enabled == false) { functions += "\r\n" + "// " + codefunction.Replace("\r\n", "\r\n// "); } else { functions += "\r\n" + codefunction; } } return(nextRow); } case "LoopTool": case "ParaLoopTool": { int width = step.StepWidth; int height = step.StepHeight; log += "\r\n" + indentString + "/*" + step.ToolName + ": " + step.StepName + "*/"; string looplog, loopfunctions; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); Step[,] loopMatrix = MatrixTransformations.ResizeArray <Step>(ref canvasMatrix, curRow, threadCol, Math.Min(curRow + height - 1, canvasMatrix.GetLength(0) - 1), canvasMatrix.GetLength(1) - 1); LoopTool.LoopToTxt(ref loopMatrix, 0, indentLevel + ((eh.Length > 0) ? 1 : 0), height, width, out looplog, out loopfunctions); nextRow = curRow + height; if (step.Enabled == false) { log += "\r\n" + indentString + "// " + looplog.Replace("\r\n", "\r\n// "); } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + looplog; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + looplog; } } if (loopfunctions.Length > 0) { if (step.Enabled == false) { functions += "\r\n" + "// " + loopfunctions.Replace("\r\n", "\r\n// "); } else { functions += "\r\n" + loopfunctions; } } return(nextRow); } case "WhileTool": { int width = step.StepWidth; int height = step.StepHeight; log += "\r\n" + indentString + "/*" + step.ToolName + ": " + step.StepName + "*/"; string wlog, wfunctions; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); Step[,] whileMatrix = MatrixTransformations.ResizeArray <Step>(ref canvasMatrix, curRow, threadCol, Math.Min(curRow + height - 1, canvasMatrix.GetLength(0) - 1), canvasMatrix.GetLength(1) - 1); WhileTool.WhileToTxt(ref whileMatrix, 0, indentLevel + ((eh.Length > 0) ? 1 : 0), height, width, out wlog, out wfunctions); nextRow = curRow + height; if (step.Enabled == false) { log += "\r\n" + indentString + "// " + wlog.Replace("\r\n", "\r\n// "); } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + wlog; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + wlog; } } if (wfunctions.Length > 0) { if (step.Enabled == false) { functions += "\r\n" + "// " + wfunctions.Replace("\r\n", "\r\n// "); } else { functions += "\r\n" + wfunctions; } } return(nextRow); } case "LockTool": { int width = step.StepWidth; int height = step.StepHeight; log += "\r\n" + indentString + "/*" + step.ToolName + ": " + step.StepName + "*/"; string llog, lfunctions; string eh = ErrorHandlingToTxt.Parse(step.StepXmlNode, indentLevel); Step[,] lockMatrix = MatrixTransformations.ResizeArray <Step>(ref canvasMatrix, curRow, threadCol, Math.Min(curRow + height - 1, canvasMatrix.GetLength(0) - 1), canvasMatrix.GetLength(1) - 1); LockTool.LockToTxt(ref lockMatrix, 0, indentLevel + ((eh.Length > 0) ? 1 : 0), height, width, out llog, out lfunctions); nextRow = curRow + height; if (step.Enabled == false) { log += "\r\n" + indentString + "// " + llog.Replace("\r\n", "\r\n// "); } else { if (eh.Length > 0) { log += "\r\n" + indentString + "try" + "\r\n" + indentString + "{"; log += "\r\n" + indentString + " " + llog; log += "\r\n" + indentString + "}" + "\r\n" + eh; } else { log += "\r\n" + indentString + llog; } } if (lfunctions.Length > 0) { if (step.Enabled == false) { functions += "\r\n" + "// " + lfunctions.Replace("\r\n", "\r\n// "); } else { functions += "\r\n" + lfunctions; } } return(nextRow); } case "ParallelTool": { int width = step.StepWidth; int height = step.StepHeight; log += "\r\n" + indentString + "/*" + step.ToolName + ": " + step.StepName + "*/"; string plog, pfunctions; Step[,] pMatrix = MatrixTransformations.ResizeArray <Step>(ref canvasMatrix, curRow, 0, Math.Min(curRow + height - 1, canvasMatrix.GetLength(0) - 1), canvasMatrix.GetLength(1) - 1); ParallelTool.ParallelToTxt(ref pMatrix, threadCol, indentLevel, height, width, out plog, out pfunctions); nextRow = curRow + height; if (step.Enabled == false) { log += "\r\n" + indentString + "// " + plog.Replace("\r\n", "\r\n// "); } else { log += "\r\n" + indentString + plog; } if (pfunctions.Length > 0) { if (step.Enabled == false) { functions += "\r\n" + "// " + pfunctions.Replace("\r\n", "\r\n// "); } else { functions += "\r\n" + pfunctions; } } return(nextRow); } case "GroupTool": case "PaWDllTool": case "DllTool": case "CommandShellTool": case "SequenceTool": case "TerminalTool": case "WebServiceTool": case "NetworkClientTool": { string glog, gfunctions; if (step.ToolName == "DllTool" || step.ToolName == "PaWDllTool" || step.ToolName == "WebServiceTool") { XmlNode path = step.StepXmlNode.SelectSingleNode(".//*[@Key='ResourceFullName']"); if (path != null) { string p; if (path.Attributes["Value"] != null) { p = path.Attributes["Value"].Value; } else { p = path.SelectSingleNode(".//*[@Key='Value']/@Value").Value; } log += "\r\n" + indentString + "/*" + "Path: " + p.Replace(".tsdll", "") + " */"; } log += "\r\n" + indentString + "/*" + step.ToolName + ": " + step.StepName + "*/"; } else if (step.ToolName == "SequenceTool") { XmlNode path = step.StepXmlNode.SelectSingleNode(".//*[@Key='LibraryFullName']"); if (path != null) { string p; if (path.Attributes["Value"] != null) { p = path.Attributes["Value"].Value; } else { p = path.SelectSingleNode(".//*[@Key='Value']/@Value").Value; } log += "\r\n" + indentString + "/*" + "Path: " + p.Replace(".tslib", "") + " */"; } log += "\r\n" + indentString + "/*" + step.ToolName + ": " + step.StepName + "*/"; } else { log += "\r\n" + indentString + "/*" + step.ToolName + ": " + step.StepName + "*/"; } XmlNode groupSteps = step.StepXmlNode.SelectSingleNode(".//List[@Key='Steps']"); XmlNode eh = step.StepXmlNode.SelectSingleNode(".//ErrorHandlingBehavior"); CanvasAnalyzer.StepsListToTxt(groupSteps.ChildNodes, true, indentLevel, eh, out glog, out gfunctions); if (step.Enabled == false) { log += "\r\n" + indentString + "// " + glog.Replace("\r\n", "\r\n// "); } else { log += "\r\n" + indentString + glog; } if (gfunctions.Length > 0) { if (step.Enabled == false) { functions += "\r\n" + "// " + gfunctions.Replace("\r\n", "\r\n// "); } else { functions += "\r\n" + gfunctions; } } return(nextRow); } case "AnalyzableCompositeTool": { string aclog, acfunctions; XmlNodeList acTools = step.StepXmlNode.SelectNodes(".//Array[@Key='ChildTools']/*"); foreach (XmlNode tool in acTools) { Step curstep = new Step(tool); curstep.Enabled = step.Enabled; LogStep(ref canvasMatrix, curstep, curRow, threadCol, indentLevel, out aclog, out acfunctions); if (step.Enabled == false) { log += "\r\n" + indentString + "// " + aclog.Replace("\r\n", "\r\n// "); } else { log += "\r\n" + indentString + aclog; } if (acfunctions.Length > 0) { if (step.Enabled == false) { functions += "\r\n" + "// " + acfunctions.Replace("\r\n", "\r\n// "); } else { functions += "\r\n" + acfunctions; } } } return(nextRow + acTools.Count - 1); } } if (step.Enabled == false) { log += "\r\n" + indentString + "//"; } else { log += "\r\n" + indentString; } log += step.StepName.Replace("_x0020_", "_") + " // (" + step.ToolName + ")"; return(nextRow); }
// Use this for initialization void Start() { instance = this; nameText1.text = Config.getInstance().name; }