BMC: Validate Ulr From CompanyMaster
This commit is contained in:
parent
097f0f1378
commit
974989b60a
@ -37,6 +37,7 @@ using System.Net.Http.Headers;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Abp.Json;
|
using Abp.Json;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using static Grpc.Core.Metadata;
|
||||||
|
|
||||||
namespace BCS.BMC.CompanyMasters
|
namespace BCS.BMC.CompanyMasters
|
||||||
{
|
{
|
||||||
@ -158,10 +159,13 @@ namespace BCS.BMC.CompanyMasters
|
|||||||
return companyId;
|
return companyId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> GetUrlIsValid(string url)
|
public async Task<ValidUrlResponseDto> UrlIsValid(string url)
|
||||||
{
|
{
|
||||||
|
bool istrue = false;
|
||||||
|
var entity= new ValidUrlResponseDto();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
HttpWebRequest request = HttpWebRequest.Create(url) as HttpWebRequest;
|
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.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
|
request.Method = "HEAD"; //Get only the header information -- no need to download any content
|
||||||
@ -171,32 +175,36 @@ namespace BCS.BMC.CompanyMasters
|
|||||||
int statusCode = (int)response.StatusCode;
|
int statusCode = (int)response.StatusCode;
|
||||||
if (statusCode >= 100 && statusCode < 400) //Good requests
|
if (statusCode >= 100 && statusCode < 400) //Good requests
|
||||||
{
|
{
|
||||||
return true;
|
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
|
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));
|
//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));
|
Debug.WriteLine(String.Format("The remote server has thrown an internal error. Url is not valid: {0}", url));
|
||||||
return false;
|
istrue = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (WebException ex)
|
|
||||||
{
|
|
||||||
if (ex.Status == WebExceptionStatus.ProtocolError) //400 errors
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// log.Warn(String.Format("Unhandled status [{0}] returned for url: {1}", ex.Status, url), ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
// log.Error(String.Format("Could not test url {0}.", url), ex);
|
// log.Error(String.Format("Could not test url {0}.", url), ex);
|
||||||
}
|
}
|
||||||
return false;
|
return entity;
|
||||||
}
|
}
|
||||||
protected async Task Update(CreateOrUpdateCompanyMasterInput input)
|
protected async Task Update(CreateOrUpdateCompanyMasterInput input)
|
||||||
{
|
{
|
||||||
|
@ -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,6 +28,6 @@ namespace BCS.BMC.CompanyMasters
|
|||||||
Task DeleteCompany(EntityDto<int> input);
|
Task DeleteCompany(EntityDto<int> input);
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
Task<HttpStatusCodeResult> TokenByCompanyUrl(GetInputUrl input);
|
Task<HttpStatusCodeResult> TokenByCompanyUrl(GetInputUrl input);
|
||||||
Task<bool> GetUrlIsValid(string url);
|
Task<ValidUrlResponseDto> UrlIsValid(string url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,5 +29,7 @@ namespace BCS.BMC.FirebaseCloudMessaging.Dto
|
|||||||
public List<string> UserId { get; set; }
|
public List<string> UserId { get; set; }
|
||||||
[FirestoreProperty]
|
[FirestoreProperty]
|
||||||
public int CompanyId { get; set; }
|
public int CompanyId { get; set; }
|
||||||
|
[FirestoreProperty]
|
||||||
|
public Guid? ScheduleGenerationId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ namespace BCS.BMC.FirebaseCloudMessaging.Dto
|
|||||||
public bool Status { get; set; }
|
public bool Status { get; set; }
|
||||||
public List<string> UserId { get; set; }
|
public List<string> UserId { get; set; }
|
||||||
public string CompanyUrl { get; set; }
|
public string CompanyUrl { get; set; }
|
||||||
|
public Guid? ScheduleGenerationId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
//[AutoMapFrom(typeof(NotificationModel))]
|
//[AutoMapFrom(typeof(NotificationModel))]
|
||||||
|
@ -126,5 +126,7 @@
|
|||||||
<text name="CompanyMaster">Company Master</text>
|
<text name="CompanyMaster">Company Master</text>
|
||||||
<text name="Url">Url</text>
|
<text name="Url">Url</text>
|
||||||
<text name="Id">Id</text>
|
<text name="Id">Id</text>
|
||||||
|
<text name="CreateNewCompany">Create New Company</text>
|
||||||
|
<text name="EditCompany">Edit Company</text>
|
||||||
</texts>
|
</texts>
|
||||||
</localizationDictionary>
|
</localizationDictionary>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<div class="modal fade" id="ClientMasterCreateModal" tabindex="-1" role="dialog" aria-labelledby="UserCreateModalLabel" data-backdrop="static">
|
<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-dialog modal-lg" role="document">
|
||||||
<div class="modal-content">
|
<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">
|
<form name="clientMasterCreateForm" role="form" class="form-horizontal">
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
@*<ul class="nav nav-tabs" role="tablist">
|
@*<ul class="nav nav-tabs" role="tablist">
|
||||||
@ -26,17 +26,17 @@
|
|||||||
<div class="tab-content mt-4">
|
<div class="tab-content mt-4">
|
||||||
<div role="tabpanel" class="tab-pane container active" id="create-client-details">
|
<div role="tabpanel" class="tab-pane container active" id="create-client-details">
|
||||||
<div class="form-group row required">
|
<div class="form-group row required">
|
||||||
<label class="col-md-3 col-form-label">@L("Url")</label>
|
<label class="col-md-2 col-form-label">@L("Url")</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-8">
|
||||||
<input type="text" class="form-control" id="Url" name="Url" required maxlength="@AbpUserBase.MaxNameLength">
|
<input type="text" class="form-control" id="Url" name="Url" required>
|
||||||
</div>
|
</div>
|
||||||
@* <input type="submit" value="Check Url" class="download-button" name="submit">*@
|
<input type="submit" value="Check Url" class="btn btn-secondary btn-sm download-button" name="submit">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group row required">
|
<div class="form-group row" id="div_CompanyName" style="visibility : hidden">
|
||||||
<label class="col-md-3 col-form-label">@L("Company")</label>
|
<label class="col-md-2 col-form-label">@L("Company")</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-8">
|
||||||
<input type="text" class="form-control" name="CompanyName" required maxlength="@AbpUserBase.MaxUserNameLength" minlength="2">
|
<input type="text" class="form-control" name="CompanyName" id="CompanyName" readonly>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@* <div class="form-group row required">
|
@* <div class="form-group row required">
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
@{
|
@{
|
||||||
Layout = null;
|
Layout = null;
|
||||||
}
|
}
|
||||||
|
@await Html.PartialAsync("~/Views/Shared/Modals/_ModalHeader.cshtml", new ModalHeaderViewModel(L("EditCompany")))
|
||||||
<form name="EditCompanyForm" role="form" class="form-horizontal">
|
<form name="EditCompanyForm" role="form" class="form-horizontal">
|
||||||
<input type="hidden" name="Id" value="@Model.Id" />
|
<input type="hidden" name="Id" value="@Model.Id" />
|
||||||
<input type="hidden" name="DomainName" value="@Model.DomainName" />
|
<input type="hidden" name="DomainName" value="@Model.DomainName" />
|
||||||
@ -23,18 +23,20 @@
|
|||||||
</ul>*@
|
</ul>*@
|
||||||
<div class="tab-content mt-4">
|
<div class="tab-content mt-4">
|
||||||
<div role="tabpanel" class="tab-pane container active" id="edit-company-details">
|
<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">
|
<div class="form-group row required">
|
||||||
<label class="col-md-3 col-form-label">@L("Company")</label>
|
<label class="col-md-3 col-form-label">@L("Company")</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input id="CompanyName" type="text" class="form-control" name="CompanyName" value="@Model.CompanyName" required maxlength="@AbpUserBase.MaxUserNameLength" minlength="2">
|
<input id="CompanyName" type="text" class="form-control" name="CompanyName" value="@Model.CompanyName" required maxlength="@AbpUserBase.MaxUserNameLength" minlength="2">
|
||||||
</div>
|
</div>
|
||||||
</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">
|
@* <div class="form-group row required">
|
||||||
<label class="col-md-3 col-form-label">@L("ClientSubDomainName")</label>
|
<label class="col-md-3 col-form-label">@L("ClientSubDomainName")</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
(function ($) {
|
(function ($) {
|
||||||
var _companyService = abp.services.app.companyMaster
|
var _companyService = abp.services.app.companyMaster
|
||||||
l = abp.localization.getSource('BMC'),
|
l = abp.localization.getSource('BMC'),
|
||||||
_$modal = $('#ClientMasterCreateModal'),
|
_$modal = $('#ClientMasterCreateModal'),
|
||||||
_$form = _$modal.find('form'),
|
_$form = _$modal.find('form'),
|
||||||
_$table = $('#CompanyMasterTable');
|
_$table = $('#CompanyMasterTable');
|
||||||
|
|
||||||
var _$companyTable = _$table.DataTable({
|
var _$companyTable = _$table.DataTable({
|
||||||
paging: true,
|
paging: true,
|
||||||
@ -47,7 +47,7 @@
|
|||||||
targets: 3,
|
targets: 3,
|
||||||
data: 'url',
|
data: 'url',
|
||||||
sortable: false
|
sortable: false
|
||||||
},{
|
}, {
|
||||||
targets: 4,
|
targets: 4,
|
||||||
data: 'domainName',
|
data: 'domainName',
|
||||||
sortable: false
|
sortable: false
|
||||||
@ -56,7 +56,7 @@
|
|||||||
targets: 5,
|
targets: 5,
|
||||||
data: 'subDomainName',
|
data: 'subDomainName',
|
||||||
sortable: false
|
sortable: false
|
||||||
},{
|
}, {
|
||||||
targets: 6,
|
targets: 6,
|
||||||
data: null,
|
data: null,
|
||||||
sortable: false,
|
sortable: false,
|
||||||
@ -84,53 +84,20 @@
|
|||||||
$('input[type="checkbox"]', rows).prop('checked', this.checked);
|
$('input[type="checkbox"]', rows).prop('checked', this.checked);
|
||||||
});
|
});
|
||||||
|
|
||||||
//function validateUrl (isValid) {
|
_$form.find('.download-button').on('click', (e) => {
|
||||||
// var companydetails = _$form.serializeFormToObject();
|
e.preventDefault();
|
||||||
// abp.ui.setBusy();
|
var companydetails = _$form.serializeFormToObject();
|
||||||
// var companyUrl = companydetails.Url;
|
//abp.ui.setBusy();
|
||||||
// abp.notify.info(l('ValidatingUrl'));
|
var companyUrl = companydetails.Url;
|
||||||
// _companyService.urlIsValid(companyUrl);
|
|
||||||
|
|
||||||
//}
|
abp.notify.info(l('ValidatingUrl'));
|
||||||
//_$form.find('.download-button').on('click', (e) => {
|
var data = _companyService.urlIsValid(companyUrl);
|
||||||
// debugger;
|
data.done(function (result) {
|
||||||
// var companydetails = _$form.serializeFormToObject();
|
$('#div_CompanyName').attr("style", "visibility : visible");
|
||||||
// //abp.ui.setBusy();
|
$('#CompanyName').val(result.tenantName);
|
||||||
// var companyUrl = companydetails.Url;
|
});
|
||||||
// $.ajax({
|
})
|
||||||
// url: abp.appPath + 'CompanyMaster/GetUrlIsValid?url=' + companyUrl,
|
|
||||||
// type: 'GET',
|
|
||||||
// data: { url: companyUrl },
|
|
||||||
// success: function (data) {
|
|
||||||
// alert('ok');
|
|
||||||
// console.log(data);
|
|
||||||
|
|
||||||
// if (data.result == true) {
|
|
||||||
// debugger;
|
|
||||||
// alert('correct');
|
|
||||||
// // window.location.replace("Management Page.aspx");
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// Error: function () {
|
|
||||||
// alert('error');
|
|
||||||
// }
|
|
||||||
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// //var companydetails = _$form.serializeFormToObject();
|
|
||||||
// //abp.ui.setBusy();
|
|
||||||
// //var companyUrl = companydetails.Url;
|
|
||||||
// //var data = _companyService.getUrlIsValid(companyUrl);
|
|
||||||
// //data.done(function (result) {
|
|
||||||
// // var isSuccess = result;
|
|
||||||
// //})
|
|
||||||
// //console.log("Hello world!");
|
|
||||||
// //console.log('1', data);
|
|
||||||
// //});
|
|
||||||
//});
|
|
||||||
|
|
||||||
_$form.find('.save-button').on('click', (e) => {
|
_$form.find('.save-button').on('click', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user