Exemplo n.º 1
0
 void ResourceTree_OnStatusUpdate(ResourceTreeView.State state, string status)
 {
     if (state.Resource.Guid == _statusBarItemGuid)
     {
         SBItem.Content = status;
     }
 }
Exemplo n.º 2
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
            });
        }
Exemplo n.º 3
0
        void ResourceTree_OnRelease(ResourceTreeView.State state)
        {
            ReleaseResourceJob.UpdateUIDelegate actUpdateUI = ReleaseResourceCallback;

            _workMaster.AddJob(new JobArgs()
            {
                CouchDB          = _couchdb,
                ErrorManager     = ErrorManager,
                FileSystem       = FileSystem,
                JobType          = Master.JobType.ReleaseResource,
                RequestingUser   = TEMP_USERNAME,
                Requestor        = this,
                Resource         = state.Resource,
                Timeout          = 10000,
                UpdateUICallback = actUpdateUI
            });
        }
Exemplo n.º 4
0
        void ResourceTree_OnItemSelect(ResourceTreeView.State state)
        {
            if (state == null)
            {
                BtnOpenSelected.IsEnabled = BtnSaveSelected.IsEnabled = BtnGetSelected.IsEnabled = false;
                _statusBarItemGuid        = Guid.Empty;
                SBItem.Content            = "";
                return;
            }

            _statusBarItemGuid = state.Resource.Guid;


            // Outdated Brush = Local resource is outdated (older than remote)
            // Error Brush = Something bad happened and the last action failed
            // Need Updated Brush = Local resource is newer than remote and needs saved to the server
            // Normal Brush = Local matches remote

            /* if outdated -> disable save, enable get
             * else if error...
             * We ran into a problem, if error, what was the previous state???
             * Need to implement a new state tracking class.
             */

            if (state.IsLocalOlder)
            {
                BtnSaveSelected.IsEnabled = false;
                BtnGetSelected.IsEnabled  = true;
            }
            else if (state.IsLocalNewer)
            {
                BtnSaveSelected.IsEnabled = true;
                BtnGetSelected.IsEnabled  = false;
            }
            else if (state.IsLocalSameAsRemote)
            {
                BtnSaveSelected.IsEnabled = false;
                BtnGetSelected.IsEnabled  = false;
            }
            else
            {
                throw new Exception("Unknown state");
            }
        }
Exemplo n.º 5
0
        void ResourceTree_OnCancel(ResourceTreeView.State state)
        {
            Common.Storage.Version resource = null;

            // If the resource of the state exists then cancel it
            // This happens when a translation is not required - non CreateResourceJob
            if ((resource = ResourceTree.GetResourceFromTree(state.Resource.Guid)) != null)
            {
                _workMaster.CancelJobForResource(resource);
                return;
            }

            if (IdTranslation.ContainsValue(state.Resource.Guid))
            {
                Guid oldGuid = Guid.Empty;

                lock (IdTranslation)
                {
                    Dictionary <Guid, Guid> .Enumerator en = IdTranslation.GetEnumerator();
                    while (en.MoveNext())
                    {
                        if (en.Current.Value == state.Resource.Guid)
                        {
                            oldGuid = en.Current.Key;
                            break;
                        }
                    }
                }

                resource = ResourceTree.GetResourceFromTree(oldGuid);
                _workMaster.CancelJobForResource(resource);
                return;
            }

            throw new InvalidOperationException("Could not locate resource.");
        }