I tried to execute this code.. but unfortunately code not running.. its working in older versions
static async void QuartzInitializer()
{
try
{
ILog log = LogManager.GetLogger(typeof(Program));
// our properties that enable XML configuration plugin
var properties = new NameValueCollection
{
["quartz.plugin.triggHistory.type"] = "Quartz.Plugin.History.LoggingJobHistoryPlugin, Quartz.Plugins",
["quartz.plugin.jobInitializer.type"] = "Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz.Plugins",
["quartz.plugin.jobInitializer.fileNames"] = "quartz_jobs.xml",
["quartz.plugin.jobInitializer.failOnFileNotFound"] = "true",
["quartz.plugin.jobInitializer.scanInterval"] = "60",
};
ISchedulerFactory sf = new StdSchedulerFactory(properties);
IScheduler sched = await sf.GetScheduler();
await sched.Start();
await Task.Delay(TimeSpan.FromMinutes(5));
}
catch (Exception ex)
{
Main();
}
}
No Exeception is thrown. I tried using try catch also.
its exiting at await sched.Start();
Related
When I try to use puppeteersharp in AX I get a error
"Method not found: 'Void Microsoft.Extensions.Logging.LoggerExtensions.LogError(Microsoft.Extensions.Logging.ILogger, System.Exception, System.String, System.Object[])'."
I have a custom DLL added to my AX project where I create a PDF but I call this method from AX. The DLL alone is working fine since I tested it outside of my AX project yet when I call it from AX the error occours. I tried different verions but there is always a problem with Microsoft.Extensions.Logging DLL.
EDIT!
As I looked at code the method I seek is in Microsoft.Extensions.Logging.Abstractions. Since in AX i found that the DLL version is 1.1.2 and has no 4th method for LogError where you can add Exception value. Is there any safe way to update DLL in AX365 onprem?
//X++ code
class ConvertXMLtoPDF
{
public static void main(Args _args)
{
try
{
helper.PuppeteerPDF();
}
catch(Exception::CLRError)
{
System.Exception ex = CLRInterop::getLastException();
info(ex.ToString());
}
}}
C# code
using PuppeteerSharp;
using PuppeteerSharp.Media;
using Microsoft.Extensions.Logging;
public async void PuppeteerPDF()
{
string path = #"C:\Temp\test\tes2t.pdf";
string save = #"C:\Temp\test\test.html";
var options = new LaunchOptions
{
Headless = true,
ExecutablePath = "C:\\Program Files\\Google\\Chrome\\Application\\Chrome.exe"
};
try
{
using (var browser = await Puppeteer.LaunchAsync(options)) // <--- here the error occours
using (var page = await browser.NewPageAsync())
{
await page.GoToAsync(save);
var result = await page.GetContentAsync();
await page.PdfAsync(path, new PdfOptions
{
Format = PaperFormat.A4,
DisplayHeaderFooter = true,
Scale = (decimal)0.5,
PrintBackground = true,
});
await page.DisposeAsync();
await browser.DisposeAsync();
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
logger.LogError(ex, "test");
logger.LogInformation(ex, "test");
}
}
[![I am unable to pass data of collection and document from android project to PCL,the way I tried threw null reference exception please help me with that.
Thanks
Android project to get data
FirestoreDb firestore = FirestoreDb.Create("iyf-raipur");
public async Task<IEnumerable<T>> GetCouncelorsAsync()
{
Query preachers = firestore.Collection(nameof(T));
QuerySnapshot snapshots = await preachers.GetSnapshotAsync();
foreach(DocumentSnapshot documentSnapshot in snapshots.Documents)
{
T data = documentSnapshot.ConvertTo<T>();
System.Console.WriteLine();
}
return (IEnumerable<T>)preachers;
}
PCL ViewModel Code
private ObservableCollection<Preacher> preachers;
private IRepository<Preacher> _repository = DependencyService.Get<IRepository<Preacher>>();
public PreacherViewModel()
{
Preachers = new ObservableCollection<Preacher>();
PopulatePreachers();
}
async void PopulatePreachers()
{
try
{
var list = await _repository.GetPreachersAsync();
foreach (var preacher in list)
{
Preachers.Add(preacher);
name = preacher.Name;
email = preacher.Email;
}
}
catch (Exception ex)
{
await Shell.Current.DisplayAlert("ERROR", ex.Message, "ok");
}
}
I am ingesting a zip file from blob storage to ADX and set the option DeleteSourceOnSuccess = true.
The ingestion works fine but unfortunately, the source file is not deleted after the operation.
How can I debug this?
var kustoIngestionProperties = new KustoIngestionProperties(databaseName: adxDatabase, tableName: table);
kustoIngestionProperties.AdditionalProperties = new Dictionary<string, string>()
{
{"zipPattern", "stats*.txt"},
{"format", "json"},
{"ingestionMappingReference", "WiFiJsonMapping"}
};
var sourceOptions = new StorageSourceOptions() { DeleteSourceOnSuccess = true };
IRetryPolicy retryPolicy = new NoRetry();
((IKustoQueuedIngestClient)client).QueueRetryPolicy = retryPolicy;
try
{
var sourceBlobSAS = CreateBlobUriWithSas(source_blob);
await client.IngestFromStorageAsync(uri: sourceBlobSAS, ingestionProperties: kustoIngestionProperties, sourceOptions);
log.LogInformation($"File: {source_blob.Name} ingested to {tenant}_{site}_raw_logs");
}
catch (System.Exception ex)
{
log.LogError(ex.ToString());
throw;
}
finally
{
client.Dispose();
}
Using Xamarin Essentials Email class, I can open the default email application this way
public async Task SendEmail(string subject, string body, List<string> recipients)
{
try
{
var message = new EmailMessage
{
Subject = subject,
Body = body,
To = recipients,
//Cc = ccRecipients,
//Bcc = bccRecipients
};
await Email.ComposeAsync(message);
}
catch (FeatureNotSupportedException fbsEx)
{
// Email is not supported on this device
}
catch (Exception ex)
{
// Some other exception occurred
}
}
Is there any possibility to attach a file in the code? I'm not finding any option in the api.
Try this code:
var message = new EmailMessage
{
Subject = "Hello",
Body = "World",
};
var fn = "Attachment.txt";
var file = Path.Combine(FileSystem.CacheDirectory, fn);
File.WriteAllText(file, "Hello World");
message.Attachments.Add(new EmailAttachment(file));
await Email.ComposeAsync(message);
I am integrating Onedrive SDK with the UWP part of my Xamarin App. Once I press the download button I get the Onedrive signin page but it throws the above error in this line:
try
{
var appFolder = await OneDriveClient.Drive.Special.AppRoot.Request().GetAsync();
Debug.WriteLine(appFolder.Name);
}
catch (ServiceException e )
{
Debug.WriteLine(e.Message +" " + e.Error.Code);
}
here is the full relevant code:
public async Task Download(string filename)
{
//AccountSelectionLoaded();
await InitializeClient();
try
{
var appFolder = await OneDriveClient.Drive.Special.AppRoot.Request().GetAsync();
Debug.WriteLine(appFolder.Name);
}
catch (ServiceException e )
{
Debug.WriteLine(e.Message +" " + e.Error.Code);
}
var file = await OneDriveClient.Drive.Special.AppRoot.Children[filename].Content.Request().GetAsync();
//var fileStream = await fileBuilder.Content.Request().GetAsync();
IStorageFile appFile = await ApplicationData.Current.LocalFolder.CreateFileAsync("test.db3",
CreationCollisionOption.OpenIfExists);
byte[] fileBytes;
using (DataReader reader = new DataReader(file.AsInputStream()))
{
fileBytes = new byte[file.Length];
await reader.LoadAsync((uint)file.Length);
reader.ReadBytes(fileBytes);
}
Debug.WriteLine(fileBytes.Length);
Debug.WriteLine("Writing");
await FileIO.WriteBytesAsync(appFile, fileBytes);
Debug.WriteLine("End of writing");
}
private async Task InitializeClient()
{
if (OneDriveClient == null)
{
Task authTask;
var msaAuthProvider = new MsaAuthenticationProvider(oneDriveConsumerClientId,oneDriveConsumerReturnUrl,scopes);
await msaAuthProvider.AuthenticateUserAsync();
OneDriveClient = new OneDriveClient(oneDriveConsumerBaseUrl, msaAuthProvider);
AuthenticationProvider = msaAuthProvider;
}
}
Thank you for reporting this issue. Indeed, we can see a associated issue using OneDrive .NET SDK 2.0.4 in a UWP app
I will report this issue through internal way.
As a workaround, please see this blog: Windows 10 - Implementing a UWP App with the Official OneDrive SDK
Laurent Bugnion described the detailed steps(and also a demo) to enable OneDrive features in a UWP app.
private IOneDriveClient _client;
public MainPage()
{
InitializeComponent();
AuthenticateButton.Click += async (s, e) =>
{
var scopes = new[]
{
"onedrive.readwrite",
"onedrive.appfolder",
"wl.signin"
};
_client = OneDriveClientExtensions.GetClientUsingOnlineIdAuthenticator(
_scopes);
var session = await client.AuthenticateAsync();
Debug.WriteLine($"Token: {session.AccessToken}");
};
}
At that time, the project is using 1.2.0 SDK which is still working now.