Exemplo n.º 1
0
    // ==============================================================================

    public void Update()
    {
        if (Input.GetKeyDown(KeyCode.R))
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }

        if (Input.GetKeyDown(KeyCode.S))
        {
            TestSendViewingData();
        }

        if (target_vrAdCanvas.AdIsShowing)
        {
            // print stats on screen every 5 frames whilst ad is showing
            ViewDataRequest viewStat = target_vrAdCanvas.MovieQuad.GetViewingData();
            if (viewStat != null && Time.frameCount % 5 == 0)
            {
                debugText.text =
                    //"developer_id = "+communicator.randomAdRequest.developer_id+"\n"+
                    //"developer_access_token = "+communicator.randomAdRequest.developer_access_token+"\n"+
                    //"developer_game_id = "+communicator.randomAdRequest.developer_game_id+"\n"+
                    "url_media = " + target_vrAdCanvas.CurrentVreoResponse.result.str_MediaURL + "\n" +
                    "type_media_format = " + target_vrAdCanvas.CurrentVreoResponse.result.str_MediaTypeName + "\n" +
                    "type_media_format_ids = " + target_vrAdCanvas.CurrentVreoResponse.result.ID_MediaType.ToString() + "\n" +
                    //"device_id = "+communicator.randomAdRequest.device_id+"\n"+
                    "total_hit_time = " + viewStat.dec_TotalHitTime.ToString("F1") + "\n" +
                    "total_screen_percentage = " + viewStat.dec_TotalScreenPercentage.ToString("F1") + "\n" +
                    "total_blocked_percentage = " + viewStat.dec_TotalBlockedPercentage.ToString("F1") + "\n" +
                    "position  = " + (viewStat.dec_TotalScreenPositionX).ToString("F1") + ", " + (viewStat.dec_TotalScreenPositionY).ToString("F1") + "\n" +
                    "total_volume_percentage = " + viewStat.dec_TotalVolumePercentage.ToString("F1") + "\n";
            }
        }
    }
Exemplo n.º 2
0
        public IHttpActionResult GetViewData([FromUri] ViewDataRequest request)
        {
            try
            {
                var responsesBulk = _viewDataServices.GetViewData(request);
                if (responsesBulk == null)
                {
                    return(Content(HttpStatusCode.OK, $"Could not find any information for survey : {request.SurveyID}"));
                }
                else
                {
                    if ((responsesBulk.Data == null) || !responsesBulk.Data.Any())
                    {
                        return(Content(HttpStatusCode.OK, $"Could not find any responses for survey id : {request.SurveyID}"));
                    }
                    var amberflagImage = $"<img src='{request.ImagePath}/flag_yellow.png' />";
                    var redflagImage   = $"<img src='{request.ImagePath}/flag_red.png' />";
                    foreach (var row in responsesBulk.Data)
                    {
                        var amberFlagColumnIndex      = 4;
                        var redFlagColumnIndex        = 3;
                        var amberFlagImageColumnIndex = 6;
                        var redFlagImageColumnIndex   = 5;
                        if ((amberFlagColumnIndex != -1) && (amberFlagImageColumnIndex != -1))
                        {
                            row[amberFlagImageColumnIndex] = row[amberFlagColumnIndex].ToLower() == "1" ? amberflagImage : string.Empty;
                        }
                        if ((redFlagColumnIndex != -1) && (redFlagImageColumnIndex != -1))
                        {
                            row[redFlagImageColumnIndex] = row[redFlagColumnIndex].ToLower() == "1" ? redflagImage : string.Empty;
                        }
                    }
                    var questionColumns = responsesBulk.Columns.Select(x => new TableColumn {
                        Title = (x.Title == "RedFlagImage") ? "Red Flag" : (x.Title == "AmberFlagImage") ? "Amber Flag" : x.Title, ToolTip = x.ToolTip, Width = "10 %"
                    }).ToArray();

                    // Set column width
                    questionColumns[0].Width = "3%";    // ID
                    questionColumns[1].Width = "5%";    // Date
                    questionColumns[3].Width = "2%";    // RedFlag
                    questionColumns[4].Width = "2%";    // AmberFlag
                    questionColumns[5].Width = "1%";    // RedFlagImage
                    questionColumns[6].Width = "1%";    // AmberFlagImage

                    var evenWidth = 80 / (questionColumns.Count() - 7);
                    // SystemData Column
                    questionColumns[2].Width = string.Format("{0}%", 100 - (80 + 14));

                    for (int i = 7; i < questionColumns.Count(); i++)
                    {
                        questionColumns[i].Width = string.Format("{0}%", evenWidth);
                    }
                    var firstSixColumns = questionColumns.Where(x => !questionColumns.Take(6).Contains(x));
                    var hiddenColumns   = new List <string>()
                    {
                        "RedFlag", "AmberFlag"
                    };

                    return(Ok(
                               new
                    {
                        Columns = questionColumns
                                  .Select(x => new { title = x.Title, width = x.Width, className = !firstSixColumns.Contains(x) ? "dt-center" : "", visible = !hiddenColumns.Contains(x.Title), tooltip = x.ToolTip })
                                  .ToArray(),
                        Data = responsesBulk.Data
                    }));
                }
            }
            catch (Exception ex)
            {
                _fileLogger.LogError(ex);
            }
            return(Content(HttpStatusCode.OK, "No data found"));
        }
Exemplo n.º 3
0
    // ==============================================================================

    public void TestSendViewingData()
    {
        ViewDataRequest viewStat = target_vrAdCanvas.MovieQuad.GetViewingData();

        communicator.SendViewData(viewStat);
    }
Exemplo n.º 4
0
        public ViewDataMessage GetViewData(ViewDataRequest request)
        {
            var columns         = new List <SurveyResponseColumn>();
            var data            = new List <string[]>();
            var parameters      = DataHelper.BuildParameters(request);
            var dtResponseData  = HaloDatabase.GetDataTable("dbo.GetViewData", parameters.ToArray());
            var amberFlagPrompt = GetAmberPrompt(request.SurveyID);

            if (dtResponseData.Rows.Count > 0)
            {
                foreach (DataRow dRow in dtResponseData.Rows)
                {
                    var rowArray = new string[dtResponseData.Columns.Count];
                    int index    = 0;
                    foreach (DataColumn dcol in dtResponseData.Columns)
                    {
                        rowArray[index] = dRow[dcol.ColumnName].ToString();
                        index++;
                    }
                    data.Add(rowArray);
                }

                foreach (DataColumn dcol in dtResponseData.Columns)
                {
                    var colName = (dcol.ColumnName.IndexOf("?") != -1) ? dcol.ColumnName.Substring(0, dcol.ColumnName.IndexOf("?")) : dcol.ColumnName;
                    colName = (colName.IndexOf(":") != -1) ? colName.Substring(0, colName.IndexOf(":")) : colName;
                    var strPrompt = string.Empty;
                    strPrompt = (dcol.ColumnName.IndexOf("?") != -1) ? dcol.ColumnName.Substring(dcol.ColumnName.IndexOf("?") + 1, dcol.ColumnName.Length - (dcol.ColumnName.IndexOf("?") + 1)).Trim() : dcol.ColumnName;
                    //TODO: REFACTOR UGLY CODE YUCK!
                    var promptID = 0;
                    if (!Int32.TryParse(strPrompt, out promptID))
                    {
                        strPrompt = (dcol.ColumnName.IndexOf(":") != -1) ? dcol.ColumnName.Substring(dcol.ColumnName.IndexOf(":") + 1, dcol.ColumnName.Length - (dcol.ColumnName.IndexOf(":") + 1)).Trim() : dcol.ColumnName;
                        if (!Int32.TryParse(strPrompt, out promptID))
                        {
                            promptID = 0;
                        }
                    }
                    var prompt = string.Empty;
                    if (promptID > 0)
                    {
                        var prompts = GetPromptsByPromptID(promptID);
                        if (prompts.Count() > 0)
                        {
                            prompt = prompts.Where(p => p.PromptID == promptID).FirstOrDefault().Prompt;
                            var promptArray = prompt.Split(new string[1] {
                                "||"
                            }, StringSplitOptions.None);
                            if (promptArray.Length == 2)
                            {
                                prompt = promptArray[1];
                            }
                        }
                    }
                    if ((colName.ToLower() == "amberflagimage") && !string.IsNullOrEmpty(amberFlagPrompt.Prompt))
                    {
                        var amberPromptArray = amberFlagPrompt.Prompt.Split(new string[1] {
                            "||"
                        }, StringSplitOptions.None);
                        prompt = amberPromptArray.Count() < 2 ? prompt : amberPromptArray[1];
                    }
                    columns.Add(new SurveyResponseColumn {
                        Title = colName, ToolTip = string.IsNullOrEmpty(prompt) ? colName : prompt
                    });
                }
            }
            return(new ViewDataMessage {
                Columns = columns, Data = data
            });
        }