Esempio n. 1
0
        public static List <NewsStruct> selectAll()
        {
            List <NewsStruct> SDML = new List <NewsStruct>();

            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = connection;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "GET_NEWS";

                connection.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    NewsStruct SDM = new NewsStruct();
                    SDM.ID             = (long)reader["ID"];
                    SDM.Headline       = (string)reader["Headline"];
                    SDM.FullNewsLink   = (string)reader["FullNewsLink"];
                    SDM.NewsContent    = (string)reader["NewsContent"];
                    SDM.Source         = (string)reader["Source"];
                    SDM.DateTimeUpdate = (DateTime)reader["DateTimeUpdate"];
                    SDML.Add(SDM);
                }



                connection.Close();
            }
            return(SDML);
        }
Esempio n. 2
0
    private void ShowNews()
    {
        BottomMenu.SetActive(false);
        choosenNews = thisRT.gameObject.GetComponentInParent <NewsStruct>();
        initNews    = Instantiate(newsPrefab, MENU.transform);

        fullPage = initNews.GetComponent <FullNewsPage>();
        fullPage.mainImage.sprite = choosenNews.mainImage.sprite;
        fullPage.mainText.text    = choosenNews.headerText.text;
        fullPage.backButton.onClick.AddListener(StartGetBack);

        fullPage.UpdatePage(choosenNews.link);

        Vector3 needsPos = new Vector3(-1080, 0, 0f);

        initNews.transform.localPosition = needsPos;
        StartCoroutine(GoToScreen());
    }
Esempio n. 3
0
    public void CreatePrefabs()
    {
        for (int i = 0; i < objectList.Count - 1; i++)
        {
            tableTags[i] = Regex.Split((string)objectList[i], @"(?<=[>])");
            prefabs[i]   = Instantiate(tablePrefab, tablePrefab.transform.localPosition, Quaternion.identity, content.transform);
        }

        for (int i = 0; i < objectList.Count - 1; i++)
        {
            prefabContent = prefabs[i].GetComponent <NewsStruct>();

            for (int j = 0; j < tableTags[i].Length; j++)
            {
                if (tableTags[i][j].Contains("banner block-banner"))
                {
                    continue;
                }

                if (tableTags[i][j].Contains("href")) // link
                {
                    string[] temp = Regex.Split(tableTags[i][j], "href=\"");
                    string   dis  = temp[1].Substring(0, temp[1].Length - 2);
                    prefabContent.link = dis;
                }

                if (tableTags[i][j].Contains("item-news-bg")) // Main Image
                {
                    string[] temp = Regex.Split(tableTags[i][j], "http");
                    string   link = "http" + temp[1];
                    link = link.Substring(0, link.Length - 4);

                    byte[]    image   = webSite.DownloadData(link);
                    Texture2D texture = new Texture2D(350, 300);
                    texture.LoadImage(image);
                    Sprite mySprite = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100.0f);

                    prefabContent.mainImage.sprite = mySprite;
                }

                if (tableTags[i][j].Contains("icon-discipline")) // Discipline
                {
                    string[] temp = Regex.Split(tableTags[i][j], "data-game=\"");
                    string   dis  = temp[1].Substring(0, temp[1].Length - 2);

                    ChangeSprite(prefabContent.gameImage, dis);
                }

                if (tableTags[i][j].Contains("header-item-news")) // Header Text
                {
                    string temp = tableTags[i][j + 1];
                    temp = temp.Substring(0, temp.Length - 7);

                    prefabContent.headerText.text = temp;
                }

                if (tableTags[i][j].Contains("description-news")) // Description
                {
                    string temp = tableTags[i][j + 1];
                    temp = temp.Substring(0, temp.Length - 7);

                    prefabContent.contentText.text = temp;
                }

                if (tableTags[i][j].Contains("data-news")) // Time
                {
                    string temp = tableTags[i][j + 1];
                    string time = temp.Substring(0, temp.Length - 7);

                    prefabContent.timeText.text = time;
                }
            }
        }
    }