@@ -36,9 +36,9 @@ public PSSyncOutputEvents(PSCmdlet cmdlet)
36
36
{
37
37
this . cmdlet = cmdlet ;
38
38
// TODO: CLU
39
- this . runspace = RunspaceFactory . CreateRunspace ( null ) ;
39
+ this . runspace = RunspaceFactory . CreateRunspace ( InitialSessionState . CreateDefault ( ) ) ;
40
40
//this.runspace = RunspaceFactory.CreateRunspace(this.cmdlet.Host);
41
- this . runspace . Open ( ) ;
41
+ // this.runspace.Open();
42
42
}
43
43
44
44
private static string FormatDuration ( TimeSpan ts )
@@ -47,7 +47,7 @@ private static string FormatDuration(TimeSpan ts)
47
47
{
48
48
return String . Format ( "{0:00}:{1:00}:{2:00}" , ts . Hours , ts . Minutes , ts . Seconds ) ;
49
49
}
50
- return String . Format ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsFormatDuration" ) , ts . Days , ts . Hours , ts . Minutes , ts . Seconds ) ;
50
+ return String . Format ( Rsrc . PSSyncOutputEventsFormatDuration , ts . Days , ts . Hours , ts . Minutes , ts . Seconds ) ;
51
51
}
52
52
53
53
public void ProgressCopyStatus ( ProgressRecord record )
@@ -57,13 +57,13 @@ public void ProgressCopyStatus(ProgressRecord record)
57
57
58
58
public void ProgressCopyStatus ( double precentComplete , double avgThroughputMbps , TimeSpan remainingTime )
59
59
{
60
- LogProgress ( 0 , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsCopying" ) , precentComplete , remainingTime , avgThroughputMbps ) ;
60
+ LogProgress ( 0 , Rsrc . PSSyncOutputEventsCopying , precentComplete , remainingTime , avgThroughputMbps ) ;
61
61
}
62
62
63
63
public void ProgressCopyComplete ( TimeSpan elapsed )
64
64
{
65
- LogProgressComplete ( 0 , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsCopying" ) ) ;
66
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsElapsedTimeForCopy" ) , FormatDuration ( elapsed ) ) ;
65
+ LogProgressComplete ( 0 , Rsrc . PSSyncOutputEventsCopying ) ;
66
+ LogMessage ( Rsrc . PSSyncOutputEventsElapsedTimeForCopy , FormatDuration ( elapsed ) ) ;
67
67
}
68
68
69
69
public void ProgressUploadStatus ( ProgressRecord record )
@@ -73,52 +73,55 @@ public void ProgressUploadStatus(ProgressRecord record)
73
73
74
74
public void ProgressUploadStatus ( double precentComplete , double avgThroughputMbps , TimeSpan remainingTime )
75
75
{
76
- LogProgress ( 0 , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsUploading" ) , precentComplete , remainingTime , avgThroughputMbps ) ;
76
+ LogProgress ( 0 , Rsrc . PSSyncOutputEventsUploading , precentComplete , remainingTime , avgThroughputMbps ) ;
77
77
}
78
78
79
79
private void LogProgress ( int activityId , string activity , double precentComplete , TimeSpan remainingTime , double avgThroughputMbps )
80
80
{
81
- var message = String . Format ( Rsrc . ResourceManager . GetString ( "PSSyncOutputEventsLogProgress" ) ,
82
- precentComplete ,
83
- FormatDuration ( remainingTime ) ,
84
- avgThroughputMbps ) ;
85
- var progressCommand = String . Format ( @"Write-Progress -Id {0} -Activity '{1}' -Status '{2}' -SecondsRemaining {3} -PercentComplete {4}" , activityId , activity , message , ( int ) remainingTime . TotalSeconds , ( int ) precentComplete ) ;
86
81
using ( var ps = System . Management . Automation . PowerShell . Create ( ) )
87
82
{
88
83
ps . Runspace = runspace ;
84
+ var message = String . Format ( Rsrc . PSSyncOutputEventsLogProgress ,
85
+ precentComplete ,
86
+ FormatDuration ( remainingTime ) ,
87
+ avgThroughputMbps ) ;
88
+ var progressCommand = String . Format ( @"Write-Progress -Id {0} -Activity '{1}' -Status '{2}' -SecondsRemaining {3} -PercentComplete {4}" , activityId , activity , message , ( int ) remainingTime . TotalSeconds , ( int ) precentComplete ) ;
89
89
// TODO: CLU
90
+ Console . WriteLine ( progressCommand ) ;
90
91
//ps.AddScript(progressCommand);
91
- ps . Invoke ( ) ;
92
+ // ps.Invoke();
92
93
}
93
94
}
94
95
95
96
private void LogProgressComplete ( int activityId , string activity )
96
97
{
97
- var progressCommand = String . Format ( @"Write-Progress -Id {0} -Activity '{1}' -Status '{2}' -Completed" , activityId , activity , Rsrc . ResourceManager . GetString ( "PSSyncOutputEventsLogProgressCompleteCompleted" ) ) ;
98
98
using ( var ps = System . Management . Automation . PowerShell . Create ( ) )
99
99
{
100
- ps . Runspace = runspace ;
100
+ var progressCommand = String . Format ( @"Write-Progress -Id {0} -Activity '{1}' -Status '{2}' -Completed" , activityId , activity , Rsrc . PSSyncOutputEventsLogProgressCompleteCompleted ) ;
101
101
// TODO: CLU
102
+ Console . WriteLine ( progressCommand ) ;
103
+ ps . Runspace = runspace ;
102
104
//ps.AddScript(progressCommand);
103
- ps . Invoke ( ) ;
105
+ // ps.Invoke();
104
106
}
105
107
}
106
108
107
109
public void MessageCreatingNewPageBlob ( long pageBlobSize )
108
110
{
109
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsCreatingNewPageBlob, pageBlobSize" ) ) ;
111
+ LogMessage ( Rsrc . PSSyncOutputEventsCreatingNewPageBlob , pageBlobSize ) ;
110
112
}
111
113
112
114
private void LogMessage ( string format , params object [ ] parameters )
113
115
{
114
- var message = String . Format ( format , parameters ) ;
115
- var verboseMessage = String . Format ( "Write-Host '{0}'" , message ) ;
116
116
using ( var ps = System . Management . Automation . PowerShell . Create ( ) )
117
117
{
118
118
ps . Runspace = runspace ;
119
+ var message = String . Format ( format , parameters ) ;
120
+ var verboseMessage = String . Format ( "Write-Host '{0}'" , message ) ;
119
121
// TODO: CLU
122
+ Console . WriteLine ( verboseMessage ) ;
120
123
//ps.AddScript(verboseMessage);
121
- ps . Invoke ( ) ;
124
+ // ps.Invoke();
122
125
}
123
126
}
124
127
@@ -127,21 +130,23 @@ private void LogError(Exception e)
127
130
using ( var ps = System . Management . Automation . PowerShell . Create ( ) )
128
131
{
129
132
ps . Runspace = runspace ;
130
- ps . AddCommand ( "Write-Error" ) ;
131
- ps . AddParameter ( "ErrorRecord" , new ErrorRecord ( e , String . Empty , ErrorCategory . NotSpecified , null ) ) ;
132
- ps . Invoke ( ) ;
133
+ // TODO: CLU
134
+ Console . Error . WriteLine ( new ErrorRecord ( e , String . Empty , ErrorCategory . NotSpecified , null ) ) ;
135
+ //ps.AddCommand("Write-Error");
136
+ //ps.AddParameter("ErrorRecord", new ErrorRecord(e, String.Empty, ErrorCategory.NotSpecified, null));
137
+ //ps.Invoke();
133
138
}
134
139
}
135
140
136
141
public void MessageResumingUpload ( )
137
142
{
138
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsResumingUpload" ) ) ;
143
+ LogMessage ( Rsrc . PSSyncOutputEventsResumingUpload ) ;
139
144
}
140
145
141
146
public void ProgressUploadComplete ( TimeSpan elapsed )
142
147
{
143
- LogProgressComplete ( 0 , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsUploading" ) ) ;
144
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsElapsedTimeForUpload" ) , FormatDuration ( elapsed ) ) ;
148
+ LogProgressComplete ( 0 , Rsrc . PSSyncOutputEventsUploading ) ;
149
+ LogMessage ( Rsrc . PSSyncOutputEventsElapsedTimeForUpload , FormatDuration ( elapsed ) ) ;
145
150
}
146
151
147
152
public void ProgressDownloadStatus ( ProgressRecord record )
@@ -151,13 +156,13 @@ public void ProgressDownloadStatus(ProgressRecord record)
151
156
152
157
public void ProgressDownloadStatus ( double precentComplete , double avgThroughputMbps , TimeSpan remainingTime )
153
158
{
154
- LogProgress ( 0 , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsDownloading" ) , precentComplete , remainingTime , avgThroughputMbps ) ;
159
+ LogProgress ( 0 , Rsrc . PSSyncOutputEventsDownloading , precentComplete , remainingTime , avgThroughputMbps ) ;
155
160
}
156
161
157
162
public void ProgressDownloadComplete ( TimeSpan elapsed )
158
163
{
159
- LogProgressComplete ( 0 , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsDownloading" ) ) ;
160
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsElapsedTimeForDownload" ) , FormatDuration ( elapsed ) ) ;
164
+ LogProgressComplete ( 0 , Rsrc . PSSyncOutputEventsDownloading ) ;
165
+ LogMessage ( Rsrc . PSSyncOutputEventsElapsedTimeForDownload , FormatDuration ( elapsed ) ) ;
161
166
}
162
167
163
168
public void ProgressOperationStatus ( ProgressRecord record )
@@ -167,19 +172,19 @@ public void ProgressOperationStatus(ProgressRecord record)
167
172
168
173
public void ProgressOperationStatus ( double percentComplete , double avgThroughputMbps , TimeSpan remainingTime )
169
174
{
170
- LogProgress ( 1 , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsCalculatingMD5Hash" ) , percentComplete , remainingTime , avgThroughputMbps ) ;
175
+ LogProgress ( 1 , Rsrc . PSSyncOutputEventsCalculatingMD5Hash , percentComplete , remainingTime , avgThroughputMbps ) ;
171
176
}
172
177
173
178
public void ProgressOperationComplete ( TimeSpan elapsed )
174
179
{
175
- LogProgressComplete ( 1 , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsCalculatingMD5Hash" ) ) ;
176
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsElapsedTimeForOperation" ) , FormatDuration ( elapsed ) ) ;
180
+ LogProgressComplete ( 1 , Rsrc . PSSyncOutputEventsCalculatingMD5Hash ) ;
181
+ LogMessage ( Rsrc . PSSyncOutputEventsElapsedTimeForOperation , FormatDuration ( elapsed ) ) ;
177
182
}
178
183
179
184
180
185
public void ErrorUploadFailedWithExceptions ( IList < Exception > exceptions )
181
186
{
182
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsUploadFailedWithException" ) ) ;
187
+ LogMessage ( Rsrc . PSSyncOutputEventsUploadFailedWithException ) ;
183
188
foreach ( var exception in exceptions )
184
189
{
185
190
LogError ( exception ) ;
@@ -188,17 +193,17 @@ public void ErrorUploadFailedWithExceptions(IList<Exception> exceptions)
188
193
189
194
public void MessageCalculatingMD5Hash ( string filePath )
190
195
{
191
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsCalculatingMD5HashForFile" ) , filePath ) ;
196
+ LogMessage ( Rsrc . PSSyncOutputEventsCalculatingMD5HashForFile , filePath ) ;
192
197
}
193
198
194
199
public void MessageMD5HashCalculationFinished ( )
195
200
{
196
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsMD5HashCalculationFinished" ) ) ;
201
+ LogMessage ( Rsrc . PSSyncOutputEventsMD5HashCalculationFinished ) ;
197
202
}
198
203
199
204
public void MessageRetryingAfterANetworkDisruption ( )
200
205
{
201
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsRetryingAfterANetworkDisruption" ) ) ;
206
+ LogMessage ( Rsrc . PSSyncOutputEventsRetryingAfterANetworkDisruption ) ;
202
207
}
203
208
204
209
public void DebugRetryingAfterException ( Exception lastException )
@@ -215,34 +220,35 @@ public void DebugRetryingAfterException(Exception lastException)
215
220
216
221
public void MessageDetectingActualDataBlocks ( )
217
222
{
218
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsDetectingActualDataBlocks" ) ) ;
223
+ LogMessage ( Rsrc . PSSyncOutputEventsDetectingActualDataBlocks ) ;
219
224
}
220
225
221
226
public void MessageDetectingActualDataBlocksCompleted ( )
222
227
{
223
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsDetectingActualDataBlocksCompleted" ) ) ;
228
+ LogMessage ( Rsrc . PSSyncOutputEventsDetectingActualDataBlocksCompleted ) ;
224
229
}
225
230
226
231
public void MessagePrintBlockRange ( IndexRange range )
227
232
{
228
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsPrintBlockRange" ) , range , range . Length ) ;
233
+ LogMessage ( Rsrc . PSSyncOutputEventsPrintBlockRange , range , range . Length ) ;
229
234
}
230
235
231
236
public void DebugEmptyBlockDetected ( IndexRange range )
232
237
{
233
- LogDebug ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsEmptyBlockDetected" ) , range . ToString ( ) ) ;
238
+ LogDebug ( Rsrc . PSSyncOutputEventsEmptyBlockDetected , range . ToString ( ) ) ;
234
239
}
235
240
236
241
private void LogDebug ( string format , params object [ ] parameters )
237
242
{
238
- var message = String . Format ( format , parameters ) ;
239
- var debugMessage = String . Format ( "Write-Debug -Message '{0}'" , message ) ;
240
243
using ( var ps = System . Management . Automation . PowerShell . Create ( ) )
241
244
{
242
245
ps . Runspace = runspace ;
243
246
// TODO: CLU
247
+ var message = String . Format ( format , parameters ) ;
248
+ var debugMessage = String . Format ( "Write-Debug -Message '{0}'" , message ) ;
249
+ Console . WriteLine ( debugMessage ) ;
244
250
//ps.AddScript(debugMessage);
245
- ps . Invoke ( ) ;
251
+ // ps.Invoke();
246
252
}
247
253
}
248
254
@@ -253,33 +259,39 @@ public void ProgressEmptyBlockDetection(int processedRangeCount, int totalRangeC
253
259
if ( processedRangeCount >= totalRangeCount )
254
260
{
255
261
256
- var progressCommand1 = String . Format ( @"Write-Progress -Id {0} -Activity '{1}' -Status '{2}' -Completed" , 2 , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsProgressEmptyBlockDetection" ) , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsEmptyBlockDetectionCompleted" ) ) ;
262
+ var progressCommand1 = String . Format ( @"Write-Progress -Id {0} -Activity '{1}' -Status '{2}' -Completed" , 2 , Rsrc . PSSyncOutputEventsProgressEmptyBlockDetection , Rsrc . PSSyncOutputEventsEmptyBlockDetectionCompleted ) ;
257
263
ps . Runspace = runspace ;
258
264
// TODO: CLU
265
+ Console . WriteLine ( progressCommand1 ) ;
259
266
//ps.AddScript(progressCommand1);
260
- ps . Invoke ( ) ;
267
+ // ps.Invoke();
261
268
return ;
262
269
}
263
270
264
- var progressCommand = String . Format ( @"Write-Progress -Id {0} -Activity '{1}' -Status '{2}' -SecondsRemaining {3} -PercentComplete {4}" , 2 , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsProgressEmptyBlockDetection" ) , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsEmptyBlockDetectionDetecting" ) , - 1 , ( ( double ) processedRangeCount / totalRangeCount ) * 100 ) ;
271
+ var progressCommand = String . Format ( @"Write-Progress -Id {0} -Activity '{1}' -Status '{2}' -SecondsRemaining {3} -PercentComplete {4}" , 2 , Rsrc . PSSyncOutputEventsProgressEmptyBlockDetection , Rsrc . PSSyncOutputEventsEmptyBlockDetectionDetecting , - 1 , ( ( double ) processedRangeCount / totalRangeCount ) * 100 ) ;
265
272
ps . Runspace = runspace ;
266
273
// TODO: CLU
274
+ Console . WriteLine ( progressCommand ) ;
267
275
//ps.AddScript(progressCommand);
268
- ps . Invoke ( ) ;
276
+ // ps.Invoke();
269
277
}
270
278
}
271
279
272
280
public void WriteVerboseWithTimestamp ( string message , params object [ ] args )
273
281
{
282
+ // TODO: CLU
274
283
var messageWithTimeStamp = string . Format ( CultureInfo . CurrentCulture , "{0:T} - {1}" , DateTime . Now , string . Format ( message , args ) ) ;
275
284
var progressCommand = String . Format ( @"Write-Verbose -Message {0}" , messageWithTimeStamp ) ;
285
+ Console . WriteLine ( progressCommand ) ;
286
+ /*
276
287
using (var ps = System.Management.Automation.PowerShell.Create())
277
288
{
278
289
ps.Runspace = runspace;
279
290
// TODO: CLU
280
291
//ps.AddScript(progressCommand);
281
- ps . Invoke ( ) ;
292
+ // ps.Invoke();
282
293
}
294
+ */
283
295
}
284
296
285
297
@@ -295,7 +307,8 @@ protected virtual void Dispose(bool disposing)
295
307
{
296
308
if ( disposing )
297
309
{
298
- runspace . Dispose ( ) ;
310
+ // TODO: CLU
311
+ //runspace.Dispose();
299
312
}
300
313
this . disposed = true ;
301
314
}
0 commit comments