BeatMachine.Model.DataModel.RunWorkflow C# (CSharp) Method

RunWorkflow() public method

This method will look at the state of this object and run the remaining steps in the workflow to make sure the data is fully loaded. This is useful in situaltions where the model may get serialized and stored, and then needs to be able to resume loading based on its state.
public RunWorkflow ( string eventPropertyName ) : void
eventPropertyName string An optional eventPropertyName, /// to be used if this is attached as part of a property /// changed handler. If not used as part of the handler, /// set this to null.
return void
        public void RunWorkflow(string eventPropertyName)
        {
            if (!AllDone)
            {
                if (SongsToAnalyzeBatchUploadReady &&
                    PropertyNameMatchesEventName(SongsToAnalyzeBatchUploadReadyPropertyName, eventPropertyName))
                {
                    ExecutionQueue.Enqueue(
                        new WaitCallback(DownloadAnalyzedSongs),
                        ExecutionQueue.Policy.Queued);
                }
                else
                {
                    if (SongsToAnalyzeBatchDownloadReady &&
                        PropertyNameMatchesEventName(SongsToAnalyzeBatchDownloadReadyPropertyName, eventPropertyName))
                    {
                        ExecutionQueue.Enqueue(
                               new WaitCallback(AnalyzeSongs),
                               ExecutionQueue.Policy.Queued);
                    }
                    else
                    {
                        if (SongsToAnalyzeLoaded &&
                            (PropertyNameMatchesEventName(SongsToAnalyzeLoadedPropertyName, eventPropertyName) ||
                            PropertyNameMatchesEventName(CatalogIdPropertyName, eventPropertyName)))
                        {
                            if (String.IsNullOrEmpty(CatalogId))
                            {
                                ExecutionQueue.Enqueue(
                                    new WaitCallback(LoadCatalogId),
                                    ExecutionQueue.Policy.Immediate);
                            }
                            else
                            {
                                ExecutionQueue.Enqueue(
                                  new WaitCallback(DownloadAnalyzedSongsAlreadyInRemoteCatalog),
                                  ExecutionQueue.Policy.Queued);
                            }
                        }
                        else
                        {
                            if (SongsOnDeviceLoaded &&
                                AnalyzedSongsLoaded &&
                                (PropertyNameMatchesEventName(SongsOnDeviceLoadedPropertyName, eventPropertyName) ||
                                PropertyNameMatchesEventName(AnalyzedSongsLoadedPropertyName, eventPropertyName)))
                            {
                                ExecutionQueue.Enqueue(
                                    new WaitCallback(DiffSongs),
                                    ExecutionQueue.Policy.Immediate);
                            }
                            else
                            {
                                if (!SongsOnDeviceLoaded &&
                                    PropertyNameMatchesEventName(SongsOnDeviceLoadedPropertyName, eventPropertyName))
                                {
                                    ExecutionQueue.Enqueue(
                                        new WaitCallback(GetSongsOnDevice),
                                        ExecutionQueue.Policy.Immediate);
                                }

                                if (!AnalyzedSongsLoaded &&
                                    PropertyNameMatchesEventName(AnalyzedSongsLoadedPropertyName, eventPropertyName))
                                {
                                    ExecutionQueue.Enqueue(
                                        new WaitCallback(GetAnalyzedSongs),
                                        ExecutionQueue.Policy.Immediate);
                                }
                            }
                        }
                    }
                }
            }
        }