...
This commit is contained in:
@@ -34,9 +34,9 @@ namespace Hushian.Application.Services
|
||||
_hubContext = hubContext;
|
||||
}
|
||||
|
||||
public async Task<ResponseBase<int>> NewConversation(ADD_ConversationDto dto, ConversationType type = ConversationType.UE)
|
||||
public async Task<ResponseBase<Read_ConversationDto>> NewConversation(ADD_ConversationDto dto, ConversationType type = ConversationType.UE)
|
||||
{
|
||||
var Response = new ResponseBase<int>();
|
||||
var Response = new ResponseBase<Read_ConversationDto>();
|
||||
if (await _companyService.AnyCompany(dto.CompanyID))
|
||||
{
|
||||
if (await _userService.AnyUser(dto.UserID))
|
||||
@@ -62,8 +62,24 @@ namespace Hushian.Application.Services
|
||||
ConversationResponses = new List<ConversationResponse>() { new() { Text = dto.Question, Type = type } }
|
||||
};
|
||||
var mi = await _ConversationRepository.ADD(conversation);
|
||||
Response.Value = mi.ID;
|
||||
Response.Success = Response.Value > 0;
|
||||
Response.Value = new Read_ConversationDto()
|
||||
{
|
||||
ID = mi.ID,
|
||||
ExperID = mi.ConversationResponses.OrderBy(o => o.ID).Last().ExperID,
|
||||
ExperFullName = mi.ConversationResponses.OrderBy(o => o.ID).Last().Exper.FullName,
|
||||
GroupID = mi.GroupID,
|
||||
GroupName = mi.Group.Name,
|
||||
LastText = mi.ConversationResponses.OrderBy(o => o.ID).Last().Text,
|
||||
LastMsgdate = mi.Cdatetime.GetDatePersian(),
|
||||
LastMsgtime = mi.Cdatetime.GetTime(),
|
||||
LastMsgType = mi.ConversationResponses.OrderBy(o => o.ID).Last().Type,
|
||||
NoReadCount = mi.ConversationResponses.Count(c => !c.IsRead),
|
||||
status = mi.Status,
|
||||
UserID = mi.UserID,
|
||||
UserFullName = string.IsNullOrEmpty(mi.User.FullName) ? mi.User.Mobile : mi.User.FullName
|
||||
|
||||
};
|
||||
Response.Success = mi.ID > 0;
|
||||
}
|
||||
else Response.Errors.Add("شناسه گروه صحیح نمی باشد");
|
||||
|
||||
@@ -78,9 +94,9 @@ namespace Hushian.Application.Services
|
||||
|
||||
return Response;
|
||||
}
|
||||
public async Task<ResponseBase<int>> NewConversationResponse(ADD_ConversationResponseDto dto, int? ExperID)
|
||||
public async Task<ResponseBase<Read_ConversationResponseDto>> NewConversationResponse(ADD_ConversationResponseDto dto, int? ExperID)
|
||||
{
|
||||
var Response = new ResponseBase<int>();
|
||||
var Response = new ResponseBase<Read_ConversationResponseDto>();
|
||||
if (dto.Type == ConversationType.EU && !ExperID.HasValue)
|
||||
{
|
||||
Response.Errors.Add("کارشناس گفتگو را مشخص گنید");
|
||||
@@ -108,8 +124,21 @@ namespace Hushian.Application.Services
|
||||
FileType = dto.FileType,
|
||||
FileName = dto.FileName
|
||||
};
|
||||
Response.Value = (await _ConversationResponseRepository.ADD(response)).ID;
|
||||
Response.Success = Response.Value > 0;
|
||||
var statuschangedb = await _ConversationResponseRepository.ADD(response);
|
||||
Response.Value = new Read_ConversationResponseDto()
|
||||
{
|
||||
ConversationID = statuschangedb.ConversationID,
|
||||
ExperID = statuschangedb.ExperID,
|
||||
ExperName = statuschangedb.Exper.FullName,
|
||||
FileContent = statuschangedb.FileContent,
|
||||
FileName = statuschangedb.FileName,
|
||||
FileType = statuschangedb.FileType,
|
||||
ID = statuschangedb.ID,
|
||||
IsRead = statuschangedb.IsRead,
|
||||
text = statuschangedb.Text,
|
||||
Type = statuschangedb.Type
|
||||
};
|
||||
Response.Success = statuschangedb.ID > 0;
|
||||
|
||||
if (convModel.Status == ConversationStatus.Recorded && Response.Success)
|
||||
{
|
||||
|
@@ -202,7 +202,7 @@
|
||||
{
|
||||
if (!string.IsNullOrEmpty(MsgInput) && SelectedConversationItems!=null)
|
||||
{
|
||||
await conversationService.ADDConversationItemFromCompanySide(SelectedConversationItems[0].ConversationID, MsgInput, Role=="Company" ? Common.Enums.ConversationType.CU : Common.Enums.ConversationType.EU);
|
||||
await conversationService.ADDConversationItem(SelectedConversationItems[0].ConversationID, MsgInput, Role=="Company" ? Common.Enums.ConversationType.CU : Common.Enums.ConversationType.EU);
|
||||
SelectedConversationItems?.Add(new() { text = MsgInput, Type = Common.Enums.ConversationType.EU });
|
||||
SelectedConversation.LastText = MsgInput;
|
||||
await Task.Yield();
|
||||
|
@@ -1,30 +1,40 @@
|
||||
@using Common.Dtos.Conversation
|
||||
|
||||
<div style="display: flex; "
|
||||
dir="rtl" class="p-1 rounded w-100">
|
||||
@if (SelectedConversationItems!=null)
|
||||
{
|
||||
<p>@SelectedConversationItems.Count()</p>
|
||||
}
|
||||
<div class="bg-green-100 border p-2 rounded text-end" dir="rtl">
|
||||
سلام
|
||||
|
||||
</div>
|
||||
<Icon Style="align-self: self-end;" Name="IconName.CheckLg" Size="IconSize.x5" />
|
||||
|
||||
</div>
|
||||
@foreach (var item in SelectedConversationItems)
|
||||
{
|
||||
if (item.Type == Common.Enums.ConversationType.UE)
|
||||
{
|
||||
<div style="display: flex; "
|
||||
dir="rtl" class="p-1 rounded w-100">
|
||||
<div class="bg-white border p-3 rounded text-end" dir="rtl">
|
||||
جهت خرید در سایت در هنگام درج اطلاعات بهخصوص کد اقتصادی دقت نمائید صورتحساب شما بر همین اساس ارسال خواهد شد در هنگام درج اطلاعات بهخصوص کد اقتصادی دقت نمائید صورتحساب شما بر همین اساس ارسال خواهد شد ثبت نام نموده و سپس از منو فروشگاه اقدام به انتخاب محصول مورد نظر خود نمائید.<br /><br />
|
||||
|
||||
<div class="bg-green-100 border p-2 rounded text-end" dir="rtl">
|
||||
@item.text
|
||||
</div>
|
||||
<Icon Style="align-self: self-end;" Name="IconName.CheckLg" Size="IconSize.x5" />
|
||||
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div style="display: flex; "
|
||||
dir="ltr" class="p-1 rounded w-100">
|
||||
<div class="bg-white border p-3 rounded text-end" dir="rtl">
|
||||
@item.text
|
||||
</div>
|
||||
<Icon Style="align-self: self-end;" Name="IconName.CheckLg" Size="IconSize.x5" />
|
||||
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@code {
|
||||
[Parameter] public List<Read_ConversationDto> Conversations { get; set; }
|
||||
// [Parameter] public List<Read_ConversationDto> Conversations { get; set; }
|
||||
[Parameter] public List<Read_ConversationResponseDto> SelectedConversationItems { get; set; }
|
||||
}
|
||||
|
@@ -31,15 +31,29 @@
|
||||
|
||||
<div class="d-flex">
|
||||
|
||||
<div class="container-input" style="width:150px;margin-left:5px">
|
||||
<input style="text-align:center;height:30px" type="number" id="Code" maxlength="64"
|
||||
@bind-value=Code title="کد احراز" class="input-form input_vk_1" required="" data-val="true" name="Code">
|
||||
<div style="width:200px;margin-left:5px;direction: ltr;">
|
||||
<input maxlength="1" type="text" inputmode="numeric" pattern="[0-9]*"
|
||||
@bind="code1" @oninput="MoveNext"
|
||||
style="width: 40px; height: 40px; text-align: center; border: 2px solid #ccc; border-radius: 5px; font-size: 20px;"
|
||||
@ref="input1" autoFocus />
|
||||
|
||||
<input maxlength="1" type="text" inputmode="numeric" pattern="[0-9]*"
|
||||
@bind="code2" @oninput="MoveNext"
|
||||
style="width: 40px; height: 40px; text-align: center; border: 2px solid #ccc; border-radius: 5px; font-size: 20px;"
|
||||
@ref="input2" />
|
||||
|
||||
<input maxlength="1" type="text" inputmode="numeric" pattern="[0-9]*"
|
||||
@bind="code3" @oninput="MoveNext"
|
||||
style="width: 40px; height: 40px; text-align: center; border: 2px solid #ccc; border-radius: 5px; font-size: 20px;"
|
||||
@ref="input3" />
|
||||
|
||||
<input maxlength="1" type="text" inputmode="numeric" pattern="[0-9]*"
|
||||
@bind="code4" @oninput="OnLastInput"
|
||||
style="width: 40px; height: 40px; text-align: center; border: 2px solid #ccc; border-radius: 5px; font-size: 20px;"
|
||||
@ref="input4" />
|
||||
|
||||
</div>
|
||||
<Button Color="ButtonColor.Primary" Type="ButtonType.Submit" class="btn-dark"
|
||||
style="text-align:center;height:30px" @onclick="ver">
|
||||
احراز
|
||||
</Button>
|
||||
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -52,6 +66,9 @@
|
||||
public string Username { get; set; }
|
||||
public int ID { get; set; } = 0;
|
||||
public string Code { get; set; } = string.Empty;
|
||||
//-----------------
|
||||
private string code1, code2, code3, code4;
|
||||
private ElementReference input1, input2, input3, input4;
|
||||
}
|
||||
@functions{
|
||||
async Task Login()
|
||||
@@ -61,6 +78,7 @@
|
||||
{
|
||||
Mobile=Username
|
||||
});
|
||||
|
||||
visible = false;
|
||||
}
|
||||
async Task ver()
|
||||
@@ -70,4 +88,33 @@
|
||||
await OnMultipleOfThree.InvokeAsync();
|
||||
visible = false;
|
||||
}
|
||||
private async Task MoveNext(ChangeEventArgs e)
|
||||
{
|
||||
if (e.Value?.ToString()?.Length == 1)
|
||||
{
|
||||
if (input1.Context == null) return;
|
||||
|
||||
if (string.IsNullOrEmpty(code1))
|
||||
await input2.FocusAsync();
|
||||
else if (string.IsNullOrEmpty(code2))
|
||||
await input3.FocusAsync();
|
||||
else if (string.IsNullOrEmpty(code3))
|
||||
await input4.FocusAsync();
|
||||
else if (string.IsNullOrEmpty(code4))
|
||||
{
|
||||
Code = $"{code1}{code2}{code3}{code4}";
|
||||
}
|
||||
}
|
||||
}
|
||||
private async Task OnLastInput(ChangeEventArgs e)
|
||||
{
|
||||
code4 = e.Value?.ToString();
|
||||
|
||||
if (!string.IsNullOrEmpty(code4) && code4.Length == 1)
|
||||
{
|
||||
Code = $"{code1}{code2}{code3}{code4}";
|
||||
|
||||
await ver();
|
||||
}
|
||||
}
|
||||
}
|
@@ -32,7 +32,8 @@
|
||||
}
|
||||
</div>
|
||||
<div class="card-body" style="max-height: 500px; overflow-y: auto; background-color: #f9f9f9;">
|
||||
|
||||
@if (!IsFisrLoding)
|
||||
{
|
||||
@if (!IsLogin)
|
||||
{
|
||||
<LoginComponent OnMultipleOfThree="EventCallback.Factory.Create(this, Login)" />
|
||||
@@ -56,15 +57,24 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<ChatBoxComponent Conversations="Conversations" SelectedConversationItems="SelectedConversationItems" />
|
||||
<ChatBoxComponent SelectedConversationItems="SelectedConversationItems" />
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="d-flex justify-content-center">
|
||||
<Spinner Class="me-3" Type="SpinnerType.Dots" Color="SpinnerColor.Primary" Visible="@IsFisrLoding" />
|
||||
|
||||
</div>
|
||||
@if (IsLogin && (@* Conversations.Count == 0 && *@ SelectedConversation == null) || (@* Conversations.Count > 0 && *@ SelectedConversation != null && SelectedConversation.status == Common.Enums.ConversationStatus.InProgress))
|
||||
|
||||
}
|
||||
</div>
|
||||
@if (IsLogin && (@* Conversations.Count == 0 && *@ SelectedConversation == null) || (@* Conversations.Count > 0 && *@ SelectedConversation != null && (SelectedConversation.status != Common.Enums.ConversationStatus.Finished)))
|
||||
{
|
||||
<div class="card-header text-white d-flex justify-content-between align-items-center">
|
||||
<input type="text" class="form-control" @bind-value="InputMessage" placeholder="پیام خود را بنویسید..." style="margin-left:10px" />
|
||||
@@ -105,6 +115,7 @@
|
||||
int CountQueueCompany = 0;
|
||||
public string CompanyName { get; set; } = "هوشیان";
|
||||
public bool IsLogin { get; set; } = false;
|
||||
public bool IsFisrLoding { get; set; } = true;
|
||||
public int? SelectedGroup { get; set; }
|
||||
public string InputMessage { get; set; }
|
||||
public bool Sending { get; set; } = false;
|
||||
@@ -121,7 +132,9 @@
|
||||
}
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
IsFisrLoding = true;
|
||||
await CheckOnline();
|
||||
IsFisrLoding = false;
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
async Task CheckOnline()
|
||||
@@ -192,7 +205,8 @@
|
||||
Conversations = await conversationService.MyConversationUserSide(CompanyID);
|
||||
if (Conversations.Count > 0)
|
||||
ConversationsContent =@<ConversionHistoryComponent Conversations="Conversations"
|
||||
OnMultipleOfThree="EventCallback.Factory.Create<int>(this, SelectedConv)" />;
|
||||
OnMultipleOfThree="EventCallback.Factory.Create<int>(this, SelectedConv)" />
|
||||
;
|
||||
|
||||
if (ConversationID.HasValue && ConversationID > 0 && Conversations.Count > 0)
|
||||
await SelectedConv(ConversationID.Value);
|
||||
@@ -229,12 +243,8 @@
|
||||
}
|
||||
async Task OnClickSendMssage()
|
||||
{
|
||||
// SelectedConversationItems.Add(new Read_ConversationResponseDto()
|
||||
// {
|
||||
// ConversationID=1,
|
||||
|
||||
// });
|
||||
// return;
|
||||
if (string.IsNullOrEmpty(InputMessage)) return;
|
||||
Sending = true;
|
||||
if (SelectedConversation != null)
|
||||
{
|
||||
@@ -243,6 +253,9 @@
|
||||
ConversationID = SelectedConversation.ID,
|
||||
Text = InputMessage
|
||||
};
|
||||
var inputconv= await conversationService.ADDConversationItem(SelectedConversation.ID, InputMessage, Common.Enums.ConversationType.UE);
|
||||
if (inputconv!=null) SelectedConversationItems.Add(inputconv);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -252,11 +265,11 @@
|
||||
GroupID = SelectedGroup,
|
||||
Question = InputMessage
|
||||
};
|
||||
var convID= await conversationService.NewConversationFromCurrentUser(Item);
|
||||
if (convID >0)
|
||||
var convNEW= await conversationService.NewConversationFromCurrentUser(Item);
|
||||
if (convNEW !=null)
|
||||
{
|
||||
ConversationID = convID;
|
||||
await SelectedConv(ConversationID.Value);
|
||||
Conversations.Add(convNEW);
|
||||
await SelectedConv(convNEW.ID);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -53,7 +53,7 @@ namespace HushianWebApp.Service
|
||||
|
||||
return new();
|
||||
}
|
||||
public async Task ADDConversationItemFromCompanySide(int ConversationID,string text, ConversationType type)
|
||||
public async Task<Read_ConversationResponseDto?> ADDConversationItem(int ConversationID,string text, ConversationType type)
|
||||
{
|
||||
var response = await _baseController.Post($"{BaseRoute}ADDConversationResponse",new ADD_ConversationResponseDto()
|
||||
{
|
||||
@@ -61,6 +61,10 @@ namespace HushianWebApp.Service
|
||||
Text=text,
|
||||
Type=type
|
||||
});
|
||||
if (response.IsSuccessStatusCode)
|
||||
return await response.Content.ReadFromJsonAsync<Read_ConversationResponseDto>();
|
||||
return null;
|
||||
|
||||
}
|
||||
public async Task<bool> ConversationIsFinish(int ConversationID)
|
||||
{
|
||||
@@ -83,13 +87,13 @@ namespace HushianWebApp.Service
|
||||
|
||||
return new();
|
||||
}
|
||||
public async Task<int> NewConversationFromCurrentUser(ADD_ConversationDto conversation)
|
||||
public async Task<Read_ConversationDto> NewConversationFromCurrentUser(ADD_ConversationDto conversation)
|
||||
{
|
||||
var response = await _baseController.Post($"{BaseRoute}NewConversationFromCurrentUser", conversation);
|
||||
if (response.IsSuccessStatusCode)
|
||||
return await response.Content.ReadFromJsonAsync<int>();
|
||||
return await response.Content.ReadFromJsonAsync<Read_ConversationDto>();
|
||||
|
||||
return -1;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user