示例#1
0
        private static async Task <bool> CollectGoogleAnalyticsAsync(Dictionary <string, string> dict)
        {
            try
            {
                DetailListener?.Invoke($"CollectGoogleAnalyticsAsync{Environment.NewLine}{dict.ToFormatTableString()}");
                string postStr = NetHelper.UrlEncode(dict);
                var    result  = await NetLegacy.PostAsync(GAURL, postStr);

                return(result != null);
            }
            catch (Exception e)
            {
                Log.Error(e, true);
                return(false);
            }
        }
示例#2
0
        private static async Task <bool> BatchCollectGoogleAnalyticsAsync(IEnumerable <Dictionary <string, string> > batchData)
        {
            try
            {
                DetailListener?.Invoke($"BatchCollectGoogleAnalyticsAsync{Environment.NewLine}{batchData.JoinToString(o => o.ToFormatTableString(), Environment.NewLine)}");
                string batchStr = "";
                foreach (var dict in batchData)
                {
                    batchStr += "\n" + NetHelper.UrlEncode(dict);
                }
                if (batchStr.Length > 1)
                {
                    batchStr = batchStr.Substring(1);
                }
                var result = await NetLegacy.PostAsync(GABATCHURL, batchStr);

                return(result != null);
            }
            catch (Exception e)
            {
                Log.Error(e, true);
                return(false);
            }
        }