Compare commits
17 Commits
Feature/pr
...
Feature/ro
| Author | SHA1 | Date | |
|---|---|---|---|
| 9475c786d3 | |||
| dddc4b143a | |||
| 3dace574ff | |||
| bf2a102a55 | |||
| 88744bd4cf | |||
| 5942075dd6 | |||
| 5c3c9739d1 | |||
| 355ec72140 | |||
| 90fa0ac8f8 | |||
| eb8352e8fc | |||
| 4c7599b568 | |||
| d179c90c48 | |||
| 8850328fd4 | |||
| 915f16c7c0 | |||
| 0d72392701 | |||
| 8f6007835c | |||
| 05d860795e |
@@ -7,7 +7,7 @@ namespace _0_Framework.Application;
|
||||
public class PagedResult<T> where T : class
|
||||
{
|
||||
public int TotalCount { get; set; }
|
||||
public List<T> List { get; set; }
|
||||
public List<T> List { get; set; } = [];
|
||||
}
|
||||
public class PagedResult<T,TMeta>:PagedResult<T> where T : class
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.RollCall;
|
||||
using CompanyManagment.App.Contracts.WorkingHoursTemp;
|
||||
@@ -91,5 +92,9 @@ namespace Company.Domain.RollCallAgg
|
||||
Task<List<RollCall>> GetRollCallsUntilNowWithWorkshopIdEmployeeIds(long workshopId, List<long> employeeIds,
|
||||
DateTime fromDate);
|
||||
#endregion
|
||||
|
||||
Task<PagedResult<RollCallCaseHistoryTitleDto>> GetCaseHistoryTitles(long workshopId,RollCallCaseHistorySearchModel searchModel);
|
||||
Task<List<RollCallCaseHistoryDetail>> GetCaseHistoryDetails(long workshopId,
|
||||
string titleId, RollCallCaseHistorySearchModel searchModel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
using _0_Framework.Excel;
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.RollCall;
|
||||
using OfficeOpenXml;
|
||||
using OfficeOpenXml.Drawing;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace CompanyManagement.Infrastructure.Excel.RollCall;
|
||||
|
||||
@@ -308,6 +314,111 @@ public class RollCallExcelGenerator : ExcelGenerator
|
||||
return package.GetAsByteArray();
|
||||
}
|
||||
|
||||
public static byte[] CaseHistoryExcelForEmployee(List<RollCallCaseHistoryDetail> data, string titleId)
|
||||
{
|
||||
if (!Regex.IsMatch(titleId, @"^\d{4}_\d{2}$"))
|
||||
throw new ArgumentException("Invalid titleId format.", nameof(titleId));
|
||||
|
||||
var splitDate = titleId.Split("_");
|
||||
var year = Convert.ToInt32(splitDate.First());
|
||||
var month = Convert.ToInt32(splitDate.Last());
|
||||
|
||||
var startDateFa = $"{year:D4}/{month:D2}/01";
|
||||
var startDate = startDateFa.ToGeorgianDateTime();
|
||||
var endDateFa = startDateFa.FindeEndOfMonth();
|
||||
var endDate = endDateFa.ToGeorgianDateTime();
|
||||
|
||||
var dateRange = (int)(endDate.Date - startDate.Date).TotalDays + 1;
|
||||
var dates = Enumerable.Range(0, dateRange).Select(x => startDate.AddDays(x)).ToList();
|
||||
|
||||
var safeData = data ?? new List<RollCallCaseHistoryDetail>();
|
||||
var first = safeData.FirstOrDefault();
|
||||
var totalWorkingTime = new TimeSpan(safeData.Sum(x => x.TotalWorkingTime.Ticks));
|
||||
|
||||
var viewModel = new CaseHistoryRollCallExcelForEmployeeViewModel
|
||||
{
|
||||
EmployeeId = first?.EmployeeId ?? 0,
|
||||
DateGr = startDate,
|
||||
PersonnelCode = first?.PersonnelCode,
|
||||
EmployeeFullName = first?.EmployeeFullName,
|
||||
PersianMonthName = month.ToFarsiMonthByIntNumber(),
|
||||
PersianYear = year.ToString(),
|
||||
TotalWorkingHoursFa = totalWorkingTime.ToFarsiHoursAndMinutes("-"),
|
||||
TotalWorkingTimeSpan = $"{(int)totalWorkingTime.TotalHours}:{totalWorkingTime.Minutes:00}",
|
||||
RollCalls = dates.Select((date, index) =>
|
||||
{
|
||||
var item = index < safeData.Count ? safeData[index] : null;
|
||||
var records = item?.Records ?? new List<RollCallCaseHistoryDetailRecord>();
|
||||
|
||||
return new RollCallItemForEmployeeExcelViewModel
|
||||
{
|
||||
DateGr = date,
|
||||
DateFa = date.ToFarsi(),
|
||||
DayOfWeekFa = date.DayOfWeek.DayOfWeeKToPersian(),
|
||||
PersonnelCode = item?.PersonnelCode,
|
||||
EmployeeFullName = item?.EmployeeFullName,
|
||||
IsAbsent = item?.Status == RollCallRecordStatus.Absent,
|
||||
HasLeave = item?.Status == RollCallRecordStatus.Leaved,
|
||||
IsHoliday = false,
|
||||
TotalWorkingHours = (item?.TotalWorkingTime ?? TimeSpan.Zero).ToFarsiHoursAndMinutes("-"),
|
||||
StartsItems = JoinRecords(records, r => r.StartTime),
|
||||
EndsItems = JoinRecords(records, r => r.EndTime),
|
||||
EnterTimeDifferences = JoinRecords(records, r => FormatSignedTimeSpan(r.EntryTimeDifference)),
|
||||
ExitTimeDifferences = JoinRecords(records, r => FormatSignedTimeSpan(r.ExitTimeDifference))
|
||||
};
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
return CaseHistoryExcelForEmployee(viewModel);
|
||||
}
|
||||
|
||||
public static byte[] CaseHistoryExcelForOneDay(List<RollCallCaseHistoryDetail> data, string titleId)
|
||||
{
|
||||
if (!Regex.IsMatch(titleId, @"^\d{4}/\d{2}/\d{2}$"))
|
||||
throw new ArgumentException("Invalid titleId format.", nameof(titleId));
|
||||
|
||||
var dateGr = titleId.ToGeorgianDateTime();
|
||||
var safeData = data ?? new List<RollCallCaseHistoryDetail>();
|
||||
|
||||
var viewModel = new CaseHistoryRollCallForOneDayViewModel
|
||||
{
|
||||
DateFa = titleId,
|
||||
DateGr = dateGr,
|
||||
DayOfWeekFa = dateGr.DayOfWeek.DayOfWeeKToPersian(),
|
||||
RollCalls = safeData.Select(item =>
|
||||
{
|
||||
var records = item.Records ?? new List<RollCallCaseHistoryDetailRecord>();
|
||||
return new RollCallItemForOneDayExcelViewModel
|
||||
{
|
||||
EmployeeFullName = item.EmployeeFullName,
|
||||
PersonnelCode = item.PersonnelCode,
|
||||
StartsItems = JoinRecords(records, r => r.StartTime),
|
||||
EndsItems = JoinRecords(records, r => r.EndTime),
|
||||
TotalWorkingHours = item.TotalWorkingTime.ToFarsiHoursAndMinutes("-")
|
||||
};
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
return CaseHistoryExcelForOneDay(viewModel);
|
||||
}
|
||||
|
||||
private static string JoinRecords(IEnumerable<RollCallCaseHistoryDetailRecord> records, Func<RollCallCaseHistoryDetailRecord, string> selector)
|
||||
{
|
||||
var safeRecords = records ?? Enumerable.Empty<RollCallCaseHistoryDetailRecord>();
|
||||
var values = safeRecords.Select(selector).Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
|
||||
return values.Count == 0 ? string.Empty : string.Join(Environment.NewLine, values);
|
||||
}
|
||||
|
||||
private static string FormatSignedTimeSpan(TimeSpan value)
|
||||
{
|
||||
if (value == TimeSpan.Zero)
|
||||
return "-";
|
||||
|
||||
var abs = value.Duration();
|
||||
var sign = value.Ticks < 0 ? "-" : "+";
|
||||
return $"{(int)abs.TotalHours}:{abs.Minutes:00}{sign}";
|
||||
}
|
||||
|
||||
private string CalculateExitMinuteDifference(TimeSpan early, TimeSpan late)
|
||||
{
|
||||
if (early == TimeSpan.Zero && late == TimeSpan.Zero)
|
||||
|
||||
@@ -4,6 +4,8 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.RollCall
|
||||
{
|
||||
@@ -125,7 +127,62 @@ namespace CompanyManagment.App.Contracts.RollCall
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> RecalculateValues(long workshopId, List<ReCalculateRollCallValues> command);
|
||||
|
||||
Task<PagedResult<RollCallCaseHistoryTitleDto>> GetCaseHistoryTitles(long workshopId,RollCallCaseHistorySearchModel searchModel);
|
||||
Task<List<RollCallCaseHistoryDetail>> GetCaseHistoryDetails(long workshopId, string titleId,
|
||||
RollCallCaseHistorySearchModel searchModel);
|
||||
|
||||
Task<RollCallCaseHistoryExcelDto> DownloadCaseHistoryExcel(long workshopId, string titleId,
|
||||
RollCallCaseHistorySearchModel searchModel);
|
||||
}
|
||||
|
||||
public class RollCallCaseHistoryExcelDto
|
||||
{
|
||||
public byte[] Bytes { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public string MimeType { get; set; }
|
||||
}
|
||||
|
||||
public class RollCallCaseHistoryDetail
|
||||
{
|
||||
public string EmployeeFullName { get; set; }
|
||||
public string PersonnelCode { get; set; }
|
||||
public TimeSpan TotalWorkingTime { get; set; }
|
||||
public List<RollCallCaseHistoryDetailRecord> Records { get; set; }
|
||||
public RollCallRecordStatus Status { get; set; }
|
||||
public long EmployeeId { get; set; }
|
||||
}
|
||||
|
||||
public enum RollCallRecordStatus
|
||||
{
|
||||
Worked = 0,
|
||||
Absent = 1,
|
||||
Leaved = 2
|
||||
}
|
||||
|
||||
public class RollCallCaseHistoryDetailRecord
|
||||
{
|
||||
public TimeSpan EntryTimeDifference { get; set; }
|
||||
public string StartTime { get; set; }
|
||||
public string EndTime { get; set; }
|
||||
public TimeSpan ExitTimeDifference { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class RollCallCaseHistorySearchModel:PaginationRequest
|
||||
{
|
||||
public string StartDate { get; set; }
|
||||
public string EndDate { get; set; }
|
||||
public string OneDayDate { get; set; }
|
||||
public long? EmployeeId { get; set; }
|
||||
}
|
||||
|
||||
public class RollCallCaseHistoryTitleDto
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
}
|
||||
|
||||
public class ReCalculateRollCallValues
|
||||
{
|
||||
public long EmployeeId { get; set; }
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\0_Framework\0_Framework.csproj" />
|
||||
<ProjectReference Include="..\Company.Domain\Company.Domain.csproj" />
|
||||
<ProjectReference Include="..\CompanyManagement.Infrastructure.Excel\CompanyManagement.Infrastructure.Excel.csproj" />
|
||||
<ProjectReference Include="..\CompanyManagment.App.Contracts\CompanyManagment.App.Contracts.csproj" />
|
||||
<ProjectReference Include="..\CompanyManagment.EFCore\CompanyManagment.EFCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -3,9 +3,11 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
|
||||
using _0_Framework.Exceptions;
|
||||
using Company.Domain.CheckoutAgg;
|
||||
using Company.Domain.CustomizeCheckoutAgg;
|
||||
using Company.Domain.CustomizeCheckoutTempAgg;
|
||||
@@ -16,6 +18,8 @@ using Company.Domain.LeaveAgg;
|
||||
using Company.Domain.RollCallAgg;
|
||||
using Company.Domain.RollCallAgg.DomainService;
|
||||
using Company.Domain.RollCallEmployeeAgg;
|
||||
using Company.Domain.WorkshopAgg;
|
||||
using CompanyManagement.Infrastructure.Excel.RollCall;
|
||||
using CompanyManagment.App.Contracts.Checkout;
|
||||
using CompanyManagment.App.Contracts.Employee;
|
||||
using CompanyManagment.App.Contracts.RollCall;
|
||||
@@ -34,8 +38,9 @@ public class RollCallApplication : IRollCallApplication
|
||||
private readonly ICustomizeWorkshopSettingsRepository _customizeWorkshopSettingsRepository;
|
||||
private readonly ICustomizeWorkshopEmployeeSettingsRepository _customizeWorkshopEmployeeSettingsRepository;
|
||||
private readonly ICustomizeCheckoutTempRepository _customizeCheckoutTempRepository;
|
||||
private readonly IWorkshopRepository _workshopRepository;
|
||||
|
||||
public RollCallApplication(IRollCallRepository rollCallRepository, IRollCallEmployeeRepository rollCallEmployeeRepository, IEmployeeRepository employeeRepository, ILeaveRepository leaveRepository, ICustomizeCheckoutRepository customizeCheckoutRepository, ICheckoutRepository checkoutRepository, IRollCallDomainService rollCallDomainService, ICustomizeWorkshopSettingsRepository customizeWorkshopSettingsRepository, ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository, ICustomizeCheckoutTempRepository customizeCheckoutTempRepository)
|
||||
public RollCallApplication(IRollCallRepository rollCallRepository, IRollCallEmployeeRepository rollCallEmployeeRepository, IEmployeeRepository employeeRepository, ILeaveRepository leaveRepository, ICustomizeCheckoutRepository customizeCheckoutRepository, ICheckoutRepository checkoutRepository, IRollCallDomainService rollCallDomainService, ICustomizeWorkshopSettingsRepository customizeWorkshopSettingsRepository, ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository, ICustomizeCheckoutTempRepository customizeCheckoutTempRepository, IWorkshopRepository workshopRepository)
|
||||
{
|
||||
_rollCallRepository = rollCallRepository;
|
||||
_rollCallEmployeeRepository = rollCallEmployeeRepository;
|
||||
@@ -47,6 +52,7 @@ public class RollCallApplication : IRollCallApplication
|
||||
_customizeWorkshopSettingsRepository = customizeWorkshopSettingsRepository;
|
||||
_customizeWorkshopEmployeeSettingsRepository = customizeWorkshopEmployeeSettingsRepository;
|
||||
_customizeCheckoutTempRepository = customizeCheckoutTempRepository;
|
||||
_workshopRepository = workshopRepository;
|
||||
}
|
||||
|
||||
public OperationResult Create(CreateRollCall command)
|
||||
@@ -858,4 +864,58 @@ public class RollCallApplication : IRollCallApplication
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<PagedResult<RollCallCaseHistoryTitleDto>> GetCaseHistoryTitles(long workshopId,
|
||||
RollCallCaseHistorySearchModel searchModel)
|
||||
{
|
||||
return await _rollCallRepository.GetCaseHistoryTitles(workshopId,searchModel);
|
||||
}
|
||||
|
||||
public async Task<List<RollCallCaseHistoryDetail>> GetCaseHistoryDetails(long workshopId,
|
||||
string titleId, RollCallCaseHistorySearchModel searchModel)
|
||||
{
|
||||
return await _rollCallRepository.GetCaseHistoryDetails(workshopId, titleId, searchModel);
|
||||
}
|
||||
|
||||
public async Task<RollCallCaseHistoryExcelDto> DownloadCaseHistoryExcel(long workshopId, string titleId,
|
||||
RollCallCaseHistorySearchModel searchModel)
|
||||
{
|
||||
var data = await _rollCallRepository
|
||||
.GetCaseHistoryDetails(workshopId, titleId, searchModel);
|
||||
string nameSecondPart = "";
|
||||
byte[] excelBytes;
|
||||
|
||||
if (Regex.IsMatch(titleId, @"^\d{4}_\d{2}$"))
|
||||
{
|
||||
var splitDate = titleId.Split("_");
|
||||
var year = Convert.ToInt32(splitDate.First());
|
||||
var month = Convert.ToInt32(splitDate.Last());
|
||||
|
||||
var monthName = Convert.ToInt32(month).ToFarsiMonthByIntNumber();
|
||||
nameSecondPart = $"{year}/{monthName}";
|
||||
excelBytes = RollCallExcelGenerator.CaseHistoryExcelForEmployee(data, titleId);
|
||||
}
|
||||
else if (Regex.IsMatch(titleId, @"^\d{4}/\d{2}/\d{2}$"))
|
||||
{
|
||||
var oneDayDate = titleId.ToGeorgianDateTime();
|
||||
nameSecondPart = $" {oneDayDate.DayOfWeek.DayOfWeeKToPersian()}،{titleId}";
|
||||
excelBytes = RollCallExcelGenerator.CaseHistoryExcelForOneDay(data, titleId);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BadRequestException("شناسه سر تیتر وارد شده نامعتبر است");
|
||||
}
|
||||
|
||||
var workshopFullName = _workshopRepository.Get(workshopId)?.WorkshopFullName ?? "بدون کارگاه";
|
||||
|
||||
var fileName = $"{workshopFullName} - {nameSecondPart}.xlsx";
|
||||
|
||||
var res = new RollCallCaseHistoryExcelDto()
|
||||
{
|
||||
Bytes = excelBytes,
|
||||
MimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
FileName = fileName
|
||||
};
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -713,10 +713,15 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
|
||||
var itemsQuery = _companyContext.EmployeeDocumentItems
|
||||
.Where(x => x.DocumentStatus != DocumentStatus.Unsubmitted)
|
||||
.Include(x => x.EmployeeDocuments)
|
||||
.ThenInclude(x => x.Workshop).ThenInclude(x => x.WorkshopEmployers).ThenInclude(x => x.Employer)
|
||||
.GroupBy(x => x.WorkshopId).Select(x => new WorkshopWithEmployeeDocumentsViewModel()
|
||||
.ThenInclude(x => x.Workshop)
|
||||
.ThenInclude(x => x.WorkshopEmployers)
|
||||
.ThenInclude(x => x.Employer)
|
||||
.GroupBy(x => x.WorkshopId)
|
||||
.Select(x => new WorkshopWithEmployeeDocumentsViewModel()
|
||||
{
|
||||
SubmittedItemsCount = x.Count(y => y.DocumentStatus == DocumentStatus.SubmittedByAdmin || y.DocumentStatus == DocumentStatus.SubmittedByClient),
|
||||
SubmittedItemsCount = x
|
||||
.Count(y => y.DocumentStatus == DocumentStatus.SubmittedByAdmin
|
||||
|| y.DocumentStatus == DocumentStatus.SubmittedByClient),
|
||||
WorkshopId = x.Key,
|
||||
WorkshopFullName = x.First().EmployeeDocuments.Workshop.WorkshopName,
|
||||
EmployerName = x.First().EmployeeDocuments.Workshop.WorkshopEmployers.First().Employer.FullName
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,200 @@
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagement.Infrastructure.Excel.RollCall;
|
||||
using CompanyManagment.App.Contracts.RollCall;
|
||||
using CompanyManagment.App.Contracts.RollCallEmployee;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ServiceHost.BaseControllers;
|
||||
|
||||
namespace ServiceHost.Areas.Client.Controllers.RollCall;
|
||||
|
||||
public class RollCallCaseHistoryController : ClientBaseController
|
||||
{
|
||||
private readonly IRollCallApplication _rollCallApplication;
|
||||
private readonly long _workshopId;
|
||||
private readonly IWorkshopApplication _workshopApplication;
|
||||
private readonly IRollCallEmployeeApplication _rollCallEmployeeApplication;
|
||||
public RollCallCaseHistoryController(IRollCallApplication rollCallApplication,
|
||||
IAuthHelper authHelper, IWorkshopApplication workshopApplication,
|
||||
IRollCallEmployeeApplication rollCallEmployeeApplication)
|
||||
{
|
||||
_rollCallApplication = rollCallApplication;
|
||||
_workshopApplication = workshopApplication;
|
||||
_rollCallEmployeeApplication = rollCallEmployeeApplication;
|
||||
_workshopId = authHelper.GetWorkshopId();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<PagedResult<RollCallCaseHistoryTitleDto>>> GetTitles(
|
||||
RollCallCaseHistorySearchModel searchModel)
|
||||
{
|
||||
return await _rollCallApplication.GetCaseHistoryTitles(_workshopId, searchModel);
|
||||
}
|
||||
|
||||
[HttpGet("details")]
|
||||
public async Task<ActionResult<List<RollCallCaseHistoryDetail>>> GetDetails(string titleId,
|
||||
RollCallCaseHistorySearchModel searchModel)
|
||||
{
|
||||
return await _rollCallApplication.GetCaseHistoryDetails(_workshopId, titleId, searchModel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد و ویرایش
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public ActionResult<OperationResult> Upsert(CreateOrEditEmployeeRollCall command)
|
||||
{
|
||||
command.WorkshopId = _workshopId;
|
||||
return _rollCallApplication.ManualEdit(command);
|
||||
}
|
||||
|
||||
[HttpGet("print")]
|
||||
public async Task<ActionResult<List<RollCallCaseHistoryDetail>>> GetPrintDetails(string titleId,
|
||||
RollCallCaseHistorySearchModel searchModel)
|
||||
{
|
||||
return await _rollCallApplication.GetCaseHistoryDetails(_workshopId, titleId, searchModel);
|
||||
}
|
||||
|
||||
[HttpGet("total-working")]
|
||||
public ActionResult<OperationResult<string>> OnGetTotalWorking(
|
||||
string startDate,
|
||||
string startTime,
|
||||
string endDate,
|
||||
string endTime)
|
||||
{
|
||||
var op = new OperationResult<string>();
|
||||
const string emptyValue = "-";
|
||||
|
||||
if (!TryParseDateTime(startDate, startTime, out var start) ||
|
||||
!TryParseDateTime(endDate, endTime, out var end))
|
||||
{
|
||||
return op.Succcedded(emptyValue);
|
||||
}
|
||||
|
||||
if (start >= end)
|
||||
{
|
||||
return op.Succcedded(emptyValue);
|
||||
}
|
||||
|
||||
var duration = (end - start).ToFarsiHoursAndMinutes(emptyValue);
|
||||
return op.Succcedded(duration);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpGet("excel")]
|
||||
public async Task<IActionResult> GetDownload(string titleId, RollCallCaseHistorySearchModel searchModel)
|
||||
{
|
||||
var res =await _rollCallApplication.DownloadCaseHistoryExcel(_workshopId, titleId, searchModel);
|
||||
|
||||
return File(res.Bytes,
|
||||
res.MimeType,
|
||||
res.FileName);
|
||||
|
||||
}
|
||||
|
||||
[HttpGet("edit")]
|
||||
public ActionResult<EditRollCallDetailsResult> GetEditDetails(string date, long employeeId)
|
||||
{
|
||||
var result = _rollCallApplication.GetWorkshopEmployeeRollCallsForDate(_workshopId, employeeId, date);
|
||||
//var dates = _rollCallApplication.GetEditableDatesForManualEdit(date.ToGeorgianDateTime());
|
||||
var name = _rollCallEmployeeApplication.GetByEmployeeIdAndWorkshopId(employeeId, _workshopId);
|
||||
|
||||
var total = new TimeSpan(result.Sum(x =>
|
||||
(x.EndDate!.Value.Ticks - x.StartDate!.Value.Ticks)));
|
||||
|
||||
var res = new EditRollCallDetailsResult()
|
||||
{
|
||||
EmployeeFullName = name.EmployeeFullName,
|
||||
EmployeeId = employeeId,
|
||||
DateFa = date,
|
||||
//EditableDates = dates,
|
||||
Records = result.Select(x=>new EmployeeRollCallRecord()
|
||||
{
|
||||
Date = x.DateGr,
|
||||
EndDate = x.EndDateFa,
|
||||
EndTime = x.EndTimeString,
|
||||
RollCallId = x.Id,
|
||||
StartDate = x.StartDateFa,
|
||||
StartTime = x.StartTimeString
|
||||
}).ToList(),
|
||||
TotalRollCallsDuration = total.ToFarsiHoursAndMinutes("-")
|
||||
};
|
||||
|
||||
return res;
|
||||
}
|
||||
[HttpPost("edit")]
|
||||
public ActionResult<OperationResult> Edit(CreateOrEditEmployeeRollCall command)
|
||||
{
|
||||
command.WorkshopId = _workshopId;
|
||||
var result = _rollCallApplication.ManualEdit(command);
|
||||
return result;
|
||||
}
|
||||
[HttpDelete("delete")]
|
||||
public IActionResult OnPostRemoveEmployeeRollCallsInDate(RemoveEmployeeRollCallRequest request)
|
||||
{
|
||||
var result = _rollCallApplication.RemoveEmployeeRollCallsInDate(_workshopId, request.EmployeeId, request.Date);
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
success = result.IsSuccedded,
|
||||
message = result.Message,
|
||||
});
|
||||
}
|
||||
|
||||
// [HttpGet("edit")]
|
||||
// public ActionResult<> GetEditDetails(string date,long employeeId)
|
||||
// {
|
||||
// var result = _rollCallApplication.GetWorkshopEmployeeRollCallsForDate(_workshopId, employeeId, date);
|
||||
// //var dates = _rollCallApplication.GetEditableDatesForManualEdit(date.ToGeorgianDateTime());
|
||||
// var name = _rollCallEmployeeApplication.GetByEmployeeIdAndWorkshopId(employeeId, _workshopId);
|
||||
//
|
||||
// var total = new TimeSpan(result.Sum(x =>
|
||||
// (x.EndDate!.Value.Ticks - x.StartDate!.Value.Ticks)));
|
||||
//
|
||||
// var command = new EmployeeRollCallsViewModel()
|
||||
// {
|
||||
// EmployeeFullName = name.EmployeeFullName,
|
||||
// EmployeeId = employeeId,
|
||||
// DateFa = date,
|
||||
// //EditableDates = dates,
|
||||
// RollCalls = result,
|
||||
// TotalRollCallsDuration = total.ToFarsiHoursAndMinutes("-")
|
||||
// };
|
||||
// }
|
||||
|
||||
|
||||
private static bool TryParseDateTime(string date, string time, out DateTime result)
|
||||
{
|
||||
result = default;
|
||||
|
||||
try
|
||||
{
|
||||
var dateTime = date.ToGeorgianDateTime();
|
||||
var timeOnly = TimeOnly.Parse(time);
|
||||
result = dateTime.AddTicks(timeOnly.Ticks);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EditRollCallDetailsResult
|
||||
{
|
||||
public string EmployeeFullName { get; set; }
|
||||
public long EmployeeId { get; set; }
|
||||
public string DateFa { get; set; }
|
||||
public string TotalRollCallsDuration { get; set; }
|
||||
public List<EmployeeRollCallRecord> Records { get; set; }
|
||||
}
|
||||
|
||||
public class RemoveEmployeeRollCallRequest
|
||||
{
|
||||
public long EmployeeId { get; set; }
|
||||
public string Date { get; set; }
|
||||
}
|
||||
@@ -251,8 +251,6 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
|
||||
var hours = (int)span.TotalHours;
|
||||
var minutes = span.Minutes;
|
||||
|
||||
|
||||
|
||||
if (hours > 0 && minutes > 0)
|
||||
{
|
||||
return new JsonResult(new
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ServiceHost.BaseControllers;
|
||||
|
||||
[Authorize(Policy = "AdminArea")]
|
||||
|
||||
@@ -42,6 +42,15 @@ public class GeneralController : GeneralBaseController
|
||||
currentDate
|
||||
});
|
||||
}
|
||||
[HttpGet("persian-day-of-week")]
|
||||
public ActionResult<OperationResult<string>> OnGetDayOfWeek(string dateFa)
|
||||
{
|
||||
var op = new OperationResult<string>();
|
||||
if (!dateFa.TryToGeorgianDateTime(out DateTime date))
|
||||
return op.Failed("تاریخ وارد شده نامعتبر است");
|
||||
|
||||
return op.Succcedded(date.DayOfWeek.DayOfWeeKToPersian());
|
||||
}
|
||||
|
||||
// [HttpGet("pm-permissions")]
|
||||
// public IActionResult GetPMPermissions()
|
||||
@@ -96,44 +105,8 @@ public class GeneralController : GeneralBaseController
|
||||
var statusCode = isSuccess ? "1" : "0";
|
||||
return $"{baseUrl}/callback?Status={statusCode}&transactionId={transactionId}";
|
||||
}
|
||||
}
|
||||
|
||||
public class TokenReq
|
||||
{
|
||||
public long Amount { get; set; }
|
||||
|
||||
public string CallbackUrl { get; set; }
|
||||
|
||||
[Display(Name = "شماره فاکتور")]
|
||||
[MaxLength(100)]
|
||||
[Required]
|
||||
[Key]
|
||||
// be ezaye har pazirande bayad yekta bashad
|
||||
public string invoiceID { get; set; }
|
||||
|
||||
[Required] public long terminalID { get; set; }
|
||||
|
||||
/*
|
||||
* JSON Bashad
|
||||
* etelaate takmili site harchi
|
||||
* nabayad char khas dashte bashe (*'"xp_%!+- ...)
|
||||
*/
|
||||
public string Payload { get; set; } = "";
|
||||
public string email { get; set; }
|
||||
}
|
||||
|
||||
public class TokenResp
|
||||
{
|
||||
// if 0 = success
|
||||
public int Status { get; set; }
|
||||
public string AccessToken { get; set; }
|
||||
}
|
||||
|
||||
public class PayRequest
|
||||
{
|
||||
[Required] [MaxLength(3000)] public string token { get; set; }
|
||||
[Required] public long terminalID { get; set; }
|
||||
public string nationalCode { get; set; }
|
||||
}
|
||||
|
||||
public class SepehrGatewayPayResponse
|
||||
@@ -170,9 +143,3 @@ public class SepehrGatewayPayResponse
|
||||
|
||||
[Display(Name = " شماره کارت ")] public string cardnumber { get; set; }
|
||||
}
|
||||
|
||||
public class AdviceReq
|
||||
{
|
||||
[Display(Name = " رسید دیجیتال ")] public string digitalreceipt { get; set; }
|
||||
public long Tid { get; set; }
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
"sqlDebugging": true,
|
||||
"dotnetRunMessages": "true",
|
||||
"nativeDebugging": true,
|
||||
"applicationUrl": "https://localhost:5004;http://localhost:5003;",
|
||||
"applicationUrl": "https://localhost:5004;http://localhost:5003;https://192.168.0.117:5005",
|
||||
"jsWebView2Debugging": false,
|
||||
"hotReloadEnabled": true
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user