コード例 #1
0
        public async Task RefreshStreamingEndpointAsync(StreamingEndpoint streamingEndpoint)
        {
            int index = -1;

            foreach (StreamingEndpointEntry CE in _MyObservStreamingEndpoints) // let's search for index
            {
                if (CE.Id == streamingEndpoint.Id)
                {
                    index = _MyObservStreamingEndpoints.IndexOf(CE);
                    break;
                }
            }

            if (index >= 0) // we found it
            {               // we update the observation collection
                await _client.RefreshTokenIfNeededAsync();

                streamingEndpoint = await _client.AMSclient.StreamingEndpoints.GetAsync(_client.credentialsEntry.ResourceGroup, _client.credentialsEntry.AccountName, streamingEndpoint.Name); //refresh

                if (streamingEndpoint != null)
                {
                    _MyObservStreamingEndpoints[index].State        = (StreamingEndpointResourceState)streamingEndpoint.ResourceState;
                    _MyObservStreamingEndpoints[index].Description  = streamingEndpoint.Description;
                    _MyObservStreamingEndpoints[index].LastModified = ((DateTime)streamingEndpoint.LastModified).ToLocalTime();
                    _MyObservStreamingEndpoints[index].Type         = StreamingEndpointInformation.ReturnTypeSE(streamingEndpoint);
                    _MyObservStreamingEndpoints[index].CDN          = ((bool)streamingEndpoint.CdnEnabled) ? StreamingEndpointInformation.ReturnDisplayedProvider(streamingEndpoint.CdnProvider) ?? "CDN" : string.Empty;
                    _MyObservStreamingEndpoints[index].ScaleUnits   = StreamingEndpointInformation.ReturnTypeSE(streamingEndpoint) != StreamingEndpointInformation.StreamEndpointType.Premium ? string.Empty : ((int)streamingEndpoint.ScaleUnits).ToString();
                    this.BeginInvoke(new Action(() => this.Refresh()));
                }
            }
        }
コード例 #2
0
        public async Task RefreshTransformsAsync() // all transforms are refreshed
        {
            if (!_initialized)
            {
                return;
            }

            Debug.WriteLine("Refresh Transforms Start");

            BeginInvoke(new Action(() => FindForm().Cursor = Cursors.WaitCursor));

            await _amsClient.RefreshTokenIfNeededAsync();

            IEnumerable <Task <TransformEntryV3> > transforms = (await _amsClient.AMSclient.Transforms.ListAsync(_amsClient.credentialsEntry.ResourceGroup, _amsClient.credentialsEntry.AccountName)).Select(async a => new TransformEntryV3(_context)
            {
                Name         = a.Name,
                Description  = a.Description,
                Outputs      = a.Outputs.Count,
                Jobs         = (await _amsClient.AMSclient.Jobs.ListAsync(_amsClient.credentialsEntry.ResourceGroup, _amsClient.credentialsEntry.AccountName, a.Name)).Count(),
                LastModified = a.LastModified.ToLocalTime().ToString("G")
            }
                                                                                                                                                                                                             );

            TransformEntryV3[] mappedItems = await Task.WhenAll(transforms);

            _MyObservTransformsV3 = new BindingList <TransformEntryV3>(mappedItems);

            BeginInvoke(new Action(() => DataSource = _MyObservTransformsV3));

            Debug.WriteLine("RefreshTransforms End");

            BeginInvoke(new Action(() => FindForm().Cursor = Cursors.Default));
        }
        public async Task RefreshLiveEventAsync(int pagetodisplay) // all assets are refreshed
        {
            if (!_initialized)
            {
                return;
            }

            this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.WaitCursor));

            await _client.RefreshTokenIfNeededAsync();

            var listLE = await _client.AMSclient.LiveEvents.ListAsync(_client.credentialsEntry.ResourceGroup, _client.credentialsEntry.AccountName);

            totalLiveEvents = listLE.Count();

            var channelquery = listLE.Select(c =>
                                             new LiveEventEntry
            {
                Name           = c.Name,
                Description    = c.Description,
                InputProtocol  = string.Format("{0} ({1})", c.Input.StreamingProtocol.ToString() /*Program.ReturnNameForProtocol(c.Input.StreamingProtocol)*/, c.Input.Endpoints.Count),
                Encoding       = ReturnChannelBitmap(c),
                EncodingPreset = (c.Encoding != null && c.Encoding.EncodingType != LiveEventEncodingType.None) ? c.Encoding.PresetName : string.Empty,
                InputUrl       = c.Input.Endpoints.Count > 0 ? c.Input.Endpoints.FirstOrDefault().Url : string.Empty,
                PreviewUrl     = c.Preview.Endpoints.Count > 0 ? c.Preview.Endpoints.FirstOrDefault().Url : string.Empty,
                State          = c.ResourceState,
                LastModified   = c.LastModified != null ? (DateTime?)((DateTime)c.LastModified).ToLocalTime() : null
            }
                                             );

            _MyObservLiveEvent = new SortableBindingList <LiveEventEntry>(channelquery.ToList());
            this.BeginInvoke(new Action(() => this.DataSource = _MyObservLiveEvent));
            _refreshedatleastonetime = true;
            this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.Default));
        }
コード例 #4
0
        public async Task RefreshTransformsAsync() // all transforms are refreshed
        {
            if (!_initialized)
            {
                return;
            }

            Debug.WriteLine("Refresh Transforms Start");

            BeginInvoke(new Action(() => FindForm().Cursor = Cursors.WaitCursor));

            await _client.RefreshTokenIfNeededAsync();

            IEnumerable <TransformEntryV3> transforms = (await _client.AMSclient.Transforms.ListAsync(_client.credentialsEntry.ResourceGroup, _client.credentialsEntry.AccountName)).Select(a => new TransformEntryV3
            {
                Name         = a.Name,
                Description  = a.Description,
                LastModified = a.LastModified.ToLocalTime().ToString("G")
            }
                                                                                                                                                                                            );

            _MyObservTransformsV3 = new BindingList <TransformEntryV3>(transforms.ToList());

            BeginInvoke(new Action(() => DataSource = _MyObservTransformsV3));

            Debug.WriteLine("RefreshTransforms End");

            BeginInvoke(new Action(() => FindForm().Cursor = Cursors.Default));
        }
コード例 #5
0
        private async void BathUploadFrame2_LoadAsync(object sender, EventArgs e)
        {
            DpiUtils.InitPerMonitorDpi(this);

            // to scale the bitmap in the buttons
            HighDpiHelper.AdjustControlImagesDpiScale(panel1);

            if (ErrorConnect)
            {
                Close();
            }
            await _client.RefreshTokenIfNeededAsync();

            foreach (StorageAccount storage in (await _client.AMSclient.Mediaservices.GetAsync(_client.credentialsEntry.ResourceGroup, _client.credentialsEntry.AccountName)).StorageAccounts)
            {
                string sname   = AMSClientV3.GetStorageName(storage.Id);
                bool   primary = (storage.Type == StorageAccountType.Primary);
                comboBoxStorage.Items.Add(new Item(string.Format("{0} {1}", sname, primary ? "(primary)" : ""), sname));
                if (primary)
                {
                    comboBoxStorage.SelectedIndex = comboBoxStorage.Items.Count - 1;
                }
            }

            List <int> listInt = new List <int>()
            {
                1, 2, 4, 8, 16, 32, 64
            };

            comboBoxBlockSize.Items.Clear();
            listInt.ForEach(l => comboBoxBlockSize.Items.Add(l.ToString()));
            comboBoxBlockSize.SelectedIndex = 3;
        }
コード例 #6
0
        private async Task LoadTransformsAsync()
        {
            await _client.RefreshTokenIfNeededAsync();

            _transforms = await _client.AMSclient.Transforms.ListAsync(_client.credentialsEntry.ResourceGroup, _client.credentialsEntry.AccountName);

            BeginUpdate();
            Items.Clear();

            foreach (Transform transform in _transforms)
            {
                ListViewItem item = new ListViewItem(transform.Name);
                item.SubItems.Add(transform.Description);
                item.SubItems.Add(transform.LastModified.ToLocalTime().ToString("G"));
                if (_selectedTransformName == transform.Name)
                {
                    item.Selected = true;
                }
                Items.Add(item);
            }
            AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            EndUpdate();
        }
コード例 #7
0
        private async Task ControlsResetToDefaultAsync()
        {
            await _amsClientV3.RefreshTokenIfNeededAsync();

            IList <StorageAccount> storAccounts = (await _amsClientV3.AMSclient.Mediaservices.GetAsync(_amsClientV3.credentialsEntry.ResourceGroup, _amsClientV3.credentialsEntry.AccountName)).StorageAccounts;

            comboBoxStorage.Items.Clear();
            foreach (StorageAccount storage in storAccounts)
            {
                string sname   = AMSClientV3.GetStorageName(storage.Id);
                bool   primary = (storage.Type == StorageAccountType.Primary);
                comboBoxStorage.Items.Add(new Item(string.Format("{0} {1}", sname, primary ? "(primary)" : string.Empty), sname));
                if (primary)
                {
                    comboBoxStorage.SelectedIndex = comboBoxStorage.Items.Count - 1;
                }
            }
        }
コード例 #8
0
        private async Task LoadAssetsAsync()
        {
            await _client.RefreshTokenIfNeededAsync();

            ODataQuery <Asset> odataQuery = null;

            odataQuery = new ODataQuery <Asset>();

            if (_searchExactAssetName != null)
            {
                odataQuery.Filter = "name eq " + "'" + _searchExactAssetName + "'";
            }
            else
            {
                odataQuery.OrderBy = "Properties/Created desc";
            }
            _assets = await _client.AMSclient.Assets.ListAsync(_client.credentialsEntry.ResourceGroup, _client.credentialsEntry.AccountName, odataQuery);

            BeginUpdate();
            Items.Clear();

            foreach (Asset asset in _assets)
            {
                ListViewItem item = new ListViewItem(asset.Name);
                item.SubItems.Add(asset.Description);
                item.SubItems.Add(asset.LastModified.ToLocalTime().ToString("G"));
                if (_searchExactAssetName == asset.Name)
                {
                    item.Selected = true;
                }

                Items.Add(item);
            }

            AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            EndUpdate();
        }
コード例 #9
0
        public static async Task DoGenerateClientManifestForAllAssetsAsync(AMSClientV3 amsClient, MyDelegate TextBoxLogWriteLine)
        {
            bool cancel = false;

            if (MessageBox.Show("The tool will list the published assets and will create a client manifest when needed.", "Client manifest creation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) != DialogResult.OK)
            {
                return;
            }


            ListContainerSasInput input = new ListContainerSasInput()
            {
                Permissions = AssetContainerPermission.ReadWriteDelete,
                ExpiryTime  = DateTime.Now.AddHours(2).ToUniversalTime()
            };
            await amsClient.RefreshTokenIfNeededAsync();


            // Get a list of all of the locators and enumerate through them a page at a time.
            IPage <StreamingLocator> firstPage = await amsClient.AMSclient.StreamingLocators.ListAsync(amsClient.credentialsEntry.ResourceGroup, amsClient.credentialsEntry.AccountName);

            IPage <StreamingLocator> currentPage = firstPage;

            do
            {
                foreach (StreamingLocator locator in currentPage)
                {
                    TextBoxLogWriteLine("Inspecting locator {0}...", locator.Name, false);

                    // Get the asset associated with the locator.
                    Asset asset = amsClient.AMSclient.Assets.Get(amsClient.credentialsEntry.ResourceGroup, amsClient.credentialsEntry.AccountName, locator.AssetName);

                    AssetContainerSas response;
                    try
                    {
                        response = await amsClient.AMSclient.Assets.ListContainerSasAsync(amsClient.credentialsEntry.ResourceGroup, amsClient.credentialsEntry.AccountName, asset.Name, input.Permissions, input.ExpiryTime);
                    }
                    catch (Exception ex)
                    {
                        TextBoxLogWriteLine("Error when listing blobs of asset '{0}'.", asset.Name, true); // Warning
                        TextBoxLogWriteLine(Program.GetErrorMessage(ex), string.Empty, true);              // Warning

                        //MessageBox.Show(Program.GetErrorMessage(ex), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    string             uploadSasUrl     = response.AssetContainerSasUrls.First();
                    Uri                sasUri           = new Uri(uploadSasUrl);
                    CloudBlobContainer storageContainer = new CloudBlobContainer(sasUri);

                    // Get a manifest file list from the Storage container.
                    List <string> fileList = GetFilesListFromStorage(storageContainer);

                    string ismcFileName        = fileList.Where(a => a.ToLower().Contains(".ismc")).FirstOrDefault();
                    string ismManifestFileName = fileList.Where(a => a.ToLower().EndsWith(".ism")).FirstOrDefault();
                    // If there is no .ism then there's no reason to continue.  If there's no .ismc we need to add it.
                    if (ismManifestFileName != null && ismcFileName == null)
                    {
                        DialogResult dialog = MessageBox.Show($"Asset {asset.Name} it does not have an ISMC file. Create one ?", "Client manifest creation", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                        if (dialog == DialogResult.Yes)
                        {
                            TextBoxLogWriteLine("Asset {0} : it does not have an ISMC file.", asset.Name, false);

                            // let's try to read client manifest
                            XDocument manifest = null;
                            try
                            {
                                manifest = await AssetInfo.TryToGetClientManifestContentUsingStreamingLocatorAsync(asset, amsClient, locator.Name);
                            }
                            catch (Exception ex)
                            {
                                TextBoxLogWriteLine("Error when trying to read client manifest for asset '{0}'.", asset.Name, true); // Warning
                                TextBoxLogWriteLine(Program.GetErrorMessage(ex), string.Empty, true);                                // Warning
                                return;
                            }

                            string ismcContentXml = manifest.ToString();
                            if (ismcContentXml.Length == 0)
                            {
                                TextBoxLogWriteLine("Asset {0} : client manifest is empty.", asset.Name, true); // Warning

                                //error state, skip this asset
                                continue;
                            }
                            if (ismcContentXml.IndexOf("<Protection>") > 0)
                            {
                                TextBoxLogWriteLine("Asset {0} : content is encrypted. Removing the protection header from the client manifest.", asset.Name, false);
                                //remove DRM from the ISCM manifest
                                ismcContentXml = XmlManifestUtils.RemoveXmlNode(ismcContentXml);
                            }
                            string         newIsmcFileName = ismManifestFileName.Substring(0, ismManifestFileName.IndexOf(".")) + ".ismc";
                            CloudBlockBlob ismcBlob        = WriteStringToBlob(ismcContentXml, newIsmcFileName, storageContainer);
                            TextBoxLogWriteLine("Asset {0} : client manifest created.", asset.Name, false);

                            // Download the ISM so that we can modify it to include the ISMC file link.
                            string ismXmlContent = GetFileXmlFromStorage(storageContainer, ismManifestFileName);
                            ismXmlContent = XmlManifestUtils.AddIsmcToIsm(ismXmlContent, newIsmcFileName);
                            WriteStringToBlob(ismXmlContent, ismManifestFileName, storageContainer);
                            TextBoxLogWriteLine("Asset {0} : server manifest updated.", asset.Name, false);

                            // update the ism to point to the ismc (download, modify, delete original, upload new)
                        }
                        else if (dialog == DialogResult.Cancel)
                        {
                            cancel = true;
                            break;
                        }
                    }
                }

                if (cancel)
                {
                    break;
                }

                // Continue on to the next page of locators.
                try
                {
                    currentPage = amsClient.AMSclient.StreamingLocators.ListNext(currentPage.NextPageLink);
                }
                catch (Exception)
                {
                    // we'll get here at the end of the page when the page is empty.  This is okay.
                }
            } while (currentPage.NextPageLink != null);
            MessageBox.Show("Locator listing is complete.", "Client manifest creation", MessageBoxButtons.OK, MessageBoxIcon.Information);
            TextBoxLogWriteLine("Locator listing is complete.", string.Empty, false);
        }
コード例 #10
0
        private async void ChooseStreamingEndpoint_Load(object sender, EventArgs e)
        {
            DpiUtils.InitPerMonitorDpi(this);

            label.Text = string.Format(label.Text, _asset.Name);

            // SE List
            await _amsClient.RefreshTokenIfNeededAsync();

            // StreamingEndpoint BestSE = Task.Run(async () => await AssetInfo.GetBestStreamingEndpointAsync(_client)).Result;
            StreamingEndpoint BestSE = await AssetInfo.GetBestStreamingEndpointAsync(_amsClient);

            var myStreamingEndpoints = Task.Run(() => _amsClient.AMSclient.StreamingEndpoints.ListAsync(_amsClient.credentialsEntry.ResourceGroup, _amsClient.credentialsEntry.AccountName)).GetAwaiter().GetResult();

            foreach (StreamingEndpoint se in myStreamingEndpoints)
            {
                listBoxSE.Items.Add(new Item(string.Format(AMSExplorer.Properties.Resources.AssetInformation_AssetInformation_Load_012ScaleUnit, se.Name, se.ResourceState, StreamingEndpointInformation.ReturnTypeSE(se)), se.Name + "|" + se.HostName));
                if (se.Id == BestSE.Id)
                {
                    listBoxSE.SelectedIndex = listBoxSE.Items.Count - 1;
                }

                foreach (string custom in se.CustomHostNames)
                {
                    listBoxSE.Items.Add(new Item(string.Format(AMSExplorer.Properties.Resources.AssetInformation_AssetInformation_Load_012ScaleUnitCustomHostname3, se.Name, se.ResourceState, StreamingEndpointInformation.ReturnTypeSE(se), custom), se.Name + "|" + custom));
                }
            }


            // Filters

            // asset filters
            Microsoft.Rest.Azure.IPage <AssetFilter> assetFilters = await _amsClient.AMSclient.AssetFilters.ListAsync(_amsClient.credentialsEntry.ResourceGroup, _amsClient.credentialsEntry.AccountName, _asset.Name);

            List <string> afiltersnames = assetFilters.Select(a => a.Name).ToList();

            listViewFilters.BeginUpdate();
            assetFilters.ToList().ForEach(f =>
            {
                ListViewItem lvitem = new ListViewItem(new string[] { AMSExplorer.Properties.Resources.ChooseStreamingEndpoint_ChooseStreamingEndpoint_Load_AssetFilter + f.Name, f.Name });
                if (_filter != null && f.Name == _filter)
                {
                    lvitem.Checked = true;
                }
                listViewFilters.Items.Add(lvitem);
            }
                                          );

            // account filters
            IPage <AccountFilter> acctFilters = await _amsClient.AMSclient.AccountFilters.ListAsync(_amsClient.credentialsEntry.ResourceGroup, _amsClient.credentialsEntry.AccountName);

            acctFilters.ToList().ForEach(f =>
            {
                ListViewItem lvitem = new ListViewItem(new string[] { AMSExplorer.Properties.Resources.ChooseStreamingEndpoint_ChooseStreamingEndpoint_Load_GlobalFilter + f.Name, f.Name });
                if (_filter != null && f.Name == _filter && listViewFilters.CheckedItems.Count == 0) // only if not already selected (asset filter priority > account filter)
                {
                    lvitem.Checked = true;
                }
                if (afiltersnames.Contains(f.Name)) // global filter with same name than asset filter
                {
                    lvitem.ForeColor = Color.Gray;
                }
                listViewFilters.Items.Add(lvitem);
            }
                                         );
            listViewFilters.EndUpdate();


            if (_playertype == PlayerType.DASHIFRefPlayer)
            {
                radioButtonDASHCSF.Checked = true;
            }

            comboBoxBrowser.Items.Add(new Item(AMSExplorer.Properties.Resources.ChooseStreamingEndpoint_ChooseStreamingEndpoint_Load_DefaultBrowser, string.Empty));
            if (_displayBrowserSelection)
            { // let's add the browser options to lplayback the content (IE, Edge, Chrome...)
                if (IsWindows10())
                {
                    comboBoxBrowser.Items.Add(new Item(Constants.BrowserEdge[0], Constants.BrowserEdge[1]));
                }

                comboBoxBrowser.Items.Add(new Item(Constants.BrowserIE[0], Constants.BrowserIE[1]));
                comboBoxBrowser.Items.Add(new Item(Constants.BrowserChrome[0], Constants.BrowserChrome[1]));
                comboBoxBrowser.SelectedIndex = 0;
            }
            comboBoxBrowser.Visible = _displayBrowserSelection;

            UpdatePreviewUrl();

            FillLocatorComboInPolicyTab();
        }
コード例 #11
0
        public async Task RefreshAssetsAsync(int pagetodisplay) // all assets are refreshed
        {
            if (!_initialized)
            {
                return;
            }
            if (pagetodisplay == 1)
            {
                _currentPageNumberIsMax = false;
            }
            Debug.WriteLine("RefreshAssets Start");

            if (WorkerAnalyzeAssets.IsBusy)
            {
                // cancel the analyze.
                WorkerAnalyzeAssets.CancelAsync();
            }
            this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.WaitCursor));

            /*
             *
             *
             * Property
             * Name	Filtering	Ordering
             * Equals	Greater than	Less Than	Ascending	Descending
             * Name	✓	✓	✓	✓	✓
             * Properties/AssetId	✓
             * Properties/Created	✓	✓	✓	✓	✓
             * Properties/LastModified
             * Properties/AlternateId	✓
             * Properties/Description
             * Properties/Container
             * Properties/StorageId
             *
             *
             */


            ///////////////////////
            // SORTING
            ///////////////////////
            var odataQuery = new ODataQuery <Asset>();

            switch (_orderassets)
            {
            case OrderAssets.CreatedDescending:
                odataQuery.OrderBy = "Properties/Created desc";
                break;

            case OrderAssets.CreatedAscending:
                odataQuery.OrderBy = "Properties/Created";
                break;

            case OrderAssets.NameAscending:
                odataQuery.OrderBy = "Name";
                break;

            case OrderAssets.NameDescending:
                odataQuery.OrderBy = "Name desc";
                break;

            default:
                odataQuery.OrderBy = "Properties/Created desc";
                break;
            }



            ///////////////////////
            // SEARCH
            ///////////////////////
            if (_searchinname != null && !string.IsNullOrEmpty(_searchinname.Text))
            {
                string search = _searchinname.Text;

                switch (_searchinname.SearchType)
                {
                // Search on Asset name Equals
                case SearchIn.AssetNameEquals:
                    search            = "'" + search + "'";
                    odataQuery.Filter = "name eq " + search;
                    break;

                // Search on Asset name starts with
                case SearchIn.AssetNameStartsWith:
                    search            = "'" + search + "'";
                    odataQuery.Filter = "name gt " + search.Substring(0, search.Length - 2) + char.ConvertFromUtf32(char.ConvertToUtf32(search, search.Length - 2) - 1) + new String('z', 262 - search.Length) + "'" + " and name lt " + search.Substring(0, search.Length - 2) + char.ConvertFromUtf32(char.ConvertToUtf32(search, search.Length - 2) + 1) + "'";
                    break;

                // Search on Asset name Greater than
                case SearchIn.AssetNameGreaterThan:
                    search            = "'" + search + "'";
                    odataQuery.Filter = "name gt " + search;
                    break;

                // Search on Asset name Less than
                case SearchIn.AssetNameLessThan:
                    search            = "'" + search + "'";
                    odataQuery.Filter = "name lt " + search;
                    break;

                // Search on Asset aternate id
                case SearchIn.AssetAltId:
                    search            = "'" + search + "'";
                    odataQuery.Filter = "properties/alternateid eq " + search;
                    break;

                case SearchIn.AssetId:
                    odataQuery.Filter = "properties/assetid eq " + search;
                    break;

                default:
                    break;
                }
            }

            // DAYS
            bool filterStartDate = false;
            bool filterEndDate   = false;

            DateTime dateTimeStart    = DateTime.UtcNow;
            DateTime dateTimeRangeEnd = DateTime.UtcNow.AddDays(1);

            int days = FilterTime.ReturnNumberOfDays(_timefilter);

            if (days > 0)
            {
                filterStartDate = true;
                dateTimeStart   = (DateTime.UtcNow.Add(-TimeSpan.FromDays(days)));
            }
            else if (days == -1) // TimeRange
            {
                filterStartDate = true;
                filterEndDate   = true;
                dateTimeStart   = _timefilterTimeRange.StartDate;
                if (_timefilterTimeRange.EndDate != null) // there is an end time
                {
                    dateTimeRangeEnd = (DateTime)_timefilterTimeRange.EndDate;
                }
            }
            if (filterStartDate)
            {
                if (odataQuery.Filter != null)
                {
                    odataQuery.Filter = odataQuery.Filter + " and ";
                }
                odataQuery.Filter = odataQuery.Filter + $"properties/created gt {dateTimeStart.ToString("o")}";
            }
            if (filterEndDate)
            {
                if (odataQuery.Filter != null)
                {
                    odataQuery.Filter = odataQuery.Filter + " and ";
                }
                odataQuery.Filter = odataQuery.Filter + $"properties/created lt {dateTimeRangeEnd.ToString("o")}";
            }

            IPage <Asset> currentPage = null;
            await _client.RefreshTokenIfNeededAsync();

            if (pagetodisplay == 1)
            {
                firstpage = await _client.AMSclient.Assets.ListAsync(_client.credentialsEntry.ResourceGroup, _client.credentialsEntry.AccountName, odataQuery);

                currentPage = firstpage;
            }
            else
            {
                currentPage        = firstpage;
                _currentPageNumber = 1;
                while (currentPage.NextPageLink != null && pagetodisplay > _currentPageNumber)
                {
                    _currentPageNumber++;
                    currentPage = await _client.AMSclient.Assets.ListNextAsync(currentPage.NextPageLink);
                }
                if (currentPage.NextPageLink == null)
                {
                    _currentPageNumberIsMax = true;                                   // we reached max
                }
            }



            /*
             * var assets = currentPage.Select(a => new AssetEntryV3
             * {
             *  Name = a.Name,
             *  Description = a.Description,
             *  AssetId = a.AssetId,
             *  AlternateId = a.AlternateId,
             *  Created = ((DateTime)a.Created).ToLocalTime().ToString("G"),
             *  StorageAccountName = a.StorageAccountName
             * }
             * );
             */


            var assets = currentPage.Select(a =>
                                            (cacheAssetentriesV3.ContainsKey(a.Name) &&
                                             cacheAssetentriesV3[a.Name].LastModified != null &&
                                             (cacheAssetentriesV3[a.Name].LastModified == a.LastModified.ToLocalTime().ToString("G")) ?
                                             cacheAssetentriesV3[a.Name] :
                                             new AssetEntryV3
            {
                Name = a.Name,
                Description = a.Description,
                AssetId = a.AssetId,
                AlternateId = a.AlternateId,
                Created = ((DateTime)a.Created).ToLocalTime().ToString("G"),
                LastModified = ((DateTime)a.LastModified).ToLocalTime().ToString("G"),
                StorageAccountName = a.StorageAccountName
            }
                                            ));

            _MyObservAssetV3 = new BindingList <AssetEntryV3>(assets.ToList());

            this.BeginInvoke(new Action(() => this.DataSource = _MyObservAssetV3));

            Debug.WriteLine("RefreshAssets End");
            AnalyzeItemsInBackground();

            this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.Default));
        }
コード例 #12
0
        public async Task RefreshLiveOutputsAsync(int pagetodisplay) // all assets are refreshed
        {
            if (!_initialized)
            {
                return;
            }
            if (idsList.Count == 0)
            {
                return;
            }

            Debug.WriteLine("RefreshPrograms : start");

            this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.WaitCursor));

            await _client.RefreshTokenIfNeededAsync();

            IEnumerable <LiveEvent> ListEvents;

            if (_anyChannel == enumDisplayProgram.None)
            {
                ListEvents = new List <LiveEvent>();
            }
            else
            {
                ListEvents = (await _client.AMSclient.LiveEvents.ListAsync(_client.credentialsEntry.ResourceGroup, _client.credentialsEntry.AccountName))
                             .ToList()
                             .Where(l => _anyChannel == enumDisplayProgram.Any || (_anyChannel == enumDisplayProgram.Selected && LiveEventSourceNames.Contains(l.Name)));
            }


            List <Program.LiveOutputExt> LOList = new List <Program.LiveOutputExt>();

            foreach (var le in ListEvents)
            {
                var plist = (await _client.AMSclient.LiveOutputs.ListAsync(_client.credentialsEntry.ResourceGroup, _client.credentialsEntry.AccountName, le.Name))
                            .ToList();
                plist.ForEach(p => LOList.Add(new Program.LiveOutputExt()
                {
                    LiveOutputItem = p, LiveEventName = le.Name
                }));
            }

            var programquery = from c in (LOList)
                               //orderby c.LastModified descending
                               select new LiveOutputEntry
            {
                Name                = c.LiveOutputItem.Name,
                State               = c.LiveOutputItem.ResourceState,
                Description         = c.LiveOutputItem.Description,
                ArchiveWindowLength = c.LiveOutputItem.ArchiveWindowLength,
                LastModified        = c.LiveOutputItem.LastModified != null ? (DateTime?)((DateTime)c.LiveOutputItem.LastModified).ToLocalTime() : null,
                Published           = DataGridViewAssets.BuildBitmapPublication(c.LiveOutputItem.AssetName, _client).bitmap,
                LiveEventName       = c.LiveEventName
            };



            _MyObservLiveOutputs = new SortableBindingList <LiveOutputEntry>(programquery.ToList());
            this.BeginInvoke(new Action(() => this.DataSource = _MyObservLiveOutputs));
            _refreshedatleastonetime = true;

            this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.Default));

            Debug.WriteLine("RefreshPrograms : end");
        }
コード例 #13
0
        public async Task RefreshjobsAsync(int pagetodisplay) // all jobs are refreshed
        {
            if ((!_initialized) || _transformName.Count == 0)
            {
                return;
            }

            Debug.WriteLine("Refresh Jobs Start");

            this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.WaitCursor));

            ///////////////////////
            // SORTING
            ///////////////////////
            var odataQuery = new ODataQuery <Job>();

            switch (_orderjobs)
            {
            case OrderJobs.CreatedDescending:
                odataQuery.OrderBy = "Properties/Created desc";
                break;

            case OrderJobs.CreatedAscending:
                odataQuery.OrderBy = "Properties/Created";
                break;

            case OrderJobs.NameAscending:
                odataQuery.OrderBy = "Name";
                break;

            case OrderJobs.NameDescending:
                odataQuery.OrderBy = "Name desc";
                break;

            default:
                odataQuery.OrderBy = "Properties/Created desc";
                break;
            }



            ///////////////////////
            // Filter
            ///////////////////////

            switch (_filterjobsstate)
            {
            case "All":
                break;

            default:
                odataQuery.Filter = string.Format("Properties/state eq Microsoft.Media.JobState'{0}'", _filterjobsstate);
                break;
            }



            // DAYS
            bool filterStartDate = false;
            bool filterEndDate   = false;

            DateTime dateTimeStart    = DateTime.UtcNow;
            DateTime dateTimeRangeEnd = DateTime.UtcNow.AddDays(1);

            int days = FilterTime.ReturnNumberOfDays(_timefilter);

            if (days > 0)
            {
                filterStartDate = true;
                dateTimeStart   = (DateTime.UtcNow.Add(-TimeSpan.FromDays(days)));
            }
            else if (days == -1) // TimeRange
            {
                filterStartDate = true;
                filterEndDate   = true;
                dateTimeStart   = _timefilterTimeRange.StartDate;
                if (_timefilterTimeRange.EndDate != null) // there is an end time
                {
                    dateTimeRangeEnd = (DateTime)_timefilterTimeRange.EndDate;
                }
            }
            if (filterStartDate)
            {
                if (odataQuery.Filter != null)
                {
                    odataQuery.Filter = odataQuery.Filter + " and ";
                }
                odataQuery.Filter = odataQuery.Filter + $"Properties/Created gt {dateTimeStart.ToString("o")}";
            }
            if (filterEndDate)
            {
                if (odataQuery.Filter != null)
                {
                    odataQuery.Filter = odataQuery.Filter + " and ";
                }
                odataQuery.Filter = odataQuery.Filter + $"Properties/Created lt {dateTimeRangeEnd.ToString("o")}";
            }


            // Paging
            await _client.RefreshTokenIfNeededAsync();

            IPage <Job> currentPage = null;
            var         transform   = _transformName.First();

            if (pagetodisplay == 1)
            {
                firstpage = await _client.AMSclient.Jobs.ListAsync(_client.credentialsEntry.ResourceGroup, _client.credentialsEntry.AccountName, transform, odataQuery);

                currentPage = firstpage;
            }
            else
            {
                currentPage        = firstpage;
                _currentPageNumber = 1;
                while (currentPage.NextPageLink != null && pagetodisplay > _currentPageNumber)
                {
                    _currentPageNumber++;
                    currentPage = await _client.AMSclient.Jobs.ListNextAsync(currentPage.NextPageLink);
                }
                if (currentPage.NextPageLink == null)
                {
                    _currentPageNumberIsMax = true;                                   // we reached max
                }
            }


            var jobs = currentPage.Select(a => new JobEntryV3
            {
                Name          = a.Name,
                Description   = a.Description,
                LastModified  = ((DateTime)a.LastModified).ToLocalTime().ToString("G"),
                TransformName = transform,
                Outputs       = a.Outputs.Count,
                Priority      = a.Priority,
                State         = a.State,
                Progress      = ReturnProgressJob(a).progress
                                // progress;  we don't want the progress bar to be displayed
            }
                                          );

            _MyObservJobV3 = new BindingList <JobEntryV3>(jobs.ToList());

            this.BeginInvoke(new Action(() => this.DataSource = _MyObservJobV3));

            Debug.WriteLine("RefreshJobs End");

            RestoreJobProgress(new List <string> {
                transform
            });

            this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.Default));
        }