コード例 #1
0
        private static string doSendFilesWithZetaUploader(
            BackgroundWorker bw,
            SendProjectInformation information,
            string[] filePathsToSend)
        {
            if (filePathsToSend.Length > 0)
            {
                bw.ReportProgress(
                    0,
                    new ExcelProgressInformation
                {
                    TemporaryProgressMessage =
                        string.Format(
                            Resources.ExcelExportController_doSendFilesWithZetaUploader_Sending__0__files_through_Zeta_Uploader___,
                            filePathsToSend.Length)
                });

                var sendInfo =
                    new ZetaUploaderCommunicationClientTransferInformation2
                {
                    EMailReceiverAddresses =
                        splitEMailAddresses(
                            information.SendFilesEMailReceivers),
                    EMailSubject =
                        replaceEMailPlaceholders(
                            information.SendFilesEMailSubject, information),
                    AdditionalRemarks =
                        replaceEMailPlaceholders(
                            information.SendFilesEMailBody, information),
                    Language =
                        CultureHelper.GetSupportedUICultureFromThreeLetterWindowsLanguageName(
                            CultureInfo.CurrentUICulture.ThreeLetterWindowsLanguageName).TwoLetterISOLanguageName,
                    UserStates = new[] { new ZulPair {
                                             Name = @"allow-browse", Value = bool.TrueString
                                         } },
                };

                // --

                if (filePathsToSend.Length == 1)
                {
                    sendInfo.FileName    = ZlpPathHelper.GetFileNameFromFilePath(filePathsToSend[0]);
                    sendInfo.FileContent = ZlpIOHelper.ReadAllBytes(filePathsToSend[0]);
                }
                else
                {
                    sendInfo.FileName = replaceEMailPlaceholders(@"ZRE-Sent-Project-{SafeProjectName}.zip", information);

                    var compressInfos = new CompressHeterogeneousInfos();

                    compressInfos.AddFiles(filePathsToSend);

                    sendInfo.FileContent =
                        CompressionHelper.CompressHeterogeneous(
                            compressInfos);
                }

                if (bw.CancellationPending)
                {
                    throw new OperationCanceledException();
                }

                var ws     = WebServiceManager.Current.ZetaUploaderWS;
                var result = ws.SendFile2(sendInfo);

                return(result.DownloadUrl);
            }
            else
            {
                throw new Exception(Resources.SendProjectController_doSendFilesWithZetaUploader_No_files_to_send_);
            }
        }
コード例 #2
0
		private static string doSendFilesWithZetaUploader(
			BackgroundWorker bw,
			SendProjectInformation information,
			string[] filePathsToSend)
		{
			if (filePathsToSend.Length > 0)
			{
				bw.ReportProgress(
					0,
					new ExcelProgressInformation
					{
						TemporaryProgressMessage =
							string.Format(
								Resources.ExcelExportController_doSendFilesWithZetaUploader_Sending__0__files_through_Zeta_Uploader___,
								filePathsToSend.Length)
					});

				var sendInfo =
					new ZetaUploaderCommunicationClientTransferInformation2
					{
						EMailReceiverAddresses =
							splitEMailAddresses(
								information.SendFilesEMailReceivers),
						EMailSubject =
							replaceEMailPlaceholders(
								information.SendFilesEMailSubject, information),
						AdditionalRemarks =
							replaceEMailPlaceholders(
								information.SendFilesEMailBody, information),
						Language =
							CultureHelper.GetSupportedUICultureFromThreeLetterWindowsLanguageName(
								CultureInfo.CurrentUICulture.ThreeLetterWindowsLanguageName).TwoLetterISOLanguageName,
						UserStates = new[] { new ZulPair { Name = @"allow-browse", Value = bool.TrueString } },
					};

				// --

				if (filePathsToSend.Length == 1)
				{
					sendInfo.FileName = ZlpPathHelper.GetFileNameFromFilePath(filePathsToSend[0]);
					sendInfo.FileContent = ZlpIOHelper.ReadAllBytes(filePathsToSend[0]);
				}
				else
				{
					sendInfo.FileName = replaceEMailPlaceholders(@"ZRE-Sent-Project-{SafeProjectName}.zip", information);

					var compressInfos = new CompressHeterogeneousInfos();

					compressInfos.AddFiles(filePathsToSend);

					sendInfo.FileContent =
						CompressionHelper.CompressHeterogeneous(
							compressInfos);
				}

				if (bw.CancellationPending)
				{
					throw new OperationCanceledException();
				}

				var ws = WebServiceManager.Current.ZetaUploaderWS;
				var result = ws.SendFile2(sendInfo);

				return result.DownloadUrl;
			}
			else
			{
				throw new Exception(Resources.SendProjectController_doSendFilesWithZetaUploader_No_files_to_send_);
			}
		}