예제 #1
0
        public PowerShellResults ProcessUpload(UploadFileContext context, WebServiceParameters param)
        {
            param.FaultIfNull();
            UploadUMParameter uploadUMParameter = (UploadUMParameter)param;

            uploadUMParameter.PromptFileStream = context.FileStream;
            uploadUMParameter.PromptFileName   = Path.GetFileName(context.FileName);
            if (uploadUMParameter.UMAutoAttendant == null && uploadUMParameter.UMDialPlan == null)
            {
                uploadUMParameter.UMAutoAttendant.FaultIfNull();
            }
            return(this.ImportObject(uploadUMParameter));
        }
예제 #2
0
        public PowerShellResults ProcessUpload(UploadFileContext context, WebServiceParameters param)
        {
            param.FaultIfNull();
            SetUserPhotoParameters setUserPhotoParameters = (SetUserPhotoParameters)param;

            setUserPhotoParameters.PhotoStream = context.FileStream;
            Identity identity = Identity.ParseIdentity(setUserPhotoParameters.Identity);

            if (identity == null || string.IsNullOrEmpty(identity.RawIdentity))
            {
                throw new BadQueryParameterException("Identity");
            }
            return(this.SetPhoto(identity, context.FileStream));
        }
예제 #3
0
 public PowerShellResults ProcessUpload(UploadFileContext context, WebServiceParameters parameters)
 {
     parameters.FaultIfNull();
     if (parameters is FingerprintUploadParameters)
     {
         FingerprintUploadParameters fingerprintUploadParameters = (FingerprintUploadParameters)parameters;
         byte[] array = new byte[context.FileStream.Length];
         context.FileStream.Read(array, 0, array.Length);
         fingerprintUploadParameters.FileData = array;
         string description = context.FileName.Substring(context.FileName.LastIndexOf("\\") + 1);
         fingerprintUploadParameters.Description = description;
         return(base.NewObject <Fingerprint, FingerprintUploadParameters>("New-Fingerprint", fingerprintUploadParameters));
     }
     return(null);
 }
예제 #4
0
        public PowerShellResults ProcessUpload(UploadFileContext context, WebServiceParameters param)
        {
            param.FaultIfNull();
            UploadExtensionParameter uploadExtensionParameter = (UploadExtensionParameter)param;

            uploadExtensionParameter.FileStream = context.FileStream;
            if (RbacPrincipal.Current.RbacConfiguration.HasRoleOfType(RoleType.MyReadWriteMailboxApps))
            {
                uploadExtensionParameter.AllowReadWriteMailbox = new SwitchParameter(true);
            }
            PSCommand pscommand = new PSCommand().AddCommand("New-App");

            this.AddParameters(pscommand, param);
            return(base.Invoke <ExtensionRow>(pscommand));
        }
예제 #5
0
        public virtual PowerShellResults ProcessUpload(UploadFileContext context, WebServiceParameters parameters)
        {
            PowerShellResults result;

            using (MemoryStream memoryStream = new MemoryStream(Math.Max((int)context.FileStream.Length / 2, 1024)))
            {
                using (GZipStream gzipStream = new GZipStream(memoryStream, CompressionMode.Compress))
                {
                    context.FileStream.CopyTo(gzipStream);
                }
                result = new PowerShellResults <EncodedFile>
                {
                    Output = new EncodedFile[]
                    {
                        new EncodedFile
                        {
                            FileContent = Convert.ToBase64String(memoryStream.ToArray())
                        }
                    }
                };
            }
            return(result);
        }
예제 #6
0
        public PowerShellResults ProcessFileUploadRequest(HttpContext httpContext)
        {
            HttpPostedFile httpPostedFile = httpContext.Request.Files["uploadFile"];

            if (httpPostedFile != null && !string.IsNullOrEmpty(httpPostedFile.FileName) && httpPostedFile.ContentLength > 0)
            {
                string         text          = httpContext.Request.Form["handlerClass"];
                IUploadHandler uploadHandler = this.CreateInstance(text);
                if (httpPostedFile.ContentLength <= uploadHandler.MaxFileSize)
                {
                    string            text2   = httpContext.Request.Form["parameters"];
                    object            obj     = text2.JsonDeserialize(uploadHandler.SetParameterType, null);
                    UploadFileContext context = new UploadFileContext(httpPostedFile.FileName, httpPostedFile.InputStream);
                    try
                    {
                        EcpEventLogConstants.Tuple_UploadRequestStarted.LogEvent(new object[]
                        {
                            EcpEventLogExtensions.GetUserNameToLog(),
                            text,
                            text2
                        });
                        return(uploadHandler.ProcessUpload(context, (WebServiceParameters)obj));
                    }
                    finally
                    {
                        EcpEventLogConstants.Tuple_UploadRequestCompleted.LogEvent(new object[]
                        {
                            EcpEventLogExtensions.GetUserNameToLog()
                        });
                    }
                }
                ByteQuantifiedSize byteQuantifiedSize = new ByteQuantifiedSize((ulong)((long)uploadHandler.MaxFileSize));
                throw new HttpException(Strings.FileExceedsLimit(byteQuantifiedSize.ToString()));
            }
            throw new HttpException(Strings.UploadFileCannotBeEmpty);
        }
        public override PowerShellResults ProcessUpload(UploadFileContext context, WebServiceParameters parameters)
        {
            string migrationBatchType = ((MigrationCsvUploadParameters)parameters).MigrationBatchType;
            string a;

            if ((a = migrationBatchType) != null)
            {
                MigrationBatchCsvSchema migrationBatchCsvSchema;
                if (!(a == "LocalMove"))
                {
                    if (!(a == "RemoteMove"))
                    {
                        if (!(a == "Staged"))
                        {
                            if (!(a == "IMAP"))
                            {
                                if (!(a == "Cutover"))
                                {
                                    goto IL_7C;
                                }
                                goto IL_7C;
                            }
                            else
                            {
                                migrationBatchCsvSchema = new MigrationBatchCsvSchema();
                            }
                        }
                        else
                        {
                            migrationBatchCsvSchema = new ExchangeMigrationBatchCsvSchema();
                        }
                    }
                    else
                    {
                        migrationBatchCsvSchema = new MigrationRemoteMoveCsvSchema();
                    }
                }
                else
                {
                    migrationBatchCsvSchema = new MigrationLocalMoveCsvSchema();
                }
                migrationBatchCsvSchema.AllowUnknownColumnsInCSV = ((MigrationCsvUploadParameters)parameters).AllowUnknownColumnsInCsv;
                CsvRow?csvRow = null;
                int    num    = 0;
                using (MemoryStream memoryStream = new MemoryStream((int)context.FileStream.Length))
                {
                    context.FileStream.CopyTo(memoryStream);
                    context.FileStream.Position = 0L;
                    memoryStream.Position       = 0L;
                    try
                    {
                        foreach (CsvRow csvRow2 in migrationBatchCsvSchema.Read(memoryStream))
                        {
                            if (csvRow2.Index > 0)
                            {
                                csvRow = new CsvRow?(csvRow ?? csvRow2);
                                num++;
                            }
                        }
                    }
                    catch (CsvUnknownColumnsException ex)
                    {
                        throw new UnknownColumnsInCsvException(ex.Columns);
                    }
                }
                if (num == 0)
                {
                    throw new LocalizedException(Strings.NoMailboxInCsv);
                }
                PowerShellResults <EncodedFile> powerShellResults = (PowerShellResults <EncodedFile>)base.ProcessUpload(context, parameters);
                return(new PowerShellResults <MigrationCsvFile>
                {
                    Output = new MigrationCsvFile[]
                    {
                        new MigrationCsvFile
                        {
                            FileContent = powerShellResults.Value.FileContent,
                            MailboxCount = num,
                            FirstSmtpAddress = ((csvRow != null) ? csvRow.Value["EmailAddress"] : null)
                        }
                    }
                });
            }
IL_7C:
            throw new Exception(string.Format("Migration type '{0}' doesn't require CSV input.", migrationBatchType));
        }