public string SendCommand(string commandtype, string commandbody, string SK) { string[,] p = new string[2, 2]; p[0, 0] = "commandtype"; p[1, 0] = commandtype; p[0, 1] = "commandbody"; p[1, 1] = commandbody; if (!COS_SECURITY_TOOL.SECURITY_RequestDecrypt(p, SK)) { return(COS_SECURITY_TOOL.SECURITY_ContentEncrypt("-4")); } commandtype = COS_SECURITY_TOOL.SECURITY_ContentDecrypt(commandtype); commandbody = COS_SECURITY_TOOL.SECURITY_ContentDecrypt(commandbody); if (commandtype.ToLower().Trim() == "i") { string[] body = commandbody.Split('|'); string hccu_id = body[1]; string mac = body[2]; string ip = body[3]; string prop = body[4]; EP ep = new EP(); string skraw = "EP_TypeId=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt("1") + "&EP_UserDefined_Alias=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt("Unknown") + "&EP_ProductId=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt("1") + "&HCCU_Id=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt(hccu_id) + "&EP_MAC_Id=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt(mac) + "&PROPFORMAT=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt(prop) + "&IP=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt(ip); string sk = COS_SECURITY_TOOL.SECURITY_RequestEncrypt(skraw); return(ep.EP_Add_20140320(COS_SECURITY_TOOL.SECURITY_ContentEncrypt("1"), COS_SECURITY_TOOL.SECURITY_ContentEncrypt("Unknown"), COS_SECURITY_TOOL.SECURITY_ContentEncrypt("1"), COS_SECURITY_TOOL.SECURITY_ContentEncrypt(hccu_id), COS_SECURITY_TOOL.SECURITY_ContentEncrypt(mac), COS_SECURITY_TOOL.SECURITY_ContentEncrypt(prop), COS_SECURITY_TOOL.SECURITY_ContentEncrypt(ip), sk)); } else if (commandtype.ToLower().Trim() == "d") { string[] body = commandbody.Split('|'); if (body.Length < 5) { return(""); } string hccu_id = body[1]; string mac = body[2]; string d_length = body[3]; if (mac.Length != 16) { return(""); } COS_WEBSERVICE_EP c = new COS_WEBSERVICE_EP(); string epid = Get_EPID_From_MAC(mac); ParseDataCommand(commandbody, epid, d_length, hccu_id); string skraw = "EP_ID=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt(epid); string sk = COS_SECURITY_TOOL.SECURITY_RequestEncrypt(skraw); EXEC_ORDER e = new EXEC_ORDER(); return(e.EXEC_ORDER_Get_WithIP(COS_SECURITY_TOOL.SECURITY_ContentEncrypt(epid), sk)); } else { return(""); } }
public string SendCommand(string commandtype, string commandbody, string SK) { string[,] p = new string[2, 2]; p[0, 0] = "commandtype"; p[1, 0] = commandtype; p[0, 1] = "commandbody"; p[1, 1] = commandbody; if (!COS_SECURITY_TOOL.SECURITY_RequestDecrypt(p, SK)) return COS_SECURITY_TOOL.SECURITY_ContentEncrypt("-4"); commandtype = COS_SECURITY_TOOL.SECURITY_ContentDecrypt(commandtype); commandbody = COS_SECURITY_TOOL.SECURITY_ContentDecrypt(commandbody); if (commandtype.ToLower().Trim() == "i") { string[] body = commandbody.Split('|'); string hccu_id = body[1]; string mac = body[2]; string ip = body[3]; string prop = body[4]; EP ep = new EP(); string skraw = "EP_TypeId=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt("1") + "&EP_UserDefined_Alias=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt("Unknown") + "&EP_ProductId=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt("1") + "&HCCU_Id=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt(hccu_id) + "&EP_MAC_Id=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt(mac) + "&PROPFORMAT=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt(prop) + "&IP=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt(ip); string sk = COS_SECURITY_TOOL.SECURITY_RequestEncrypt(skraw); return ep.EP_Add_20140320(COS_SECURITY_TOOL.SECURITY_ContentEncrypt("1"), COS_SECURITY_TOOL.SECURITY_ContentEncrypt("Unknown"), COS_SECURITY_TOOL.SECURITY_ContentEncrypt("1"), COS_SECURITY_TOOL.SECURITY_ContentEncrypt(hccu_id), COS_SECURITY_TOOL.SECURITY_ContentEncrypt(mac), COS_SECURITY_TOOL.SECURITY_ContentEncrypt(prop), COS_SECURITY_TOOL.SECURITY_ContentEncrypt(ip), sk); } else if (commandtype.ToLower().Trim() == "d") { string[] body = commandbody.Split('|'); if (body.Length < 5) return ""; string hccu_id = body[1]; string mac = body[2]; string d_length = body[3]; if (mac.Length != 16) return ""; COS_WEBSERVICE_EP c = new COS_WEBSERVICE_EP(); string epid = Get_EPID_From_MAC(mac); ParseDataCommand(commandbody, epid, d_length, hccu_id); string skraw = "EP_ID=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt(epid); string sk = COS_SECURITY_TOOL.SECURITY_RequestEncrypt(skraw); EXEC_ORDER e = new EXEC_ORDER(); return e.EXEC_ORDER_Get_WithIP(COS_SECURITY_TOOL.SECURITY_ContentEncrypt(epid), sk); } else { return ""; } }