private string ExportAssetCSVLine(IAsset asset, bool detailed, bool localtime)
        {
            List <string> linec = new List <string>();

            linec.Add(asset.Name);
            linec.Add(asset.Id);
            linec.Add(localtime ? asset.LastModified.ToLocalTime().ToString() : asset.LastModified.ToString());
            linec.Add(AssetInfo.GetAssetType(asset));
            linec.Add(AssetInfo.GetSize(asset).ToString());
            var urls = AssetInfo.GetURIs(asset);

            if (urls != null && urls.Count() > 0)
            {
                foreach (var url in urls)
                {
                    linec.Add(url != null ? url.ToString() : string.Empty);
                }
            }
            else
            {
                for (int i = 0; i < _context.StreamingEndpoints.Count(); i++)
                {
                    linec.Add(string.Empty);
                }
            }

            var streamlocators = asset.Locators.Where(l => l.Type == LocatorType.OnDemandOrigin);

            if (streamlocators.Any())
            {
                if (localtime)
                {
                    linec.Add(streamlocators.Max(l => l.ExpirationDateTime).ToLocalTime().ToString());
                }
                else
                {
                    linec.Add(streamlocators.Max(l => l.ExpirationDateTime).ToString());
                }
            }
            else
            {
                linec.Add(string.Empty);
            }


            // SAS locator
            var saslocators = asset.Locators.Where(l => l.Type == LocatorType.Sas);
            var saslocator  = saslocators.ToList().OrderByDescending(l => l.ExpirationDateTime).FirstOrDefault();

            if (saslocator != null && asset.AssetFiles.Count() > 0)
            {
                if (asset.AssetFiles.Count() == 1)
                {
                    var ProgressiveDownloadUri = asset.AssetFiles.FirstOrDefault().GetSasUri(saslocator);
                    linec.Add(ProgressiveDownloadUri.AbsoluteUri);
                }
                else
                {
                    linec.Add(saslocator.Path);
                }

                if (localtime)
                {
                    linec.Add(saslocator.ExpirationDateTime.ToLocalTime().ToString());
                }
                else
                {
                    linec.Add(saslocator.ExpirationDateTime.ToString());
                }
            }
            else
            {
                linec.Add(string.Empty);
                linec.Add(string.Empty);
            }


            if (detailed)
            {
                linec.Add(asset.AlternateId);
                linec.Add(asset.StorageAccount.Name);
                linec.Add(asset.Uri == null ? string.Empty : asset.Uri.ToString());
                var streamingloc = asset.Locators.Where(l => l.Type == LocatorType.OnDemandOrigin);
                linec.Add(streamingloc.Count().ToString());
                if (localtime)
                {
                    linec.Add(streamingloc.Any() ? streamingloc.Min(l => l.ExpirationDateTime).ToLocalTime().ToString() : null);
                    linec.Add(streamingloc.Any() ? streamingloc.Max(l => l.ExpirationDateTime).ToLocalTime().ToString() : null);
                }
                else
                {
                    linec.Add(streamingloc.Any() ? streamingloc.Min(l => l.ExpirationDateTime).ToString() : null);
                    linec.Add(streamingloc.Any() ? streamingloc.Max(l => l.ExpirationDateTime).ToString() : null);
                }

                // SAS
                linec.Add(saslocators.Count().ToString());
                if (localtime)
                {
                    linec.Add(saslocators.Any() ? saslocators.Min(l => l.ExpirationDateTime).ToLocalTime().ToString() : null);
                    linec.Add(saslocators.Any() ? saslocators.Max(l => l.ExpirationDateTime).ToLocalTime().ToString() : null);
                }
                else
                {
                    linec.Add(saslocators.Any() ? saslocators.Min(l => l.ExpirationDateTime).ToString() : null);
                    linec.Add(saslocators.Any() ? saslocators.Max(l => l.ExpirationDateTime).ToString() : null);
                }

                linec.Add(asset.GetEncryptionState(AssetDeliveryProtocol.SmoothStreaming | AssetDeliveryProtocol.HLS | AssetDeliveryProtocol.Dash).ToString());
                linec.Add(asset.AssetFilters.Count().ToString());
            }

            return(convertCSVLine(linec));
        }
        private void ExportAssetExcel(IAsset asset, Excel.Worksheet xlWorkSheet, int row, bool detailed, bool localtime)
        {
            int index = 1;

            xlWorkSheet.Cells[row, index++] = asset.Name;
            xlWorkSheet.Cells[row, index++] = asset.Id;
            xlWorkSheet.Cells[row, index++] = localtime ? asset.LastModified.ToLocalTime() : asset.LastModified;
            xlWorkSheet.Cells[row, index++] = AssetInfo.GetAssetType(asset);
            xlWorkSheet.Cells[row, index++] = AssetInfo.GetSize(asset);
            int backindex = index;
            var urls      = AssetInfo.GetURIs(asset);

            if (urls != null)
            {
                foreach (var url in urls)
                {
                    xlWorkSheet.Cells[row, index++] = url != null?url.ToString() : string.Empty;
                }
            }
            index = backindex + _context.StreamingEndpoints.Count();
            var streamlocators = asset.Locators.Where(l => l.Type == LocatorType.OnDemandOrigin);

            if (streamlocators.Any())
            {
                if (localtime)
                {
                    xlWorkSheet.Cells[row, index++] = (DateTime?)streamlocators.Max(l => l.ExpirationDateTime).ToLocalTime();
                }
                else
                {
                    xlWorkSheet.Cells[row, index++] = (DateTime?)streamlocators.Max(l => l.ExpirationDateTime);
                }
            }
            else
            {
                xlWorkSheet.Cells[row, index++] = string.Empty;
            }


            // SAS locator
            var saslocators = asset.Locators.Where(l => l.Type == LocatorType.Sas);
            var saslocator  = saslocators.ToList().OrderByDescending(l => l.ExpirationDateTime).FirstOrDefault();

            if (saslocator != null && asset.AssetFiles.Count() > 0)
            {
                if (asset.AssetFiles.Count() == 1)
                {
                    var ProgressiveDownloadUri = asset.AssetFiles.FirstOrDefault().GetSasUri(saslocator);
                    xlWorkSheet.Cells[row, index++] = ProgressiveDownloadUri.AbsoluteUri;
                }
                else
                {
                    xlWorkSheet.Cells[row, index++] = saslocator.Path;
                }

                if (localtime)
                {
                    xlWorkSheet.Cells[row, index++] = saslocator.ExpirationDateTime.ToLocalTime();
                }
                else
                {
                    xlWorkSheet.Cells[row, index++] = saslocator.ExpirationDateTime;
                }
            }
            else
            {
                xlWorkSheet.Cells[row, index++] = string.Empty;
                xlWorkSheet.Cells[row, index++] = string.Empty;
            }


            if (detailed)
            {
                xlWorkSheet.Cells[row, index++] = asset.AlternateId;
                xlWorkSheet.Cells[row, index++] = asset.StorageAccount.Name;
                xlWorkSheet.Cells[row, index++] = asset.Uri == null ? string.Empty : asset.Uri.ToString();
                var streamingloc = asset.Locators.Where(l => l.Type == LocatorType.OnDemandOrigin);
                xlWorkSheet.Cells[row, index++] = streamingloc.Count();
                if (localtime)
                {
                    xlWorkSheet.Cells[row, index++] = streamingloc.Any() ? (DateTime?)streamingloc.Min(l => l.ExpirationDateTime).ToLocalTime() : null;
                    xlWorkSheet.Cells[row, index++] = streamingloc.Any() ? (DateTime?)streamingloc.Max(l => l.ExpirationDateTime).ToLocalTime() : null;
                }
                else
                {
                    xlWorkSheet.Cells[row, index++] = streamingloc.Any() ? (DateTime?)streamingloc.Min(l => l.ExpirationDateTime) : null;
                    xlWorkSheet.Cells[row, index++] = streamingloc.Any() ? (DateTime?)streamingloc.Max(l => l.ExpirationDateTime) : null;
                }

                // SAS
                xlWorkSheet.Cells[row, index++] = saslocators.Count();
                if (localtime)
                {
                    xlWorkSheet.Cells[row, index++] = saslocators.Any() ? (DateTime?)saslocators.Min(l => l.ExpirationDateTime).ToLocalTime() : null;
                    xlWorkSheet.Cells[row, index++] = saslocators.Any() ? (DateTime?)saslocators.Max(l => l.ExpirationDateTime).ToLocalTime() : null;
                }
                else
                {
                    xlWorkSheet.Cells[row, index++] = saslocators.Any() ? (DateTime?)saslocators.Min(l => l.ExpirationDateTime) : null;
                    xlWorkSheet.Cells[row, index++] = saslocators.Any() ? (DateTime?)saslocators.Max(l => l.ExpirationDateTime) : null;
                }

                xlWorkSheet.Cells[row, index++] = asset.GetEncryptionState(AssetDeliveryProtocol.SmoothStreaming | AssetDeliveryProtocol.HLS | AssetDeliveryProtocol.Dash).ToString();
                xlWorkSheet.Cells[row, index++] = asset.AssetFilters.Count().ToString();
            }
        }
Esempio n. 3
0
        private void ExportAssetExcel(IAsset asset, Excel.Worksheet xlWorkSheet, int row, bool detailed, bool localtime)
        {
            int index = 1;

            xlWorkSheet.Cells[row, index++] = asset.Name;
            xlWorkSheet.Cells[row, index++] = asset.Id;
            xlWorkSheet.Cells[row, index++] = localtime ? asset.LastModified.ToLocalTime() : asset.LastModified;
            xlWorkSheet.Cells[row, index++] = AssetInfo.GetAssetType(asset);
            xlWorkSheet.Cells[row, index++] = AssetInfo.GetSize(asset);
            int backindex = index;
            var urls      = AssetInfo.GetURIs(asset);

            if (urls != null)
            {
                foreach (var url in urls)
                {
                    xlWorkSheet.Cells[row, index++] = url != null?url.ToString() : string.Empty;
                }
            }
            index = backindex + _context.StreamingEndpoints.Count();
            if (localtime)
            {
                xlWorkSheet.Cells[row, index++] = asset.Locators.Any() ? (DateTime?)asset.Locators.Max(l => l.ExpirationDateTime).ToLocalTime() : null;
            }
            else
            {
                xlWorkSheet.Cells[row, index++] = asset.Locators.Any() ? (DateTime?)asset.Locators.Max(l => l.ExpirationDateTime) : null;
            }

            if (detailed)
            {
                xlWorkSheet.Cells[row, index++] = asset.AlternateId;
                xlWorkSheet.Cells[row, index++] = asset.StorageAccount.Name;
                xlWorkSheet.Cells[row, index++] = asset.Uri == null ? string.Empty : asset.Uri.ToString();
                var streamingloc = asset.Locators.Where(l => l.Type == LocatorType.OnDemandOrigin);
                xlWorkSheet.Cells[row, index++] = streamingloc.Count();
                if (localtime)
                {
                    xlWorkSheet.Cells[row, index++] = streamingloc.Any() ? (DateTime?)streamingloc.Min(l => l.ExpirationDateTime).ToLocalTime() : null;
                    xlWorkSheet.Cells[row, index++] = streamingloc.Any() ? (DateTime?)streamingloc.Max(l => l.ExpirationDateTime).ToLocalTime() : null;
                }
                else
                {
                    xlWorkSheet.Cells[row, index++] = streamingloc.Any() ? (DateTime?)streamingloc.Min(l => l.ExpirationDateTime) : null;
                    xlWorkSheet.Cells[row, index++] = streamingloc.Any() ? (DateTime?)streamingloc.Max(l => l.ExpirationDateTime) : null;
                }

                var sasloc = asset.Locators.Where(l => l.Type == LocatorType.Sas);
                xlWorkSheet.Cells[row, index++] = sasloc.Count();
                if (localtime)
                {
                    xlWorkSheet.Cells[row, index++] = sasloc.Any() ? (DateTime?)sasloc.Min(l => l.ExpirationDateTime).ToLocalTime() : null;
                    xlWorkSheet.Cells[row, index++] = sasloc.Any() ? (DateTime?)sasloc.Max(l => l.ExpirationDateTime).ToLocalTime() : null;
                }
                else
                {
                    xlWorkSheet.Cells[row, index++] = sasloc.Any() ? (DateTime?)sasloc.Min(l => l.ExpirationDateTime) : null;
                    xlWorkSheet.Cells[row, index++] = sasloc.Any() ? (DateTime?)sasloc.Max(l => l.ExpirationDateTime) : null;
                }

                xlWorkSheet.Cells[row, index++] = asset.GetEncryptionState(AssetDeliveryProtocol.SmoothStreaming | AssetDeliveryProtocol.HLS | AssetDeliveryProtocol.Dash).ToString();
                xlWorkSheet.Cells[row, index++] = asset.AssetFilters.Count().ToString();
            }
        }