public void SetCommand(string telWithPlus, I2_InfoDisplay i2) { InitIfNot(); i2.FileLog_Debug("Android Add: " + telWithPlus + " ..."); string androidAnswer = Exchange(new AndroidCmdToken(_8UpdateCommunicator_Real.Cmds.set, telWithPlus.Replace("+", ""))); i2.FileLog_Debug("Android Add: " + androidAnswer); }
public List <string> GetCommand(I2_InfoDisplay i2) { InitIfNot(); i2.AddLine2(new DetailedData_TypeAndAndroidEP() { Endpoint = Endpoint }); i2.FileLog_Debug("_8AndroidCommunicator_Real.GetCommand ..."); List <string> retOnAndroid = new List <string>(); string getResponse = Exchange(new AndroidCmdToken(_8UpdateCommunicator_Real.Cmds.get)); string firstLine = ""; using (AndroidStringParser p = new AndroidStringParser(getResponse)) { p.Parse(delegate(string val) { if (firstLine.Length == 0) { firstLine = val; } if (val.StartsWith("zapi_")) { retOnAndroid.Add("+" + val.Substring("zapi_".Length)); } }); } i2.FileLog_Info("Android GET done: " + firstLine); if (retOnAndroid.Count > 0) { i2.FileLog_Info("Android GET 1st Entry: " + retOnAndroid[0]); } return(retOnAndroid); }
public List <string> GetCommand(I2_InfoDisplay i2) { i2.FileLog_Debug("_8ServerCommunicator_Real.GetCommand ..."); List <string> retOnServer = new List <string>(); string url = "http://niceapi.net/ItemX?id=GetTelNumbers&sub=" + "_3GetData.Server.TrayType".GetConfig(); i2.FileLog_Debug("_8ServerCommunicator_Real.GetCommand " + url); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { using (StreamReader sr = new StreamReader(response.GetResponseStream())) { string lastLine = "???"; try { while (true) { string serverLine = sr.ReadLine(); if (serverLine == null) { throw new IOException(); } lastLine = serverLine; if (serverLine.StartsWith("+")) { retOnServer.Add(serverLine); } } } catch (IOException) { } i2.FileLog_Info("ServerUpdate done: " + lastLine); if (retOnServer.Count > 0) { i2.FileLog_Info("ServerUpdate 1st Entry: " + retOnServer[0]); } } } return(retOnServer); }
public void ExchangeDataWithServer(I2_InfoDisplay d, I6_WhatsAppProcess p) { d.AddLine("exchangeDataWithASP"); d.FileLog_Debug("exchangeDataWithASP"); toASP.TrayType = ConfigurationManager.AppSettings["_3GetData.Server.TrayType"]; d.AddLine2(new DetailedData_TypeAndAndroidEP() { TrayType = toASP.TrayType }); d.AddLine2(new DetailedData_TypeAndAndroidEP() { LocalIPAddress = Extensions.GetLocalIPAddress() }); if (String.IsNullOrEmpty(toASP.TrayType)) { throw new ConfigurationException("_3GetData.Server.TrayType is missing!"); } ASPTray_ObjectList.Counters toASPCount = toASP.GetCounters(); if (toASPCount.Total_Results() > 0) { d.FileLog_Info(toASPCount.Total_ResultsString() + " up msg"); } d.AddLine2(toASPCount.AddLineIFace_Send()); string url = p.Debug_AmendUrl(FolderNames.GetUrl(this.urlToUse), toASP.GetCounters().Total_ResultsString()); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.ReadWriteTimeout = FolderNames.GetValue(MyValues.Tray_TcpTimeoutSec) * 1000; request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; Stream requestStream = request.GetRequestStream(); BinBase64StreamHelper.Tray2ASP_ToB64Stream(ref toASP, requestStream); requestStream.Close(); // GET RESPONSE **************************************************** HttpWebResponse response = (HttpWebResponse)request.GetResponse(); d.AddLine("GetResponse done"); toASP = new Data_Net_Tray2ASP(); fromASP = new Data_Net_ASP2Tray(); Stream stream = response.GetResponseStream(); BinBase64StreamHelper.ASP2Tray_FromB64Stream(ref fromASP, stream); response.Close(); ASPTray_ObjectList.Counters fromASPCount = fromASP.GetCounters(); if (fromASPCount.Total_Requests() > 0) { d.FileLog_Info(fromASPCount.Total_RequestsString() + " down msg"); } d.AddLine2(fromASPCount.AddLineIFace_Receive()); }
void internalThread() { m_2iInfoDisplay.FileLog_Debug("internalThread start"); m_2iInfoDisplay.FileLog_Debug(Assembly.GetAssembly(typeof(IMyLog)).WriteAssemblyVersion()); m_2iInfoDisplay.ReturnWhenReady(); Ix iAll = new Ix(m_2iInfoDisplay, m_4Screen, m_5Mouse, m_6Process, m_8Updater, new C9_CPUSlowdown()); iAll.iSlowdown.Slowdown(iAll); processEmptyWakeUpTrigger(iAll); while (m_wantToStop.WaitOne(10, false) == false) { try { iAll.iSlowdown.Slowdown(iAll); m_2iInfoDisplay.LoopStart(); m_3iGetData.ExchangeDataWithServer(m_2iInfoDisplay, m_6Process); List <ASPTrayBase> serverFiles = m_3iGetData.GetServerFiles(iAll); if (serverFiles.Count == 0) { processEmptyWakeUpTrigger(iAll); } else { foreach (ASPTrayBase f1 in serverFiles) { m_2iInfoDisplay.FileLog_Info("".PadRight(50, '*')); m_2iInfoDisplay.FileLog_Info("processing start : " + f1.GetFileName()); iAll.iSlowdown.Slowdown(iAll); ASPTrayBase.eASPtrayType f1e = f1.GetEnumType(); switch (f1e) { case ASPTrayBase.eASPtrayType.ScreenShotRequest: { Data_Net__02ScreenshotRequest _02 = (Data_Net__02ScreenshotRequest)f1; m_2iInfoDisplay.FileLog_Info("processing screenshot start: " + _02.MsgTicks.ToString()); Bitmap bAll = ImageCapture.GetAll(); m_3iGetData.AddResultFile( new Data_Net__03ScreenshotResult( bAll.BmpToB64_Png(), _02.GetFileName())); m_2iInfoDisplay.FileLog_Info("processing done screenshot: " + _02.MsgTicks.ToString()); } break; case ASPTrayBase.eASPtrayType.NormalMessage: { Data_Net__00NormalMessage _00 = (Data_Net__00NormalMessage)f1; m_2iInfoDisplay.AddLine(_00.DestMobile); m_2iInfoDisplay.FileLog_Info(_00.DestMobile); if (_00.FailedCounter != 0) { m_2iInfoDisplay.FileLog_Info(String.Format("FailedCounter: {0} / {1}", _00.FailedCounter, _00.DisposeAfterNFailed)); } m_2iInfoDisplay.FileLog_Info("MSG: " + _00.Msg.MsgForLogFile()); int processId; bool use; m_3iGetData.Debug_GetProcessIdOfFile(f1, out processId, out use); if (use) { m_6Process.Debug_AmendProcessId(processId); } iAll.TypeOfProcess = Ix.eTypeOfProcess.Normal; eI6Error whatsAppRes = m_6Process.Process( _00.DestMobile, _00.Msg, iAll); m_2iInfoDisplay.AddLine(whatsAppRes.ToString()); switch (whatsAppRes) { case eI6Error.Success: m_3iGetData.AddResultFile(new Data_Net__01NormalMessageResult( _00.GetFileName(), true)); m_2iInfoDisplay.FileLog_Debug("processing done: " + _00.UniqueId()); break; case eI6Error.FailedButNoLettingHostKnow_TelNotActive: m_2iInfoDisplay.AddLine("No Tel in Android yet"); m_2iInfoDisplay.FileLog_Info("No Tel in Android yet"); break; default: // failed m_3iGetData.AddResultFile(new Data_Net__01NormalMessageResult( _00.GetFileName(), false)); m_2iInfoDisplay.FileLog_Debug("processing failed (interaction): " + _00.UniqueId() + " " + whatsAppRes.ToString()); break; } } break; case ASPTrayBase.eASPtrayType.CheckTelNumbers: { Data_Net__04CheckTelNumbers _04 = (Data_Net__04CheckTelNumbers)f1; m_2iInfoDisplay.AddLine("CheckTelNumbers:" + _04.GetFileName()); MobileNoHandler handleOk = new MobileNoHandler(_04.TelListChecked); MobileNoHandler handleRetryPlease = new MobileNoHandler(""); MobileNoHandler handleNotWorking = new MobileNoHandler(""); foreach (string toBeCheckedNoZap in new MobileNoHandler(_04.TelList).MobileNumberArray) { string toBeChecked = toBeCheckedNoZap.Zapi_Add(); m_2iInfoDisplay.AddLine("Checking " + toBeChecked); m_2iInfoDisplay.FileLog_Info("Checking " + toBeChecked); int processId; bool use; m_3iGetData.Debug_GetProcessIdOfFile(f1, out processId, out use); if (use) { m_6Process.Debug_AmendProcessId(processId); } iAll.TypeOfProcess = Ix.eTypeOfProcess.TelNumberChecking; eI6Error whatsAppRes = m_6Process.Process( toBeChecked, null, iAll); m_2iInfoDisplay.AddLine(whatsAppRes.ToString()); switch (whatsAppRes) { case eI6Error.Success: handleOk.Add(toBeCheckedNoZap); break; case eI6Error.FailedButNoLettingHostKnow_TelNotActive: handleRetryPlease.Add(toBeCheckedNoZap); break; default: // failed handleNotWorking.Add(toBeCheckedNoZap); break; } } m_3iGetData.AddResultFile( new Data_Net__05CheckTelNumbersResult( _04.GetFileName(), handleOk.getVal, handleRetryPlease.getVal, handleNotWorking.getVal)); } break; default: m_2iInfoDisplay.AddLine("UNKOWN FILE TYPE"); m_2iInfoDisplay.FileLog_Error("UNKOWN FILE TYPE"); break; } } } // delay if (m_3iGetData.DoWeHaveDataToSend()) { // we have data to send, so dont wait too long m_2iInfoDisplay.Delay(500); } else { m_2iInfoDisplay.Delay(2 * 1000); } } catch (SystemException se) { m_2iInfoDisplay.AddLine("SystemException"); m_2iInfoDisplay.AddLine(se.Message); m_2iInfoDisplay.AddLine(se.ToString()); if (!se.ToString().Contains("System.Net.WebException: The operation has timed out")) { m_2iInfoDisplay.FileLog_Error(se.Message + " - " + se.ToString()); } m_3iGetData.Reset_toASP(); m_2iInfoDisplay.Delay(5 * 1000); } } }