1192 lines
38 KiB
C#
1192 lines
38 KiB
C#
/*
|
|
* Created by SharpDevelop.
|
|
* User: dmacinto
|
|
* Date: 10/05/11
|
|
* Time: 3:04 PM
|
|
*
|
|
* To change this template use Tools | Options | Coding | Edit Standard Headers.
|
|
*/
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Net;
|
|
using System.IO;
|
|
using System.Text;
|
|
using Newtonsoft.Json.Linq;
|
|
using System.Text.RegularExpressions;
|
|
|
|
using System.Runtime.Serialization.Formatters.Binary;
|
|
|
|
using System.Configuration;
|
|
using System.Security.Cryptography.X509Certificates;
|
|
using System.Net.Security;
|
|
|
|
using cdrtool;
|
|
using System.Net.NetworkInformation;
|
|
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace cdrtool
|
|
{
|
|
/// <summary>
|
|
/// Darwin specific handling of Login/Logout, Get users, Get PDF etc.
|
|
/// </summary>
|
|
public class WebRoutines
|
|
{
|
|
public WebRoutines()
|
|
{
|
|
}
|
|
|
|
public static bool Login(string user, string pswd, ref string token, ref CookieContainer cookiejar, WebProxy proxy)
|
|
{
|
|
byte[] webResp = null;
|
|
|
|
//LOGIN : https://portal.sip.rogers.com/en -> https://portal.sip.rogers.com/api/auth/login
|
|
|
|
bool success = Web.MakeRequest(
|
|
"GET",
|
|
"http://portal.sip.rogers.com/en",
|
|
true,
|
|
ref token,
|
|
ref webResp,
|
|
ref cookiejar) ;
|
|
|
|
if (!success)
|
|
{
|
|
Logger.Log(5, "Login0 FAIL{0}:{1}:{2}", Encoding.ASCII.GetString(webResp));
|
|
}
|
|
else
|
|
{
|
|
Logger.Log(3, "Success initial login page.");
|
|
|
|
webResp = null;
|
|
|
|
try
|
|
{
|
|
//Logger.Log(6, "{\"username\":\"" + cdrtool.username + "\",\"password\":\"" + cdrtool.password + "\",\"accountGuid\":null,\"rememberMe\":false}");
|
|
success = Web.MakeRequest(
|
|
"POST",
|
|
"https://portal.sip.rogers.com/api/auth/login",
|
|
//String.Format("{\"username\":\"{0}\",\"password\":\"{1}\",\"accountGuid\":null,\"rememberMe\":false}",user,pswd),
|
|
"{\"username\":\"" + cdrtool.username + "\",\"password\":\"" + cdrtool.password + "\",\"accountGuid\":null,\"rememberMe\":false}",
|
|
true,
|
|
ref webResp,
|
|
ref cookiejar);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Logger.Log(1, "Web Authentication Error {0}", e.Message);
|
|
}
|
|
|
|
//MFA - delay is handled in Gmail.GetMail routine using cdrtool.mfa_delay in seconds.
|
|
try
|
|
{
|
|
Task<string> task = Gmail.GetMail();
|
|
cdrtool.mfa = task.Result;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.WriteLine("Gmail fault {0}", e.Message);
|
|
}
|
|
|
|
|
|
if (cdrtool.mfa == "")
|
|
{
|
|
success = false;
|
|
Logger.Log(0, "No valid MFA code received in allotted time.");
|
|
}
|
|
else
|
|
{
|
|
Logger.Log(5, "Login Stage 2, using code={0}", cdrtool.mfa);
|
|
|
|
try
|
|
{
|
|
success = Web.MakeRequest(
|
|
"POST",
|
|
"https://portal.sip.rogers.com/api/auth/login",
|
|
//String.Format("{\"username\":\"{0}\",\"password\":\"{1}\",\"accountGuid\":null,\"rememberMe\":false}",user,pswd),
|
|
"{\"username\":\"" + cdrtool.username + "\",\"password\":\"" + cdrtool.password + "\",\"code\":\"" + cdrtool.mfa + "\",\"rememberMe\":false}",
|
|
true,
|
|
ref webResp,
|
|
ref cookiejar);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Logger.Log(5, "Stage2 fault {0}", e.Message);
|
|
}
|
|
|
|
}
|
|
//-MFA
|
|
|
|
if (success)
|
|
{
|
|
//Console.WriteLine("{0}", Encoding.ASCII.GetString(webResp) );
|
|
|
|
dynamic jResp = JObject.Parse(Encoding.ASCII.GetString(webResp));
|
|
token = jResp.account.user.token;
|
|
Logger.Log(5, "Token=[{0}]", token);
|
|
Logger.Log(0, "{0} is logged in for {1}", jResp.account.displayName, jResp.account.company.name);
|
|
cdrtool.company = jResp.account.company.name;
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
Logger.Log(5, "Login FAIL{0}:{1}:{2}", Encoding.ASCII.GetString(webResp));
|
|
}
|
|
}
|
|
|
|
return success;
|
|
}
|
|
|
|
|
|
public static bool GetGUIDs(string token, ref string wfr_guid, ref string ch_guid, ref string act_guid, ref string co_guid, ref string did_guid,
|
|
ref string year, ref string mtd, ref CookieContainer cookiejar, WebProxy proxyObject)
|
|
{
|
|
byte[] webResp = null;
|
|
bool isJSON = true;
|
|
|
|
bool success = Web.MakeRequest(
|
|
"GET",
|
|
"https://portal.sip.rogers.com/api/accounts/user-accounts",
|
|
isJSON,
|
|
ref token,
|
|
ref webResp,
|
|
ref cookiejar);
|
|
|
|
if (success)
|
|
{
|
|
Logger.Log(3, "Success: user-accounts");
|
|
}
|
|
else
|
|
{
|
|
Logger.Log(5, "USERACCT FAIL{0}:{1}:{2}", Encoding.ASCII.GetString(webResp));
|
|
}
|
|
|
|
|
|
// /api/workflows/landing-page-entries
|
|
|
|
if (success)
|
|
{
|
|
webResp = null;
|
|
success = Web.MakeRequest(
|
|
"GET",
|
|
"https://portal.sip.rogers.com/api/workflows/landing-page-entries",
|
|
isJSON,
|
|
ref token,
|
|
ref webResp,
|
|
ref cookiejar);
|
|
|
|
if (success)
|
|
{
|
|
//wfr_guid = getWFRguid(response4[1].ToString());
|
|
/* [[{"label":"APP.CALL_REPORTING.LABEL","description":"APP.GETTING_STARTED.REPORTING.DESCRIPTION","entries":[{"label":"APP.GETTING_STARTED.SERVICE_GRAPH.LABEL","description":"APP.GETTING_STARTED.SERVICE_GRAPH.DESCRIPTION","image":null,"icon":"insights","workflow":{"sharing":{},"guid":"89644421-7163-46b5-8757-e627a58a5eac","workflowRoutes":[{"guid":"63180702-08db-4bef-b3d6-865bfe497fe3"}]}},{"label":"APP.GETTING_STARTED.CALL_HISTORY.LABEL","description":"APP.GETTING_STARTED.CALL_HISTORY.DESCRIPTION","image":null,"icon":"download_for_offline","workflow":{"sharing":{},"guid":"4328117a-297e-4df2-ba5d-178daa793a16","workflowRoutes":[{"guid":"318024c2-bd1f-4d4e-9e00-7039e0c04998"}]}},{"label":"APP.GETTING_STARTED.VIEW_PEER_INVENTORY.LABEL","description":"APP.GETTING_STARTED.VIEW_PEER_INVENTORY.DESCRIPTION","image":"","icon":"summarize","workflow":{"sharing":{},"guid":"ae6cc939-f4ba-4287-80b9-d45567609f00","workflowRoutes":[{"guid":"0a8a8a1e-1eb2-4104-a3a9-80307864eb16"}]}}]}]] */
|
|
|
|
dynamic jResp = JArray.Parse(Encoding.ASCII.GetString(webResp));
|
|
foreach (dynamic jEntry in jResp[0].entries)
|
|
{
|
|
// APP.GETTING_STARTED.CALL_HISTORY.LABEL
|
|
// Console.WriteLine("{0}",jEntry.label);
|
|
if (jEntry.label == "APP.GETTING_STARTED.CALL_HISTORY.LABEL")
|
|
{
|
|
wfr_guid = jEntry.workflow.workflowRoutes[0].guid;
|
|
Logger.Log(5, " wfr_guid=[{0}]", wfr_guid);
|
|
|
|
}
|
|
}
|
|
|
|
Logger.Log(3, "Success wrf_guid");
|
|
}
|
|
else
|
|
{
|
|
Logger.Log(5, "WFRGUID FAIL{0}:{1}:{2}", Encoding.ASCII.GetString(webResp));
|
|
}
|
|
|
|
}
|
|
|
|
if (success)
|
|
{
|
|
webResp = null;
|
|
success = Web.MakeRequest(
|
|
"GET",
|
|
"https://portal.sip.rogers.com/api/workflows/routes/" + wfr_guid,
|
|
isJSON,
|
|
ref token,
|
|
ref webResp,
|
|
ref cookiejar);
|
|
|
|
if (success)
|
|
{
|
|
//ch_guid = getCHguid(response5[1].ToString());
|
|
|
|
dynamic jResp = JObject.Parse(Encoding.ASCII.GetString(webResp));
|
|
ch_guid = jResp.layout.contents[0].guid;
|
|
Logger.Log(5, " ch_guid=[{0}]", ch_guid);
|
|
|
|
Logger.Log(3, "Success ch_guid");
|
|
}
|
|
|
|
else
|
|
{
|
|
Logger.Log(5, "CHGUID FAIL{0}:{1}:{2}", Encoding.ASCII.GetString(webResp));
|
|
}
|
|
|
|
}
|
|
|
|
if (success)
|
|
{
|
|
webResp = null;
|
|
success = Web.MakeRequest(
|
|
"GET",
|
|
"https://portal.sip.rogers.com/api/panels/" + ch_guid,
|
|
isJSON,
|
|
ref token,
|
|
ref webResp,
|
|
ref cookiejar);
|
|
|
|
if (success)
|
|
{
|
|
//act_guid = getACTguid(response6[1].ToString());
|
|
|
|
dynamic jResp = JObject.Parse(Encoding.ASCII.GetString(webResp));
|
|
act_guid = jResp.variables.callHistoryList.route.path.parts[0].path;
|
|
// path : "/actions/5dd6b3da-0422-4b7f-b405-6b4c3bf4126e/call-history"
|
|
act_guid = act_guid.Split('/')[2];
|
|
|
|
Logger.Log(5, " act_guid=[{0}]", act_guid);
|
|
|
|
Logger.Log(3, "Success act_guid");
|
|
}
|
|
else
|
|
{
|
|
Logger.Log(5, "ACTGUID FAIL{0}:{1}:{2}", Encoding.ASCII.GetString(webResp));
|
|
}
|
|
|
|
}
|
|
|
|
if (success)
|
|
{
|
|
webResp = null;
|
|
success = Web.MakeRequest(
|
|
"GET",
|
|
"https://portal.sip.rogers.com/api/actions/" + act_guid + "/call-history-locations",
|
|
isJSON,
|
|
ref token,
|
|
ref webResp,
|
|
ref cookiejar);
|
|
|
|
if (success)
|
|
{
|
|
//co_guid = getCOguid(response7[1].ToString());
|
|
|
|
dynamic jResp = JArray.Parse(Encoding.ASCII.GetString(webResp));
|
|
co_guid = jResp[0].companyGuid;
|
|
|
|
Logger.Log(5, " co_guid=[{0}]", co_guid);
|
|
|
|
Logger.Log(3, "Success co_guid");
|
|
}
|
|
else
|
|
{
|
|
Logger.Log(5, "COGUID FAIL{0}:{1}:{2}", Encoding.ASCII.GetString(webResp));
|
|
}
|
|
|
|
}
|
|
|
|
if (success)
|
|
{
|
|
webResp = null;
|
|
success = Web.MakeRequest(
|
|
"POST",
|
|
"https://portal.sip.rogers.com/api/actions/" + act_guid + "/call-history",
|
|
"{\"type\":\"links\",\"monthsBack\":\"12\",\"companyGuid\":\"" + co_guid + "\",\"excludeCurrentMonth\":\"false\"}",
|
|
isJSON,
|
|
token,
|
|
ref webResp,
|
|
ref cookiejar);
|
|
|
|
if (success)
|
|
{
|
|
//did_guid = getDIDguid(response8[1].ToString());
|
|
|
|
//Console.WriteLine(response8[1].ToString());
|
|
dynamic jResp = JArray.Parse(Encoding.ASCII.GetString(webResp));
|
|
did_guid = jResp[0].didSourceGuid;
|
|
|
|
Logger.Log(5, " did_guid=[{0}]", did_guid);
|
|
|
|
foreach (dynamic jEntry in jResp)
|
|
{
|
|
if (jEntry.type == "history-mtd")
|
|
{
|
|
mtd = jEntry.month;
|
|
year = jEntry.year;
|
|
//Logger.Log(3, "MTD={0} YEAR={1}", mtd, year);
|
|
//Logger.Log(0, "Initiating CDR pull...");
|
|
success = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
Logger.Log(3, "Success did_guid");
|
|
Logger.Log(5, "MTD={0} YEAR={1}", mtd, year);
|
|
}
|
|
|
|
else
|
|
{
|
|
Logger.Log(5, "DIDGUID FAIL{0}:{1}:{2}", Encoding.ASCII.GetString(webResp));
|
|
}
|
|
}
|
|
|
|
return success;
|
|
}
|
|
|
|
|
|
public static bool GetMTDFile( string dirpath, string filename, string token, ref string act_guid, ref string co_guid, ref string did_guid,
|
|
ref string year, ref string mtd, ref CookieContainer cookiejar, WebProxy proxyObject)
|
|
{
|
|
byte[] webResp = null;
|
|
bool isJSON = true;
|
|
string link = "";
|
|
|
|
Logger.Log(1, "Requesting MTD for {0}/{1}", year, int.Parse(mtd)+1 ); // months are 0..11 for some weird reason
|
|
|
|
bool success = Web.MakeRequest(
|
|
"POST",
|
|
"https://portal.sip.rogers.com/api/actions/" + act_guid + "/call-history",
|
|
//{"type":"history-mtd","didSourceGuid":"5fa38eb4-1320-446f-a7d3-44169d68e850","companyGuid":"4fc11004-4c19-4601-a84c-ddca282d0f39","month":10,"year":2022}
|
|
"{\"type\":\"history-mtd\",\"didSourceGuid\":\"" + did_guid + "\",\"companyGuid\":\"" + co_guid + "\",\"month\":" + mtd + ",\"year\":" + year + "}",
|
|
isJSON,
|
|
ref webResp,
|
|
ref cookiejar);
|
|
|
|
if (!success)
|
|
{
|
|
Logger.Log(5, "MTDFILE FAIL{0}:{1}:{2}", Encoding.ASCII.GetString(webResp));
|
|
}
|
|
else
|
|
{
|
|
link = Encoding.ASCII.GetString(webResp);
|
|
link = link.Substring(1,link.Length-2);
|
|
|
|
Logger.Log(3,"File Link is:{0}",link);
|
|
Logger.Log(0, "File Name is:{0}", link.Split('/')[6]);
|
|
|
|
if ( filename == "" )
|
|
{
|
|
filename = link.Split('/')[6]; //FEB2023, was [2] before URI changed
|
|
}
|
|
|
|
Logger.Log(5, "Filename is:{0}", filename);
|
|
|
|
//next operation is NOT JSON !!!
|
|
isJSON = false;
|
|
|
|
Logger.Log(1, "...starting file GET");
|
|
|
|
webResp = null;
|
|
success = Web.MakeRequest(
|
|
"GET",
|
|
/* "https://portal.sip.rogers.com/api/" + link, */ //FEB2023
|
|
link,
|
|
isJSON,
|
|
ref token,
|
|
ref webResp,
|
|
ref cookiejar);
|
|
|
|
if ( success )
|
|
{
|
|
Logger.Log(1, "File Downloaded!");
|
|
|
|
//Save CDR to file
|
|
string fileName = dirpath + filename ;
|
|
Logger.Log(0, " assigned filename: {0}", fileName);
|
|
|
|
//byte[] csv = ObjectToByteArray(response10[1]);
|
|
Logger.Log(0, " file size: {0}", webResp.Length );
|
|
|
|
StreamWriter file = new StreamWriter(fileName);
|
|
file.BaseStream.Write(webResp,0,webResp.Length);
|
|
file.Close();
|
|
Logger.Log(" file saved.");
|
|
|
|
//void Upload_stream(MemoryStream ms, string filename, string host, int port, string username, string password)
|
|
if (cdrtool.sftp) // are we uploading to SFTP server
|
|
{
|
|
Logger.Log(0, " Initiating SFTP upload...");
|
|
try
|
|
{
|
|
using (var ms = new MemoryStream(webResp))
|
|
{
|
|
try { sftp.Upload_stream(ms, cdrtool.ssh_path + fileName, cdrtool.ssh_host, cdrtool.ssh_port, cdrtool.ssh_user, cdrtool.ssh_pass); }
|
|
catch (Exception e) { Logger.Log(0, "SFTP Upload Exception: {0}:{1}", e.Message, e.InnerException.Message); }
|
|
|
|
/*
|
|
try { ms.Close(); }
|
|
catch (Exception e) { Logger.Log(0, "SFTP Stream Close Exception: {0}:{1}", e.Message, e.InnerException.Message); }
|
|
*/
|
|
Logger.Log(" uploaded.");
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Logger.Log(0, "SFTP Upload Exception: {0}:{1}", e.Message, e.InnerException.Message);
|
|
}
|
|
}
|
|
}
|
|
webResp = null;
|
|
}
|
|
|
|
return success;
|
|
}
|
|
|
|
|
|
public static bool GetCDRHistoryFile(string dirpath, string filename, int offset, string token, ref string act_guid, ref string co_guid, ref string did_guid,
|
|
ref string year, ref string mtd, ref CookieContainer cookiejar, WebProxy proxyObject)
|
|
{
|
|
byte[] webResp = null;
|
|
bool isJSON = true;
|
|
string link = "";
|
|
bool success = false;
|
|
|
|
|
|
if (int.Parse(mtd) == 0) // if currently January, check last Dec's CDR complete file.
|
|
{
|
|
mtd = "12"; // FEB20223 equiv to Jan - 1 = Dec
|
|
year = (int.Parse(year) - 1).ToString();
|
|
}
|
|
|
|
|
|
Logger.Log(1, "Requesting history for {0}/{1}", year, (int.Parse(mtd) - offset + 1)); //months are 0..11 for some weird reason
|
|
|
|
// call-history-4596-2025-11.csv
|
|
//string historyfile = dirpath + link.Split('/')[6]; //FEB2023, was [2] before uri changed
|
|
string historyfile = dirpath + "call-history-4596-" + year + "-" + mtd + ".csv"; // JAN2026 no longer using short filename, we must rebuild
|
|
|
|
if (File.Exists(historyfile))
|
|
{
|
|
Logger.Log(0, "...skip last month's CDR History as it exists ({0})", historyfile);
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
//
|
|
success = Web.MakeRequest(
|
|
"POST",
|
|
"https://portal.sip.rogers.com/api/actions/" + act_guid + "/call-history",
|
|
//{"type":"history-mtd","didSourceGuid":"5fa38eb4-1320-446f-a7d3-44169d68e850","companyGuid":"4fc11004-4c19-4601-a84c-ddca282d0f39","month":10,"year":2022}
|
|
"{\"type\":\"history\",\"didSourceGuid\":\"" + did_guid + "\",\"companyGuid\":\"" + co_guid + "\",\"month\":" + (int.Parse(mtd) - cdrtool.prevMonOffset).ToString() + ",\"year\":" + year + "}",
|
|
isJSON,
|
|
ref webResp,
|
|
ref cookiejar);
|
|
|
|
if (success)
|
|
{
|
|
link = Encoding.ASCII.GetString(webResp);
|
|
link = link.Substring(1, link.Length - 2);
|
|
|
|
Logger.Log(3, "File Link is:{0}", link);
|
|
Logger.Log(0, "File Name is:{0}", link.Split('/')[6]);
|
|
}
|
|
|
|
else
|
|
{
|
|
Logger.Log(5, "HISTORY FAIL{0}:{1}:{2}", Encoding.ASCII.GetString(webResp));
|
|
return success;
|
|
}
|
|
|
|
//
|
|
|
|
webResp = null;
|
|
|
|
Logger.Log(1, " starting history file GET");
|
|
|
|
success = Web.MakeRequest(
|
|
"GET",
|
|
/* "https://portal.sip.rogers.com/api/" + link, */ //FEB2023
|
|
link,
|
|
!isJSON, // not JSON
|
|
"", // do NOT use a Token here, not Auth required.
|
|
ref webResp,
|
|
ref cookiejar);
|
|
|
|
if ( success )
|
|
{
|
|
Logger.Log(1, "File2 Downloaded!");
|
|
//Console.WriteLine(response12[1].ToString());
|
|
|
|
//Save CDR to file
|
|
|
|
Logger.Log(0, " assigned filename: {0}", historyfile);
|
|
|
|
Logger.Log(0, " file size: {0}", webResp.Length);
|
|
|
|
StreamWriter file = new StreamWriter(historyfile);
|
|
file.BaseStream.Write(webResp, 0, webResp.Length);
|
|
file.Close();
|
|
|
|
if (cdrtool.sftp) // are we uploading to SFTP server
|
|
{
|
|
MemoryStream ms = new MemoryStream(webResp);
|
|
sftp.Upload_stream(ms, cdrtool.ssh_path + historyfile, cdrtool.ssh_host, cdrtool.ssh_port, cdrtool.ssh_user, cdrtool.ssh_pass);
|
|
ms.Close();
|
|
}
|
|
}
|
|
webResp = null;
|
|
|
|
} //end of if exists check
|
|
return success;
|
|
}
|
|
|
|
/*
|
|
public static bool Login2 ( string user, string pswd, ref CookieContainer cookiejar, WebProxy proxy )
|
|
{
|
|
//object[] response = {};
|
|
byte[] webResp = null;
|
|
bool success = false;
|
|
TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1));
|
|
long time = (long) t.TotalSeconds * 1000;
|
|
|
|
cdrtool.token = "";
|
|
string wfr_guid = "";
|
|
string ch_guid = "";
|
|
string act_guid = "";
|
|
string co_guid = "";
|
|
string did_guid = "";
|
|
string link = "";
|
|
|
|
//LOGIN : https://portal.sip.rogers.com/en -> https://portal.sip.rogers.com/api/auth/login
|
|
|
|
success = Web.MakeRequest(
|
|
"GET",
|
|
"http://portal.sip.rogers.com/en",
|
|
true,
|
|
ref token,
|
|
ref webResp,
|
|
ref cookiejar );
|
|
|
|
if ( success )
|
|
{
|
|
Logger.Log(3,"Success Login0");
|
|
}
|
|
|
|
else
|
|
{
|
|
Logger.Log(5, "Login0 FAIL{0}:{1}:{2}", Encoding.ASCII.GetString(webResp));
|
|
}
|
|
|
|
webResp = null;
|
|
|
|
success = Web.MakeRequest(
|
|
"POST",
|
|
"https://portal.sip.rogers.com/api/auth/login",
|
|
//String.Format("{\"username\":\"{0}\",\"password\":\"{1}\",\"accountGuid\":null,\"rememberMe\":false}",user,pswd),
|
|
"{\"username\":\"" + cdrtool.username + "\",\"password\":\"" + cdrtool.password + "\",\"accountGuid\":null,\"rememberMe\":false}",
|
|
true,
|
|
token,
|
|
ref webResp,
|
|
ref cookiejar );
|
|
|
|
if ( success )
|
|
{
|
|
//Console.WriteLine("{0}", Encoding.ASCII.GetString(webResp) );
|
|
|
|
dynamic jResp = JObject.Parse(Encoding.ASCII.GetString(webResp));
|
|
cdrtool.token = jResp.account.user.token;
|
|
Logger.Log(5, "Token=[{0}]", cdrtool.token);
|
|
Logger.Log(0, "{0} is logged in for {1}", jResp.account.displayName, jResp.account.company.name);
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
Logger.Log(5,"Login1 FAIL{0}:{1}:{2}", Encoding.ASCII.GetString(webResp));
|
|
}
|
|
|
|
/*
|
|
object[] response1 = { }; //2022
|
|
cdrtool.token = "";
|
|
response1 = Web.MakeRequest(
|
|
"POST",
|
|
true, //changed from false DWMM
|
|
"https://portal.sip.rogers.com/api/auth/login",
|
|
//String.Format("{\"username\":\"{0}\",\"password\":\"{1}\",\"accountGuid\":null,\"rememberMe\":false}",user,pswd),
|
|
"{\"username\":\"" + cdrtool.username + "\",\"password\":\"" + cdrtool.password + "\",\"accountGuid\":null,\"rememberMe\":false}",
|
|
ref cookiejar,
|
|
proxy);
|
|
|
|
if ((bool)response1[0])
|
|
{
|
|
//cdrtool.token = getToken(response1[1].ToString());
|
|
|
|
dynamic jResp = JObject.Parse(response1[1].ToString());
|
|
cdrtool.token = jResp.account.user.token;
|
|
Logger.Log(5, "Token=[{0}]", cdrtool.token);
|
|
|
|
|
|
Logger.Log(0, "{0} is logged in for {1}", jResp.account.displayName, jResp.account.company.name);
|
|
success = true;
|
|
}
|
|
|
|
else
|
|
{
|
|
Logger.Log(5, "Login1 FAIL{0}:{1}:{2}", response1);
|
|
success = false;
|
|
}
|
|
///
|
|
|
|
object[] response3 = {};
|
|
if ( success )
|
|
{
|
|
Logger.Log(5,"Success Login2");
|
|
response3 = Web.MakeRequest(
|
|
"GET",
|
|
false,
|
|
"https://portal.sip.rogers.com/api/accounts/user-accounts",
|
|
"",
|
|
ref cookiejar,
|
|
proxy );
|
|
if ( (bool)response3[0] )
|
|
{
|
|
Logger.Log(3,"Success Login3");
|
|
success = true;
|
|
}
|
|
|
|
else
|
|
{
|
|
Logger.Log(5,"Login3 FAIL{0}:{1}:{2}",response3);
|
|
success = false;
|
|
}
|
|
|
|
}
|
|
// /api/workflows/landing-page-entries
|
|
|
|
object[] response4 = {};
|
|
if ( success )
|
|
{
|
|
Logger.Log(5,"Success Login3");
|
|
response4 = Web.MakeRequest(
|
|
"GET",
|
|
false,
|
|
"https://portal.sip.rogers.com/api/workflows/landing-page-entries",
|
|
"",
|
|
ref cookiejar,
|
|
proxy );
|
|
if ( (bool)response4[0] )
|
|
{
|
|
//wfr_guid = getWFRguid(response4[1].ToString());
|
|
// [[{"label":"APP.CALL_REPORTING.LABEL","description":"APP.GETTING_STARTED.REPORTING.DESCRIPTION","entries":[{"label":"APP.GETTING_STARTED.SERVICE_GRAPH.LABEL","description":"APP.GETTING_STARTED.SERVICE_GRAPH.DESCRIPTION","image":null,"icon":"insights","workflow":{"sharing":{},"guid":"89644421-7163-46b5-8757-e627a58a5eac","workflowRoutes":[{"guid":"63180702-08db-4bef-b3d6-865bfe497fe3"}]}},{"label":"APP.GETTING_STARTED.CALL_HISTORY.LABEL","description":"APP.GETTING_STARTED.CALL_HISTORY.DESCRIPTION","image":null,"icon":"download_for_offline","workflow":{"sharing":{},"guid":"4328117a-297e-4df2-ba5d-178daa793a16","workflowRoutes":[{"guid":"318024c2-bd1f-4d4e-9e00-7039e0c04998"}]}},{"label":"APP.GETTING_STARTED.VIEW_PEER_INVENTORY.LABEL","description":"APP.GETTING_STARTED.VIEW_PEER_INVENTORY.DESCRIPTION","image":"","icon":"summarize","workflow":{"sharing":{},"guid":"ae6cc939-f4ba-4287-80b9-d45567609f00","workflowRoutes":[{"guid":"0a8a8a1e-1eb2-4104-a3a9-80307864eb16"}]}}]}]]
|
|
|
|
dynamic jResp = JArray.Parse(response4[1].ToString());
|
|
foreach ( dynamic jEntry in jResp[0].entries)
|
|
{
|
|
// APP.GETTING_STARTED.CALL_HISTORY.LABEL
|
|
// Console.WriteLine("{0}",jEntry.label);
|
|
if ( jEntry.label == "APP.GETTING_STARTED.CALL_HISTORY.LABEL")
|
|
{
|
|
wfr_guid = jEntry.workflow.workflowRoutes[0].guid;
|
|
Logger.Log(5, " wfr_guid=[{0}]", wfr_guid);
|
|
|
|
}
|
|
}
|
|
|
|
Logger.Log(3,"Success Login4");
|
|
success = true;
|
|
}
|
|
|
|
else
|
|
{
|
|
Logger.Log(5,"Login4 FAIL{0}:{1}:{2}",response4);
|
|
success = false;
|
|
}
|
|
|
|
}
|
|
|
|
object[] response5 = {};
|
|
if ( success )
|
|
{
|
|
Logger.Log(5,"Success Login4");
|
|
response5 = Web.MakeRequest(
|
|
"GET",
|
|
false,
|
|
"https://portal.sip.rogers.com/api/workflows/routes/" + wfr_guid,
|
|
"",
|
|
ref cookiejar,
|
|
proxy );
|
|
if ( (bool)response5[0] )
|
|
{
|
|
//ch_guid = getCHguid(response5[1].ToString());
|
|
|
|
dynamic jResp = JObject.Parse(response5[1].ToString());
|
|
ch_guid = jResp.layout.contents[0].guid;
|
|
Logger.Log(5, " ch_guid=[{0}]", ch_guid);
|
|
|
|
Logger.Log(3,"Success Login5");
|
|
success = true;
|
|
}
|
|
|
|
else
|
|
{
|
|
Logger.Log(5,"Login5 FAIL{0}:{1}:{2}",response5);
|
|
success = false;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
object[] response6 = {};
|
|
if ( success )
|
|
{
|
|
Logger.Log(5,"Success Login5");
|
|
response6 = Web.MakeRequest(
|
|
"GET",
|
|
false,
|
|
"https://portal.sip.rogers.com/api/panels/" + ch_guid,
|
|
"",
|
|
ref cookiejar,
|
|
proxy );
|
|
if ( (bool)response6[0] )
|
|
{
|
|
//act_guid = getACTguid(response6[1].ToString());
|
|
|
|
dynamic jResp = JObject.Parse(response6[1].ToString());
|
|
act_guid = jResp.variables.callHistoryList.route.path.parts[0].path;
|
|
// path : "/actions/5dd6b3da-0422-4b7f-b405-6b4c3bf4126e/call-history"
|
|
act_guid = act_guid.Split('/')[2];
|
|
|
|
Logger.Log(5, " act_guid=[{0}]", act_guid);
|
|
|
|
Logger.Log(3,"Success Login6");
|
|
success = true;
|
|
}
|
|
|
|
else
|
|
{
|
|
Logger.Log(5,"Login6 FAIL{0}:{1}:{2}",response6);
|
|
success = false;
|
|
}
|
|
|
|
}
|
|
|
|
object[] response7 = {};
|
|
if ( success )
|
|
{
|
|
Logger.Log(5,"Success Login6");
|
|
response7 = Web.MakeRequest(
|
|
"GET",
|
|
false,
|
|
"https://portal.sip.rogers.com/api/actions/" + act_guid + "/call-history-locations",
|
|
"",
|
|
ref cookiejar,
|
|
proxy );
|
|
if ( (bool)response7[0] )
|
|
{
|
|
//co_guid = getCOguid(response7[1].ToString());
|
|
|
|
dynamic jResp = JArray.Parse(response7[1].ToString());
|
|
co_guid = jResp[0].companyGuid;
|
|
|
|
Logger.Log(5, " co_guid=[{0}]", co_guid);
|
|
|
|
Logger.Log(3,"Success Login7");
|
|
success = true;
|
|
}
|
|
|
|
else
|
|
{
|
|
Logger.Log(5,"Login7 FAIL{0}:{1}:{2}",response7);
|
|
success = false;
|
|
}
|
|
|
|
}
|
|
|
|
string mtd = "";
|
|
string year = "";
|
|
|
|
object[] response8 = {};
|
|
if ( success )
|
|
{
|
|
Logger.Log(5,"Success Login7");
|
|
response8 = Web.MakeRequest(
|
|
"POST",
|
|
true, //changed from false DWMM
|
|
"https://portal.sip.rogers.com/api/actions/" + act_guid + "/call-history",
|
|
"{\"type\":\"links\",\"monthsBack\":\"12\",\"companyGuid\":\"" + co_guid + "\",\"excludeCurrentMonth\":\"false\"}",
|
|
ref cookiejar,
|
|
proxy );
|
|
|
|
if ( (bool)response8[0] )
|
|
{
|
|
//did_guid = getDIDguid(response8[1].ToString());
|
|
|
|
//Console.WriteLine(response8[1].ToString());
|
|
dynamic jResp = JArray.Parse(response8[1].ToString());
|
|
did_guid = jResp[0].didSourceGuid;
|
|
|
|
Logger.Log(5, " did_guid=[{0}]", did_guid);
|
|
|
|
foreach (dynamic jEntry in jResp)
|
|
{
|
|
if (jEntry.type == "history-mtd")
|
|
{
|
|
mtd = jEntry.month;
|
|
year = jEntry.year;
|
|
Logger.Log(3, "MTD={0} YEAR={1}", mtd, year);
|
|
Logger.Log(0, "Initiating CDR pull...");
|
|
success = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
Logger.Log(3,"Success Login8");
|
|
success = true;
|
|
}
|
|
|
|
else
|
|
{
|
|
Logger.Log(5,"Login8 FAIL{0}:{1}:{2}",response8);
|
|
success = false;
|
|
}
|
|
}
|
|
|
|
object[] response9 = {};
|
|
if ( success )
|
|
{
|
|
Logger.Log(5,"Success Login8");
|
|
Logger.Log(1, "Requesting MTD for {0}/{1}", year, int.Parse(mtd)+1 ); // months are 0..11 for some weird reason
|
|
response9 = Web.MakeRequest(
|
|
"POST",
|
|
true, //changed from false DWMM
|
|
"https://portal.sip.rogers.com/api/actions/" + act_guid + "/call-history",
|
|
//{"type":"history-mtd","didSourceGuid":"5fa38eb4-1320-446f-a7d3-44169d68e850","companyGuid":"4fc11004-4c19-4601-a84c-ddca282d0f39","month":10,"year":2022}
|
|
"{\"type\":\"history-mtd\",\"didSourceGuid\":\"" + did_guid + "\",\"companyGuid\":\"" + co_guid + "\",\"month\":" + mtd + ",\"year\":" + year + "}",
|
|
ref cookiejar,
|
|
proxy );
|
|
|
|
if ( (bool)response9[0] )
|
|
{
|
|
link = response9[1].ToString();
|
|
link = link.Substring(1,link.Length-2);
|
|
|
|
Logger.Log(0,"File Link is:{0}",link);
|
|
Logger.Log(3,"Success Login9");
|
|
success = true;
|
|
}
|
|
|
|
else
|
|
{
|
|
Logger.Log(5,"Login8 FAIL{0}:{1}:{2}",response9);
|
|
success = false;
|
|
}
|
|
}
|
|
|
|
string storage = cdrtool.token;
|
|
cdrtool.token = "";
|
|
|
|
object[] response10 = {};
|
|
if ( success )
|
|
{
|
|
Logger.Log(5,"Success Login9");
|
|
Logger.Log(1,"...starting file GET");
|
|
response10 = Web.MakeRequest(
|
|
"GET",
|
|
false,
|
|
"https://portal.sip.rogers.com/api/" + link,
|
|
"",
|
|
ref cookiejar,
|
|
proxy );
|
|
if ( (bool)response10[0] )
|
|
{
|
|
|
|
Logger.Log(5,"Success Login10");
|
|
Logger.Log(1,"File Downloaded!");
|
|
//Console.WriteLine(response10[1].ToString());
|
|
success = true;
|
|
|
|
//Save CDR to file
|
|
string fileName = "CURRENT.csv";
|
|
//fileName = link.Split('/')[2];
|
|
fileName = cdrtool.dirpath + fileName;
|
|
Logger.Log(0," assigned filename: {0}",fileName);
|
|
|
|
byte[] csv = ObjectToByteArray(response10[1]);
|
|
Logger.Log(0," file size: {0}",csv.Length-29); //formatter adds crap at beginning (29) and end (1) to be able to recreate.
|
|
|
|
StreamWriter file = new StreamWriter(fileName); file.BaseStream.Write(csv,29,csv.Length-30); file.Close();
|
|
}
|
|
}
|
|
|
|
cdrtool.token = storage;
|
|
|
|
// history file check
|
|
if (cdrtool.checkPrevMonth)
|
|
{
|
|
if ( int.Parse(mtd) == 1) // if currently January, check last Dec's CDR complete file.
|
|
{
|
|
mtd = "13"; // gets decremented in the call string below
|
|
year = (int.Parse(year)-1).ToString();
|
|
}
|
|
|
|
object[] response11 = {};
|
|
if ( success )
|
|
{
|
|
Logger.Log(5,"Success Login10");
|
|
Logger.Log(1, "Requesting history for {0}/{1}",year, (int.Parse(mtd) - cdrtool.prevMonOffset + 1) ); //months are 0..11 for some weird reason
|
|
response11 = Web.MakeRequest(
|
|
"POST",
|
|
true, //changed from false DWMM
|
|
"https://portal.sip.rogers.com/api/actions/" + act_guid + "/call-history",
|
|
//{"type":"history-mtd","didSourceGuid":"5fa38eb4-1320-446f-a7d3-44169d68e850","companyGuid":"4fc11004-4c19-4601-a84c-ddca282d0f39","month":10,"year":2022}
|
|
"{\"type\":\"history\",\"didSourceGuid\":\"" + did_guid + "\",\"companyGuid\":\"" + co_guid + "\",\"month\":" + (int.Parse(mtd)-cdrtool.prevMonOffset).ToString() + ",\"year\":" + year + "}",
|
|
ref cookiejar,
|
|
proxy );
|
|
|
|
if ( (bool)response11[0] )
|
|
{
|
|
link = response11[1].ToString();
|
|
link = link.Substring(1,link.Length-2);
|
|
|
|
Logger.Log(0,"File Link is:{0}",link);
|
|
Logger.Log(3,"Success Login11");
|
|
success = true;
|
|
}
|
|
|
|
else
|
|
{
|
|
Logger.Log(5,"Login11 FAIL{0}:{1}:{2}",response11);
|
|
success = false;
|
|
}
|
|
}
|
|
|
|
if (File.Exists(cdrtool.dirpath+link.Split('/')[2]))
|
|
{
|
|
Logger.Log(0,"...previous month's CDR History already exists ({0}) ...skipping",cdrtool.dirpath+link.Split('/')[2] );
|
|
}
|
|
else
|
|
{
|
|
|
|
cdrtool.token = "";
|
|
|
|
object[] response12 = {};
|
|
if ( (bool)response11[0] )
|
|
{
|
|
Logger.Log(5,"Success Login11");
|
|
Logger.Log(1,"starting file2 GET");
|
|
response12 = Web.MakeRequest(
|
|
"GET",
|
|
false,
|
|
"https://portal.sip.rogers.com/api/" + link,
|
|
"",
|
|
ref cookiejar,
|
|
proxy );
|
|
if ( (bool)response12[0] )
|
|
{
|
|
|
|
Logger.Log(3,"Success Login12");
|
|
Logger.Log(1,"File2 Downloaded!");
|
|
//Console.WriteLine(response12[1].ToString());
|
|
success = true;
|
|
|
|
//Save CDR to file
|
|
string fileName = "History.csv";
|
|
fileName = link.Split('/')[2];
|
|
fileName = cdrtool.dirpath + fileName;
|
|
Logger.Log(0," assigned filename: {0}",fileName);
|
|
|
|
byte[] csv = ObjectToByteArray(response12[1]);
|
|
Logger.Log(0," file size: {0}",csv.Length-29); //formatter adds crap at beginning (29) and end (1) to be able to recreate.
|
|
|
|
StreamWriter file = new StreamWriter(fileName); file.BaseStream.Write(csv,29,csv.Length-30); file.Close();
|
|
|
|
}
|
|
}
|
|
|
|
} //end of if exists check
|
|
|
|
|
|
cdrtool.checkPrevMonth = false;
|
|
}
|
|
cdrtool.token = storage;
|
|
return success;
|
|
}
|
|
*/
|
|
|
|
|
|
public static bool Logout ( string token, ref CookieContainer cookiejar, ref WebProxy proxy )
|
|
{
|
|
byte[] ignore = null;
|
|
bool success = Web.MakeRequest(
|
|
"POST",
|
|
"https://portal.sip.rogers.com/api/auth/logout",
|
|
"{ \"JSON\" : \"True\"}",
|
|
true, // isJSON
|
|
token,
|
|
ref ignore, // don't care about the return stream
|
|
ref cookiejar );
|
|
|
|
if ( success )
|
|
{
|
|
Logger.Log(0,"Logout successful.");
|
|
}
|
|
return success;
|
|
}
|
|
|
|
/*
|
|
public static string getToken ( string json )
|
|
{
|
|
string token;
|
|
//"token":"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50R3VpZCI6ImNhMzgzZDViLWMyYzktNGU1My04NWQ3LWY1MTYwZjdlYjU0ZSIsImNvbXBhbnlHdWlkIjoiNGZjMTEwMDQtNGMxOS00NjAxLWE4NGMtZGRjYTI4MmQwZjM5IiwidXNlckd1aWQiOiIyNmZlYzk5OC1jZTMyLWMyMGEtODYxYi1lOTNmYTJmYWM1MDEiLCJpYXQiOjE2Njc5NTc4ODQsImV4cCI6MTY2Nzk1ODc4NH0.SeJJVcOJJk5vOhOznCiPmZFhQwl4bAJ7odJbFa1OVDGtoOEKD_CCV9kdTWMxWITj8v3zJJLJHnkhFAO1QU7llA"},"company"
|
|
//"token":"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2N ... 3zJJLJHnkhFAO1QU7llA"},"company"
|
|
|
|
Match m = Regex.Match(json, @"{""account"".*?""token"":""(.+?)""},""company"""); // we're hunting for the "token":"flkajdlkahfkjdsahfka"
|
|
|
|
if ( ( !m.Success ) )
|
|
{
|
|
Logger.Log(0,"Token not found!");
|
|
return "";
|
|
}
|
|
else
|
|
{
|
|
token = m.Groups[1].Value.ToString();
|
|
Logger.Log(3,"Token={0}",token);
|
|
}
|
|
return token;
|
|
}
|
|
|
|
public static string getCustomer ( string json )
|
|
{
|
|
|
|
string name;
|
|
//company":{"guid":"4fc11004-4c19-4601-a84c-ddca282d0f39","name":"Hydro Ottawa Limited 4596"}},"expiresIn
|
|
|
|
Match m = Regex.Match(json, @"{""guid"".*?""name"":""(.+?)""}},""expiresIn"""); // we're hunting for the "token":"flkajdlkahfkjdsahfka"
|
|
|
|
if ( ( !m.Success ) )
|
|
{
|
|
Logger.Log(0,"Customer name not found!");
|
|
return "";
|
|
}
|
|
else
|
|
{
|
|
name = m.Groups[1].Value.ToString();
|
|
Logger.Log(3,"Customer={0}",name);
|
|
}
|
|
return name;
|
|
}
|
|
|
|
public static string getWFRguid ( string json )
|
|
{
|
|
string guid;
|
|
|
|
//{.*HISTORY.DESCRIPTION.*workflowRoutes\":\[{"guid\":\"(.+)\"}.*VIEW_PEER_INVENTORY
|
|
Match m = Regex.Match(json, @"{.*CALL_HISTORY.DESCRIPTION.*?workflowRoutes"":.{""guid"":""(.+?)""}.}"); // we're looking for "workflowRoutes":[{"guid":"318024c2-bd1f-4d4e-9e00-7039e0c04998"}]}},{"label":
|
|
|
|
if ( ( !m.Success ) )
|
|
{
|
|
Logger.Log(0,"wfr_guid not found!");
|
|
return "";
|
|
}
|
|
else
|
|
{
|
|
guid = m.Groups[1].Value.ToString();
|
|
Logger.Log(2," wfr_guid={0}",guid);
|
|
}
|
|
return guid;
|
|
}
|
|
|
|
public static string getCHguid ( string json )
|
|
{
|
|
string guid;
|
|
|
|
// layout":{"direction":"column","contents":[{"component":"panel","guid":"ff2b74bb-bd68-46ff-9609-2f180378cceb","definition":false}]},"variables":{},"dialogs":{},"routeName":"call-history"
|
|
Match m = Regex.Match(json, @"{.*component"":""panel"",""guid"":""(.+?)"",""definition"); // we're looking for "guid":[{"guid":"ff2b74bb-bd68-46ff-9609-2f180378cceb",
|
|
|
|
if ( ( !m.Success ) )
|
|
{
|
|
Logger.Log(0,"ch_guid not found!");
|
|
return "";
|
|
}
|
|
else
|
|
{
|
|
guid = m.Groups[1].Value.ToString();
|
|
Logger.Log(2," ch_guid={0}",guid);
|
|
}
|
|
return guid;
|
|
}
|
|
|
|
public static string getACTguid ( string json )
|
|
{
|
|
string guid;
|
|
|
|
// layout":{"direction":"column","contents":[{"component":"panel","guid":"ff2b74bb-bd68-46ff-9609-2f180378cceb","definition":false}]},"variables":{},"dialogs":{},"routeName":"call-history"
|
|
Match m = Regex.Match(json, @"{.*actions/(.*?)/call-history"); // we're looking for "guid":[{"guid":"ff2b74bb-bd68-46ff-9609-2f180378cceb",
|
|
|
|
if ( ( !m.Success ) )
|
|
{
|
|
Logger.Log(0,"act_guid not found!");
|
|
return "";
|
|
}
|
|
else
|
|
{
|
|
guid = m.Groups[1].Value.ToString();
|
|
Logger.Log(2," act_guid={0}",guid);
|
|
}
|
|
return guid;
|
|
}
|
|
|
|
public static string getCOguid ( string json )
|
|
{
|
|
string guid;
|
|
|
|
// layout":{"direction":"column","contents":[{"component":"panel","guid":"ff2b74bb-bd68-46ff-9609-2f180378cceb","definition":false}]},"variables":{},"dialogs":{},"routeName":"call-history"
|
|
Match m = Regex.Match(json, @"{.*companyGuid"":""(.*?)"",""clientId"); // we're looking for "guid":[{"guid":"ff2b74bb-bd68-46ff-9609-2f180378cceb",
|
|
|
|
if ( ( !m.Success ) )
|
|
{
|
|
Logger.Log(0,"co_guid not found!");
|
|
return "";
|
|
}
|
|
else
|
|
{
|
|
guid = m.Groups[1].Value.ToString();
|
|
Logger.Log(2," co_guid={0}",guid);
|
|
}
|
|
return guid;
|
|
}
|
|
|
|
public static string getDIDguid ( string json )
|
|
{
|
|
string guid;
|
|
|
|
// "type":"history-mtd","didSourceGuid":"5fa38eb4-1320-446f-a7d3-44169d68e850"},{"timePeriod":"2022-
|
|
Match m = Regex.Match(json, @"{.*didSourceGuid"":""(.*?)""},{""timePeriod");
|
|
|
|
if ( ( !m.Success ) )
|
|
{
|
|
Logger.Log(0,"did_guid not found!");
|
|
return "";
|
|
}
|
|
else
|
|
{
|
|
guid = m.Groups[1].Value.ToString();
|
|
Logger.Log(2," did_guid={0}",guid);
|
|
}
|
|
return guid;
|
|
}
|
|
*/
|
|
|
|
// Convert an object to a byte array
|
|
public static byte[] ObjectToByteArray(object obj)
|
|
{
|
|
BinaryFormatter bf = new BinaryFormatter();
|
|
using (var ms = new MemoryStream())
|
|
{
|
|
bf.Serialize(ms, obj);
|
|
//byte[] b = (byte[]) (object) bf.Deserialize(ms);
|
|
return ms.ToArray();
|
|
//return b;
|
|
}
|
|
}
|
|
}
|
|
}
|