Пример #1
0
 static void ac_AssignmentCompleteError(object sender, AssignmentErrorEventArgs e)
 {
     Console.WriteLine("Errore durante la consegna del compito: {0}", e.ErrorType);
     if (e.Error != null)
         Console.WriteLine("{0}", e.Error.Message);
     Console.ReadKey();
 }
Пример #2
0
        public void Execute()
        {
            try
            {
                #if DEBUG  //evita warning su consegna anticipata
                Global.Time = new FakeTimeProvider(Global.RecentSpanTimeForStart + 5);
                #endif
                var projectNames = fileManager.GetProjectNames();
                if (projectNames.Length == 0)
                {
                    AssignmentStartError.Fire(this, AssignmentErrorEventArgs.New(AssignmentErrorType.ProjectTargetNoFound));
                    return;
                }

                if (IsDoubleStart())
                {
                    var e = new CheckDoubleStartEventArgs();
                    AssignmentCheckDoubleStart.Fire(this, e);
                    if (e.Abort)
                    {
                        return;
                    }
                }

                var ea = new ProjectNameRequestEventArgs()
                {
                    ProjectNames = projectNames, SelectedProjectName = projectNames[0]
                };
                AssignmentRequestProjectName.Fire(this, ea);
                if (ea.Abort)
                {
                    AssignmentStartAborted.Fire(this);
                    return;
                }

                ProcessManager.CloseOpenWindows(AssignmentManager.SkipProcessToClose, forceClose: true);
                Log.Write(LogLevel.Verbose, "START: chiuse finestre");

                _Execute(ea.SelectedProjectName, ea.NameAs);

                AssignmentStartCompleted.Fire(this);
            }
            catch (Exception e)
            {
                AssignmentStartError.Fire(this, AssignmentErrorEventArgs.New(AssignmentErrorType.UnknowError, e));
            }
            finally
            {
                Global.Time = new DefaultTimeProvider();
                Log.Close();
            }
        }
Пример #3
0
        public void Execute()
        {
            try
            {
                #if DEBUG  //evita warning su consegna anticipata
                Global.Time = new FakeTimeProvider(Global.RecentSpanTimeForComplete + 5);
                #endif

                if (!fileManager.TargetExists(config.ProjectFullName))
                {
                    AssignmentCompleteError.Fire(this, AssignmentErrorEventArgs.New(AssignmentErrorType.ProjectTargetNoFound));
                    return;
                }

                if (IsAnticipateComplete())
                {
                    var e = new CompleteAnticipateStartEventArgs();
                    AssignmentCompleteAnticipateStart.Fire(this, e);
                    if (e.Abort)
                    {
                        return;
                    }
                }

                if (ProcessManager.IsExecuting(config.ProjectTarget.Target))
                {
                    var e = new CompleteRequestCloseTargetEventArgs()
                    {
                        TargetInfo = config.ProjectTarget
                    };
                    AssignmentRequestCloseTarget.Fire(this, e);
                    if (e.Abort)
                    {
                        return;
                    }
                }
                else
                {
                    var e = new CompleteStartEventArgs {
                        ProjectName = config.ProjectName
                    };
                    AssignmentCompleteStart.Fire(this, e);
                    if (e.Abort)
                    {
                        AssignmentCompleteAborted.Fire(this);
                        return;
                    }
                }

                CloseOpenWindows();

                _Execute();
                AssignmentCompleteCompleted.Fire(this);
            }
            catch (Exception e)
            {
                AssignmentCompleteError.Fire(this, AssignmentErrorEventArgs.New(AssignmentErrorType.UnknowError, e));
            }
            finally
            {
                Global.Time = new DefaultTimeProvider();
            }
        }
Пример #4
0
 static void am_AssignmentStartError(object sender, AssignmentErrorEventArgs e)
 {
     Console.WriteLine("Si è verificato un errore: {0}", e.ErrorType);
     if (e.Error != null)
         Console.WriteLine("{0}", e.Error.Message);
 }
Пример #5
0
 void ac_AssignmentCompleteError(object sender, AssignmentErrorEventArgs e)
 {
     var msg = e.Error != null ? e.Error.Message : "";
     Log.Write(LogLevel.Error, "COMPLETE: {0}", CreateErrorLogText(e));
     MessageDialog.Show(CreateErrorText(e), MessageInfoType.Error);
 }
Пример #6
0
 string CreateErrorText(AssignmentErrorEventArgs e)
 {
     string errorMsg = e.Error != null ? e.Error.Message : "";
     string msg = string.Format("[{0}]\n{1}", e.ErrorType.Message(), errorMsg);
     return msg + "\n\nChiama il professore!";
 }
Пример #7
0
 string CreateErrorLogText(AssignmentErrorEventArgs e)
 {
     string errorMsg = e.Error != null ? e.Error.Message : "";
     return string.Format("[{0}]\n{1}", e.ErrorType.Message(), errorMsg);
 }