Ejemplo n.º 1
0
        public void QueueEvents(List <Countly.CountlyEvent> Events)
        {
            string data = "";

            data += "app_key=" + AppKey;
            data += "&" + "device_id=" + DeviceInfo.getUDID();
            data += "&" + "events=" + JsonConvert.SerializeObject(Events, Formatting.None, new JsonSerializerSettings()
            {
                NullValueHandling = NullValueHandling.Ignore, ContractResolver = new CamelCasePropertyNamesContractResolver()
            });

            //bool First1 = true;
            //foreach(Countly.CountlyEvent CurrentEvent in Events)
            //{
            //    if (First1)
            //    {
            //        First1 = false;
            //    }
            //    else
            //    {
            //        data += ",";
            //    }
            //    data += "{";
            //    data += "\"" + "key" + "\"" + ":" + "\"" + CurrentEvent.Key + "\"" + ",";
            //    data += "\"" + "count" + "\"" + ":" + CurrentEvent.Count;
            //    if (CurrentEvent.UsingSum)
            //    {
            //        data += ",";
            //        data += "\"" + "sum" + "\"" + ":" + CurrentEvent.Sum;
            //    }
            //    if (CurrentEvent.UsingSegmentation)
            //    {
            //        data += ",";
            //        data += "\"" + "segmentation" + "\"" + ":" + "{";

            //        bool First2 = true;
            //        foreach (String CurrentKey in CurrentEvent.Segmentation.Keys)
            //        {
            //            if (First2)
            //            {
            //                First2 = false;
            //            }
            //            else
            //            {
            //                data += ",";
            //            }
            //            data += "\"" + CurrentKey + "\"" + ":" + "\"" + CurrentEvent.Segmentation[CurrentKey] + "\"";
            //        }

            //        data += "}";
            //    }
            //    data += "}";
            //}

            //data += "]";

            queue.Enqueue(data);
        }
Ejemplo n.º 2
0
        public void updateSession(int duration)
        {
            string data;

            data  = "app_key=" + AppKey;
            data += "&" + "device_id=" + DeviceInfo.getUDID();
            data += "&" + "session_duration=" + duration;

            queue.Enqueue(data);

            Tick();
        }
Ejemplo n.º 3
0
        public void beginSession()
        {
            string data;

            data  = "app_key=" + AppKey;
            data += "&" + "device_id=" + DeviceInfo.getUDID();
            data += "&" + "sdk_version=" + "1.0";
            data += "&" + "begin_session=" + "1";
            data += "&" + "metrics=" + DeviceInfo.getMetrics();

            queue.Enqueue(data);

            Tick();
        }
Ejemplo n.º 4
0
        public void QueueEvents(List <Countly.CountlyEvent> Events)
        {
            string data = "";

            data += "app_key=" + AppKey;
            data += "&" + "device_id=" + DeviceInfo.getUDID();
            data += "&" + "events=" + "[";

            foreach (Countly.CountlyEvent CurrentEvent in Events)
            {
                data += "{";
                data += "\"" + "key" + "\"" + ":" + "\"" + CurrentEvent.Key + "\"" + ",";
                data += "\"" + "count" + "\"" + ":" + CurrentEvent.Count;
                if (CurrentEvent.UsingSum)
                {
                    data += ",";
                    data += "\"" + "sum" + "\"" + ":" + CurrentEvent.Sum;
                }
                if (CurrentEvent.UsingSegmentation)
                {
                    data += ",";
                    data += "\"" + "segmentation" + "\"" + ":" + "{";

                    bool First = true;
                    foreach (String CurrentKey in CurrentEvent.Segmentation.Keys)
                    {
                        if (First)
                        {
                            First = false;
                        }
                        else
                        {
                            data += ",";
                        }
                        data += "\"" + CurrentKey + "\"" + ":" + "\"" + CurrentEvent.Segmentation[CurrentKey] + "\"";
                    }

                    data += "}";
                }
                data += "}";
            }

            data += "]";

            queue.Enqueue(data);
        }
Ejemplo n.º 5
0
        public void endSession(int duration)
        {
            string data;

            data  = "app_key=" + AppKey;
            data += "&" + "device_id=" + DeviceInfo.getUDID();
            data += "&" + "end_session=" + "1";
            data += "&" + "session_duration=" + duration;

            queue.Enqueue(data);

            Tick();
            //thread.Join();

            /*
             * StopThread = true;
             * if (null != thread && ThreadState.Unstarted != thread.ThreadState)
             * {
             *  thread.Join();
             * }
             *
             * ManualResetEvent Continue = new ManualResetEvent(false);
             *
             * foreach (String CurrentQuery in queue)
             * {
             *  try
             *  {
             *      WebClient Downloader = new WebClient();
             *      Downloader.OpenReadCompleted += new OpenReadCompletedEventHandler((object sender, OpenReadCompletedEventArgs args) =>
             *          {
             *              try
             *              {
             *                  if (null != args.Error)
             *                  {
             *                      throw args.Error;
             *                  }
             *
             #if (DEBUG)
             *                  Debug.WriteLine("Countly:\t" + "ok -> " + CurrentQuery);
             #endif
             *              }
             *              catch (Exception E)
             *              {
             *              }
             *              finally
             *              {
             *                  if (null != args.Result)
             *                  {
             *                      args.Result.Close();
             *                  }
             *
             *                  Continue.Set();
             *              }
             *          });
             *      Downloader.OpenReadAsync(new Uri(ServerURL + "/i?" + CurrentQuery, UriKind.Absolute));
             *      Continue.WaitOne();
             *  }
             *  catch (Exception E)
             *  {
             #if (DEBUG)
             #endif
             *  }
             *  finally
             *  {
             *      Continue.Reset();
             *  }
             * }
             */
        }
Ejemplo n.º 6
0
        public void endSession(int duration)
        {
            string data;

            data  = "app_key=" + AppKey;
            data += "&" + "device_id=" + DeviceInfo.getUDID();
            data += "&" + "end_session=" + "1";
            data += "&" + "session_duration=" + duration;

            queue.Enqueue(data);
            Tick();

            //ManualResetEvent Restart = new ManualResetEvent(false);

            //ThreadPool.QueueUserWorkItem((o) =>
            //    {
            //        HttpWebRequest Request = WebRequest.CreateHttp(ServerURL + "/i?" + data);

            //        Request.BeginGetResponse(new AsyncCallback((Async) =>
            //            {
            //                HttpWebResponse Responce = (HttpWebResponse)((HttpWebRequest)Async.AsyncState).EndGetResponse(Async);
            //                String s = (new StreamReader(Responce.GetResponseStream())).ReadToEnd();
            //                Restart.Set();
            //            }), Request);
            //    });
            //Restart.WaitOne();

            //Tick();
            //thread.Join();

            /*
             * StopThread = true;
             * if (null != thread && ThreadState.Unstarted != thread.ThreadState)
             * {
             *  thread.Join();
             * }
             *
             * ManualResetEvent Continue = new ManualResetEvent(false);
             *
             * foreach (String CurrentQuery in queue)
             * {
             *  try
             *  {
             *      WebClient Downloader = new WebClient();
             *      Downloader.OpenReadCompleted += new OpenReadCompletedEventHandler((object sender, OpenReadCompletedEventArgs args) =>
             *          {
             *              try
             *              {
             *                  if (null != args.Error)
             *                  {
             *                      throw args.Error;
             *                  }
             *
             #if (DEBUG)
             *                  Debug.WriteLine("Countly:\t" + "ok -> " + CurrentQuery);
             #endif
             *              }
             *              catch (Exception E)
             *              {
             *              }
             *              finally
             *              {
             *                  if (null != args.Result)
             *                  {
             *                      args.Result.Close();
             *                  }
             *
             *                  Continue.Set();
             *              }
             *          });
             *      Downloader.OpenReadAsync(new Uri(ServerURL + "/i?" + CurrentQuery, UriKind.Absolute));
             *      Continue.WaitOne();
             *  }
             *  catch (Exception E)
             *  {
             #if (DEBUG)
             #endif
             *  }
             *  finally
             *  {
             *      Continue.Reset();
             *  }
             * }
             */
        }