Ejemplo n.º 1
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            string destinationFile         = request.Inputs["Destination Location"].AsString();
            string originZip               = request.Inputs["Origin Zip"].AsString();
            string destinationExistsChoice = request.Inputs["If the Destination Files Exist"].AsString();

            int    numberOfFiles = 0;
            bool   warn          = false;
            String warnMessage   = String.Empty;

            DirectoryInfo DestinationFolder = new DirectoryInfo(destinationFile);
            FileInfo      zipFile           = new FileInfo(originZip);

            if (zipFile.Exists)
            {
                if (!DestinationFolder.Exists)
                {
                    DestinationFolder.Create();
                }

                using (ZipFile zip1 = ZipFile.Read(zipFile.FullName.ToString()))
                {
                    foreach (ZipEntry e in zip1)
                    {
                        numberOfFiles = numberOfFiles + 1;
                        try
                        {
                            switch (destinationExistsChoice)
                            {
                            case "Overwrite":
                                e.Extract(DestinationFolder.ToString(), ExtractExistingFileAction.OverwriteSilently);
                                break;

                            case "Do not overwrite":
                                e.Extract(DestinationFolder.ToString(), ExtractExistingFileAction.DoNotOverwrite);
                                break;

                            default:
                                e.Extract(DestinationFolder.ToString(), ExtractExistingFileAction.OverwriteSilently);
                                break;
                            }
                        }
                        catch (Exception error) { warn = true; warnMessage += error.Message + "\n"; }
                    }
                }
            }
            else
            {
                response.LogErrorMessage("Cannot find Zip file " + request.Inputs["Origin Zip"].AsString());
            }

            response.Publish("Destination Location", DestinationFolder.FullName.ToString());
            response.Publish("Number of files decompressed", numberOfFiles.ToString());

            if (warn)
            {
                response.LogWarningMessage(warnMessage);
            }
        }
Ejemplo n.º 2
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            userName        = settings.UserName;
            password        = settings.Password;
            domain          = settings.Domain;
            serviceURL      = settings.ServiceUrl;
            exchangeVersion = settings.ExchangeVersion;

            userEmailAddr = request.Inputs["Mailbox Email Address"].AsString();


            ExchangeService service = new ExchangeService();

            switch (exchangeVersion)
            {
            case "Exchange2007_SP1":
                service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
                break;

            case "Exchange2010":
                service = new ExchangeService(ExchangeVersion.Exchange2010);
                break;

            case "Exchange2010_SP1":
                service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
                break;

            default:
                service = new ExchangeService();
                break;
            }

            service.Credentials = new WebCredentials(userName, password, domain);
            String AccountUrl = userName + "@" + domain;

            if (serviceURL.Equals("Autodiscover"))
            {
                service.AutodiscoverUrl(userEmailAddr, (a) => { return(true); });
            }
            else
            {
                service.Url = new Uri(serviceURL);
            }

            OofSettings userOOFSettings = service.GetUserOofSettings(userEmailAddr);

            if (request.Inputs.Contains("External Audiance"))
            {
                ExternalAudience = request.Inputs["External Audiance"].AsString();
                switch (ExternalAudience)
                {
                case "All":
                    userOOFSettings.ExternalAudience = OofExternalAudience.All;
                    break;

                case "Known":
                    userOOFSettings.ExternalAudience = OofExternalAudience.Known;
                    break;

                case "None":
                    userOOFSettings.ExternalAudience = OofExternalAudience.None;
                    break;

                default:
                    response.LogWarningMessage("State must be one of the following: Disabled, Enabled, Scheduled");
                    break;
                }
            }
            if (request.Inputs.Contains("Start Time"))
            {
                try
                {
                    StartTime = Convert.ToDateTime(request.Inputs["Start Time"].AsString());
                    userOOFSettings.Duration.StartTime = StartTime;
                }
                catch
                {
                    response.LogWarningMessage("Start Time must be a valid Date Time: Entered Value was " + request.Inputs["Start Time"].AsString());
                }
            }
            if (request.Inputs.Contains("End Time"))
            {
                try
                {
                    EndTime = Convert.ToDateTime(request.Inputs["End Time"].AsString());
                    userOOFSettings.Duration.EndTime = EndTime;
                }
                catch
                {
                    response.LogWarningMessage("End Time must be a valid Date Time: Entered Value was " + request.Inputs["End Time"].AsString());
                }
            }
            if (request.Inputs.Contains("External Reply"))
            {
                ExternalReply = request.Inputs["External Reply"].AsString();
                userOOFSettings.ExternalReply = ExternalReply;
            }
            if (request.Inputs.Contains("Internal Reply"))
            {
                InternalReply = request.Inputs["Internal Reply"].AsString();
                userOOFSettings.InternalReply = InternalReply;
            }
            if (request.Inputs.Contains("State"))
            {
                State = request.Inputs["State"].AsString();
                switch (State)
                {
                case "Disabled":
                    userOOFSettings.State = OofState.Disabled;
                    break;

                case "Enabled":
                    userOOFSettings.State = OofState.Enabled;
                    break;

                case "Scheduled":
                    userOOFSettings.State = OofState.Scheduled;
                    break;

                default:
                    response.LogWarningMessage("State must be one of the following: Disabled, Enabled, Scheduled");
                    break;
                }
            }

            service.SetUserOofSettings(userEmailAddr, userOOFSettings);
            userOOFSettings = service.GetUserOofSettings(userEmailAddr);
            response.WithFiltering().PublishRange(getOOF(userOOFSettings));
        }