Beispiel #1
0
        private string errorData2jsonstr(ErrorInfo obj)
        {
            string ret = "";

            ret = UmsJson.Serialize(obj);
            return(ret);
        }
Beispiel #2
0
        private string eventData2jsonstr(Event obj)
        {
            string ret = "";

            ret = UmsJson.Serialize(obj);
            return(ret);
        }
Beispiel #3
0
        //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);
        }
Beispiel #4
0
        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);
            }
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        //save crash info when app crash
        public void crashDataProceed(ApplicationUnhandledExceptionEventArgs ex, string flag = "ums crash")
        {
            Exception e                       = ex.ExceptionObject;
            string    err_title               = e.Message == null ? "" : e.Message;
            string    err_stack_trace         = e.StackTrace == null ? "" : e.StackTrace;
            string    error_title_statcktrace = err_title + "\r\n" + err_stack_trace;

            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.getDeviceName();
            error.os_version = Utility.getOsVersion();
            string error_info = UmsJson.Serialize(error);

            CrashListener.ReportException(error_info, flag);
        }
Beispiel #7
0
        //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);
        }
Beispiel #8
0
        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)
            { }
        }