This commit is contained in:
@@ -106,6 +106,8 @@ namespace rockfishCore
|
||||
//Check schema
|
||||
RfSchema.CheckAndUpdate(dbContext);
|
||||
|
||||
bool bMM=RfMail.MailIsMirroringProperly();
|
||||
|
||||
}//eof
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,83 +32,5 @@ Mailkit (supposedly system.net.mail will be ported in v2.0 of .net core but for
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
**************************
|
||||
//command to scaffold the sqlite db:
|
||||
dotnet ef dbcontext scaffold "Datasource=/home/john/Documents/rockfishCore/db/rockfish.sqlite" Microsoft.EntityFrameworkCore.Sqlite -o Models -f
|
||||
|
||||
//scaffold all controllers with these commands:
|
||||
dotnet aspnet-codegenerator controller -api -m rockfishCore.Models.Contact -dc rockfishCore.Models.rockfishContext -name ContactController -outDir ./Controllers
|
||||
dotnet aspnet-codegenerator controller -api -m rockfishCore.Models.Customer -dc rockfishCore.Models.rockfishContext -name CustomerController -outDir ./Controllers
|
||||
dotnet aspnet-codegenerator controller -api -m rockfishCore.Models.Incident -dc rockfishCore.Models.rockfishContext -name IncidentController -outDir ./Controllers
|
||||
dotnet aspnet-codegenerator controller -api -m rockfishCore.Models.LicenseTemplates -dc rockfishCore.Models.rockfishContext -name LicenseTemplatesController -outDir ./Controllers
|
||||
dotnet aspnet-codegenerator controller -api -m rockfishCore.Models.Notification -dc rockfishCore.Models.rockfishContext -name NotificationController -outDir ./Controllers
|
||||
dotnet aspnet-codegenerator controller -api -m rockfishCore.Models.Purchase -dc rockfishCore.Models.rockfishContext -name PurchaseController -outDir ./Controllers
|
||||
dotnet aspnet-codegenerator controller -api -m rockfishCore.Models.Site -dc rockfishCore.Models.rockfishContext -name SiteController -outDir ./Controllers
|
||||
dotnet aspnet-codegenerator controller -api -m rockfishCore.Models.Trial -dc rockfishCore.Models.rockfishContext -name TrialController -outDir ./Controllers
|
||||
dotnet aspnet-codegenerator controller -api -m rockfishCore.Models.User -dc rockfishCore.Models.rockfishContext -name UserController -outDir ./Controllers
|
||||
|
||||
|
||||
Here is the help command for this:
|
||||
dotnet aspnet-codegenerator controller --help
|
||||
|
||||
|
||||
|
||||
***********************************
|
||||
EF CORE STUFF NOTES
|
||||
|
||||
To INCLUDE relatives use like this:
|
||||
|
||||
var site = await _context.Site
|
||||
.Include(m=>m.TrialNavigation)
|
||||
.Include(m=>m.Purchase)
|
||||
.Include(m=>m.Incident)
|
||||
.SingleOrDefaultAsync(m => m.Id == id);
|
||||
|
||||
|
||||
|
||||
=-=-=-=-
|
||||
EF Core include queries
|
||||
|
||||
|
||||
//ad-hoc:
|
||||
// var res = from c in _context.Customer.OrderBy(c => c.Name)
|
||||
// join site in _context.Site.DefaultIfEmpty() on c.Id equals site.CustomerId
|
||||
// join purchase in _context.Purchase.DefaultIfEmpty() on site.Id equals purchase.SiteId
|
||||
// where (purchase.CancelDate == null)
|
||||
// select new infoListCustomer
|
||||
// {
|
||||
// active = c.Active,
|
||||
// id = c.Id,
|
||||
// name = c.Name,
|
||||
// siteId = site.Id,
|
||||
// siteName = site.Name,
|
||||
// purchaseId = purchase.Id,
|
||||
// purchaseName = purchase.Name
|
||||
// };
|
||||
|
||||
|
||||
//Using ef relationships:
|
||||
|
||||
// using (var context = new BloggingContext())
|
||||
// {
|
||||
// var blogs = context.Blogs
|
||||
// .Include(blog => blog.Posts)
|
||||
// .ThenInclude(post => post.Author)
|
||||
// .ThenInclude(author => author.Photo)
|
||||
// .Include(blog => blog.Owner)
|
||||
// .ThenInclude(owner => owner.Photo)
|
||||
// .ToList();
|
||||
// }
|
||||
|
||||
var res = _context.Customer
|
||||
.Include(customer => customer.Site)
|
||||
.ThenInclude(site => site.Purchase)//or...:
|
||||
//.Include(customer => customer.Purchase)//this also due to reference in EF
|
||||
.OrderBy(customer => customer.Name);
|
||||
//.ToList();
|
||||
|
||||
|
||||
var xtest=res.ToList();
|
||||
var xcount=xtest.Count();
|
||||
uidnext {61644} {685} {61644} {685}
|
||||
uidvalidity 1276936849 1532556097 1276936849 1532556097
|
||||
@@ -17,6 +17,9 @@ namespace rockfishCore.Util
|
||||
public static class RfMail
|
||||
{
|
||||
|
||||
public const string MAIL_MIRROR_SMPT_ADDRESS = "mail2.ayanova.com";
|
||||
public const string MAIL_MIRROR_IMAP_ADDRESS = "mail2.ayanova.com";
|
||||
|
||||
public const string MAIL_SMPT_ADDRESS = "mail.ayanova.com";
|
||||
public const int MAIL_SMPT_PORT = 465;
|
||||
public const string MAIL_IMAP_ADDRESS = "mail.ayanova.com";
|
||||
@@ -109,7 +112,7 @@ namespace rockfishCore.Util
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void SendMessage(string MessageFrom, string MessageTo, string MessageSubject, string MessageBody,
|
||||
bool trackDeliveryStatus = false, string CustomHeader = "", string CustomHeaderValue = "")
|
||||
@@ -183,12 +186,13 @@ namespace rockfishCore.Util
|
||||
}
|
||||
|
||||
var spamFolder = client.GetFolder("Spam");
|
||||
|
||||
if (spamFolder != null){
|
||||
client.Inbox.Open(FolderAccess.ReadWrite);
|
||||
client.Inbox.MoveTo(new UniqueId(spamMessageId), spamFolder);
|
||||
|
||||
if (spamFolder != null)
|
||||
{
|
||||
client.Inbox.Open(FolderAccess.ReadWrite);
|
||||
client.Inbox.MoveTo(new UniqueId(spamMessageId), spamFolder);
|
||||
}
|
||||
|
||||
|
||||
|
||||
client.Disconnect(true);
|
||||
}
|
||||
@@ -618,6 +622,75 @@ namespace rockfishCore.Util
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="mailAccount"></param>
|
||||
/// <param name="mailFolder"></param>
|
||||
/// <param name="mirrorServer"></param>
|
||||
/// <returns></returns>
|
||||
public static IMessageSummary GetMostRecentMessageSummary(string mailAccount, string mailFolder, bool mirrorServer)
|
||||
{
|
||||
|
||||
using (var client = new ImapClient())
|
||||
{
|
||||
// Accept all SSL certificates
|
||||
client.ServerCertificateValidationCallback = (s, c, h, e) => true;
|
||||
//client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT, true);
|
||||
if (mirrorServer)
|
||||
client.Connect(MAIL_MIRROR_IMAP_ADDRESS, MAIL_IMAP_PORT);
|
||||
else
|
||||
client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT);
|
||||
// Note: since we don't have an OAuth2 token, disable
|
||||
// the XOAUTH2 authentication mechanism.
|
||||
client.AuthenticationMechanisms.Remove("XOAUTH2");
|
||||
|
||||
if (mailAccount == "support@ayanova.com")
|
||||
{
|
||||
client.Authenticate(MAIL_ACCOUNT_SUPPORT, MAIL_ACCOUNT_PASSWORD_SUPPORT);
|
||||
}
|
||||
if (mailAccount == "sales@ayanova.com")
|
||||
{
|
||||
client.Authenticate(MAIL_ACCOUNT_SALES, MAIL_ACCOUNT_PASSWORD_SALES);
|
||||
}
|
||||
|
||||
var fldr = client.GetFolder(mailFolder);
|
||||
fldr.Open(FolderAccess.ReadOnly);
|
||||
//---------------
|
||||
int Count = fldr.Count;
|
||||
var messages = fldr.Fetch(Count - 1, Count, MessageSummaryItems.Envelope).ToList();
|
||||
|
||||
//--------------
|
||||
client.Disconnect(true);
|
||||
if (messages.Count > 0)
|
||||
return messages[0];
|
||||
else
|
||||
return null;
|
||||
|
||||
}
|
||||
}//get message
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//Validate mirroring is working
|
||||
//
|
||||
//
|
||||
public static bool MailIsMirroringProperly()
|
||||
{
|
||||
//check that the mirror and master contain the same most recent message in
|
||||
//Sent
|
||||
//AyaNovaReceivedSubscribed
|
||||
//
|
||||
|
||||
var SentMasterSummary = GetMostRecentMessageSummary("support@ayanova.com", "Sent", false);
|
||||
var AyaNovaReceivedSubscribedSummary = GetMostRecentMessageSummary("support@ayanova.com", "AyaNovaReceivedSubscribed", false);
|
||||
var SentMirrorSummary = GetMostRecentMessageSummary("support@ayanova.com", "Sent", true);
|
||||
var AyaNovaReceivedSubscribedMirrorSummary = GetMostRecentMessageSummary("support@ayanova.com", "AyaNovaReceivedSubscribed", true);
|
||||
|
||||
return SentMasterSummary.UniqueId.Id == SentMirrorSummary.UniqueId.Id && AyaNovaReceivedSubscribedSummary.UniqueId.Id == AyaNovaReceivedSubscribedMirrorSummary.UniqueId.Id;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//----------------
|
||||
|
||||
Reference in New Issue
Block a user