Beispiel #1
0
        public async void TrackUser()
        {
            var metrics = new UserMetrics()
            {
                ApiKey = apiKey,
                User   = GetUserInfo(),
                App    = GetAppInfo(),
                System = GetSystemInfo(),
            };

            // Do the serialization and sending on the thread pool
            try {
                await Task.Factory.StartNew(async delegate {
                    var data = JsonConvert.SerializeObject(metrics);

                    var req = new HttpRequestMessage()
                    {
                        RequestUri = new Uri(baseUrl, "metrics"),
                        Method     = HttpMethod.Post,
                        Content    = new StringContent(data, System.Text.Encoding.UTF8, "application/json"),
                    };

                    await httpClient.SendAsync(req);
                }).ConfigureAwait(continueOnCapturedContext: false);
            } catch (Exception exc) {
                LogError(String.Format("Failed to track user: {0}", exc));
            }
        }
Beispiel #2
0
        public ActiveUserViewModel(UserMetrics metrics) : base(metrics)
        {
            Contract.Requires(metrics != null);

            this.MostActiveUsers = new List <MostActiveUsers>();

            foreach (var user in metrics.MostActiveUsers)
            {
                this.MostActiveUsers.Add(this.CreateUser(user));
            }
        }
Beispiel #3
0
    //called when drone is requested to be built
    public void QueueFinished(Transform home, EntityType type)
    {
        switch (type)
        {
        case EntityType.Droid:
            //add offset here
            Vector3 pos = new Vector3(Random.Range(-1.0f, 1.0f), spawnHeight, Random.Range(-1.0f, 1.0f));
            pos = pos.normalized * spawnRange;

            SpawnDroid(type, new Vector3(home.position.x + pos.x, pos.y, home.position.z + pos.z));
            //Instantiate(DroidPrefab, new Vector3(home.position.x + pos.x, pos.y, home.position.z + pos.z), Quaternion.identity);

            UserMetrics.DroidIncrease();
            break;

        default:
            Debug.Log("ERROR: DROID TYPE INVALID");
            break;
        }
    }
Beispiel #4
0
        public void TrackUser(UserMetrics metrics)
        {
            // Do the serialization and sending on the thread pool
            ThreadPool.QueueUserWorkItem(async delegate {
                try {
                    using (var httpClient = MakeHttpClient()) {
                        var data = JsonConvert.SerializeObject(metrics);

                        var req = new HttpRequestMessage()
                        {
                            RequestUri = new Uri(BaseUrl, "metrics"),
                            Method     = HttpMethod.Post,
                            Content    = new StringContent(data, Encoding.UTF8, "application/json"),
                        };

                        await httpClient.SendAsync(req);
                    }
                } catch (Exception exc) {
                    Log.WriteLine("Failed to track user: {0}", exc);
                }
            });
        }
Beispiel #5
0
        public UserMetrics GetUserMetrics(int projectId, DateRange dateRange, int count)
        {
            var result = new UserMetrics()
            {
                Project         = this.projectService.GetProject(projectId),
                ProjectList     = this.projectService.GetProjects(),
                MostActiveUsers = new List <ActiveUserInfo>()
            };

            using (this.unitOfWorkProvider.CreateUnitOfWork())
            {
                if (dateRange != null)
                {
                    IList <ActiveUser> usersList = this.statisticsProvider.GetActiveUsers(projectId, dateRange, count).ToList();

                    foreach (var user in usersList)
                    {
                        result.MostActiveUsers.Add(new ActiveUserInfo
                        {
                            Id               = user.Id,
                            Url              = this.vkUrlProvider.GetMemberProfileUrl((int)user.Id),
                            Name             = !string.IsNullOrWhiteSpace(user.UserName) ? user.UserName : "******",
                            NumberOfComments = user.CommentCount,
                            NumberOfLikes    = user.LikeCount,
                            NumberOfPosts    = user.PostCount,
                            NumberOfShares   = user.ShareCount,
                            Sum              = user.CommentCount + user.LikeCount + user.PostCount + user.ShareCount,
                            BirthDate        = new API.DTO.BirthDate(user.BirthDate.BirthYear, user.BirthDate.BirthMonth, user.BirthDate.BirthDay),
                            CityId           = user.CityId,
                            CountryId        = user.CountryId,
                            Education        = (API.DTO.EducationLevel)(int) user.Education,
                            Gender           = (API.DTO.Gender)(int) user.Gender
                        });
                    }
                }
            }
            return(result);
        }
Beispiel #6
0
    public void OnPrefabSelect(int prefab)
    {
        SelectionManager.Instance.OnPrefabCreation();
        Object.Destroy(prefabObject);

        switch (prefab)
        {
        case 1:
            prefabObject = (GameObject)Instantiate(turretPrefab);
            prefabType   = EntityType.Turret;
            UserMetrics.TurretIncrease();
            break;

        case 2:
            prefabObject = (GameObject)Instantiate(barracksPrefab);
            prefabType   = EntityType.Barracks;
            UserMetrics.BuildingIncrease();
            break;

        case 3:
            prefabObject = (GameObject)Instantiate(wallPrefab);
            prefabType   = EntityType.Wall;
            UserMetrics.BuildingIncrease();
            break;
        }
        //define the variable changes required for the prefab
        prefabObject.GetComponent <Collider>().enabled         = false;
        prefabObject.GetComponentInChildren <Canvas>().enabled = false;
        prefabObject.GetComponent <SelectableObject>().enabled = false;
        ((Behaviour)prefabObject.GetComponent("Halo")).enabled = false;
        if (prefabType == EntityType.Turret)
        {
            prefabObject.GetComponentInChildren <ParticleSystem>().Pause();
        }
        prefabObject.SetActive(true);
    }
Beispiel #7
0
    // Update is called once per frame
    void Update()
    {
        #region hotkeys
        if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.Z))
        {
            undo();
        }
        if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.Y))
        {
            redo();
        }
        if (Input.GetKeyDown(KeyCode.P))
        {
            Debug.Break();
        }
        if (Input.GetKey(KeyCode.LeftShift) && Input.GetKeyDown(KeyCode.Delete))
        {
            OnDeleteAll();
        }
        if (Input.GetKeyDown(KeyCode.Delete))
        {
            OnDelete();
        }
        if (Input.GetKeyDown(KeyCode.G))
        {
            OnUpgrade();
        }
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            OnPrefabSelect(1);
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            OnPrefabSelect(2);
        }
        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            OnPrefabSelect(3);
        }
        if (Input.GetKeyDown("escape"))
        {
            Application.Quit();
        }

        #endregion

        if (prefabObject != null && prefabObject.activeSelf)
        {
            prefabObject.GetComponent <Transform>().position =
                new Vector3(
                    SelectionManager.Instance.mousePosition.x,
                    SelectionManager.Instance.mousePosition.y + prefabObject.GetComponent <Transform>().localScale.y,
                    SelectionManager.Instance.mousePosition.z);
            //prefabObject.GetComponent<Transform>().position = SelectionManager.Instance.mousePosition;
        }
        UserMetrics.UpdateFile();

        if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            for (int counter = 0; counter < 100; counter++)
            {
                GameObject.Instantiate(DroidManager.Instance.DroidPrefab, new Vector3(0, 0, 0), Quaternion.identity);
            }
        }

        if (Input.GetKeyDown(KeyCode.Alpha5))
        {
            foreach (GameObject gameObject in ProfilingObjectPooling)
            {
                gameObject.SetActive(true);
            }
        }
    }
Beispiel #8
0
        public UserMetrics Users_GetUserMetrics(uint userId) {
            var ret = new UserMetrics();

            ret.CommentPosts = Catalog.NewQuery(
@" /* GetUserMetrics:Comment Posts */
	SELECT COUNT(*)
	FROM comments
	WHERE cmnt_poster_user_id = ?USERID
	AND cmnt_deleter_user_id IS NULL;")
    .With("USERID", userId)
    .ReadAsUInt() ?? 0;

            ret.DownRatings = Catalog.NewQuery(
@" /* GetUserMetrics:down ratings*/
    SELECT COUNT(*)
	FROM ratings
	WHERE rating_reset_timestamp IS NULL
	AND rating_user_id = ?USERID
	AND rating_score = 0;")
    .With("USERID", userId)
    .ReadAsUInt() ?? 0;

            ret.UpRatings = Catalog.NewQuery(
@" /* GetUserMetrics:up ratings */
    SELECT COUNT(*)
	FROM ratings
	WHERE rating_reset_timestamp IS NULL
	AND rating_user_id = ?USERID
	AND rating_score = 1;")
.With("USERID", userId)
.ReadAsUInt() ?? 0;

            ret.PagesCreated = Catalog.NewQuery(
@" /* GetUserMetrics:pages created */
   SELECT (
		SELECT COUNT(*) AS freshpages
		FROM pages
		WHERE page_revision = 1
		AND page_user_id = ?USERID
		) + ( 
		SELECT COUNT(*) AS oldinitialpages
		FROM `old`
		WHERE old_revision = 1
		AND old_user = ?USERID
		) AS pagescreated;")
.With("USERID", userId)
.ReadAsUInt() ?? 0;

            ret.PagesChanged = Catalog.NewQuery(
@" /* GetUserMetrics:pages changed */
	SELECT (
		SELECT COUNT(*) AS freshpages
		FROM pages
		WHERE page_user_id = ?USERID
		) + ( 
		SELECT COUNT(*) AS oldpages 
		FROM (
		SELECT old_page_id
		FROM `old`
		WHERE old_user = ?USERID
		GROUP BY old_page_id) p
		) AS pageschanges;")
.With("USERID", userId)
.ReadAsUInt() ?? 0;

            ret.FilesUploaded = Catalog.NewQuery(
@" /* GetUserMetrics:files uploaded*/
	SELECT COUNT(*)
	FROM resourcerevs
	JOIN resources
		ON res_id = resrev_res_id
	WHERE res_type = 2
	AND resourcerevs.resrev_user_id = ?USERID
	AND resourcerevs.resrev_change_mask & 1 = 1
	ORDER BY res_id;")
.With("USERID", userId)
.ReadAsUInt() ?? 0;

            return ret;
        }
Beispiel #9
0
        public UserMetrics Users_GetUserMetrics(uint userId)
        {
            var ret = new UserMetrics();

            ret.CommentPosts = Catalog.NewQuery(
                @" /* GetUserMetrics:Comment Posts */
	SELECT COUNT(*)
	FROM comments
	WHERE cmnt_poster_user_id = ?USERID
	AND cmnt_deleter_user_id IS NULL;"    )
                               .With("USERID", userId)
                               .ReadAsUInt() ?? 0;

            ret.DownRatings = Catalog.NewQuery(
                @" /* GetUserMetrics:down ratings*/
    SELECT COUNT(*)
	FROM ratings
	WHERE rating_reset_timestamp IS NULL
	AND rating_user_id = ?USERID
	AND rating_score = 0;"    )
                              .With("USERID", userId)
                              .ReadAsUInt() ?? 0;

            ret.UpRatings = Catalog.NewQuery(
                @" /* GetUserMetrics:up ratings */
    SELECT COUNT(*)
	FROM ratings
	WHERE rating_reset_timestamp IS NULL
	AND rating_user_id = ?USERID
	AND rating_score = 1;"    )
                            .With("USERID", userId)
                            .ReadAsUInt() ?? 0;

            ret.PagesCreated = Catalog.NewQuery(
                @" /* GetUserMetrics:pages created */
   SELECT (
		SELECT COUNT(*) AS freshpages
		FROM pages
		WHERE page_revision = 1
		AND page_user_id = ?USERID
		) + ( 
		SELECT COUNT(*) AS oldinitialpages
		FROM `old`
		WHERE old_revision = 1
		AND old_user = ?USERID
		) AS pagescreated;"        )
                               .With("USERID", userId)
                               .ReadAsUInt() ?? 0;

            ret.PagesChanged = Catalog.NewQuery(
                @" /* GetUserMetrics:pages changed */
	SELECT (
		SELECT COUNT(*) AS freshpages
		FROM pages
		WHERE page_user_id = ?USERID
		) + ( 
		SELECT COUNT(*) AS oldpages 
		FROM (
		SELECT old_page_id
		FROM `old`
		WHERE old_user = ?USERID
		GROUP BY old_page_id) p
		) AS pageschanges;"        )
                               .With("USERID", userId)
                               .ReadAsUInt() ?? 0;

            ret.FilesUploaded = Catalog.NewQuery(
                @" /* GetUserMetrics:files uploaded*/
	SELECT COUNT(*)
	FROM resourcerevs
	JOIN resources
		ON res_id = resrev_res_id
	WHERE res_type = 2
	AND resourcerevs.resrev_user_id = ?USERID
	AND resourcerevs.resrev_change_mask & 1 = 1
	ORDER BY res_id;"    )
                                .With("USERID", userId)
                                .ReadAsUInt() ?? 0;

            return(ret);
        }