本文整理汇总了C#中IProgressStatus.ReportError方法的典型用法代码示例。如果您正苦于以下问题:C# IProgressStatus.ReportError方法的具体用法?C# IProgressStatus.ReportError怎么用?C# IProgressStatus.ReportError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProgressStatus
的用法示例。
在下文中一共展示了IProgressStatus.ReportError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterRepository
public AddinRepository RegisterRepository (IProgressStatus monitor, string url, bool updateNow)
{
if (!url.EndsWith (".mrep"))
url = url + "/main.mrep";
RepositoryRecord rr = FindRepositoryRecord (url);
if (rr != null)
return rr;
RegisterRepository (url, false);
try {
if (updateNow) {
UpdateRepository (monitor, url);
rr = FindRepositoryRecord (url);
Repository rep = rr.GetCachedRepository ();
rr.Name = rep.Name;
}
service.SaveConfiguration ();
return rr;
} catch (Exception ex) {
if (monitor != null)
monitor.ReportError ("The repository could not be registered", ex);
if (ContainsRepository (url))
RemoveRepository (url);
return null;
}
}
示例2: ScanAddinsFile
public void ScanAddinsFile (IProgressStatus monitor, string file, AddinScanResult scanResult)
{
XmlTextReader r = null;
StringCollection directories = new StringCollection ();
StringCollection directoriesWithSubdirs = new StringCollection ();
try {
r = new XmlTextReader (new StreamReader (file));
r.MoveToContent ();
if (r.IsEmptyElement)
return;
r.ReadStartElement ();
r.MoveToContent ();
while (r.NodeType != XmlNodeType.EndElement) {
if (r.NodeType == XmlNodeType.Element && r.LocalName == "Directory") {
string subs = r.GetAttribute ("include-subdirs");
string path = r.ReadElementString ().Trim ();
if (path.Length > 0) {
if (subs == "true")
directoriesWithSubdirs.Add (path);
else
directories.Add (path);
}
}
else
r.Skip ();
r.MoveToContent ();
}
} catch (Exception ex) {
monitor.ReportError ("Could not process addins file: " + file, ex);
return;
} finally {
if (r != null)
r.Close ();
}
foreach (string d in directories) {
string dir = d;
if (!Path.IsPathRooted (dir))
dir = Path.Combine (Path.GetDirectoryName (file), dir);
ScanFolder (monitor, dir, scanResult);
}
foreach (string d in directoriesWithSubdirs) {
string dir = d;
if (!Path.IsPathRooted (dir))
dir = Path.Combine (Path.GetDirectoryName (file), dir);
ScanFolderRec (monitor, dir, scanResult);
}
}
示例3: DatabaseInfrastructureCheck
bool DatabaseInfrastructureCheck (IProgressStatus monitor)
{
// Do some sanity check, to make sure the basic database infrastructure can be created
bool hasChanges = false;
try {
if (!Directory.Exists (AddinCachePath)) {
Directory.CreateDirectory (AddinCachePath);
hasChanges = true;
}
if (!Directory.Exists (AddinFolderCachePath)) {
Directory.CreateDirectory (AddinFolderCachePath);
hasChanges = true;
}
// Make sure we can write in those folders
Util.CheckWrittableFloder (AddinCachePath);
Util.CheckWrittableFloder (AddinFolderCachePath);
fatalDatabseError = false;
}
catch (Exception ex) {
monitor.ReportError ("Add-in cache directory could not be created", ex);
fatalDatabseError = true;
monitor.Cancel ();
}
return hasChanges;
}
示例4: ReadFolderInfo
public bool ReadFolderInfo (IProgressStatus monitor, string file, out AddinScanFolderInfo folderInfo)
{
try {
folderInfo = AddinScanFolderInfo.Read (fileDatabase, file);
return true;
}
catch (Exception ex) {
folderInfo = null;
monitor.ReportError ("Could not read folder info file", ex);
return false;
}
}
示例5: SaveFolderInfo
public bool SaveFolderInfo (IProgressStatus monitor, AddinScanFolderInfo folderInfo)
{
try {
folderInfo.Write (fileDatabase, AddinFolderCachePath);
return true;
}
catch (Exception ex) {
monitor.ReportError ("Could not write folder info file", ex);
return false;
}
}
示例6: ScanAddinsFile
public void ScanAddinsFile(IProgressStatus monitor, string file, string domain, AddinScanResult scanResult)
{
XmlTextReader r = null;
ArrayList directories = new ArrayList ();
ArrayList directoriesWithSubdirs = new ArrayList ();
string basePath = Path.GetDirectoryName (file);
try {
r = new XmlTextReader (fs.OpenTextFile (file));
r.MoveToContent ();
if (r.IsEmptyElement)
return;
r.ReadStartElement ();
r.MoveToContent ();
while (r.NodeType != XmlNodeType.EndElement) {
if (r.NodeType == XmlNodeType.Element && r.LocalName == "Directory") {
string subs = r.GetAttribute ("include-subdirs");
string sdom;
string share = r.GetAttribute ("shared");
if (share == "true")
sdom = AddinDatabase.GlobalDomain;
else if (share == "false")
sdom = null;
else
sdom = domain; // Inherit the domain
string path = r.ReadElementString ().Trim ();
if (path.Length > 0) {
path = Util.NormalizePath (path);
if (subs == "true")
directoriesWithSubdirs.Add (new string[] {path, sdom});
else
directories.Add (new string[] {path, sdom});
}
}
else if (r.NodeType == XmlNodeType.Element && r.LocalName == "GacAssembly") {
string aname = r.ReadElementString ().Trim ();
if (aname.Length > 0) {
aname = Util.NormalizePath (aname);
aname = Util.GetGacPath (aname);
if (aname != null) {
// Gac assemblies always use the global domain
directories.Add (new string[] {aname, AddinDatabase.GlobalDomain});
}
}
}
else if (r.NodeType == XmlNodeType.Element && r.LocalName == "Exclude") {
string path = r.ReadElementString ().Trim ();
if (path.Length > 0) {
path = Util.NormalizePath (path);
if (!Path.IsPathRooted (path))
path = Path.Combine (basePath, path);
scanResult.AddPathToIgnore (Path.GetFullPath (path));
}
}
else
r.Skip ();
r.MoveToContent ();
}
} catch (Exception ex) {
monitor.ReportError ("Could not process addins file: " + file, ex);
return;
} finally {
if (r != null)
r.Close ();
}
foreach (string[] d in directories) {
string dir = d[0];
if (!Path.IsPathRooted (dir))
dir = Path.Combine (basePath, dir);
ScanFolder (monitor, dir, d[1], scanResult);
}
foreach (string[] d in directoriesWithSubdirs) {
string dir = d[0];
if (!Path.IsPathRooted (dir))
dir = Path.Combine (basePath, dir);
ScanFolderRec (monitor, dir, d[1], scanResult);
}
}
示例7: ReadAddinDescription
public bool ReadAddinDescription (IProgressStatus monitor, string file, out AddinDescription description)
{
try {
description = AddinDescription.ReadBinary (fileDatabase, file);
if (description != null)
description.OwnerDatabase = this;
return true;
}
catch (Exception ex) {
if (monitor == null)
throw;
description = null;
monitor.ReportError ("Could not read folder info file", ex);
return false;
}
}
示例8: BuildPackage
/// <summary>
/// Packages an add-in
/// </summary>
/// <param name="statusMonitor">
/// Progress monitor where to show progress status
/// </param>
/// <param name="targetDirectory">
/// Directory where to generate the package
/// </param>
/// <param name="filePaths">
/// Paths to the add-ins to be packaged. Paths can be either the main assembly of an add-in, or an add-in
/// manifest (.addin or .addin.xml).
/// </param>
/// <remarks>
/// This method can be used to create a package for an add-in, which can then be pushed to an on-line
/// repository. The package will include the main assembly or manifest of the add-in and any external
/// file declared in the add-in metadata.
/// </remarks>
public void BuildPackage(IProgressStatus monitor, string outFilePath, string filePath)
{
AddinDescription conf = registry.GetAddinDescription (monitor, filePath);
if (conf == null) {
monitor.ReportError ("Could not read add-in file: " + filePath, null);
return;
}
var basePath = Path.GetDirectoryName(outFilePath);
ZipOutputStream s = new ZipOutputStream(File.Create(outFilePath));
s.SetLevel(5);
// Generate a stripped down description of the add-in in a file, since the complete
// description may be declared as assembly attributes
XmlDocument doc = new XmlDocument ();
doc.PreserveWhitespace = false;
doc.LoadXml (conf.SaveToXml ().OuterXml);
CleanDescription (doc.DocumentElement);
MemoryStream ms = new MemoryStream ();
XmlTextWriter tw = new XmlTextWriter (ms, System.Text.Encoding.UTF8);
tw.Formatting = Formatting.Indented;
doc.WriteTo (tw);
tw.Flush ();
byte[] data = ms.ToArray ();
ZipEntry infoEntry = new ZipEntry ("addin.info");
s.PutNextEntry (infoEntry);
s.Write (data, 0, data.Length);
// Now add the add-in files
ArrayList list = new ArrayList ();
if (!conf.AllFiles.Contains (Path.GetFileName (filePath)))
list.Add (Path.GetFileName (filePath));
foreach (string f in conf.AllFiles) {
list.Add (f);
}
foreach (var prop in conf.Properties) {
try {
if (File.Exists (Path.Combine (basePath, prop.Value)))
list.Add (prop.Value);
} catch {
// Ignore errors
}
}
monitor.Log ("Creating package " + Path.GetFileName (outFilePath));
foreach (string file in list) {
string fp = Path.Combine (basePath, file);
using (FileStream fs = File.OpenRead (fp)) {
byte[] buffer = new byte [fs.Length];
fs.Read (buffer, 0, buffer.Length);
ZipEntry entry = new ZipEntry (file);
s.PutNextEntry (entry);
s.Write (buffer, 0, buffer.Length);
}
}
s.Finish();
s.Close();
}
示例9: BuildPackageFilename
public string BuildPackageFilename(IProgressStatus monitor,string targetDirectory, string filePath)
{
var conf = registry.GetAddinDescription(monitor, filePath);
if (conf == null)
{
monitor.ReportError("Could not read add-in file: " + filePath, null);
return null;
}
if (targetDirectory == null)
targetDirectory = Path.GetDirectoryName (filePath);
// Generate the file name
string name;
if (conf.LocalId.Length == 0)
name = Path.GetFileNameWithoutExtension(filePath);
else
name = conf.LocalId;
name = Addin.GetFullId(conf.Namespace, name, conf.Version);
name = name.Replace(',', '_').Replace(".__", ".");
return Path.Combine(targetDirectory, name) + ".mpack";
}
示例10: LoadAddin
internal bool LoadAddin(IProgressStatus statusMonitor, string id, bool throwExceptions)
{
try {
if (IsAddinLoaded (id))
return true;
if (!Registry.IsAddinEnabled (id)) {
string msg = GettextCatalog.GetString ("Disabled add-ins can't be loaded.");
ReportError (msg, id, null, false);
if (throwExceptions)
throw new InvalidOperationException (msg);
return false;
}
ArrayList addins = new ArrayList ();
Stack depCheck = new Stack ();
ResolveLoadDependencies (addins, depCheck, id, false);
addins.Reverse ();
if (statusMonitor != null)
statusMonitor.SetMessage ("Loading Addins");
for (int n=0; n<addins.Count; n++) {
if (statusMonitor != null)
statusMonitor.SetProgress ((double) n / (double)addins.Count);
Addin iad = (Addin) addins [n];
if (IsAddinLoaded (iad.Id))
continue;
if (statusMonitor != null)
statusMonitor.SetMessage (string.Format(GettextCatalog.GetString("Loading {0} add-in"), iad.Id));
if (!InsertAddin (statusMonitor, iad))
return false;
}
return true;
}
catch (Exception ex) {
ReportError ("Add-in could not be loaded: " + ex.Message, id, ex, false);
if (statusMonitor != null)
statusMonitor.ReportError ("Add-in '" + id + "' could not be loaded.", ex);
if (throwExceptions)
throw;
return false;
}
}
示例11: InsertAddin
bool InsertAddin(IProgressStatus statusMonitor, Addin iad)
{
try {
RuntimeAddin p = new RuntimeAddin (this);
// Read the config file and load the add-in assemblies
AddinDescription description = p.Load (iad);
// Register the add-in
loadedAddins [Addin.GetIdName (p.Id)] = p;
if (!AddinDatabase.RunningSetupProcess) {
// Load the extension points and other addin data
foreach (ExtensionNodeSet rel in description.ExtensionNodeSets) {
RegisterNodeSet (rel);
}
foreach (ConditionTypeDescription cond in description.ConditionTypes) {
Type ctype = p.GetType (cond.TypeName, true);
RegisterCondition (cond.Id, ctype);
}
}
foreach (ExtensionPoint ep in description.ExtensionPoints)
InsertExtensionPoint (p, ep);
// Fire loaded event
NotifyAddinLoaded (p);
ReportAddinLoad (p.Id);
return true;
}
catch (Exception ex) {
ReportError ("Add-in could not be loaded", iad.Id, ex, false);
if (statusMonitor != null)
statusMonitor.ReportError ("Add-in '" + iad.Id + "' could not be loaded.", ex);
return false;
}
}
示例12: RegisterRepository
/// <summary>
/// Subscribes to an on-line repository
/// </summary>
/// <param name="monitor">
/// Progress monitor where to show progress status and log
/// </param>
/// <param name="url">
/// URL of the repository
/// </param>
/// <param name="updateNow">
/// When set to True, the repository index will be downloaded.
/// </param>
/// <returns>
/// A repository reference
/// </returns>
public AddinRepository RegisterRepository (IProgressStatus monitor, string url, bool updateNow)
{
if (string.IsNullOrEmpty (url))
throw new ArgumentException ("Emtpy url");
if (!url.EndsWith (".mrep")) {
if (url [url.Length - 1] != '/')
url += "/";
url = url + "main.mrep";
}
RepositoryRecord rr = FindRepositoryRecord (url);
if (rr != null)
return rr;
rr = RegisterRepository (url, false);
try {
if (updateNow) {
UpdateRepository (monitor, url);
rr = FindRepositoryRecord (url);
Repository rep = rr.GetCachedRepository ();
if (rep != null)
rr.Name = rep.Name;
}
service.SaveConfiguration ();
return rr;
} catch (Exception ex) {
if (monitor != null)
monitor.ReportError ("The repository could not be registered", ex);
if (ContainsRepository (url))
RemoveRepository (url);
return null;
}
}
示例13: MonitorProcessStatus
public static void MonitorProcessStatus (IProgressStatus monitor, TextReader reader, StringCollection progessLog)
{
string line;
string exceptionText = null;
while ((line = reader.ReadLine ()) != null) {
int i = line.IndexOf (':');
if (i != -1) {
string tag = line.Substring (0, i);
string txt = line.Substring (i+1);
bool wasTag = true;
switch (tag) {
case "process-ps-msg":
monitor.SetMessage (Decode (txt));
break;
case "process-ps-progress":
monitor.SetProgress (double.Parse (txt));
break;
case "process-ps-log":
monitor.Log (Decode (txt));
break;
case "process-ps-warning":
monitor.ReportWarning (Decode (txt));
break;
case "process-ps-exception":
exceptionText = Decode (txt);
if (exceptionText == string.Empty)
exceptionText = null;
break;
case "process-ps-error":
string err = Decode (txt);
if (err == string.Empty) err = null;
monitor.ReportError (err, exceptionText != null ? new Exception (exceptionText) : null);
break;
case "process-ps-cancel":
monitor.Cancel ();
break;
case "process-ps-plog":
progessLog.Add (Decode (txt));
break;
default:
wasTag = false;
break;
}
if (wasTag)
continue;
}
Console.WriteLine (line);
}
}
示例14: ScanAssembly
bool ScanAssembly (IProgressStatus monitor, string filePath, AddinScanResult scanResult, out AddinDescription config)
{
config = null;
try {
Assembly asm = Util.LoadAssemblyForReflection (filePath);
// Get the config file from the resources, if there is one
string configFile = null;
foreach (string res in asm.GetManifestResourceNames ()) {
if (res.EndsWith (".addin") || res.EndsWith (".addin.xml")) {
configFile = res;
break;
}
}
if (configFile != null) {
using (Stream s = asm.GetManifestResourceStream (configFile)) {
string asmFile = new Uri (asm.CodeBase).LocalPath;
config = AddinDescription.Read (s, Path.GetDirectoryName (asmFile));
}
}
else {
// On this case, only scan the assembly if it has the Addin attribute.
AddinAttribute att = (AddinAttribute) Attribute.GetCustomAttribute (asm, typeof(AddinAttribute), false);
if (att == null) {
config = null;
return true;
}
config = new AddinDescription ();
}
config.BasePath = Path.GetDirectoryName (filePath);
config.AddinFile = filePath;
string rasmFile = Path.GetFileName (filePath);
if (!config.MainModule.Assemblies.Contains (rasmFile))
config.MainModule.Assemblies.Add (rasmFile);
return ScanDescription (monitor, config, asm, scanResult);
}
catch (Exception ex) {
// Something went wrong while scanning the assembly. We'll ignore it for now.
monitor.ReportError ("There was an error while scanning assembly: " + filePath, ex);
return false;
}
}
示例15: ScanSingleFile
public AddinDescription ScanSingleFile(IProgressStatus monitor, string file, AddinScanResult scanResult)
{
AddinDescription config = null;
if (monitor.LogLevel > 1)
monitor.Log ("Scanning file: " + file);
monitor.Log ("plog:scan:" + file);
try {
string ext = Path.GetExtension (file).ToLower ();
bool scanSuccessful;
if (ext == ".dll" || ext == ".exe")
scanSuccessful = ScanAssembly (monitor, file, scanResult, out config);
else
scanSuccessful = ScanConfigAssemblies (monitor, file, scanResult, out config);
if (scanSuccessful && config != null) {
config.Domain = "global";
if (config.Version.Length == 0)
config.Version = "0.0.0.0";
if (config.LocalId.Length == 0) {
// Generate an internal id for this add-in
config.LocalId = database.GetUniqueAddinId (file, "", config.Namespace, config.Version);
}
}
}
catch (Exception ex) {
monitor.ReportError ("Unexpected error while scanning file: " + file, ex);
} finally {
monitor.Log ("plog:endscan");
}
return config;
}