Example #1
0
        private List <CacheExtensionInfo> ResetCacheList()
        {
            ICacheInfo[] allCaches = CacheManager.GetAllCaches();

            Array.Sort(allCaches, new CacheComparer());

            var caches = new List <CacheExtensionInfo>();

            foreach (var cacheInfo in allCaches)
            {
                string index1 = "size_" + cacheInfo.Id.ToShortID();

                long num = MainUtil.GetLong(this.Request.Form[index1], 0L);

                caches.Add(new CacheExtensionInfo
                {
                    CacheIndex = index1,
                    CacheName  = cacheInfo.Name,
                    Count      = cacheInfo.Count.ToString(),
                    Size       = StringUtil.GetSizeString(cacheInfo.Size),
                    CacheDelta = cacheInfo.Size.ToString(),
                    MaxSize    = StringUtil.GetSizeString(cacheInfo.MaxSize),
                    Delta      = StringUtil.GetSizeString(cacheInfo.Size - num)
                });
            }

            var stats = CacheManager.GetStatistics();

            this.Size.Text    = $"Size: {stats.TotalSize}";
            this.Entries.Text = $"Entries: {stats.TotalCount}";

            return(caches);
        }
            private void LiteralControlDataBinding(object sender, EventArgs e)
            {
                var     target    = (Literal)sender;
                Control container = target.NamingContainer;
                var     dataItem  = DataBinder.GetDataItem(container) as BaseItem;

                if (dataItem != null)
                {
                    long fileSize = MainUtil.GetLong(dataItem[this.FieldName], 0);
                    if (dataItem is FolderItem)
                    {
                        target.Text = string.Empty;
                    }
                    else
                    {
                        target.Text = MainUtil.FormatSize(fileSize);
                    }
                }
            }
Example #3
0
        protected override object UploadInternal(NameValueCollection parameters, byte[] fileBytes, Item accountItem)
        {
            string fileName = this.GetFileName(parameters);

            var videoToUpload = new VideoToUpload
            {
                AssetType            = "video",
                ChunkSize            = MainUtil.GetLong(this.ChunkSize, 5000000),
                FileSize             = fileBytes.LongLength,
                FileName             = fileName,
                Name                 = Path.GetFileNameWithoutExtension(fileName),
                PostProcessingStatus = this.PostProcessingStatus
            };

            Video video = this.CreateVideo(accountItem, videoToUpload);

            if (video != null)
            {
                try
                {
                    var sended = this.SendContent(parameters, fileBytes, accountItem, video);
                    if (sended)
                    {
                        this.MarkAs(accountItem, video, "uploaded");
                        video.Status = "processing";
                        return(video);
                    }

                    this.DeleteVideo(accountItem, video);
                    return(new CanceledVideo());
                }
                catch (Exception)
                {
                    this.UpdateStatus(Guid.Empty, this.GetFileId(parameters), accountItem.ID.Guid, 0, "Uploading process failed. Please read logs for more details!");
                    this.MarkAs(accountItem, video, "failed");
                }
            }

            return(null);
        }
        /// <summary>
        ///  Entity From Item
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public virtual object CreateEntity(Item item)
        {
            Economics economics;

            DateTime creationDate;
            DateTime lastModifiedDate;
            DateTime publishedDate;

            Enum.TryParse(item[FieldIDs.Video.Economics], true, out economics);

            DateTime.TryParse(item[FieldIDs.Video.CreationDate], out creationDate);
            DateTime.TryParse(item[FieldIDs.Video.LastModifiedDate], out lastModifiedDate);
            DateTime.TryParse(item[FieldIDs.Video.PublishedDate], out publishedDate);

            return(new Video
            {
                Id = item[FieldIDs.MediaElement.Id],
                Economics = economics,
                ReferenceId = item[FieldIDs.MediaElement.ReferenceId],
                Name = item[FieldIDs.MediaElement.Name],
                Length = MainUtil.GetLong(item[FieldIDs.Video.Length], 0),
                CreationDate = creationDate,
                LastModifiedDate = lastModifiedDate,
                PublishedDate = publishedDate,
                LinkText = item[FieldIDs.Video.LinkText],
                LinkURL = item[FieldIDs.Video.LinkUrl],
                LongDescription = item[FieldIDs.Video.LongDescription],
                PlaysTotal = MainUtil.GetInt(item[FieldIDs.Video.PlaysTotal], 0),
                PlaysTrailingWeek = MainUtil.GetInt(item[FieldIDs.Video.PlaysTrailingWeek], 0),
                ShortDescription = item[FieldIDs.MediaElement.ShortDescription],
                ThumbnailUrl = item[FieldIDs.MediaElement.ThumbnailUrl],
                VideoStillURL = item[FieldIDs.Video.VideoStillUrl],
                Tags = this.GetValues(item.Fields[FieldIDs.Video.Tags], FieldIDs.Tag.Name),
                CustomFields = this.GetCustomFields(item.Fields[FieldIDs.Video.CustomFields])
            });
        }
Example #5
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            Assert.ArgumentNotNull((object)e, "e");
            base.OnLoad(e);
            if (XamlControl.AjaxScriptManager.IsEvent)
            {
                return;
            }
            this.ImageWidth  = 0;
            this.ImageHeight = 0;
            ItemUri uri = ItemUri.ParseQueryString();

            if (uri == (ItemUri)null)
            {
                return;
            }
            Item obj = Database.GetItem(uri);

            if (obj == null)
            {
                return;
            }
            string text = obj["Dimensions"];

            if (string.IsNullOrEmpty(text))
            {
                return;
            }
            int length = text.IndexOf('x');

            if (length < 0)
            {
                return;
            }
            this.ImageWidth  = MainUtil.GetInt(StringUtil.Left(text, length).Trim(), 0);
            this.ImageHeight = MainUtil.GetInt(StringUtil.Mid(text, length + 1).Trim(), 0);
            if (this.ImageWidth <= 0 || this.ImageHeight <= 0)
            {
                this.Aspect.Checked  = false;
                this.Aspect.Disabled = true;
            }
            else
            {
                this.Aspect.Checked = true;
            }
            if (this.ImageWidth > 0)
            {
                this.OriginalSize.Text = Translate.Text("Original Dimensions: {0} x {1}", (object)this.ImageWidth, (object)this.ImageHeight);
            }

            if (MainUtil.GetLong((object)obj["Size"], 0L) >= Settings.Media.MaxSizeInMemory)
            {
                this.HeightEdit.Enabled = false;
                this.WidthEdit.Enabled  = false;
                this.Aspect.Disabled    = true;
            }
            else
            {
                this.SizeWarning.Visible = false;
            }
            this.OriginalText.Text = StringUtil.GetString(new string[2]
            {
                obj["Alt"],
                Translate.Text("[none]")
            });
            UrlHandle urlHandle = UrlHandle.Get();
            XmlValue  xmlValue  = new XmlValue(urlHandle["xmlvalue"], "image");

            this.XmlValue        = xmlValue;
            this.Alt.Text        = xmlValue.GetAttribute("alt");
            this.HeightEdit.Text = xmlValue.GetAttribute("height");
            this.WidthEdit.Text  = xmlValue.GetAttribute("width");
            this.HSpace.Text     = xmlValue.GetAttribute("hspace");
            this.VSpace.Text     = xmlValue.GetAttribute("vspace");
            this.Img.ImageUrl    = this.GetMediaUrl(obj);
            this.Img.Height      = imageHeight;

            this.OriginalWidth.Value  = obj["Width"];
            this.OriginalHeight.Value = obj["Height"];

            this.X1.Text = this.GetCoordinateValue(xmlValue, "x1");
            this.X2.Text = this.GetCoordinateValue(xmlValue, "x2");
            this.Y1.Text = this.GetCoordinateValue(xmlValue, "y1");
            this.Y2.Text = this.GetCoordinateValue(xmlValue, "y2");

            this.Ratio.Value = xmlValue.GetAttribute("ratio");
            if (!string.IsNullOrWhiteSpace(this.Ratio.Value))
            {
                HeightEdit.Enabled      = false;
                WidthEdit.Enabled       = false;
                CroppingOptions.Visible = false;
            }

            if (MainUtil.GetBool(urlHandle["disableheight"], false))
            {
                this.HeightEdit.Enabled = false;
                this.Aspect.Checked     = false;
                this.Aspect.Disabled    = true;
            }

            if (!string.IsNullOrEmpty(this.GetCoordinateValue(xmlValue, "x2")))
            {
                var croppedWidth  = Math.Round((decimal)(int.Parse(this.GetCoordinateValue(xmlValue, "x2")) - int.Parse(this.GetCoordinateValue(xmlValue, "x1"))));
                var croppedHeight = Math.Round((decimal)(int.Parse(this.GetCoordinateValue(xmlValue, "y2")) - int.Parse(this.GetCoordinateValue(xmlValue, "y1"))));

                //var str3 = xmlValue.GetAttribute("width");
                //var str4 = xmlValue.GetAttribute("height");

                //if (string.IsNullOrEmpty(str3) || string.IsNullOrEmpty(str4))
                //{
                //    str3 = croppedWidth.ToString();
                //    str4 = croppedHeight.ToString();
                //}
                //else
                //{
                //    str3 = Math.Round((decimal)croppedWidth * int.Parse(str4) / croppedHeight).ToString();
                //}
                this.CroppedSize.Text = Translate.Text("Cropped Dimensions before resizing: {0} x {1}", (object)croppedWidth, (object)croppedHeight);
            }

            if (!MainUtil.GetBool(urlHandle["disablewidth"], false))
            {
                return;
            }
            this.WidthEdit.Enabled = false;
            this.Aspect.Checked    = false;
            this.Aspect.Disabled   = true;
        }