예제 #1
0
        public bool ExecuteActivities(string[] activities, bool continueOnError)
        {
            ValidateState();

            if (activities == null || activities.Length == 0)
            {
                return(true);
            }

            mActivityProvider.AbortRequested = false;

            if (activities[0] != cActivityVerify && activities[0] != cActivityKillServer && !mActivityProvider.IsDeviceConnected)
            {
                OnActivityFailed(new ActivityFailedEventArgs(Resources.MsgNoDevices));
                return(false);
            }

            for (int activityIndex = 0; activityIndex < activities.Length; activityIndex++)
            {
                OnActivityStarting(new ActivityStatusEventArgs(activityIndex, activities.Length));

                Log.V(cLogTag, "Executing activity {0} ({1} of {2})", activities[activityIndex], activityIndex + 1, activities.Length);

                if (ExecuteActivity(activities[activityIndex], activityIndex, activities.Length, continueOnError))
                {
                    Log.V(cLogTag, "Successfully completed activity {0} ({1} of {2})", activities[activityIndex], activityIndex + 1, activities.Length);
                    OnActivityExecuted(new ActivityStatusEventArgs(activityIndex, activities.Length));
                }
                else
                {
                    if (!continueOnError)
                    {
                        Log.V(cLogTag, "Aborting after failed activity {0} ({1} of {2})", activities[activityIndex], activityIndex + 1, activities.Length);
                        return(false);
                    }

                    Log.V(cLogTag, "Continuing after failed activity {0} ({1} of {2})", activities[activityIndex], activityIndex + 1, activities.Length);
                }

                if (mActivityProvider.HandleAbort() || !mActivityProvider.IsDeviceConnected)
                {
                    Log.V(cLogTag, "Aborting due to user request or connectivity loss after activity {0} ({1} of {2})", activities[activityIndex], activityIndex + 1, activities.Length);
                    return(false);
                }
            }

            return(true);
        }