private string update2jsonstr(UpdatePreference obj) { string ret = ""; ret = UmsJson.Serialize(obj); return(ret); }
private string pageData2jsonstr(PageInfo obj) { string ret = ""; ret = UmsJson.Serialize(obj); return(ret); }
private string clientData2jsonstr(ClientData d) { string ret = ""; ret = UmsJson.Serialize(d); return(ret); }
private string eventData2jsonstr(Event obj) { string ret = ""; ret = UmsJson.Serialize(obj); return(ret); }
private string errorData2jsonstr(ErrorInfo obj) { string ret = ""; ret = UmsJson.Serialize(obj); return(ret); }
private string tag2jsonstr(Tag d) { string ret = ""; ret = UmsJson.Serialize(d); return(ret); }
private string pushids2jsonstr(Pushid d) { string ret = ""; ret = UmsJson.Serialize(d); return(ret); }
private string userids2jsonstr(Userid d) { string ret = ""; ret = UmsJson.Serialize(d); return(ret); }
//save crash info when app crash public void crashDataProceed(UnhandledExceptionEventArgs ex, string flag = "ums crash") { Exception e = ex.Exception; string err_title = "" + ex.Message + e.Message; string err_stack_trace = e.StackTrace == null ? "" : e.StackTrace; string error_title_statcktrace = err_title + "\r\n" + err_stack_trace; while (e.InnerException != null) { e = e.InnerException; error_title_statcktrace += "\r\n" + e.StackTrace; } ErrorInfo error = new ErrorInfo(); error.appkey = appkey; //error.stacktrace = ex.Message+"\r\n"+ex.StackTrace; error.stacktrace = error_title_statcktrace; error.time = Utility.getTime(); error.version = Utility.getApplicationVersion() == null ? "" : Utility.getApplicationVersion(); error.activity = Utility.getCurrentPageName(); error.deviceid = Utility.getDeviceId(); error.os_version = Utility.getOsVersion(); string error_info = UmsJson.Serialize(error); CrashListener.ReportException(error_info, flag); }
internal static void ReportException(Exception ex, string extra) { try { using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { SafeDeleteFile(store); using (TextWriter output = new StreamWriter(store.CreateFile(filename))) { ErrorInfo error = new ErrorInfo(); error.appkey = UmsManager.appkey; error.stacktrace = ex.Message + "\r\n" + ex.StackTrace; error.time = Utility.getTime(); error.version = Utility.getApplicationVersion(); error.activity = Utility.getCurrentPageName(); error.deviceid = Utility.getDeviceName(); error.os_version = Utility.getOsVersion(); string str = UmsJson.Serialize(error); output.WriteLine(str); } } } catch (Exception) { } }
private string onlineconfig2jsonstr(OnLineConfig obj) { string ret = ""; ret = UmsJson.Serialize(obj); return(ret); }
public async void sendData(string url) { /* * var request = HttpWebRequest.Create(url); * var result = (IAsyncResult)request.BeginGetResponse(ResponseCallback, request); */ //HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url); //myRequest.Method = "POST"; //myRequest.ContentType = "application/x-www-form-urlencoded"; //myRequest.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), myRequest); HttpClient client = new GZipHttpClient(); //must call getPostInfo() to initialize the message first await getPostInfo(); HttpContent httpContent = new StringContent("content=" + this.message);//TODO convert to UTF8 httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded"); HttpResponseMessage response = null; try { response = await client.PostAsync(url, httpContent); DebugTool.Log("post response:" + response); } catch (HttpRequestException ex) { //do nothing response = null; } if (response == null || response.StatusCode != HttpStatusCode.OK) { CommonRet errorRet = new CommonRet(); errorRet.flag = "-100"; errorRet.msg = "server error "; if (response != null) { errorRet.msg += response.StatusCode; } ret = UmsJson.Serialize(errorRet); DebugTool.Log(ret); stateChanged(type, ret, obj); } else { ret = await response.Content.ReadAsStringAsync(); stateChanged(type, ret, obj); } }
//all data private string allData2jsonstr() { AllInfo allinfo = new AllInfo(); allinfo.appkey = UmsManager.appkey; string ret = ""; IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings; if (settings.Contains("clientdata")) { List <ClientData> list_client_data = (List <ClientData>)settings["clientdata"]; allinfo.clientData = list_client_data; } if (settings.Contains("tagdata")) { List <Tag> list_tag_data = (List <Tag>)settings["tagdata"]; allinfo.tagListInfo = list_tag_data; } if (settings.Contains("eventdata")) { List <Event> list_event_data = (List <Event>)settings["eventdata"]; allinfo.eventInfo = list_event_data; } try { string err_str = CrashListener.CheckForPreviousException(); ErrorInfo error = UmsJson.Deserialize <ErrorInfo>(err_str); if (error != null) { List <ErrorInfo> err_list = new List <ErrorInfo>(); err_list.Add(error); allinfo.errorInfo = err_list; } } catch (Exception e) { DebugTool.Log(e.Message); } if (settings.Contains("pageinfo")) { List <PageInfo> list_pageinfo_data = (List <PageInfo>)settings["pageinfo"]; allinfo.activityInfo = list_pageinfo_data; } ret = UmsJson.Serialize(allinfo); return(ret); }
private void GetResponseCallback(IAsyncResult asynchronousResult) { HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState; HttpWebResponse response = null; try { response = (HttpWebResponse)request.EndGetResponse(asynchronousResult); } catch (Exception e) { DebugTool.Log(e.InnerException.Message); } if (response == null) { CommonRet errorRet = new CommonRet(); errorRet.flag = "-100"; errorRet.msg = "server is not founded."; ret = UmsJson.Serialize(errorRet); DebugTool.Log(ret); stateChanged(type, ret, obj); return; } Stream streamResponse = response.GetResponseStream(); StreamReader streamRead = new StreamReader(streamResponse); string responseString = streamRead.ReadToEnd(); // Close the stream object streamResponse.Close(); streamRead.Close(); ret = responseString; stateChanged(type, ret, obj); }
//check is exist crash log public static bool isExistCrashLog() { try { string err_str = CrashListener.CheckForPreviousException(); ErrorInfo o = UmsJson.Deserialize <ErrorInfo>(err_str); if (o != null) { return(true); } } catch (Exception e) { DebugTool.Log(e.Message); return(false); } return(false); }
//all data private async Task <string> allData2jsonstr() { AllInfo allinfo = new AllInfo(); allinfo.appkey = UmsManager.appkey; string ret = ""; Windows.Storage.ApplicationDataContainer settings = Windows.Storage.ApplicationData.Current.LocalSettings; allinfo.clientData = await ApplicationSettings.GetSettingFromXmlFileAsync <List <ClientData> >(SettingKeys.CLIENT_DATA, null); allinfo.eventInfo = await ApplicationSettings.GetSettingFromXmlFileAsync <List <Event> >(SettingKeys.EVENT_DATA, null); allinfo.activityInfo = await ApplicationSettings.GetSettingFromXmlFileAsync <List <PageInfo> >(SettingKeys.PAGE_INFO, null); //patch: we nolonger use in storage settings anymore, just remove it for old versions ApplicationSettings.RemoveSetting(SettingKeys.CLIENT_DATA); ApplicationSettings.RemoveSetting(SettingKeys.EVENT_DATA); ApplicationSettings.RemoveSetting(SettingKeys.PAGE_INFO); try { string err_str = CrashListener.CheckForPreviousException(); ErrorInfo error = UmsJson.Deserialize <ErrorInfo>(err_str); if (error != null) { List <ErrorInfo> err_list = new List <ErrorInfo>(); err_list.Add(error); allinfo.errorInfo = err_list; } } catch (Exception e) { DebugTool.Log(e.Message); } ret = UmsJson.Serialize(allinfo); return(ret); }
internal static void ReportException(Exception ex, string extra) { try { ErrorInfo error = new ErrorInfo(); error.appkey = UmsManager.appkey; //error.stacktrace = ex.Message+"\r\n"+ex.StackTrace; error.stacktrace = ex.StackTrace == null ? "" : ex.StackTrace; error.time = Utility.getTime(); error.version = Utility.getApplicationVersion(); error.activity = Utility.getCurrentPageName(); error.deviceid = Utility.getDeviceName(); error.os_version = Utility.getOsVersion(); string str = UmsJson.Serialize(error); ApplicationSettings.SetSetting <string>(LAST_ERROR_LOG, str); } catch (Exception) { } }