当前位置: 首页>>代码示例>>C#>>正文


C# State.UpdateResourceStatus方法代码示例

本文整理汇总了C#中State.UpdateResourceStatus方法的典型用法代码示例。如果您正苦于以下问题:C# State.UpdateResourceStatus方法的具体用法?C# State.UpdateResourceStatus怎么用?C# State.UpdateResourceStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在State的用法示例。


在下文中一共展示了State.UpdateResourceStatus方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StartDownload

        public void StartDownload(Version resource, Common.Work.Master.JobType jobType)
        {
            if (FindTreeViewItem(resource) != null)
                throw new ArgumentException("The resource already exists.");

            State state;
            TreeViewItem tvi;

            tvi = new TreeViewItem();

            state = new State(resource);
            state.UpdateDirection(false, true);
            state.UpdateEvent(false, false, false, true, false, false, false, false);
            state.UpdateResourceStatus(false, true, false, true, false);

            tvi.Tag = state;
            tvi.Selected += new RoutedEventHandler(TreeViewItem_Selected);

            TreeViewItemProps.SetGuid(tvi, resource.MetaAsset.Guid.ToString("N"));
            TreeViewItemProps.SetIsCanceled(tvi, false);
            TreeViewItemProps.SetIsLoading(tvi, true);
            TreeViewItemProps.SetPercentComplete(tvi, 0);
            UpdateStatus(tvi, "Downloading resource.");

            state.JobType = jobType;

            if (resource.MetaAsset != null && !string.IsNullOrEmpty(resource.MetaAsset.Title))
                tvi.Header = resource.MetaAsset.Title;
            else
                tvi.Header = resource.Guid;

            AddContextMenu(tvi);

            ResourceTree.Items.Add(tvi);

            // Add twice because we need to ignore both the meta and data assets
            _ignoreFileChangesForGuids.Add(resource.Guid);
            _ignoreFileChangesForGuids.Add(resource.Guid);

            SetResourceTreeSelectedIndex(-1);
        }
开发者ID:274706834,项目名称:opendms-dot-net,代码行数:41,代码来源:ResourceTreeView.xaml.cs

示例2: AddNewExistingLocalResource

        /// <summary>
        /// Adds a resource that exists on the local filesystem as a new node on the tree.
        /// </summary>
        /// <param name="resource">The resource.</param>
        public void AddNewExistingLocalResource(Version resource)
        {
            if (FindTreeViewItem(resource) != null)
                throw new ArgumentException("The resource already exists.");

            State state;
            TreeViewItem tvi;

            tvi = new TreeViewItem();
            state = new State(resource);

            tvi.Tag = state;
            tvi.Selected += new RoutedEventHandler(TreeViewItem_Selected);

            TreeViewItemProps.SetGuid(tvi, resource.MetaAsset.Guid.ToString("N"));
            TreeViewItemProps.SetIsCanceled(tvi, false);
            TreeViewItemProps.SetIsLoading(tvi, false);
            TreeViewItemProps.SetPercentComplete(tvi, 0);
            UpdateStatus(tvi, "Resource needs saved to server.");

            state.UpdateDirection(false, false);
            state.UpdateEvent(true, false, false, false, true, false, false, false);
            state.UpdateResourceStatus(true, false, false, false, true);

            tvi.Background = _needUpdatedBrush;

            if (resource.MetaAsset != null && !string.IsNullOrEmpty(resource.MetaAsset.Title))
                tvi.Header = resource.MetaAsset.Title;
            else
                tvi.Header = resource.Guid;


            AddContextMenu(tvi);

            ResourceTree.Items.Add(tvi);

            SetResourceTreeSelectedIndex(-1);
        }
开发者ID:274706834,项目名称:opendms-dot-net,代码行数:42,代码来源:ResourceTreeView.xaml.cs

示例3: FinishStatusCheck

        public void FinishStatusCheck(Common.Work.JobResult result, string fileMd5)
        {
            TreeViewItem tvi;
            State state;

            if ((tvi = FindTreeViewItem(result.Resource)) == null)
            {
                // Item does not exist in the tree, it needs added if the job was successful
                if (result.Job.IsCancelled)
                {
                    MessageBox.Show("Actions on resource " + result.Resource.Guid.ToString("N") + " were cancelled by the user.");
                }
                else if (result.Job.IsError)
                {
                    MessageBox.Show("An error occurred while trying to check the status of the resource " + result.Resource.Guid.ToString("N") + ".");
                }
                else if (result.Job.IsTimeout)
                {
                    MessageBox.Show("Actions on resource " + result.Resource.Guid.ToString("N") + " timed out.");
                }
                else if (result.Job.IsFinished)
                {
                    tvi = new TreeViewItem();
                    state = new State(result.InputArgs.Resource);

                    tvi.Tag = state;
                    tvi.Selected += new RoutedEventHandler(TreeViewItem_Selected);

                    TreeViewItemProps.SetGuid(tvi, result.Resource.Guid.ToString("N"));
                    TreeViewItemProps.SetIsCanceled(tvi, false);
                    TreeViewItemProps.SetIsLoading(tvi, false);
                    TreeViewItemProps.SetPercentComplete(tvi, 0);

                    state.UpdateDirection(false, false);
                    state.UpdateEvent(false, false, false, false, true, false, false, false);
                    if (string.IsNullOrEmpty(result.Resource.MetaAsset.Md5)
                        || result.InputArgs.Resource.MetaAsset.Md5 != fileMd5)
                    {
                        state.UpdateResourceStatus(true, false, false, true, true);
                        UpdateStatus(tvi, "File needs saved to server.");
                        tvi.Background = _needUpdatedBrush;
                    }
                    else
                    {
                        state.UpdateResourceStatus(false, false, true, true, true);
                        UpdateStatus(tvi, "Loaded.");
                        tvi.Background = _normalBrush;
                    }

                    if (result.InputArgs.Resource.MetaAsset != null &&
                        !string.IsNullOrEmpty(result.InputArgs.Resource.MetaAsset.Title))
                        tvi.Header = result.InputArgs.Resource.MetaAsset.Title;
                    else
                        tvi.Header = result.InputArgs.Resource.Guid;

                    AddContextMenu(tvi);

                    ResourceTree.Items.Add(tvi);
                }
                else
                {
                    throw new Exception("Unhandled event");
                }
            }
            else
            {
                // Item does exist in the tree, we just need to update
                state = (State)tvi.Tag;
                TreeViewItemProps.SetIsLoading(tvi, false);
                TreeViewItemProps.SetPercentComplete(tvi, 0);
                state.UpdateDirection(false, false);

                if (result.Job.IsCancelled)
                {
                    TreeViewItemProps.SetIsCanceled(tvi, true);
                    UpdateStatus(tvi, "Status check canceled by user.");
                    state.UpdateEvent(false, false, false, false, true, true, false, false);
                    tvi.Background = _errorBrush;
                }
                else if (result.Job.IsError)
                {
                    TreeViewItemProps.SetIsCanceled(tvi, true);
                    UpdateStatus(tvi, "Error: failed status check.");
                    state.UpdateEvent(false, false, false, false, true, false, false, true);
                    tvi.Background = _errorBrush;
                }
                else if (result.Job.IsTimeout)
                {
                    TreeViewItemProps.SetIsCanceled(tvi, true);
                    UpdateStatus(tvi, "Error: timeout occurred performing status check.");
                    state.UpdateEvent(false, false, false, false, true, false, true, false);
                    tvi.Background = _errorBrush;
                }
                else if (result.Job.IsFinished)
                {
                    TreeViewItemProps.SetIsCanceled(tvi, true);
                    
                    state.UpdateEvent(false, false, false, false, true, false, false, false);
                    if (string.IsNullOrEmpty(result.Resource.MetaAsset.Md5)
                        || result.Resource.MetaAsset.Md5 != fileMd5)
//.........这里部分代码省略.........
开发者ID:274706834,项目名称:opendms-dot-net,代码行数:101,代码来源:ResourceTreeView.xaml.cs


注:本文中的State.UpdateResourceStatus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。