/// <summary>
        /// Method for sending the motivation values to the tracker
        /// </summary>
        internal void sendMotivationValuesToTracker()
        {
            //get the tracker
            if (tracker == null)
            {
                if (AssetManager.Instance.findAssetsByClass("TrackerAsset").Count >= 1)
                {
                    tracker = (TrackerAsset)AssetManager.Instance.findAssetsByClass("TrackerAsset")[0];
                    loggingMAs("Found tracker for tracking motivation values!");
                }
                else
                {
                    //no tracking
                    loggingMAs("No tracker implemented - motivational state is not send to the server");
                    return;
                }
            }

            if (tracker.CheckHealth())
            {
                loggingMAs(tracker.Health);
                MotivationAssessmentAssetSettings maas = (MotivationAssessmentAssetSettings)getMAsA().Settings;
                if (tracker.Login(maas.TrackerName, maas.TrackerPassword))
                {
                    loggingMAs("logged in - tracker");
                }
                else
                {
                    loggingMAs("Maybe you forgot to store name/password for the tracker to the Motivation Assessment Asset Settings.");
                }
            }

            if (tracker.Connected)
            {
                tracker.Start();
                Dictionary <string, double> ms = getMotivationState().getMotivation();
                foreach (string motivationAspect in ms.Keys)
                {
                    tracker.setVar(motivationAspect, ms[motivationAspect].ToString());
                }
                tracker.Completable.Completed("MotivationAssessmentAsset");

#if !PORTABLE
                new Thread(() =>
                {
                    //next line: thread is killed after all foreground threads are dead
                    Thread.CurrentThread.IsBackground = true;
                    tracker.Flush();
                }).Start();
#else
                tracker.Flush();
#endif
            }
            else
            {
                loggingMAs("Not connected to tracker.");
            }
        }
Пример #2
0
        public void Initialize()
        {
            Debug.Print("-------");

            settings.Secure   = true;
            settings.Host     = "127.0.0.1";
            settings.Port     = 443;
            settings.BasePath = "/api/";

            settings.UserToken    = "";
            settings.TrackingCode = "";
            settings.StorageType  = TrackerAsset.StorageTypes.local;
            settings.TraceFormat  = TrackerAsset.TraceFormats.csv;
            settings.BatchSize    = 10;

            asset.Settings = settings;

            asset.Bridge = new TrackerAssetUnitTests.TesterBridge();
            storage      = (IDataStorage)asset.Bridge;
            asset.Start();
        }