Exemple #1
0
    private void _BindCityContents(int cityId)
    {
        DataSet ds = objAdmin.GetCityContents(cityId);

        if (ds != null && ds.Tables.Count > 0)
        {
            if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
            {
                txtLatitude.Text  = ds.Tables[0].Rows[0]["lat"].ToString().Replace(",", ".");
                txtLongitude.Text = ds.Tables[0].Rows[0]["long"].ToString().Replace(",", ".");
                lblCityInfo.Text  = ds.Tables[0].Rows[0]["CityInfo"].ToString().Replace(System.Environment.NewLine, "<br/>");

                if (ds.Tables[0].Rows[0]["VideoURL"].ToString() != "")
                {
                    string code = ds.Tables[0].Rows[0]["VideoURL"].ToString().Split('=')[1];
                    string url  = "https://www.youtube.com/embed/" + code;// +"?autoplay=1";
                    ifrm.Attributes["src"] = url;
                }
            }
            if (ds.Tables[1] != null && ds.Tables[1].Rows.Count > 0)
            {
                dlPictures.DataSource = ds.Tables[1];
                dlPictures.DataBind();
            }
        }
    }
    private void _BindCityContents(int cityId)
    {
        try
        {
            DataSet   ds       = objAdmin.GetCityContents(cityId);
            DataTable CityInfo = objAdmin.GetParticipatingCityInfo(cityId);

            if (CityInfo.Rows.Count > 0)
            {
                float FromCitylat = float.Parse(CityInfo.Rows[0]["lat"].ToString());
                float FromCitylon = float.Parse(CityInfo.Rows[0]["long"].ToString());
                BindMap(FromCitylat, FromCitylon, CityInfo.Rows[0]["CityName"].ToString());
            }

            string targetPath = Request.MapPath(@"~\\Pictures");

            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    txtCityInfo.Text = ds.Tables[0].Rows[0]["CityInfo"].ToString();
                    txtVideoUrl.Text = ds.Tables[0].Rows[0]["VideoURL"].ToString();

                    if (txtVideoUrl.Text != "")
                    {
                        string code = txtVideoUrl.Text.Split('=')[1];
                        string url  = "https://www.youtube.com/embed/" + code;// +"?autoplay=1";
                        ifrm.Attributes["src"] = url;
                        div_Video.Visible      = true;
                    }
                }
                if (ds.Tables[1] != null && ds.Tables[1].Rows.Count > 0)
                {
                    dtImages = ds.Tables[1];
                    dlPictures.DataSource = dtImages;
                    dlPictures.DataBind();

                    if (Directory.Exists(Request.MapPath("~\\Pictures\\City\\" + cityId)))
                    {
                        DirectoryInfo di            = new DirectoryInfo(Request.MapPath("~\\Pictures\\City\\" + cityId));
                        FileInfo[]    files         = null;
                        string        searchPattern = "*.*";
                        files = di.GetFiles(searchPattern, SearchOption.TopDirectoryOnly);

                        if (files != null)
                        {
                            foreach (FileInfo f in files)
                            {
                                if ((dtImages.Select("ImageName='" + f.Name + "'")).Length == 0)
                                {
                                    //f.Delete();
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (Directory.Exists(Request.MapPath("~\\Pictures\\City\\" + cityId)))
                    {
                        DirectoryInfo di = new DirectoryInfo(Request.MapPath("~\\Pictures\\City\\" + cityId));
                        di.Delete(true);
                    }
                }
            }
        }
        catch (Exception ex)
        {}
    }