本文整理汇总了C#中PSTestLib.PSCmdletBase.WriteVerbose方法的典型用法代码示例。如果您正苦于以下问题:C# PSCmdletBase.WriteVerbose方法的具体用法?C# PSCmdletBase.WriteVerbose怎么用?C# PSCmdletBase.WriteVerbose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PSTestLib.PSCmdletBase
的用法示例。
在下文中一共展示了PSCmdletBase.WriteVerbose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteErrorMethod045OnErrorScreenshot
protected override void WriteErrorMethod045OnErrorScreenshot(PSCmdletBase cmdlet)
{
WriteVerbose(this, "WriteErrorMethod045OnErrorScreenshot UIAutomation");
if (!Preferences.OnErrorScreenShot) return;
IUiElement elementToTakeScreenShot = null;
try {
if (null != CurrentData.CurrentWindow) {
cmdlet.WriteVerbose(cmdlet, "taking screenshot of the current window");
elementToTakeScreenShot = CurrentData.CurrentWindow;
} else {
cmdlet.WriteVerbose(cmdlet, "taking screenshot of the desktop object");
elementToTakeScreenShot = UiElement.RootElement;
}
}
catch {
cmdlet.WriteVerbose(cmdlet, "taking screenshot of the desktop object (on fail)");
elementToTakeScreenShot = UiElement.RootElement;
}
cmdlet.WriteVerbose(cmdlet, "taking screenshot");
UiaHelper.GetScreenshotOfAutomationElement(
cmdlet,
elementToTakeScreenShot,
CmdletName(cmdlet),
true,
new ScreenshotRect(),
string.Empty,
Preferences.OnErrorScreenShotFormat);
cmdlet.WriteVerbose(cmdlet, "done");
}
示例2: WriteVerbose
public void WriteVerbose(PSCmdletBase cmdlet, object obj)
{
string cmdletName = "? : ";
string objectString = string.Empty;
try {
objectString = obj.ToString();
}
catch {}
if (null != cmdlet) {
try {
cmdletName =
CmdletSignature(cmdlet);
cmdlet.WriteVerbose(cmdletName + objectString);
}
catch {
cmdlet.WriteVerbose(cmdletName + "failed");
}
} else {
cmdlet.WriteVerbose(cmdletName + objectString);
}
}
示例3: runTwoScriptBlockCollections
protected internal void runTwoScriptBlockCollections(
ScriptBlock[] scriptblocksSet1,
ScriptBlock[] scriptblocksSet2,
// 20130318
//PSCmdletBase cmdlet)
PSCmdletBase cmdlet,
object[] parameters)
{
cmdlet.WriteVerbose(cmdlet, "preparing scriptblocks");
System.Collections.Generic.List<ScriptBlock> scriptblocks =
new System.Collections.Generic.List<ScriptBlock>();
try {
if (scriptblocksSet1 != null &&
scriptblocksSet1.Length > 0) {
foreach (ScriptBlock sb in scriptblocksSet1) {
scriptblocks.Add(sb);
}
}
if (scriptblocksSet2 != null &&
scriptblocksSet2.Length > 0) {
foreach (ScriptBlock sb in scriptblocksSet2) {
scriptblocks.Add(sb);
}
}
// if (null == scriptblocks || 0 == scriptblocks.Count) {
//
// cmdlet.WriteVerbose(cmdlet, "there is no any StopAction scriptblock");
//
// //throw new Exception("There are no StopAction scriptblocks, define at least one");
// cmdlet.WriteError(
// cmdlet,
// "There are no StopAction scriptblocks, define at least one",
// "NoStopActionScriptblocks",
// ErrorCategory.InvalidArgument,
// true);
// }
cmdlet.WriteVerbose(cmdlet, "scriptblocks were prepared");
}
catch (Exception eScriptblocksPreparation) {
cmdlet.WriteVerbose(cmdlet, "Scriptblocks are not going to be run");
cmdlet.WriteVerbose(cmdlet, eScriptblocksPreparation.Message);
cmdlet.WriteError(
cmdlet,
eScriptblocksPreparation.Message,
"ScriptblocksNotPrepared",
ErrorCategory.InvalidOperation,
true);
}
// 20130318
//runScriptBlocks(scriptblocks, cmdlet, false);
// 20130319
try {
cmdlet.WriteVerbose(cmdlet, "running scriptblocks");
runScriptBlocks(scriptblocks, cmdlet, false, parameters);
cmdlet.WriteVerbose(cmdlet, "Scriptblocks finished successfully");
}
catch (Exception eScriptBlocks) {
cmdlet.WriteVerbose(cmdlet, "Scriptblocks failed");
cmdlet.WriteVerbose(cmdlet, eScriptBlocks.Message);
cmdlet.WriteError(
cmdlet,
eScriptBlocks.Message,
"ScriptblocksFailed",
ErrorCategory.InvalidResult,
true);
}
}
示例4: WriteObject
public void WriteObject(PSCmdletBase cmdlet, object outputObject)
{
if (PSCmdletBase.UnitTestMode) {
UnitTestOutput.CheckInitialized();
UnitTestOutput.StartAddingOutput();
}
cmdlet.WriteVerbose(cmdlet, "outputting the object");
this.writeSingleObject(cmdlet, outputObject);
}
示例5: writeSingleObject
private void writeSingleObject(PSCmdletBase cmdlet, object outputObject)
{
//if (WriteObjectMethod010CheckOutputObject(outputObject)) {
if (CheckSingleObject(cmdlet, outputObject)) {
cmdlet.WriteVerbose(cmdlet, "the output object is not null");
// WriteObjectMethod020Highlight(cmdlet, outputObject);
//
// WriteObjectMethod030RunScriptBlocks(cmdlet, outputObject);
//
// WriteObjectMethod040SetTestResult(cmdlet, outputObject);
//
// WriteObjectMethod045OnSuccessScreenshot(cmdlet, outputObject);
//
// WriteObjectMethod050OnSuccessDelay(cmdlet, outputObject);
BeforeWriteSingleObject(cmdlet, outputObject);
//WriteSingleObject(cmdlet, outputObject);
try {
if (PSCmdletBase.UnitTestMode) {
UnitTestOutput.Add(outputObject);
} else {
// WriteObjectMethod060OutputResult(cmdlet, outputObject);
WriteSingleObject(cmdlet, outputObject);
}
}
catch {}
//WriteObjectMethod060OutputResult(cmdlet, outputObject);
AfterWriteSingleObject(cmdlet, outputObject);
// WriteObjectMethod070Report(cmdlet, outputObject);
//WriteObjectMethod080ReportFailure();
} else {
}
}
示例6: runScriptBlocks
// 20120816
public void runScriptBlocks(
System.Collections.Generic.List<ScriptBlock> scriptblocks,
PSCmdletBase cmdlet,
// 20130318
//bool eventHandlers)
bool eventHandlers,
object[] parameters)
{
try {
if (scriptblocks != null &&
scriptblocks.Count > 0) {
cmdlet.WriteVerbose(cmdlet, "there are " + scriptblocks.Count.ToString() + " scriptblock(s) to run");
foreach (ScriptBlock sb in scriptblocks) {
if (sb != null) {
try {
if (eventHandlers) {
cmdlet.WriteVerbose(cmdlet, "run event handler");
runScriptBlock runner = new runScriptBlock(runSBEvent);
runner(sb, cmdlet.EventSource, cmdlet.EventArgs);
} else {
cmdlet.WriteVerbose(cmdlet, "run action with parameters");
// 20130318
//runScriptBlock runner = new runScriptBlock(runSBAction);
//runner(sb, cmdlet.EventSource, cmdlet.EventArgs);
runScriptBlockWithParameters runnerWithParams = new runScriptBlockWithParameters(runSBActionWithParams);
cmdlet.WriteVerbose(cmdlet, "the scriptblock runner has been created");
// 20130606
try {
cmdlet.WriteVerbose(cmdlet, "listing parameters");
if (null == parameters || 0 == parameters.Length) {
cmdlet.WriteVerbose(cmdlet, "there are no parameters");
} else {
foreach (var singleParam in parameters) {
cmdlet.WriteVerbose(cmdlet, singleParam);
}
}
}
catch (Exception eListParameters) {
cmdlet.WriteVerbose(cmdlet, eListParameters.Message);
}
runnerWithParams(sb, parameters);
cmdlet.WriteVerbose(cmdlet, "the scriptblock runner has finished");
}
} catch (Exception eInner) {
// 20130318
// ErrorRecord err =
// new ErrorRecord(
// eInner,
// "InvokeException",
// ErrorCategory.OperationStopped,
// sb);
// err.ErrorDetails =
// new ErrorDetails("Error in " +
// sb.ToString());
// WriteError(this, err, false);
// this.WriteError(
// this,
// "Error in " +
// sb.ToString() +
// ". " +
// eInner.Message,
// "InvokeException",
// ErrorCategory.OperationStopped,
// // 20130318
// //false);
// true);
// 20130606
cmdlet.WriteVerbose(cmdlet, eInner.Message);
//throw;
throw new Exception("Failed to run scriptblock");
}
}
}
}
} catch (Exception eOuter) {
// 20130318
// WriteError(this,
// new ErrorRecord(eOuter, "runScriptBlocks", ErrorCategory.InvalidArgument, null),
// true);
// this.WriteError(
//.........这里部分代码省略.........
示例7: OpenDatabase
public static void OpenDatabase(
PSCmdletBase cmdlet,
string fileName,
bool structureDB,
bool repositoryDB,
bool resultsDB)
{
// check input
try {
string absolutePath =
System.IO.Path.GetFullPath(fileName);
cmdlet.WriteVerbose(cmdlet, absolutePath);
if (System.IO.File.Exists(absolutePath)) {
string connectionString =
"Data Source='" +
absolutePath +
"';Version=3;Max Pool Size=100;UseUTF16Encoding=True;";
cmdlet.WriteVerbose(cmdlet, connectionString);
using (SQLiteConnection conn = new SQLiteConnection(connectionString)) {
conn.Open();
IDatabase database =
new Database(
((DatabaseFileCmdletBase)cmdlet).Name,
fileName,
conn);
// check structure DB
// check repository DB
// check data DB
conn.Close();
if (structureDB) {
TestData.CurrentStructureDB = database;
}
if (repositoryDB) {
TestData.CurrentRepositoryDB = database;
}
if (resultsDB) {
TestData.CurrentResultsDB = database;
}
SQLiteData.Databases.Add(database);
cmdlet.WriteObject(cmdlet, database);
}
}
}
catch (Exception eOpenDB) {
cmdlet.WriteError(
cmdlet,
"Unable to open the database. " +
eOpenDB.Message,
"OpenDBFailed",
ErrorCategory.InvalidOperation,
true);
}
}
示例8: runSQLCommand
private static void runSQLCommand(PSCmdletBase cmdlet, IDatabase database, string SQLCode)
{
if (null == database) {
cmdlet.WriteError(
cmdlet,
"Could not find the database with name '" +
database.Name +
"' among registered databases",
"CouldNotFindDB",
ErrorCategory.InvalidArgument,
true);
}
if (null == database.Connection) {
database.Connection =
new SQLiteConnection(database.ConnectionString);
}
if (database.Connection.State == ConnectionState.Closed) {
database.Connection.Open();
}
using (SQLiteCommand cmd =
new SQLiteCommand(SQLCode)) {
cmd.Connection = database.Connection;
//cmdlet.WriteVerbose(cmdlet, cmd.ExecuteNonQuery().ToString());
int result = cmd.ExecuteNonQuery();
cmdlet.WriteVerbose(
cmdlet,
SQLCode +
": " +
result.ToString());
}
}
示例9: BackupTestResults
//public static void BackupTestResults(PSCmdletBase cmdlet, SQLiteConnection connection)
public static void BackupTestResults(PSCmdletBase cmdlet, string databaseName)
{
// 20120920
SQLiteConnection connection = ConnectionMakeAlive(cmdlet, databaseName);
DbProviderFactory factory = new SQLiteFactory();
cmdlet.WriteVerbose(cmdlet, "begin transaction");
using (DbTransaction dbTrans = connection.BeginTransaction()) {
cmdlet.WriteVerbose(cmdlet, "creating a data adapter");
using (DbDataAdapter adp1 = factory.CreateDataAdapter()) {
cmdlet.WriteVerbose(cmdlet, "creating a command");
using (DbCommand cmd1 = connection.CreateCommand()) {
cmdlet.WriteVerbose(cmdlet, "1");
cmd1.Transaction = dbTrans;
cmdlet.WriteVerbose(cmdlet, "2");
cmd1.CommandText = "SELECT * FROM TestSuites WHERE 1 = 2";
cmdlet.WriteVerbose(cmdlet, "3");
adp1.SelectCommand = cmd1;
cmdlet.WriteVerbose(cmdlet, "4");
using (DbCommandBuilder bld1 = factory.CreateCommandBuilder()) {
cmdlet.WriteVerbose(cmdlet, "5");
bld1.DataAdapter = adp1;
cmdlet.WriteVerbose(cmdlet, "6");
using (DataTable tbl1 = new DataTable()) {
cmdlet.WriteVerbose(cmdlet, "7");
adp1.Fill(tbl1);
//for (int n = 0; n < 10000; n++) {
cmdlet.WriteVerbose(cmdlet, "8");
for (int suiteCounter = 0; suiteCounter < TestData.TestSuites.Count; suiteCounter++) {
cmdlet.WriteVerbose(cmdlet, "9");
DataRow row1 = tbl1.NewRow();
//row[1] = n;
//(Id INTEGER PRIMARY KEY, SuiteId TEXT, SuiteName TEXT, StatusId NUMERIC, Description TEXT);");
row1["SuiteId"] = SQLiteHelper.PrepareEscapedString(TestData.TestSuites[suiteCounter].Id);
row1["SuiteName"] = SQLiteHelper.PrepareEscapedString(TestData.TestSuites[suiteCounter].Name);
row1["StatusId"] = (int)TestData.TestSuites[suiteCounter].enStatus;
row1["Description"] = SQLiteHelper.PrepareEscapedString(TestData.TestSuites[suiteCounter].Description);
tbl1.Rows.Add(row1);
}
cmdlet.WriteVerbose(cmdlet, "12");
cmdlet.WriteVerbose(cmdlet, tbl1.Rows.Count.ToString() + " rows");
adp1.Update(tbl1);
cmdlet.WriteVerbose(cmdlet, tbl1.Rows.Count.ToString() + " rows");
cmdlet.WriteVerbose(cmdlet, "14");
//dbTrans.Commit();
}
}
}
}
cmdlet.WriteVerbose(cmdlet, "15");
using (DbDataAdapter adp2 = factory.CreateDataAdapter()) {
cmdlet.WriteVerbose(cmdlet, "16");
using (DbCommand cmd2 = connection.CreateCommand()) {
cmdlet.WriteVerbose(cmdlet, "17");
cmd2.Transaction = dbTrans;
cmd2.CommandText = "SELECT * FROM TestScenarios WHERE 1 = 2";
cmdlet.WriteVerbose(cmdlet, "19");
adp2.SelectCommand = cmd2;
cmdlet.WriteVerbose(cmdlet, "20");
using (DbCommandBuilder bld2 = factory.CreateCommandBuilder()) {
cmdlet.WriteVerbose(cmdlet, "21");
bld2.DataAdapter = adp2;
cmdlet.WriteVerbose(cmdlet, "22");
using (DataTable tbl2 = new DataTable()) {
cmdlet.WriteVerbose(cmdlet, "23");
adp2.Fill(tbl2);
//for (int n = 0; n < 10000; n++) {
foreach (TestSuite testSuite in TestData.TestSuites) {
for (int scenarioCounter = 0; scenarioCounter < testSuite.TestScenarios.Count; scenarioCounter++) {
DataRow row2 = tbl2.NewRow();
//row[1] = n;
//Id INTEGER PRIMARY KEY, SuiteId TEXT, ScenarioId TEXT, ScenarioName TEXT, StatusId NUMERIC, Description TEXT);");
row2["SuiteId"] = SQLiteHelper.PrepareEscapedString(testSuite.TestScenarios[scenarioCounter].SuiteId);
row2["ScenarioId"] = SQLiteHelper.PrepareEscapedString(testSuite.TestScenarios[scenarioCounter].Id);
row2["ScenarioName"] = SQLiteHelper.PrepareEscapedString(testSuite.TestScenarios[scenarioCounter].Name);
//row["StatusId"] = (int)testSuite.TestScenarios[scenarioCounter].
row2["Description"] = SQLiteHelper.PrepareEscapedString(testSuite.TestScenarios[scenarioCounter].Description);
tbl2.Rows.Add(row2);
}
}
cmdlet.WriteVerbose(cmdlet, "27");
adp2.Update(tbl2);
cmdlet.WriteVerbose(cmdlet, "28");
//dbTrans.Commit();
}
//.........这里部分代码省略.........
示例10: CreateConstant
public static void CreateConstant(
PSCmdletBase cmdlet,
//int testBucketId,
ITestBucket bucket,
string[] constantNames,
object[] constantValues,
System.Type[] constantTypes)
{
try {
checkConnection(TestData.CurrentStructureDB.Connection);
DbProviderFactory factory = new SQLiteFactory();
cmdlet.WriteVerbose(cmdlet, "begin transaction");
using (DbTransaction dbTrans =
TestData.CurrentStructureDB.Connection.BeginTransaction()) {
cmdlet.WriteVerbose(cmdlet, "creating a data adapter");
using (DbDataAdapter adpConstant = factory.CreateDataAdapter()) {
cmdlet.WriteVerbose(cmdlet, "creating a command");
using (DbCommand cmd1 = TestData.CurrentStructureDB.Connection.CreateCommand()) {
cmd1.Transaction = dbTrans;
cmd1.CommandText = "SELECT * FROM TestConstants WHERE 1 = 2";
adpConstant.SelectCommand = cmd1;
using (DbCommandBuilder bldConstant = factory.CreateCommandBuilder()) {
bldConstant.DataAdapter = adpConstant;
using (DataTable tblConstant = new DataTable()) {
adpConstant.Fill(tblConstant);
for (int i = 0; i < constantNames.Length; i++) {
DataRow rowConstant = tblConstant.NewRow();
rowConstant["ConstantName"] = constantNames[i];
//rowConstant["ConstantTag"] = constantTags[i];
//rowConstant["Description"] = constantDescriptions[i];
rowConstant["ConstantValue"] = constantValues[i];
rowConstant["ConstantType"] = constantTypes[i];
rowConstant["BucketId"] = bucket.BucketId;
tblConstant.Rows.Add(rowConstant);
ITestConstant constant =
new TestConstant(
constantNames[i],
constantValues[i],
constantTypes[i]);
constant.BucketId = bucket.BucketId;
}
cmdlet.WriteVerbose(cmdlet, "12");
cmdlet.WriteVerbose(cmdlet, tblConstant.Rows.Count.ToString() + " rows");
adpConstant.Update(tblConstant);
cmdlet.WriteVerbose(cmdlet, tblConstant.Rows.Count.ToString() + " rows");
cmdlet.WriteVerbose(cmdlet, "14");
}
}
}
}
dbTrans.Commit();
}
}
catch (Exception eCreateConstant) {
cmdlet.WriteError(cmdlet,
"Failed to create test constant(s). " +
eCreateConstant.Message,
"CreateConstantFailed",
ErrorCategory.InvalidOperation,
true);
}
}
示例11: CloseDatabase
public static void CloseDatabase(
PSCmdletBase cmdlet,
string databaseName)
{
// check input
try {
cmdlet.WriteVerbose(cmdlet, "enumerating registered databases");
for (int i = 0; i < SQLiteData.Databases.Count; i++) {
cmdlet.WriteVerbose(cmdlet, "check the database name");
if (databaseName == SQLiteData.Databases[i].Name) {
cmdlet.WriteVerbose(cmdlet, "close the database");
try {
if (null != SQLiteData.Databases[i].Connection &&
SQLiteData.Databases[i].Connection.State == ConnectionState.Open) {
SQLiteData.Databases[i].Connection.Close();
}
}
catch {}
if (SQLiteData.Databases[i].IsResultsDB) {
TestData.CurrentResultsDB = null;
}
if (SQLiteData.Databases[i].IsRepositoryDB) {
TestData.CurrentRepositoryDB = null;
}
if (SQLiteData.Databases[i].IsStructureDB) {
TestData.CurrentStructureDB = null;
}
//SQLiteData.Databases[i].Connection.Close();
SQLiteData.Databases.RemoveAt(i);
break;
}
}
}
catch (Exception eOpenDB) {
cmdlet.WriteError(
cmdlet,
"Unable to open the database. " +
eOpenDB.Message,
"OpenDBFailed",
ErrorCategory.InvalidOperation,
true);
}
}
示例12: WriteVerbose
public void WriteVerbose(PSCmdletBase cmdlet, object obj)
{
// 20131113
if (PSCmdletBase.UnitTestMode) {
UnitTestOutput.CheckInitialized();
UnitTestOutput.StartAddingOutput();
}
string cmdletName = "? : ";
string objectString = string.Empty;
try {
objectString = obj.ToString();
}
catch {}
if (null != cmdlet) {
try {
cmdletName =
CmdletSignature(cmdlet);
cmdlet.WriteVerbose(cmdletName + objectString);
}
catch {
cmdlet.WriteVerbose(cmdletName + "failed");
}
} else {
cmdlet.WriteVerbose(cmdletName + objectString);
}
}
示例13: runTwoScriptBlockCollections
protected void runTwoScriptBlockCollections(
ScriptBlock[] scriptblocksSet1,
ScriptBlock[] scriptblocksSet2,
// 20130318
//PSCmdletBase cmdlet)
PSCmdletBase cmdlet,
object[] parameters)
{
cmdlet.WriteVerbose(cmdlet, "preparing scriptblocks");
System.Collections.Generic.List<ScriptBlock> scriptblocks =
new System.Collections.Generic.List<ScriptBlock>();
try {
if (scriptblocksSet1 != null &&
scriptblocksSet1.Length > 0) {
foreach (ScriptBlock sb in scriptblocksSet1) {
scriptblocks.Add(sb);
}
}
if (scriptblocksSet2 != null &&
scriptblocksSet2.Length > 0) {
foreach (ScriptBlock sb in scriptblocksSet2) {
scriptblocks.Add(sb);
}
}
cmdlet.WriteVerbose(cmdlet, "scriptblocks were prepared");
}
catch (Exception eScriptblocksPreparation) {
cmdlet.WriteVerbose(cmdlet, "Scriptblocks are not going to be run");
cmdlet.WriteVerbose(cmdlet, eScriptblocksPreparation.Message);
cmdlet.WriteError(
cmdlet,
eScriptblocksPreparation.Message,
"ScriptblocksNotPrepared",
ErrorCategory.InvalidOperation,
true);
}
// 20130318
//runScriptBlocks(scriptblocks, cmdlet, false);
// 20130319
try {
cmdlet.WriteVerbose(cmdlet, "running scriptblocks");
runScriptBlocks(scriptblocks, cmdlet, false, parameters);
cmdlet.WriteVerbose(cmdlet, "Scriptblocks finished successfully");
}
catch (Exception eScriptBlocks) {
cmdlet.WriteVerbose(cmdlet, "Scriptblocks failed");
cmdlet.WriteVerbose(cmdlet, eScriptBlocks.Message);
cmdlet.WriteError(
cmdlet,
eScriptBlocks.Message,
"ScriptblocksFailed",
ErrorCategory.InvalidResult,
true);
}
}
示例14: runScriptBlocks
// 20120816
public void runScriptBlocks(
System.Collections.Generic.List<ScriptBlock> scriptblocks,
PSCmdletBase cmdlet,
// 20130318
//bool eventHandlers)
bool eventHandlers,
object[] parameters)
{
try {
if (scriptblocks != null &&
scriptblocks.Count > 0) {
foreach (ScriptBlock sb in scriptblocks) {
if (sb != null) {
try {
if (eventHandlers) {
cmdlet.WriteVerbose(cmdlet, "run event handler");
runScriptBlock runner = new runScriptBlock(runSBEvent);
runner(sb, cmdlet.EventSource, cmdlet.EventArgs);
} else {
cmdlet.WriteVerbose(cmdlet, "run action with parameters");
// 20130318
//runScriptBlock runner = new runScriptBlock(runSBAction);
//runner(sb, cmdlet.EventSource, cmdlet.EventArgs);
runScriptBlockWithParameters runnerWithParams = new runScriptBlockWithParameters(runSBActionWithParams);
runnerWithParams(sb, parameters);
}
} catch (Exception eInner) {
// 20130318
// ErrorRecord err =
// new ErrorRecord(
// eInner,
// "InvokeException",
// ErrorCategory.OperationStopped,
// sb);
// err.ErrorDetails =
// new ErrorDetails("Error in " +
// sb.ToString());
// WriteError(this, err, false);
// this.WriteError(
// this,
// "Error in " +
// sb.ToString() +
// ". " +
// eInner.Message,
// "InvokeException",
// ErrorCategory.OperationStopped,
// // 20130318
// //false);
// true);
throw;
}
}
}
}
} catch (Exception eOuter) {
// 20130318
// WriteError(this,
// new ErrorRecord(eOuter, "runScriptBlocks", ErrorCategory.InvalidArgument, null),
// true);
// this.WriteError(
// this,
// eOuter.Message,
// "runScriptBlocks",
// ErrorCategory.InvalidArgument,
// true);
throw;
}
}
示例15: WriteErrorMethod045OnErrorScreenshot
protected override void WriteErrorMethod045OnErrorScreenshot(PSCmdletBase cmdlet)
{
WriteVerbose(this, "WriteErrorMethod045OnErrorScreenshot UIAutomation");
if (UIAutomation.Preferences.OnErrorScreenShot) {
//UIAHelper.GetScreenshotOfAutomationElement(
// UIAHelper.GetScreenshotOfCmdletInput(
// (cmdlet as HasControlInputCmdletBase),
// CmdletName(cmdlet), //string.Empty,
// true,
// 0,
// 0,
// 0,
// 0,
// string.Empty,
// UIAutomation.Preferences.OnErrorScreenShotFormat);
// if (Preferences.HideHighlighterOnScreenShotTaking) {
// UIAHelper.HideHighlighters();
// }
AutomationElement elementToTakeScreenShot = null;
try {
if (null != CurrentData.CurrentWindow) {
cmdlet.WriteVerbose(cmdlet, "taking screenshot of the current window");
elementToTakeScreenShot = CurrentData.CurrentWindow;
} else {
cmdlet.WriteVerbose(cmdlet, "taking screenshot of the desktop object");
elementToTakeScreenShot = AutomationElement.RootElement;
}
}
catch {
cmdlet.WriteVerbose(cmdlet, "taking screenshot of the desktop object (on fail)");
elementToTakeScreenShot = AutomationElement.RootElement;
}
cmdlet.WriteVerbose(cmdlet, "taking screenshot");
UIAHelper.GetScreenshotOfAutomationElement(
// 20130322
//(cmdlet as HasControlInputCmdletBase),
cmdlet,
elementToTakeScreenShot,
CmdletName(cmdlet),
true,
0,
0,
0,
0,
string.Empty,
UIAutomation.Preferences.OnErrorScreenShotFormat);
cmdlet.WriteVerbose(cmdlet, "done");
}
}