Ejemplo n.º 1
0
 /// <summary>
 /// Publish a count related event (e.g., plugin_total_count) to the Disa Android client.
 ///
 /// IMPORTANT: Note that this is internal so that only the Disa.Framework assembly can call this function.
 /// </summary>
 /// <param name="eventAction">The type safe representation of the Event Action.</param>
 /// <param name="eventCategory">The type safe representation of the Event Category.</param>
 /// <param name="customDimensionIndex">The type safe representation of the Custom Dimension Index.</param>
 /// <param name="count">The count to be associated with this Google Analytics event.</param>
 internal static void RaiseCountEvent(
     EventAction eventAction,
     EventCategory eventCategory,
     CustomDimensionIndex customDimensionIndex,
     int count)
 {
     CountEvent?.Invoke(eventAction, eventCategory, customDimensionIndex, count);
 }
        public static void OnEvent(JAnalytics.Event e)
        {
            int type = e.getType();

            switch (type)
            {
            case JAnalytics.Event.BrowseEventType:
                BrowseEvent browseEven     = (BrowseEvent)e;
                string      browseId       = browseEven.getBrowseId();
                string      browseName     = browseEven.getBrowseName();
                string      browseType     = browseEven.getBrowseType();
                long        browseDuration = browseEven.getBrowseDuration();
                OnBrowseEvent(browseId, browseName, browseType, browseDuration,
                              browseEven.getExtraDic());
                break;

            case JAnalytics.Event.CalculateEventType:
                CalculateEvent calculateEvent = (CalculateEvent)e;
                string         eventId        = calculateEvent.getEventId();
                double         eventValues    = calculateEvent.getEventValued();
                OnCalculateEvent(eventId, eventValues,
                                 calculateEvent.getExtraDic());
                break;

            case JAnalytics.Event.CountEventType:
                CountEvent countEvent = (CountEvent)e;
                OnCountEvent(countEvent.getEventId(),
                             countEvent.getExtraDic());
                break;

            case JAnalytics.Event.LoginEventType:
                LoginEvent loginEvent = (LoginEvent)e;
                OnLoginEvent(loginEvent.getLoginMethod(), loginEvent.geLoginSuccess(),
                             loginEvent.getExtraDic());
                break;

            case JAnalytics.Event.PurchaseEventType:
                PurchaseEvent purchaseEvent         = (PurchaseEvent)e;
                string        purchaseGoodsid       = purchaseEvent.getPurchaseGoodsid();
                string        purchaseGoodsName     = purchaseEvent.getPurchaseGoodsName();
                double        purchasePrice         = purchaseEvent.getPurchasePrice();
                bool          purchaseSuccess       = purchaseEvent.getPurchaseSuccess();
                int           purchaseCurrencyUnity = purchaseEvent.getPurchaseCurrencyInt();
                string        purchaseGoodsType     = purchaseEvent.getPurchaseGoodsType();
                int           purchaseGoodsCount    = purchaseEvent.getPurchaseGoodsCount();
                OnPurchaseEvent(purchaseGoodsid, purchaseGoodsName, purchasePrice,
                                purchaseSuccess, purchaseCurrencyUnity, purchaseGoodsType, purchaseGoodsCount,
                                purchaseEvent.getExtraDic());
                break;

            case JAnalytics.Event.RegisterEventType:
                RegisterEvent registerEvent = (RegisterEvent)e;
                OnRegisterEvent(registerEvent.getRegisterMethod(), registerEvent.getRegisterSuccess(), registerEvent.getExtraDic());
                break;
            }
        }
Ejemplo n.º 3
0
        private void GetFilesInfo()
        {
            DirectoryInfo   dirInfo = new DirectoryInfo(sourcePath);
            List <FileInfo> files   = dirInfo.GetFiles().ToList();

            totalCount = files.Count;
            CountEvent?.Invoke(totalCount);

            Adapter(files);
        }
Ejemplo n.º 4
0
        private Task[] CreateCounterTaskList4(uint mOldTaskid, uint mNewTaskid)
        {
            //服务端变化时请求任务(先删除老任务后增加新任务)
            List <Task> tasks = new List <Task>();
            //2.--删除老计数任务------------------------------------------------------------
            TaskSubscribeCounting MyOldTaskCount = new TaskSubscribeCounting();

            MyOldTaskCount.task_type           = TaskType.TASK_COUNT;
            MyOldTaskCount.serverTask_ID       = mOldTaskid;
            MyOldTaskCount.activity_state      = false;
            MyOldTaskCount.store_taskSpecified = false;
            MyOldTaskCount.store_task          = false;

            tasks.Add(MyOldTaskCount);

            //---增加新任务-------------------------------------------
            TaskSubscribeCounting MyTaskCount = new TaskSubscribeCounting();

            MyTaskCount.task_type           = TaskType.TASK_COUNT;
            MyTaskCount.serverTask_ID       = mNewTaskid;
            MyTaskCount.activity_state      = true;
            MyTaskCount.store_taskSpecified = true;
            MyTaskCount.store_task          = true;

            CountingGateID MyCountingGateID = new CountingGateID();

            MyCountingGateID.id          = "10";
            MyTaskCount.counting_gate_id = MyCountingGateID;

            CountEvent MyCountEvent = new CountEvent();

            MyCountEvent.count_event_type = CountEventType.COUNT_EVENT_DELTA_SUM_IN_OUT;
            MyCountEvent.delta            = 1;

            EventTrigger MyEventTrigger = new EventTrigger();

            MyEventTrigger.Item = MyCountEvent;

            Trigger MyTrigger = new Trigger();

            MyTrigger.Item = MyEventTrigger;

            MyTaskCount.trigger = MyTrigger;
            tasks.Add(MyTaskCount);



            return(tasks.ToArray());
        }
Ejemplo n.º 5
0
            /// <exception cref="InvalidOperationException">Maximum suspension depth has been exceeded.</exception>
            public Suspension([NotNull] CountEvent countEventForSuspensions)
            {
                Interlocked.Exchange(ref countEvent, countEventForSuspensions);

                try
                {
                    countEventForSuspensions.Increment();
                }
                catch
                {
                    Interlocked.Exchange(ref countEvent, null);

                    throw;
                }
            }
Ejemplo n.º 6
0
        public LogCastClient([NotNull] LogCastOptions options, [NotNull] IFallbackLogger fallbackLogger)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (fallbackLogger == null)
            {
                throw new ArgumentNullException(nameof(fallbackLogger));
            }

            if (options.Endpoint == null)
            {
                fallbackLogger.Write("Endpoint cannot be null reference");
                throw new ArgumentException("Endpoint can not be null reference", nameof(options));
            }
            if (options.Throttling < 10)
            {
                fallbackLogger.Write("Throttling cannot be less than 10");
                throw new ArgumentException("Throttling can not be less than 10", nameof(options));
            }

            _options        = options;
            _fallbackLogger = fallbackLogger;
            _queue          = new BlockingCollection <LogCastMessageFactory>();

            var sendingThreadCount = _options.SendingThreadCount;
            var threadCount        = sendingThreadCount > 0 ? sendingThreadCount : 4;

            _countEvent = new CountEvent();
            Threads     = Enumerable
                          .Range(0, threadCount)
                          .Select(i => new Thread(Sender)
            {
                IsBackground = true
            })
                          .ToArray();

            foreach (var thread in Threads)
            {
                thread.Start();
            }
        }
Ejemplo n.º 7
0
 public override void Arrange()
 {
     Sut = new CountEvent();
 }
 public static void Count(long counts, CountEvent e)
 {
     Interlocked.Add(ref _state.CountTotals[(int)e], counts);
 }
 public static long GetCounts(CountEvent e)
 {
     return(_state.CountTotals[(int)e]);
 }
Ejemplo n.º 10
0
        private Task[] CreateCounterTaskList3(uint mTaskid)
        {
            //启动时请求任务
            List <Task> tasks = new List <Task>();
            //2.--关于计数任务------------------------------------------------------------
            TaskSubscribeCounting MyTaskCount = new TaskSubscribeCounting();

            MyTaskCount.task_type           = TaskType.TASK_COUNT;
            MyTaskCount.serverTask_ID       = mTaskid;
            MyTaskCount.activity_state      = true;
            MyTaskCount.store_taskSpecified = true;
            MyTaskCount.store_task          = true;

            CountingGateID MyCountingGateID = new CountingGateID();

            MyCountingGateID.id          = "10";
            MyTaskCount.counting_gate_id = MyCountingGateID;

            CountEvent MyCountEvent = new CountEvent();

            MyCountEvent.count_event_type = CountEventType.COUNT_EVENT_DELTA_SUM_IN_OUT;
            MyCountEvent.delta            = 1;
            EventTrigger MyEventTrigger = new EventTrigger();

            MyEventTrigger.Item = MyCountEvent;

            Trigger MyTrigger = new Trigger();

            MyTrigger.Item = MyEventTrigger;

            MyTaskCount.trigger = MyTrigger;
            tasks.Add(MyTaskCount);

            //2.--关于心跳任务------------------------------------------------------------
            TaskSubscribeAlive MyTaskAlive = new TaskSubscribeAlive();

            MyTaskAlive.task_type           = TaskType.TASK_ALIVE;
            MyTaskAlive.serverTask_ID       = mTaskid;
            MyTaskAlive.activity_state      = true;
            MyTaskAlive.store_taskSpecified = true;
            MyTaskAlive.store_task          = true;

            Date MyDate = new Date();

            MyDate.kind = DateType.DATE_DONT_CARE;
            MyDate.day_of_monthSpecified = false;
            MyDate.day_of_weekSpecified  = false;

            ClockTime MyStartTime = new ClockTime();

            MyStartTime.hours   = 0;
            MyStartTime.minutes = 0;
            MyStartTime.seconds = 20;

            TimeTrigger MyTimeTrigger = new TimeTrigger();

            MyTimeTrigger.date          = MyDate;
            MyTimeTrigger.cycle         = "PT10M";
            MyTimeTrigger.random_offset = "PT0S";
            MyTimeTrigger.start         = MyStartTime;

            Trigger MyTrigger2 = new Trigger();

            MyTrigger2.Item     = MyTimeTrigger;
            MyTaskAlive.trigger = MyTrigger2;

            tasks.Add(MyTaskAlive);
            return(tasks.ToArray());
        }
Ejemplo n.º 11
0
        private Task[] CreateCounterTaskList2(NotificationBase notification)
        {
            List <Task> tasks = new List <Task>();

            if (notification is StartupNotification)
            {
                //2.--关于计数任务------------------------------------------------------------
                StartupNotification MyStartNotifi        = notification as StartupNotification;
                HellaAPCECOMannager MyHellaAPCECOManager = new HellaAPCECOMannager();
                HellaApcHelper      MyHellaApcHelper     = new HellaApcHelper(MyStartNotifi.customer_ID, "startup");
                uint GetTaskID = HellaApcHelper.DoUpdateWork(MyHellaAPCECOManager, MyHellaApcHelper);

                TaskSubscribeCounting MyTaskCount = new TaskSubscribeCounting();

                MyTaskCount.task_type           = TaskType.TASK_COUNT;
                MyTaskCount.serverTask_ID       = GetTaskID; //1000;
                MyTaskCount.activity_state      = true;
                MyTaskCount.store_taskSpecified = true;
                MyTaskCount.store_task          = true;

                CountingGateID MyCountingGateID = new CountingGateID();
                MyCountingGateID.id          = "10";
                MyTaskCount.counting_gate_id = MyCountingGateID;

                CountEvent MyCountEvent = new CountEvent();
                MyCountEvent.count_event_type = CountEventType.COUNT_EVENT_DELTA_SUM_IN_OUT;

                EventTrigger MyEventTrigger = new EventTrigger();
                MyEventTrigger.Item = MyCountEvent;

                Trigger MyTrigger = new Trigger();
                MyTrigger.Item = MyEventTrigger;

                MyTaskCount.trigger = MyTrigger;
                tasks.Add(MyTaskCount);

                //2.--关于心跳任务------------------------------------------------------------
                TaskSubscribeAlive MyTaskAlive = new TaskSubscribeAlive();
                MyTaskAlive.task_type           = TaskType.TASK_ALIVE;
                MyTaskAlive.serverTask_ID       = 100;// GetTaskID;
                MyTaskAlive.activity_state      = true;
                MyTaskAlive.store_taskSpecified = true;
                MyTaskAlive.store_task          = true;

                Date MyDate = new Date();
                MyDate.kind = DateType.DATE_DONT_CARE;
                MyDate.day_of_monthSpecified = false;
                MyDate.day_of_weekSpecified  = false;

                ClockTime MyStartTime = new ClockTime();
                MyStartTime.hours   = 0;
                MyStartTime.minutes = 0;
                MyStartTime.seconds = 20;

                TimeTrigger MyTimeTrigger = new TimeTrigger();
                MyTimeTrigger.date          = MyDate;
                MyTimeTrigger.cycle         = "PT10M";
                MyTimeTrigger.random_offset = "PT0S";
                MyTimeTrigger.start         = MyStartTime;

                Trigger MyTrigger2 = new Trigger();
                MyTrigger2.Item     = MyTimeTrigger;
                MyTaskAlive.trigger = MyTrigger2;

                tasks.Add(MyTaskAlive);

                //-----------------------------------------------------------------------------
            }

            if (notification is AliveNotification)
            {
                StartupNotification MyStartNotifi = notification as StartupNotification;

                HellaAPCECOMannager MyHellaAPCECOManager = new HellaAPCECOMannager();
                HellaApcHelper      MyHellaApcHelper     = new HellaApcHelper(MyStartNotifi.customer_ID, "keepalive");
                uint GetTaskID = HellaApcHelper.DoUpdateWork(MyHellaAPCECOManager, MyHellaApcHelper);


                TaskSubscribeCounting MyTaskCount = new TaskSubscribeCounting();

                MyTaskCount.task_type           = TaskType.TASK_COUNT;
                MyTaskCount.serverTask_ID       = GetTaskID; //1000;
                MyTaskCount.activity_state      = true;
                MyTaskCount.store_taskSpecified = true;
                MyTaskCount.store_task          = true;

                CountingGateID MyCountingGateID = new CountingGateID();
                MyCountingGateID.id          = "10";
                MyTaskCount.counting_gate_id = MyCountingGateID;

                CountEvent MyCountEvent = new CountEvent();
                MyCountEvent.count_event_type = CountEventType.COUNT_EVENT_DELTA_SUM_IN_OUT;

                EventTrigger MyEventTrigger = new EventTrigger();
                MyEventTrigger.Item = MyCountEvent;

                Trigger MyTrigger = new Trigger();
                MyTrigger.Item = MyEventTrigger;

                MyTaskCount.trigger = MyTrigger;

                tasks.Add(MyTaskCount);
            }

            return(tasks.ToArray());
        }
Ejemplo n.º 12
0
 private void onCountEvent(CountEvent eventParam)
 {
     counter = eventParam.counter;
 }
Ejemplo n.º 13
0
 public void Apply(CountEvent @event) => SeenEvents += 1;
Ejemplo n.º 14
0
 public string speak(object sender, CountEvent counter)
 {
     return("#" + counter.count + " pig : I am a pig\n");
 }
Ejemplo n.º 15
0
 public string speak(object sender, CountEvent counter)
 {
     return("#" + counter.count + " cat : I am a cat\n");
 }
Ejemplo n.º 16
0
    public static void OnGUI()
    {
        str_unity = GUILayout.TextField(str_unity, GUILayout.Width(Screen.width - 80),
                                        GUILayout.Height(100));
        if (GUILayout.Button("onPageStart", GUILayout.Height(80)))
        {
            JAnalyticsBinding.OnPageStart("testOnPage-1");
        }

        if (GUILayout.Button("onPageEnd", GUILayout.Height(80)))
        {
            JAnalyticsBinding.OnPageEnd("testOnPage-1");
        }

        if (GUILayout.Button("onPurchaseEvent", GUILayout.Height(80)))
        {
            string   purchaseGoodsid       = "goodsId";
            string   purchaseGoodsName     = "篮球";
            double   purchasePrice         = 300;
            bool     purchaseSuccess       = true;
            Currency purchaseCurrencyUnity = Currency.CNY;
            string   purchaseGoodsType     = "sport";
            int      purchaseGoodsCount    = 1;

            PurchaseEvent eEvent = new PurchaseEvent(purchaseGoodsid, purchaseGoodsName,
                                                     purchasePrice, purchaseSuccess, purchaseCurrencyUnity, purchaseGoodsType, purchaseGoodsCount);
            eEvent.addKeyValue("1", "a");
            eEvent.addKeyValue("2", "b");
            JAnalyticsBinding.OnEvent(eEvent);
        }


        if (GUILayout.Button("onBrowseEvent", GUILayout.Height(80)))
        {
            string browseId       = "browse_id";
            string browseName     = "深圳热点新闻";
            string browseType     = "news";
            long   browseDuration = 30;

            BrowseEvent eEvent = new BrowseEvent(browseId, browseName,
                                                 browseType, browseDuration);
            eEvent.addKeyValue("1", "a");
            eEvent.addKeyValue("2", "b");

            JAnalyticsBinding.OnEvent(eEvent);
        }

        if (GUILayout.Button("onRegisterEvent", GUILayout.Height(80)))
        {
            string registerMethod  = "sina";
            bool   registerSuccess = true;


            RegisterEvent eEvent = new RegisterEvent(registerMethod, registerSuccess);
            eEvent.addKeyValue("1", "a");
            eEvent.addKeyValue("2", "b");


            JAnalyticsBinding.OnEvent(eEvent);
        }

        if (GUILayout.Button("onLoginEvent", GUILayout.Height(80)))
        {
            string loginMethod  = "qq";
            bool   loginSuccess = true;

            LoginEvent eEvent = new LoginEvent(loginMethod, loginSuccess);
            eEvent.addKeyValue("1", "a");
            eEvent.addKeyValue("2", "b");

            JAnalyticsBinding.OnEvent(eEvent);
        }

        if (GUILayout.Button("onCalculateEvent", GUILayout.Height(80)))
        {
            string eventId    = "onCalculateEvent_event_id";
            double eventValue = 10.1;

            CalculateEvent eEvent = new CalculateEvent(eventId, eventValue);
            eEvent.addKeyValue("1", "a");
            eEvent.addKeyValue("2", "b");

            JAnalyticsBinding.OnEvent(eEvent);
        }

        if (GUILayout.Button("onCountEvent", GUILayout.Height(80)))
        {
            string eventId = "onCountEvent_event_id";

            CountEvent eEvent = new CountEvent(eventId);
            eEvent.addKeyValue("1", "a");
            eEvent.addKeyValue("2", "b");

            JAnalyticsBinding.OnEvent(eEvent);
        }



        if (GUILayout.Button("identifyAccount", GUILayout.Height(80)))
        {
            Account account = new Account("AccountAccount");
            account.SetName("nnnnn");


            account.SetExtraAttr("k1", "v1");
            account.SetExtraAttr("k2", null);

            int                sequence             = callbackId++;
            string             gameObjectNameBack   = gameObject.name;
            string             gameObjectMethodBack = "AccountCallBack";
            JAnalyticsCallBack callBack             = new JAnalyticsCallBack(sequence, gameObjectNameBack, gameObjectMethodBack);
            JAnalyticsBinding.IdentifyAccount(account, callBack);
        }

        if (GUILayout.Button("detachAccount", GUILayout.Height(80)))
        {
            int                sequence             = callbackId++;
            string             gameObjectNameBack   = gameObject.name;
            string             gameObjectMethodBack = "AccountCallBack";
            JAnalyticsCallBack callBack             = new JAnalyticsCallBack(sequence, gameObjectNameBack, gameObjectMethodBack);

            JAnalyticsBinding.DetachAccount(callBack);
        }

        if (GUILayout.Button("setAnalyticsReportPeriod", GUILayout.Height(80)))
        {
            int period = 30;
            JAnalyticsBinding.SetAnalyticsReportPeriod(period);
        }
    }