Beispiel #1
0
        void ResourceTree_OnReload(ResourceTreeView.State state)
        {
            CheckUpdateStatusJob.UpdateUIDelegate actUpdateUI = null;

            switch (state.JobType)
            {
            case Master.JobType.CheckoutJob:
                actUpdateUI = GetResourceCallback;
                break;

            case Master.JobType.CheckUpdateStatus:
                actUpdateUI = CheckUpdateStatus;
                break;

            case Master.JobType.CreateResource:
                // TODO
                // This needs to delete the resource from CouchDB and then
                // create the resource on CouchDB again.
                throw new NotImplementedException();
                break;

            case Master.JobType.GetResource:
                actUpdateUI = GetResourceCallback;
                break;

            case Master.JobType.ReleaseResource:
                actUpdateUI = ReleaseResourceCallback;
                break;

            case Master.JobType.SaveResource:
                actUpdateUI = SaveResourceCallback;
                break;

            default:
                throw new InvalidOperationException("Unknown job type to retry.");
            }

            _workMaster.AddJob(new JobArgs()
            {
                CouchDB          = _couchdb,
                ErrorManager     = ErrorManager,
                FileSystem       = FileSystem,
                JobType          = state.JobType,
                RequestingUser   = TEMP_USERNAME,
                Requestor        = this,
                Resource         = state.Resource,
                Timeout          = (uint)Settings.Instance.NetworkTimeout,
                UpdateUICallback = actUpdateUI
            });
        }
Beispiel #2
0
        /// <summary>
        /// Loads all resources on the local file system.
        /// </summary>
        /// <remarks>Runs on the UI thread.</remarks>
        void LoadLocalResources()
        {
            MetaAsset ma;
            Version   resource = null;
            Guid      guid     = Guid.Empty;
            string    temp;

            CheckUpdateStatusJob.UpdateUIDelegate actUpdateUI = CheckUpdateStatus;
            string[] files = FileSystem.GetFiles(Common.FileSystem.Path.RelativeMetaPath);

            for (int i = 0; i < files.Length; i++)
            {
                temp     = files[i];
                files[i] = System.IO.Path.GetFileNameWithoutExtension(files[i]);

                try { guid = new Guid(files[i]); }
                catch
                {
                    guid = Guid.Empty;
                }

                if (guid != Guid.Empty)
                {
                    ma = new MetaAsset(guid, _couchdb);

                    if (ma.LoadFromLocal(null, ma.RelativePath, FileSystem))
                    {
                        resource = new Version(ma, _couchdb);
                        _workMaster.AddJob(new JobArgs()
                        {
                            CouchDB          = _couchdb,
                            ErrorManager     = ErrorManager,
                            FileSystem       = FileSystem,
                            JobType          = Master.JobType.CheckUpdateStatus,
                            RequestingUser   = TEMP_USERNAME,
                            Requestor        = this,
                            Resource         = resource,
                            Timeout          = 100000,
                            UpdateUICallback = actUpdateUI
                        });
                    }
                    else
                    {
                        MessageBox.Show("The resource with id " + guid.ToString("N") + " failed to load, please verify the formatting of its meta data.");
                    }
                }
            }
        }
Beispiel #3
0
 /// <summary>
 /// Handles the Click event of the BtnRefreshETagStatus control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
 /// <remarks>Runs on the UI thread.</remarks>
 private void BtnRefreshETagStatus_Click(object sender, RoutedEventArgs e)
 {
     CheckUpdateStatusJob.UpdateUIDelegate actUpdateUI = CheckUpdateStatus;
     _workMaster.AddJob(new JobArgs()
     {
         CouchDB          = _couchdb,
         ErrorManager     = ErrorManager,
         FileSystem       = FileSystem,
         JobType          = Master.JobType.CheckUpdateStatus,
         RequestingUser   = TEMP_USERNAME,
         Requestor        = this,
         Resource         = ResourceTree.Selected,
         Timeout          = 1000,
         UpdateUICallback = actUpdateUI
     });
 }