Compare commits
30 Commits
master
...
feature/In
Author | SHA1 | Date | |
---|---|---|---|
6e0884b935 | |||
a8a988f7cf | |||
a8dea50c2c | |||
9ecc2c1825 | |||
6180e3356a | |||
086ab86095 | |||
838d149d52 | |||
00af57fd4a | |||
9798125d18 | |||
e7999cda7d | |||
5509295fd7 | |||
b8fdcf2561 | |||
03dbd16d3e | |||
974989b60a | |||
097f0f1378 | |||
3682a17d53 | |||
7617b41df0 | |||
84cb9d4251 | |||
7e4fd047f2 | |||
91a8f80b32 | |||
724930efc9 | |||
2adb716ead | |||
c93955df68 | |||
2750b3d25e | |||
02243079b2 | |||
c38e4e6599 | |||
9938bbabc7 | |||
f822cc9fe9 | |||
6ef253f537 | |||
2de5770939 |
@ -19,6 +19,8 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FirebaseAdmin" Version="2.3.0" />
|
||||
<PackageReference Include="FireSharp" Version="2.0.4" />
|
||||
<PackageReference Include="Google.Cloud.Firestore" Version="3.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.9" />
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.9" />
|
||||
</ItemGroup>
|
||||
|
@ -36,7 +36,8 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using Newtonsoft.Json;
|
||||
using Abp.Json;
|
||||
|
||||
using System.Diagnostics;
|
||||
using static Grpc.Core.Metadata;
|
||||
|
||||
namespace BCS.BMC.CompanyMasters
|
||||
{
|
||||
@ -125,10 +126,10 @@ namespace BCS.BMC.CompanyMasters
|
||||
protected async Task<int> Create(CreateOrUpdateCompanyMasterInput input)
|
||||
{
|
||||
int companyId = 0;
|
||||
|
||||
// await GetUrlIsValid(input.Url);
|
||||
var company = from m in _companyMaster.GetAllList().Where(m => m.Url.ToLower().Trim() == input.Url.ToLower().Trim())
|
||||
|
||||
select m;
|
||||
select m;
|
||||
|
||||
var entity = input.MapTo<CompanyMaster>();
|
||||
// entity.TenantId = AbpSession.TenantId;
|
||||
@ -147,7 +148,7 @@ namespace BCS.BMC.CompanyMasters
|
||||
}
|
||||
}
|
||||
entity.DomainName = host;
|
||||
if (company == null || company.Count() == 0)
|
||||
if (company == null || company.Count() == 0)
|
||||
{
|
||||
companyId = await _companyMaster.InsertAndGetIdAsync(entity);
|
||||
}
|
||||
@ -158,6 +159,53 @@ namespace BCS.BMC.CompanyMasters
|
||||
return companyId;
|
||||
}
|
||||
|
||||
public async Task<ValidUrlResponseDto> UrlIsValid(string url)
|
||||
{
|
||||
bool istrue = false;
|
||||
var entity= new ValidUrlResponseDto();
|
||||
try
|
||||
{
|
||||
|
||||
HttpWebRequest request = HttpWebRequest.Create(url) as HttpWebRequest;
|
||||
request.Timeout = 5000; //set the timeout to 5 seconds to keep the user from waiting too long for the page to load
|
||||
request.Method = "HEAD"; //Get only the header information -- no need to download any content
|
||||
|
||||
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
|
||||
{
|
||||
int statusCode = (int)response.StatusCode;
|
||||
if (statusCode >= 100 && statusCode < 400) //Good requests
|
||||
{
|
||||
entity.IsSuccess = true;
|
||||
Uri uri = new Uri(url, UriKind.Absolute);
|
||||
var host = uri.Host;
|
||||
|
||||
if (host.Split('.').Length > 2)
|
||||
{
|
||||
int lastIndex = host.LastIndexOf(".");
|
||||
int index = host.LastIndexOf(".", lastIndex - 1);
|
||||
var subdomain = host.Substring(0, index);
|
||||
if (subdomain != "www")
|
||||
{
|
||||
entity.TenantName = subdomain;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (statusCode >= 500 && statusCode <= 510) //Server Errors
|
||||
{
|
||||
//log.Warn(String.Format("The remote server has thrown an internal error. Url is not valid: {0}", url));
|
||||
Debug.WriteLine(String.Format("The remote server has thrown an internal error. Url is not valid: {0}", url));
|
||||
istrue = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// log.Error(String.Format("Could not test url {0}.", url), ex);
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
protected async Task Update(CreateOrUpdateCompanyMasterInput input)
|
||||
{
|
||||
var entity = await _companyMaster.FirstOrDefaultAsync(x => x.Id == input.Id);
|
||||
@ -217,7 +265,7 @@ namespace BCS.BMC.CompanyMasters
|
||||
}
|
||||
|
||||
var company = await _companyMaster.FirstOrDefaultAsync(x => x.Url == input.CompanyUrl.ToString());
|
||||
if(company == null)
|
||||
if (company == null)
|
||||
{
|
||||
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BCS.BMC.CompanyMasters.Dto
|
||||
{
|
||||
public class ValidUrlResponseDto
|
||||
{
|
||||
public bool IsSuccess { get; set; }
|
||||
public string TenantName { get; set; }
|
||||
}
|
||||
}
|
@ -28,5 +28,6 @@ namespace BCS.BMC.CompanyMasters
|
||||
Task DeleteCompany(EntityDto<int> input);
|
||||
[HttpPost]
|
||||
Task<HttpStatusCodeResult> TokenByCompanyUrl(GetInputUrl input);
|
||||
Task<ValidUrlResponseDto> UrlIsValid(string url);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BCS.BMC.FirebaseCloudMessaging.Dto
|
||||
{
|
||||
public class BmcMessageStatusInput
|
||||
{
|
||||
public string UserId { get; set; }
|
||||
public long? ScheduleGenerationId { get; set; }
|
||||
public long? BmcID { get; set; }
|
||||
public string Status { get; set; }
|
||||
public string CompanyUrl { get; set; }
|
||||
public bool IsSuccess { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
using Google.Cloud.Firestore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BCS.BMC.FirebaseCloudMessaging.Dto
|
||||
{
|
||||
[FirestoreData]
|
||||
public class FireStoreNotificationModel
|
||||
{
|
||||
[FirestoreProperty]
|
||||
public string FcmToken { get; set; }
|
||||
//[FirestoreProperty]
|
||||
//public List<string> Id { get; set; }
|
||||
[FirestoreProperty]
|
||||
public string Message { get; set; }
|
||||
[FirestoreProperty]
|
||||
public DateTime? MessageSentDateTime { get; set; }
|
||||
[FirestoreProperty]
|
||||
|
||||
public string SenderImageurl { get; set; }
|
||||
[FirestoreProperty]
|
||||
public string SenderName { get; set; }
|
||||
[FirestoreProperty]
|
||||
public bool Status { get; set; }
|
||||
[FirestoreProperty]
|
||||
public List<string> UserId { get; set; }
|
||||
[FirestoreProperty]
|
||||
public int CompanyId { get; set; }
|
||||
[FirestoreProperty]
|
||||
public long? ScheduleGenerationId { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BCS.BMC.FirebaseCloudMessaging.Dto
|
||||
{
|
||||
public class FireStoreNotificationModelDto
|
||||
{
|
||||
public string FcmToken { get; set; }
|
||||
public string Message { get; set; }
|
||||
public DateTime? MessageSentDateTime { get; set; }
|
||||
|
||||
public string SenderImageurl { get; set; }
|
||||
public string SenderName { get; set; }
|
||||
public bool Status { get; set; }
|
||||
public string UserId { get; set; }
|
||||
|
||||
public int CompanyId { get; set; }
|
||||
|
||||
public long? ScheduleGenerationId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using FirebaseAdmin.Messaging;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -9,9 +10,14 @@ namespace BCS.BMC.FirebaseCloudMessaging.Dto
|
||||
{
|
||||
public class FireBaseResponseModel
|
||||
{
|
||||
[JsonProperty("isSuccess")]
|
||||
public bool IsSuccess { get; set; }
|
||||
[JsonProperty("message")]
|
||||
public string Message { get; set; }
|
||||
public Notification notification { get; set; }
|
||||
public string FcmToken { get; set; }
|
||||
|
||||
public BmcMessageStatusInput getResponseData { get; set; }
|
||||
}
|
||||
public class FireBaseResponseModelForBmc
|
||||
{
|
||||
public Notification notification { get; set; }
|
||||
public List<string> FcmToken { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,38 +1,30 @@
|
||||
using Newtonsoft.Json;
|
||||
using Abp.AutoMapper;
|
||||
using BCS.BMC.BMC.FirebaseCloudMessages;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BCS.BMC.FirebaseCloudMessaging.Dto
|
||||
{
|
||||
[AutoMapTo(typeof (FirebaseCloudMessageDetails))]
|
||||
public class NotificationModel
|
||||
{
|
||||
[JsonProperty("deviceId")]
|
||||
public string DeviceId { get; set; }
|
||||
[JsonProperty("isAndroidDevice")]
|
||||
public bool IsAndroidDevice { get; set; }
|
||||
[JsonProperty("title")]
|
||||
public string Title { get; set; }
|
||||
[JsonProperty("body")]
|
||||
public string Body { get; set; }
|
||||
}
|
||||
public string FcmToken { get; set; }
|
||||
|
||||
public class GoogleNotification
|
||||
{
|
||||
public class DataPayload
|
||||
{
|
||||
[JsonProperty("title")]
|
||||
public string Title { get; set; }
|
||||
[JsonProperty("body")]
|
||||
public string Body { get; set; }
|
||||
}
|
||||
[JsonProperty("priority")]
|
||||
public string Priority { get; set; } = "high";
|
||||
[JsonProperty("data")]
|
||||
public DataPayload Data { get; set; }
|
||||
[JsonProperty("notification")]
|
||||
public DataPayload Notification { get; set; }
|
||||
public string Message { get; set; }
|
||||
public DateTime? MessageSentDateTime { get; set; }
|
||||
|
||||
public string SenderImageurl { get; set; }
|
||||
public string SenderName { get; set; }
|
||||
|
||||
public bool Status { get; set; }
|
||||
public string UserId { get; set; }
|
||||
public long? BmcID { get; set; }
|
||||
public string CompanyUrl { get; set; }
|
||||
public long? ScheduleGenerationId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,10 @@ using System.Threading.Tasks;
|
||||
using FirebaseAdmin;
|
||||
using Google.Apis.Auth.OAuth2;
|
||||
using System;
|
||||
|
||||
using BCS.BMC.FirebaseCloudMessaging.Dto;
|
||||
using System.Collections.Generic;
|
||||
using Abp.Json;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace BCS.BMC.FirebaseCloudMessaging
|
||||
{
|
||||
@ -22,23 +25,48 @@ namespace BCS.BMC.FirebaseCloudMessaging
|
||||
}
|
||||
|
||||
|
||||
public static async Task<string> SendNotification(string fcmToken, Notification notification)
|
||||
public async Task<BatchResponse> SendNotification(FireBaseResponseModelForBmc notification)
|
||||
{
|
||||
try
|
||||
{
|
||||
var message = new Message()
|
||||
var message = new MulticastMessage()
|
||||
{
|
||||
Notification = notification,
|
||||
Token = fcmToken,
|
||||
Notification = notification.notification,
|
||||
Tokens = notification.FcmToken,
|
||||
};
|
||||
|
||||
return await FirebaseMessaging.DefaultInstance.SendAsync(message) ;
|
||||
|
||||
var response = await FirebaseMessaging.DefaultInstance.SendMulticastAsync(message);
|
||||
return response;
|
||||
}
|
||||
catch(Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<BatchResponse> SendNotificationBwac(FireBaseResponseModel notification)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<string> token = new List<string>();
|
||||
token.Add(notification.FcmToken);
|
||||
var message = new MulticastMessage()
|
||||
{
|
||||
Notification = notification.notification,
|
||||
Tokens = token,
|
||||
};
|
||||
|
||||
var response = await FirebaseMessaging.DefaultInstance.SendMulticastAsync(message);
|
||||
return response;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
public async Task GetNotification(NotificationModel notification)
|
||||
{
|
||||
var data = notification;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Abp.Application.Services;
|
||||
using BCS.BMC.FirebaseCloudMessaging.Dto;
|
||||
using FirebaseAdmin.Messaging;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -6,6 +7,8 @@ namespace BCS.BMC.FirebaseCloudMessaging
|
||||
{
|
||||
public interface IFirebaseNotificationAppService : IApplicationService
|
||||
{
|
||||
// Task<string> SendNotification(string fcmToken, Notification notification);
|
||||
Task<BatchResponse> SendNotification(FireBaseResponseModelForBmc notification);
|
||||
Task GetNotification(NotificationModel notification);
|
||||
Task<BatchResponse> SendNotificationBwac(FireBaseResponseModel notification);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
using Abp.Domain.Entities.Auditing;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BCS.BMC.BMC.FirebaseCloudMessages
|
||||
{
|
||||
[Table("FirebaseCloudMessageDetails")]
|
||||
public class FirebaseCloudMessageDetails : FullAuditedEntity
|
||||
{
|
||||
public const int SenderNameMaxLength = 32;
|
||||
public const int SenderImageurlMaxLength = 256;
|
||||
public const int FcmTokenMaxLength = 512;
|
||||
public int Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
[MaxLength(FcmTokenMaxLength)]
|
||||
public string FcmToken { get; set; }
|
||||
[MaxLength(SenderImageurlMaxLength)]
|
||||
public string SenderImageurl { get; set; }
|
||||
[MaxLength(SenderNameMaxLength)]
|
||||
public string SenderName { get; set; }
|
||||
public DateTime? MessageSentDateTime { get; set; }
|
||||
public bool Status { get; set; }
|
||||
public string Message { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using Abp.Domain.Entities.Auditing;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BCS.BMC.BMC.FirebaseCloudMessages
|
||||
{
|
||||
[Table("FirebaseToken")]
|
||||
public class FirebaseToken : FullAuditedEntity
|
||||
{
|
||||
public const int HostNameMaxLength = 512;
|
||||
public int? UserId { get; set; }
|
||||
[MaxLength(HostNameMaxLength)]
|
||||
public string HostName { get; set; }
|
||||
public string FcmToken { get; set; }
|
||||
}
|
||||
}
|
@ -126,5 +126,7 @@
|
||||
<text name="CompanyMaster">Company Master</text>
|
||||
<text name="Url">Url</text>
|
||||
<text name="Id">Id</text>
|
||||
<text name="CreateNewCompany">Create New Company</text>
|
||||
<text name="EditCompany">Edit Company</text>
|
||||
</texts>
|
||||
</localizationDictionary>
|
||||
|
@ -4,6 +4,7 @@ using BCS.BMC.Authorization.Roles;
|
||||
using BCS.BMC.Authorization.Users;
|
||||
using BCS.BMC.MultiTenancy;
|
||||
using BCS.BMC.BMC.CompanyMasters;
|
||||
using BCS.BMC.BMC.FirebaseCloudMessages;
|
||||
|
||||
namespace BCS.BMC.EntityFrameworkCore
|
||||
{
|
||||
@ -11,7 +12,8 @@ namespace BCS.BMC.EntityFrameworkCore
|
||||
{
|
||||
/* Define a DbSet for each entity of the application */
|
||||
public virtual DbSet<CompanyMaster> CompanyMasters { get; set; }
|
||||
|
||||
public virtual DbSet<FirebaseCloudMessageDetails> FirebaseCloudMessageDetail { get; set; }
|
||||
public virtual DbSet<FirebaseToken> FirebaseTokens { get; set; }
|
||||
public BMCDbContext(DbContextOptions<BMCDbContext> options)
|
||||
: base(options)
|
||||
{
|
||||
|
2058
BCS.BMC/src/BCS.BMC.EntityFrameworkCore/Migrations/20221124084114_FirebaeCloudMessageDetails.Designer.cs
generated
Normal file
2058
BCS.BMC/src/BCS.BMC.EntityFrameworkCore/Migrations/20221124084114_FirebaeCloudMessageDetails.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BCS.BMC.Migrations
|
||||
{
|
||||
public partial class FirebaeCloudMessageDetails : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "FirebaseCloudMessageDetails",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
UserId = table.Column<int>(type: "int", nullable: false),
|
||||
FcmToken = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true),
|
||||
SenderImageurl = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
||||
SenderName = table.Column<string>(type: "nvarchar(32)", maxLength: 32, nullable: true),
|
||||
MessageSentDateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
Status = table.Column<bool>(type: "bit", nullable: false),
|
||||
Message = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
CreatorUserId = table.Column<long>(type: "bigint", nullable: true),
|
||||
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
LastModifierUserId = table.Column<long>(type: "bigint", nullable: true),
|
||||
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
|
||||
DeleterUserId = table.Column<long>(type: "bigint", nullable: true),
|
||||
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_FirebaseCloudMessageDetails", x => x.Id);
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "FirebaseCloudMessageDetails");
|
||||
}
|
||||
}
|
||||
}
|
2102
BCS.BMC/src/BCS.BMC.EntityFrameworkCore/Migrations/20221124113203_FirebaseToken.Designer.cs
generated
Normal file
2102
BCS.BMC/src/BCS.BMC.EntityFrameworkCore/Migrations/20221124113203_FirebaseToken.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BCS.BMC.Migrations
|
||||
{
|
||||
public partial class FirebaseToken : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "FirebaseToken",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
UserId = table.Column<int>(type: "int", nullable: true),
|
||||
HostName = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true),
|
||||
FcmToken = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
CreatorUserId = table.Column<long>(type: "bigint", nullable: true),
|
||||
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
LastModifierUserId = table.Column<long>(type: "bigint", nullable: true),
|
||||
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
|
||||
DeleterUserId = table.Column<long>(type: "bigint", nullable: true),
|
||||
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_FirebaseToken", x => x.Id);
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "FirebaseToken");
|
||||
}
|
||||
}
|
||||
}
|
2102
BCS.BMC/src/BCS.BMC.EntityFrameworkCore/Migrations/20221124131235_RemoveIdFrom_FirebaseToken.Designer.cs
generated
Normal file
2102
BCS.BMC/src/BCS.BMC.EntityFrameworkCore/Migrations/20221124131235_RemoveIdFrom_FirebaseToken.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,19 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BCS.BMC.Migrations
|
||||
{
|
||||
public partial class RemoveIdFrom_FirebaseToken : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1613,6 +1613,108 @@ namespace BCS.BMC.Migrations
|
||||
b.ToTable("CompanyMaster");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BCS.BMC.BMC.FirebaseCloudMessages.FirebaseCloudMessageDetails", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
||||
|
||||
b.Property<DateTime>("CreationTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<long?>("CreatorUserId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long?>("DeleterUserId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<DateTime?>("DeletionTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("FcmToken")
|
||||
.HasMaxLength(512)
|
||||
.HasColumnType("nvarchar(512)");
|
||||
|
||||
b.Property<bool>("IsDeleted")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<DateTime?>("LastModificationTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<long?>("LastModifierUserId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Message")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime?>("MessageSentDateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("SenderImageurl")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("nvarchar(256)");
|
||||
|
||||
b.Property<string>("SenderName")
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("nvarchar(32)");
|
||||
|
||||
b.Property<bool>("Status")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("FirebaseCloudMessageDetails");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BCS.BMC.BMC.FirebaseCloudMessages.FirebaseToken", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
||||
|
||||
b.Property<DateTime>("CreationTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<long?>("CreatorUserId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long?>("DeleterUserId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<DateTime?>("DeletionTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("FcmToken")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("HostName")
|
||||
.HasMaxLength(512)
|
||||
.HasColumnType("nvarchar(512)");
|
||||
|
||||
b.Property<bool>("IsDeleted")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<DateTime?>("LastModificationTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<long?>("LastModifierUserId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int?>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("FirebaseToken");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BCS.BMC.MultiTenancy.Tenant", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
|
@ -29,6 +29,7 @@ using System.Text;
|
||||
using System.IO;
|
||||
using Abp.AutoMapper;
|
||||
using Abp.Domain.Entities;
|
||||
using BCS.BMC.BMC.FirebaseCloudMessages;
|
||||
|
||||
namespace BCS.BMC.Controllers
|
||||
{
|
||||
@ -43,6 +44,7 @@ namespace BCS.BMC.Controllers
|
||||
private readonly IExternalAuthManager _externalAuthManager;
|
||||
private readonly UserRegistrationManager _userRegistrationManager;
|
||||
private readonly IRepository<CompanyMaster, int> _companyMaster;
|
||||
private readonly IRepository<FirebaseToken, int> _firebaseToken;
|
||||
ResponseMessageModel responsemessage = new ResponseMessageModel();
|
||||
public TokenAuthController(
|
||||
LogInManager logInManager,
|
||||
@ -52,7 +54,8 @@ namespace BCS.BMC.Controllers
|
||||
IExternalAuthConfiguration externalAuthConfiguration,
|
||||
IExternalAuthManager externalAuthManager,
|
||||
UserRegistrationManager userRegistrationManager,
|
||||
IRepository<CompanyMaster, int> companyMaster)
|
||||
IRepository<CompanyMaster, int> companyMaster,
|
||||
IRepository<FirebaseToken, int> firebaseToken)
|
||||
{
|
||||
_logInManager = logInManager;
|
||||
_tenantCache = tenantCache;
|
||||
@ -62,6 +65,7 @@ namespace BCS.BMC.Controllers
|
||||
_externalAuthManager = externalAuthManager;
|
||||
_userRegistrationManager = userRegistrationManager;
|
||||
_companyMaster = companyMaster;
|
||||
_firebaseToken = firebaseToken;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@ -263,7 +267,12 @@ namespace BCS.BMC.Controllers
|
||||
{
|
||||
return BadRequest("Url Not Found");
|
||||
}
|
||||
return Ok("Success");
|
||||
var result = new
|
||||
{
|
||||
CompanyId = company.Id,
|
||||
|
||||
};
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@ -273,7 +282,7 @@ namespace BCS.BMC.Controllers
|
||||
var protocol = "";
|
||||
if (string.IsNullOrWhiteSpace(input.CompanyUrl))
|
||||
{
|
||||
return BadRequest("Please Enter A Valid Url");
|
||||
return BadRequest("Please enter a valid Url");
|
||||
}
|
||||
using (HttpClient client = new HttpClient())
|
||||
{
|
||||
@ -296,6 +305,11 @@ namespace BCS.BMC.Controllers
|
||||
{
|
||||
return BadRequest("Invalid Company Url");
|
||||
}
|
||||
var companyAccountId = await _companyMaster.FirstOrDefaultAsync(x => x.CompanyName == input.CompanyId);
|
||||
if (companyAccountId == null)
|
||||
{
|
||||
return BadRequest("Please enter valid Company Account ID");
|
||||
}
|
||||
|
||||
// var baseUrl = uri + "api/BmcLogin";
|
||||
var baseUrl = protocol + "://" + host + "/api/BmcLogin";
|
||||
@ -314,6 +328,23 @@ namespace BCS.BMC.Controllers
|
||||
{
|
||||
var responseStream = await response.Content.ReadAsStringAsync();
|
||||
LoginOrRegisterResponseMessageModel result = JsonConvert.DeserializeObject<LoginOrRegisterResponseMessageModel>(responseStream);
|
||||
result.result.CompanyId = company.Id;
|
||||
|
||||
var getTokenDetails = _firebaseToken.GetAllList().Where(x => x.HostName == host && x.UserId == int.Parse(result.result.userId)).FirstOrDefault();
|
||||
if (getTokenDetails is null)
|
||||
{
|
||||
FirebaseToken entity = new FirebaseToken();
|
||||
entity.UserId = int.Parse(result.result.userId);
|
||||
entity.HostName = host;
|
||||
entity.FcmToken = input.FcmToken;
|
||||
await _firebaseToken.InsertAndGetIdAsync(entity);
|
||||
}
|
||||
if (getTokenDetails != null)
|
||||
{
|
||||
getTokenDetails.FcmToken = input.FcmToken;
|
||||
|
||||
await _firebaseToken.UpdateAsync(getTokenDetails);
|
||||
}
|
||||
return Ok(result);
|
||||
}
|
||||
else if (response.StatusCode == HttpStatusCode.InternalServerError)
|
||||
@ -321,7 +352,7 @@ namespace BCS.BMC.Controllers
|
||||
var contents = await response.Content.ReadAsStringAsync();
|
||||
ResponseMessageModel result = JsonConvert.DeserializeObject<ResponseMessageModel>(contents);
|
||||
|
||||
return BadRequest(result.error.message == "Login Failed" ? "Invalid Username Or Password" : result.error.message);
|
||||
return BadRequest(result.error.message == "Login Failed" ? "Please enter valid Username or Password" : result.error.message);
|
||||
}
|
||||
return Ok();
|
||||
}
|
||||
@ -342,6 +373,11 @@ namespace BCS.BMC.Controllers
|
||||
{
|
||||
return BadRequest("Url Not Found");
|
||||
}
|
||||
var companyAccountId = await _companyMaster.FirstOrDefaultAsync(x => x.CompanyName == input.CompanyAccountId);
|
||||
if (companyAccountId == null)
|
||||
{
|
||||
return BadRequest("Please enter valid Company Account ID");
|
||||
}
|
||||
using (HttpClient client = new HttpClient())
|
||||
{
|
||||
var baseUrl = input.CompanyUrl + "/api/services/bwac/employeeRegister/RegisterEmployeeAsNewUser";
|
||||
@ -362,16 +398,37 @@ namespace BCS.BMC.Controllers
|
||||
{
|
||||
var responseStream = await response.Content.ReadAsStringAsync();
|
||||
LoginOrRegisterResponseMessageModel result = JsonConvert.DeserializeObject<LoginOrRegisterResponseMessageModel>(responseStream);
|
||||
result.result.CompanyId = company.Id;
|
||||
return Ok(result);
|
||||
}
|
||||
else if (response.StatusCode == HttpStatusCode.InternalServerError)
|
||||
{
|
||||
var contents = await response.Content.ReadAsStringAsync();
|
||||
ResponseMessageModel result = JsonConvert.DeserializeObject<ResponseMessageModel>(contents);
|
||||
return BadRequest(result);
|
||||
return BadRequest(result.error.message.ToString());
|
||||
}
|
||||
}
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> DeleteRegisteredFcmToken([FromBody] FcmTokenDeleteInput input)
|
||||
{
|
||||
Uri uri = new Uri(input.HostName);
|
||||
var host = uri.Host;
|
||||
var getTokenDetails = _firebaseToken.GetAllList().Where(x => x.HostName == host && x.UserId == input.UserId).FirstOrDefault();
|
||||
|
||||
if (getTokenDetails != null)
|
||||
{
|
||||
FirebaseToken entity = new FirebaseToken();
|
||||
getTokenDetails.FcmToken = null;
|
||||
await _firebaseToken.UpdateAsync(getTokenDetails);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest("logout failed");
|
||||
}
|
||||
return Ok("Success");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BCS.BMC.BMC.CompanyMasters;
|
||||
using Abp.AutoMapper;
|
||||
using BCS.BMC.BMC.FirebaseCloudMessages;
|
||||
|
||||
namespace BCS.BMC.Models.TokenAuth
|
||||
{
|
||||
|
||||
[AutoMap(typeof(FirebaseToken))]
|
||||
public class CreateOrUpdateFireBaseModel
|
||||
{
|
||||
public int? UserId { get; set; }
|
||||
public string HostName { get; set; }
|
||||
public string FcmToken { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BCS.BMC.Models.TokenAuth
|
||||
{
|
||||
public class FcmTokenDeleteInput
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
public string HostName { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using FirebaseAdmin.Messaging;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BCS.BMC.Models.TokenAuth
|
||||
{
|
||||
public class FcmTokenResponseModel
|
||||
{
|
||||
public result results { get; set; }
|
||||
}
|
||||
|
||||
public class results
|
||||
{
|
||||
public string message { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ namespace BCS.BMC.Models.TokenAuth
|
||||
public class LoginInputModel
|
||||
{
|
||||
public string CompanyUrl { get; set; }
|
||||
public string CompanyId { get; set; }
|
||||
public string UsernameOrEmailAddress { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string FcmToken { get; set; }
|
||||
|
@ -16,9 +16,14 @@ namespace BCS.BMC.Models.TokenAuth
|
||||
|
||||
public int statusCode { get; set; }
|
||||
public string userName { get; set; }
|
||||
public string firstName { get; set; }
|
||||
public string lastName { get; set; }
|
||||
public string emailAddress { get; set; }
|
||||
public string userId { get; set; }
|
||||
public string employeeId { get; set; }
|
||||
public string phoneNo { get; set; }
|
||||
public string profilePictureId { get; set; }
|
||||
public int? CompanyId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -8,8 +8,7 @@ namespace BCS.BMC.Models.TokenAuth
|
||||
{
|
||||
public class RegistrationInput
|
||||
{
|
||||
public string Firstname { get; set; }
|
||||
public string Lastname { get; set; }
|
||||
public string CompanyAccountId { get; set; }
|
||||
public string UserNameOrEmail { get; set; }
|
||||
public string Phoneno { get; set; }
|
||||
public string Password { get; set; }
|
||||
|
@ -14,6 +14,5 @@ namespace BCS.BMC.Models.TokenAuth
|
||||
public class Error
|
||||
{
|
||||
public string message { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,8 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BuildBundlerMinifier" Version="3.2.449" />
|
||||
<PackageReference Include="FireSharp" Version="2.0.4" />
|
||||
<PackageReference Include="Google.Cloud.Firestore" Version="3.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
@ -37,5 +37,10 @@ namespace BCS.BMC.Web.Controllers
|
||||
|
||||
return PartialView("_EditModal", output);
|
||||
}
|
||||
//public async Task<bool> GetUrlIsValid(string url)
|
||||
//{
|
||||
// bool isSuccess = await _companyasterService.GetUrlIsValid(url);
|
||||
// return isSuccess;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
@ -1,29 +0,0 @@
|
||||
using BCS.BMC.Controllers;
|
||||
using BCS.BMC.FirebaseCloudMessaging;
|
||||
using FirebaseAdmin.Messaging;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BCS.BMC.Web.Controllers
|
||||
{
|
||||
//[Route("api/notification")]
|
||||
//[ApiController]
|
||||
public class FirebaseNotificationController : BMCControllerBase
|
||||
{
|
||||
private readonly FirebaseNotificationAppService _notificationService;
|
||||
|
||||
public FirebaseNotificationController(FirebaseNotificationAppService notificationService)
|
||||
{
|
||||
_notificationService = notificationService;
|
||||
}
|
||||
|
||||
[Route("send")]
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Notification(string fcmToken, [FromBody] Notification notification)
|
||||
{
|
||||
var result = await FirebaseNotificationAppService.SendNotification(fcmToken, notification);
|
||||
return Ok(result);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,226 @@
|
||||
using Abp.AutoMapper;
|
||||
using Abp.Domain.Repositories;
|
||||
using Abp.Json;
|
||||
using BCS.BMC.BMC.CompanyMasters;
|
||||
using BCS.BMC.BMC.FirebaseCloudMessages;
|
||||
using BCS.BMC.Controllers;
|
||||
using BCS.BMC.FirebaseCloudMessaging;
|
||||
using BCS.BMC.FirebaseCloudMessaging.Dto;
|
||||
using BCS.BMC.Models.TokenAuth;
|
||||
using FirebaseAdmin.Messaging;
|
||||
using FireSharp.Config;
|
||||
using FireSharp.Interfaces;
|
||||
using FireSharp.Response;
|
||||
using Google.Cloud.Firestore;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Abp.EntityFrameworkCore.Repositories;
|
||||
using System.Security.Cryptography;
|
||||
using Abp.Domain.Uow;
|
||||
using Google.Type;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace BCS.BMC.Web.Controllers
|
||||
{
|
||||
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class NotificationController : BMCControllerBase
|
||||
{
|
||||
|
||||
private readonly IFirebaseNotificationAppService _notificationService;
|
||||
private readonly IRepository<FirebaseCloudMessageDetails> _firebaseCloudMessageDetails;
|
||||
private readonly IRepository<FirebaseToken, int> _firebaseToken;
|
||||
private readonly IRepository<CompanyMaster, int> _companyMasterService;
|
||||
private readonly IUnitOfWorkManager _unitOfWorkManager;
|
||||
//IFirebaseConfig config = new FirebaseConfig
|
||||
//{
|
||||
// AuthSecret = "n6DTPQEbpnLahrrk2EYu4bJ2Wd3jCk2N8kocazdI",
|
||||
// BasePath = "https://firechat-57601-default-rtdb.europe-west1.firebasedatabase.app/"
|
||||
//};
|
||||
//IFirebaseClient client;
|
||||
public NotificationController(IFirebaseNotificationAppService notificationService,
|
||||
IRepository<FirebaseCloudMessageDetails> firebaseCloudMessageDetails,
|
||||
IRepository<FirebaseToken, int> firebaseToken,
|
||||
IRepository<CompanyMaster, int> companyMasterService,
|
||||
IUnitOfWorkManager unitOfWorkManager)
|
||||
{
|
||||
_notificationService = notificationService;
|
||||
_firebaseCloudMessageDetails = firebaseCloudMessageDetails;
|
||||
_firebaseToken = firebaseToken;
|
||||
_companyMasterService = companyMasterService;
|
||||
_unitOfWorkManager = unitOfWorkManager;
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<SendResponse> SendNotification([FromBody] FireBaseResponseModelForBmc notification)
|
||||
{
|
||||
var result = await _notificationService.SendNotification(notification);
|
||||
return result.Responses[0];
|
||||
}
|
||||
|
||||
public async Task<IActionResult> SendNotificationForBwac([FromBody] List<FireBaseResponseModel> notifications)
|
||||
{
|
||||
List<BmcMessageStatusInput> bmcMessageStatusInputs = new List<BmcMessageStatusInput>();
|
||||
foreach (var notification in notifications)
|
||||
{
|
||||
var result = await _notificationService.SendNotificationBwac(notification);
|
||||
|
||||
if (result.SuccessCount > 0)
|
||||
{
|
||||
if (notification.getResponseData != null)
|
||||
{
|
||||
notification.getResponseData.IsSuccess = true;
|
||||
notification.getResponseData.Status = "Delivered";
|
||||
}
|
||||
}
|
||||
if (result.FailureCount > 0)
|
||||
{
|
||||
if (notification.getResponseData != null)
|
||||
{
|
||||
notification.getResponseData.IsSuccess = false;
|
||||
notification.getResponseData.Status = result.Responses[0].Exception.Message;
|
||||
}
|
||||
//await UpdateBmcMessageStatus(notification.getResponseData);
|
||||
}
|
||||
bmcMessageStatusInputs.Add(notification.getResponseData);
|
||||
}
|
||||
|
||||
await UpdateBmcMessageStatus(bmcMessageStatusInputs);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> GetNotifications([FromBody] List<NotificationModel> notifications)
|
||||
{
|
||||
string path = AppDomain.CurrentDomain.BaseDirectory + @"firechat-57601-firebase-adminsdk-anscp-e04366c4d4.json";
|
||||
Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", path);
|
||||
var companyDetails = _companyMasterService.GetAllList().Where(x => x.Url.Trim() == notifications.FirstOrDefault().CompanyUrl.Trim()).FirstOrDefault();
|
||||
var getTokenDetails = _firebaseToken.GetAllList();
|
||||
|
||||
try
|
||||
{
|
||||
List<FireStoreNotificationModelDto> notificationModelsList = new List<FireStoreNotificationModelDto>();
|
||||
FirestoreDb db = FirestoreDb.Create("firechat-57601");
|
||||
var sendNotificationInfoList = new List<FireBaseResponseModel>();
|
||||
var cloudMessageDetailsEntityList = new List<FirebaseCloudMessageDetails>();
|
||||
foreach (var notification in notifications)
|
||||
{
|
||||
FireStoreNotificationModelDto data = new FireStoreNotificationModelDto();
|
||||
var sendNotificationInfo = new FireBaseResponseModel();
|
||||
data.FcmToken = notification.FcmToken;
|
||||
// data.Id = notification.Id;
|
||||
data.Message = notification.Message;
|
||||
data.MessageSentDateTime = notification.MessageSentDateTime;
|
||||
//data.MessageSentDateTime = DateTime.UtcNow;
|
||||
data.SenderImageurl = notification.SenderImageurl;
|
||||
data.SenderName = notification.SenderName;
|
||||
data.Status = notification.Status;
|
||||
data.UserId = notification.UserId;
|
||||
data.CompanyId = companyDetails.Id;
|
||||
data.ScheduleGenerationId = Int64.Parse(notification.ScheduleGenerationId.ToString());
|
||||
//await db.Collection("BMC_Notification").Document().SetAsync(data);
|
||||
notificationModelsList.Add(data);
|
||||
|
||||
var entity = new FirebaseCloudMessageDetails();
|
||||
entity.UserId = Int32.Parse(notification.UserId);
|
||||
entity.SenderImageurl = notification.SenderImageurl;
|
||||
entity.SenderName = notification.SenderName;
|
||||
entity.MessageSentDateTime = notification.MessageSentDateTime;
|
||||
entity.Status = notification.Status;
|
||||
entity.Message = notification.Message;
|
||||
cloudMessageDetailsEntityList.Add(entity);
|
||||
|
||||
|
||||
Notification noti = new Notification
|
||||
{
|
||||
Title = notification.SenderName.ToJsonString(),
|
||||
Body = notification.Message.ToJsonString(),
|
||||
//ImageUrl = null
|
||||
};
|
||||
var responseData = new BmcMessageStatusInput();
|
||||
{
|
||||
responseData.UserId = notification.UserId;
|
||||
responseData.ScheduleGenerationId = notification.ScheduleGenerationId;
|
||||
responseData.CompanyUrl = notification.CompanyUrl;
|
||||
responseData.BmcID = notification.BmcID;
|
||||
}
|
||||
var uID = Convert.ToInt32(notification.UserId);
|
||||
var tokenDetails = getTokenDetails.FirstOrDefault(x => x.UserId == uID);
|
||||
|
||||
sendNotificationInfo.notification = noti;
|
||||
sendNotificationInfo.getResponseData = responseData;
|
||||
sendNotificationInfo.FcmToken = tokenDetails.FcmToken;
|
||||
|
||||
sendNotificationInfoList.Add(sendNotificationInfo);
|
||||
}
|
||||
var getAllFireStoreData = from table in notificationModelsList
|
||||
group table by table.Message
|
||||
into grp
|
||||
select new FireStoreNotificationModel
|
||||
{
|
||||
FcmToken = grp.FirstOrDefault().FcmToken,
|
||||
Message = grp.FirstOrDefault().Message,
|
||||
MessageSentDateTime = grp.FirstOrDefault().MessageSentDateTime,
|
||||
//data.MessageSentDateTime = DateTime.UtcNow;
|
||||
SenderImageurl = grp.FirstOrDefault().SenderImageurl,
|
||||
SenderName = grp.FirstOrDefault().SenderName,
|
||||
Status = grp.FirstOrDefault().Status,
|
||||
UserId = grp.Select(i => i.UserId).ToList(),
|
||||
CompanyId = grp.FirstOrDefault().CompanyId,
|
||||
ScheduleGenerationId = grp.FirstOrDefault().ScheduleGenerationId,
|
||||
};
|
||||
using (var uow = _unitOfWorkManager.Begin())
|
||||
{
|
||||
foreach (var fireStoreData in getAllFireStoreData)
|
||||
{
|
||||
await db.Collection("BMC_Notification").Document().SetAsync(fireStoreData);
|
||||
}
|
||||
await uow.CompleteAsync();
|
||||
}
|
||||
|
||||
using (var uow = _unitOfWorkManager.Begin())
|
||||
{
|
||||
foreach (var entity in cloudMessageDetailsEntityList)
|
||||
{
|
||||
await _firebaseCloudMessageDetails.InsertAsync(entity);
|
||||
}
|
||||
await uow.CompleteAsync();
|
||||
}
|
||||
await SendNotificationForBwac(sendNotificationInfoList);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> UpdateBmcMessageStatus([FromBody] List<BmcMessageStatusInput> bmcMessageStatusInput)
|
||||
{
|
||||
string baseUrl = "";
|
||||
foreach (var outputMessage in bmcMessageStatusInput)
|
||||
{
|
||||
var companyDetails = _companyMasterService.GetAllList().Where(x => x.Url.Trim() == outputMessage.CompanyUrl.Trim()).FirstOrDefault();
|
||||
baseUrl = companyDetails.Url + "api/services/bwac/updateBmcMessageStatus/UpdateMessageStatus";
|
||||
|
||||
}
|
||||
using (HttpClient client = new HttpClient())
|
||||
{
|
||||
var requestJson = JsonConvert.SerializeObject(bmcMessageStatusInput);
|
||||
var requestContent = new StringContent(requestJson.ToString());
|
||||
requestContent.Headers.ContentType = new MediaTypeWithQualityHeaderValue("application/json");
|
||||
HttpResponseMessage response = await client.PostAsync(baseUrl, requestContent);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@
|
||||
<div class="modal fade" id="ClientMasterCreateModal" tabindex="-1" role="dialog" aria-labelledby="UserCreateModalLabel" data-backdrop="static">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
@* @await Html.PartialAsync("~/Views/Shared/Modals/_ModalHeader.cshtml", new ModalHeaderViewModel(L("CreateNewUser")))*@
|
||||
@await Html.PartialAsync("~/Views/Shared/Modals/_ModalHeader.cshtml", new ModalHeaderViewModel(L("CreateNewCompany")))
|
||||
<form name="clientMasterCreateForm" role="form" class="form-horizontal">
|
||||
<div class="modal-body">
|
||||
@*<ul class="nav nav-tabs" role="tablist">
|
||||
@ -26,18 +26,20 @@
|
||||
<div class="tab-content mt-4">
|
||||
<div role="tabpanel" class="tab-pane container active" id="create-client-details">
|
||||
<div class="form-group row required">
|
||||
<label class="col-md-3 col-form-label">@L("Company")</label>
|
||||
<div class="col-md-9">
|
||||
<input type="text" class="form-control" name="CompanyName" required maxlength="@AbpUserBase.MaxUserNameLength" minlength="2">
|
||||
<label class="col-md-2 col-form-label">@L("Url")</label>
|
||||
<div class="col-md-8">
|
||||
<input type="text" class="form-control" id="Url" name="Url" required>
|
||||
</div>
|
||||
<input type="submit" value="Check Url" class="btn btn-secondary btn-sm download-button" name="submit">
|
||||
</div>
|
||||
|
||||
<div class="form-group row" id="div_CompanyName" style="visibility : hidden">
|
||||
<label class="col-md-2 col-form-label">@L("Company")</label>
|
||||
<div class="col-md-8">
|
||||
<input type="text" class="form-control" name="CompanyName" id="CompanyName" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row required">
|
||||
<label class="col-md-3 col-form-label">@L("Url")</label>
|
||||
<div class="col-md-9">
|
||||
<input type="text" class="form-control" name="Url" required maxlength="@AbpUserBase.MaxNameLength">
|
||||
</div>
|
||||
</div>
|
||||
@* <div class="form-group row required">
|
||||
@* <div class="form-group row required">
|
||||
<label class="col-md-3 col-form-label">@L("ClientSubDomainName")</label>
|
||||
<div class="col-md-9">
|
||||
<input type="text" class="form-control" name="ClientSubDomainName" required maxlength="@AbpUserBase.MaxSurnameLength">
|
||||
|
@ -6,7 +6,7 @@
|
||||
@{
|
||||
Layout = null;
|
||||
}
|
||||
|
||||
@await Html.PartialAsync("~/Views/Shared/Modals/_ModalHeader.cshtml", new ModalHeaderViewModel(L("EditCompany")))
|
||||
<form name="EditCompanyForm" role="form" class="form-horizontal">
|
||||
<input type="hidden" name="Id" value="@Model.Id" />
|
||||
<input type="hidden" name="DomainName" value="@Model.DomainName" />
|
||||
@ -23,18 +23,20 @@
|
||||
</ul>*@
|
||||
<div class="tab-content mt-4">
|
||||
<div role="tabpanel" class="tab-pane container active" id="edit-company-details">
|
||||
<div class="form-group row required">
|
||||
<label class="col-md-3 col-form-label">@L("Url")</label>
|
||||
<div class="col-md-9">
|
||||
<input id="url" type="text" class="form-control" name="Url" value="@Model.Url" required maxlength="@AbpUserBase.MaxUserNameLength" minlength="2">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row required">
|
||||
<label class="col-md-3 col-form-label">@L("Company")</label>
|
||||
<div class="col-md-9">
|
||||
<input id="CompanyName" type="text" class="form-control" name="CompanyName" value="@Model.CompanyName" required maxlength="@AbpUserBase.MaxUserNameLength" minlength="2">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row required">
|
||||
<label class="col-md-3 col-form-label">@L("Domain")</label>
|
||||
<div class="col-md-9">
|
||||
<input id="url" type="text" class="form-control" name="Url" value="@Model.Url" required maxlength="@AbpUserBase.MaxUserNameLength" minlength="2">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@* <div class="form-group row required">
|
||||
<label class="col-md-3 col-form-label">@L("ClientSubDomainName")</label>
|
||||
<div class="col-md-9">
|
||||
|
@ -1,9 +1,9 @@
|
||||
(function ($) {
|
||||
var _companyService = abp.services.app.companyMaster
|
||||
l = abp.localization.getSource('BMC'),
|
||||
_$modal = $('#ClientMasterCreateModal'),
|
||||
l = abp.localization.getSource('BMC'),
|
||||
_$modal = $('#ClientMasterCreateModal'),
|
||||
_$form = _$modal.find('form'),
|
||||
_$table = $('#CompanyMasterTable');
|
||||
_$table = $('#CompanyMasterTable');
|
||||
|
||||
var _$companyTable = _$table.DataTable({
|
||||
paging: true,
|
||||
@ -47,7 +47,7 @@
|
||||
targets: 3,
|
||||
data: 'url',
|
||||
sortable: false
|
||||
},{
|
||||
}, {
|
||||
targets: 4,
|
||||
data: 'domainName',
|
||||
sortable: false
|
||||
@ -56,7 +56,7 @@
|
||||
targets: 5,
|
||||
data: 'subDomainName',
|
||||
sortable: false
|
||||
},{
|
||||
}, {
|
||||
targets: 6,
|
||||
data: null,
|
||||
sortable: false,
|
||||
@ -84,6 +84,21 @@
|
||||
$('input[type="checkbox"]', rows).prop('checked', this.checked);
|
||||
});
|
||||
|
||||
_$form.find('.download-button').on('click', (e) => {
|
||||
e.preventDefault();
|
||||
var companydetails = _$form.serializeFormToObject();
|
||||
//abp.ui.setBusy();
|
||||
var companyUrl = companydetails.Url;
|
||||
|
||||
abp.notify.info(l('ValidatingUrl'));
|
||||
var data = _companyService.urlIsValid(companyUrl);
|
||||
data.done(function (result) {
|
||||
$('#div_CompanyName').attr("style", "visibility : visible");
|
||||
$('#CompanyName').val(result.tenantName);
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
_$form.find('.save-button').on('click', (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user