Example #1
0
    public void SetArticle(VRShopArticle article)
    {
        if (article == assignedArticle)
        {
            return;
        }
        cartQuanity = DEFAULT_QUANTITY;

        articleName        = article.Name;
        articlePrice       = article.Price;
        articleDescription = article.Description;
        articleImage       = article.Thumbnail;
        assignedArticle    = article;

        UpdateName();
        UpdatePrice();
        UpdateDescription();
        UpdateImage();
        UpdateColor();
    }
    /////////////////////////////////////////////////

    public void SelectScreen(GameObject screen)
    {
        // Mark the previously selected screen as unselected to make it move back or hide it
        UnselectScreen();

        // Create a clone of the screen with visible backside (pretend that it's the same gameobject as the selected one)
        isArticleMonitor = screen.transform.parent.transform == transform;
        expandedScreen   = GameObject.Instantiate(screen, transform);
        if (isArticleMonitor)
        {
            selectedArticle = screen.GetComponent <ArticleMonitorWrapper>().GetArticle();
            expandedScreen.GetComponent <ArticleMonitorWrapper>().SetArticle(selectedArticle);
        }
        else
        {
            selectedArticle = null;
        }
        expandedScreen.tag = SCREEN_NOTSELECTABLE;
        SetBacksideActive(expandedScreen, true);

        // Rememeber the selected screen
        selectedScreen = screen;
        ShowScreen(screen, false);
    }
Example #3
0
    public static List <VRShopArticle> SearchForArticle(string searchString)
    {
        // Prepare return list
        List <VRShopArticle> queriedArticles = new List <VRShopArticle>();

        // Prevent empty searches
        if (searchString.Length > 0)
        {
            // Connect to the SQLite DB
            SqliteConnection dbConnection = new SqliteConnection(DATABASE_PATH);
            dbConnection.Open();

            // Prepare the query using the search keyword
            SqliteCommand query = dbConnection.CreateCommand();
            query.CommandType = CommandType.Text;
            query.CommandText = ARTICLE_SEARCH_QUERY;
            query.Parameters.AddWithValue(ARTICLE_SEARCH_STRING_PLACEHOLDER, string.Format("%{0}%", searchString));

            // Exectute the query and read the results
            var reader = query.ExecuteReader();

            // Initialize column ordinals
            int colId          = reader.GetOrdinal(S_COL_ID);
            int colName        = reader.GetOrdinal(S_COL_NAME);
            int colPrice       = reader.GetOrdinal(S_COL_PRICE);
            int colDescription = reader.GetOrdinal(S_COL_DESCRIPTION);
            int colThumbnail   = reader.GetOrdinal(S_COL_THUMBNAIL);
            int colSize        = reader.GetOrdinal(S_COL_SIZE);

            // Iterate through every returned row
            while (reader.Read())
            {
                int     id;
                string  articleName;
                decimal price;
                string  description = "";
                byte[]  img         = null;
                float?  size        = null;

                // NOT NULL constraint applies, null check therefore not required
                id          = reader.GetInt32(colId);
                articleName = reader.GetString(colName);
                price       = reader.GetDecimal(colPrice);

                // May be null, needs to be caught
                if (!reader.IsDBNull(colDescription))
                {
                    description = reader.GetString(colDescription);
                }

                if (!reader.IsDBNull(colThumbnail))
                {
                    img = (byte[])reader[colThumbnail];
                }

                if (!reader.IsDBNull(colSize))
                {
                    double dsize = reader.GetDouble(colSize);
                    size = (float)dsize;
                }

                // Add to result list
                VRShopArticle article = new VRShopArticle(id, price, articleName, description, img, size);
                queriedArticles.Add(article);
            }
            dbConnection.Close();
        }

        // Return results
        return(queriedArticles);
    }
Example #4
0
    public List <VRShopArticle> setWeatherAttributes(string searchStr)
    {
        StartCoroutine(getRequest());
        UnityWebRequest jsonString = GlobalControl.sendValFunc;

        //List<VRShopArticle> queriedArticles = AddComponents<List<VRShopArticle>>(tempObject);

        if (jsonString.isDone)
        {
            StopCoroutine(getRequest());
            //string jsonString = GlobalControl.sendValFunc;
            Debug.Log("Global Control Value below");
            //Debug.Log(jsonString);
            if (jsonString == null)
            {
                Debug.Log("globalcontrol value is not preserved");
            }
            else
            {
                Debug.Log("Value is Preserved");
            }

            //string jsonString = "";

            var weatherJson = JSON.Parse(jsonString.downloadHandler.text);
            Debug.Log("WeatherJson value below");
            Debug.Log(weatherJson);


            int     id;
            string  articleName;
            decimal price;
            string  description = "";
            string  img         = null;
            float?  size        = null;

            if (string.Equals(searchStr, "a"))
            {
                Debug.Log("You typed everything :" + searchStr);

                for (int i = 0; i < weatherJson.Count; i++)
                {
                    id          = Convert.ToInt32(weatherJson[i]["id"]);
                    articleName = weatherJson[i]["name"];
                    price       = Convert.ToDecimal(weatherJson[i]["price"]);
                    description = weatherJson[i]["description"];
                    img         = weatherJson[i]["thumbnail"];
                    size        = float.Parse(weatherJson[i]["scale_factor"]);

                    try
                    {
                        VRShopArticle article = new VRShopArticle(id, price, articleName, description, img, size);
                        tester.Add(article);
                    }

                    catch (Exception)
                    {
                    }
                }
                /*Debug.Log("These are queried :" + tester);*/
                return(tester);
            }

            else
            {
                Debug.Log("You typed " + searchStr);
                for (int i = 0; i < weatherJson.Count; i++)
                {
                    id          = Convert.ToInt32(weatherJson[i]["id"]);
                    articleName = weatherJson[i]["name"];
                    price       = Convert.ToDecimal(weatherJson[i]["price"]);
                    description = weatherJson[i]["description"];
                    img         = weatherJson[i]["thumbnail"];
                    size        = float.Parse(weatherJson[i]["scale_factor"]);

                    try
                    {
                        if ((articleName.Length > 0) && (description.Length > 0))
                        {
                            Debug.Log("<******************************************************>");
                            if ((articleName.Contains(searchStr)) || (description.Contains(searchStr)))
                            {
                                Debug.Log("<&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&>");

                                VRShopArticle article = new VRShopArticle(id, price, articleName, description, img, size);
                                tester.Add(article);
                                Debug.Log(weatherJson[i]);
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                }

/*                Debug.Log("Total queried values:" + tester.Count);
 *              Debug.Log("return value:" + tester);*/
                return(tester);
            }
        }
        else
        {
            print("Request is not complete....Wait sometime");
        }

        return(null);
    }