diff --git a/Controllers/OrderController.cs b/Controllers/OrderController.cs index ccf840e..dbfea27 100644 --- a/Controllers/OrderController.cs +++ b/Controllers/OrderController.cs @@ -16,7 +16,7 @@ namespace rockfishCore.Controllers //### OUR ROUTE CALLED FROM ROCKFISH CLIENT #### [Produces("application/json")] [Route("api/order")] - [Authorize] + public class OrderController : Controller { private readonly rockfishContext ct; @@ -45,10 +45,16 @@ namespace rockfishCore.Controllers // Now use username and password with whatever authentication process you want if (username == "Y24PYYDQSA1L12905N5MKU" && password == "MA8GMQK2PC3FDNT1RTR68R") { - //put the notification into the db as freeform notification information + //put the jobject notification into the db as json string freeform notification information //to be processed by other code later. i.e. just capture it as is cleanly and don't bother trying to do anything fancy here this should be tight and focused and side effect free - + //save it to the database + var VendorNotification = new VendorNotification(); + VendorNotification.Vendor = "shareit"; + VendorNotification.Data = j.ToString(); + VendorNotification.Processed = false; + await ct.VendorNotification.AddAsync(VendorNotification); + await ct.SaveChangesAsync(); } @@ -59,7 +65,7 @@ namespace rockfishCore.Controllers System.Diagnostics.Debug.WriteLine($"order/shareit - Exception processing request: {ex.Message}"); } - return NoContent(); + return Ok("ok");//shareit robot looks for an OK response to know if it should resend or not https://account.mycommerce.com/home/wiki/7479805 } diff --git a/Models/VendorNotification.cs b/Models/VendorNotification.cs new file mode 100644 index 0000000..65016a7 --- /dev/null +++ b/Models/VendorNotification.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; + + +namespace rockfishCore.Models +{ + public partial class VendorNotification + { + public VendorNotification() + { + DtCreated = Util.DateUtil.NowAsEpoch(); + } + public long Id { get; set; } + public long DtCreated { get; set; } + public string Vendor { get; set; } + public string Data { get; set; } + public long? DtProcessed { get; set; } + public bool Processed { get; set; } + + } +} diff --git a/Models/rockfishContext.cs b/Models/rockfishContext.cs index 05fb365..45a83d0 100644 --- a/Models/rockfishContext.cs +++ b/Models/rockfishContext.cs @@ -9,7 +9,7 @@ namespace rockfishCore.Models public partial class rockfishContext : DbContext { - + public virtual DbSet Customer { get; set; } public virtual DbSet LicenseTemplates { get; set; } public virtual DbSet Purchase { get; set; } @@ -29,9 +29,11 @@ namespace rockfishCore.Models //schema 10 case 3233 public virtual DbSet License { get; set; } + //raven + public virtual DbSet TrialRequest { get; set; } + + public virtual DbSet VendorNotification { get; set; } -//raven - public virtual DbSet TrialRequest { get; set; } //Note: had to add this constructor to work with the code in startup.cs that gets the connection string from the appsettings.json file //and commented out the above on configuring @@ -51,7 +53,7 @@ namespace rockfishCore.Models //************************************************ protected override void OnModelCreating(ModelBuilder modelBuilder) - { + { modelBuilder.Entity(entity => { entity.ToTable("customer"); @@ -97,10 +99,10 @@ namespace rockfishCore.Models .HasColumnName("supportEmail") .HasColumnType("text"); - + }); - + modelBuilder.Entity(entity => { entity.ToTable("licenseTemplates"); @@ -142,7 +144,7 @@ namespace rockfishCore.Models }); - + modelBuilder.Entity(entity => { @@ -301,7 +303,7 @@ namespace rockfishCore.Models //.WillCascadeOnDelete(true); }); - + modelBuilder.Entity(entity => @@ -416,7 +418,7 @@ namespace rockfishCore.Models .HasColumnType("blob") .IsRequired(); - + }); @@ -519,13 +521,43 @@ namespace rockfishCore.Models .HasColumnName("key") .HasColumnType("text") .IsRequired(); - - - - }); + modelBuilder.Entity(entity => + { + entity.ToTable("vendornotification"); + + entity.Property(e => e.Id).HasColumnName("id"); + + entity.Property(e => e.DtCreated) + .HasColumnName("dtcreated") + .HasColumnType("integer") + .IsRequired(); + + entity.Property(e => e.Vendor) + .HasColumnName("vendor") + .HasColumnType("text") + .IsRequired(); + + entity.Property(e => e.Data) + .HasColumnName("data") + .HasColumnType("text") + .IsRequired(); + + entity.Property(e => e.Processed) + .HasColumnName("processed") + .HasColumnType("boolean") + .IsRequired(); + + + entity.Property(e => e.DtProcessed) + .HasColumnName("dtprocessed") + .HasColumnType("integer"); + + + }); + //----------- } diff --git a/util/RfSchema.cs b/util/RfSchema.cs index 4b0aed5..144e41d 100644 --- a/util/RfSchema.cs +++ b/util/RfSchema.cs @@ -13,7 +13,7 @@ namespace rockfishCore.Util ///////////////////////////////////////////////////////////////// /////////// CHANGE THIS ON NEW SCHEMA UPDATE //////////////////// - public const int DESIRED_SCHEMA_LEVEL = 17; + public const int DESIRED_SCHEMA_LEVEL = 18; ///////////////////////////////////////////////////////////////// @@ -404,6 +404,22 @@ namespace rockfishCore.Util currentSchema = 17; setSchemaLevel(currentSchema); } + + + ////////////////////////////////////////////////// + //schema 18 Shareit notifications + if (currentSchema < 18) + { + + exec("CREATE TABLE vendornotification (" + + "id INTEGER PRIMARY KEY, dtcreated integer not null, vendor text not null, data text not null, dtprocessed integer, processed boolean default 0 NOT NULL CHECK (processed IN (0,1))" + + ")"); + + currentSchema = 18; + setSchemaLevel(currentSchema); + } + + //************************************************************************************* diff --git a/wwwroot/js/app.api.js b/wwwroot/js/app.api.js index 498ed26..209be2d 100644 --- a/wwwroot/js/app.api.js +++ b/wwwroot/js/app.api.js @@ -415,9 +415,10 @@ app.api = (function () { $.ajax({ method: "post", dataType: "json", - url: app.shell.stateMap.apiUrl + "order/shareit", - username: 'Y24PYYDQSA1L12905N5MKU', - password: 'MA8GMQK2PC3FDNT1RTR68R', + url: app.shell.stateMap.apiUrl + "order/shareit", + headers: { + "Authorization": "Basic " + btoa('xxxxxx' + ":" + 'xxxxxx') + }, contentType: "application/json; charset=utf-8", data: JSON.stringify(objData), success: function (data) { diff --git a/wwwroot/js/app.rfsettings.js b/wwwroot/js/app.rfsettings.js index 7b5de62..02924ca 100644 --- a/wwwroot/js/app.rfsettings.js +++ b/wwwroot/js/app.rfsettings.js @@ -55,6 +55,7 @@ app.rfsettings = (function () { // onTest = function (event) { event.preventDefault(); + //debugger; var submitData = { creation_date: "2018-06-19T11:08:09.0000000Z", // <-- NEW id: 283832781, // <-- NEW @@ -93,10 +94,11 @@ app.rfsettings = (function () { }; app.api.test(submitData, function (res) { if (res.error) { + alert("ERROR"); $.gevent.publish("app-show-error", res.msg); } else { //do nothing, success! - + alert("SUCCESS!"); //$('#key').val(res); return false; } diff --git a/wwwroot/js/templates/app.rfsettings.handlebars b/wwwroot/js/templates/app.rfsettings.handlebars index 7fa640d..c5c8adf 100644 --- a/wwwroot/js/templates/app.rfsettings.handlebars +++ b/wwwroot/js/templates/app.rfsettings.handlebars @@ -1,19 +1,35 @@
-
+
- - + +
-
- -
+ +
+
+ +
\ No newline at end of file