![]() |
VOOZH | about |
dotnet add package Mechsoft.MFiles.VAF.Workers --version 3.0.2
NuGet\Install-Package Mechsoft.MFiles.VAF.Workers -Version 3.0.2
<PackageReference Include="Mechsoft.MFiles.VAF.Workers" Version="3.0.2" />
<PackageVersion Include="Mechsoft.MFiles.VAF.Workers" Version="3.0.2" />Directory.Packages.props
<PackageReference Include="Mechsoft.MFiles.VAF.Workers" />Project file
paket add Mechsoft.MFiles.VAF.Workers --version 3.0.2
#r "nuget: Mechsoft.MFiles.VAF.Workers, 3.0.2"
#:package Mechsoft.MFiles.VAF.Workers@3.0.2
#addin nuget:?package=Mechsoft.MFiles.VAF.Workers&version=3.0.2Install as a Cake Addin
#tool nuget:?package=Mechsoft.MFiles.VAF.Workers&version=3.0.2Install as a Cake Tool
Manages and simplifies M-Files background operations
Interop.MFilesAPI
MFiles.VAF.2.1.0.4
public class TCMBCurrencyRateFetcher : BackgroundWorkerOnceADayWithReturn<VaultApplication, Dictionary<string, double>>
{
public TCMBCurrencyRateFetcher() : base("TCMB daily currency rate fetcher", 16, 32, 00)
{
}
public override Dictionary<string, double> DoWork(VaultApplication application, BackgroundOperation operation)
{
var serializer = new XmlSerializer(typeof(CurrenyCollection));
using (var client = new WebClient())
{
using (var stream = client.OpenRead("http://www.tcmb.gov.tr/kurlar/today.xml"))
{
var root = (CurrenyCollection)serializer.Deserialize(stream);
return root.Currencies.ToDictionary(d => d.CurrencyCode, d => double.Parse(d.ForexBuying.Replace('.', ',')));
}
}
}
[XmlRoot(ElementName = "Currency")]
public class Currency
{
[XmlElement(ElementName = "CurrencyName")]
public string CurrencyName { get; set; }
[XmlElement(ElementName = "ForexBuying")]
public string ForexBuying { get; set; }
[XmlElement(ElementName = "ForexSelling")]
public string ForexSelling { get; set; }
[XmlElement(ElementName = "BanknoteBuying")]
public string BanknoteBuying { get; set; }
[XmlElement(ElementName = "BanknoteSelling")]
public string BanknoteSelling { get; set; }
[XmlElement(ElementName = "CrossRateUSD")]
public string CrossRateUSD { get; set; }
[XmlElement(ElementName = "CrossRateOther")]
public string CrossRateOther { get; set; }
[XmlAttribute(AttributeName = "CrossOrder")]
public string CrossOrder { get; set; }
[XmlAttribute(AttributeName = "CurrencyCode")]
public string CurrencyCode { get; set; }
}
[XmlRoot(ElementName = "Tarih_Date")]
public class CurrenyCollection
{
[XmlElement(ElementName = "Currency")]
public List<Currency> Currencies { get; set; }
}
}
Then use it in VaultApplication class
public class VaultApplication : VaultApplicationBase
{
protected override void StartApplication()
{
var currencyFetcher = new TCMBExchangeRateFetcher();
currencyFetcher.Successed += (sender, currencies) =>
{
var usd = currencies["USD"];
SysUtils.ReportInfoToEventLog($"USD: {usd}");
};
currencyFetcher.ErrorOccured += (sender, exception) =>
{
SysUtils.ReportErrorToEventLog("An error occured while fetching currencies. Worker will re-run after specified timespan offset", exception);
};
this.StartWorker(currencyFetcher);
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net45 net45 is compatible. net451 net451 was computed. net452 net452 was computed. net46 net46 was computed. net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.2 | 1,400 | 11/26/2019 |