Пример #1
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        protected override void _Execute(params object[] args)
        {
            bool   needClearBusyState = false;
            string projectName        = null;

            try
            {
                Debug.Assert(args.Length > 0);

                string projectPath = args[0] as string;
                Debug.Assert(projectPath != null);

                // get project name
                projectName = Path.GetFileNameWithoutExtension(projectPath);

                // get project configuration
                ProjectConfiguration config = _FindConfigByName(projectName);
                if (config != null)
                {
                    // check if we need to auto-archive project
                    if (_NeedToAutoArchive(config))
                    {
                        // set status
                        string statusMessage = string.Format((string)_Application.FindResource("ArchiveMessageProcessStatusFormat"), projectName);
                        WorkingStatusHelper.SetBusy(statusMessage);
                        needClearBusyState = true;

                        ProjectArchivingSettings arSet = config.ProjectArchivingSettings;
                        DateTime date = DateTime.Now.Date.AddMonths(-arSet.TimeDomain);

                        ArchiveResult result = ProjectFactory.ArchiveProject(config, date);
                        _ShowResult(projectName, result);

                        if (result.IsArchiveCreated)
                        {   // Update project page
                            ProjectsPage projectsPage = (ProjectsPage)_Application.MainWindow.GetPage(PagePaths.ProjectsPagePath);
                            projectsPage.UpdateView();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);

                Collection <MessageDetail> details = new Collection <MessageDetail>();
                details.Add(new MessageDetail(MessageType.Error, ex.Message));

                string message = string.Format((string)_Application.FindResource("ArchiveMessageProcessFailedFromat"), projectName);
                _Application.Messenger.AddMessage(MessageType.Warning, message, details);
            }

            if (needClearBusyState)
            {
                WorkingStatusHelper.SetReleased();
            }
        }