示例#1
0
 public JSONApplication ToJSON()
 {
     return(new JSONApplication
     {
         Name = Name,
         ExceptionCount = ExceptionCount,
         MostRecent = MostRecent.ToRelativeTime()
     });
 }
        protected override void Execute(CodeActivityContext executionContext)
        {
            #region "Load CRM Service from context"

            Common objCommon = new Common(executionContext);
            objCommon.tracingService.Trace("Load CRM Service from context --- OK");

            #endregion

            #region "Read Parameters"

            // Get parameters
            string          mainRecordURL = MainRecordURL.Get(executionContext);
            string          fileName      = FileName.Get(executionContext);
            EntityReference email         = Email.Get(executionContext);
            bool            retrieveActivityMimeAttachment = RetrieveActivityMimeAttachment.Get(executionContext);
            bool            mostRecent = MostRecent.Get(executionContext);
            int?            topRecords = TopRecords.Get(executionContext);


            // Extract values from URL
            string[] urlParts             = mainRecordURL.Split("?".ToArray());
            string[] urlParams            = urlParts[1].Split("&".ToCharArray());
            string   ParentObjectTypeCode = urlParams[0].Replace("etc=", "");
            string   ParentId             = urlParams[1].Replace("id=", "");
            objCommon.tracingService.Trace("ParentObjectTypeCode=" + ParentObjectTypeCode + "--ParentId=" + ParentId);

            // Treat file name
            if (fileName == "*")
            {
                fileName = "";
            }
            fileName = fileName.Replace("*", "%");

            #endregion

            msdyncrmWorkflowTools_Class commonClass = new msdyncrmWorkflowTools_Class(objCommon.service, objCommon.tracingService);
            commonClass.EntityAttachmentToEmail(fileName, ParentId, email, retrieveActivityMimeAttachment, mostRecent, topRecords);
        }
示例#3
0
        public void Refresh(bool PromptForPassword)
        {
            try
            {
                LastRefresh = DateTime.Now;

                ArchiveFilename MostRecent;
                lock (ArchiveFileList)
                {
                    using (NetworkConnection newself = new NetworkConnection(CompleteBackupFolder, BackupCredentials))
                        ArchiveFileList.LoadAll(this);

                    // Locate most recent backup...
                    MostRecent = ArchiveFileList.FindMostRecent();
                }

                if (MostRecent == ArchiveFilename.MaxValue)
                {
                    MostRecentBackup = DateTime.MinValue;
                }
                else
                {
                    try
                    {
                        Manifest Manifest;
                        using (NetworkConnection newself = new NetworkConnection(CompleteBackupFolder, BackupCredentials))
                            Manifest = MostRecent.LoadArchiveManifest(this, PromptForPassword);
                        MostRecentBackup = Manifest.BackupStartTime;
                    }
                    catch (Ionic.Zip.BadPasswordException bpe)
                    {
                        if (PromptForPassword)
                        {
                            throw bpe;
                        }
                        else
                        {
                            MostRecentBackup = MostRecent.BackupDate;
                        }
                    }
                }

                // Also check for an Backup_Status.xml file...
                // This file is created with each backup, and is particularly helpful when we have an 'empty backup'
                // where no archive need be created (because nothing has changed).  We need to display to the user that
                // the project was backed up recently, but we needn't create an archive.  The Backup_Status.xml file
                // accomplishes this.
                FileInfo[] FileList = new DirectoryInfo(CompleteBackupFolder).GetFiles("Backup_Status.xml");
                if (FileList.Length > 0)
                {
                    BackupStatus Status = null;
                    try
                    {
                        Status = BackupStatus.Load(FileList[0].FullName);
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show("Unable to load backup status file (see error details below).  This file helps ZippyBackup keep track of some things, but we can also figure it out from scratch and make a new backup status file when you perform your next backup.  Click OK and ZippyBackup will proceed without it.  Your next backup may take longer than usual.\n\nDetailed error information: " + exc.Message);
                    }
                    if (Status != null)
                    {
                        if (MostRecent != ArchiveFilename.MaxValue &&
                            Status.LastArchive == MostRecent.ToString() &&
                            Status.LastBackup.ToUniversalTime() > MostRecentBackup.ToUniversalTime())
                        {
                            MostRecentBackup = Status.LastBackup;
                        }
                        MostRecentCompleteBackup = Status.LastCompletedBackup;
                        LastScanRelativePath     = Status.LastScanRelativePath;
                        LastVerifyRelativePath   = Status.LastVerifyRelativePath;
                        MostRecentVerify         = Status.LastVerify;
                        MostRecentCompleteVerify = Status.LastCompletedVerify;
                    }
                }

                // Clear out the manifest cache...
                lock (ManifestCache)
                    ManifestCache.Clear();

                LoadIssue = false;
            }
            catch (System.Security.Authentication.InvalidCredentialException) { LoadIssue = true; }
            catch (IOException) { LoadIssue = true; }
        }