本文整理汇总了C#中IProgress.WriteWarning方法的典型用法代码示例。如果您正苦于以下问题:C# IProgress.WriteWarning方法的具体用法?C# IProgress.WriteWarning怎么用?C# IProgress.WriteWarning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProgress
的用法示例。
在下文中一共展示了IProgress.WriteWarning方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPotentialRepoUri
/// <summary>
/// Gets what the uri of the named repository would be, on this source. I.e., gets the full path.
/// </summary>
public override string GetPotentialRepoUri(string repoIdentifier, string projectName, IProgress progress)
{
string matchName;
string warningMessage;
TryGetBestRepoMatch(repoIdentifier, projectName, out matchName, out warningMessage);
if (warningMessage != null)
{
progress.WriteWarning(warningMessage);
}
return URI.Replace(ProjectNameVariable, matchName);
}
示例2: CanConnect
public override bool CanConnect(HgRepository localRepository, string projectName, IProgress progress)
{
var path = GetPotentialRepoUri(localRepository.Identifier, projectName, progress);
if (URI.StartsWith(_networkMachineSpecifier) || URI.StartsWith(_alternativeMachineSpecifier))
{
progress.WriteStatus("Checking to see if we can connect with {0}...", path);
if (!NetworkInterface.GetIsNetworkAvailable())
{
progress.WriteWarning("This machine does not have a live network connection.");
return false;
}
}
var result = Directory.Exists(path);
if (!result)
{
progress.WriteWarning("Cannot find the specified file folder.");
}
return result;
}
示例3: CheckRepositoryBranches
/// <summary>
/// Maybe let the user know about the need to update, or that other team members are still using an older version.
/// </summary>
public void CheckRepositoryBranches(IEnumerable<Revision> branches, IProgress progress)
{
var savedSettings = Settings.Default.OtherBranchRevisions;
var conflictingUser = LiftSynchronizerAdjunct.GetRepositoryBranchCheckData(branches, BranchName, ref savedSettings);
Settings.Default.OtherBranchRevisions = savedSettings;
Settings.Default.Save();
if (!string.IsNullOrEmpty(conflictingUser))
progress.WriteWarning(string.Format(Resources.ksOtherRevisionWarning, conflictingUser));
}
示例4: CheckRepositoryBranches
/// <summary>
/// During a Send/Receive when Chorus has completed a pull and there is more than one branch on the repository
/// it will pass the revision of the head of each branch to the client.
/// The client can use this to display messages to the users when other branches are active other than their own.
/// i.e. "Someone else has a new version you should update"
/// or "Your colleague needs to update, you won't see their changes until they do."
/// Note: partly because it modifies the global Settings file, I haven't made a unit test for this method.
/// Most of the functionality is deliberately in the GetRepositoryBranchCheckData, which is tested.
/// </summary>
/// <param name="branches">A list (IEnumerable really) of all the open branches in this repo.</param>
/// <param name="progress">Where we will write a warning if changes in other branches</param>
public void CheckRepositoryBranches(IEnumerable<Revision> branches, IProgress progress)
{
string savedSettings = Properties.Settings.Default.OtherBranchRevisions;
string conflictingUser = GetRepositoryBranchCheckData(branches, BranchName, ref savedSettings);
if (!string.IsNullOrEmpty(conflictingUser))
progress.WriteWarning(string.Format("Other users of this LIFT repository (most recently {0}) are using a different version of FieldWorks or WeSay. Changes from users with more recent versions will not be merged into projects using older versions. We strongly recommend that all users upgrade to the same version as soon as possible.", conflictingUser));
Properties.Settings.Default.OtherBranchRevisions = savedSettings;
Properties.Settings.Default.Save();
}
示例5: DoNotifications
public void DoNotifications(HgRepository repository, IProgress progress)
{
if(progress.CancelRequested)
{
progress.WriteWarning("Cancelled.");
return;
}
if (InnerException != null)
{
progress.WriteVerbose("inner exception:");
progress.WriteError(Message);
}
progress.WriteError(Message);
progress.WriteVerbose(StackTrace);
if ((WhatToDo & WhatToDo.CheckAddressAndConnection) > 0)
{
//todo: seems we could do some of this ourselves, like pinging the destination
progress.WriteError("Check your network connection and server address, or try again later.");
}
if ((WhatToDo & WhatToDo.CheckSettings) > 0)
{
progress.WriteError("Check your server settings, such as project name, user name, and password.");
}
if ((WhatToDo & WhatToDo.VerifyIntegrity) > 0)
{
if (HgRepository.IntegrityResults.Bad == repository.CheckIntegrity(progress))
{
throw new ApplicationException(
"Bad news: The mecurial repository is damaged. You will need to seek expert help to resolve this problem."
);
// Removing windows forms dependency CP 2012-08
//MessageBox.Show(
// "Bad news: The mecurial repository is damaged. You will need to seek expert help to resolve this problem.", "Chorus", MessageBoxButtons.OK, MessageBoxIcon.Error);
//return;//don't suggest anything else
}
}
if ((WhatToDo & WhatToDo.SuggestRestart) > 0)
{
progress.WriteError("The problem might be helped by restarting your computer.");
}
if ((WhatToDo & WhatToDo.NeedExpertHelp) > 0)
{
progress.WriteError("You may need expert help.");
}
}
示例6: CheckBook
/// <summary>
///
/// </summary>
/// <remarks>The image-replacement feature is perhaps a one-off for a project where the an advisor replaced the folders
/// with a version that lacked most of the images (perhaps because dropbox copies small files first and didn't complete the sync)</remarks>
/// <param name="progress"></param>
/// <param name="pathToFolderOfReplacementImages">We'll find any matches in the entire folder, regardless of sub-folder name</param>
public void CheckBook(IProgress progress, string pathToFolderOfReplacementImages = null)
{
var error = GetValidateErrors();
if(!string.IsNullOrEmpty(error))
progress.WriteError(error);
//check for missing images
foreach (XmlElement imgNode in Dom.SafeSelectNodes("//img"))
{
var imageFileName = imgNode.GetAttribute("src");
if (string.IsNullOrEmpty(imageFileName))
{
var classNames=imgNode.GetAttribute("class");
if (classNames == null || !classNames.Contains("licenseImage"))//bit of hack... it's ok for licenseImages to be blank
{
progress.WriteWarning("image src is missing");
//review: this, we could fix with a new placeholder... maybe in the javascript edit stuff?
}
continue;
}
//trim off the end of "license.png?123243"
var startOfDontCacheHack = imageFileName.IndexOf('?');
if (startOfDontCacheHack > -1)
imageFileName = imageFileName.Substring(0, startOfDontCacheHack);
while (Uri.UnescapeDataString(imageFileName) != imageFileName)
imageFileName = Uri.UnescapeDataString(imageFileName);
if (!File.Exists(Path.Combine(_folderPath, imageFileName)))
{
if (!string.IsNullOrEmpty(pathToFolderOfReplacementImages))
{
if (!AttemptToReplaceMissingImage(imageFileName, pathToFolderOfReplacementImages, progress))
{
progress.WriteWarning(string.Format("Could not find replacement for image {0} in {1}", imageFileName, _folderPath));
}
}
else
{
progress.WriteWarning(string.Format("Image {0} is missing from the folder {1}", imageFileName, _folderPath));
}
}
}
}
示例7: MakeLowQualitySmallVideo
/// <summary>
/// Converts to low-quality, small video
/// </summary>
/// <param name="maxSeconds">0 if you don't want to truncate at all</param>
/// <returns>log of the run</returns>
public static ExecutionResult MakeLowQualitySmallVideo(string inputPath, string outputPath, int maxSeconds, IProgress progress)
{
if (string.IsNullOrEmpty(LocateAndRememberFFmpeg()))
{
return new ExecutionResult() { StandardError = "Could not locate FFMpeg" };
}
// isn't working: var arguments = "-i \"" + inputPath + "\" -vcodec mpeg4 -s 160x120 -b 800 -acodec libmp3lame -ar 22050 -ab 32k -ac 1 \"" + outputPath + "\"";
var arguments = "-i \"" + inputPath +
"\" -vcodec mpeg4 -s 160x120 -b 800 -acodec libmp3lame -ar 22050 -ab 32k -ac 1 ";
if (maxSeconds > 0)
arguments += " -t " + maxSeconds + " ";
arguments += "\"" + outputPath + "\"";
progress.WriteMessage("ffmpeg " + arguments);
var result = CommandLineProcessing.CommandLineRunner.Run(LocateAndRememberFFmpeg(),
arguments,
Environment.CurrentDirectory,
60 * 10, //10 minutes
progress
);
progress.WriteVerbose(result.StandardOutput);
//hide a meaningless error produced by some versions of liblame
if (result.StandardError.Contains("lame: output buffer too small")
&& File.Exists(outputPath))
{
result = new ExecutionResult
{
ExitCode = 0,
StandardOutput = result.StandardOutput,
StandardError = string.Empty
};
}
if (result.StandardError.ToLower().Contains("error") //ffmpeg always outputs config info to standarderror
|| result.StandardError.ToLower().Contains("unable to")
|| result.StandardError.ToLower().Contains("invalid")
|| result.StandardError.ToLower().Contains("could not"))
progress.WriteWarning(result.StandardError);
return result;
}
示例8: Start
/// <summary>
/// use this one if you're doing a long running task that you'll have running in a thread, so that you need a way to abort it
/// </summary>
public ExecutionResult Start(string exePath, string arguments, Encoding encoding, string fromDirectory, int secondsBeforeTimeOut, IProgress progress, Action<string> actionForReportingProgress, string standardInputPath = null)
{
progress.WriteVerbose("running '{0} {1}' from '{2}'", exePath, arguments, fromDirectory);
ExecutionResult result = new ExecutionResult();
result.Arguments = arguments;
result.ExePath = exePath;
using (_process = new Process())
{
_process.StartInfo.RedirectStandardError = true;
_process.StartInfo.RedirectStandardOutput = true;
_process.StartInfo.UseShellExecute = false;
_process.StartInfo.CreateNoWindow = true;
_process.StartInfo.WorkingDirectory = fromDirectory;
_process.StartInfo.FileName = exePath;
_process.StartInfo.Arguments = arguments;
if (encoding != null)
{
_process.StartInfo.StandardOutputEncoding = encoding;
}
if (actionForReportingProgress != null)
_processReader = new AsyncProcessOutputReader(_process, progress, actionForReportingProgress);
else
_processReader = new SynchronousProcessOutputReader(_process, progress);
if (standardInputPath != null)
_process.StartInfo.RedirectStandardInput = true;
try
{
Debug.WriteLine("CommandLineRunner Starting at " + DateTime.Now.ToString());
_process.Start();
if (standardInputPath != null)
{
var myWriter = _process.StandardInput.BaseStream;
var input = File.ReadAllBytes(standardInputPath);
myWriter.Write(input, 0, input.Length);
myWriter.Close(); // no more input
}
}
catch (Win32Exception error)
{
throw;
}
if (secondsBeforeTimeOut > TimeoutSecondsOverrideForUnitTests)
secondsBeforeTimeOut = TimeoutSecondsOverrideForUnitTests;
bool timedOut = false;
Debug.WriteLine("CommandLineRunner Reading at " + DateTime.Now.ToString("HH:mm:ss.ffff"));
if (!_processReader.Read(secondsBeforeTimeOut))
{
timedOut = !progress.CancelRequested;
try
{
if (_process.HasExited)
{
progress.WriteWarning("Process exited, cancelRequested was {0}", progress.CancelRequested);
}
else
{
if (timedOut)
progress.WriteWarning("({0}) Timed Out...", exePath);
progress.WriteWarning("Killing Process ({0})", exePath);
_process.Kill();
}
}
catch (Exception e)
{
progress.WriteWarning(
"Exception while killing process, as though the process reader failed to notice that the process was over: {0}",
e.Message);
progress.WriteWarning("Process.HasExited={0}", _process.HasExited.ToString());
}
}
result.StandardOutput = _processReader.StandardOutput;
result.StandardError = _processReader.StandardError;
if (timedOut)
{
result.StandardError += Environment.NewLine + "Timed Out after waiting " + secondsBeforeTimeOut +
" seconds.";
result.ExitCode = ExecutionResult.kTimedOut;
}
else if (progress.CancelRequested)
{
result.StandardError += Environment.NewLine + "User Cancelled.";
result.ExitCode = ExecutionResult.kCancelled;
}
else
{
result.ExitCode = _process.ExitCode;
}
}
return result;
}
示例9: ValidateFile
public string ValidateFile(string pathToFile, IProgress progress)
{
if (progress == null)
throw new ArgumentNullException("progress");
if (string.IsNullOrEmpty(pathToFile))
return "No file to work with.";
if (!File.Exists(pathToFile))
return "File does not exist.";
var extension = Path.GetExtension(pathToFile);
if (string.IsNullOrEmpty(extension))
return "File has no extension.";
if (extension[0] != '.')
return "File has no extension.";
var handler = GetHandlerfromExtension(extension.Substring(1));
var results = handler.ValidateFile(pathToFile);
if (results != null)
{
progress.WriteError("File '{0}' is not valid with message:{1}\t{2}", pathToFile, Environment.NewLine, results);
progress.WriteWarning("It may also have other problems in addition to the one that was reported.");
}
return results;
}
示例10: CheckBook
/// <summary>
///
/// </summary>
/// <remarks>The image-replacement feature is perhaps a one-off for a project where an advisor replaced the folders
/// with a version that lacked most of the images (perhaps because dropbox copies small files first and didn't complete the sync)</remarks>
/// <param name="progress"></param>
/// <param name="pathToFolderOfReplacementImages">We'll find any matches in the entire folder, regardless of sub-folder name</param>
public void CheckBook(IProgress progress, string pathToFolderOfReplacementImages = null)
{
var error = GetValidateErrors();
if(!string.IsNullOrEmpty(error))
progress.WriteError(error);
//check for missing images
foreach (XmlElement imgNode in HtmlDom.SelectChildImgAndBackgroundImageElements(Dom.Body))
{
var imageFileName = HtmlDom.GetImageElementUrl(imgNode).PathOnly.NotEncoded;
if (string.IsNullOrEmpty(imageFileName))
{
var classNames=imgNode.GetAttribute("class");
if (classNames == null || !classNames.Contains("licenseImage"))//bit of hack... it's ok for licenseImages to be blank
{
progress.WriteWarning("image src is missing");
//review: this, we could fix with a new placeholder... maybe in the javascript edit stuff?
}
continue;
}
// Certain .svg files (cogGrey.svg, FontSizeLetter.svg) aren't really part of the book and are stored elsewhere.
// Also, at present the user can't insert them into a book. Don't report them.
// TODO: if we ever allow the user to add .svg files, we'll need to change this
if (Path.HasExtension(imageFileName) && Path.GetExtension(imageFileName).ToLowerInvariant() == ".svg")
continue;
// Branding images are handled in a special way in BrandingApi.cs.
// Without this, we get "Warning: Image /bloom/api/branding/image is missing from the folder xxx" (see BL-3975)
if (imageFileName.EndsWith(BrandingApi.kBrandingImageUrlPart))
continue;
//trim off the end of "license.png?123243"
var startOfDontCacheHack = imageFileName.IndexOf('?');
if (startOfDontCacheHack > -1)
imageFileName = imageFileName.Substring(0, startOfDontCacheHack);
while (Uri.UnescapeDataString(imageFileName) != imageFileName)
imageFileName = Uri.UnescapeDataString(imageFileName);
if (!RobustFile.Exists(Path.Combine(_folderPath, imageFileName)))
{
if (!string.IsNullOrEmpty(pathToFolderOfReplacementImages))
{
if (!AttemptToReplaceMissingImage(imageFileName, pathToFolderOfReplacementImages, progress))
{
progress.WriteWarning(string.Format("Could not find replacement for image {0} in {1}", imageFileName, _folderPath));
}
}
else
{
progress.WriteWarning(string.Format("Image {0} is missing from the folder {1}", imageFileName, _folderPath));
}
}
}
}
示例11: Run
public static ExecutionResult Run(string commandLine, string fromDirectory, int secondsBeforeTimeOut, IProgress progress)
{
ExecutionResult result = new ExecutionResult();
Process process = new Process();
if (String.IsNullOrEmpty(MercurialLocation.PathToMercurialFolder))
{
throw new ApplicationException("Mercurial location has not been configured.");
}
process.StartInfo.EnvironmentVariables["PYTHONPATH"] = Path.Combine(MercurialLocation.PathToMercurialFolder, "library.zip");
process.StartInfo.EnvironmentVariables["HGENCODING"] = "UTF-8"; // See mercurial/encoding.py
process.StartInfo.EnvironmentVariables["HGENCODINGMODE"] = "strict";
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WorkingDirectory = fromDirectory;
process.StartInfo.FileName = MercurialLocation.PathToHgExecutable;
var debug = Environment.GetEnvironmentVariable(@"CHORUSDEBUGGING") == null ? String.Empty : @"--debug ";
process.StartInfo.Arguments = commandLine.Replace("hg ", debug); //we don't want the whole command line, just the args portion
//The fixutf8 extension's job is to get hg to talk in this encoding
process.StartInfo.StandardOutputEncoding = System.Text.Encoding.UTF8;
process.StartInfo.StandardErrorEncoding = System.Text.Encoding.UTF8;
if(!String.IsNullOrEmpty(debug))
{
Logger.WriteEvent("Running hg command: hg --debug {0}", commandLine);
}
try
{
process.Start();
}
catch(Win32Exception error)
{
const int ERROR_FILE_NOT_FOUND = 2;
if (error.NativeErrorCode == ERROR_FILE_NOT_FOUND &&
!commandLine.Contains("version"))//don't recurse if the readinessMessage itself is what failed
{
string msg = HgRepository.GetEnvironmentReadinessMessage("en");
if(!string.IsNullOrEmpty(msg))
throw new ApplicationException(msg);
else
{
throw error;
}
}
else
{
throw error;
}
}
var processReader = new HgProcessOutputReader(fromDirectory);
if(secondsBeforeTimeOut > TimeoutSecondsOverrideForUnitTests)
secondsBeforeTimeOut = TimeoutSecondsOverrideForUnitTests;
bool timedOut = false;
if (!processReader.Read(ref process, secondsBeforeTimeOut, progress))
{
timedOut = !progress.CancelRequested;
try
{
if (process.HasExited)
{
progress.WriteWarning("Process exited, cancelRequested was {0}", progress.CancelRequested);
}
else
{
progress.WriteWarning("Killing Hg Process...");
process.Kill();
}
}
catch(Exception e)
{
progress.WriteWarning("Exception while killing process, as though the process reader failed to notice that the process was over: {0}", e.Message);
progress.WriteWarning("Process.HasExited={0}", process.HasExited.ToString());
}
}
result.StandardOutput = processReader.StandardOutput;
result.StandardError = processReader.StandardError;
if (timedOut)
{
result.StandardError += Environment.NewLine + "Timed Out after waiting " + secondsBeforeTimeOut + " seconds.";
result.ExitCode = ProcessStream.kTimedOut;
}
else if (progress.CancelRequested)
{
result.StandardError += Environment.NewLine + "User Cancelled.";
result.ExitCode = ProcessStream.kCancelled;
}
else
{
result.ExitCode = process.ExitCode;
}
return result;
}