Exemplo n.º 1
0
        public string[] GetMediaFile(int FileId)
        {
            Uri    requestUri = Context.Request.Url;
            string baseUrl    = requestUri.Scheme + Uri.SchemeDelimiter + requestUri.Host + (requestUri.IsDefaultPort ? "" : ":" + requestUri.Port);

            MediaFiles media_obj = new MediaFiles();
            DataTable  dt        = media_obj.GetDetailById(FileId);
            string     Title     = dt.Rows[0]["Title"].ToString();
            string     FileName  = dt.Rows[0]["FileName"].ToString();
            string     FileUrl   = dt.Rows[0]["FileUrl"].ToString();
            string     Photo     = dt.Rows[0]["Photo"].ToString();
            string     Thumbnail = dt.Rows[0]["Photo"].ToString();
            int        TypeId    = Convert.ToInt32(dt.Rows[0]["TypeId"].ToString());

            //====MediaType=================================================================
            MediaTypes media_type_obj = new MediaTypes();
            string     TypePath       = media_type_obj.GetTypePathByTypeId(TypeId);
            //==============================================================================

            //string dir_path = Server.MapPath("~/" + TypePath);

            string file_path = baseUrl + "/" + TypePath + "/" + FileName;

            string dir_image_path = System.Configuration.ConfigurationManager.AppSettings["upload_media_image_dir"];
            string image          = "";

            if (Photo != string.Empty)
            {
                image = baseUrl + "/" + dir_image_path + "/photo/" + Photo;
            }
            if (Photo == string.Empty)
            {
                image = baseUrl + "/" + dir_image_path + "/thumbnails/" + Thumbnail;
            }
            if (Photo == string.Empty && Thumbnail == string.Empty)
            {
                image = baseUrl + "/images/no_image.jpg";
            }


            string[] array_list = new string[3];
            array_list[0] = Title;
            if (FileName != string.Empty && FileUrl == string.Empty)
            {
                array_list[1] = file_path;
            }
            else
            {
                array_list[1] = FileUrl;
            }
            array_list[2] = image;
            return(array_list);
        }