diff --git a/0_Framework/Application/Version.cs b/0_Framework/Application/Version.cs index 1141c775..28a10db0 100644 --- a/0_Framework/Application/Version.cs +++ b/0_Framework/Application/Version.cs @@ -11,7 +11,7 @@ public static class Version static Version() { StyleVersion = "2.11.24"; - AdminVersion = "2.5.8"; + AdminVersion = "2.5.9"; CameraVersion = "1.0.3"; } diff --git a/AccountManagement.Application.Contracts/Account/AccountSearchModel.cs b/AccountManagement.Application.Contracts/Account/AccountSearchModel.cs index 206279f2..6267ddd0 100644 --- a/AccountManagement.Application.Contracts/Account/AccountSearchModel.cs +++ b/AccountManagement.Application.Contracts/Account/AccountSearchModel.cs @@ -9,5 +9,6 @@ public string RoleName { get; set; } public string VerifyCode { get; set; } public string IsActiveString { get; set; } + public string positionId { get; set; } } } diff --git a/AccountManagement.Application.Contracts/Account/AccountViewModel.cs b/AccountManagement.Application.Contracts/Account/AccountViewModel.cs index f71cea73..3b67b685 100644 --- a/AccountManagement.Application.Contracts/Account/AccountViewModel.cs +++ b/AccountManagement.Application.Contracts/Account/AccountViewModel.cs @@ -20,7 +20,7 @@ namespace AccountManagement.Application.Contracts.Account #region Mahan public int PositionValue { get; set; } - + public long PositionId { get; set; } #endregion } } diff --git a/AccountManagement.Application.Contracts/Account/IAccountApplication.cs b/AccountManagement.Application.Contracts/Account/IAccountApplication.cs index 8464c1dd..432ffef6 100644 --- a/AccountManagement.Application.Contracts/Account/IAccountApplication.cs +++ b/AccountManagement.Application.Contracts/Account/IAccountApplication.cs @@ -29,12 +29,12 @@ namespace AccountManagement.Application.Contracts.Account OperationResult DirectLogin(long id); #region Mahan - List AccountsForAssign(long accountId); List GetAccountsByPositionId(long positionId); List GetAccountLowerPositionvalue(); + OperationResult ReLogin(); - #endregion - } + #endregion + } } diff --git a/AccountManagement.Application.Contracts/Media/MediaViewModel.cs b/AccountManagement.Application.Contracts/Media/MediaViewModel.cs index 5eeebdf8..c79b38f3 100644 --- a/AccountManagement.Application.Contracts/Media/MediaViewModel.cs +++ b/AccountManagement.Application.Contracts/Media/MediaViewModel.cs @@ -5,4 +5,5 @@ public class MediaViewModel public long Id { get; set; } public string Path { get; set; } public string Type { get; set; } + public string Category { get; set; } } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Position/AddAccountToPositionPartialViewModel.cs b/AccountManagement.Application.Contracts/Position/AddAccountToPositionPartialViewModel.cs new file mode 100644 index 00000000..770af606 --- /dev/null +++ b/AccountManagement.Application.Contracts/Position/AddAccountToPositionPartialViewModel.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using AccountManagement.Application.Contracts.Account; + +namespace AccountManagement.Application.Contracts.Position; + +public class AddAccountToPositionPartialViewModel +{ + public List Accounts { get; set; } + public long PositionId { get; set; } +} \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Position/CreatePosition.cs b/AccountManagement.Application.Contracts/Position/CreatePosition.cs index 537557a2..527d836c 100644 --- a/AccountManagement.Application.Contracts/Position/CreatePosition.cs +++ b/AccountManagement.Application.Contracts/Position/CreatePosition.cs @@ -1,4 +1,4 @@ -namespace TaskManager.Application.Contract.Position; +namespace AccountManagement.Application.Contracts.Position; public class CreatePosition { diff --git a/AccountManagement.Application.Contracts/Position/CreatePositionModalViewModel.cs b/AccountManagement.Application.Contracts/Position/CreatePositionModalViewModel.cs new file mode 100644 index 00000000..3fcc6a1a --- /dev/null +++ b/AccountManagement.Application.Contracts/Position/CreatePositionModalViewModel.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace AccountManagement.Application.Contracts.Position; + +public class CreatePositionModalViewModel +{ + public int LastPositionValue { get; set; } + public List UnUsedPositionValue { get; set; } +} \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Position/EditPosition.cs b/AccountManagement.Application.Contracts/Position/EditPosition.cs index c9d498c8..70c513e3 100644 --- a/AccountManagement.Application.Contracts/Position/EditPosition.cs +++ b/AccountManagement.Application.Contracts/Position/EditPosition.cs @@ -1,4 +1,4 @@ -namespace TaskManager.Application.Contract.Position; +namespace AccountManagement.Application.Contracts.Position; public class EditPosition:CreatePosition { diff --git a/AccountManagement.Application.Contracts/Position/IPositionApplication.cs b/AccountManagement.Application.Contracts/Position/IPositionApplication.cs index a1e6b712..bad57871 100644 --- a/AccountManagement.Application.Contracts/Position/IPositionApplication.cs +++ b/AccountManagement.Application.Contracts/Position/IPositionApplication.cs @@ -2,14 +2,15 @@ using _0_Framework.Application; using AccountManagement.Application.Contracts.Account; -namespace TaskManager.Application.Contract.Position; +namespace AccountManagement.Application.Contracts.Position; public interface IPositionApplication { OperationResult Create(CreatePosition command); - OperationResult SaveAccountPosition(List command, long positionId); + OperationResult SaveAccountPosition(List accountIds, long positionId); List GetNoPositionAccounts(); - OperationResult Remove(long id); + List GetUnUsedPositionValues(); + OperationResult Remove(long id); OperationResult Edit(EditPosition command); List GetPositions(); OperationResult Save(); @@ -17,4 +18,5 @@ public interface IPositionApplication OperationResult RemoveAccountListFromPosition(List accountIdList, long PositionId); List GetLowerPosition(); int GetLastPositionValue(); + } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Position/PositionViewModel.cs b/AccountManagement.Application.Contracts/Position/PositionViewModel.cs index e5a37abd..d78f3d1a 100644 --- a/AccountManagement.Application.Contracts/Position/PositionViewModel.cs +++ b/AccountManagement.Application.Contracts/Position/PositionViewModel.cs @@ -1,6 +1,6 @@ -namespace TaskManager.Application.Contract.Position; +namespace AccountManagement.Application.Contracts.Position; public class PositionViewModel:EditPosition { - + public int CountUsers { get; set; } } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Task/CompleteTaskViewModel.cs b/AccountManagement.Application.Contracts/Task/CompleteTaskViewModel.cs index bb4d4bac..73389d6e 100644 --- a/AccountManagement.Application.Contracts/Task/CompleteTaskViewModel.cs +++ b/AccountManagement.Application.Contracts/Task/CompleteTaskViewModel.cs @@ -1,5 +1,4 @@ -#nullable enable -namespace AccountManagement.Application.Contracts.Task; +namespace AccountManagement.Application.Contracts.Task; public class CompleteTaskViewModel { diff --git a/AccountManagement.Application.Contracts/Task/CreateTask.cs b/AccountManagement.Application.Contracts/Task/CreateTask.cs index f0bed283..a88b849f 100644 --- a/AccountManagement.Application.Contracts/Task/CreateTask.cs +++ b/AccountManagement.Application.Contracts/Task/CreateTask.cs @@ -1,5 +1,4 @@ - -using System.Collections.Generic; +using System.Collections.Generic; using Microsoft.AspNetCore.Http; namespace AccountManagement.Application.Contracts.Task; diff --git a/AccountManagement.Application.Contracts/Task/EditTask.cs b/AccountManagement.Application.Contracts/Task/EditTask.cs index 2eada867..7974ddb9 100644 --- a/AccountManagement.Application.Contracts/Task/EditTask.cs +++ b/AccountManagement.Application.Contracts/Task/EditTask.cs @@ -6,4 +6,7 @@ public class EditTask:CreateTask { public long Id { get; set; } public List medias { get; set; } + public string? CompleteDescription { get; set; } + public bool IsDone { get; set; } + public List DeletedFileIds { get; set; } } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Task/EditTaskPartialViewModel.cs b/AccountManagement.Application.Contracts/Task/EditTaskPartialViewModel.cs new file mode 100644 index 00000000..da2338d7 --- /dev/null +++ b/AccountManagement.Application.Contracts/Task/EditTaskPartialViewModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using AccountManagement.Application.Contracts.Account; + +namespace AccountManagement.Application.Contracts.Task; + +public class EditTaskPartialViewModel +{ + public EditTask EditTask { get; set; } + public List AccountList { get; set; } + public long Id { get; set; } +} \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Task/ITaskApplication.cs b/AccountManagement.Application.Contracts/Task/ITaskApplication.cs index d3076a03..2b615c05 100644 --- a/AccountManagement.Application.Contracts/Task/ITaskApplication.cs +++ b/AccountManagement.Application.Contracts/Task/ITaskApplication.cs @@ -29,10 +29,16 @@ public interface ITaskApplication OperationResult AcceptCancelRequest(long taskId); OperationResult RejectCancelRequest(long taskId); - OperationResult CompleteTask(CompleteTaskViewModel command); + + OperationResult CreateCompleteTaskRequest(CompleteTaskViewModel command); + OperationResult AcceptCompleteRequest(long taskId); + OperationResult RejectCompleteRequest(long taskId); + OperationResult CreateTaskByPosition(CreateTask command, List positionIds); List GetAllRequestedTasks(TaskSearchModel searchModel); int GetRequestedTasksCount(); + OperationResult ChangeRequestTimeAndAccept(string time,long taskId); + TaskViewModel GetRequestDetails(long id); } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Task/OperationModalTaskRequest.cs b/AccountManagement.Application.Contracts/Task/OperationModalTaskRequest.cs new file mode 100644 index 00000000..dcbbb5b5 --- /dev/null +++ b/AccountManagement.Application.Contracts/Task/OperationModalTaskRequest.cs @@ -0,0 +1,9 @@ +namespace AccountManagement.Application.Contracts.Task; + +public class OperationModalTaskRequest +{ + public string Time { get; set; } + public string Description{ get; set; } + + +} \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Task/OperationModalViewModel.cs b/AccountManagement.Application.Contracts/Task/OperationModalViewModel.cs index 60bd79e1..c19be162 100644 --- a/AccountManagement.Application.Contracts/Task/OperationModalViewModel.cs +++ b/AccountManagement.Application.Contracts/Task/OperationModalViewModel.cs @@ -12,6 +12,8 @@ public class OperationModalViewModel public CreateTaskCancel CreateTaskCancel { get; set; } public CreateTaskTimeRequest CreateTaskTimeRequest { get; set; } public CompleteTaskViewModel CompleteTaskViewModel { get; set; } + public TaskViewModel ModalTaskRequest { get; set; } + public string Type { get; set; } } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Task/TaskSearchModel.cs b/AccountManagement.Application.Contracts/Task/TaskSearchModel.cs index c461658f..ba68ccbd 100644 --- a/AccountManagement.Application.Contracts/Task/TaskSearchModel.cs +++ b/AccountManagement.Application.Contracts/Task/TaskSearchModel.cs @@ -6,6 +6,7 @@ public class TaskSearchModel public string StartDate { get; set; } public string EndDate { get; set; } public long AccountId { get; set; } + public string IsDoneRequest { get; set; } public string IsDone { get; set; } public string IsCanceled { get; set; } public string IsCancelRequest { get; set; } @@ -13,4 +14,5 @@ public class TaskSearchModel public string TimeRequestAccepted { get; set; } public string TypeOfTicket { get; set; } + } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Task/TaskViewModel.cs b/AccountManagement.Application.Contracts/Task/TaskViewModel.cs index 696ff6ba..d1735009 100644 --- a/AccountManagement.Application.Contracts/Task/TaskViewModel.cs +++ b/AccountManagement.Application.Contracts/Task/TaskViewModel.cs @@ -17,13 +17,21 @@ public class TaskViewModel public string CreateDate { get; set; } public string EndTaskDateFA { get; set; } public string EndTaskTime { get; set; } + public string RequestTaskDate { get; set; } + public bool IsDone { get; set; } - public bool RequestCancel { get; set; } + public bool IsDoneRequest { get; set; } + public string IsDoneDescription { get; set; } + + public bool RequestCancel { get; set; } public bool RequestTime { get; set; } public bool IsCancel { get; set; } public bool IsCancelRequest { get; set; } + public string CancelDescription { get; set; } public int AcceptedTimeRequest { get; set; } - public DateTime EndTaskDateGE { get; set; } + public string TimeRequestDescription { get; set; } + + public DateTime EndTaskDateGE { get; set; } public DateTime CreateTaskDateGE { get; set; } public string ContractingPartyName { get; set; } public string? Description { get; set; } diff --git a/AccountManagement.Application.Contracts/TaskSubject/ITaskSubjectApplication.cs b/AccountManagement.Application.Contracts/TaskSubject/ITaskSubjectApplication.cs index c06c1f89..de3640a1 100644 --- a/AccountManagement.Application.Contracts/TaskSubject/ITaskSubjectApplication.cs +++ b/AccountManagement.Application.Contracts/TaskSubject/ITaskSubjectApplication.cs @@ -8,5 +8,5 @@ public interface ITaskSubjectApplication OperationResult Create(string subject); OperationResult Edit(TaskSubjectViewModel command); OperationResult Delete(long id); - List GetAll(); + List GetAll(string search); } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Ticket/AdminResponseViewModel.cs b/AccountManagement.Application.Contracts/Ticket/AdminResponseViewModel.cs new file mode 100644 index 00000000..bc15c709 --- /dev/null +++ b/AccountManagement.Application.Contracts/Ticket/AdminResponseViewModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using AccountManagement.Application.Contracts.Media; + +namespace AccountManagement.Application.Contracts.Ticket; + +public class AdminResponseViewModel +{ + public long TicketId { get; set; } + public string Response { get; set; } + public List MediaViewModels { get; set; } +} \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Ticket/AssignTicket.cs b/AccountManagement.Application.Contracts/Ticket/AssignTicket.cs new file mode 100644 index 00000000..5282e746 --- /dev/null +++ b/AccountManagement.Application.Contracts/Ticket/AssignTicket.cs @@ -0,0 +1,9 @@ + +using AccountManagement.Application.Contracts.Task; + +namespace AccountManagement.Application.Contracts.Ticket; + +public class AssignTicket : CreateTask +{ + public long TicketId { get; set; } +} \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Ticket/ClientResponseViewModel.cs b/AccountManagement.Application.Contracts/Ticket/ClientResponseViewModel.cs new file mode 100644 index 00000000..220956eb --- /dev/null +++ b/AccountManagement.Application.Contracts/Ticket/ClientResponseViewModel.cs @@ -0,0 +1,6 @@ +namespace AccountManagement.Application.Contracts.Ticket; + +public class ClientResponseViewModel : AdminResponseViewModel +{ + +} \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Ticket/CreateTicket.cs b/AccountManagement.Application.Contracts/Ticket/CreateTicket.cs new file mode 100644 index 00000000..0182e371 --- /dev/null +++ b/AccountManagement.Application.Contracts/Ticket/CreateTicket.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using Microsoft.AspNetCore.Http; + +namespace AccountManagement.Application.Contracts.Ticket; + +public class CreateTicket +{ + public string Title { get; set; } + public string Description { get; set; } + public long SenderId { get; set; } + public string ContractingPartyName { get; set; } + public string TicketType { get; set; } + public IFormFile Document1 { get; set; } + public IFormFile Document2 { get; set; } + public IFormFile Document3 { get; set; } + public IFormFile Document4 { get; set; } + public IFormFile Document5 { get; set; } + public IFormFile ScreenShot { get; set; } + public IFormFile Voice { get; set; } +} \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Ticket/EditTicket.cs b/AccountManagement.Application.Contracts/Ticket/EditTicket.cs new file mode 100644 index 00000000..5509fd95 --- /dev/null +++ b/AccountManagement.Application.Contracts/Ticket/EditTicket.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using AccountManagement.Application.Contracts.Media; + +namespace AccountManagement.Application.Contracts.Ticket; + +public class EditTicket:CreateTicket +{ + public long Id { get; set; } + public List MediaViewModels { get; set; } +} \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Ticket/ITicketApplication.cs b/AccountManagement.Application.Contracts/Ticket/ITicketApplication.cs new file mode 100644 index 00000000..b4095f5a --- /dev/null +++ b/AccountManagement.Application.Contracts/Ticket/ITicketApplication.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using _0_Framework.Application; +using AccountManagement.Application.Contracts.Task; + +namespace AccountManagement.Application.Contracts.Ticket; + +public interface ITicketApplication +{ + OperationResult CreateTicket(CreateTicket command); + OperationResult AssignTicket(CreateTask command, long ticketId); + OperationResult CompleteTicket(long id); + OperationResult AdminResponseTicket(ResponseTicket command); + OperationResult ClientResponseTicket(ResponseTicket command); + EditTicket GetDetails(long id); + List GetAll(TicketSearchModel searchModel); + bool IsExist(long id); +} \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Ticket/ResponseTicket.cs b/AccountManagement.Application.Contracts/Ticket/ResponseTicket.cs new file mode 100644 index 00000000..9843cf83 --- /dev/null +++ b/AccountManagement.Application.Contracts/Ticket/ResponseTicket.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; +using Microsoft.AspNetCore.Http; + +namespace AccountManagement.Application.Contracts.Ticket; +public class ResponseTicket +{ + public long TicketId { get; set; } + public string Response { get; set; } + public IFormFile Document1 { get; set; } + public IFormFile Document2 { get; set; } + public IFormFile Document3 { get; set; } + public IFormFile Document4 { get; set; } + public IFormFile Document5 { get; set; } + public IFormFile Document6 { get; set; } + public IFormFile Voice { get; set; } +} \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Ticket/TicketSearchModel.cs b/AccountManagement.Application.Contracts/Ticket/TicketSearchModel.cs new file mode 100644 index 00000000..074e9689 --- /dev/null +++ b/AccountManagement.Application.Contracts/Ticket/TicketSearchModel.cs @@ -0,0 +1,21 @@ +namespace AccountManagement.Application.Contracts.Ticket; + +public class TicketSearchModel +{ + public string StartDate { get; set; } + + public string EndDate { get; set; } + + public string ContractingPartyName { get; set; } + + public string OneDay { get; set; } + + public string IsAssigned { get; set; } + + public string TypeOfTicket { get; set; } + + public string Title { get; set; } + + public string Status { get; set; } + +} \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Ticket/TicketViewModel.cs b/AccountManagement.Application.Contracts/Ticket/TicketViewModel.cs new file mode 100644 index 00000000..123a2681 --- /dev/null +++ b/AccountManagement.Application.Contracts/Ticket/TicketViewModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +namespace AccountManagement.Application.Contracts.Ticket; + +public class TicketViewModel:EditTicket +{ + public List AdminResponseViewModels { get; set; } + public List ClientResponseViewModels { get; set; } + public string Status { get; set; } + public string CreationDateTime { get; set; } + public DateTime CreationDateTimeGr { get; set; } + public long? TaskId { get; set; } + +} \ No newline at end of file diff --git a/AccountManagement.Application/AccountApplication.cs b/AccountManagement.Application/AccountApplication.cs index e7afef34..c178b633 100644 --- a/AccountManagement.Application/AccountApplication.cs +++ b/AccountManagement.Application/AccountApplication.cs @@ -422,4 +422,28 @@ public class AccountApplication : IAccountApplication { return _accountRepository.GetAccountLowerPositionvalue(); } + + public OperationResult ReLogin() + { + var prAcc = _authHelper.CurrentAccountInfo(); + var operation = new OperationResult(); + var account = _accountRepository.GetIncludePositions(prAcc.Id); + if (account == null) + return operation.Failed("این اکانت وجود ندارد"); + + + + var permissions = _roleRepository.Get(account.RoleId) + .Permissions + .Select(x => x.Code) + .ToList(); + + + _authHelper.SignOut(); + var authViewModel = new AuthViewModel(account.id, account.RoleId, account.Fullname + , account.Username, account.Mobile, account.ProfilePhoto, permissions, account.RoleName, account.AdminAreaPermission, account.ClientAriaPermission, account.Position.PositionValue); + _authHelper.Signin(authViewModel); + return operation.Succcedded(2); + + } } \ No newline at end of file diff --git a/AccountManagement.Application/PositionApplication.cs b/AccountManagement.Application/PositionApplication.cs index 88558d8a..decf6050 100644 --- a/AccountManagement.Application/PositionApplication.cs +++ b/AccountManagement.Application/PositionApplication.cs @@ -1,9 +1,8 @@ using System.Collections.Generic; using _0_Framework.Application; using AccountManagement.Application.Contracts.Account; +using AccountManagement.Application.Contracts.Position; using AccountManagement.Domain.AccountAgg; - -using TaskManager.Application.Contract.Position; using TaskManager.Domain.PositionAgg; namespace TaskManager.Application; @@ -52,7 +51,7 @@ public class PositionApplication:IPositionApplication return operation.Succcedded(position.id); } //ذخیره لیست پرسنل برای سمت خود - public OperationResult SaveAccountPosition(List command, long positionId) + public OperationResult SaveAccountPosition(List accountIds, long positionId) { var operation = new OperationResult(); if (!_positionRepository.Exists(x=>x.id==positionId)) @@ -60,14 +59,14 @@ public class PositionApplication:IPositionApplication return operation.Failed("چنین سمتی وجود ندارد"); } - if (command.Count<1) + if (accountIds.Count<1) { return operation.Failed("لطفا شخصی برای ذخیره انتخاب کنید"); } - foreach (var accountViewModel in command) + foreach (var id in accountIds) { - var account = _accountRepository.Get(accountViewModel.Id); + var account = _accountRepository.Get(id); account.SetPosition(positionId); } _accountRepository.SaveChanges(); @@ -79,6 +78,11 @@ public class PositionApplication:IPositionApplication return _positionRepository.GetNoPositionAccounts(); } + public List GetUnUsedPositionValues() + { + return _positionRepository.GetUnUsedPositionValues(); + } + public OperationResult Remove(long id) { var operation = new OperationResult(); diff --git a/AccountManagement.Application/TaskApplication.cs b/AccountManagement.Application/TaskApplication.cs index 20c8391b..c8dc7243 100644 --- a/AccountManagement.Application/TaskApplication.cs +++ b/AccountManagement.Application/TaskApplication.cs @@ -16,983 +16,1065 @@ using System.Reflection; namespace AccountManagement.Application; - public class TaskApplication : ITaskApplication { - private readonly ITaskRepository _taskRepository; - private readonly IAccountRepository _accountRepository; - private readonly IMediaRepository _mediaRepository; - private readonly IPositionRepository _positionRepository; - private readonly IAssignRepository _assignRepository; - private readonly IHttpContextAccessor _contextAccessor; - - - public TaskApplication(ITaskRepository taskRepository, IAccountRepository accountRepository, IMediaRepository mediaRepository, IAssignRepository assignRepository, IHttpContextAccessor contextAccessor, IPositionRepository positionRepository) - { - _taskRepository = taskRepository; - _accountRepository = accountRepository; - _mediaRepository = mediaRepository; - _assignRepository = assignRepository; - _contextAccessor = contextAccessor; - _positionRepository = positionRepository; - } - //غیرفعال سازی تسک - public OperationResult DeActiveTask(long TaskId) - { - var operation = new OperationResult(); - if (!_taskRepository.Exists(x => x.id == TaskId)) - { - return operation.Failed("چنین وظیفه ای برای حذف وجود ندارد!"); - } - - var task = _taskRepository.Get(TaskId); - task.DeActive(); - _taskRepository.SaveChanges(); - return operation.Succcedded(task.id); - - } - //حذف کامل تسک - public OperationResult RemoveTask(long TaskId) - { - var operation = new OperationResult(); - if (!_taskRepository.Exists(x => x.id == TaskId)) - { - return operation.Failed("چنین وظیفه ای برای حذف وجود ندارد!"); - } - - var task = _taskRepository.Get(TaskId); - var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); - var sender = _accountRepository.GetIncludePositions(task.SenderId); - if (sender.Position.PositionValue < positionValue) - { - return operation.Failed("شما نمیتواند وظیفه ای که سطحی از شما پایین تر دارد را حذف کنید"); - } - var medias = _mediaRepository.GetMediaByTaskId(TaskId); - if (task.IsCanceledRequest || task.IsDone || task.IsCancel || task.TimeRequest || task.AcceptedTimeRequest > 0) - { - task.DeActive(); - } - else - { - foreach (var item in medias) - { - RemoveFile(item.Id); - } - _taskRepository.Remove(task.id); - - } - - _taskRepository.SaveChanges(); - return operation.Succcedded(); - } - //حذف فایلی در تسک - public OperationResult RemoveFile(long MediaId) - { - var operation = new OperationResult(); - if (!_mediaRepository.Exists(x => x.id == MediaId)) - { - operation.Failed("چنین فایلی وجود ندارد"); - } - var media = _mediaRepository.Get(MediaId); - File.Delete(media.Path); - _mediaRepository.Remove(media.id); - _mediaRepository.SaveChanges(); - return operation.Succcedded(); - } - //ویرایش تسک - public OperationResult Edit(EditTask command) - { - var posValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); - var operation = new OperationResult(); - if (string.IsNullOrEmpty(command.Title)) - { - return operation.Failed("لطفا عنوان وظیفه خود ار وارد کنید"); - } - - if (string.IsNullOrEmpty(command.EndTaskDate)) - { - return operation.Failed("لطفا تاریخ انجام وظیفه را وارد کنید"); - } - - if (command.ReceiverId.Count < 1) - { - return operation.Failed("طرف وظیفه خود را وارد کنید"); - } - - if (command.SenderId < 1) - { - return operation.Failed("خطای سیستمی!!!"); - } - - var sender = _accountRepository.GetIncludePositions(command.SenderId); - if (sender.Position.PositionValue < posValue) - { - return operation.Failed("شما حق ویرایش این وظیفه را ندارید"); - } - var task = _taskRepository.Get(command.Id); - var endTask = command.EndTaskDate.ToGeorgianDateTime(); - task.Edit(command.Title, endTask, command.Description, command.SenderId); - - - #region ChangeMedias - - #region SaveDocuments - - if ((command.Document1?.Length > 2000000) || (command.Document2?.Length > 2000000) || (command.Document3?.Length > 2000000)) - return operation.Failed("حجم فایل نمیتواند از 2 مگابایت بیشتر باشد"); - - if (command.Document1?.Length > 0) - { - var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - string filepath = Path.Combine(path, command.Document1.FileName); - - using (var stream = new FileStream(filepath, FileMode.Create)) - { - command.Document1.CopyTo(stream); - - } - - - if (!_mediaRepository.Exists(x => x.Path == filepath)) - { - var type = Path.GetExtension(filepath); - var media = new Media(filepath, type, "فایل"); - _mediaRepository.Create(media); - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - } - } - if (command.Document2?.Length > 0) - { - var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - string filepath = Path.Combine(path, command.Document2.FileName); - - using (var stream = new FileStream(filepath, FileMode.Create)) - { - command.Document2.CopyTo(stream); - - } - - - if (!_mediaRepository.Exists(x => x.Path == filepath)) - { - var type = Path.GetExtension(filepath); - var media = new Media(filepath, type, "فایل"); - _mediaRepository.Create(media); - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - } - } - if (command.Document3?.Length > 0) - { - var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - string filepath = Path.Combine(path, command.Document3.FileName); - - using (var stream = new FileStream(filepath, FileMode.Create)) - { - command.Document3.CopyTo(stream); - - } - - - if (!_mediaRepository.Exists(x => x.Path == filepath)) - { - var type = Path.GetExtension(filepath); - var media = new Media(filepath, type, "فایل"); - _mediaRepository.Create(media); - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - } - } - if (command.Document4?.Length > 0) - { - var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); + private readonly ITaskRepository _taskRepository; + private readonly IAccountRepository _accountRepository; + private readonly IMediaRepository _mediaRepository; + private readonly IPositionRepository _positionRepository; + private readonly IAssignRepository _assignRepository; + private readonly IHttpContextAccessor _contextAccessor; + + + public TaskApplication(ITaskRepository taskRepository, IAccountRepository accountRepository, IMediaRepository mediaRepository, IAssignRepository assignRepository, IHttpContextAccessor contextAccessor, IPositionRepository positionRepository) + { + _taskRepository = taskRepository; + _accountRepository = accountRepository; + _mediaRepository = mediaRepository; + _assignRepository = assignRepository; + _contextAccessor = contextAccessor; + _positionRepository = positionRepository; + } + //غیرفعال سازی تسک + public OperationResult DeActiveTask(long TaskId) + { + var operation = new OperationResult(); + if (!_taskRepository.Exists(x => x.id == TaskId)) + { + return operation.Failed("چنین وظیفه ای برای حذف وجود ندارد!"); + } + + var task = _taskRepository.Get(TaskId); + task.DeActive(); + _taskRepository.SaveChanges(); + return operation.Succcedded(task.id); + + } + //حذف کامل تسک + public OperationResult RemoveTask(long TaskId) + { + var operation = new OperationResult(); + if (!_taskRepository.Exists(x => x.id == TaskId)) + { + return operation.Failed("چنین وظیفه ای برای حذف وجود ندارد!"); + } + + var task = _taskRepository.Get(TaskId); + var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); + var sender = _accountRepository.GetIncludePositions(task.SenderId); + if (sender.Position.PositionValue < positionValue) + { + return operation.Failed("شما نمیتواند وظیفه ای که سطحی از شما پایین تر دارد را حذف کنید"); + } + var medias = _mediaRepository.GetMediaByTaskId(TaskId); + if (task.IsCanceledRequest || task.IsDone || task.IsCancel || task.TimeRequest || task.AcceptedTimeRequest > 0) + { + task.DeActive(); + } + else + { + foreach (var item in medias) + { + RemoveFile(item.Id); + } + _taskRepository.Remove(task.id); + + } + + _taskRepository.SaveChanges(); + return operation.Succcedded(); + } + //حذف فایلی در تسک + public OperationResult RemoveFile(long MediaId) + { + var operation = new OperationResult(); + if (!_mediaRepository.Exists(x => x.id == MediaId)) + { + operation.Failed("چنین فایلی وجود ندارد"); + } + var media = _mediaRepository.Get(MediaId); + File.Delete(media.Path); + _mediaRepository.Remove(media.id); + _mediaRepository.SaveChanges(); + return operation.Succcedded(); + } + //ویرایش تسک + public OperationResult Edit(EditTask command) + { + var posValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); + var operation = new OperationResult(); + if (string.IsNullOrEmpty(command.Title)) + { + return operation.Failed("لطفا عنوان وظیفه خود ار وارد کنید"); + } + + if (string.IsNullOrEmpty(command.EndTaskDate)) + { + return operation.Failed("لطفا تاریخ انجام وظیفه را وارد کنید"); + } + + if (command.ReceiverId.Count < 1) + { + return operation.Failed("طرف وظیفه خود را وارد کنید"); + } + + if (command.SenderId < 1) + { + return operation.Failed("خطای سیستمی!!!"); + } + + var sender = _accountRepository.GetIncludePositions(command.SenderId); + if (sender.Position.PositionValue < posValue) + { + return operation.Failed("شما حق ویرایش این وظیفه را ندارید"); + } + var task = _taskRepository.Get(command.Id); + var endTask = command.EndTaskDate.ToGeorgianDateTime(); + task.Edit(command.Title, endTask, command.Description, command.SenderId, command.ContractingPartyName); + _taskRepository.SaveChanges(); + + + #region ChangeMedias + + #region DeleteMedias + + if (command.DeletedFileIds?.Count > 0) + { + foreach (var mediaId in command.DeletedFileIds) + { + var media = _mediaRepository.Get(mediaId); + _mediaRepository.Remove(media.id); + File.Delete(media.Path); + } + } + + _mediaRepository.SaveChanges(); + + #endregion + + + + + #region SaveDocuments + + if ((command.Document1?.Length > 2000000) || (command.Document2?.Length > 2000000) || (command.Document3?.Length > 2000000)) + return operation.Failed("حجم فایل نمیتواند از 2 مگابایت بیشتر باشد"); + + if (command.Document1?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); - string filepath = Path.Combine(path, command.Document4.FileName); + string filepath = Path.Combine(path, command.Document1.FileName); - using (var stream = new FileStream(filepath, FileMode.Create)) - { - command.Document4.CopyTo(stream); + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document1.CopyTo(stream); - } + } - if (!_mediaRepository.Exists(x => x.Path == filepath)) - { - var type = Path.GetExtension(filepath); - var media = new Media(filepath, type, "فایل"); - _mediaRepository.Create(media); - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - } - } - if (command.Document5?.Length > 0) - { - var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - string filepath = Path.Combine(path, command.Document5.FileName); - - using (var stream = new FileStream(filepath, FileMode.Create)) - { - command.Document5.CopyTo(stream); - - } - - - if (!_mediaRepository.Exists(x => x.Path == filepath)) - { - var type = Path.GetExtension(filepath); - var media = new Media(filepath, type, "فایل"); - _mediaRepository.Create(media); - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - } - } - if (command.Document6?.Length > 0) - { - var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - string filepath = Path.Combine(path, command.Document6.FileName); - - using (var stream = new FileStream(filepath, FileMode.Create)) - { - command.Document6.CopyTo(stream); - - } - - - if (!_mediaRepository.Exists(x => x.Path == filepath)) - { - var type = Path.GetExtension(filepath); - var media = new Media(filepath, type, "فایل"); - _mediaRepository.Create(media); - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - } - } - - - - - - - #endregion - - - - if (command.Voice?.Length > 0) - { - var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - string filepath = Path.Combine(path, command.Voice.FileName); - using (var stream = new FileStream(filepath, FileMode.Create)) - { - command.Voice.CopyTo(stream); - } - - if (!_mediaRepository.Exists(x => x.Path == filepath)) - { - var type = Path.GetExtension(filepath); - var media = new Media(filepath, type, "صوت"); - _mediaRepository.Create(media); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - } - - } - - - #endregion - - - _taskRepository.SaveChanges(); - return operation.Succcedded(); - } - //ساخت یک ارجاع دهنده - public OperationResult CreateAssign(CreateAssign command) - { - var posValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); - var operation = new OperationResult(); - if (!_taskRepository.Exists(x => x.id == command.TaskId)) - { - return operation.Failed("چنین وظیفه ای وجود ندارد"); - } - if (!_accountRepository.Exists(x => x.id == command.AssignerId)) - { - return operation.Failed("خطای سیستمی!!"); - } - - foreach (var assignedId in command.AssignedId) - { - if (!_accountRepository.Exists(x => x.id == assignedId)) - { - return operation.Failed("چنین شخصی برای ارجاع وجود ندارد."); - } - } + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - var assigner = _accountRepository.GetIncludePositions(command.AssignerId); - foreach (var assignedId in command.AssignedId) - { - var assigned = _accountRepository.GetIncludePositions(assignedId); - - var assign = new Assign(command.TaskId, command.AssignerId, assignedId, assigner.Position.PositionValue, - assigned.Fullname, assigned.Position.PositionValue); - _assignRepository.Create(assign); - } - _assignRepository.SaveChanges(); - return operation.Succcedded(); - } - //ساخت تسک - public OperationResult CreateTask(CreateTask command) - { - var operation = new OperationResult(); - if (string.IsNullOrEmpty(command.Title)) - { - return operation.Failed("لطفا عنوان وظیفه خود ار وارد کنید"); - } - - if (string.IsNullOrEmpty(command.EndTaskDate)) - { - return operation.Failed("لطفا تاریخ انجام وظیفه را وارد کنید"); - } + } + if (command.Document2?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + string filepath = Path.Combine(path, command.Document2.FileName); + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document2.CopyTo(stream); - if (string.IsNullOrEmpty(command.ContractingPartyName)) - { - return operation.Failed("لطفا طرف حساب خودرا وارد کنید"); - } - + } - if (command.SenderId < 1) - { - return operation.Failed("خطای سیستمی!!!"); - } - var sender = _accountRepository.GetIncludePositions(command.SenderId); - - if (command.PositionId?.Count > 0 && command.ReceiverId?.Count > 0) - { - if (command.PositionId.Any(x => x > 0)) - { - return operation.Failed("شما نمیتوانید همرمان به صورت انفرادی و هم به صورت گروهی تسک دهید. "); - } - } - else if (command.PositionId?.Count > 0) - { - var res = CreateTaskByPosition(command); - return res; - } - if (command.ReceiverId.Count < 1) - { - return operation.Failed("طرف وظیفه خود را وارد کنید"); - } - - var receivers = _accountRepository.GetAccountsByIds(command.ReceiverId); - - if (sender.Position.PositionValue == 1) - { - - } - else if (receivers.Any(x => sender.Position.PositionValue > x.Position.PositionValue)) - { - return operation.Failed("شما نمیتوانید به سطح بالاتر خود وظیفه ای دهید"); - } - else if (receivers.Count == 1 && receivers.Any(x => sender.id == x.id)) - { - - } - else if (receivers.Any(x => sender.Position.PositionValue == x.Position.PositionValue)) - { - return operation.Failed("شما نمیتوانید به هم سطح خود وظیفه ای دهید"); - } - - - DateTime endTask; - endTask = string.IsNullOrWhiteSpace(command.EndTaskTime) ? command.EndTaskDate.ToGeorgianDateTime2() : command.EndTaskDate.ToGeorgianDateWithTime(command.EndTaskTime); - - - - var task = new Tasks(command.Title, endTask, command.Description, command.SenderId, command.ContractingPartyName); - _taskRepository.Create(task); - _assignRepository.SaveChanges(); - foreach (var receiver in receivers) - { - var assign = new Assign(task.id, task.SenderId, receiver.id, sender.Position.PositionValue, receiver.Fullname, - receiver.Position.PositionValue); - _assignRepository.Create(assign); - } - - - - #region SaveMedias - - #region SaveDocuments - - if ((command.Document1?.Length > 2000000) || (command.Document2?.Length > 2000000) || (command.Document3?.Length > 2000000)) - return operation.Failed("حجم فایل نمیتواند از 2 مگابایت بیشتر باشد"); - - if (command.Document1?.Length > 0) - { - var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - string filepath = Path.Combine(path, command.Document1.FileName); - - using (var stream = new FileStream(filepath, FileMode.Create)) - { - command.Document1.CopyTo(stream); - - } - - var type = Path.GetExtension(filepath); - var media = new Media(filepath, type, "فایل"); - _mediaRepository.Create(media); - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - } - if (command.Document2?.Length > 0) - { - var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - string filepath = Path.Combine(path, command.Document2.FileName); - - using (var stream = new FileStream(filepath, FileMode.Create)) - { - command.Document2.CopyTo(stream); - - } - - var type = Path.GetExtension(filepath); - var media = new Media(filepath, type, "فایل"); - _mediaRepository.Create(media); - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - } - if (command.Document3?.Length > 0) - { - var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - string filepath = Path.Combine(path, command.Document3.FileName); - using (var stream = new FileStream(filepath, FileMode.Create)) - { - command.Document3.CopyTo(stream); + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - } + } + if (command.Document3?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); - var type = Path.GetExtension(filepath); - var media = new Media(filepath, type, "فایل"); - _mediaRepository.Create(media); - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - } - if (command.Document4?.Length > 0) - { - var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); + string filepath = Path.Combine(path, command.Document3.FileName); - string filepath = Path.Combine(path, command.Document4.FileName); + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document3.CopyTo(stream); - using (var stream = new FileStream(filepath, FileMode.Create)) - { - command.Document4.CopyTo(stream); + } - } - var type = Path.GetExtension(filepath); - var media = new Media(filepath, type, "فایل"); - _mediaRepository.Create(media); - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - } - if (command.Document5?.Length > 0) - { - var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - string filepath = Path.Combine(path, command.Document5.FileName); - - using (var stream = new FileStream(filepath, FileMode.Create)) - { - command.Document5.CopyTo(stream); - - } - - var type = Path.GetExtension(filepath); - var media = new Media(filepath, type, "فایل"); - _mediaRepository.Create(media); - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - } - if (command.Document6?.Length > 0) - { - var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - string filepath = Path.Combine(path, command.Document6.FileName); - - using (var stream = new FileStream(filepath, FileMode.Create)) - { - command.Document6.CopyTo(stream); - - } - - var type = Path.GetExtension(filepath); - var media = new Media(filepath, type, "فایل"); - _mediaRepository.Create(media); - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - } + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + } + if (command.Document4?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); - #endregion + string filepath = Path.Combine(path, command.Document4.FileName); + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document4.CopyTo(stream); + } - if (command.Voice?.Length > 0) - { - var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - string filepath = Path.Combine(path, command.Voice.FileName); - using (var stream = new FileStream(filepath, FileMode.Create)) - { - command.Voice.CopyTo(stream); - } - var type = Path.GetExtension(filepath); - var media = new Media(filepath, type, "صوت"); - _mediaRepository.Create(media); - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - } + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + } + if (command.Document5?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); - #endregion - _taskRepository.SaveChanges(); - return operation.Succcedded(task.id); - } - - public OperationResult CreateTaskByPosition(CreateTask command) - { - var operation = new OperationResult(); - var sender = _accountRepository.GetIncludePositions(command.SenderId); - - var receivers = _positionRepository.GetAccountsByIds(command.PositionId); - - - if (sender.Position.PositionValue == 1) - { - - } - else if (receivers.Any(x => sender.Position.PositionValue > x.Position.PositionValue)) - { - return operation.Failed("شما نمیتوانید به سطح بالاتر خود وظیفه ای دهید"); - } - else if (receivers.Count == 1 && receivers.Any(x => sender.id == x.id)) - { - - } - else if (receivers.Any(x => sender.Position.PositionValue == x.Position.PositionValue)) - { - return operation.Failed("شما نمیتوانید به هم سطح خود وظیفه ای دهید"); - } - - - DateTime endTask; - if (string.IsNullOrWhiteSpace(command.EndTaskTime)) - { - endTask = command.EndTaskDate.ToGeorgianDateTime2(); - } - else - { - endTask = command.EndTaskDate.ToGeorgianDateWithTime(command.EndTaskTime); - } - - - - var task = new Tasks(command.Title, endTask, command.Description, command.SenderId, command.ContractingPartyName); - _taskRepository.Create(task); - _assignRepository.SaveChanges(); - foreach (var receiver in receivers) - { - var assign = new Assign(task.id, task.SenderId, receiver.id, sender.Position.PositionValue, receiver.Fullname, - receiver.Position.PositionValue); - _assignRepository.Create(assign); - } + string filepath = Path.Combine(path, command.Document5.FileName); + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document5.CopyTo(stream); + } - #region SaveMedias - #region SaveDocuments - if ((command.Document1?.Length > 2000000) || (command.Document2?.Length > 2000000) || (command.Document3?.Length > 2000000)) - return operation.Failed("حجم فایل نمیتواند از 2 مگابایت بیشتر باشد"); - - if (command.Document1?.Length > 0) - { - var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - string filepath = Path.Combine(path, command.Document1.FileName); - - using (var stream = new FileStream(filepath, FileMode.Create)) - { - command.Document1.CopyTo(stream); - - } - - var type = Path.GetExtension(filepath); - var media = new Media(filepath, type, "فایل"); - _mediaRepository.Create(media); - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - } - if (command.Document2?.Length > 0) - { - var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - string filepath = Path.Combine(path, command.Document2.FileName); + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - using (var stream = new FileStream(filepath, FileMode.Create)) - { - command.Document2.CopyTo(stream); + } + if (command.Document6?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); - } + string filepath = Path.Combine(path, command.Document6.FileName); - var type = Path.GetExtension(filepath); - var media = new Media(filepath, type, "فایل"); - _mediaRepository.Create(media); - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - } - if (command.Document3?.Length > 0) - { - var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - string filepath = Path.Combine(path, command.Document3.FileName); + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document6.CopyTo(stream); - using (var stream = new FileStream(filepath, FileMode.Create)) - { - command.Document3.CopyTo(stream); - - } - - var type = Path.GetExtension(filepath); - var media = new Media(filepath, type, "فایل"); - _mediaRepository.Create(media); - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - } - if (command.Document4?.Length > 0) - { - var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - string filepath = Path.Combine(path, command.Document4.FileName); - - using (var stream = new FileStream(filepath, FileMode.Create)) - { - command.Document4.CopyTo(stream); - - } - - var type = Path.GetExtension(filepath); - var media = new Media(filepath, type, "فایل"); - _mediaRepository.Create(media); - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - } - if (command.Document5?.Length > 0) - { - var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - string filepath = Path.Combine(path, command.Document5.FileName); - - using (var stream = new FileStream(filepath, FileMode.Create)) - { - command.Document5.CopyTo(stream); - - } - - var type = Path.GetExtension(filepath); - var media = new Media(filepath, type, "فایل"); - _mediaRepository.Create(media); - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - } - if (command.Document6?.Length > 0) - { - var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - string filepath = Path.Combine(path, command.Document6.FileName); - - using (var stream = new FileStream(filepath, FileMode.Create)) - { - command.Document6.CopyTo(stream); - - } - - var type = Path.GetExtension(filepath); - var media = new Media(filepath, type, "فایل"); - _mediaRepository.Create(media); - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - } - - - - #endregion - - - - if (command.Voice?.Length > 0) - { - var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - string filepath = Path.Combine(path, command.Voice.FileName); - using (var stream = new FileStream(filepath, FileMode.Create)) - { - command.Voice.CopyTo(stream); - } - var type = Path.GetExtension(filepath); - var media = new Media(filepath, type, "صوت"); - _mediaRepository.Create(media); - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - - } - - - - #endregion - _taskRepository.SaveChanges(); - return operation.Succcedded(task.id); - } - - // ویرایش تسک - public EditTask GetDetails(long taskId) - { - return _taskRepository.GetDetails(taskId); - } - - //لیست کامل تسک ها - public List GetTasks(TaskSearchModel searchModel) - { - var test = _taskRepository.GetTasks(searchModel); - - return test; - } - //ساخت درخواست مهلت - public OperationResult CreateRequestTime(CreateTaskTimeRequest command) - { - var operation = new OperationResult(); - if (command.TaskId == 0) - { - return operation.Failed("چنین وظیفه ای وجود ندارد"); - } - - if (string.IsNullOrWhiteSpace(command.Description)) - { - return operation.Failed("توضیحات خود را وارد کنید"); - } - - if (string.IsNullOrWhiteSpace(command.RequestTime)) - { - return operation.Failed("مهلت درخواستی خود را وارد کنید"); - } - - var task = _taskRepository.Get(command.TaskId); - var requestTime = command.RequestTime.ToGeorgianDateTime(); - task.CreateTimeRequest(requestTime, command.Description); - _taskRepository.SaveChanges(); - return operation.Succcedded(task.id); - } - //تایید درخواست مهلت - public OperationResult AcceptRequestDatetime(long taskId) - { - var operation = new OperationResult(); - if (!_taskRepository.Exists(x => x.id == taskId)) - { - return operation.Failed("چنین وظیفه ای وجود ندارد"); - } - - var task = _taskRepository.Get(taskId); - if (!task.TimeRequest) - { - return operation.Failed("چنین وظیفه ای درخواستی برای مهلت ندارد"); - } - - if (task.RequestDate == null) - { - return operation.Failed("تاریخی برای درخواست وظیفه ثبت نشده است"); - } - task.AcceptTimeRequest(); - _taskRepository.SaveChanges(); - return operation.Succcedded(task.id); - } - //ساخت درخواست کنسل - public OperationResult CreateCancelRequest(CreateTaskCancel command) - { - var operation = new OperationResult(); - if (string.IsNullOrWhiteSpace(command.Description)) - { - return operation.Failed("توضیحات خود را وارد کنید"); - } - - if (!_taskRepository.Exists(x => x.id == command.TaskId)) - { - return operation.Failed("چنین وظیفه ای وجود ندارد"); - } - var task = _taskRepository.Get(command.TaskId); - task.CreateCancelRequest(command.Description); - _taskRepository.SaveChanges(); - return operation.Succcedded(task.id); - } - //تایید درخواست کنسل - public OperationResult AcceptCancelRequest(long taskId) - { - var operation = new OperationResult(); - if (!_taskRepository.Exists(x => x.id == taskId)) - { - return operation.Failed("چنین وظیفه ای وجود ندارد"); - } - var task = _taskRepository.Get(taskId); - if (!task.IsCanceledRequest) - { - return operation.Failed("چنین وظیفه ای درخواستی برای انصراف ندارد"); - } - task.AcceptCancelRequest(); - _taskRepository.SaveChanges(); - return operation.Succcedded(taskId); - } - //انجام شدن تسک - public OperationResult CompleteTask(CompleteTaskViewModel command) - { - var operation = new OperationResult(); - if (!_taskRepository.Exists(x => x.id == command.Id)) - { - return operation.Failed("چنین وظیفه ای وجود ندارد"); - } - var task = _taskRepository.Get(command.Id); - task.Completed(command.Description); - _taskRepository.SaveChanges(); - return operation.Succcedded(task.id); - } - //لغو درخواست کنسل تسک - public OperationResult RejectCancelRequest(long taskId) - { - var operation = new OperationResult(); - if (!_taskRepository.Exists(x => x.id == taskId)) - { - return operation.Failed("چنین وظیفه ای وجود ندارد"); - } - var task = _taskRepository.Get(taskId); - if (!task.IsCanceledRequest) - { - return operation.Failed("چنین وظیفه ای درخواستی برای انصراف ندارد"); - } - task.RejectCancel(); - _taskRepository.SaveChanges(); - return operation.Succcedded(taskId); - } - //لغو درخواست مهلت تسک - public OperationResult RejectTimeRequest(long taskId) - { - var operation = new OperationResult(); - if (!_taskRepository.Exists(x => x.id == taskId)) - { - return operation.Failed("چنین وظیفه ای وجود ندارد"); - } - - var task = _taskRepository.Get(taskId); - if (!task.TimeRequest) - { - return operation.Failed("چنین وظیفه ای درخواستی برای مهلت ندارد"); - } - task.RejectTimeRequest(); - _taskRepository.SaveChanges(); - return operation.Succcedded(task.id); - } - - public OperationResult CreateTaskByPosition(CreateTask command, List positionIds) - { - var operation = new OperationResult(); - var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); - var positions = new List(); - foreach (var positionId in positionIds) - { - var position = _positionRepository.Get(positionId); - positions.Add(position); - } - - - if (positions.Any(x => x.PositionValue <= positionValue)) - { - return operation.Failed("شما نمیتوانید به گروه هم سطح یا سطح بالاتر خود تسکی دهد"); - } - - var receiverIds = new List(); - foreach (var positionId in positionIds) - { - var acc = _accountRepository.GetAccountsByPositionId(positionId).Select(x => x.Id).ToList(); - receiverIds.AddRange(acc); - } - - command.ReceiverId = receiverIds; - operation = CreateTask(command); - return operation; - } - - public List GetAllRequestedTasks(TaskSearchModel searchModel) - { - return _taskRepository.GetAllRequestedTasks(searchModel); - } - - public int GetRequestedTasksCount() - { - return _taskRepository.GetRequestedTasksCount(); - } + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + + } + + + + + + + #endregion + + + + if (command.Voice?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Voice.FileName); + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Voice.CopyTo(stream); + } + + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "صوت"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + + + } + + + #endregion + + + _taskRepository.SaveChanges(); + return operation.Succcedded(); + } + //ساخت یک ارجاع دهنده + public OperationResult CreateAssign(CreateAssign command) + { + var posValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); + var operation = new OperationResult(); + if (!_taskRepository.Exists(x => x.id == command.TaskId)) + { + return operation.Failed("چنین وظیفه ای وجود ندارد"); + } + if (!_accountRepository.Exists(x => x.id == command.AssignerId)) + { + return operation.Failed("خطای سیستمی!!"); + } + + foreach (var assignedId in command.AssignedId) + { + if (!_accountRepository.Exists(x => x.id == assignedId)) + { + return operation.Failed("چنین شخصی برای ارجاع وجود ندارد."); + } + + } + + var assigner = _accountRepository.GetIncludePositions(command.AssignerId); + foreach (var assignedId in command.AssignedId) + { + var assigned = _accountRepository.GetIncludePositions(assignedId); + + var assign = new Assign(command.TaskId, command.AssignerId, assignedId, assigner.Position.PositionValue, + assigned.Fullname, assigned.Position.PositionValue); + _assignRepository.Create(assign); + } + _assignRepository.SaveChanges(); + return operation.Succcedded(); + } + //ساخت تسک + public OperationResult CreateTask(CreateTask command) + { + var operation = new OperationResult(); + if (string.IsNullOrEmpty(command.Title)) + { + return operation.Failed("لطفا عنوان وظیفه خود ار وارد کنید"); + } + + if (string.IsNullOrEmpty(command.EndTaskDate)) + { + return operation.Failed("لطفا تاریخ انجام وظیفه را وارد کنید"); + } + + + + if (string.IsNullOrEmpty(command.ContractingPartyName)) + { + return operation.Failed("لطفا طرف حساب خودرا وارد کنید"); + } + + + if (command.SenderId < 1) + { + return operation.Failed("خطای سیستمی!!!"); + } + + var sender = _accountRepository.GetIncludePositions(command.SenderId); + + if (command.PositionId?.Count > 0 && command.ReceiverId?.Count > 0) + { + if (command.PositionId.Any(x => x > 0)) + { + return operation.Failed("شما نمیتوانید همرمان به صورت انفرادی و هم به صورت گروهی تسک دهید. "); + } + } + else if (command.PositionId?.Count > 0) + { + var res = CreateTaskByPosition(command); + return res; + } + if (command.ReceiverId.Count < 1) + { + return operation.Failed("طرف وظیفه خود را وارد کنید"); + } + + var receivers = _accountRepository.GetAccountsByIds(command.ReceiverId); + + if (sender.Position.PositionValue == 1) + { + + } + + else if (receivers.Any(x => sender.Position.PositionValue >= x.Position.PositionValue)) + { + var checkReceiver = receivers.Where(x => sender.Position.PositionValue >= x.Position.PositionValue).ToList(); + if (checkReceiver.All(x => x.id == sender.id)) + { + + } + else + { + return operation.Failed("شما نمیتوانید به سطح بالاتر خود یا هم سطح خود وظیفه ای دهید"); + } + + } + else if (receivers.Count == 1 && receivers.Any(x => sender.id == x.id)) + { + + } + + + var endTask = string.IsNullOrWhiteSpace(command.EndTaskTime) ? command.EndTaskDate.ToGeorgianDateTime2() : command.EndTaskDate.ToGeorgianDateWithTime(command.EndTaskTime); + + + + var task = new Tasks(command.Title, endTask, command.Description, command.SenderId, command.ContractingPartyName); + _taskRepository.Create(task); + _assignRepository.SaveChanges(); + foreach (var receiver in receivers) + { + var assign = new Assign(task.id, task.SenderId, receiver.id, sender.Position.PositionValue, receiver.Fullname, + receiver.Position.PositionValue); + _assignRepository.Create(assign); + } + + + + #region SaveMedias + + #region SaveDocuments + + if ((command.Document1?.Length > 5000000) || (command.Document2?.Length > 5000000) || (command.Document3?.Length > 5000000) || (command.Document4?.Length > 5000000) + || (command.Document5?.Length > 5000000) || (command.Document6?.Length > 5000000)) + return operation.Failed("حجم فایل نمیتواند از 5 مگابایت بیشتر باشد"); + + if (command.Document1?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document1.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document1.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + } + if (command.Document2?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document2.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document2.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + } + if (command.Document3?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document3.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document3.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + } + if (command.Document4?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document4.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document4.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + } + if (command.Document5?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document5.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document5.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + } + if (command.Document6?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document6.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document6.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + } + + + + #endregion + + + + if (command.Voice?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Voice.FileName); + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Voice.CopyTo(stream); + } + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "صوت"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + + } + + + + #endregion + _taskRepository.SaveChanges(); + return operation.Succcedded(task.id); + } + + public OperationResult CreateTaskByPosition(CreateTask command) + { + var operation = new OperationResult(); + var sender = _accountRepository.GetIncludePositions(command.SenderId); + + var receivers = _positionRepository.GetAccountsByIds(command.PositionId); + + + if (sender.Position.PositionValue == 1) + { + + } + else if (receivers.Any(x => sender.Position.PositionValue > x.Position.PositionValue)) + { + return operation.Failed("شما نمیتوانید به سطح بالاتر خود وظیفه ای دهید"); + } + else if (receivers.Count == 1 && receivers.Any(x => sender.id == x.id)) + { + + } + else if (receivers.Any(x => sender.Position.PositionValue == x.Position.PositionValue)) + { + return operation.Failed("شما نمیتوانید به هم سطح خود وظیفه ای دهید"); + } + + + DateTime endTask; + if (string.IsNullOrWhiteSpace(command.EndTaskTime)) + { + endTask = command.EndTaskDate.ToGeorgianDateTime2(); + } + else + { + endTask = command.EndTaskDate.ToGeorgianDateWithTime(command.EndTaskTime); + } + + + + var task = new Tasks(command.Title, endTask, command.Description, command.SenderId, command.ContractingPartyName); + _taskRepository.Create(task); + _assignRepository.SaveChanges(); + foreach (var receiver in receivers) + { + var assign = new Assign(task.id, task.SenderId, receiver.id, sender.Position.PositionValue, receiver.Fullname, + receiver.Position.PositionValue); + _assignRepository.Create(assign); + } + + + + #region SaveMedias + + #region SaveDocuments + + if ((command.Document1?.Length > 2000000) || (command.Document2?.Length > 2000000) || (command.Document3?.Length > 2000000)) + return operation.Failed("حجم فایل نمیتواند از 2 مگابایت بیشتر باشد"); + + if (command.Document1?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document1.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document1.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + } + if (command.Document2?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document2.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document2.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + } + if (command.Document3?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document3.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document3.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + } + if (command.Document4?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document4.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document4.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + } + if (command.Document5?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document5.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document5.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + } + if (command.Document6?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document6.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document6.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + } + + + + #endregion + + + + if (command.Voice?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Voice.FileName); + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Voice.CopyTo(stream); + } + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "صوت"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + + } + + + + #endregion + _taskRepository.SaveChanges(); + return operation.Succcedded(task.id); + } + + // ویرایش تسک + public EditTask GetDetails(long taskId) + { + return _taskRepository.GetDetails(taskId); + } + + //لیست کامل تسک ها + public List GetTasks(TaskSearchModel searchModel) + { + var test = _taskRepository.GetTasks(searchModel); + + return test; + } + //ساخت درخواست مهلت + public OperationResult CreateRequestTime(CreateTaskTimeRequest command) + { + var operation = new OperationResult(); + if (command.TaskId == 0) + { + return operation.Failed("چنین وظیفه ای وجود ندارد"); + } + + if (string.IsNullOrWhiteSpace(command.Description)) + { + return operation.Failed("توضیحات خود را وارد کنید"); + } + + if (string.IsNullOrWhiteSpace(command.RequestTime)) + { + return operation.Failed("مهلت درخواستی خود را وارد کنید"); + } + + var task = _taskRepository.Get(command.TaskId); + var requestTime = command.RequestTime.ToGeorgianDateTime(); + task.CreateTimeRequest(requestTime, command.Description); + _taskRepository.SaveChanges(); + return operation.Succcedded(task.id); + } + //تایید درخواست مهلت + public OperationResult AcceptRequestDatetime(long taskId) + { + var operation = new OperationResult(); + if (!_taskRepository.Exists(x => x.id == taskId)) + { + return operation.Failed("چنین وظیفه ای وجود ندارد"); + } + + var task = _taskRepository.Get(taskId); + if (!task.TimeRequest) + { + return operation.Failed("چنین وظیفه ای درخواستی برای مهلت ندارد"); + } + + if (task.RequestDate == null) + { + return operation.Failed("تاریخی برای درخواست وظیفه ثبت نشده است"); + } + task.AcceptTimeRequest(); + _taskRepository.SaveChanges(); + return operation.Succcedded(task.id); + } + //ساخت درخواست کنسل + public OperationResult CreateCancelRequest(CreateTaskCancel command) + { + var operation = new OperationResult(); + if (string.IsNullOrWhiteSpace(command.Description)) + { + return operation.Failed("توضیحات خود را وارد کنید"); + } + + if (!_taskRepository.Exists(x => x.id == command.TaskId)) + { + return operation.Failed("چنین وظیفه ای وجود ندارد"); + } + var task = _taskRepository.Get(command.TaskId); + task.CreateCancelRequest(command.Description); + _taskRepository.SaveChanges(); + return operation.Succcedded(task.id); + } + //تایید درخواست کنسل + public OperationResult AcceptCancelRequest(long taskId) + { + var operation = new OperationResult(); + if (!_taskRepository.Exists(x => x.id == taskId)) + { + return operation.Failed("چنین وظیفه ای وجود ندارد"); + } + var task = _taskRepository.Get(taskId); + if (!task.IsCanceledRequest) + { + return operation.Failed("چنین وظیفه ای درخواستی برای انصراف ندارد"); + } + task.AcceptCancelRequest(); + _taskRepository.SaveChanges(); + return operation.Succcedded(taskId); + } + //انجام شدن تسک + public OperationResult CreateCompleteTaskRequest(CompleteTaskViewModel command) + { + var operation = new OperationResult(); + if (!_taskRepository.Exists(x => x.id == command.Id)) + { + return operation.Failed("چنین وظیفه ای وجود ندارد"); + } + var task = _taskRepository.Get(command.Id); + task.CompleteRequest(command.Description); + _taskRepository.SaveChanges(); + return operation.Succcedded(task.id); + } + + public OperationResult AcceptCompleteRequest(long taskId) + { + var operation = new OperationResult(); + if (!_taskRepository.Exists(x => x.id == taskId)) + { + return operation.Failed("چنین وظیفه ای وجود ندارد"); + } + var task = _taskRepository.Get(taskId); + if (!task.IsDoneRequest) + { + return operation.Failed("چنین وظیفه ای درخواستی برای تایید ندارد"); + } + task.Completed(); + _taskRepository.SaveChanges(); + return operation.Succcedded(taskId); + } + + public OperationResult RejectCompleteRequest(long taskId) + { + var operation = new OperationResult(); + if (!_taskRepository.Exists(x => x.id == taskId)) + { + return operation.Failed("چنین وظیفه ای وجود ندارد"); + } + var task = _taskRepository.Get(taskId); + if (!task.IsDoneRequest) + { + return operation.Failed("چنین وظیفه ای درخواستی برای انصراف ندارد"); + } + task.RejectCompleteRequest(); + _taskRepository.SaveChanges(); + return operation.Succcedded(taskId); + } + + //لغو درخواست کنسل تسک + public OperationResult RejectCancelRequest(long taskId) + { + var operation = new OperationResult(); + if (!_taskRepository.Exists(x => x.id == taskId)) + { + return operation.Failed("چنین وظیفه ای وجود ندارد"); + } + var task = _taskRepository.Get(taskId); + if (!task.IsCanceledRequest) + { + return operation.Failed("چنین وظیفه ای درخواستی برای انصراف ندارد"); + } + task.RejectCancel(); + _taskRepository.SaveChanges(); + return operation.Succcedded(taskId); + } + //لغو درخواست مهلت تسک + public OperationResult RejectTimeRequest(long taskId) + { + var operation = new OperationResult(); + if (!_taskRepository.Exists(x => x.id == taskId)) + { + return operation.Failed("چنین وظیفه ای وجود ندارد"); + } + + var task = _taskRepository.Get(taskId); + if (!task.TimeRequest) + { + return operation.Failed("چنین وظیفه ای درخواستی برای مهلت ندارد"); + } + task.RejectTimeRequest(); + _taskRepository.SaveChanges(); + return operation.Succcedded(task.id); + } + + public OperationResult CreateTaskByPosition(CreateTask command, List positionIds) + { + var operation = new OperationResult(); + var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); + var positions = new List(); + foreach (var positionId in positionIds) + { + var position = _positionRepository.Get(positionId); + positions.Add(position); + } + + + if (positions.Any(x => x.PositionValue <= positionValue)) + { + return operation.Failed("شما نمیتوانید به گروه هم سطح یا سطح بالاتر خود تسکی دهد"); + } + + var receiverIds = new List(); + foreach (var positionId in positionIds) + { + var acc = _accountRepository.GetAccountsByPositionId(positionId).Select(x => x.Id).ToList(); + receiverIds.AddRange(acc); + } + + command.ReceiverId = receiverIds; + operation = CreateTask(command); + return operation; + } + + public List GetAllRequestedTasks(TaskSearchModel searchModel) + { + return _taskRepository.GetAllRequestedTasks(searchModel); + } + + public int GetRequestedTasksCount() + { + return _taskRepository.GetRequestedTasksCount(); + } + + public OperationResult ChangeRequestTimeAndAccept(string time, long taskId) + { + var operation = new OperationResult(); + if (!_taskRepository.Exists(x => x.id == taskId)) + { + return operation.Failed("چنین وظیفه ای وجود ندارد"); + } + + var task = _taskRepository.Get(taskId); + if (!task.TimeRequest) + { + return operation.Failed("چنین وظیفه ای درخواستی برای مهلت ندارد"); + } + + if (task.RequestDate == null) + { + return operation.Failed("تاریخی برای درخواست وظیفه ثبت نشده است"); + } + + DateTime timeGr = time.ToGeorgianDateTime2(); + task.ChangeTimeTask(timeGr); + _taskRepository.SaveChanges(); + return operation.Succcedded(task.id); + } + + public TaskViewModel GetRequestDetails(long id) + { + return _taskRepository.GetRequestDetails(id); + } } \ No newline at end of file diff --git a/AccountManagement.Application/TaskSubjectApplication.cs b/AccountManagement.Application/TaskSubjectApplication.cs index 454f37be..42383942 100644 --- a/AccountManagement.Application/TaskSubjectApplication.cs +++ b/AccountManagement.Application/TaskSubjectApplication.cs @@ -73,8 +73,8 @@ public class TaskSubjectApplication : ITaskSubjectApplication } } - public List GetAll() + public List GetAll(string search) { - return _taskSubjectRepository.GetAll(); + return _taskSubjectRepository.GetAll(search); } } \ No newline at end of file diff --git a/AccountManagement.Application/TicketApplication.cs b/AccountManagement.Application/TicketApplication.cs new file mode 100644 index 00000000..38b42ae5 --- /dev/null +++ b/AccountManagement.Application/TicketApplication.cs @@ -0,0 +1,768 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net.Sockets; +using _0_Framework.Application; +using AccountManagement.Application.Contracts.Task; +using AccountManagement.Application.Contracts.Ticket; +using AccountManagement.Domain.AccountAgg; +using AccountManagement.Domain.AdminResponseAgg; +using AccountManagement.Domain.AssignAgg; +using AccountManagement.Domain.ClientResponseAgg; +using AccountManagement.Domain.MediaAgg; +using AccountManagement.Domain.TaskAgg; +using AccountManagement.Domain.TicketAgg; + +namespace AccountManagement.Application; + +public class TicketApplication : ITicketApplication +{ + private readonly ITicketRepository _ticketRepository; + private readonly IAccountRepository _accountRepository; + private readonly ITaskRepository _taskRepository; + private readonly IAssignRepository _assignRepository; + private readonly IMediaRepository _mediaRepository; + + public TicketApplication(ITicketRepository ticketRepository, IAccountRepository accountRepository, ITaskRepository taskRepository, IAssignRepository assignRepository, IMediaRepository mediaRepository) + { + _ticketRepository = ticketRepository; + _accountRepository = accountRepository; + _taskRepository = taskRepository; + _assignRepository = assignRepository; + _mediaRepository = mediaRepository; + } + + public OperationResult CreateTicket(CreateTicket command) + { + var operation = new OperationResult(); + if (string.IsNullOrWhiteSpace(command.ContractingPartyName)) + { + return operation.Failed("خطای سیستمی"); + } + + if (string.IsNullOrWhiteSpace(command.Title)) + { + return operation.Failed("لطفا عنوان را وارد کنید"); + } + + if (string.IsNullOrWhiteSpace(command.Description)) + { + return operation.Failed("لطفا توضیحات خودرا وارد کنید"); + } + + + + var ticket = new Ticket(command.Title, command.Description, command.SenderId, command.ContractingPartyName, + command.TicketType); + _ticketRepository.Create(ticket); + _ticketRepository.SaveChanges(); + #region SaveDocuments + + if ((command.Document1?.Length > 5000000) || (command.Document2?.Length > 5000000) || (command.Document3?.Length > 5000000) || (command.Document4?.Length > 5000000) + || (command.Document5?.Length > 5000000)) + return operation.Failed("حجم فایل نمیتواند از 5 مگابایت بیشتر باشد"); + + + if (command.Document1?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Ticket", $"{ticket.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document1.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document1.CopyTo(stream); + } + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateTicketMedia(ticket.id, media.id); + } + if (command.Document2?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Ticket", $"{ticket.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document2.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document2.CopyTo(stream); + } + var type = Path.GetExtension(filepath); + + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateTicketMedia(ticket.id, media.id); + } + if (command.Document3?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Ticket", $"{ticket.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document3.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document3.CopyTo(stream); + } + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateTicketMedia(ticket.id, media.id); + } + if (command.Document4?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Ticket", $"{ticket.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document4.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document4.CopyTo(stream); + } + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateTicketMedia(ticket.id, media.id); + } + if (command.Document5?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Ticket", $"{ticket.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document5.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document5.CopyTo(stream); + } + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateTicketMedia(ticket.id, media.id); + } + if (command.ScreenShot?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Ticket", $"{ticket.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.ScreenShot.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.ScreenShot.CopyTo(stream); + } + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateTicketMedia(ticket.id, media.id); + } + + + + #endregion + #region SaveVoice + if (command.Voice?.Length > 0) + { + + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Ticket", $"{ticket.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Voice.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Voice.CopyTo(stream); + } + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateTicketMedia(ticket.id, media.id); + + } + #endregion + + _mediaRepository.SaveChanges(); + return operation.Succcedded(ticket.id); + } + + public OperationResult AssignTicket(CreateTask command, long ticketId) + { + var operation = new OperationResult(); + if (string.IsNullOrEmpty(command.Title)) + { + return operation.Failed("لطفا عنوان وظیفه خود ار وارد کنید"); + } + + if (string.IsNullOrEmpty(command.EndTaskDate)) + { + return operation.Failed("لطفا تاریخ انجام وظیفه را وارد کنید"); + } + + + if (string.IsNullOrEmpty(command.ContractingPartyName)) + { + return operation.Failed("لطفا طرف حساب خودرا وارد کنید"); + } + + if (command.SenderId < 1) + { + return operation.Failed("خطای سیستمی!!!"); + } + + var sender = _accountRepository.GetIncludePositions(command.SenderId); + + + if (command.ReceiverId.Count < 1) + { + return operation.Failed("طرف وظیفه خود را وارد کنید"); + } + + var receivers = _accountRepository.GetAccountsByIds(command.ReceiverId); + + if (sender.Position.PositionValue == 1) + { + + } + else if (receivers.Any(x => sender.Position.PositionValue >= x.Position.PositionValue)) + { + var checkReceiver = receivers.Where(x => sender.Position.PositionValue >= x.Position.PositionValue).ToList(); + if (checkReceiver.All(x => x.id == sender.id)) + { + + } + else + { + return operation.Failed("شما نمیتوانید به سطح بالاتر خود یا هم سطح خود وظیفه ای دهید"); + } + + } + else if (receivers.Count == 1 && receivers.Any(x => sender.id == x.id)) + { + + } + + + var endTask = string.IsNullOrWhiteSpace(command.EndTaskTime) ? command.EndTaskDate.ToGeorgianDateTime2() : command.EndTaskDate.ToGeorgianDateWithTime(command.EndTaskTime); + + var task = new Tasks(command.Title, endTask, command.Description, command.SenderId, command.ContractingPartyName, ticketId); + _taskRepository.Create(task); + _assignRepository.SaveChanges(); + foreach (var receiver in receivers) + { + var assign = new Assign(task.id, task.SenderId, receiver.id, sender.Position.PositionValue, receiver.Fullname, + receiver.Position.PositionValue); + _assignRepository.Create(assign); + } + + + + #region SaveMedias + + #region SaveDocuments + + if ((command.Document1?.Length > 5000000) || (command.Document2?.Length > 5000000) || (command.Document3?.Length > 5000000) || (command.Document4?.Length > 5000000) + || (command.Document5?.Length > 5000000) || (command.Document6?.Length > 5000000)) + return operation.Failed("حجم فایل نمیتواند از 5 مگابایت بیشتر باشد"); + + + if (command.Document1?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document1.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document1.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + } + if (command.Document2?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document2.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document2.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + } + if (command.Document3?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document3.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document3.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + } + if (command.Document4?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document4.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document4.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + } + if (command.Document5?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document5.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document5.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + } + if (command.Document6?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document6.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document6.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + } + + + + #endregion + #region SaveVoice + if (command.Voice?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "Task", $"{task.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Voice.FileName); + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Voice.CopyTo(stream); + } + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "صوت"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + + } + #endregion + + + + + #endregion + _taskRepository.SaveChanges(); + + return operation.Succcedded(task.id); + } + + public OperationResult CompleteTicket(long id) + { + var operation = new OperationResult(); + if (!_ticketRepository.Exists(x => x.id == id)) + { + return operation.Failed("چنین تیکتی وجود ندارد"); + } + var ticket = _ticketRepository.Get(id); + ticket.Completed(); + _ticketRepository.SaveChanges(); + return operation.Succcedded(ticket.id); + } + + public OperationResult AdminResponseTicket(ResponseTicket command) + { + var operation = new OperationResult(); + if (string.IsNullOrWhiteSpace(command.Response)) + { + return operation.Failed("لطفا پیغام خود را وارد کنبد"); + } + + var adminRes = new AdminResponse(command.Response, command.TicketId); + _ticketRepository.CreateAdminResponse(adminRes); + _ticketRepository.SaveChanges(); + + #region SaveDocuments + + if ((command.Document1?.Length > 5000000) || (command.Document2?.Length > 5000000) || (command.Document3?.Length > 5000000) || (command.Document4?.Length > 5000000) + || (command.Document5?.Length > 5000000) || (command.Document6?.Length > 5000000)) + return operation.Failed("حجم فایل نمیتواند از 5 مگابایت بیشتر باشد"); + + + if (command.Document1?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "TicketAdminResponse", $"{adminRes.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document1.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document1.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateAdminResponseMedia(adminRes.id, media.id); + } + if (command.Document2?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "TicketAdminResponse", $"{adminRes.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document2.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document2.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateAdminResponseMedia(adminRes.id, media.id); + } + if (command.Document3?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "TicketAdminResponse", $"{adminRes.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document3.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document3.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateAdminResponseMedia(adminRes.id, media.id); + } + if (command.Document4?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "TicketAdminResponse", $"{adminRes.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document4.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document4.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateAdminResponseMedia(adminRes.id, media.id); + } + if (command.Document5?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "TicketAdminResponse", $"{adminRes.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document5.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document5.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateAdminResponseMedia(adminRes.id, media.id); + } + + if (command.Document6?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", + "Storage", + "TicketAdminResponse", $"{adminRes.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document6.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document6.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateAdminResponseMedia(adminRes.id, media.id); + + + } + + #endregion + _mediaRepository.SaveChanges(); + + + return operation.Succcedded(adminRes.id); + } + + public OperationResult ClientResponseTicket(ResponseTicket command) + { + var operation = new OperationResult(); + if (string.IsNullOrWhiteSpace(command.Response)) + { + return operation.Failed("لطفا پیغام خود را وارد کنبد"); + } + + var clientRes = new ClientResponse(command.Response, command.TicketId); + _ticketRepository.CreateClientResponse(clientRes); + _ticketRepository.SaveChanges(); + #region SaveDocuments + + if ((command.Document1?.Length > 5000000) || (command.Document2?.Length > 5000000) || (command.Document3?.Length > 5000000) || (command.Document4?.Length > 5000000) + || (command.Document5?.Length > 5000000) || (command.Document6?.Length > 5000000)) + return operation.Failed("حجم فایل نمیتواند از 5 مگابایت بیشتر باشد"); + + + if (command.Document1?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "TicketClientResponse", $"{clientRes.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document1.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document1.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateClientResponseMedia(clientRes.id, media.id); + + } + if (command.Document2?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "TicketClientResponse", $"{clientRes.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document2.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document2.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateClientResponseMedia(clientRes.id, media.id); + } + if (command.Document3?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "TicketClientResponse", $"{clientRes.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document3.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document3.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateClientResponseMedia(clientRes.id, media.id); + } + if (command.Document4?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "TicketClientResponse", $"{clientRes.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document4.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document4.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateClientResponseMedia(clientRes.id, media.id); + } + if (command.Document5?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage", + "TicketClientResponse", $"{clientRes.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document5.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document5.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateClientResponseMedia(clientRes.id, media.id); + } + + if (command.Document6?.Length > 0) + { + var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", + "Storage", + "TicketClientResponse", $"{clientRes.id}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, command.Document6.FileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + command.Document6.CopyTo(stream); + + } + + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + _mediaRepository.CreateClientResponseMedia(clientRes.id, media.id); + + + } + + #endregion + _mediaRepository.SaveChanges(); + return operation.Succcedded(clientRes.id); + } + + public EditTicket GetDetails(long id) + { + return _ticketRepository.GetDetails(id); + } + + public List GetAll(TicketSearchModel searchModel) + { + return _ticketRepository.GetAll(searchModel); + } + + public bool IsExist(long id) + { + return _ticketRepository.Exists(x => x.id == id); + } +} \ No newline at end of file diff --git a/AccountManagement.Configuration/AccountManagementBootstrapper.cs b/AccountManagement.Configuration/AccountManagementBootstrapper.cs index 5bf2ad5d..2bb7cc9f 100644 --- a/AccountManagement.Configuration/AccountManagementBootstrapper.cs +++ b/AccountManagement.Configuration/AccountManagementBootstrapper.cs @@ -1,9 +1,11 @@ using AccountManagement.Application; using AccountManagement.Application.Contracts.Account; using AccountManagement.Application.Contracts.CameraAccount; +using AccountManagement.Application.Contracts.Position; using AccountManagement.Application.Contracts.Role; using AccountManagement.Application.Contracts.Task; using AccountManagement.Application.Contracts.TaskSubject; +using AccountManagement.Application.Contracts.Ticket; using AccountManagement.Domain.AccountAgg; using AccountManagement.Domain.AssignAgg; using AccountManagement.Domain.CameraAccountAgg; @@ -11,11 +13,11 @@ using AccountManagement.Domain.MediaAgg; using AccountManagement.Domain.RoleAgg; using AccountManagement.Domain.TaskAgg; using AccountManagement.Domain.TaskSubjectAgg; +using AccountManagement.Domain.TicketAgg; using AccountMangement.Infrastructure.EFCore; using AccountMangement.Infrastructure.EFCore.Repository; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; -using TaskManager.Application.Contract.Position; using TaskManager.Application; using TaskManager.Domain.PositionAgg; using TaskManager.Infrastructure.EFCore.Repository; @@ -36,7 +38,6 @@ namespace AccountManagement.Configuration services.AddTransient(); #region Mahan - services.AddTransient(); services.AddTransient(); @@ -50,6 +51,9 @@ namespace AccountManagement.Configuration services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + #endregion diff --git a/AccountManagement.Domain/AdminResponseAgg/AdminResponse.cs b/AccountManagement.Domain/AdminResponseAgg/AdminResponse.cs new file mode 100644 index 00000000..a8c6cc40 --- /dev/null +++ b/AccountManagement.Domain/AdminResponseAgg/AdminResponse.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using _0_Framework.Domain; +using AccountManagement.Domain.AdminResponseMediaAgg; +using AccountManagement.Domain.TicketAgg; + +namespace AccountManagement.Domain.AdminResponseAgg; + +public class AdminResponse:EntityBase +{ + public AdminResponse(string response,long ticketId) + { + Response = response; + TicketId = ticketId; + } + + public long TicketId { get; private set; } + public string Response { get; private set; } + public Ticket Ticket { get; set; } + public List AdminResponseMedias { get; set; } + + +} \ No newline at end of file diff --git a/AccountManagement.Domain/AdminResponseMediaAgg/AdminResponseMedia.cs b/AccountManagement.Domain/AdminResponseMediaAgg/AdminResponseMedia.cs new file mode 100644 index 00000000..ff021982 --- /dev/null +++ b/AccountManagement.Domain/AdminResponseMediaAgg/AdminResponseMedia.cs @@ -0,0 +1,18 @@ +using AccountManagement.Domain.AdminResponseAgg; +using AccountManagement.Domain.MediaAgg; + + +namespace AccountManagement.Domain.AdminResponseMediaAgg; + +public class AdminResponseMedia +{ + public AdminResponseMedia(long adminResponseId, long mediaId) + { + AdminResponseId = adminResponseId; + MediaId = mediaId; + } + public long AdminResponseId { get; set; } + public long MediaId { get; set; } + public AdminResponse AdminResponse { get; set; } + public Media Media { get; set; } +} \ No newline at end of file diff --git a/AccountManagement.Domain/ClientResponseAgg/ClientResponse.cs b/AccountManagement.Domain/ClientResponseAgg/ClientResponse.cs new file mode 100644 index 00000000..ced20711 --- /dev/null +++ b/AccountManagement.Domain/ClientResponseAgg/ClientResponse.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using _0_Framework.Domain; +using AccountManagement.Domain.ClientResponseMediaAgg; +using AccountManagement.Domain.TicketAgg; + +namespace AccountManagement.Domain.ClientResponseAgg; + +public class ClientResponse:EntityBase +{ + public ClientResponse(string response, long ticketId) + { + Response = response; + TicketId = ticketId; + } + + public long TicketId { get; private set; } + public string Response { get; private set; } + public Ticket Ticket { get; set; } + public List ClientResponseMedias { get; set; } + +} \ No newline at end of file diff --git a/AccountManagement.Domain/ClientResponseMediaAgg/ClientResponseMedia.cs b/AccountManagement.Domain/ClientResponseMediaAgg/ClientResponseMedia.cs new file mode 100644 index 00000000..a2bd8922 --- /dev/null +++ b/AccountManagement.Domain/ClientResponseMediaAgg/ClientResponseMedia.cs @@ -0,0 +1,19 @@ + +using AccountManagement.Domain.ClientResponseAgg; +using AccountManagement.Domain.MediaAgg; + +namespace AccountManagement.Domain.ClientResponseMediaAgg; + +public class ClientResponseMedia +{ + public ClientResponseMedia(long clientResponseId, long mediaId) + { + ClientResponseId = clientResponseId; + MediaId = mediaId; + } + + public long ClientResponseId { get; set; } + public long MediaId { get; set; } + public ClientResponse ClientResponse{ get; set; } + public Media Media { get; set; } +} \ No newline at end of file diff --git a/AccountManagement.Domain/MediaAgg/IMediaRepository.cs b/AccountManagement.Domain/MediaAgg/IMediaRepository.cs index 95965103..d85b140e 100644 --- a/AccountManagement.Domain/MediaAgg/IMediaRepository.cs +++ b/AccountManagement.Domain/MediaAgg/IMediaRepository.cs @@ -10,4 +10,8 @@ public interface IMediaRepository:IRepository void CreateMediaWithTaskMedia(long taskId, long mediaId); List GetMediaByTaskId(long taskId); void Remove(long id); + + void CreateTicketMedia(long ticketId, long mediaId); + void CreateAdminResponseMedia(long adminResponseId, long mediaId); + void CreateClientResponseMedia(long clientResponseId, long mediaId); } \ No newline at end of file diff --git a/AccountManagement.Domain/MediaAgg/Media.cs b/AccountManagement.Domain/MediaAgg/Media.cs index aae2710e..9adca572 100644 --- a/AccountManagement.Domain/MediaAgg/Media.cs +++ b/AccountManagement.Domain/MediaAgg/Media.cs @@ -1,6 +1,9 @@ using System.Collections.Generic; using _0_Framework.Domain; +using AccountManagement.Domain.AdminResponseMediaAgg; +using AccountManagement.Domain.ClientResponseMediaAgg; using AccountManagement.Domain.TaskMediaAgg; +using AccountManagement.Domain.TicketMediasAgg; namespace AccountManagement.Domain.MediaAgg; @@ -24,4 +27,7 @@ public class Media:EntityBase //دسته بندی ذخیره فایل public string Category { get; set; } public List TaskMedias { get; set; } + public List AdminResponseMedias { get; set; } + public List ClientResponseMedias { get; set; } + public List TicketMedias { get; set; } } \ No newline at end of file diff --git a/AccountManagement.Domain/PositionAgg/IPositionRepository.cs b/AccountManagement.Domain/PositionAgg/IPositionRepository.cs index 6ce0767a..60cbc802 100644 --- a/AccountManagement.Domain/PositionAgg/IPositionRepository.cs +++ b/AccountManagement.Domain/PositionAgg/IPositionRepository.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using _0_Framework.Domain; using AccountManagement.Application.Contracts.Account; +using AccountManagement.Application.Contracts.Position; using AccountManagement.Domain.AccountAgg; -using TaskManager.Application.Contract.Position; namespace TaskManager.Domain.PositionAgg; @@ -11,6 +11,7 @@ public interface IPositionRepository : IRepository List GetPositions(); List GetLowerPosition(); + List GetUnUsedPositionValues(); List GetNoPositionAccounts(); List GetAccountsByIds(List ids); diff --git a/AccountManagement.Domain/TaskAgg/ITaskRepository.cs b/AccountManagement.Domain/TaskAgg/ITaskRepository.cs index dc785a4e..e3061ecc 100644 --- a/AccountManagement.Domain/TaskAgg/ITaskRepository.cs +++ b/AccountManagement.Domain/TaskAgg/ITaskRepository.cs @@ -13,8 +13,11 @@ public interface ITaskRepository:IRepository //گرفتن تمامی وظایف List GetTasks(TaskSearchModel searchModel); List GetAllRequestedTasks(TaskSearchModel searchModel); - string SetTasksColors(DateTime time); + string SetTasksColors(DateTime time,bool isCancel); int GetRequestedTasksCount(); + TaskViewModel GetRequestDetails(long id); + + } \ No newline at end of file diff --git a/AccountManagement.Domain/TaskAgg/Tasks.cs b/AccountManagement.Domain/TaskAgg/Tasks.cs index 4cf48c49..e2c75ca9 100644 --- a/AccountManagement.Domain/TaskAgg/Tasks.cs +++ b/AccountManagement.Domain/TaskAgg/Tasks.cs @@ -47,18 +47,33 @@ public class Tasks : EntityBase //توضیحات درخواست انصراف public string? CancelDescription { get; private set; } public bool IsDone { get; private set; } + public bool IsDoneRequest { get; private set; } + public string? DoneDescription { get; private set; } public string IsActiveString { get; private set; } public List Assigns { get; set; } public List TaskMedias { get; set; } + public long? TicketId { get; set; } - - public void Edit(string title, DateTime endTaskDate, string? description, long senderId) + public Tasks(string title, DateTime endTaskDate, string? description, long senderId, string contractingPartyName, long ticketId) { Title = title; EndTaskDate = endTaskDate; Description = description; SenderId = senderId; + ContractingPartyName = contractingPartyName; + StartTaskDate = DateTime.Now; + IsActiveString = "true"; + TicketId = ticketId; + } + + public void Edit(string title, DateTime endTaskDate, string? description, long senderId, string contractingPartyName) + { + Title = title; + EndTaskDate = endTaskDate; + Description = description; + SenderId = senderId; + ContractingPartyName= contractingPartyName; } @@ -104,9 +119,20 @@ public class Tasks : EntityBase IsCanceledRequest = false; } - public void Completed(string? doneDescription) + public void CompleteRequest(string? doneDescription) { DoneDescription = doneDescription; + IsDoneRequest = true; + } + + public void RejectCompleteRequest() + { + IsDoneRequest = false; + DoneDescription=null; + } + public void Completed() + { + IsDoneRequest = false; IsDone=true; } @@ -121,7 +147,13 @@ public class Tasks : EntityBase } - + public void ChangeTimeTask(DateTime time) + { + EndTaskDate = time; + AcceptedTimeRequest++; + RequestDate = null; + TimeRequest = false; + } } \ No newline at end of file diff --git a/AccountManagement.Domain/TaskSubjectAgg/ITaskSubjectRepository.cs b/AccountManagement.Domain/TaskSubjectAgg/ITaskSubjectRepository.cs index d548e870..c7a046e4 100644 --- a/AccountManagement.Domain/TaskSubjectAgg/ITaskSubjectRepository.cs +++ b/AccountManagement.Domain/TaskSubjectAgg/ITaskSubjectRepository.cs @@ -6,6 +6,6 @@ namespace AccountManagement.Domain.TaskSubjectAgg; public interface ITaskSubjectRepository:IRepository { - List GetAll(); + List GetAll(string search); void Remove(long id); } \ No newline at end of file diff --git a/AccountManagement.Domain/TicketAgg/ITicketRepository.cs b/AccountManagement.Domain/TicketAgg/ITicketRepository.cs new file mode 100644 index 00000000..c6aa0aee --- /dev/null +++ b/AccountManagement.Domain/TicketAgg/ITicketRepository.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using _0_Framework.Domain; +using AccountManagement.Application.Contracts.Ticket; +using AccountManagement.Domain.AdminResponseAgg; +using AccountManagement.Domain.ClientResponseAgg; + +namespace AccountManagement.Domain.TicketAgg; + +public interface ITicketRepository:IRepository +{ + List GetAll(TicketSearchModel searchModel); + void CreateAdminResponse(AdminResponse command); + void CreateClientResponse(ClientResponse command); + EditTicket GetDetails(long id); + + +} \ No newline at end of file diff --git a/AccountManagement.Domain/TicketAgg/Ticket.cs b/AccountManagement.Domain/TicketAgg/Ticket.cs new file mode 100644 index 00000000..b3d0e84a --- /dev/null +++ b/AccountManagement.Domain/TicketAgg/Ticket.cs @@ -0,0 +1,42 @@ + +using System.Collections.Generic; +using _0_Framework.Domain; +using AccountManagement.Domain.AdminResponseAgg; +using AccountManagement.Domain.ClientResponseAgg; +using AccountManagement.Domain.TicketMediasAgg; + +namespace AccountManagement.Domain.TicketAgg; + +public class Ticket:EntityBase +{ + public Ticket(string title, string description, long senderId, string contractingPartyName, string ticketType) + { + Title = title; + Description = description; + Status = "درحال بررسی"; + SenderId = senderId; + ContractingPartyName = contractingPartyName; + TicketType = ticketType; + } + + public string Title { get; private set; } + public string Description { get; private set; } + public string TicketType { get; set; } + public string Status { get; private set; } + public long SenderId { get; private set; } + public string ContractingPartyName { get; private set; } + public long? TaskId { get; private set; } + public List ClientResponses { get; set; } + public List AdminResponses{ get; set; } + public List TicketMedias { get; set; } + + public void Completed() + { + Status = "بسته شده"; + } + + public void Responded() + { + Status = "پاسخ داده شده"; + } +} \ No newline at end of file diff --git a/AccountManagement.Domain/TicketMediasAgg/TicketMedia.cs b/AccountManagement.Domain/TicketMediasAgg/TicketMedia.cs new file mode 100644 index 00000000..39f96a60 --- /dev/null +++ b/AccountManagement.Domain/TicketMediasAgg/TicketMedia.cs @@ -0,0 +1,19 @@ +using AccountManagement.Domain.MediaAgg; +using AccountManagement.Domain.TicketAgg; + +namespace AccountManagement.Domain.TicketMediasAgg; + +public class TicketMedia +{ + public TicketMedia(long ticketId, long mediaId) + { + TicketId = ticketId; + MediaId = mediaId; + } + + public long TicketId { get; set; } + public long MediaId { get; set; } + + public Ticket Ticket { get; set; } + public Media Media { get; set; } +} \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/AccountContext.cs b/AccountMangement.Infrastructure.EFCore/AccountContext.cs index 52fd7ff5..98762f3c 100644 --- a/AccountMangement.Infrastructure.EFCore/AccountContext.cs +++ b/AccountMangement.Infrastructure.EFCore/AccountContext.cs @@ -10,6 +10,12 @@ using AccountManagement.Domain.TaskAgg; using AccountManagement.Domain.TaskMediaAgg; using AccountManagement.Domain.TaskSubjectAgg; using TaskManager.Domain.PositionAgg; +using AccountManagement.Domain.AdminResponseAgg; +using AccountManagement.Domain.AdminResponseMediaAgg; +using AccountManagement.Domain.ClientResponseAgg; +using AccountManagement.Domain.ClientResponseMediaAgg; +using AccountManagement.Domain.TicketAgg; +using AccountManagement.Domain.TicketMediasAgg; namespace AccountMangement.Infrastructure.EFCore { @@ -29,6 +35,13 @@ namespace AccountMangement.Infrastructure.EFCore public DbSet TaskMedias { get; set; } public DbSet TaskSubjects { get; set; } + public DbSet AdminResponses { get; set; } + public DbSet AdminResponseMedias { get; set; } + public DbSet ClientResponses { get; set; } + public DbSet ClientResponseMedias { get; set; } + public DbSet Tickets { get; set; } + public DbSet TicketMedias { get; set; } + #endregion public AccountContext(DbContextOptions options) : base(options) { diff --git a/AccountMangement.Infrastructure.EFCore/Mappings/AdminResponseMapping.cs b/AccountMangement.Infrastructure.EFCore/Mappings/AdminResponseMapping.cs new file mode 100644 index 00000000..526b9872 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Mappings/AdminResponseMapping.cs @@ -0,0 +1,22 @@ +using AccountManagement.Domain.AdminResponseAgg; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace AccountMangement.Infrastructure.EFCore.Mappings; + +public class AdminResponseMapping : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("AdminResponses"); + builder.HasKey(x => x.id); + + + builder.Property(x => x.Response).HasColumnType("ntext"); + + + builder.HasMany(x => x.AdminResponseMedias).WithOne(x => x.AdminResponse).HasForeignKey(x => x.AdminResponseId); + builder.HasOne(x => x.Ticket).WithMany(x => x.AdminResponses).HasForeignKey(x => x.TicketId); + + } +} \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Mappings/AdminResponseMediaMapping.cs b/AccountMangement.Infrastructure.EFCore/Mappings/AdminResponseMediaMapping.cs new file mode 100644 index 00000000..61802fb6 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Mappings/AdminResponseMediaMapping.cs @@ -0,0 +1,18 @@ +using AccountManagement.Domain.AdminResponseMediaAgg; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + + +namespace AccountMangement.Infrastructure.EFCore.Mappings; + +public class AdminResponseMediaMapping:IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("AdminResponseMedias"); + builder.HasKey(x => new { x.AdminResponseId, x.MediaId }); + + builder.HasOne(x => x.Media).WithMany(x => x.AdminResponseMedias).HasForeignKey(x => x.MediaId); + builder.HasOne(x => x.AdminResponse).WithMany(x => x.AdminResponseMedias).HasForeignKey(x => x.AdminResponseId); + } +} \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Mappings/ClientResponseMapping.cs b/AccountMangement.Infrastructure.EFCore/Mappings/ClientResponseMapping.cs new file mode 100644 index 00000000..7fb29163 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Mappings/ClientResponseMapping.cs @@ -0,0 +1,20 @@ +using AccountManagement.Domain.ClientResponseAgg; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace AccountMangement.Infrastructure.EFCore.Mappings; +public class ClientResponseMapping:IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("ClientResponses"); + builder.HasKey(x => x.id); + + + builder.Property(x => x.Response).HasColumnType("ntext"); + + + builder.HasMany(x => x.ClientResponseMedias).WithOne(x => x.ClientResponse).HasForeignKey(x => x.ClientResponseId); + builder.HasOne(x => x.Ticket).WithMany(x => x.ClientResponses).HasForeignKey(x => x.TicketId); + } +} \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Mappings/ClientResponseMediaMapping.cs b/AccountMangement.Infrastructure.EFCore/Mappings/ClientResponseMediaMapping.cs new file mode 100644 index 00000000..29a49e35 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Mappings/ClientResponseMediaMapping.cs @@ -0,0 +1,18 @@ +using AccountManagement.Domain.ClientResponseMediaAgg; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + + +namespace AccountMangement.Infrastructure.EFCore.Mappings; + +public class ClientResponseMediaMapping:IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("ClientResponseMedias"); + builder.HasKey(x => new { x.ClientResponseId, x.MediaId }); + + builder.HasOne(x => x.Media).WithMany(x => x.ClientResponseMedias).HasForeignKey(x => x.MediaId); + builder.HasOne(x => x.ClientResponse).WithMany(x => x.ClientResponseMedias).HasForeignKey(x => x.ClientResponseId); + } +} \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Mappings/TaskMapping.cs b/AccountMangement.Infrastructure.EFCore/Mappings/TaskMapping.cs index 36ca9819..fc66ab7c 100644 --- a/AccountMangement.Infrastructure.EFCore/Mappings/TaskMapping.cs +++ b/AccountMangement.Infrastructure.EFCore/Mappings/TaskMapping.cs @@ -21,9 +21,10 @@ public class TaskMapping:IEntityTypeConfiguration builder.Property(x => x.IsActiveString).HasMaxLength(7); builder.Property(x => x.ContractingPartyName).HasMaxLength(200); builder.Property(x => x.DoneDescription).IsRequired(false).HasColumnType("ntext"); + builder.Property(x => x.TicketId).IsRequired(false); - builder.HasMany(x => x.Assigns).WithOne(x => x.Task).HasForeignKey(x => x.TaskId).IsRequired(false); + builder.HasMany(x => x.Assigns).WithOne(x => x.Task).HasForeignKey(x => x.TaskId).IsRequired(false).OnDelete(DeleteBehavior.Cascade); } } \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Mappings/TasksMediaMapping.cs b/AccountMangement.Infrastructure.EFCore/Mappings/TasksMediaMapping.cs index 505217df..93db0d97 100644 --- a/AccountMangement.Infrastructure.EFCore/Mappings/TasksMediaMapping.cs +++ b/AccountMangement.Infrastructure.EFCore/Mappings/TasksMediaMapping.cs @@ -10,7 +10,10 @@ public class TasksMediaMapping:IEntityTypeConfiguration builder.ToTable("TasksMedias"); builder.HasKey(x => new { x.MediaId, x.TaskId }); - builder.HasOne(x => x.Media).WithMany(x => x.TaskMedias).HasForeignKey(x => x.MediaId); - builder.HasOne(x => x.Tasks).WithMany(x => x.TaskMedias).HasForeignKey(x => x.TaskId); + builder.HasOne(x => x.Media).WithMany(x => x.TaskMedias) + .HasForeignKey(x => x.MediaId).OnDelete(DeleteBehavior.Cascade); + + builder.HasOne(x => x.Tasks).WithMany(x => x.TaskMedias) + .HasForeignKey(x => x.TaskId).OnDelete(DeleteBehavior.Cascade); } } \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Mappings/TicketMapping.cs b/AccountMangement.Infrastructure.EFCore/Mappings/TicketMapping.cs new file mode 100644 index 00000000..0ca34f93 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Mappings/TicketMapping.cs @@ -0,0 +1,29 @@ +using AccountManagement.Domain.TicketAgg; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + + +namespace AccountMangement.Infrastructure.EFCore.Mappings; + +public class TicketMapping:IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.HasKey(x => x.id); + builder.ToTable("Tickets"); + + + builder.Property(x => x.TaskId).IsRequired(false); + builder.Property(x => x.ContractingPartyName).HasMaxLength(155); + builder.Property(x => x.TicketType).HasMaxLength(50); + builder.Property(x => x.Title).HasMaxLength(200); + builder.Property(x => x.Description).HasColumnType("ntext"); + builder.Property(x => x.Status).HasMaxLength(30); + + + + builder.HasMany(x => x.ClientResponses).WithOne(x => x.Ticket).HasForeignKey(x => x.TicketId); + builder.HasMany(x => x.TicketMedias).WithOne(x => x.Ticket).HasForeignKey(x => x.MediaId); + builder.HasMany(x => x.AdminResponses).WithOne(x => x.Ticket).HasForeignKey(x => x.TicketId); + } +} \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Mappings/TicketMediasMapping.cs b/AccountMangement.Infrastructure.EFCore/Mappings/TicketMediasMapping.cs new file mode 100644 index 00000000..b909483a --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Mappings/TicketMediasMapping.cs @@ -0,0 +1,19 @@ +using AccountManagement.Domain.TicketMediasAgg; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + + +namespace AccountMangement.Infrastructure.EFCore.Mappings; + +public class TicketMediasMapping:IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("TicketMedias"); + builder.HasKey(x => new { x.TicketId, x.MediaId }); + + builder.HasOne(x => x.Media).WithMany(x => x.TicketMedias).HasForeignKey(x => x.MediaId); + builder.HasOne(x => x.Ticket).WithMany(x => x.TicketMedias).HasForeignKey(x => x.TicketId); + + } +} \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/20240701124238_setOnDeleteToCascadeInTaskTableWithAssign.Designer.cs b/AccountMangement.Infrastructure.EFCore/Migrations/20240701124238_setOnDeleteToCascadeInTaskTableWithAssign.Designer.cs new file mode 100644 index 00000000..3d9629f5 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Migrations/20240701124238_setOnDeleteToCascadeInTaskTableWithAssign.Designer.cs @@ -0,0 +1,484 @@ +// +using System; +using AccountMangement.Infrastructure.EFCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace AccountMangement.Infrastructure.EFCore.Migrations +{ + [DbContext(typeof(AccountContext))] + [Migration("20240701124238_setOnDeleteToCascadeInTaskTableWithAssign")] + partial class setOnDeleteToCascadeInTaskTableWithAssign + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AdminAreaPermission") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("ClientAriaPermission") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Fullname") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("IsActiveString") + .HasMaxLength(6) + .HasColumnType("nvarchar(6)"); + + b.Property("Mobile") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("NationalCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PositionId") + .HasMaxLength(10) + .HasColumnType("bigint"); + + b.Property("ProfilePhoto") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("RoleName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("VerifyCode") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.HasKey("id"); + + b.HasIndex("PositionId"); + + b.HasIndex("RoleId"); + + b.ToTable("Accounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AssignedId") + .HasColumnType("bigint"); + + b.Property("AssignedName") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("AssignedPositionValue") + .HasColumnType("int"); + + b.Property("AssignerId") + .HasColumnType("bigint"); + + b.Property("AssignerPositionValue") + .HasColumnType("int"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TaskId"); + + b.ToTable("Assigns", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.CameraAccountAgg.CameraAccount", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("IsActiveSting") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Mobile") + .HasMaxLength(11) + .HasColumnType("nvarchar(11)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("WorkshopId") + .HasColumnType("bigint"); + + b.Property("WorkshopName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.HasIndex("AccountId"); + + b.ToTable("CameraAccounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.MediaAgg.Media", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Category") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Path") + .HasColumnType("ntext"); + + b.Property("Type") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("id"); + + b.ToTable("Medias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("Roles", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AcceptedTimeRequest") + .HasColumnType("int"); + + b.Property("CancelDescription") + .HasColumnType("ntext"); + + b.Property("ContractingPartyName") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("ntext"); + + b.Property("DoneDescription") + .HasColumnType("ntext"); + + b.Property("EndTaskDate") + .HasColumnType("datetime2"); + + b.Property("IsActiveString") + .HasMaxLength(7) + .HasColumnType("nvarchar(7)"); + + b.Property("IsCancel") + .HasColumnType("bit"); + + b.Property("IsCanceledRequest") + .HasColumnType("bit"); + + b.Property("IsDone") + .HasColumnType("bit"); + + b.Property("RequestDate") + .HasColumnType("datetime2"); + + b.Property("SenderId") + .HasColumnType("bigint"); + + b.Property("StartTaskDate") + .HasColumnType("datetime2"); + + b.Property("TimeRequest") + .HasColumnType("bit"); + + b.Property("TimeRequestDescription") + .HasColumnType("ntext"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("TasksManager", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMediaAgg.TaskMedia", b => + { + b.Property("MediaId") + .HasColumnType("bigint"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.HasKey("MediaId", "TaskId"); + + b.HasIndex("TaskId"); + + b.ToTable("TasksMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskSubjectAgg.TaskSubject", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Subject") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("TaskSubjects", (string)null); + }); + + modelBuilder.Entity("TaskManager.Domain.PositionAgg.Position", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("PositionName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("PositionValue") + .HasMaxLength(2) + .HasColumnType("int"); + + b.HasKey("id"); + + b.ToTable("Positions", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.HasOne("TaskManager.Domain.PositionAgg.Position", "Position") + .WithMany("Accounts") + .HasForeignKey("PositionId"); + + b.HasOne("AccountManagement.Domain.RoleAgg.Role", "Role") + .WithMany("Accounts") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Position"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.HasOne("AccountManagement.Domain.TaskAgg.Tasks", "Task") + .WithMany("Assigns") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("AccountManagement.Domain.CameraAccountAgg.CameraAccount", b => + { + b.HasOne("AccountManagement.Domain.AccountAgg.Account", "Account") + .WithMany("CameraAccounts") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.OwnsMany("AccountManagement.Domain.RoleAgg.Permission", "Permissions", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("Code") + .HasColumnType("int"); + + b1.Property("RoleId") + .HasColumnType("bigint"); + + b1.HasKey("Id"); + + b1.HasIndex("RoleId"); + + b1.ToTable("RolePermissions", (string)null); + + b1.WithOwner("Role") + .HasForeignKey("RoleId"); + + b1.Navigation("Role"); + }); + + b.Navigation("Permissions"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMediaAgg.TaskMedia", b => + { + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("TaskMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.TaskAgg.Tasks", "Tasks") + .WithMany("TaskMedias") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Media"); + + b.Navigation("Tasks"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.Navigation("CameraAccounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.MediaAgg.Media", b => + { + b.Navigation("TaskMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.Navigation("Accounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.Navigation("Assigns"); + + b.Navigation("TaskMedias"); + }); + + modelBuilder.Entity("TaskManager.Domain.PositionAgg.Position", b => + { + b.Navigation("Accounts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/20240701124238_setOnDeleteToCascadeInTaskTableWithAssign.cs b/AccountMangement.Infrastructure.EFCore/Migrations/20240701124238_setOnDeleteToCascadeInTaskTableWithAssign.cs new file mode 100644 index 00000000..bc98acf7 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Migrations/20240701124238_setOnDeleteToCascadeInTaskTableWithAssign.cs @@ -0,0 +1,41 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace AccountMangement.Infrastructure.EFCore.Migrations +{ + /// + public partial class setOnDeleteToCascadeInTaskTableWithAssign : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Assigns_TasksManager_TaskId", + table: "Assigns"); + + migrationBuilder.AddForeignKey( + name: "FK_Assigns_TasksManager_TaskId", + table: "Assigns", + column: "TaskId", + principalTable: "TasksManager", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Assigns_TasksManager_TaskId", + table: "Assigns"); + + migrationBuilder.AddForeignKey( + name: "FK_Assigns_TasksManager_TaskId", + table: "Assigns", + column: "TaskId", + principalTable: "TasksManager", + principalColumn: "id"); + } + } +} diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/20240702162847_InitialTicket.Designer.cs b/AccountMangement.Infrastructure.EFCore/Migrations/20240702162847_InitialTicket.Designer.cs new file mode 100644 index 00000000..22be46b0 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Migrations/20240702162847_InitialTicket.Designer.cs @@ -0,0 +1,725 @@ +// +using System; +using AccountMangement.Infrastructure.EFCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace AccountMangement.Infrastructure.EFCore.Migrations +{ + [DbContext(typeof(AccountContext))] + [Migration("20240702162847_InitialTicket")] + partial class InitialTicket + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AdminAreaPermission") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("ClientAriaPermission") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Fullname") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("IsActiveString") + .HasMaxLength(6) + .HasColumnType("nvarchar(6)"); + + b.Property("Mobile") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("NationalCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PositionId") + .HasMaxLength(10) + .HasColumnType("bigint"); + + b.Property("ProfilePhoto") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("RoleName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("VerifyCode") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.HasKey("id"); + + b.HasIndex("PositionId"); + + b.HasIndex("RoleId"); + + b.ToTable("Accounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Response") + .HasColumnType("ntext"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TicketId"); + + b.ToTable("AdminResponses", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseMediaAgg.AdminResponseMedia", b => + { + b.Property("AdminResponseId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("AdminResponseId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("AdminResponseMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AssignedId") + .HasColumnType("bigint"); + + b.Property("AssignedName") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("AssignedPositionValue") + .HasColumnType("int"); + + b.Property("AssignerId") + .HasColumnType("bigint"); + + b.Property("AssignerPositionValue") + .HasColumnType("int"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TaskId"); + + b.ToTable("Assigns", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.CameraAccountAgg.CameraAccount", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("IsActiveSting") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Mobile") + .HasMaxLength(11) + .HasColumnType("nvarchar(11)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("WorkshopId") + .HasColumnType("bigint"); + + b.Property("WorkshopName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.HasIndex("AccountId"); + + b.ToTable("CameraAccounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Response") + .HasColumnType("ntext"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TicketId"); + + b.ToTable("ClientResponses", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseMediaAgg.ClientResponseMedia", b => + { + b.Property("ClientResponseId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("ClientResponseId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("ClientResponseMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.MediaAgg.Media", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Category") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Path") + .HasColumnType("ntext"); + + b.Property("Type") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("id"); + + b.ToTable("Medias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("Roles", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AcceptedTimeRequest") + .HasColumnType("int"); + + b.Property("CancelDescription") + .HasColumnType("ntext"); + + b.Property("ContractingPartyName") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("ntext"); + + b.Property("DoneDescription") + .HasColumnType("ntext"); + + b.Property("EndTaskDate") + .HasColumnType("datetime2"); + + b.Property("IsActiveString") + .HasMaxLength(7) + .HasColumnType("nvarchar(7)"); + + b.Property("IsCancel") + .HasColumnType("bit"); + + b.Property("IsCanceledRequest") + .HasColumnType("bit"); + + b.Property("IsDone") + .HasColumnType("bit"); + + b.Property("RequestDate") + .HasColumnType("datetime2"); + + b.Property("SenderId") + .HasColumnType("bigint"); + + b.Property("StartTaskDate") + .HasColumnType("datetime2"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TimeRequest") + .HasColumnType("bit"); + + b.Property("TimeRequestDescription") + .HasColumnType("ntext"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("TasksManager", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMediaAgg.TaskMedia", b => + { + b.Property("MediaId") + .HasColumnType("bigint"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.HasKey("MediaId", "TaskId"); + + b.HasIndex("TaskId"); + + b.ToTable("TasksMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskSubjectAgg.TaskSubject", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Subject") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("TaskSubjects", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketAgg.Ticket", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("ContractingPartyName") + .HasMaxLength(155) + .HasColumnType("nvarchar(155)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("ntext"); + + b.Property("SenderId") + .HasColumnType("bigint"); + + b.Property("Status") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.Property("TicketType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("id"); + + b.ToTable("Tickets", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketMediasAgg.TicketMedia", b => + { + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("TicketId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("TicketMedias", (string)null); + }); + + modelBuilder.Entity("TaskManager.Domain.PositionAgg.Position", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("PositionName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("PositionValue") + .HasMaxLength(2) + .HasColumnType("int"); + + b.HasKey("id"); + + b.ToTable("Positions", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.HasOne("TaskManager.Domain.PositionAgg.Position", "Position") + .WithMany("Accounts") + .HasForeignKey("PositionId"); + + b.HasOne("AccountManagement.Domain.RoleAgg.Role", "Role") + .WithMany("Accounts") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Position"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("AdminResponses") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseMediaAgg.AdminResponseMedia", b => + { + b.HasOne("AccountManagement.Domain.AdminResponseAgg.AdminResponse", "AdminResponse") + .WithMany("AdminResponseMedias") + .HasForeignKey("AdminResponseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("AdminResponseMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AdminResponse"); + + b.Navigation("Media"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.HasOne("AccountManagement.Domain.TaskAgg.Tasks", "Task") + .WithMany("Assigns") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("AccountManagement.Domain.CameraAccountAgg.CameraAccount", b => + { + b.HasOne("AccountManagement.Domain.AccountAgg.Account", "Account") + .WithMany("CameraAccounts") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("ClientResponses") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseMediaAgg.ClientResponseMedia", b => + { + b.HasOne("AccountManagement.Domain.ClientResponseAgg.ClientResponse", "ClientResponse") + .WithMany("ClientResponseMedias") + .HasForeignKey("ClientResponseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("ClientResponseMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ClientResponse"); + + b.Navigation("Media"); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.OwnsMany("AccountManagement.Domain.RoleAgg.Permission", "Permissions", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("Code") + .HasColumnType("int"); + + b1.Property("RoleId") + .HasColumnType("bigint"); + + b1.HasKey("Id"); + + b1.HasIndex("RoleId"); + + b1.ToTable("RolePermissions", (string)null); + + b1.WithOwner("Role") + .HasForeignKey("RoleId"); + + b1.Navigation("Role"); + }); + + b.Navigation("Permissions"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMediaAgg.TaskMedia", b => + { + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("TaskMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.TaskAgg.Tasks", "Tasks") + .WithMany("TaskMedias") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Media"); + + b.Navigation("Tasks"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketMediasAgg.TicketMedia", b => + { + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("TicketMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("TicketMedias") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Media"); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.Navigation("CameraAccounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.Navigation("AdminResponseMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.Navigation("ClientResponseMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.MediaAgg.Media", b => + { + b.Navigation("AdminResponseMedias"); + + b.Navigation("ClientResponseMedias"); + + b.Navigation("TaskMedias"); + + b.Navigation("TicketMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.Navigation("Accounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.Navigation("Assigns"); + + b.Navigation("TaskMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketAgg.Ticket", b => + { + b.Navigation("AdminResponses"); + + b.Navigation("ClientResponses"); + + b.Navigation("TicketMedias"); + }); + + modelBuilder.Entity("TaskManager.Domain.PositionAgg.Position", b => + { + b.Navigation("Accounts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/20240702162847_InitialTicket.cs b/AccountMangement.Infrastructure.EFCore/Migrations/20240702162847_InitialTicket.cs new file mode 100644 index 00000000..3ce15bc9 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Migrations/20240702162847_InitialTicket.cs @@ -0,0 +1,206 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace AccountMangement.Infrastructure.EFCore.Migrations +{ + /// + public partial class InitialTicket : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "TicketId", + table: "TasksManager", + type: "bigint", + nullable: true); + + migrationBuilder.CreateTable( + name: "Tickets", + columns: table => new + { + id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Title = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + Description = table.Column(type: "ntext", nullable: true), + TicketType = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), + Status = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: true), + SenderId = table.Column(type: "bigint", nullable: false), + ContractingPartyName = table.Column(type: "nvarchar(155)", maxLength: 155, nullable: true), + TaskId = table.Column(type: "bigint", nullable: true), + CreationDate = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Tickets", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "AdminResponses", + columns: table => new + { + id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + TicketId = table.Column(type: "bigint", nullable: false), + Response = table.Column(type: "ntext", nullable: true), + CreationDate = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AdminResponses", x => x.id); + table.ForeignKey( + name: "FK_AdminResponses_Tickets_TicketId", + column: x => x.TicketId, + principalTable: "Tickets", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ClientResponses", + columns: table => new + { + id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + TicketId = table.Column(type: "bigint", nullable: false), + Response = table.Column(type: "ntext", nullable: true), + CreationDate = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ClientResponses", x => x.id); + table.ForeignKey( + name: "FK_ClientResponses_Tickets_TicketId", + column: x => x.TicketId, + principalTable: "Tickets", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "TicketMedias", + columns: table => new + { + TicketId = table.Column(type: "bigint", nullable: false), + MediaId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TicketMedias", x => new { x.TicketId, x.MediaId }); + table.ForeignKey( + name: "FK_TicketMedias_Medias_MediaId", + column: x => x.MediaId, + principalTable: "Medias", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_TicketMedias_Tickets_TicketId", + column: x => x.TicketId, + principalTable: "Tickets", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AdminResponseMedias", + columns: table => new + { + AdminResponseId = table.Column(type: "bigint", nullable: false), + MediaId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AdminResponseMedias", x => new { x.AdminResponseId, x.MediaId }); + table.ForeignKey( + name: "FK_AdminResponseMedias_AdminResponses_AdminResponseId", + column: x => x.AdminResponseId, + principalTable: "AdminResponses", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AdminResponseMedias_Medias_MediaId", + column: x => x.MediaId, + principalTable: "Medias", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ClientResponseMedias", + columns: table => new + { + ClientResponseId = table.Column(type: "bigint", nullable: false), + MediaId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ClientResponseMedias", x => new { x.ClientResponseId, x.MediaId }); + table.ForeignKey( + name: "FK_ClientResponseMedias_ClientResponses_ClientResponseId", + column: x => x.ClientResponseId, + principalTable: "ClientResponses", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ClientResponseMedias_Medias_MediaId", + column: x => x.MediaId, + principalTable: "Medias", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AdminResponseMedias_MediaId", + table: "AdminResponseMedias", + column: "MediaId"); + + migrationBuilder.CreateIndex( + name: "IX_AdminResponses_TicketId", + table: "AdminResponses", + column: "TicketId"); + + migrationBuilder.CreateIndex( + name: "IX_ClientResponseMedias_MediaId", + table: "ClientResponseMedias", + column: "MediaId"); + + migrationBuilder.CreateIndex( + name: "IX_ClientResponses_TicketId", + table: "ClientResponses", + column: "TicketId"); + + migrationBuilder.CreateIndex( + name: "IX_TicketMedias_MediaId", + table: "TicketMedias", + column: "MediaId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AdminResponseMedias"); + + migrationBuilder.DropTable( + name: "ClientResponseMedias"); + + migrationBuilder.DropTable( + name: "TicketMedias"); + + migrationBuilder.DropTable( + name: "AdminResponses"); + + migrationBuilder.DropTable( + name: "ClientResponses"); + + migrationBuilder.DropTable( + name: "Tickets"); + + migrationBuilder.DropColumn( + name: "TicketId", + table: "TasksManager"); + } + } +} diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/20240702165608_EditTaskMapping.Designer.cs b/AccountMangement.Infrastructure.EFCore/Migrations/20240702165608_EditTaskMapping.Designer.cs new file mode 100644 index 00000000..8cb708f6 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Migrations/20240702165608_EditTaskMapping.Designer.cs @@ -0,0 +1,725 @@ +// +using System; +using AccountMangement.Infrastructure.EFCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace AccountMangement.Infrastructure.EFCore.Migrations +{ + [DbContext(typeof(AccountContext))] + [Migration("20240702165608_EditTaskMapping")] + partial class EditTaskMapping + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AdminAreaPermission") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("ClientAriaPermission") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Fullname") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("IsActiveString") + .HasMaxLength(6) + .HasColumnType("nvarchar(6)"); + + b.Property("Mobile") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("NationalCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PositionId") + .HasMaxLength(10) + .HasColumnType("bigint"); + + b.Property("ProfilePhoto") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("RoleName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("VerifyCode") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.HasKey("id"); + + b.HasIndex("PositionId"); + + b.HasIndex("RoleId"); + + b.ToTable("Accounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Response") + .HasColumnType("ntext"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TicketId"); + + b.ToTable("AdminResponses", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseMediaAgg.AdminResponseMedia", b => + { + b.Property("AdminResponseId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("AdminResponseId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("AdminResponseMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AssignedId") + .HasColumnType("bigint"); + + b.Property("AssignedName") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("AssignedPositionValue") + .HasColumnType("int"); + + b.Property("AssignerId") + .HasColumnType("bigint"); + + b.Property("AssignerPositionValue") + .HasColumnType("int"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TaskId"); + + b.ToTable("Assigns", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.CameraAccountAgg.CameraAccount", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("IsActiveSting") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Mobile") + .HasMaxLength(11) + .HasColumnType("nvarchar(11)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("WorkshopId") + .HasColumnType("bigint"); + + b.Property("WorkshopName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.HasIndex("AccountId"); + + b.ToTable("CameraAccounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Response") + .HasColumnType("ntext"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TicketId"); + + b.ToTable("ClientResponses", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseMediaAgg.ClientResponseMedia", b => + { + b.Property("ClientResponseId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("ClientResponseId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("ClientResponseMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.MediaAgg.Media", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Category") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Path") + .HasColumnType("ntext"); + + b.Property("Type") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("id"); + + b.ToTable("Medias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("Roles", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AcceptedTimeRequest") + .HasColumnType("int"); + + b.Property("CancelDescription") + .HasColumnType("ntext"); + + b.Property("ContractingPartyName") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("ntext"); + + b.Property("DoneDescription") + .HasColumnType("ntext"); + + b.Property("EndTaskDate") + .HasColumnType("datetime2"); + + b.Property("IsActiveString") + .HasMaxLength(7) + .HasColumnType("nvarchar(7)"); + + b.Property("IsCancel") + .HasColumnType("bit"); + + b.Property("IsCanceledRequest") + .HasColumnType("bit"); + + b.Property("IsDone") + .HasColumnType("bit"); + + b.Property("RequestDate") + .HasColumnType("datetime2"); + + b.Property("SenderId") + .HasColumnType("bigint"); + + b.Property("StartTaskDate") + .HasColumnType("datetime2"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TimeRequest") + .HasColumnType("bit"); + + b.Property("TimeRequestDescription") + .HasColumnType("ntext"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("TasksManager", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMediaAgg.TaskMedia", b => + { + b.Property("MediaId") + .HasColumnType("bigint"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.HasKey("MediaId", "TaskId"); + + b.HasIndex("TaskId"); + + b.ToTable("TasksMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskSubjectAgg.TaskSubject", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Subject") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("TaskSubjects", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketAgg.Ticket", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("ContractingPartyName") + .HasMaxLength(155) + .HasColumnType("nvarchar(155)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("ntext"); + + b.Property("SenderId") + .HasColumnType("bigint"); + + b.Property("Status") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.Property("TicketType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("id"); + + b.ToTable("Tickets", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketMediasAgg.TicketMedia", b => + { + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("TicketId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("TicketMedias", (string)null); + }); + + modelBuilder.Entity("TaskManager.Domain.PositionAgg.Position", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("PositionName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("PositionValue") + .HasMaxLength(2) + .HasColumnType("int"); + + b.HasKey("id"); + + b.ToTable("Positions", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.HasOne("TaskManager.Domain.PositionAgg.Position", "Position") + .WithMany("Accounts") + .HasForeignKey("PositionId"); + + b.HasOne("AccountManagement.Domain.RoleAgg.Role", "Role") + .WithMany("Accounts") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Position"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("AdminResponses") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseMediaAgg.AdminResponseMedia", b => + { + b.HasOne("AccountManagement.Domain.AdminResponseAgg.AdminResponse", "AdminResponse") + .WithMany("AdminResponseMedias") + .HasForeignKey("AdminResponseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("AdminResponseMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AdminResponse"); + + b.Navigation("Media"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.HasOne("AccountManagement.Domain.TaskAgg.Tasks", "Task") + .WithMany("Assigns") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("AccountManagement.Domain.CameraAccountAgg.CameraAccount", b => + { + b.HasOne("AccountManagement.Domain.AccountAgg.Account", "Account") + .WithMany("CameraAccounts") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("ClientResponses") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseMediaAgg.ClientResponseMedia", b => + { + b.HasOne("AccountManagement.Domain.ClientResponseAgg.ClientResponse", "ClientResponse") + .WithMany("ClientResponseMedias") + .HasForeignKey("ClientResponseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("ClientResponseMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ClientResponse"); + + b.Navigation("Media"); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.OwnsMany("AccountManagement.Domain.RoleAgg.Permission", "Permissions", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("Code") + .HasColumnType("int"); + + b1.Property("RoleId") + .HasColumnType("bigint"); + + b1.HasKey("Id"); + + b1.HasIndex("RoleId"); + + b1.ToTable("RolePermissions", (string)null); + + b1.WithOwner("Role") + .HasForeignKey("RoleId"); + + b1.Navigation("Role"); + }); + + b.Navigation("Permissions"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMediaAgg.TaskMedia", b => + { + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("TaskMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.TaskAgg.Tasks", "Tasks") + .WithMany("TaskMedias") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Media"); + + b.Navigation("Tasks"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketMediasAgg.TicketMedia", b => + { + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("TicketMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("TicketMedias") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Media"); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.Navigation("CameraAccounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.Navigation("AdminResponseMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.Navigation("ClientResponseMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.MediaAgg.Media", b => + { + b.Navigation("AdminResponseMedias"); + + b.Navigation("ClientResponseMedias"); + + b.Navigation("TaskMedias"); + + b.Navigation("TicketMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.Navigation("Accounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.Navigation("Assigns"); + + b.Navigation("TaskMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketAgg.Ticket", b => + { + b.Navigation("AdminResponses"); + + b.Navigation("ClientResponses"); + + b.Navigation("TicketMedias"); + }); + + modelBuilder.Entity("TaskManager.Domain.PositionAgg.Position", b => + { + b.Navigation("Accounts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/20240702165608_EditTaskMapping.cs b/AccountMangement.Infrastructure.EFCore/Migrations/20240702165608_EditTaskMapping.cs new file mode 100644 index 00000000..3f98a4c6 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Migrations/20240702165608_EditTaskMapping.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace AccountMangement.Infrastructure.EFCore.Migrations +{ + /// + public partial class EditTaskMapping : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/20240703103641_SetOnDeleteToCascadeInTaskMediaTable.Designer.cs b/AccountMangement.Infrastructure.EFCore/Migrations/20240703103641_SetOnDeleteToCascadeInTaskMediaTable.Designer.cs new file mode 100644 index 00000000..72bd53c9 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Migrations/20240703103641_SetOnDeleteToCascadeInTaskMediaTable.Designer.cs @@ -0,0 +1,725 @@ +// +using System; +using AccountMangement.Infrastructure.EFCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace AccountMangement.Infrastructure.EFCore.Migrations +{ + [DbContext(typeof(AccountContext))] + [Migration("20240703103641_SetOnDeleteToCascadeInTaskMediaTable")] + partial class SetOnDeleteToCascadeInTaskMediaTable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AdminAreaPermission") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("ClientAriaPermission") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Fullname") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("IsActiveString") + .HasMaxLength(6) + .HasColumnType("nvarchar(6)"); + + b.Property("Mobile") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("NationalCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PositionId") + .HasMaxLength(10) + .HasColumnType("bigint"); + + b.Property("ProfilePhoto") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("RoleName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("VerifyCode") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.HasKey("id"); + + b.HasIndex("PositionId"); + + b.HasIndex("RoleId"); + + b.ToTable("Accounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Response") + .HasColumnType("ntext"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TicketId"); + + b.ToTable("AdminResponses", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseMediaAgg.AdminResponseMedia", b => + { + b.Property("AdminResponseId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("AdminResponseId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("AdminResponseMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AssignedId") + .HasColumnType("bigint"); + + b.Property("AssignedName") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("AssignedPositionValue") + .HasColumnType("int"); + + b.Property("AssignerId") + .HasColumnType("bigint"); + + b.Property("AssignerPositionValue") + .HasColumnType("int"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TaskId"); + + b.ToTable("Assigns", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.CameraAccountAgg.CameraAccount", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("IsActiveSting") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Mobile") + .HasMaxLength(11) + .HasColumnType("nvarchar(11)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("WorkshopId") + .HasColumnType("bigint"); + + b.Property("WorkshopName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.HasIndex("AccountId"); + + b.ToTable("CameraAccounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Response") + .HasColumnType("ntext"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TicketId"); + + b.ToTable("ClientResponses", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseMediaAgg.ClientResponseMedia", b => + { + b.Property("ClientResponseId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("ClientResponseId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("ClientResponseMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.MediaAgg.Media", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Category") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Path") + .HasColumnType("ntext"); + + b.Property("Type") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("id"); + + b.ToTable("Medias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("Roles", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AcceptedTimeRequest") + .HasColumnType("int"); + + b.Property("CancelDescription") + .HasColumnType("ntext"); + + b.Property("ContractingPartyName") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("ntext"); + + b.Property("DoneDescription") + .HasColumnType("ntext"); + + b.Property("EndTaskDate") + .HasColumnType("datetime2"); + + b.Property("IsActiveString") + .HasMaxLength(7) + .HasColumnType("nvarchar(7)"); + + b.Property("IsCancel") + .HasColumnType("bit"); + + b.Property("IsCanceledRequest") + .HasColumnType("bit"); + + b.Property("IsDone") + .HasColumnType("bit"); + + b.Property("RequestDate") + .HasColumnType("datetime2"); + + b.Property("SenderId") + .HasColumnType("bigint"); + + b.Property("StartTaskDate") + .HasColumnType("datetime2"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TimeRequest") + .HasColumnType("bit"); + + b.Property("TimeRequestDescription") + .HasColumnType("ntext"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("TasksManager", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMediaAgg.TaskMedia", b => + { + b.Property("MediaId") + .HasColumnType("bigint"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.HasKey("MediaId", "TaskId"); + + b.HasIndex("TaskId"); + + b.ToTable("TasksMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskSubjectAgg.TaskSubject", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Subject") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("TaskSubjects", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketAgg.Ticket", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("ContractingPartyName") + .HasMaxLength(155) + .HasColumnType("nvarchar(155)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("ntext"); + + b.Property("SenderId") + .HasColumnType("bigint"); + + b.Property("Status") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.Property("TicketType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("id"); + + b.ToTable("Tickets", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketMediasAgg.TicketMedia", b => + { + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("TicketId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("TicketMedias", (string)null); + }); + + modelBuilder.Entity("TaskManager.Domain.PositionAgg.Position", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("PositionName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("PositionValue") + .HasMaxLength(2) + .HasColumnType("int"); + + b.HasKey("id"); + + b.ToTable("Positions", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.HasOne("TaskManager.Domain.PositionAgg.Position", "Position") + .WithMany("Accounts") + .HasForeignKey("PositionId"); + + b.HasOne("AccountManagement.Domain.RoleAgg.Role", "Role") + .WithMany("Accounts") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Position"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("AdminResponses") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseMediaAgg.AdminResponseMedia", b => + { + b.HasOne("AccountManagement.Domain.AdminResponseAgg.AdminResponse", "AdminResponse") + .WithMany("AdminResponseMedias") + .HasForeignKey("AdminResponseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("AdminResponseMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AdminResponse"); + + b.Navigation("Media"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.HasOne("AccountManagement.Domain.TaskAgg.Tasks", "Task") + .WithMany("Assigns") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("AccountManagement.Domain.CameraAccountAgg.CameraAccount", b => + { + b.HasOne("AccountManagement.Domain.AccountAgg.Account", "Account") + .WithMany("CameraAccounts") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("ClientResponses") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseMediaAgg.ClientResponseMedia", b => + { + b.HasOne("AccountManagement.Domain.ClientResponseAgg.ClientResponse", "ClientResponse") + .WithMany("ClientResponseMedias") + .HasForeignKey("ClientResponseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("ClientResponseMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ClientResponse"); + + b.Navigation("Media"); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.OwnsMany("AccountManagement.Domain.RoleAgg.Permission", "Permissions", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("Code") + .HasColumnType("int"); + + b1.Property("RoleId") + .HasColumnType("bigint"); + + b1.HasKey("Id"); + + b1.HasIndex("RoleId"); + + b1.ToTable("RolePermissions", (string)null); + + b1.WithOwner("Role") + .HasForeignKey("RoleId"); + + b1.Navigation("Role"); + }); + + b.Navigation("Permissions"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMediaAgg.TaskMedia", b => + { + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("TaskMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.TaskAgg.Tasks", "Tasks") + .WithMany("TaskMedias") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Media"); + + b.Navigation("Tasks"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketMediasAgg.TicketMedia", b => + { + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("TicketMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("TicketMedias") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Media"); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.Navigation("CameraAccounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.Navigation("AdminResponseMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.Navigation("ClientResponseMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.MediaAgg.Media", b => + { + b.Navigation("AdminResponseMedias"); + + b.Navigation("ClientResponseMedias"); + + b.Navigation("TaskMedias"); + + b.Navigation("TicketMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.Navigation("Accounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.Navigation("Assigns"); + + b.Navigation("TaskMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketAgg.Ticket", b => + { + b.Navigation("AdminResponses"); + + b.Navigation("ClientResponses"); + + b.Navigation("TicketMedias"); + }); + + modelBuilder.Entity("TaskManager.Domain.PositionAgg.Position", b => + { + b.Navigation("Accounts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/20240703103641_SetOnDeleteToCascadeInTaskMediaTable.cs b/AccountMangement.Infrastructure.EFCore/Migrations/20240703103641_SetOnDeleteToCascadeInTaskMediaTable.cs new file mode 100644 index 00000000..6b558692 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Migrations/20240703103641_SetOnDeleteToCascadeInTaskMediaTable.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace AccountMangement.Infrastructure.EFCore.Migrations +{ + /// + public partial class SetOnDeleteToCascadeInTaskMediaTable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/20240704073907_AddIsDoneRequestToTaskManagerTable.Designer.cs b/AccountMangement.Infrastructure.EFCore/Migrations/20240704073907_AddIsDoneRequestToTaskManagerTable.Designer.cs new file mode 100644 index 00000000..96440b4c --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Migrations/20240704073907_AddIsDoneRequestToTaskManagerTable.Designer.cs @@ -0,0 +1,728 @@ +// +using System; +using AccountMangement.Infrastructure.EFCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace AccountMangement.Infrastructure.EFCore.Migrations +{ + [DbContext(typeof(AccountContext))] + [Migration("20240704073907_AddIsDoneRequestToTaskManagerTable")] + partial class AddIsDoneRequestToTaskManagerTable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AdminAreaPermission") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("ClientAriaPermission") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Fullname") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("IsActiveString") + .HasMaxLength(6) + .HasColumnType("nvarchar(6)"); + + b.Property("Mobile") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("NationalCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PositionId") + .HasMaxLength(10) + .HasColumnType("bigint"); + + b.Property("ProfilePhoto") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("RoleName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("VerifyCode") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.HasKey("id"); + + b.HasIndex("PositionId"); + + b.HasIndex("RoleId"); + + b.ToTable("Accounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Response") + .HasColumnType("ntext"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TicketId"); + + b.ToTable("AdminResponses", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseMediaAgg.AdminResponseMedia", b => + { + b.Property("AdminResponseId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("AdminResponseId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("AdminResponseMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AssignedId") + .HasColumnType("bigint"); + + b.Property("AssignedName") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("AssignedPositionValue") + .HasColumnType("int"); + + b.Property("AssignerId") + .HasColumnType("bigint"); + + b.Property("AssignerPositionValue") + .HasColumnType("int"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TaskId"); + + b.ToTable("Assigns", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.CameraAccountAgg.CameraAccount", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("IsActiveSting") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Mobile") + .HasMaxLength(11) + .HasColumnType("nvarchar(11)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("WorkshopId") + .HasColumnType("bigint"); + + b.Property("WorkshopName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.HasIndex("AccountId"); + + b.ToTable("CameraAccounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Response") + .HasColumnType("ntext"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TicketId"); + + b.ToTable("ClientResponses", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseMediaAgg.ClientResponseMedia", b => + { + b.Property("ClientResponseId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("ClientResponseId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("ClientResponseMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.MediaAgg.Media", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Category") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Path") + .HasColumnType("ntext"); + + b.Property("Type") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("id"); + + b.ToTable("Medias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("Roles", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AcceptedTimeRequest") + .HasColumnType("int"); + + b.Property("CancelDescription") + .HasColumnType("ntext"); + + b.Property("ContractingPartyName") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("ntext"); + + b.Property("DoneDescription") + .HasColumnType("ntext"); + + b.Property("EndTaskDate") + .HasColumnType("datetime2"); + + b.Property("IsActiveString") + .HasMaxLength(7) + .HasColumnType("nvarchar(7)"); + + b.Property("IsCancel") + .HasColumnType("bit"); + + b.Property("IsCanceledRequest") + .HasColumnType("bit"); + + b.Property("IsDone") + .HasColumnType("bit"); + + b.Property("IsDoneRequest") + .HasColumnType("bit"); + + b.Property("RequestDate") + .HasColumnType("datetime2"); + + b.Property("SenderId") + .HasColumnType("bigint"); + + b.Property("StartTaskDate") + .HasColumnType("datetime2"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TimeRequest") + .HasColumnType("bit"); + + b.Property("TimeRequestDescription") + .HasColumnType("ntext"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("TasksManager", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMediaAgg.TaskMedia", b => + { + b.Property("MediaId") + .HasColumnType("bigint"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.HasKey("MediaId", "TaskId"); + + b.HasIndex("TaskId"); + + b.ToTable("TasksMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskSubjectAgg.TaskSubject", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Subject") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("TaskSubjects", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketAgg.Ticket", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("ContractingPartyName") + .HasMaxLength(155) + .HasColumnType("nvarchar(155)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("ntext"); + + b.Property("SenderId") + .HasColumnType("bigint"); + + b.Property("Status") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.Property("TicketType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("id"); + + b.ToTable("Tickets", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketMediasAgg.TicketMedia", b => + { + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("TicketId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("TicketMedias", (string)null); + }); + + modelBuilder.Entity("TaskManager.Domain.PositionAgg.Position", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("PositionName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("PositionValue") + .HasMaxLength(2) + .HasColumnType("int"); + + b.HasKey("id"); + + b.ToTable("Positions", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.HasOne("TaskManager.Domain.PositionAgg.Position", "Position") + .WithMany("Accounts") + .HasForeignKey("PositionId"); + + b.HasOne("AccountManagement.Domain.RoleAgg.Role", "Role") + .WithMany("Accounts") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Position"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("AdminResponses") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseMediaAgg.AdminResponseMedia", b => + { + b.HasOne("AccountManagement.Domain.AdminResponseAgg.AdminResponse", "AdminResponse") + .WithMany("AdminResponseMedias") + .HasForeignKey("AdminResponseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("AdminResponseMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AdminResponse"); + + b.Navigation("Media"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.HasOne("AccountManagement.Domain.TaskAgg.Tasks", "Task") + .WithMany("Assigns") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("AccountManagement.Domain.CameraAccountAgg.CameraAccount", b => + { + b.HasOne("AccountManagement.Domain.AccountAgg.Account", "Account") + .WithMany("CameraAccounts") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("ClientResponses") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseMediaAgg.ClientResponseMedia", b => + { + b.HasOne("AccountManagement.Domain.ClientResponseAgg.ClientResponse", "ClientResponse") + .WithMany("ClientResponseMedias") + .HasForeignKey("ClientResponseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("ClientResponseMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ClientResponse"); + + b.Navigation("Media"); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.OwnsMany("AccountManagement.Domain.RoleAgg.Permission", "Permissions", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("Code") + .HasColumnType("int"); + + b1.Property("RoleId") + .HasColumnType("bigint"); + + b1.HasKey("Id"); + + b1.HasIndex("RoleId"); + + b1.ToTable("RolePermissions", (string)null); + + b1.WithOwner("Role") + .HasForeignKey("RoleId"); + + b1.Navigation("Role"); + }); + + b.Navigation("Permissions"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMediaAgg.TaskMedia", b => + { + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("TaskMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.TaskAgg.Tasks", "Tasks") + .WithMany("TaskMedias") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Media"); + + b.Navigation("Tasks"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketMediasAgg.TicketMedia", b => + { + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("TicketMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("TicketMedias") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Media"); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.Navigation("CameraAccounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.Navigation("AdminResponseMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.Navigation("ClientResponseMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.MediaAgg.Media", b => + { + b.Navigation("AdminResponseMedias"); + + b.Navigation("ClientResponseMedias"); + + b.Navigation("TaskMedias"); + + b.Navigation("TicketMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.Navigation("Accounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.Navigation("Assigns"); + + b.Navigation("TaskMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketAgg.Ticket", b => + { + b.Navigation("AdminResponses"); + + b.Navigation("ClientResponses"); + + b.Navigation("TicketMedias"); + }); + + modelBuilder.Entity("TaskManager.Domain.PositionAgg.Position", b => + { + b.Navigation("Accounts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/20240704073907_AddIsDoneRequestToTaskManagerTable.cs b/AccountMangement.Infrastructure.EFCore/Migrations/20240704073907_AddIsDoneRequestToTaskManagerTable.cs new file mode 100644 index 00000000..4bdc7955 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Migrations/20240704073907_AddIsDoneRequestToTaskManagerTable.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace AccountMangement.Infrastructure.EFCore.Migrations +{ + /// + public partial class AddIsDoneRequestToTaskManagerTable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "IsDoneRequest", + table: "TasksManager", + type: "bit", + nullable: false, + defaultValue: false); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IsDoneRequest", + table: "TasksManager"); + } + } +} diff --git a/AccountMangement.Infrastructure.EFCore/Repository/AccountRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/AccountRepository.cs index 61a244ce..16e03e90 100644 --- a/AccountMangement.Infrastructure.EFCore/Repository/AccountRepository.cs +++ b/AccountMangement.Infrastructure.EFCore/Repository/AccountRepository.cs @@ -5,6 +5,7 @@ using AccountManagement.Domain.AccountAgg; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading.Tasks; using AccountManagement.Domain.RoleAgg; @@ -106,6 +107,7 @@ public class AccountRepository : RepositoryBase, IAccountReposito }).Where(x=>x.RoleId == 15 && x.IsActiveString == "true").ToList(); } + [SuppressMessage("ReSharper.DPA", "DPA0007: Large number of DB records", MessageId = "count: 282")] public List Search(AccountSearchModel searchModel) { var query = _context.Accounts.Include(x => x.Role).Select(x => new AccountViewModel @@ -179,6 +181,7 @@ public class AccountRepository : RepositoryBase, IAccountReposito Fullname = x.Fullname, Id = x.id, PositionValue = x.Position.PositionValue, + PositionId = x.Position.id, IsActiveString = x.IsActiveString, Username = x.Username @@ -193,7 +196,7 @@ public class AccountRepository : RepositoryBase, IAccountReposito var assignerIds = _context.Assigns.Where(x => x.TaskId == taskId).Select(x => x.AssignerId).ToList(); return _context.Accounts.Include(x => x.Position).Where(x => - x.Position.PositionValue > posValue && !assignerIds.Contains(x.id) && !assignedIds.Contains(x.id)).Select( + x.Position.PositionValue > posValue && !assignerIds.Contains(x.id) && !assignedIds.Contains(x.id)).Select( x => new AccountViewModel() { PositionValue = x.Position.PositionValue, @@ -203,16 +206,15 @@ public class AccountRepository : RepositoryBase, IAccountReposito IsActiveString = x.IsActiveString, Username = x.Username }).ToList(); + + } - public List GetAccountsByIds(List ids) - { - var res = _context.Accounts.Include(x => x.Position).Where(x => x.PositionId != null); - return res.Where(x => ids.Contains(x.id)).ToList(); - } + public List GetAccountLowerPositionvalue() { + var account = GetIncludePositions(int.Parse(_contextAccessor.HttpContext.User.FindFirst("AccountId").Value)); return _context.Accounts.Include(x => x.Position) .Where(x => x.Position.PositionValue > account.Position.PositionValue && x.IsActiveString == "true").Select(x => new AccountViewModel() @@ -231,6 +233,12 @@ public class AccountRepository : RepositoryBase, IAccountReposito CreationDateGr = x.CreationDate, }).ToList(); + + } + public List GetAccountsByIds(List ids) + { + var res = _context.Accounts.Include(x => x.Position).Where(x => x.PositionId != null); + return res.Where(x => ids.Contains(x.id)).ToList(); } public AccountViewModel GetAccountViewModel(long id) diff --git a/AccountMangement.Infrastructure.EFCore/Repository/MediaRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/MediaRepository.cs index 6cdbaa23..0a76d520 100644 --- a/AccountMangement.Infrastructure.EFCore/Repository/MediaRepository.cs +++ b/AccountMangement.Infrastructure.EFCore/Repository/MediaRepository.cs @@ -2,8 +2,11 @@ using System.Linq; using _0_Framework.InfraStructure; using AccountManagement.Application.Contracts.Media; +using AccountManagement.Domain.AdminResponseMediaAgg; +using AccountManagement.Domain.ClientResponseMediaAgg; using AccountManagement.Domain.MediaAgg; using AccountManagement.Domain.TaskMediaAgg; +using AccountManagement.Domain.TicketMediasAgg; using Microsoft.EntityFrameworkCore; namespace AccountMangement.Infrastructure.EFCore.Repository; @@ -24,7 +27,26 @@ public class MediaRepository:RepositoryBase,IMediaRepository } public void Remove(long id) { - Remove(id); + var media = Get(id); + Remove(media); + } + + public void CreateTicketMedia(long ticketId, long mediaId) + { + var ticketMedias = new TicketMedia(ticketId, mediaId); + _taskManagerContext.Add(ticketMedias); + } + + public void CreateAdminResponseMedia(long adminResponseId, long mediaId) + { + var adminResMedia = new AdminResponseMedia(adminResponseId, mediaId); + _taskManagerContext.Add(adminResMedia); + } + + public void CreateClientResponseMedia(long clientResponseId, long mediaId) + { + var clientResMedia = new ClientResponseMedia(clientResponseId, mediaId); + _taskManagerContext.Add(clientResMedia); } public List GetMediaByTaskId(long taskId) diff --git a/AccountMangement.Infrastructure.EFCore/Repository/PositionRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/PositionRepository.cs index 976401b6..cddd4839 100644 --- a/AccountMangement.Infrastructure.EFCore/Repository/PositionRepository.cs +++ b/AccountMangement.Infrastructure.EFCore/Repository/PositionRepository.cs @@ -2,11 +2,11 @@ using System.Linq; using _0_Framework.InfraStructure; using AccountManagement.Application.Contracts.Account; +using AccountManagement.Application.Contracts.Position; using AccountManagement.Domain.AccountAgg; using AccountMangement.Infrastructure.EFCore; using Microsoft.AspNetCore.Http; using Microsoft.EntityFrameworkCore; -using TaskManager.Application.Contract.Position; using TaskManager.Domain.PositionAgg; namespace TaskManager.Infrastructure.EFCore.Repository; @@ -29,7 +29,8 @@ public class PositionRepository : RepositoryBase, IPositionRepos { Value = x.PositionValue, Id = x.id, - Name = x.PositionName + Name = x.PositionName, + CountUsers = _accountContext.Accounts.Count(a => a.PositionId==x.id) @@ -53,6 +54,13 @@ public class PositionRepository : RepositoryBase, IPositionRepos }).OrderBy(x => x.Value).ToList(); } + public List GetUnUsedPositionValues() + { + List values= new List() {1,2,3,4,5}; + var usedPositions= _accountContext.Positions.Select(x => x.PositionValue).ToList(); + return values.Where(x => !usedPositions.Contains(x)).ToList(); + } + //لیست کسانی که سمتی برایشان ثبت نشده است public List GetNoPositionAccounts() { diff --git a/AccountMangement.Infrastructure.EFCore/Repository/TaskRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/TaskRepository.cs index dcfe872b..0abddfca 100644 --- a/AccountMangement.Infrastructure.EFCore/Repository/TaskRepository.cs +++ b/AccountMangement.Infrastructure.EFCore/Repository/TaskRepository.cs @@ -34,7 +34,7 @@ public class TaskRepository : RepositoryBase, ITaskRepository return _accountContext.Tasks.Where(x => x.id == TaskId).Select(x => new EditTask() { - EndTaskDate = x.EndTaskDate.ToFarsiFull(), + EndTaskDate = x.EndTaskDate.ToFarsi(), Description = x.Description, Id = x.id, Title = x.Title, @@ -43,17 +43,23 @@ public class TaskRepository : RepositoryBase, ITaskRepository { Path = m.Media.Path, Type = m.Media.Type, + Category = m.Media.Category, Id = m.Media.id }).ToList(), EndTaskTime = x.EndTaskDate.ToFarsiFull().Substring(11), ContractingPartyName = x.ContractingPartyName, + CompleteDescription = x.DoneDescription, + IsDone = x.IsDone, + ReceiverId = _accountContext.Assigns.Where(a=>a.TaskId==x.id).Select(a=>a.AssignedId).ToList(), + SenderId = x.SenderId }).FirstOrDefault(); } public void Remove(long id) { - Remove(id); + var task=Get(id); + Remove(task); } @@ -69,7 +75,7 @@ public class TaskRepository : RepositoryBase, ITaskRepository }; var query = _accountContext.Assigns.Include(x => x.Task).Where(x => x.Task.IsDone == false && x.Task.IsActiveString == "true" && - (x.Task.IsCanceledRequest == true || x.Task.TimeRequest == true)).Select(x => + (x.Task.IsCanceledRequest == true || x.Task.TimeRequest == true||x.Task.IsDoneRequest)).Select(x => new TaskViewModel() { @@ -90,6 +96,7 @@ public class TaskRepository : RepositoryBase, ITaskRepository ContractingPartyName = x.Task.ContractingPartyName, MediaCount = x.Task.TaskMedias.Count(m => m.TaskId == x.id), Description = x.Task.Description, + IsDoneRequest = x.Task.IsDoneRequest }); //res = res.GroupBy(x => x.Id).Select(x => x.First()); @@ -132,7 +139,8 @@ public class TaskRepository : RepositoryBase, ITaskRepository IsCancelRequest = x.IsCancelRequest, ContractingPartyName = x.ContractingPartyName, MediaCount = x.MediaCount, - Description = x.Description + Description = x.Description, + IsDoneRequest=x.IsDoneRequest }); if (!string.IsNullOrWhiteSpace(searchModel.StartDate) && !string.IsNullOrWhiteSpace(searchModel.EndDate)) { @@ -153,12 +161,15 @@ public class TaskRepository : RepositoryBase, ITaskRepository (end < x.EndTaskDateGE && x.EndTaskDateGE > end))); } - if (searchModel.AccountId > 0) + + + if (!string.IsNullOrWhiteSpace(searchModel.IsDoneRequest)) { - res = res.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId)); + bool isDoneReq = bool.Parse(searchModel.IsDoneRequest); + res = res.Where(x => x.IsDoneRequest == isDoneReq); } - if (!string.IsNullOrWhiteSpace(searchModel.IsDone)) + if (!string.IsNullOrWhiteSpace(searchModel.IsDone)) { bool isDone = bool.Parse(searchModel.IsDone); res = res.Where(x => x.IsDone == isDone); @@ -189,11 +200,18 @@ public class TaskRepository : RepositoryBase, ITaskRepository } + var resEnum = res.AsEnumerable(); var result = resEnum.GroupBy(x => x.Id).Select(x => x.First()); - var orderResult = result.OrderBy(x => x.IsDone ? 1 : 0) - .ThenBy(x => x.EndTaskDateGE).ThenBy(x => x.IsCancel ? 0 : 1); + if (searchModel.AccountId > 0) + { + result = result.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId)); + } + + + var orderResult = result.OrderBy(x => x.IsDone ? 1 : 0) + .ThenBy(x => x.EndTaskDateGE).ThenBy(x => x.IsCancel ? 0 : 1); var final = orderResult.Skip(searchModel.PageIndex).Take(30).ToList(); final = final.Select(x => new TaskViewModel() @@ -223,7 +241,8 @@ public class TaskRepository : RepositoryBase, ITaskRepository ContractingPartyName = x.ContractingPartyName, MediaCount = x.MediaCount, SelfName = x.SelfName, - Description = x.Description + Description = x.Description, + IsDoneRequest=x.IsDoneRequest, @@ -260,13 +279,14 @@ public class TaskRepository : RepositoryBase, ITaskRepository AcceptedTimeRequest = x.AcceptedTimeRequest, IsCancelRequest = x.IsCancelRequest, ContractingPartyName = x.ContractingPartyName, - Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE), + Color = x.IsCancelRequest || x.RequestTime || x.IsDoneRequest ? SetRequestTasksColors(x.RequestTime, x.IsCancelRequest,x.IsDoneRequest) : "", MediaCount = x.MediaCount, HasAttachment = (!string.IsNullOrWhiteSpace(x.Description) || x.MediaCount > 0), SelfName = x.SelfName, SelfAssigned = x.SelfAssigned, SelfAssigner = x.SelfAssigner, - Description = x.Description + Description = x.Description, + IsDoneRequest=x.IsDoneRequest }).ToList(); final = final.Select(x => new TaskViewModel() @@ -299,7 +319,8 @@ public class TaskRepository : RepositoryBase, ITaskRepository EndTaskTime = $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}:{x.EndTaskDateGE.Second}" != "23:59:59" ? $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}" : "", - Description = x.Description + Description = x.Description, + IsDoneRequest=x.IsDoneRequest }).ToList(); return final; } @@ -319,7 +340,7 @@ public class TaskRepository : RepositoryBase, ITaskRepository .Select(x => new TaskViewModel() { - + AssignedId = x.AssignedId, AssignerId = x.AssignerId, CreateDate = x.Task.CreationDate.ToFarsi(), @@ -335,8 +356,9 @@ public class TaskRepository : RepositoryBase, ITaskRepository AcceptedTimeRequest = x.Task.AcceptedTimeRequest, IsCancelRequest = x.Task.IsCanceledRequest, ContractingPartyName = x.Task.ContractingPartyName, - MediaCount = x.Task.TaskMedias.Count(m => m.TaskId == x.id), + MediaCount = _accountContext.TaskMedias.Count(m => m.TaskId == x.Task.id), Description = x.Task.Description, + IsDoneRequest=x.Task.IsDoneRequest, }); //res = res.GroupBy(x => x.Id).Select(x => x.First()); @@ -379,8 +401,9 @@ public class TaskRepository : RepositoryBase, ITaskRepository IsCancelRequest = x.IsCancelRequest, ContractingPartyName = x.ContractingPartyName, MediaCount = x.MediaCount, - Description = x.Description - }); + Description = x.Description, + IsDoneRequest=x.IsDoneRequest + }); if (!string.IsNullOrWhiteSpace(searchModel.StartDate) && !string.IsNullOrWhiteSpace(searchModel.EndDate)) { var start = searchModel.StartDate.ToGeorgianDateTime(); @@ -400,12 +423,13 @@ public class TaskRepository : RepositoryBase, ITaskRepository (end < x.EndTaskDateGE && x.EndTaskDateGE > end))); } - if (searchModel.AccountId > 0) + if (!string.IsNullOrWhiteSpace(searchModel.IsDoneRequest)) { - res = res.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId)); + bool isDoneReq = bool.Parse(searchModel.IsDoneRequest); + res = res.Where(x => x.IsDoneRequest == isDoneReq); } - if (!string.IsNullOrWhiteSpace(searchModel.IsDone)) + if (!string.IsNullOrWhiteSpace(searchModel.IsDone)) { bool isDone = bool.Parse(searchModel.IsDone); res = res.Where(x => x.IsDone == isDone); @@ -438,8 +462,16 @@ public class TaskRepository : RepositoryBase, ITaskRepository var resEnum = res.AsEnumerable(); var result = resEnum.GroupBy(x => x.Id).Select(x => x.First()); - var orderResult = result.OrderBy(x => x.IsDone ? 1 : 0) - .ThenBy(x => x.EndTaskDateGE).ThenBy(x => x.IsCancel ? 0 : 1); + + if (searchModel.AccountId > 0) + { + result = result.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId)); + } + + + var orderResult = result.OrderByDescending(x => x.IsCancel ? 0 : 1).ThenBy(x => x.IsDone ? 1 : 0) + .ThenBy(x => x.EndTaskDateGE); + var final = orderResult.Skip(searchModel.PageIndex).Take(30).ToList(); @@ -470,13 +502,14 @@ public class TaskRepository : RepositoryBase, ITaskRepository ContractingPartyName = x.ContractingPartyName, MediaCount = x.MediaCount, SelfName = x.SelfName, - Description = x.Description + Description = x.Description, + IsDoneRequest=x.IsDoneRequest - }).ToList(); + }).ToList(); final = final.Select(x => new TaskViewModel() @@ -507,14 +540,15 @@ public class TaskRepository : RepositoryBase, ITaskRepository AcceptedTimeRequest = x.AcceptedTimeRequest, IsCancelRequest = x.IsCancelRequest, ContractingPartyName = x.ContractingPartyName, - Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE), + Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE,x.IsCancel), MediaCount = x.MediaCount, - HasAttachment = (!string.IsNullOrWhiteSpace(x.Description) || x.MediaCount > 0), + HasAttachment = (!string.IsNullOrWhiteSpace(x.Description) || x.MediaCount > 0)?true:false, SelfName = x.SelfName, SelfAssigned = x.SelfAssigned, SelfAssigner = x.SelfAssigner, - Description = x.Description - }).ToList(); + Description = x.Description, + IsDoneRequest=x.IsDoneRequest + }).ToList(); final = final.Select(x => new TaskViewModel() { @@ -544,16 +578,21 @@ public class TaskRepository : RepositoryBase, ITaskRepository HasAttachment = x.HasAttachment, SelfName = !(x.SelfAssigned || x.SelfAssigner) ? "-" : x.SelfName, EndTaskTime = $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}:{x.EndTaskDateGE.Second}" != "23:59:59" - ? $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}" - : "", - Description = x.Description - }).ToList(); + ? $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}" + : "", + Description = x.Description, + IsDoneRequest=x.IsDoneRequest + }).ToList(); return final; } - public string SetTasksColors(DateTime date) + public string SetTasksColors(DateTime date,bool isCancel) { + if (isCancel) + { + return "brown"; + } var now = DateTime.Now.Date; if (date.Date < now) { @@ -576,12 +615,50 @@ public class TaskRepository : RepositoryBase, ITaskRepository } + public string SetRequestTasksColors(bool timeRequest, bool cancelRequest,bool isDoneRequest) + { + if (timeRequest) + { + return "yellow"; + } + else if (cancelRequest) + { + return "red"; + } + else if (isDoneRequest) + { + return "green"; + } + else + { + return ""; + } + + } + public int GetRequestedTasksCount() { - return _accountContext.Assigns.Include(x => x.Task).Where(x => - x.Task.IsDone == false && x.Task.IsActiveString == "true" && - (x.Task.IsCanceledRequest == true || x.Task.TimeRequest == true)).GroupBy(x => x.TaskId) - .Select(x => x.First()).Count(); + return _accountContext.Assigns.Include(x => x.Task).Where(x => + x.Task.IsDone == false && x.Task.IsActiveString == "true" && + (x.Task.IsCanceledRequest == true || x.Task.TimeRequest == true||x.Task.IsDoneRequest)).GroupBy(x => x.TaskId) + .Select(x => x.First()).Count(); + } + + public TaskViewModel GetRequestDetails(long id) + { + return _accountContext.Tasks.Where(x => x.id == id).Select(x=>new TaskViewModel() + { + Id = x.id, + Name = x.Title, + ContractingPartyName = x.ContractingPartyName, + TimeRequestDescription = x.TimeRequestDescription, + CancelDescription = x.CancelDescription, + IsDoneDescription = x.DoneDescription, + IsCancelRequest = x.IsDoneRequest, + RequestTime = x.TimeRequest, + IsDoneRequest = x.IsDoneRequest, + RequestTaskDate = x.RequestDate==null?"":x.RequestDate.ToFarsi() + }).FirstOrDefault(); } } diff --git a/AccountMangement.Infrastructure.EFCore/Repository/TaskSubjectRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/TaskSubjectRepository.cs index 57a44cd6..8f6b0c83 100644 --- a/AccountMangement.Infrastructure.EFCore/Repository/TaskSubjectRepository.cs +++ b/AccountMangement.Infrastructure.EFCore/Repository/TaskSubjectRepository.cs @@ -15,13 +15,19 @@ public class TaskSubjectRepository:RepositoryBase, ITaskSubjec _context = context; } - public List GetAll() + public List GetAll(string search) { - return _context.TaskSubjects.Select(x => new TaskSubjectViewModel() + var res = _context.TaskSubjects.Select(x => new TaskSubjectViewModel() { Id = x.id, Subject = x.Subject - }).ToList(); + }); + if (!string.IsNullOrWhiteSpace(search)) + { + res = res.Where(x => x.Subject.Contains(search)); + } + + return res.ToList(); } public void Remove(long id) diff --git a/AccountMangement.Infrastructure.EFCore/Repository/TicketRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/TicketRepository.cs new file mode 100644 index 00000000..cd9b1ea0 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Repository/TicketRepository.cs @@ -0,0 +1,153 @@ +using System.Collections.Generic; +using System.Linq; +using _0_Framework.Application; +using _0_Framework.InfraStructure; +using AccountManagement.Application.Contracts.Media; +using AccountManagement.Application.Contracts.Ticket; +using AccountManagement.Domain.AdminResponseAgg; +using AccountManagement.Domain.ClientResponseAgg; +using AccountManagement.Domain.TicketAgg; +using Microsoft.EntityFrameworkCore; + +namespace AccountMangement.Infrastructure.EFCore.Repository; + +public class TicketRepository : RepositoryBase, ITicketRepository +{ + private readonly AccountContext _accountContext; + public TicketRepository(AccountContext accountContext) : base(accountContext) + { + _accountContext = accountContext; + } + + public List GetAll(TicketSearchModel searchModel) + { + var query = _accountContext.Tickets.OrderByDescending(x => x.CreationDate).Select(x => new TicketViewModel() + { + Description = x.Description, + SenderId = x.SenderId, + ContractingPartyName = x.ContractingPartyName, + Id = x.id, + Title = x.Title, + TicketType = x.TicketType, + Status = x.Status, + TaskId = x.TaskId, + CreationDateTimeGr = x.CreationDate, + CreationDateTime = x.CreationDate.ToFarsiFull(), + MediaViewModels = _accountContext.TicketMedias.Include(z => z.Media).Where(a => a.TicketId == x.id) + .Select(m => new MediaViewModel() + { + Id = m.Media.id, + Path = m.Media.Path, + Type = m.Media.Type, + }).ToList(), + AdminResponseViewModels = _accountContext.AdminResponses.Include(a => a.AdminResponseMedias) + .Where(a => a.TicketId == x.id).Select(a => new AdminResponseViewModel() + { + MediaViewModels = _accountContext.AdminResponseMedias.Include(d => d.Media) + .Where(d => d.AdminResponseId == a.id).Select(d => new MediaViewModel() + { + Id = d.Media.id, + Path = d.Media.Path, + Type = d.Media.Type, + }).ToList(), + Response = a.Response, + TicketId = a.TicketId + }).ToList(), + ClientResponseViewModels = _accountContext.ClientResponses.Include(a => a.ClientResponseMedias) + .Where(a => a.TicketId == x.id).Select(a => new ClientResponseViewModel() + { + MediaViewModels = _accountContext.ClientResponseMedias.Include(d => d.Media) + .Where(d => d.ClientResponseId == a.id).Select(d => new MediaViewModel() + { + Id = d.Media.id, + Path = d.Media.Path, + Type = d.Media.Type, + }).ToList(), + Response = a.Response, + TicketId = a.TicketId + }).ToList(), + + }); + + if (!string.IsNullOrWhiteSpace(searchModel.ContractingPartyName)) + { + query = query.Where(x => x.ContractingPartyName.Contains(searchModel.ContractingPartyName)); + } + + if (!string.IsNullOrWhiteSpace(searchModel.Status)) + { + query = query.Where(x => x.Status == searchModel.Status); + } + + if (!(string.IsNullOrWhiteSpace(searchModel.StartDate) && string.IsNullOrWhiteSpace(searchModel.EndDate))) + { + if (string.IsNullOrWhiteSpace(searchModel.OneDay)) + { + var startDate = searchModel.StartDate.ToGeorgianDateTime(); + var endDate = searchModel.EndDate.ToGeorgianDateTime(); + query = query.Where(x => startDate < x.CreationDateTimeGr && endDate > x.CreationDateTimeGr); + } + + } + + if (!string.IsNullOrWhiteSpace(searchModel.Title)) + { + query = query.Where(x => x.Title.Contains(searchModel.Title)); + } + + if (!string.IsNullOrWhiteSpace(searchModel.TypeOfTicket)) + { + query = query.Where(x => x.TicketType == searchModel.TypeOfTicket); + } + + if (!string.IsNullOrWhiteSpace(searchModel.OneDay)) + { + var day = searchModel.OneDay.ToGeorgianDateTime(); + query = query.Where(x => x.CreationDateTimeGr.Date == day.Date); + } + + if (!string.IsNullOrWhiteSpace(searchModel.IsAssigned)) + { + var isAssigned = bool.Parse(searchModel.IsAssigned); + if (isAssigned) + { + query.Where(x => x.TaskId != null); + } + else if (!isAssigned) + { + query.Where(x => x.TaskId == null); + } + } + return query.ToList(); + } + + public void CreateAdminResponse(AdminResponse command) + { + _accountContext.Add(command); + } + + public void CreateClientResponse(ClientResponse command) + { + _accountContext.Add(command); + } + + public EditTicket GetDetails(long id) + { + return _accountContext.Tickets.Select(x => new EditTicket() + { + ContractingPartyName = x.ContractingPartyName, + Description = x.Description, + Id = x.id, + SenderId = x.SenderId, + TicketType = x.TicketType, + Title = x.Title, + MediaViewModels = _accountContext.TicketMedias.Include(z => z.Media).Where(a => a.TicketId == x.id) + .Select(m => new MediaViewModel() + { + Id = m.Media.id, + Path = m.Media.Path, + Type = m.Media.Type, + }).ToList(), + }).FirstOrDefault(x => x.Id == id); + } +} \ No newline at end of file diff --git a/ServiceHost/Areas/Admin/Pages/Accounts/Account/CreateRole.cshtml b/ServiceHost/Areas/Admin/Pages/Accounts/Account/CreateRole.cshtml index 8f099116..0499b73b 100644 --- a/ServiceHost/Areas/Admin/Pages/Accounts/Account/CreateRole.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Accounts/Account/CreateRole.cshtml @@ -540,100 +540,105 @@ - @* مدیریت متن *@ -
- - - - @*لیست متون*@ -
- - - -
- @*عنوان*@ -
- - - -
- @*بخش*@ -
- - - -
- @*فصل*@ -
- - - -
- @*ماژول*@ -
- - - -
-
@* مدیریت وظایف *@
- - @*لیست وظایف*@ + + @*وظایف*@
- - + + @*لیست وظایف*@
- + + + +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ @*لیست درخواست ها*@
- -
-
- -
-
- -
-
- + + + +
+ +
+
+ +
+
+ +
+
+ +
- @*لیست عناوین وظایف*@ + @*گروهبندی*@
- + +
+ +
+
+ +
+
+ +
+
+ +
- -
- @* مدیریت لوایح *@ -
- - - - @*لیست لوایح*@ + @*وظیفه جدید*@
- - -
- @*ایجاد*@ -
- - - -
- @*مخاطب*@ -
- - + +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ @* بیمه *@
diff --git a/ServiceHost/Areas/Admin/Pages/Accounts/Account/EditRole.cshtml b/ServiceHost/Areas/Admin/Pages/Accounts/Account/EditRole.cshtml index 6dd6c0bc..95dfffd2 100644 --- a/ServiceHost/Areas/Admin/Pages/Accounts/Account/EditRole.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Accounts/Account/EditRole.cshtml @@ -105,7 +105,7 @@
- + oo6ltk,m,br @* بانک اطلاعات *@
@@ -533,100 +533,106 @@
- @* مدیریت متن *@ -
- - - - @*لیست متون*@ -
- - - -
- @*عنوان*@ -
- - - -
- @*بخش*@ -
- - - -
- @*فصل*@ -
- - - -
- @*ماژول*@ -
- - - -
-
+ @* مدیریت وظایف *@
- - @*لیست وظایف*@ -
- - + + @*وظایف*@ +
+ + + @*لیست وظایف*@ +
+ + + +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ @*لیست درخواست ها*@ +
+ + -
- +
+ +
+
+ +
+
+ +
+
+ +
+
-
- + @*گروهبندی*@ +
+ + + +
+ +
+
+ +
+
+ +
+
+ +
-
- -
-
- -
-
- -
-
- @*لیست عناوین وظایف*@ -
- - - -
- -
- @* مدیریت لوایح *@ -
- - - - @*لیست لوایح*@ -
- - - -
- @*ایجاد*@ -
- - - -
- @*مخاطب*@ -
- - - + @*وظیفه جدید*@ +
+ + + +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ @* بیمه *@
diff --git a/ServiceHost/Areas/Admin/Pages/Company/ConnectedPersonnels/Index.cshtml b/ServiceHost/Areas/Admin/Pages/Company/ConnectedPersonnels/Index.cshtml index 72928002..5ae894c6 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/ConnectedPersonnels/Index.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/ConnectedPersonnels/Index.cshtml @@ -575,7 +575,7 @@ } }); - $('.tableFindBtn').on('change', function () { + $(document).on('change', '.tableFindBtn', function () { $(this).find(".save").prop("disabled", false); }); }); diff --git a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/InsuranceConfirm.cshtml b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/InsuranceConfirm.cshtml index 9b9a4103..35338314 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/InsuranceConfirm.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/InsuranceConfirm.cshtml @@ -42,7 +42,7 @@ } .last-div{ width: 100%; - height: 55px; + /* height: 55px; */ } .printBtns { diff --git a/ServiceHost/Areas/Admin/Pages/Shared/_Menu.cshtml b/ServiceHost/Areas/Admin/Pages/Shared/_Menu.cshtml index e6a90867..2978a43d 100644 --- a/ServiceHost/Areas/Admin/Pages/Shared/_Menu.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Shared/_Menu.cshtml @@ -3,231 +3,249 @@ @inject _0_Framework.Application.IAuthHelper AuthHelper; @{ - - var currentAccout = AuthHelper.CurrentAccountInfo(); + + var currentAccout = AuthHelper.CurrentAccountInfo(); }
-
@*@section Script { diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/Task/Create.cshtml b/ServiceHost/Areas/AdminNew/Pages/Company/Task/Create.cshtml new file mode 100644 index 00000000..ca0c3c8a --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Company/Task/Create.cshtml @@ -0,0 +1,250 @@ +@page +@model ServiceHost.Areas.AdminNew.Pages.Company.Task.CreateModel +@using Version = _0_Framework.Application.Version + +@{ + ViewData["title"] = " - وظیفه جدید"; +} + + +@section Styles { + + + +} + +
+ +
+
+
+ +
+

وظایف جدید

+
کارگاه نورداد مهر گستر کاسپین
+
+
+ +
+
+ + +
+
+
+ +
+ @* *@ +
+
+
+
+
+ + +
+
+ + +
+
+
+
+ +
+ +
+
+
+
+
+ +
+
    +
+
+
+
+ +
+ + + + +
+
+
    +
+
+
+
+
+
+
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+ +
+
+
+ +
+ + @*
+ مهلت زمانی: +
*@ +
+ + +
+
+
+ +
+
+
+ + +
+
+
+
+ +
+ + + + + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+ +
+
+ + انصراف + + + @* ارسال *@ +
+
+ +
+ +
+
+
+
+ + + + + + + +@section Script { + + + + + + + + +} + + + diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/Task/Create.cshtml.cs b/ServiceHost/Areas/AdminNew/Pages/Company/Task/Create.cshtml.cs new file mode 100644 index 00000000..b0f51677 --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Company/Task/Create.cshtml.cs @@ -0,0 +1,232 @@ +using _0_Framework.Application; +using AccountManagement.Application.Contracts.Account; +using AccountManagement.Application.Contracts.Position; +using AccountManagement.Application.Contracts.Task; +using AccountManagement.Application.Contracts.TaskSubject; +using CompanyManagment.App.Contracts.PersonalContractingParty; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.AspNetCore.Mvc.Rendering; + +namespace ServiceHost.Areas.AdminNew.Pages.Company.Task +{ + public class CreateModel : PageModel + { + private readonly ITaskApplication _taskApplication; + private readonly IAccountApplication _accountApplication; + private readonly IPersonalContractingPartyApp _personalContractingPartyApp; + private readonly IAuthHelper _authHelper; + private readonly IPersonalContractingPartyApp _contractingPartyApp; + private readonly IPositionApplication _positionApplication; + private readonly ITaskSubjectApplication _taskSubjectApplication; + + public CreateModel(ITaskApplication taskApplication, IAccountApplication accountApplication, IPersonalContractingPartyApp personalContractingPartyApp, IAuthHelper authHelper, IPersonalContractingPartyApp contractingPartyApp, IPositionApplication positionApplication, ITaskSubjectApplication taskSubjectApplication) + { + _taskApplication = taskApplication; + _accountApplication = accountApplication; + _personalContractingPartyApp = personalContractingPartyApp; + _authHelper = authHelper; + _contractingPartyApp = contractingPartyApp; + _positionApplication = positionApplication; + _taskSubjectApplication = taskSubjectApplication; + } + + public CreateTask Command { get; set; } + public SelectList AccountsList { get; set; } + public List PositionViewModels { get; set; } + public long Id { get; set; } + public string DateFa; + + public IActionResult OnGet() + { + if (_authHelper.GetPermissions().Any(x=>x==903)) + { + var accounts = _accountApplication.GetAccountLowerPositionvalue(); + AccountsList = new SelectList(accounts, "Id", "Fullname"); + PositionViewModels = _positionApplication.GetLowerPosition(); + DateFa = DateTime.Now.ToFarsi(); + Id = _authHelper.CurrentAccountId(); + return Page(); + } + else + { + return Forbid(); + } + + } + + + public IActionResult OnPostCreateSaveTask(CreateTask Command) + { + Command.SenderId= _authHelper.CurrentAccountId(); + var result = _taskApplication.CreateTask(Command); + return new JsonResult(new + { + IsSuccedded = result.IsSuccedded, + message = result.Message, + }); + } + + public IActionResult OnGetSearchContractingParties(string searchName) + { + var list =_contractingPartyApp.SearchByName(searchName); + return new JsonResult(new + { + isSuccess=true, + list =list, + }); + } + + + // برای محاسبه تاریخ و ساعت + #region ComputeDay + //public IActionResult OnGetComputeDay(string date, string time) + //{ + + // if (string.IsNullOrWhiteSpace(time)) + // { + // time = "23:59"; + // } + // if (!string.IsNullOrWhiteSpace(date)) + // { + // var endTime = Convert.ToDateTime(time); + // var dateDeadline = date.ToGeorgianDateTime(); + // dateDeadline = dateDeadline.AddHours(endTime.Hour).AddMinutes(endTime.Minute); + + // var dateNow = DateTime.Now; + + // if (dateDeadline > dateNow) + // { + // var daysSpan = ((dateDeadline.Date - dateNow.Date).TotalDays); + + + // if (!string.IsNullOrWhiteSpace(time)) + // { + + + // var hourlyDate = dateDeadline.ToLocalTime() - DateTime.Now.ToLocalTime(); + // var hours = dateDeadline.Hour - DateTime.Now.Hour; + + + // if (hours > 0&& (int)daysSpan > 0) + // { + // return new JsonResult(new + // { + // res = $"{(int)daysSpan} روز " + hours + " " + "ساعت ", + // }); + // } + // else if (hours == 0&&(int)daysSpan>0) + // { + // return new JsonResult(new + // { + // res = $"{(int)daysSpan} روز " + // }); + // } + // else if (hours>0&& (int)daysSpan == 0) + // { + // return new JsonResult(new + // { + // res = $"{hours} ساعت", + // }); + // } + + + // } + + + // return new JsonResult(new + // { + // res = $"{(int)daysSpan} روز", + // }); + // } + // else + // { + // return new JsonResult(new + // { + // status = false, + // res = "مهلت انجام پروژه نمی تواند کوچکتر از گذشته باشد.", + // }); + // } + // } + + // return new JsonResult(new + // { + // res = "", + // }); + //} + + + #endregion + + + + + // برای باز کردن مودال عنوان دلبخواه + public IActionResult OnGetTaskSubject() + { + + return Partial("CreateCRUDTaskSubjectModal"); + } + + // برای گرفتن عنوان دلبخواه + public IActionResult OnGetListTaskSubject() + { + var result = _taskSubjectApplication.GetAll("").OrderByDescending(x=>x.Id); + return new JsonResult(new + { + result + }); + } + + + // برای ذخیره عنوان دلبخواه + public IActionResult OnPostCreateTaskSubject(string subject) + { + var result = _taskSubjectApplication.Create(subject); + return new JsonResult(new + { + isSuccess = result.IsSuccedded, + message = result.Message, + }); + } + + // برای ویرایش عنوان دلبخواه + public IActionResult OnPostEditTaskSubject(long id, string subject) + { + var model = new TaskSubjectViewModel() + { + Id = id, + Subject = subject + }; + var result = _taskSubjectApplication.Edit(model); + return new JsonResult(new + { + isSuccess = result.IsSuccedded, + message = result.Message, + }); + } + + // برای حذف عنوان دلبخواه + public IActionResult OnPostRemoveTaskSubject(long id) + { + var result = _taskSubjectApplication.Delete(id); + return new JsonResult(new + { + isSuccess = result.IsSuccedded, + message = result.Message, + }); + } + + + public IActionResult OnGetSearchTaskSubject(string searchSubject) + { + var list = _taskSubjectApplication.GetAll(searchSubject); + return new JsonResult(new + { + isSuccess = true, + list = list, + }); + } + + } +} diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/Task/CreateCRUDTaskSubjectModal.cshtml b/ServiceHost/Areas/AdminNew/Pages/Company/Task/CreateCRUDTaskSubjectModal.cshtml new file mode 100644 index 00000000..f0a75c78 --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Company/Task/CreateCRUDTaskSubjectModal.cshtml @@ -0,0 +1,70 @@ +@using Version = _0_Framework.Application.Version + + + + + + + + + + + + + + + diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/Task/DetailsModal.cshtml b/ServiceHost/Areas/AdminNew/Pages/Company/Task/DetailsModal.cshtml new file mode 100644 index 00000000..b0622098 --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Company/Task/DetailsModal.cshtml @@ -0,0 +1,174 @@ +@model AccountManagement.Application.Contracts.Task.EditTask +@using Version = _0_Framework.Application.Version + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/Task/Edit.cshtml b/ServiceHost/Areas/AdminNew/Pages/Company/Task/Edit.cshtml new file mode 100644 index 00000000..03871657 --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Company/Task/Edit.cshtml @@ -0,0 +1,284 @@ +@model AccountManagement.Application.Contracts.Task.EditTaskPartialViewModel +@using System.Web +@using Microsoft.AspNetCore.Mvc.TagHelpers +@using Version = _0_Framework.Application.Version + +@{ + int fileIndex = 0; + int i = 1; + + + + +} + + + + + + + + + diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/Task/Group.cshtml b/ServiceHost/Areas/AdminNew/Pages/Company/Task/Group.cshtml new file mode 100644 index 00000000..94ce42f5 --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Company/Task/Group.cshtml @@ -0,0 +1,371 @@ +@page +@using Version = _0_Framework.Application.Version +@model ServiceHost.Areas.AdminNew.Pages.Company.Task.GroupModel +@{ + ViewData["Title"] = " - " + "کارگاه"; + int index = 1; + int i = 0; +} + +@section Styles { + + + + + + + + + + + + +} + + + +
+
+
+

عملیات گروه‌بندی وظیفه

+
+ +
+
+ + +
+ +
+ +
+ +
+ @foreach (var item in Model.PositionViewModels) + { +
+ + +
+ @(index++) +
+
+

نام گروه:

+

@item.Name

+
+
+

سطح گروه: @item.Value

+

تعداد اعضاء: @item.CountUsers

+
+
+ + +
+
+ } +
+
+
+
+ +
+
ردیف
+
نام پرسنل
+
سطح
+
عملیات
+
+ +
+ +
+ +
+
+
+ +
+ + + + + + + +@section Script { + + + + + + +} \ No newline at end of file diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/Task/Group.cshtml.cs b/ServiceHost/Areas/AdminNew/Pages/Company/Task/Group.cshtml.cs new file mode 100644 index 00000000..3303e3ce --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Company/Task/Group.cshtml.cs @@ -0,0 +1,130 @@ +using _0_Framework.Application; +using AccountManagement.Application.Contracts.Account; +using AccountManagement.Application.Contracts.Position; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace ServiceHost.Areas.AdminNew.Pages.Company.Task +{ + public class GroupModel : PageModel + { + private readonly IPositionApplication _positionApplication; + private readonly IAccountApplication _accountApplication ; + private readonly IAuthHelper _authHelper; + + public GroupModel(IPositionApplication positionApplication, IAccountApplication accountApplication, IAuthHelper authHelper) + { + _positionApplication = positionApplication; + _accountApplication = accountApplication; + _authHelper = authHelper; + } + + public List PositionViewModels { get; set; } + + public IActionResult OnGet() + { + if (_authHelper.GetPermissions().Any(x=>x==902)) + { + PositionViewModels = _positionApplication.GetPositions(); + return Page(); + } + else + { + return Forbid(); + } + + } + + + + public IActionResult OnGetGroupAccountsAjax(long id) + { + return new JsonResult(new + { + accounts = _accountApplication.GetAccountsByPositionId(id) + }); + } + + public IActionResult OnGetShowCreateModal() + { + if (_authHelper.GetPermissions().Any(x=>x==90210)) + { + var lastPositionValue = _positionApplication.GetLastPositionValue(); + var unusedPositions = _positionApplication.GetUnUsedPositionValues(); + var model = new CreatePositionModalViewModel() + { + LastPositionValue = lastPositionValue, + UnUsedPositionValue = unusedPositions + }; + return Partial("GroupCreateModal", model); + } + else + { + return Forbid(); + } + } + + public IActionResult OnPostCreatePosition(CreatePosition command) + { + var res = _positionApplication.Create(command); + + return new JsonResult(new + { + isSuccedded=res.IsSuccedded, + message=res.Message, + }); + } + + public IActionResult OnPostDeleteAccountFromPosition(List accountIds,long positionId) + { + var res= _positionApplication.RemoveAccountListFromPosition(accountIds, positionId); + + return new JsonResult(new + { + isSuccedded = res.IsSuccedded, + message = res.Message, + }); + } + + public IActionResult OnPostRemovePosition(long positionId) + { + var res = _positionApplication.Remove(positionId); + return new JsonResult(new + { + isSuccedded = res.IsSuccedded, + message = res.Message, + }); + } + + public IActionResult OnGetAccountPosition(long positionId) + { + var accounts = _positionApplication.GetNoPositionAccounts(); + var model = new AddAccountToPositionPartialViewModel() + { + Accounts = accounts, + PositionId = positionId + }; + return Partial("GroupAddMemberToGroup", model); + + } + + public IActionResult OnPostAddAccountToPosition(List accounts, long positionId) + { + var res = _positionApplication.SaveAccountPosition(accounts, positionId); + var selfPositionValue = _authHelper.CurrentAccountInfo().PositionValue != null + ? _authHelper.CurrentAccountInfo().PositionValue + : 0; + + if (res.IsSuccedded&& selfPositionValue < 1) + { + _accountApplication.ReLogin(); + } + return new JsonResult(new + { + isSuccedded = res.IsSuccedded, + message = res.Message, + }); + } + } +} diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/Task/GroupAddMemberToGroup.cshtml b/ServiceHost/Areas/AdminNew/Pages/Company/Task/GroupAddMemberToGroup.cshtml new file mode 100644 index 00000000..40fee1ad --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Company/Task/GroupAddMemberToGroup.cshtml @@ -0,0 +1,250 @@ +@model AccountManagement.Application.Contracts.Position.AddAccountToPositionPartialViewModel +@using Version = _0_Framework.Application.Version + + + + + + + + + + +
+ +
+ + + + + + diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/Task/GroupCreateModal.cshtml b/ServiceHost/Areas/AdminNew/Pages/Company/Task/GroupCreateModal.cshtml new file mode 100644 index 00000000..b9e91c9a --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Company/Task/GroupCreateModal.cshtml @@ -0,0 +1,177 @@ +@model AccountManagement.Application.Contracts.Position.CreatePositionModalViewModel +@using Version = _0_Framework.Application.Version + + + + + + + + + + +
+ +
+ + + + + + diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/Task/Index.cshtml b/ServiceHost/Areas/AdminNew/Pages/Company/Task/Index.cshtml new file mode 100644 index 00000000..0d96f17b --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Company/Task/Index.cshtml @@ -0,0 +1,385 @@ +@page +@using Version = _0_Framework.Application.Version +@model ServiceHost.Areas.AdminNew.Pages.Company.Task.IndexModel +@{ + var index = 1; +} + + +@section Styles { + + + + + + + + + + + + + + + + + +} + + +
+
+
+ +
+

مدیریت وظایف

+
کارگاه نورداد مهر گستر کاسپین
+
+
+ +
+
+ + + + + + + +
+ + + + +
+
+ + +
+
+ + +
+ +
+ + + + +
+ +
+ + @*
+
ردیف
+
عملیات
+
+ +
+
*@ + + @* @foreach (var task in Model.TaskViewModels) + { +
+
+
+ + @(index++) + +
+
+ + + @foreach (var assign in task.AssignList) + { + if (assign.AssignViewModels.Count > 0) + { +
+ @foreach (var item in assign.AssignViewModels) + { +
@item.AssignedName
+ } +
+ } + else + { +
+
-
+ +
+ } + + } + +
+
@task.EndTaskDateFA
+
+ +
+
@task.ContractingPartyName
+
+ +
+ @if (task.Description!=null) + { +
@Html.Raw(task.Description)
+ } + else + { +
ندارد
+ } +
+ +
+
+ + + +
+
+ +
+ + +
+
+
+
+ +
+ @foreach(var assign in task.AssignViewModels) + { +
+
@assign.AssignedName
+
+ } +
+ +
+
+
@task.ContractingPartyName
+
+
+
@task.EndTaskDateFA
+
+
+ +
+
+
+ + + + +
+
+
+
+ + +
+
+
+
+
+ } *@ + +
+
+ + + + + + +
+ + + + + + +@section Script { + + + + + + + +} \ No newline at end of file diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/Task/Index.cshtml.cs b/ServiceHost/Areas/AdminNew/Pages/Company/Task/Index.cshtml.cs new file mode 100644 index 00000000..e04ee016 --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Company/Task/Index.cshtml.cs @@ -0,0 +1,625 @@ +using System.ComponentModel.DataAnnotations; +using System.Diagnostics; +using _0_Framework.Application; +using AccountManagement.Application.Contracts.Account; +using AccountManagement.Application.Contracts.Assign; +using AccountManagement.Application.Contracts.Position; +using AccountManagement.Application.Contracts.Task; +using AccountManagement.Domain.MediaAgg; +using CompanyManagment.App.Contracts.Checkout; +using CompanyManagment.App.Contracts.Contract; +using CompanyManagment.App.Contracts.Leave; +using CompanyManagment.App.Contracts.Workshop; +using CompanyManagment.Application; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using static System.Runtime.InteropServices.JavaScript.JSType; +using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; + +namespace ServiceHost.Areas.AdminNew.Pages.Company.Task +{ + public class IndexModel : PageModel + { + private readonly ITaskApplication _taskApplication; + private readonly IAuthHelper _authHelper; + private readonly IAccountApplication _accountApplication; + private readonly IPositionApplication _positionApplication; + private readonly IWebHostEnvironment _environment; + + public IndexModel(ITaskApplication taskApplication, IAuthHelper authHelper, + IAccountApplication accountApplication, IPositionApplication positionApplication, + IWebHostEnvironment environment) + { + _taskApplication = taskApplication; + _authHelper = authHelper; + _accountApplication = accountApplication; + _positionApplication = positionApplication; + _environment = environment; + } + + public List TaskViewModels { get; set; } + public TaskSearchModel SearchModel { get; set; } + public int RequestCount { get; set; } + + + + public IActionResult OnGet(TaskSearchModel searchModel) + { + if (_authHelper.GetPermissions().Any(x => x == 901)) + { + //var serach = new TaskSearchModel(); + searchModel.PageIndex = 0; + SearchModel = searchModel; + RequestCount = _taskApplication.GetRequestedTasksCount(); + return Page(); + } + else + { + return Forbid(); + } + + + } + + public IActionResult OnGetTaskPagination(int pageIndex, string startDate, string endDate, long accountId, + string isDone, + string isCanceled, string isCancelRequest, string isTimeRequest, string timeRequestAccepted, string type, string isDoneRequest) + { + + var searchModel = new TaskSearchModel() + { + IsDone = isDone, + IsDoneRequest = isDoneRequest, + IsCancelRequest = isCancelRequest, + AccountId = accountId, + EndDate = endDate, + IsCanceled = isCanceled, + IsTimeRequest = isTimeRequest, + PageIndex = pageIndex, + StartDate = startDate, + TimeRequestAccepted = timeRequestAccepted, + TypeOfTicket = type + + }; + + var taskList = new List(); + + taskList = searchModel.TypeOfTicket == "request" + ? _taskApplication.GetAllRequestedTasks(searchModel) + : _taskApplication.GetTasks(searchModel); + + + + return new JsonResult(new + { + pageIndex = taskList.Count, + taskList = taskList, + positions = _positionApplication.GetLowerPosition() + }); + } + + public IActionResult OnGetRequestCount() + { + var requestCount = _taskApplication.GetRequestedTasksCount(); + return new JsonResult(new + { + isSuccess = true, + result = requestCount + }); + } + + // برای ارجاع دادن + public IActionResult OnPostCreateAssign(OperationModalViewModel command) + { + if (_authHelper.GetPermissions().Any(x => x == 90110)) + { + + var assign = new CreateAssign() + { + AssignerPositionValue = (int)_authHelper.CurrentAccountInfo().PositionValue, + AssignedId = command.CreateAssign.AssignedId, + AssignerId = _authHelper.CurrentAccountId(), + TaskId = command.TaskId + }; + var res = _taskApplication.CreateAssign(assign); + return new JsonResult(new + { + isSuccess = res.IsSuccedded, + message = res.Message, + + }); + } + else + { + return Forbid(); + } + + } + + // برای مهلت زمانی + public IActionResult OnPostCreateTimeRequest(OperationModalViewModel command) + { + if (_authHelper.GetPermissions().Any(x => x == 90111)) + { + var requestTime = new CreateTaskTimeRequest() + { + Description = command.CreateTaskTimeRequest.Description, + RequestTime = command.CreateTaskTimeRequest.RequestTime, + TaskId = command.TaskId + }; + var res = _taskApplication.CreateRequestTime(requestTime); + return new JsonResult(new + { + isSuccess = res.IsSuccedded, + message = res.Message, + + }); + } + else + { + return Forbid(); + } + + } + + // برای تایید درخواست مهلت + public IActionResult OnPostAcceptTimeRequest(long id) + { + var res = _taskApplication.AcceptRequestDatetime(id); + return new JsonResult(new + { + isSuccess = res.IsSuccedded, + message = res.Message, + + }); + } + + // برای لغو درخواست مهلت + public IActionResult OnPostRejectTimeRequest(long id) + { + var res = _taskApplication.RejectTimeRequest(id); + return new JsonResult(new + { + isSuccess = res.IsSuccedded, + message = res.Message, + + }); + } + + // برای درخواست انصراف + public IActionResult OnPostCreateCancelRequest(OperationModalViewModel command) + { + var requestCancel = new CreateTaskCancel() + { + Description = command.CreateTaskCancel.Description, + TaskId = command.TaskId + }; + var res = _taskApplication.CreateCancelRequest(requestCancel); + return new JsonResult(new + { + isSuccess = res.IsSuccedded, + message = res.Message, + + }); + } + + // برای تایید انصراف + public IActionResult OnPostAcceptCancel(long id) + { + var res = _taskApplication.AcceptCancelRequest(id); + return new JsonResult(new + { + isSuccess = res.IsSuccedded, + message = res.Message, + + }); + } + + // برای لغو انصراف + public IActionResult OnPostRejectCancel(long id) + { + var res = _taskApplication.RejectCancelRequest(id); + return new JsonResult(new + { + isSuccess = res.IsSuccedded, + message = res.Message, + + }); + } + + // برای انجام تسک + public IActionResult OnPostComplete(OperationModalViewModel command) + { + var completeTask = new CompleteTaskViewModel() + { + Description = command.CompleteTaskViewModel.Description, + Id = command.TaskId + }; + + var res = _taskApplication.CreateCompleteTaskRequest(completeTask); + return new JsonResult(new + { + isSuccess = res.IsSuccedded, + message = res.Message, + + }); + } + + public IActionResult OnPostAcceptComplete(long id) + { + var res = _taskApplication.AcceptCompleteRequest(id); + return new JsonResult(new + { + isSuccess = res.IsSuccedded, + message = res.Message, + + }); + } + public IActionResult OnPostRejectComplete(long id) + { + var res = _taskApplication.RejectCompleteRequest(id); + return new JsonResult(new + { + isSuccess = res.IsSuccedded, + message = res.Message, + + }); + + } + + + + // برای باز کردن مودال عملیات تسک + public IActionResult OnGetAssignTo(long taskId, string type) + { + if (_authHelper.GetPermissions().Any(x => x == 90110)) + { + var model = new OperationModalViewModel() + { + TaskId = taskId, + Type = type, + Accounts = _accountApplication.AccountsForAssign(taskId) + }; + return Partial("OperationModal", model); + } + + else + { + return Forbid(); + } + } + + + + // برای باز کردن مودال عملیات درخواست تسک + public IActionResult OnGetOperationRequestTask(long taskId, string type) + { + var model = new OperationModalViewModel() + { + ModalTaskRequest = _taskApplication.GetRequestDetails(taskId), + TaskId = taskId, + Type = type, + Accounts = _accountApplication.AccountsForAssign(taskId) + }; + return Partial("OperationRequestModal", model); + } + + + + + // برای باز کردن مودال جزئیات تسک مثل عنوان، تاریخ، توضیحات و ... + public IActionResult OnGetDetailsTask(long taskId) + { + if (_authHelper.GetPermissions().Any(x => x == 90113)) + { + var model = _taskApplication.GetDetails(taskId); + return Partial("DetailsModal", model); + } + else + { + return Forbid(); + } + + } + + #region Show and Download Files + + public IActionResult OnGetGetFile(string filePath, long id) + { + if (string.IsNullOrEmpty(filePath)) + { + return NotFound(); + } + + + if (!System.IO.File.Exists(filePath)) + { + return NotFound(); + } + + var contentType = GetContentTypeImage(Path.GetExtension(filePath)); + if (string.IsNullOrWhiteSpace(contentType)) + { + byte[] fileContent = System.IO.File.ReadAllBytes(filePath); + var extension = GetContentType(Path.GetExtension(filePath)); + return File(fileContent, extension, $"Task_{id}{Path.GetExtension(filePath)}"); + } + else + { + return PhysicalFile(filePath, contentType); + } + + } + + public IActionResult OnGetShowVoice(string filePath) + { + if (string.IsNullOrEmpty(filePath)) + { + return NotFound(); + } + + + if (!System.IO.File.Exists(filePath)) + { + return NotFound(); + } + byte[] voiceContent = System.IO.File.ReadAllBytes(filePath); + return File(voiceContent, "audio/ogg", $"Task_voice.ogg"); + + } + + + public IActionResult OnGetShowPicture(string filePath) + { + if (string.IsNullOrEmpty(filePath)) + { + return NotFound(); + } + + + if (!System.IO.File.Exists(filePath)) + { + return NotFound(); + } + + var contentType = GetContentTypeImage(Path.GetExtension(filePath)); + return PhysicalFile(filePath, contentType); + } + + private string GetContentTypeImage(string extension) + { + if (!extension.StartsWith(".")) + { + extension = "." + extension; + } + + return extension.ToLower() switch + { + ".jpg" => "image/jpeg", + ".jpeg" => "image/jpeg", + ".png" => "image/png", + ".gif" => "image/gif", + ".bmp" => "image/bmp", + ".svg" => "image/svg+xml", + ".ico" => "image/x-icon", + _ => "", + }; + } + + public static string GetContentType(string extension) + { + + // Ensure the extension starts with a dot + if (!extension.StartsWith(".")) + { + extension = "." + extension; + } + + // Use switch expression to return the appropriate content type + return extension.ToLower() switch + { + ".txt" => "text/plain", + ".htm" => "text/html", + ".html" => "text/html", + ".css" => "text/css", + ".js" => "application/javascript", + ".json" => "application/json", + ".xml" => "application/xml", + ".pdf" => "application/pdf", + ".zip" => "application/zip", + ".rar" => "application/x-rar-compressed", + ".tar" => "application/x-tar", + ".mp3" => "audio/mpeg", + ".wav" => "audio/wav", + ".mp4" => "video/mp4", + ".avi" => "video/x-msvideo", + ".doc" => "application/msword", + ".docx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + ".xls" => "application/vnd.ms-excel", + ".xlsx" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + ".ppt" => "application/vnd.ms-powerpoint", + ".pptx" => "application/vnd.openxmlformats-officedocument.presentationml.presentation", + _ => "application/octet-stream", + }; + } + + #endregion + + public IActionResult OnPostRemoveTask(long taskId) + { + if (_authHelper.GetPermissions().Any(x => x == 90115)) + { + var res = _taskApplication.RemoveTask(taskId); + return new JsonResult(new + { + isSuccess = res.IsSuccedded, + message = res.Message, + }); + } + else + { + return Forbid(); + } + + + } + + // برای تغییر تاریخ درخواست تسک + public IActionResult OnPostChangeTime(string time, long taskId) + { + var res = _taskApplication.ChangeRequestTimeAndAccept(time, taskId); + return new JsonResult(new + { + isSuccess = res.IsSuccedded, + message = res.Message, + }); + } + + + + public IActionResult OnGetEditTask(long taskId) + { + if (_authHelper.GetPermissions().Any(x => x == 90114)) + { + var model = new EditTaskPartialViewModel() + { + Id = _authHelper.CurrentAccountId(), + AccountList = _accountApplication.GetAccountLowerPositionvalue().Select(x => new AccountViewModel() + { + Id = x.Id, + Fullname = x.Fullname + }).ToList(), + EditTask = _taskApplication.GetDetails(taskId) + }; + return Partial("Edit", model); + } + else + { + return Forbid(); + } + + + + //var index = 1; + //var medias = model.EditTask.medias.Where(x => x.Category == "فایل").ToList(); + //foreach (var media in medias) + //{ + // switch (index) + // { + // case 1: + // using (var stream = System.IO.File.OpenRead(media.Path)) + // { + // model.EditTask.Document1 = new FormFile(stream, 0, stream.Length, $"{taskId}_1", + // Path.GetFileName(stream.Name)); + // } + // break; + // case 2: + // using (var stream = System.IO.File.OpenRead(media.Path)) + // { + // model.EditTask.Document2 = new FormFile(stream, 0, stream.Length, $"{taskId}_2", + // Path.GetFileName(stream.Name)); + // } + // break; + // case 3: + // using (var stream = System.IO.File.OpenRead(media.Path)) + // { + // model.EditTask.Document3 = new FormFile(stream, 0, stream.Length, $"{taskId}_3", + // Path.GetFileName(stream.Name)); + // } + // break; + // case 4: + // using (var stream = System.IO.File.OpenRead(media.Path)) + // { + // model.EditTask.Document4 = new FormFile(stream, 0, stream.Length, $"{taskId}_4", + // Path.GetFileName(stream.Name)); + // } + // break; + // case 5: + // using (var stream = System.IO.File.OpenRead(media.Path)) + // { + // model.EditTask.Document5 = new FormFile(stream, 0, stream.Length, $"{taskId}_5", + // Path.GetFileName(stream.Name)); + // } + // break; + // case 6: + // using (var stream = System.IO.File.OpenRead(media.Path)) + // { + // model.EditTask.Document6 = new FormFile(stream, 0, stream.Length, $"{taskId}_6", + // Path.GetFileName(stream.Name)); + // } + // break; + // } + + // index++; + //} + + //var voice = model.EditTask.medias.FirstOrDefault(x => x.Category == "صوت"); + //if (voice != null) + //{ + // using (var stream = System.IO.File.OpenRead(voice.Path)) + // { + // model.EditTask.Voice = new FormFile(stream, 0, stream.Length, $"{taskId}_v", + // Path.GetFileName(stream.Name)); + // } + //} + + + } + + public IActionResult OnPostEditSaveTask(EditTaskPartialViewModel command) + { + var editCommand = new EditTask() + { + CompleteDescription = command.EditTask.CompleteDescription, + ContractingPartyName = command.EditTask.ContractingPartyName, + Description = command.EditTask.Description, + Document1 = command.EditTask.Document1, + Document2 = command.EditTask.Document2, + Document3 = command.EditTask.Document3, + Document4 = command.EditTask.Document4, + Document5 = command.EditTask.Document5, + Document6 = command.EditTask.Document6, + Voice = command.EditTask.Voice, + EndTaskDate = command.EditTask.EndTaskDate, + EndTaskTime = command.EditTask.EndTaskTime, + Id = command.EditTask.Id, + ReceiverId = command.EditTask.ReceiverId, + IsDone = command.EditTask.IsDone, + PositionId = command.EditTask.PositionId, + SenderId = command.EditTask.SenderId, + Title = command.EditTask.Title, + medias = command.EditTask.medias, + DeletedFileIds = command.EditTask.DeletedFileIds, + }; + var result = _taskApplication.Edit(editCommand); + + var res = result.IsSuccedded; + return new JsonResult(new + { + isSuccess = res, + message = result.Message, + }); + } + + + + + public IActionResult OnGetEmployeeList() + { + var result = _accountApplication.GetAccountLowerPositionvalue(); + + + + return new JsonResult(new { result=result }); + } + + + + } +} + + + + + diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/Task/OperationModal.cshtml b/ServiceHost/Areas/AdminNew/Pages/Company/Task/OperationModal.cshtml new file mode 100644 index 00000000..d04ec321 --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Company/Task/OperationModal.cshtml @@ -0,0 +1,248 @@ +@model AccountManagement.Application.Contracts.Task.OperationModalViewModel +@using Version = _0_Framework.Application.Version + +@{ + + +} + + + + +@{ + switch (Model.Type) + { + case "assign": +
+ + +
+ break; + + + case "request_time": +
+ + +
+ break; + + + case "canceled": +
+ + +
+ break; + + + case "completed": +
+ + +
+ break; + + + + + } +} + + + + \ No newline at end of file diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/Task/OperationRequestModal.cshtml b/ServiceHost/Areas/AdminNew/Pages/Company/Task/OperationRequestModal.cshtml new file mode 100644 index 00000000..2debcfb9 --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Company/Task/OperationRequestModal.cshtml @@ -0,0 +1,168 @@ +@model AccountManagement.Application.Contracts.Task.OperationModalViewModel +@using Version = _0_Framework.Application.Version + +@{ + + + +} +@{ + + + switch (Model.Type) + { + case "request_time": + + + break; + + case "cancel_request": + + break; + + + case "complete_request": + + break; + + } +} + + + + + diff --git a/ServiceHost/Areas/AdminNew/Pages/Index.cshtml b/ServiceHost/Areas/AdminNew/Pages/Index.cshtml new file mode 100644 index 00000000..3c70df37 --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Index.cshtml @@ -0,0 +1,258 @@ +@page +@model ServiceHost.Areas.AdminNew.Pages.IndexModel + +@{ + + +} + +
+
+
+ + + +
+
+ + @if (@Model.DbBackupList.Count > 0) + { +
+
+
لیست بکاپ های دیتابیس
+ @foreach (var item in @Model.DbBackupList) + { +
+
+
@item.FileName
+
+
+ } +
+
+ } + + @if (@Model.InsuranceBackupList.Count > 0) + { +
+
+
لیست بکاپ های بیمه
+ @foreach (var item in @Model.InsuranceBackupList) + { +
+
+
@item.FileName
+
+
+ } +
+
+ } + +
\ No newline at end of file diff --git a/ServiceHost/Areas/AdminNew/Pages/Index.cshtml.cs b/ServiceHost/Areas/AdminNew/Pages/Index.cshtml.cs new file mode 100644 index 00000000..8381cd10 --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Index.cshtml.cs @@ -0,0 +1,53 @@ +using _0_Framework.Application; +using backService; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace ServiceHost.Areas.AdminNew.Pages +{ + public class IndexModel : PageModel + { + private readonly IConfiguration _configuration; + public List DbBackupList { get; set; } + public List InsuranceBackupList { get; set; } + + public IndexModel(IWebHostEnvironment webHostEnvironment, IConfiguration configuration) + { + _configuration = configuration; + } + public void OnGet() + { + #region DbBackupLoad + + string? dbZipPath = _configuration["BackupOptions:DbBackupZipPath"]; + string[] dbBackups = Directory.GetFiles(dbZipPath); + DbBackupList = dbBackups.Select(x => new BackupViewModel() + { + FileName = Path.GetFileName(x), + FullPath = x, + CreationDate = Path.GetFileName(x).ExtractTimeFromDbbackup(), + }).OrderByDescending(x => x.CreationDate).ToList(); + + #endregion + + #region InsurancBackupLoad + + string? insuranceZipPath = _configuration["BackupOptions:InsuranceListZipPath"]; + string[] insuranceBackups = Directory.GetFiles(insuranceZipPath); + InsuranceBackupList = insuranceBackups.Select(x => new BackupViewModel() + { + FileName = Path.GetFileName(x), + FullPath = x, + CreationDate = Path.GetFileName(x).ExtractTimeFromInsurancebackup(), + }).OrderByDescending(x => x.CreationDate).ToList(); + + #endregion + } + + public IActionResult OnGetDownloadFile(string path, string fileName) + { + byte[] fileContent = System.IO.File.ReadAllBytes(path); + return File(fileContent, "application/zip", fileName); + } + } +} diff --git a/ServiceHost/Areas/AdminNew/Pages/Shared/_Header.cshtml b/ServiceHost/Areas/AdminNew/Pages/Shared/_Header.cshtml new file mode 100644 index 00000000..ba86a9ff --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Shared/_Header.cshtml @@ -0,0 +1,182 @@ +@using System.Reflection.Metadata +@inject _0_Framework.Application.IAuthHelper AuthHelper; +@{ + var currentAccout = AuthHelper.CurrentAccountInfo(); +} + + +
+ + +
+ + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + + + + diff --git a/ServiceHost/Areas/AdminNew/Pages/Shared/_Layout.cshtml b/ServiceHost/Areas/AdminNew/Pages/Shared/_Layout.cshtml new file mode 100644 index 00000000..8d96795e --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Shared/_Layout.cshtml @@ -0,0 +1,225 @@ +@using Microsoft.AspNetCore.Razor.Language.Intermediate +@using Version = _0_Framework.Application.Version + + + + + + + + + گزارشگیر @ViewData["Title"] + + + + + + + + + + + + + + + + + + + @RenderSection("Styles", false) + + + + +
+ + + +
+
+ @RenderBody() +
+
+ + + + + + + + + + + + + + + + + + + + + + @* *@ + + + + @RenderSection("Script", false) + + + \ No newline at end of file diff --git a/ServiceHost/Areas/AdminNew/Pages/Shared/_Menu.cshtml b/ServiceHost/Areas/AdminNew/Pages/Shared/_Menu.cshtml new file mode 100644 index 00000000..75323b68 --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Shared/_Menu.cshtml @@ -0,0 +1,463 @@ +@using System.Reflection.Metadata +@using AccountManagement.Application.Contracts.Account +@using CompanyManagment.App.Contracts.FinancialStatment +@using CompanyManagment.App.Contracts.PersonalContractingParty + +@inject _0_Framework.Application.IAuthHelper AuthHelper; +@inject IFinancialStatmentApplication FinancialStatment; +@inject IPersonalContractingPartyApp ContractingPartyApp; + +@{ + var currentAccout = AuthHelper.CurrentAccountInfo(); + var statmentInfo = ContractingPartyApp.GetContractingpartyIdByAccountId(currentAccout.Id); + + +} + + + + \ No newline at end of file diff --git a/ServiceHost/Areas/AdminNew/Pages/Shared/_ValidationScriptsPartial.cshtml b/ServiceHost/Areas/AdminNew/Pages/Shared/_ValidationScriptsPartial.cshtml new file mode 100644 index 00000000..5a16d80a --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Shared/_ValidationScriptsPartial.cshtml @@ -0,0 +1,2 @@ + + diff --git a/ServiceHost/Areas/AdminNew/Pages/Shared/_validationAlert.cshtml b/ServiceHost/Areas/AdminNew/Pages/Shared/_validationAlert.cshtml new file mode 100644 index 00000000..8b8cb456 --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Shared/_validationAlert.cshtml @@ -0,0 +1,45 @@ + + + + + + + \ No newline at end of file diff --git a/ServiceHost/Areas/AdminNew/Pages/_ViewImports.cshtml b/ServiceHost/Areas/AdminNew/Pages/_ViewImports.cshtml new file mode 100644 index 00000000..5457561d --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/_ViewImports.cshtml @@ -0,0 +1,3 @@ +@namespace ServiceHost.Areas.AdminNew.Pages +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@addTagHelper *, ServiceHost \ No newline at end of file diff --git a/ServiceHost/Areas/AdminNew/Pages/_ViewStart.cshtml b/ServiceHost/Areas/AdminNew/Pages/_ViewStart.cshtml new file mode 100644 index 00000000..a5f10045 --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/_ViewStart.cshtml @@ -0,0 +1,3 @@ +@{ + Layout = "_Layout"; +} diff --git a/ServiceHost/ServiceHost.csproj b/ServiceHost/ServiceHost.csproj index 0894c535..c080ce5d 100644 --- a/ServiceHost/ServiceHost.csproj +++ b/ServiceHost/ServiceHost.csproj @@ -72,6 +72,7 @@ + diff --git a/ServiceHost/appsettings.Development.json b/ServiceHost/appsettings.Development.json index 16234f8d..dcb3ac0a 100644 --- a/ServiceHost/appsettings.Development.json +++ b/ServiceHost/appsettings.Development.json @@ -12,7 +12,7 @@ //"MesbahDb": "Data Source=DESKTOP-NUE119G\\MSNEW;Initial Catalog=Mesbah_db;Integrated Security=True" //server - //"MesbahDb": "Data Source=171.22.24.15;Initial Catalog=mesbah_db;Persist Security Info=False;User ID=ir_db;Password=R2rNp[170][3019]#@ATt;TrustServerCertificate=true;" + //"MesbahDb": "Data Source=171.22.24.15;Initial Catalog=mesbah_db;Persist Security Info=False;User ID=ir_db;Password=R2rNp[170][3019]#@ATt;TrustServerCertificate=true;" //local "MesbahDb": "Data Source=.;Initial Catalog=Mesbah_db;Integrated Security=True;TrustServerCertificate=true;" diff --git a/ServiceHost/wwwroot/AssetsAdminNew/ContractingParties/css/Index.css b/ServiceHost/wwwroot/AssetsAdminNew/ContractingParties/css/Index.css new file mode 100644 index 00000000..1bc953b9 --- /dev/null +++ b/ServiceHost/wwwroot/AssetsAdminNew/ContractingParties/css/Index.css @@ -0,0 +1,694 @@ + +.sizeSet { + padding: 2px !important; + text-align: center !important; +} + +.faSize { + font-size: 21px !important; +} + +.rad { + border-radius: 8px !important; + /* padding: 10px; */ + padding: 2px 5px 0px 5px; +} + +.ionSize { + font-size: 20px !important; + top: 2px !important; + position: relative; +} + +.ionRad { + border-radius: 8px !important; + padding: 0px 7px 0px 7px !important; + background-color: #ff7700 !important; + border-color: #ff7700 !important; +} + +.thh0 { + width: 8px !important; +} + +.thh { + width: 40px !important; +} + +.thh2 { + width: 130px !important; +} + +.thhNastionalId { + width: 30px !important; +} + +.inpt { + width: 100%; + border: 1px solid #c7c7c7; +} + +.partyType { + background-color: #dddddd !important; + border-radius: 25px; + border: 1px solid #bfbfbf; + margin-left: 5px; +} + +.searchpanel { + background-color: #747272; +} + +select { + cursor: pointer; +} + +.withOutInstitutionContract { + background-color: #ffbfbf !important; +} + +.btn-table { + margin: 0 5px; + border-radius: 8px; + padding: 4px 8px 2px 8px; + box-shadow: 0 0 6px 0px #838383; + font-size: 20px; +} + +.addActualEmployer { + background-color: #f5f5f5; + border-color: #0f9500; + color: #0f9500 !important; + border-top-left-radius: 0px; + border-bottom-left-radius: 0px; +} + +.addLegalEmployer { + background-color: #f5f5f5; + border-color: #1d92e5; + color: #1d92e5 !important; + border-top-right-radius: 0px; + border-bottom-right-radius: 0px; +} + +.addActualEmployer:hover, .addActualEmployer:focus { + background-color: #f5f5f5; + border-color: #0f9500; + color: #0f9500 !important; + box-shadow: 0 2px 5px 0 rgba(0,0,0,.16), 0 2px 10px 0 rgba(0,0,0,.12); +} + +.addLegalEmployer:hover, .addLegalEmployer:focus { + background-color: #f5f5f5; + border-color: #1d92e5; + color: #1d92e5 !important; + box-shadow: 0 2px 5px 0 rgba(0,0,0,.16), 0 2px 10px 0 rgba(0,0,0,.12); +} + +#datatable thead .sorting:after { + opacity: 0; +} + +#datatable > tbody > tr > td { + padding: 4px 8px; +} + +.blockCount { + font-size: 14px; + vertical-align: middle; + position: relative; + top: -2px; + display: inline-flex; + width: 10px; +} + +@media (max-width: 768px) { + .in-containers { + margin: 3px 0; + font-size: 11px; + } +} + +.searchFilter, .searchFilter:hover, .searchFilter:focus, .searchFilter:active { + border-bottom-left-radius: 0px; + border-top-left-radius: 0px; + background-color: #524651; + border-color: #524651; + margin-left: -3px; +} + +.searchButtons { + display: flex; + align-items: center; + padding: 0 8px; +} + +table.dataTable thead .sorting:after, table.dataTable thead .sorting_asc:after, table.dataTable thead .sorting_desc:after { + opacity: 0; +} + +.table-bordered > thead > tr > th { + font-size: 14px; + text-align: center; +} + +.operation-td { + display: flex; + justify-content: flex-start; + flex-direction: row-reverse; +} + +.name-td { + font-size: 14px !important; + max-width: 100px; + position: relative; +} + +.bgRed, .bgRed:hover { + background-color: red; + border: red; +} + +.bgOrange, .bgOrange:hover { + background-color: #ff8404; + border: #ff8404; +} + +.bgGreen, .bgGreen:hover { + background-color: #2e951b; + border: #2e951b; +} + +.bgGray, .bgGray:hover { + background-color: #b5b5b5 !important; + color: #646464; +} + +.selectContainer { + width: 73%; + margin: auto; +} + +@media(max-width: 1000px) { + .selectContainer { + width: 100%; + margin: auto; + } +} + +/*@*select2 css start*@*/ ::-webkit-scrollbar { + width: 8px; +} + +::-webkit-scrollbar-track { + background: #dfdfdf; + border-radius: 5px; +} + +::-webkit-scrollbar-thumb { + background: #b991b9; + border-radius: 5px; +} + +.opt { + background-color: #fff7ff; + border-radius: 10px; + text-align: right; + padding: 2px 5px; + text-overflow: ellipsis; + overflow-x: hidden; + width: 100%; +} + +.noResult { + background-color: #fff7ff; + border-radius: 10px; + text-align: right; + padding: 2px 5px; +} + + .opt:hover, .noResult:hover { + background-color: #ddcadd !important; + } + +.selectDiv { + position: relative; + z-index: 2; + border-radius: 10px; + min-height: 20px; + max-height: 190px; + overflow: hidden scroll; + width: 100%; + background-color: rgb(255 255 255); + display: block; + box-shadow: 0px -1px 12px 0px rgba(0,0,0,.16), 2px 1px 10px 0 rgba(0,0,0,.12); +} + +.selectedOption { + color: #343434 !important; + background-color: #fff0ff !important; +} + +.keyboardSelected { + color: #343434 !important; + background-color: #ddcadd !important; +} + +/*@*button container start*@*/ @keyframes buttonsContainerIn { + 0% { + transform: translateX(-150px); + } + + 100% { + transform: translateX(0); + } +} + +@keyframes buttonsContainerOut { + 0% { + transform: translateX(0); + } + + 100% { + transform: translateX(-150px); + } +} + +.tooltipfullBtns { + opacity: 0; + z-index: 1; + color: #ffffff; + display: block; + font-size: 12px; + padding: 5px 10px; + border-radius: 15px; + text-align: center; + background: #fbb306; + border: 1px solid #fbb306; + box-shadow: 0 0 11px rgb(139 139 139 / 79%); + -webkit-transition: all .2s ease-in-out; + -moz-transition: all .2s ease-in-out; + -o-transition: all .2s ease-in-out; + transition: all .2s ease-in-out; + -webkit-transform: scale(0); + -moz-transform: scale(0); + -o-transform: scale(0); + -ms-transform: scale(0); + transform: scale(0); + position: absolute; + right: -35px; + bottom: 40px; + white-space: nowrap; +} + + .tooltipfullBtns:before, .tooltipfullBtns:after { + content: ''; + border-left: 7px solid transparent; + border-right: 7px solid transparent; + border-top: 10px solid #fbb306; + position: absolute; + bottom: -10px; + left: 40%; + } + +.ellipsed { + display: block; + width: 100%; + text-overflow: ellipsis; + overflow-x: clip; + white-space: nowrap; +} + +.tooltipfull-container { + cursor: pointer; + position: absolute; + display: inline-block; + right: 9px; + top: 13px; +} + +.tooltipfull { + opacity: 0; + z-index: 99; + color: #fff; + width: fit-content; + white-space: nowrap; + display: block; + font-size: 12px; + font-family: 'IranSans'; + padding: 5px 10px; + border-radius: 15px; + text-align: center; + /* text-shadow: 1px 1px 2px #111; */ + background: #524651; + border: 1px solid #524651; + box-shadow: 0 0 3px rgba(0,0,0,0.5); + -webkit-transition: all .2s ease-in-out; + -moz-transition: all .2s ease-in-out; + -o-transition: all .2s ease-in-out; + /* -ms-transition: all .2s ease-in-out; */ + transition: all .2s ease-in-out; + -webkit-transform: scale(0); + -moz-transform: scale(0); + -o-transform: scale(0); + -ms-transform: scale(0); + transform: scale(0); + position: absolute; + right: -2px; + bottom: 30px; +} + +.tooltipfull-container:hover .tooltipfull, a:hover .tooltipfull { + opacity: 1; + -webkit-transform: scale(1); + -moz-transform: scale(1); + -o-transform: scale(1); + -ms-transform: scale(1); + transform: scale(1); +} + +.tooltipfull:before, .tooltipfull:after { + content: ''; + border-left: 10px solid transparent; + border-right: 10px solid transparent; + border-top: 10px solid #524651; + position: absolute; + bottom: -10px; + right: 20px; +} + +.fulltext { + opacity: 0; + white-space: nowrap; +} + +.buttons-container.active { + opacity: 1; + animation: roadRunnerIn 0.3s cubic-bezier(0.165, 0.840, 0.440, 1.000) forwards; +} + +.buttons-container.reverse { + /*transform: translateX(-150px);*/ + transition: opacity 0.3s ease-out; + animation: roadRunnerOut 0.2s cubic-bezier(0.165, 0.840, 0.440, 1.000) forwards; +} + +@keyframes roadRunnerIn { + 0% { + transform: translateX(-150px) skewX(30deg) scaleX(1.3); + } + + 70% { + transform: translateX(30px) skewX(0deg) scaleX(.9); + } + + 100% { + transform: translateX(0px) skewX(0deg) scaleX(1); + } +} + +@keyframes roadRunnerOut { + 0% { + transform: translateX(0px) skewX(0deg) scaleX(1); + } + + 30% { + transform: translateX(-50px) skewX(0deg) scaleX(.9); + } + + 100% { + transform: translateX(-150px) skewX(30deg) scaleX(1.3); + } +} + +.flexible-div { + display: flex; + flex-wrap: wrap; + justify-content: left; +} + +.operationBtns { + display: flex; + align-items: center; + justify-content: space-evenly; +} + +.buttons-container { + opacity: 0; + display: none; + position: absolute; + background: #ffffffe0; + box-shadow: 0 0 6px 0px #939393; + flex-direction: column; + align-items: center; + padding: 10px 0px; + width: 6rem; + /*right: -10rem;*/ + height: auto; + border-radius: 10px; + justify-content: center; + transform: translateX(-150px); + z-index: 99; + /*animation: roadRunnerIn .3s cubic-bezier(0.165, 0.840, 0.440, 1.000) forwards;*/ +} + +.op-td { + max-width: 300px; + position: relative; +} + +.employee-operations { + background: #1e88b3; + color: #ffffff; + width: 7rem; + padding: 7px 8px; + font-size: 12px; + position: relative; + border-radius: 8px !important; + animation: blink 1s infinite; +} + +@keyframes blink { + 0% { + background: #1886b3; + } + + 50% { + background: #2594c1; + } + + 100% { + background: #1886b3; + } +} + +.employee-operations:hover, +.employee-operations:focus, +.employee-operations:active { + background: #1482af; + color: white; +} + +.employee-operations:before { + content: ''; + border-top: 6px solid transparent; + border-bottom: 6px solid transparent; + position: absolute; + left: 69px; + top: 8px; + border-left: 13px solid #1e88b3; +} + +.more-buttons.active .employee-operations:before { + opacity: 1; +} + +.more-buttons .employee-operations:before { + opacity: 0; +} + +.operationBtns a i.fa-trash { + transform: translate(-1px, -1px); +} + +.operationBtns a i.fa-info-circle { + color: #26731c; + transform: translate(-1px, 0px); +} + +.btn-table-block, .btn-table-details { + color: #ffffff; + width: 15rem; + height: 4.2rem; + box-shadow: 0 0 3px 0 black; + margin: 4px 0; + font-size: 11px; + display: flex; + align-items: center; +} + + .btn-table-block i, .btn-table-details i { + font-size: 22px; + margin: 0 0px 0 7px; + } + +.mobile-view { + display: none; +} + +.screen-view { + display: flex; +} + +table.dataTable thead > tr > th { + padding: 8px; +} + +.searchAll, .searchAll:hover, .searchAll:focus, .searchAll:active { + border-bottom-right-radius: 0px; + border-top-right-radius: 0px; + background-color: #545353; + border-color: #545353; +} + +.searchFilter i { + padding-left: 3px; + font-size: 14px; +} + +@media(max-width: 768px) { + .name-td { + font-size: 12px !important; + max-width: 200px; + } + + table.dataTable thead > tr > th { + padding-left: 0px; + padding-right: 0px; + text-align: center; + font-size: 12px; + } + + .employee-operations { + background: #2fb2ed; + width: 3rem; + font-size: 12px; + } + + .xs-middle { + margin: auto; + float: none; + display: flex; + justify-content: center; + column-gap: 4px; + } + + .xs-middle .btn-rounded { + padding: 6px 5px; + font-size: 12px; + } + + .employee-operations:before { + left: 28px; + } + + div.dataTables_length, div.dataTables_filter { + display: none; + } + + .pagination > li > a { + padding: 6px 10px; + } + + div.dataTables_paginate ul.pagination { + font-size: 10px; + padding: 0; + } + + .searchButtons { + flex-wrap: wrap; + } + + .addLegalEmployer, .addActualEmployer { + border-top-right-radius: 2em; + border-bottom-right-radius: 2em; + border-top-left-radius: 2em; + border-bottom-left-radius: 2em; + padding: 5px 3px; + font-size: 12px; + } + + .addActualEmployer { + margin-left: 5px; + } + + .mobile-view { + display: flex; + } + + .screen-view { + display: none; + } + + .fa-minus-circle { + font-size: 15px; + transform: translate(2px, -1px); + } + + .btn-table { + margin: 3px 5px; + border-radius: 8px; + padding: 5px; + box-shadow: 0 0 6px 0px #838383; + font-size: 18px; + width: 4rem; + } + + .buttons-container { + padding: 2px 0px; + } + + .partyType { + margin-right: 0; + margin-left: 0px; + padding: 0; + } + + .form-control { + font-size: 11px; + } + + .right-one { + padding-left: 0; + } + + .left-one { + padding-right: 0; + } + + #activing { + padding: 0; + } + + .searchFilter { + margin-left: -4px; + } + + .searchFilter, .searchAll { + padding: 6px 9px; + font-size: 10px; + } + + .searchFilter i, #activing, .partyType { + font-size: 10px; + } +} + +a.disabled { + pointer-events: none; + cursor: default; + background-color: grey !important; + border-color: grey !important; +} + + diff --git a/ServiceHost/wwwroot/AssetsAdminNew/ContractingParties/js/Index.js b/ServiceHost/wwwroot/AssetsAdminNew/ContractingParties/js/Index.js new file mode 100644 index 00000000..3beedb38 --- /dev/null +++ b/ServiceHost/wwwroot/AssetsAdminNew/ContractingParties/js/Index.js @@ -0,0 +1,1102 @@ + +$(document).ready(function () { + if ($("#empSearch").val() == "0") + $("#empSearch").val(''); +}) + +$(document).ready(function () { + $('#datatable').dataTable({ + "lengthMenu": [[25, 10, 50, 100, -1], [25, 10, 50, 100, "All"]] + }); +}); +$(document).ready(function () { + $('#datatable2').dataTable(); +}); + + + + +$("#myTab a").click(function (e) { + e.preventDefault(); + $(this).tab('show'); + +}); + +$("#myTab2 a").click(function (e) { + e.preventDefault(); + $(this).tab('show'); + +}); +// store the currently selected tab in the hash value +$("ul.nav-tabs > li > a").on("shown.bs.tab", function (e) { + var id = $(e.target).attr("href").substr(1); + window.location.hash = id; +}); +// on load of the page: switch to the currently selected tab +var hash = window.location.hash; +$('#myTab a[href="' + hash + '"]').tab('show', 'active'); +var hash2 = window.location.hash; +$('#myTab2 a[href="' + hash2 + '"]').tab('show', 'active'); + + + +var container = $('#emp'); +var searchBox = $('#empSearch'); +var hiddenInputVal = $('.sendEmployeeId'); +var searchResul = $('.searchResult'); +var mixContainerAndSerchResult = $('#emp , .searchResult'); + +container.hide(); +var liList; +var liPointer; +let count = 0; + +//close search Employee when click on body +$(document).on('click', function (event) { + if (!$(event.target).closest(container).length) { + container.hide(); + } +}); +//select option by mouse +function selectItem(id, employeeFullName) { + searchBox.val(employeeFullName); + hiddenInputVal.val(id); + container.hide(); + searchBox.addClass("selectedOption"); +}; +//search by Ajax +searchBox.on('keyup keypress', + function (e) { + $(".form-control").removeClass("selectedOption"); + $("#empSearchNationalcode").val(''); + $("#empSearchContractingPartyID").val(''); + $("#SearchModel2_RepresentativeName").val(''); + $("#SearchModel2_Nationalcode").val(''); + + if ($(this).val() == '') { + $("#SearchModel_EmployeeId").val("0"); + $("#SearchModel_EmployeeName").val(''); + } + //stop submit form with enter + var keyCode = e.keyCode || e.which; + if (keyCode === 13) { + e.preventDefault(); + if (count > 0 && count <= liList.length) { + liPointer.click(); + } + return false; + } + searchBox.removeClass("selectedOption"); + let searchText = $(this).val(); + hiddenInputVal.val(0); + + if (searchText.length > 1) { + + $.ajax({ + async: false, + contentType: 'charset=utf-8', + dataType: 'json', + type: 'GET', + url: '@Url.Page("./Index", "ContractPartyList")', + data: { "searchText": searchText }, + headers: { "RequestVerificationToken": $('@Html.AntiForgeryToken()').val() }, + + success: function (response) { + $(".opt").remove(); + if (response.mylist.length > 0) {//result Founded + + $(".noResult").remove(); + container.show(); + $.each(response.mylist, + function (i, item) { + let li = `
  • ${item.lName}
  • `; + searchResul.append(li); + + }); + } else {//result NotFounded + + $(".noResult").remove(); + container.show(); + let noResult = `
  • نتیجه ای یافت نشد
  • `; + searchResul.append(noResult); + } + }// endOfSuccess + + }); //endOfAjax + + } else { + container.hide(); + count = 0; + } + //keyboard Arrow Key Select And Enter + liList = $('#emp ul li'); + mixContainerAndSerchResult.animate({ + scrollTop: $(liList.eq(0)).offset().top - container.offset().top + container.scrollTop() + }, + 50); + if (e.which === 40) {// if ArrowUp + if (count > 0 && count <= liList.length) { + + liPointer.removeClass('keyboardSelected'); + console.log(count + "plusOne"); + liList.eq(count).addClass('keyboardSelected'); + liPointer = liList.eq(count); + if (count > 4) { + //ScrollDown + mixContainerAndSerchResult.animate({ + scrollTop: $(liPointer).offset().top - container.offset().top + container.scrollTop() + }, + 50); + } + count += 1; + + } else { + + liList.eq(0).addClass("keyboardSelected"); + liPointer = liList.eq(0); + count = 1; + } + } else if (e.which === 38) {//if ArrowDown + if (count > 0 && count <= liList.length) { + liPointer.removeClass('keyboardSelected'); + count -= 1; + liList.eq(count).addClass('keyboardSelected'); + liPointer = liList.eq(count); + //ScrollUp + mixContainerAndSerchResult.animate({ + scrollTop: $(liPointer).offset().top - container.offset().top + container.scrollTop() + }, + 50); + } + } + }); + + +$("#empSearchContractingPartyID").keypress(function (event) { + $(".form-control").removeClass("selectedOption"); + $("#empSearchNationalcode").val(''); + $("#SearchModel2_Nationalcode").val(''); + $("#empSearch").val(''); + $("#SearchModel2_EmployeeName").val(''); + $("#SearchModel2_id").val('0'); + + if (event.keyCode === 13) { + if ($("#SearchModel2_RepresentativeId").val() == "0") + $("#SearchModel2_RepresentativeName").val($(this).val()) + $("#btnSearch").click(); + } +}); + +$("#empSearch").keypress(function (event) { + $(".form-control").removeClass("selectedOption"); + $("#empSearchNationalcode").val(''); + $("#empSearchContractingPartyID").val(''); + $("#SearchModel2_RepresentativeName").val(''); + $("#SearchModel2_Nationalcode").val(''); + + if (event.keyCode === 13) { + if ($("#SearchModel2_id").val() == "0") + $("#SearchModel2_EmployeeName").val($("#empSearch").val()) + $("#btnSearch").click(); + } +}); + + + + +var containerContracting = $('#empContractingPartyID'); +var searchBoxContracting = $('#empSearchContractingPartyID'); +var hiddenInputValContracting = $('.sendContractingPartyID'); +var searchResulContracting = $('.searchResultContractingPartyID'); +var mixContainerAndSerchResultContracting = $('#empContractingPartyID , .searchResultContractingPartyID'); + +containerContracting.hide(); +var liListContracting; +var liPointerContracting; +let countContracting = 0; + +//close searchBoxContracting Employee when click on body +$(document).on('click', function (event) { + if (!$(event.target).closest(containerContracting).length) { + containerContracting.hide(); + } +}); +//select option by mouse +function selectItemContracting(id, employeeFullName) { + searchBoxContracting.val(employeeFullName); + hiddenInputValContracting.val(id); + containerContracting.hide(); + searchBoxContracting.addClass("selectedOption"); +}; +//searchBoxContracting by Ajax +searchBoxContracting.on('keyup keypress', + function (e) { + $(".form-control").removeClass("selectedOption"); + $("#empSearchNationalcode").val(''); + $("#empSearch").val(''); + $("#SearchModel2_EmployeeName").val(''); + $("#SearchModel2_id").val('0'); + $("#SearchModel2_Nationalcode").val(''); + + if ($(this).val() == '') { + $("#SearchModel_RepresentativeId").val("0"); + $("#SearchModel_RepresentativeName").val(''); + } + + //stop submit form with enter + var keyCode = e.keyCode || e.which; + if (keyCode === 13) { + e.preventDefault(); + if (countContracting > 0 && countContracting <= liListContracting.length) { + liPointerContracting.click(); + } + return false; + } + searchBoxContracting.removeClass("selectedOption"); + + let searchText = $(this).val(); + hiddenInputValContracting.val(0); + if (searchText.length > 1) { + $.ajax({ + async: false, + contentType: 'charset=utf-8', + dataType: 'json', + type: 'GET', + url: '@Url.Page("./Index", "RepresentativeList")', + data: { "searchText": searchText }, + headers: { "RequestVerificationToken": $('@Html.AntiForgeryToken()').val() }, + + success: function (response) { + $(".opt").remove(); + if (response.mylist.length > 0) {//result Founded + + $(".noResult").remove(); + containerContracting.show(); + $.each(response.mylist, + function (i, item) { + let li = `
  • ${item.fullName}
  • `; + searchResulContracting.append(li); + }); + } else {//result NotFounded + + $(".noResult").remove(); + containerContracting.show(); + let noResult = `
  • نتیجه ای یافت نشد
  • `; + searchResulContracting.append(noResult); + } + }// endOfSuccess + + }); //endOfAjax + + } else { + containerContracting.hide(); + countContracting = 0; + } + //keyboard Arrow Key Select And Enter + liListContracting = $('#empContractingPartyID ul li'); + mixContainerAndSerchResultContracting.animate({ + scrollTop: $(liListContracting.eq(0)).offset().top - containerContracting.offset().top + containerContracting.scrollTop() + }, + 50); + if (e.which === 40) {// if ArrowUp + if (countContracting > 0 && countContracting <= liListContracting.length) { + + liPointerContracting.removeClass('keyboardSelected'); + console.log(countContracting + "plusOne"); + liListContracting.eq(countContracting).addClass('keyboardSelected'); + liPointerContracting = liListContracting.eq(countContracting); + if (countContracting > 4) { + //ScrollDown + mixContainerAndSerchResultContracting.animate({ + scrollTop: $(liPointerContracting).offset().top - containerContracting.offset().top + containerContracting.scrollTop() + }, + 50); + } + countContracting += 1; + + } else { + + liListContracting.eq(0).addClass("keyboardSelected"); + liPointerContracting = liListContracting.eq(0); + countContracting = 1; + } + } else if (e.which === 38) {//if ArrowDown + if (countContracting > 0 && countContracting <= liListContracting.length) { + liPointerContracting.removeClass('keyboardSelected'); + countContracting -= 1; + liListContracting.eq(countContracting).addClass('keyboardSelected'); + liPointerContracting = liListContracting.eq(countContracting); + //ScrollUp + mixContainerAndSerchResultContracting.animate({ + scrollTop: $(liPointerContracting).offset().top - containerContracting.offset().top + containerContracting.scrollTop() + }, + 50); + } + } + }); + + + +var containerNationalcode = $('#empNationalcode'); +var searchBoxNationalcode = $('#empSearchNationalcode'); +var hiddenInputValNationalcode = $('.sendNationalcode'); +var searchResulNationalcode = $('.searchResultNationalcode'); +var mixContainerAndSerchResultNationalcode = $('#empNationalcode , .searchResultNationalcode'); + +containerNationalcode.hide(); +var liListNationalcode; +var liPointerNationalcode; +let countNationalcode = 0; + +//close searchBoxNationalcode Employee when click on body +$(document).on('click', function (event) { + if (!$(event.target).closest(containerNationalcode).length) { + containerNationalcode.hide(); + } +}); +//select option by mouse +function selectItemNationalcode(id, nationalcode) { + searchBoxNationalcode.val(nationalcode); + hiddenInputValNationalcode.val(nationalcode); + containerNationalcode.hide(); + searchBoxNationalcode.addClass("selectedOption"); +}; +//searchBoxNationalcode by Ajax +searchBoxNationalcode.on('keyup keypress', + + function (e) { + $(".form-control").removeClass("selectedOption"); + $("#empSearchContractingPartyID").val(''); + $("#SearchModel2_RepresentativeName").val(''); + $("#empSearch").val(''); + $("#SearchModel2_EmployeeName").val(''); + $("#SearchModel2_id").val('0'); + + if ($(this).val() == '') { + $("#SearchModel2_Nationalcode").val(""); + $("#empSearchNationalcode").val(''); + } + + //stop submit form with enter + var keyCode = e.keyCode || e.which; + if (keyCode === 13) { + e.preventDefault(); + if (countNationalcode > 0 && countNationalcode <= liListNationalcode.length) { + liPointerNationalcode.click(); + } + return false; + } + + searchBoxNationalcode.removeClass("selectedOption"); + + + let searchText = $(this).val(); + hiddenInputValNationalcode.val(0); + + if (searchText.length > 1) { + + $.ajax({ + async: false, + contentType: 'charset=utf-8', + dataType: 'json', + type: 'GET', + url: '@Url.Page("./Index", "PersonalContractingPartyNationalcode")', + data: { "searchText": searchText }, + headers: { "RequestVerificationToken": $('@Html.AntiForgeryToken()').val() }, + success: function (response) { + $(".opt").remove(); + if (response.mylist.length > 0) {//result Founded + $(".noResult").remove(); + containerNationalcode.show(); + $.each(response.mylist, + function (i, item) { + let li = `
  • ${item.nationalcode}
  • `; + searchResulNationalcode.append(li); + }); + } else {//result NotFounded + + $(".noResult").remove(); + containerNationalcode.show(); + let noResult = `
  • نتیجه ای یافت نشد
  • `; + searchResulNationalcode.append(noResult); + } + }// endOfSuccess + + }); //endOfAjax + + } else { + containerNationalcode.hide(); + countNationalcode = 0; + } + //keyboard Arrow Key Select And Enter + liListNationalcode = $('#empNationalcode ul li'); + mixContainerAndSerchResultNationalcode.animate({ + scrollTop: $(liListNationalcode.eq(0)).offset().top - containerNationalcode.offset().top + containerNationalcode.scrollTop() + }, + 50); + if (e.which === 40) {// if ArrowUp + if (countNationalcode > 0 && countNationalcode <= liListNationalcode.length) { + + liPointerNationalcode.removeClass('keyboardSelected'); + console.log(countNationalcode + "plusOne"); + liListNationalcode.eq(countNationalcode).addClass('keyboardSelected'); + liPointerNationalcode = liListNationalcode.eq(countNationalcode); + if (countNationalcode > 4) { + //ScrollDown + mixContainerAndSerchResultNationalcode.animate({ + scrollTop: $(liPointerNationalcode).offset().top - containerNationalcode.offset().top + containerNationalcode.scrollTop() + }, + 50); + } + countNationalcode += 1; + + } else { + + liListNationalcode.eq(0).addClass("keyboardSelected"); + liPointerNationalcode = liListNationalcode.eq(0); + countNationalcode = 1; + } + } else if (e.which === 38) {//if ArrowDown + if (countNationalcode > 0 && countNationalcode <= liListNationalcode.length) { + liPointerNationalcode.removeClass('keyboardSelected'); + countNationalcode -= 1; + liListNationalcode.eq(countNationalcode).addClass('keyboardSelected'); + liPointerNationalcode = liListNationalcode.eq(countNationalcode); + //ScrollUp + mixContainerAndSerchResultNationalcode.animate({ + scrollTop: $(liPointerNationalcode).offset().top - containerNationalcode.offset().top + containerNationalcode.scrollTop() + }, + 50); + } + } + }); + +$("#empSearchNationalcode").keypress(function (event) { + // console.log(123); + if (event.keyCode === 13) { + $(".form-control").removeClass("selectedOption"); + $("#empSearchContractingPartyID").val(''); + $("#empSearch").val(''); + $("#SearchModel2_RepresentativeName").val(''); + $("#SearchModel2_EmployeeName").val(''); + $("#SearchModel2_id").val('0'); + + $("#SearchModel2_Nationalcode").val($("#empSearchNationalcode").val()); + $("#btnSearch").click(); + } +}); + +$(".btn-searchContractingParties").click(function () { + + if ($("#SearchModel2_EmployeeId").val() == "0" || $("#SearchModel2_EmployeeId").val() == "") + $("#SearchModel2_EmployeeName").val($("#empSearch").val()); + + if ($("#SearchModel2_RepresentativeId").val() == "0" || $("#SearchModel2_RepresentativeId").val() == "") + $("#SearchModel2_RepresentativeName").val($("#empSearchContractingPartyID").val()); + + if ($("#empSearchNationalcode").val() != "0" && $("#empSearchNationalcode").val() != "") + $("#SearchModel2_Nationalcode").val($("#empSearchNationalcode").val()); + + + if ($("#empSearch").val() == "0") + $("#empSearch").val(''); + + $("#btnSearch").click(); +}); + +function remove(id, hasInstitutionContract, hasEmployer) { + + console.log(hasInstitutionContract); + + //اگر همزمان در تب جدید قرارداد غیر فعال شو، پیغاماشتابه نمایش داده میشود + // if(hasInstitutionContract=="True") + // { + // swal({ + // title: "حذف این طرف حساب به دلیل دارا بودن قرارداد مالی امکان پذیر نمی باشد.", + // text: "در صورت تمایل به حذف یا غیر فعال سازی این طرف حساب، می بایست کلیه عملیات مربوط به این طرف حساب را حذف نمایید.", + // type: "warning", + // showCancelButton: true, + // confirmButtonColor: "#DD6B55", + // //confirmButtonText: "بستن", + // cancelButtonText: "بستن", + // closeOnConfirm: false, + // closeOnCancel: true, + // customClass: "errorSwall" + // }); + + // } + // else + // { + $('.sweet-alert').removeClass("successSwall"); + $('.sweet-alert').removeClass("errorSwall"); + swal({ + title: hasEmployer > 0 ? "توجه داشته باشید حذف کامل از دیتابیس میسر نمی باشد،اما با تایید این پیام این طرف حساب و کلیه عملیات مربوط به آن غیرفعال می گردد." : "توجه داشته باشید با تایید این پیام، اطلاعات لیست مورد نظر بطور کامل از بانک اطلاعاتی حذف خواهد شد.", + text: "", + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText: "بله", + cancelButtonText: "خیر", + closeOnConfirm: false, + closeOnCancel: true, + customClass: "questionSwall" + }, function (isConfirm) { + if (isConfirm) { + + $.ajax({ + async: false, + dataType: 'json', + type: 'POST', + url: '@Url.Page("./Index", "DeletePersonalContractingParties")', + headers: { "RequestVerificationToken": $('@Html.AntiForgeryToken()').val() }, + data: { "id": id }, + success: function (response) { + + if (response.isSuccedded) { + swal({ + title: "حذف با موفقیت انجام شد.", + text: "", + type: "success", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText: "بستن", + //cancelButtonText: "خیر", + closeOnConfirm: true, + customClass: "successSwall" + }, + function (isConfirm) { + if (isConfirm) { + //$("#btnSearch").click(); + var url = '@Url.Page("/Company/ContractingParties/Index")'; + window.location.href = url; + } + }); + } + else { + + if (response.message == "DeActive") { + swal({ + title: "غیرفعال شدن این طرف حساب با موفقیت انجام شد.", + text: "به منظور حذف از دیتابیس باید کلیه عملیات مربوط به این طرف حساب را حذف نمایید.", + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText: "بستن", + cancelButtonText: "بستن", + closeOnConfirm: true, + closeOnCancel: true, + customClass: "warningSwall2" + }, + function (isConfirm) { + if (isConfirm) { + //$("#btnSearch").click(); + var url = '@Url.Page("/Company/ContractingParties/Index")'; + window.location.href = url; + } + }); + } + else { + swal({ + title: response.message, + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + //confirmButtonText: "بستن", + cancelButtonText: "بستن", + closeOnConfirm: false, + closeOnCancel: true, + customClass: "errorSwall" + }); + } + } + }, + failure: function (response) { + console.log(5, response) + } + }); + } + + }); + // } +} + + + + +function removeHasInstitutionContract(id, hasInstitutionContract, hasEmployer) { + + $('.sweet-alert').removeClass("successSwall"); + $('.sweet-alert').removeClass("errorSwall"); + + //اگر همزمان در تب جدید قرارداد غیر فعال شو، پیغاماشتابه نمایش داده میشود + // if(hasInstitutionContract=="True") + // { + // swal({ + // title: "حذف این طرف حساب به دلیل دارا بودن قرارداد مالی امکان پذیر نمی باشد.", + // text: "در صورت تمایل به حذف یا غیر فعال سازی این طرف حساب، می بایست کلیه عملیات مربوط به این طرف حساب را حذف نمایید.", + // type: "warning", + // showCancelButton: true, + // confirmButtonColor: "#DD6B55", + // //confirmButtonText: "بستن", + // cancelButtonText: "بستن", + // closeOnConfirm: false, + // closeOnCancel: true, + // customClass: "errorSwall" + // }); + + // } + // else + // { + $.ajax({ + async: false, + dataType: 'json', + type: 'POST', + url: '@Url.Page("./Index", "CheckHasContract")', + headers: { "RequestVerificationToken": $('@Html.AntiForgeryToken()').val() }, + data: { "id": id }, + success: function (response) { + + if (response.isSuccedded) { + removePersonalContractingParties(id); + } + else { + swal({ + title: "حذف این طرف حساب به دلیل دارا بودن قرارداد مالی امکان پذیر نمی باشد.", + text: "در صورت تمایل به حذف یا غیر فعال سازی این طرف حساب، می بایست کلیه عملیات مربوط به این طرف حساب را حذف نمایید.", + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + //confirmButtonText: "بستن", + cancelButtonText: "بستن", + closeOnConfirm: false, + closeOnCancel: true, + customClass: "errorSwall" + }); + } + }, + failure: function (response) { + console.log(5, response) + } + }); +} + + + +function removePersonalContractingParties(id) { + + $('.sweet-alert').removeClass("successSwall"); + $('.sweet-alert').removeClass("errorSwall"); + + $.ajax({ + async: false, + dataType: 'json', + type: 'POST', + url: '@Url.Page("./Index", "DeletePersonalContractingParties")', + headers: { "RequestVerificationToken": $('@Html.AntiForgeryToken()').val() }, + data: { "id": id }, + success: function (response) { + + if (response.isSuccedded) { + swal({ + title: "حذف با موفقیت انجام شد.", + text: "", + type: "success", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText: "بستن", + //cancelButtonText: "خیر", + closeOnConfirm: true, + customClass: "successSwall" + }, + function (isConfirm) { + if (isConfirm) { + //$("#btnSearch").click(); + var url = '@Url.Page("/Company/ContractingParties/Index")'; + window.location.href = url; + } + }); + } + else { + + if (response.message == "DeActive") { + swal({ + title: "غیرفعال شدن این طرف حساب با موفقیت انجام شد.", + text: "به منظور حذف از دیتابیس باید کلیه عملیات مربوط به این طرف حساب را حذف نمایید.", + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText: "بستن", + cancelButtonText: "بستن", + closeOnConfirm: true, + closeOnCancel: true, + customClass: "warningSwall2" + }, + function (isConfirm) { + if (isConfirm) { + //$("#btnSearch").click(); + var url = '@Url.Page("/Company/ContractingParties/Index")'; + window.location.href = url; + } + }); + } + else { + swal({ + title: response.message, + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + //confirmButtonText: "بستن", + cancelButtonText: "بستن", + closeOnConfirm: false, + closeOnCancel: true, + customClass: "errorSwall" + }); + } + } + }, + failure: function (response) { + console.log(5, response) + } + }); +} + + +function acitve(id) { + $('.sweet-alert').removeClass("successSwall"); + $('.sweet-alert').removeClass("errorSwall"); + swal({ + title: "آیا از فعال کردن این طرف حساب مطمئن هستید؟", + text: "", + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText: "بله", + cancelButtonText: "خیر", + closeOnConfirm: false, + closeOnCancel: true + }, function (isConfirm) { + if (isConfirm) { + + $.ajax({ + async: false, + dataType: 'json', + type: 'POST', + url: '@Url.Page("./Index", "ActivePersonalContractingParties")', + headers: { "RequestVerificationToken": $('@Html.AntiForgeryToken()').val() }, + data: { "id": id }, + success: function (response) { + // console.log(response); + if (response.isSuccedded) { + swal({ + title: response.message, + text: "", + type: "success", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText: "بستن", + //cancelButtonText: "خیر", + closeOnConfirm: true, + customClass: "successSwall" + }, + function (isConfirm) { + if (isConfirm) { + var url = '@Url.Page("/Company/ContractingParties/Index")'; + window.location.href = url; + // $("#btnSearch").click(); + } + }); + + } + else { + swal({ + title: response.message, + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + //confirmButtonText: "بستن", + cancelButtonText: "بستن", + closeOnConfirm: false, + closeOnCancel: true, + customClass: "errorSwall" + }); + } + + }, + failure: function (response) { + console.log(5, response) + } + }); + } + + }); +} + + +function block(id) { + $('.sweet-alert').removeClass("successSwall"); + $('.sweet-alert').removeClass("errorSwall"); + swal({ + title: "آیا از مسدود کردن این طرف حساب مطمئن هستید؟", + text: "", + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText: "بله", + cancelButtonText: "خیر", + closeOnConfirm: false, + closeOnCancel: true + }, function (isConfirm) { + if (isConfirm) { + + $.ajax({ + async: false, + dataType: 'json', + type: 'POST', + url: '@Url.Page("./Index", "BlockPersonalContractingParties")', + headers: { "RequestVerificationToken": $('@Html.AntiForgeryToken()').val() }, + data: { "id": id }, + success: function (response) { + // console.log(response); + if (response.isSuccedded) { + swal({ + title: response.message, + text: "", + type: "success", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText: "بستن", + //cancelButtonText: "خیر", + closeOnConfirm: true, + customClass: "successSwall" + }, + function (isConfirm) { + if (isConfirm) { + $("#btnSearch").click(); + } + }); + + } + else { + + swal({ + title: response.message, + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + //confirmButtonText: "بستن", + cancelButtonText: "بستن", + closeOnConfirm: false, + closeOnCancel: true, + customClass: "errorSwall" + }); + } + }, + failure: function (response) { + console.log(5, response) + } + }); + } + }); +} +function disableBlock(id, blocktime) { + $('.sweet-alert').removeClass("successSwall"); + $('.sweet-alert').removeClass("errorSwall"); + + if (blocktime == 2) { + swal({ + title: "آخرین حد مجاز برای خارج کردن از حالت مسدود 2 بار می باشد.", + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + //confirmButtonText: "بستن", + cancelButtonText: "بستن", + closeOnConfirm: false, + closeOnCancel: true, + customClass: "errorSwall" + }); + } + else { + swal({ + title: "آیا میخواهید این طرف حساب را از حالت مسدود خارج نمایید؟ ", + text: "", + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText: "بله", + cancelButtonText: "خیر", + closeOnConfirm: false, + closeOnCancel: true + }, function (isConfirm) { + if (isConfirm) { + + $.ajax({ + async: false, + dataType: 'json', + type: 'POST', + url: '@Url.Page("./Index", "DisableBlockPersonalContractingParties")', + headers: { "RequestVerificationToken": $('@Html.AntiForgeryToken()').val() }, + data: { "id": id }, + success: function (response) { + //console.log(response); + if (response.isSuccedded) { + swal({ + title: response.message, + text: "", + type: "success", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText: "بستن", + //cancelButtonText: "خیر", + closeOnConfirm: true, + customClass: "successSwall" + }, + function (isConfirm) { + if (isConfirm) { + $("#btnSearch").click(); + } + }); + + } + + else { + + swal({ + title: response.message, + // text: "برای حذف قرارداد، ابتدا تیک مربوط به امضای قرارداد را حذف نمایید.", + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + //confirmButtonText: "بستن", + cancelButtonText: "بستن", + closeOnConfirm: false, + closeOnCancel: true, + customClass: "errorSwall" + }); + } + }, + failure: function (response) { + console.log(5, response) + } + }); + } + }); + } +} + + + +$(window).on('resize', function () { + if ($(window).width() < 768) { + locateButtonContainerMobile(); + } + //if ($(window).width() > 768) { + // locateButtonContainer(); + //} +}); +$(document).on("click", function (event) { + var target = $(event.target); + if (!target.closest(".buttons-container").length + && !target.is(".employee-operations") + && !target.is("#createContractingParty") + && !target.is("#createContractingParty *") + && !target.is("#ContractingPartyDetails") + && !target.is("#ContractingPartyDetails *") + && !target.is("#ContractingPartyEdit") + && !target.is("#ContractingPartyEdit *") + && !target.is("#insertLegal") + && !target.is("#insertLegal *") + && !target.is("#legalDetails") + && !target.is("#legalDetails *") + && !target.is("#legalEdit") + && !target.is("#legalEdit *") + ) { + $(".buttons-container").removeClass("active").addClass("reverse"); + $(".more-buttons").removeClass("active"); + setTimeout(function () { + $(".buttons-container").removeClass("reverse").css("display", "none"); + }, 200); + } +}); +$(".employee-operations").on("click", function () { + if ($(window).width() < 768) { + locateButtonContainerMobile(); + } + //if ($(window).width() > 768) { + // locateButtonContainer(); + //} + var buttonsContainer = $(this).next(".buttons-container"); + if (buttonsContainer.hasClass("active")) { + buttonsContainer.removeClass("active").addClass("reverse"); + $(this).closest(".more-buttons").removeClass("active"); + setTimeout(function () { + buttonsContainer.removeClass("reverse").css("display", "none"); + }, 200); + } else { + buttonsContainer.removeClass("reverse").addClass("active").css("display", "flex"); + $(this).closest(".more-buttons").addClass("active"); + } + + $(".buttons-container").not(buttonsContainer).removeClass("active reverse").css("display", "none"); + $(".more-buttons").not($(this).closest(".more-buttons")).removeClass("active"); +}); +//function locateButtonContainer() { +// var beforePosition = $(".screen-view .employee-operations").position(); +// var containerWidth = $('.screen-view .buttons-container').outerWidth(); +// var containerHeight = $('.screen-view .buttons-container').outerHeight(); +// var containerLeft = beforePosition.left + $(".screen-view .employee-operations").outerWidth() + 20; +// var containerTop = beforePosition.top + ($(".screen-view .employee-operations").outerHeight() / 2) - (containerHeight / 2); +// $('.screen-view .buttons-container').css({ +// left: containerLeft, +// top: containerTop +// }); +//} +function locateButtonContainerMobile() { + var beforePosition = $(".mobile-view .employee-operations").position(); + var containerWidth = $('.mobile-view .buttons-container').outerWidth(); + var containerHeight = $('.mobile-view .buttons-container').outerHeight(); + var containerLeft = beforePosition.left + $(".mobile-view .employee-operations").outerWidth() + 25; + var containerTop = beforePosition.top + ($(".mobile-view .employee-operations").outerHeight() / 2) - (containerHeight / 2); + $('.mobile-view .buttons-container').css({ + left: containerLeft, + top: containerTop + }); +} + + +function removeByEmployer(id) { + + + $('.sweet-alert').removeClass("successSwall"); + $('.sweet-alert').removeClass("errorSwall"); + swal({ + title: "توجه داشته باشید با تایید این پیام، اطلاعات لیست مورد نظر بطور کامل از بانک اطلاعاتی حذف خواهد شد.", + text: "", + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText: "بله", + cancelButtonText: "خیر", + closeOnConfirm: false, + closeOnCancel: true + }, function (isConfirm) { + if (isConfirm) { + swal({ + title: "حذف کامل از دیتابیس میسر نمی باشد،اما این طرف حساب غیرفعال می گردد.", + text: "به منظور حذف از دیتابیس باید کلیه عملیات مربوط به این طرف حساب را حذف نمایید.", + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + //confirmButtonText: "بستن", + cancelButtonText: "بستن", + closeOnConfirm: false, + closeOnCancel: true, + customClass: "errorSwall" + }); + } + }); + +} + + + + diff --git a/ServiceHost/wwwroot/AssetsAdminNew/Employers/css/Index.css b/ServiceHost/wwwroot/AssetsAdminNew/Employers/css/Index.css new file mode 100644 index 00000000..f7c4e34a --- /dev/null +++ b/ServiceHost/wwwroot/AssetsAdminNew/Employers/css/Index.css @@ -0,0 +1,378 @@ + +.thh0 { + width: 8px !important; +} + +.thh { + width: 40px !important; +} + +.thh2 { + width: 130px !important; +} + +.thhNastionalId { + width: 30px !important; +} + +.inpt { + width: 100%; + border: 1px solid #c7c7c7; +} + +.searchpanel { + background-color: #747272; +} + +.table-bordered { + border-left: 0px !important; + border-right: 0px !important; +} + +.table > tbody > tr > td { + padding: 4px 8px; +} + +table.dataTable thead > tr > th { + padding: 8px; +} + +table.dataTable thead .sorting:after, +table.dataTable thead .sorting_desc:after, +table.dataTable thead .sorting_asc:after { + opacity: 0; +} + +select { + cursor: pointer; +} + +.btn-table { + border-radius: 8px !important; + padding: 2px 5px 0px 5px; + border-radius: 8px; + padding: 4px 8px; + font-size: 20px; +} + +.operation-td { + display: flex; + justify-content: flex-end; +} + +.withOutContractingParty { + background-color: #ffbfbf !important; +} + +.name-td { + font-size: 14px !important; + max-width: 100px; + position: relative; +} + +.ellipsed { + display: block; + width: 100%; + text-overflow: ellipsis; + overflow-x: clip; + white-space: nowrap; +} + +.tooltipfull-container { + cursor: pointer; + position: absolute; + display: inline-block; + right: 9px; + top: 13px; +} + +.tooltipfull { + opacity: 0; + z-index: 99; + color: #fff; + /* width: 180px; */ + display: block; + font-size: 12px; + font-family: 'IranSans'; + padding: 5px 10px; + border-radius: 15px; + text-align: center; + /* text-shadow: 1px 1px 2px #111; */ + background: #364562; + border: 1px solid #364562; + box-shadow: 0 0 3px rgba(0,0,0,0.5); + -webkit-transition: all .2s ease-in-out; + -moz-transition: all .2s ease-in-out; + -o-transition: all .2s ease-in-out; + /* -ms-transition: all .2s ease-in-out; */ + transition: all .2s ease-in-out; + -webkit-transform: scale(0); + -moz-transform: scale(0); + -o-transform: scale(0); + -ms-transform: scale(0); + transform: scale(0); + position: absolute; + right: -2px; + bottom: 30px; + white-space: nowrap; +} + +.tooltipfull-container:hover .tooltipfull, a:hover .tooltipfull { + opacity: 1; + -webkit-transform: scale(1); + -moz-transform: scale(1); + -o-transform: scale(1); + -ms-transform: scale(1); + transform: scale(1); +} + +.tooltipfull:before, .tooltipfull:after { + content: ''; + border-left: 10px solid transparent; + border-right: 10px solid transparent; + border-top: 10px solid #364562; + position: absolute; + bottom: -10px; + right: 20px; +} + +.fulltext { + opacity: 0; + white-space: nowrap; +} + +.workshop-td { + max-width: 300px; +} + +.code-td { + font-family: 'IranText' !important; + font-size: 14px !important; + text-align: center; + max-width: 50px; +} + +.mobile-view { + display: none; +} + +.screen-view { + display: flex; +} + +.addActualEmployer { + background-color: #f5f5f5; + border-color: #0f9500; + color: #0f9500 !important; + border-radius: 2em; + border-top-left-radius: 0px; + border-bottom-left-radius: 0px; +} + +.addLegalEmployer { + background-color: #f5f5f5; + border-color: #1d92e5; + color: #1d92e5 !important; + border-radius: 2em; + border-top-right-radius: 0px; + border-bottom-right-radius: 0px; +} + +.addActualEmployer:hover, .addActualEmployer:focus { + background-color: #f5f5f5; + border-color: #0f9500; + color: #0f9500 !important; + box-shadow: 0 2px 5px 0 rgba(0,0,0,.16), 0 2px 10px 0 rgba(0,0,0,.12); +} + +.addLegalEmployer:hover, .addLegalEmployer:focus { + background-color: #f5f5f5; + border-color: #1d92e5; + color: #1d92e5 !important; + box-shadow: 0 2px 5px 0 rgba(0,0,0,.16), 0 2px 10px 0 rgba(0,0,0,.12); +} + +.code-th { + max-width: 40px; +} + +.searchOne { + border-bottom-left-radius: 0px; + border-top-left-radius: 0px; + background-color: #364562; + border-color: #364562; + margin-left: -3px; +} + + .searchOne:hover, .searchOne:focus { + background-color: #364562; + border-color: #364562; + } + +.searchAll { + border-bottom-right-radius: 0px; + border-top-right-radius: 0px; + background-color: #545353; + border-color: #545353; +} + + .searchAll:hover, .searchAll:focus { + background-color: #545353; + border-color: #545353; + } + +.searchOne i { + padding-left: 3px; + font-size: 14px; +} + +@media(max-width: 1550px) { + .code-th { + max-width: 80px; + } +} + +@media(max-width: 768px) { + .name-td { + font-size: 12px !important; + } + + .mobile-view { + display: block; + } + + .screen-view { + display: none; + } + + .addLegalEmployer, .addActualEmployer { + border-top-right-radius: 2em; + border-bottom-right-radius: 2em; + border-top-left-radius: 2em; + border-bottom-left-radius: 2em; + padding: 5px 3px; + font-size: 12px; + } + + .xs-middle { + margin: auto; + float: none; + display: flex; + justify-content: center; + column-gap: 4px; + } + + .xs-middle .btn-rounded { + padding: 6px 5px; + font-size: 12px; + } + + .searchOne, .searchAll { + padding: 6px 9px; + font-size: 10px; + } + + .searchOne i, #activing, .employerType { + font-size: 10px; + } + + .searchOne { + margin-left: -4px; + } + + .form-control { + font-size: 11px; + } + + .right-one { + padding-left: 0; + } + + .left-one { + padding-right: 0; + } + + #activing { + padding: 0; + } + + .top-btns { + display: flex; + justify-content: space-around; + } +} + + + +::-webkit-scrollbar { + width: 8px; +} + +::-webkit-scrollbar-track { + background: #dfdfdf; + border-radius: 5px; +} + +::-webkit-scrollbar-thumb { + background: #c1d1f2; + border-radius: 5px; +} + +.opt { + background-color: #e8edf7; + border-radius: 10px; + text-align: right; + padding: 2px 5px; + text-overflow: ellipsis; + overflow-x: hidden; + width: 100%; +} + +.noResult { + background-color: #dce5f7; + border-radius: 10px; + text-align: right; + padding: 2px 5px; +} + + .opt:hover, .noResult:hover { + background-color: #dce5f7 !important; + color: #343434 !important; + } + +.selectDiv { + position: relative; + z-index: 2; + border-radius: 10px; + min-height: 20px; + max-height: 190px; + overflow: hidden scroll; + width: 100%; + background-color: rgb(255 255 255); + display: block; + box-shadow: 0px -1px 12px 0px rgba(0,0,0,.16), 2px 1px 10px 0 rgba(0,0,0,.12); +} + +.selectedOption { + color: #6f7072 !important; + background-color: #e2eafb !important; +} + +.keyboardSelected { + color: #424242 !important; + background-color: #c8d5ef !important; +} + +.bgGray, .bgGray:hover { + background-color: #b5b5b5 !important; + color: #646464; +} + +a.disabled { + pointer-events: none; + cursor: default; + background-color: grey !important; + border-color: grey !important; +} + + diff --git a/ServiceHost/wwwroot/AssetsAdminNew/Report/css/Index.css b/ServiceHost/wwwroot/AssetsAdminNew/Report/css/Index.css new file mode 100644 index 00000000..af215297 --- /dev/null +++ b/ServiceHost/wwwroot/AssetsAdminNew/Report/css/Index.css @@ -0,0 +1,82 @@ + +.goToTop { + position: fixed; + bottom: 40px; + } + +.clear { + background: #0ea5e9; + color: #fff !important; + padding: 4px 8px; + border-radius: 7px; + margin: 0 0 0 3px; + transition: all .2s ease; +} + +.clear:hover { + background: #0284c7 +} + +.slick-list { + padding-top: 4px !important; + padding-bottom: 4px !important; +} + +.textsChart { + gap: 3px; + display: grid; +} + +.alltxt, .alldonetxt, .allnotdonetxt { + margin: 0; + padding: 2px 5px; + font-size: 12px; + text-align: left; + border-radius: 4px; +} + +.alltxt { + color: #1e293b; +} + +.alldonetxt { + color: #65a30d; +} + +.allnotdonetxt { + color: #dc2626; +} + +tr.sticky { + position: sticky; + top: -7px; + z-index: 1; + background: #f7f9fb; +} + +#ContractSignPercentDivMobile, +#CheckoutDonePercentDivMobile, +#CheckoutSignPercentDivMobile { + display: none; + visibility: hidden; + opacity: 0; +} + +.showing { + visibility: visible !important; + opacity: 1 !important; + transition: opacity 0.3s ease-in; +} + +.btn-print { + background: #2563eb; + display: flex; + width: 30px; + height: 30px; + align-items: center; + justify-content: center; + border-radius: 3px; + margin: 0; +} + + diff --git a/ServiceHost/wwwroot/AssetsAdminNew/Report/css/PrintAll.css b/ServiceHost/wwwroot/AssetsAdminNew/Report/css/PrintAll.css new file mode 100644 index 00000000..92739b04 --- /dev/null +++ b/ServiceHost/wwwroot/AssetsAdminNew/Report/css/PrintAll.css @@ -0,0 +1,446 @@ + +#MainModal { + backdrop-filter: blur(8px); +} + +.modal .modal-dialog .modal-content { + background-color: white; + padding: 0px 30px 0 30px; +} + +.modal-header { + padding: 1rem 0rem !important; +} + +.modal .modal-dialog .modal-content .modal-body { + padding: 0 !important; +} + +.modal-dialog { + width: 1200px !important; +} + +.printBtns { + padding: 12px 2px 12px; + border-top: unset; + position: fixed; + top: 10%; + left: 50%; + transform: translateX(-800%); + display: flex; + flex-direction: column; + background: white; + align-items: center; + border-radius: 9px; + z-index: 9999999; + transition: none; +} + +@media (max-width: 1550px) { + .printBtns { + transform: translateX(-680%); + } +} + +#printThis .modal-content { + background-clip: padding-box; + background: black !important; +} + +#printThis h1, h2, h3, h4, h5, h6 { + color: black; + margin: 1rem 0; +} + +.top-title { + text-align: center; +} + +.list-no { + display: flex; + justify-content: center; + align-items: center; + margin: 1rem 0; +} + + .list-no h4 { + margin: 0 9rem; + } + +.table-title { + display: flex; + justify-content: space-between; + padding: 0 1rem; + border: 1px solid black; + border-top-right-radius: 9px; + border-top-left-radius: 9px; + border-bottom: 0; +} + + .table-title h4 { + font-size: 1.5rem; + } + +#printThis table { + direction: ltr; + width: 100%; +} + +#printThis .table-bordered { + border: 1px solid #94a3b8; + border-radius: 9px; + border-collapse: separate; + margin-bottom: 0; + table-layout: fixed; + width: 100%; +} + + #printThis .table-bordered > thead > tr > th { + font-size: 1.3rem; + color: black; + text-align: center; + vertical-align: middle; + padding: 0; + border: 1px solid #c7c7c7 !important; + background: #ddd; + } + + #printThis .table-bordered > tbody > tr > td { + padding: 8px 2px; + text-align: center; + font-size: 10px; + border: 1px solid #c7c7c7 !important; + background: transparent; + } + + #printThis .table-bordered > tbody > tr.withdraw > td { + background-color: #b5b5b5 !important; + } + +#printThis tr:nth-child(2n) td { + background: #f0f0f0 !important; +} + +tr td:first-child { + border-top-right-radius: 0px; + border-bottom-right-radius: 0px; +} + +tr td:last-child { + border-top-left-radius: 0px; + border-bottom-left-radius: 0px; +} + +tr th:first-child { + border-top-right-radius: 0px; + border-bottom-right-radius: 0px; +} + +tr th:last-child { + border-top-left-radius: 0px; + border-bottom-left-radius: 0px; +} + +.printBtns .btn-rounded { + margin-left: 0.5rem; + margin-right: 0.5rem; + padding: 5px 18px; +} + +#printThis .colgp-1 { + width: 10%; +} + +#printThis .colgp-2 { + width: 10%; +} + +#printThis .colgp-3 { + width: 30%; +} + +#printThis .colgp-4 { + width: 50%; +} + +.data-total { + border-top: 1px solid black; + margin-top: 2rem; + padding-top: 0.5rem; +} + +#printThis .table-bordered .total td { + background: #dfdfdf !important; +} + +.bl-hidden { + border-left: hidden !important; +} + +.table-name { + font-family: 'IranSans' !important; + text-align: right !important; + white-space: nowrap !important; + max-width: 100%; + width: 80px; + overflow-x: clip; + direction: rtl; +} + +.table-bordered tr:nth-child(10) { + page-break-after: always; +} + +@media screen { + #printSection { + display: none; + } +} + +@media (max-width: 1550px) { + .modal-dialog { + width: 1000px !important; + } + + .table-title h4 { + font-size: 1.3rem; + } + + .top-title h1 { + font-size: 2.5rem; + } + + .top-title h4 { + font-size: 1.5rem; + } + + .list-no h4 { + margin: 0 8rem; + } + + #printThis .table-bordered { + border: 1px solid #000000 !important; + border-radius: 9px !important; + } + + #printThis .table-bordered > thead > tr > th { + font-size: 1.1rem; + } + + #printThis .table-bordered > tbody > tr > td { + font-size: 10px; + } +} + +@page { + size: A4; + margin: 0mm; + page-break-after: auto; +} + +@media print { + body * { + visibility: hidden; + page-break-after: auto; + -webkit-print-color-adjust: exact; + print-color-adjust: exact; + } + + html, body { + height: 100%; + margin: 0 !important; + padding: 0 !important; + overflow: clip; + } + + .modal-dialog { + max-width: 100%; + width: 60cm; + } + + .modal .modal-dialog .modal-content { + padding: 0; + } + + #printSection, #printSection * { + visibility: visible; + page-break-after: auto; + } + + #printSection { + width: 27.5cm; + position: absolute; + left: 0; + page-break-after: auto; + top: 0; + padding: 2rem 0; + } + + #printThis { + padding: 2rem 1rem; + } + + + #printThis .table-bordered { + border-collapse: separate !important; + margin-bottom: 0; + table-layout: fixed; + width: 100%; + border: 0 !important; + } + + #printThis .table-bordered > thead > tr > th { + font-size: 1.2rem !important; + color: black; + text-align: center; + vertical-align: middle; + padding: 0; + border: 1px solid black; + background: #ddd; + -webkit-print-color-adjust: exact !important; + print-color-adjust: exact !important; + } + + #printThis tr:nth-child(2n) td { + background: #f0f0f0 !important; + } + + #printThis .table-bordered > tbody > tr > td { + padding: 8px 2px; + text-align: center; + font-size: 10px !important; + border: 1px solid black; + } + + #printThis .table-bordered > thead > td:first-child { + border: 9px !important; + } + + #printThis .table-bordered > thead > td:last-child { + border: 9px !important; + } + + + #printThis .colgp-1 { + width: 10%; + } + + #printThis .colgp-2 { + width: 10%; + } + + #printThis .colgp-3 { + width: 30%; + } + + #printThis .colgp-4 { + width: 50%; + } + + .bl-hidden { + border-left: hidden !important; + } + + .table-name { + padding: 8px 0; + } + + #printThis .table-bordered > thead tr:first-child { + border: 0 !important; + } + + #printThis .titleSection { + border: 1px solid #94a3b8 !important; + border-bottom: 0 !important; + border-radius: 10px 10px 0 0 !important; + background: #fff !important; + -webkit-print-color-adjust: exact !important; + print-color-adjust: exact !important; + } + + #printThis .table-bordered > thead { + display: table-header-group !important; + page-break-inside: avoid !important; + } + + #printThis .personnel-badge { + background-color: #cbd5e1 !important; + padding: 2px 5px !important; + border-radius: 5px !important; + line-height: 21px !important; + -webkit-print-color-adjust: exact !important; + print-color-adjust: exact !important; + } +} + +.titleSection { + background: #fff !important; + -webkit-print-color-adjust: exact !important; + print-color-adjust: exact !important; +} + +.col-xs-4, .col-xs-3, .col-xs-9, +.col-xs-2, .col-xs-10, .col-xs-6, +.col-xs-8, .col-xs-5, .col-xs-7, +.col-xs-offset-1 { + float: right !important; +} + +.cls-1 { + fill: url(#linear-gradient-2); +} + +.cls-2 { + fill: url(#linear-gradient-3); +} + +.cls-3 { + fill: url(#linear-gradient); +} + +.flex { + display: flex; +} + +.justify-between { + justify-content: space-between; +} + +.justify-end { + justify-content: end; +} + +.items-center { + align-items: center; +} + +.titleSection { + padding: 5px; + margin: 0; + border-bottom: 0; + align-items: center; + display: flex; +} + +.titleH1 { + font-size: 24px; + margin: 0 !important; + font-weight: 600; +} + +.lineS { + margin: 4px 0 !important; +} + +.table > tbody > tr.withdraw > td { + background-color: #b5b5b5 !important; +} + +.personnel-badge { + background-color: #cbd5e1; + padding: 2px 5px; + border-radius: 5px; + line-height: 21px; +} + + diff --git a/ServiceHost/wwwroot/AssetsAdminNew/Report/css/PrintAllEmployee.css b/ServiceHost/wwwroot/AssetsAdminNew/Report/css/PrintAllEmployee.css new file mode 100644 index 00000000..92739b04 --- /dev/null +++ b/ServiceHost/wwwroot/AssetsAdminNew/Report/css/PrintAllEmployee.css @@ -0,0 +1,446 @@ + +#MainModal { + backdrop-filter: blur(8px); +} + +.modal .modal-dialog .modal-content { + background-color: white; + padding: 0px 30px 0 30px; +} + +.modal-header { + padding: 1rem 0rem !important; +} + +.modal .modal-dialog .modal-content .modal-body { + padding: 0 !important; +} + +.modal-dialog { + width: 1200px !important; +} + +.printBtns { + padding: 12px 2px 12px; + border-top: unset; + position: fixed; + top: 10%; + left: 50%; + transform: translateX(-800%); + display: flex; + flex-direction: column; + background: white; + align-items: center; + border-radius: 9px; + z-index: 9999999; + transition: none; +} + +@media (max-width: 1550px) { + .printBtns { + transform: translateX(-680%); + } +} + +#printThis .modal-content { + background-clip: padding-box; + background: black !important; +} + +#printThis h1, h2, h3, h4, h5, h6 { + color: black; + margin: 1rem 0; +} + +.top-title { + text-align: center; +} + +.list-no { + display: flex; + justify-content: center; + align-items: center; + margin: 1rem 0; +} + + .list-no h4 { + margin: 0 9rem; + } + +.table-title { + display: flex; + justify-content: space-between; + padding: 0 1rem; + border: 1px solid black; + border-top-right-radius: 9px; + border-top-left-radius: 9px; + border-bottom: 0; +} + + .table-title h4 { + font-size: 1.5rem; + } + +#printThis table { + direction: ltr; + width: 100%; +} + +#printThis .table-bordered { + border: 1px solid #94a3b8; + border-radius: 9px; + border-collapse: separate; + margin-bottom: 0; + table-layout: fixed; + width: 100%; +} + + #printThis .table-bordered > thead > tr > th { + font-size: 1.3rem; + color: black; + text-align: center; + vertical-align: middle; + padding: 0; + border: 1px solid #c7c7c7 !important; + background: #ddd; + } + + #printThis .table-bordered > tbody > tr > td { + padding: 8px 2px; + text-align: center; + font-size: 10px; + border: 1px solid #c7c7c7 !important; + background: transparent; + } + + #printThis .table-bordered > tbody > tr.withdraw > td { + background-color: #b5b5b5 !important; + } + +#printThis tr:nth-child(2n) td { + background: #f0f0f0 !important; +} + +tr td:first-child { + border-top-right-radius: 0px; + border-bottom-right-radius: 0px; +} + +tr td:last-child { + border-top-left-radius: 0px; + border-bottom-left-radius: 0px; +} + +tr th:first-child { + border-top-right-radius: 0px; + border-bottom-right-radius: 0px; +} + +tr th:last-child { + border-top-left-radius: 0px; + border-bottom-left-radius: 0px; +} + +.printBtns .btn-rounded { + margin-left: 0.5rem; + margin-right: 0.5rem; + padding: 5px 18px; +} + +#printThis .colgp-1 { + width: 10%; +} + +#printThis .colgp-2 { + width: 10%; +} + +#printThis .colgp-3 { + width: 30%; +} + +#printThis .colgp-4 { + width: 50%; +} + +.data-total { + border-top: 1px solid black; + margin-top: 2rem; + padding-top: 0.5rem; +} + +#printThis .table-bordered .total td { + background: #dfdfdf !important; +} + +.bl-hidden { + border-left: hidden !important; +} + +.table-name { + font-family: 'IranSans' !important; + text-align: right !important; + white-space: nowrap !important; + max-width: 100%; + width: 80px; + overflow-x: clip; + direction: rtl; +} + +.table-bordered tr:nth-child(10) { + page-break-after: always; +} + +@media screen { + #printSection { + display: none; + } +} + +@media (max-width: 1550px) { + .modal-dialog { + width: 1000px !important; + } + + .table-title h4 { + font-size: 1.3rem; + } + + .top-title h1 { + font-size: 2.5rem; + } + + .top-title h4 { + font-size: 1.5rem; + } + + .list-no h4 { + margin: 0 8rem; + } + + #printThis .table-bordered { + border: 1px solid #000000 !important; + border-radius: 9px !important; + } + + #printThis .table-bordered > thead > tr > th { + font-size: 1.1rem; + } + + #printThis .table-bordered > tbody > tr > td { + font-size: 10px; + } +} + +@page { + size: A4; + margin: 0mm; + page-break-after: auto; +} + +@media print { + body * { + visibility: hidden; + page-break-after: auto; + -webkit-print-color-adjust: exact; + print-color-adjust: exact; + } + + html, body { + height: 100%; + margin: 0 !important; + padding: 0 !important; + overflow: clip; + } + + .modal-dialog { + max-width: 100%; + width: 60cm; + } + + .modal .modal-dialog .modal-content { + padding: 0; + } + + #printSection, #printSection * { + visibility: visible; + page-break-after: auto; + } + + #printSection { + width: 27.5cm; + position: absolute; + left: 0; + page-break-after: auto; + top: 0; + padding: 2rem 0; + } + + #printThis { + padding: 2rem 1rem; + } + + + #printThis .table-bordered { + border-collapse: separate !important; + margin-bottom: 0; + table-layout: fixed; + width: 100%; + border: 0 !important; + } + + #printThis .table-bordered > thead > tr > th { + font-size: 1.2rem !important; + color: black; + text-align: center; + vertical-align: middle; + padding: 0; + border: 1px solid black; + background: #ddd; + -webkit-print-color-adjust: exact !important; + print-color-adjust: exact !important; + } + + #printThis tr:nth-child(2n) td { + background: #f0f0f0 !important; + } + + #printThis .table-bordered > tbody > tr > td { + padding: 8px 2px; + text-align: center; + font-size: 10px !important; + border: 1px solid black; + } + + #printThis .table-bordered > thead > td:first-child { + border: 9px !important; + } + + #printThis .table-bordered > thead > td:last-child { + border: 9px !important; + } + + + #printThis .colgp-1 { + width: 10%; + } + + #printThis .colgp-2 { + width: 10%; + } + + #printThis .colgp-3 { + width: 30%; + } + + #printThis .colgp-4 { + width: 50%; + } + + .bl-hidden { + border-left: hidden !important; + } + + .table-name { + padding: 8px 0; + } + + #printThis .table-bordered > thead tr:first-child { + border: 0 !important; + } + + #printThis .titleSection { + border: 1px solid #94a3b8 !important; + border-bottom: 0 !important; + border-radius: 10px 10px 0 0 !important; + background: #fff !important; + -webkit-print-color-adjust: exact !important; + print-color-adjust: exact !important; + } + + #printThis .table-bordered > thead { + display: table-header-group !important; + page-break-inside: avoid !important; + } + + #printThis .personnel-badge { + background-color: #cbd5e1 !important; + padding: 2px 5px !important; + border-radius: 5px !important; + line-height: 21px !important; + -webkit-print-color-adjust: exact !important; + print-color-adjust: exact !important; + } +} + +.titleSection { + background: #fff !important; + -webkit-print-color-adjust: exact !important; + print-color-adjust: exact !important; +} + +.col-xs-4, .col-xs-3, .col-xs-9, +.col-xs-2, .col-xs-10, .col-xs-6, +.col-xs-8, .col-xs-5, .col-xs-7, +.col-xs-offset-1 { + float: right !important; +} + +.cls-1 { + fill: url(#linear-gradient-2); +} + +.cls-2 { + fill: url(#linear-gradient-3); +} + +.cls-3 { + fill: url(#linear-gradient); +} + +.flex { + display: flex; +} + +.justify-between { + justify-content: space-between; +} + +.justify-end { + justify-content: end; +} + +.items-center { + align-items: center; +} + +.titleSection { + padding: 5px; + margin: 0; + border-bottom: 0; + align-items: center; + display: flex; +} + +.titleH1 { + font-size: 24px; + margin: 0 !important; + font-weight: 600; +} + +.lineS { + margin: 4px 0 !important; +} + +.table > tbody > tr.withdraw > td { + background-color: #b5b5b5 !important; +} + +.personnel-badge { + background-color: #cbd5e1; + padding: 2px 5px; + border-radius: 5px; + line-height: 21px; +} + + diff --git a/ServiceHost/wwwroot/AssetsAdminNew/Report/js/PrintAll.js b/ServiceHost/wwwroot/AssetsAdminNew/Report/js/PrintAll.js new file mode 100644 index 00000000..16450bd7 --- /dev/null +++ b/ServiceHost/wwwroot/AssetsAdminNew/Report/js/PrintAll.js @@ -0,0 +1,20 @@ + +document.getElementById("btnPrint").onclick = function () { + printElement(document.getElementById("printThis")); +} + +function printElement(elem) { + var domClone = elem.cloneNode(true); + + var $printSection = document.getElementById("printSection"); + + if (!$printSection) { + $printSection = document.createElement("div"); + $printSection.id = "printSection"; + document.body.appendChild($printSection); + } + + $printSection.innerHTML = ""; + $printSection.appendChild(domClone); + window.print(); +} diff --git a/ServiceHost/wwwroot/AssetsAdminNew/Report/js/index.js b/ServiceHost/wwwroot/AssetsAdminNew/Report/js/index.js new file mode 100644 index 00000000..4e77c62d --- /dev/null +++ b/ServiceHost/wwwroot/AssetsAdminNew/Report/js/index.js @@ -0,0 +1,1067 @@ + +$(document).ready(function () { + $('#ContractDonePercent').click(function (e) { + $("#ContractDonePercent").addClass("active"); + $("#ContractSignPercent").removeClass("active"); + $("#CheckoutDonePercent").removeClass("active"); + $("#CheckoutSignPercent").removeClass("active"); + $(".ContractDonePercent").show(); + $(".ContractSignPercent").hide(); + $(".CheckoutDonePercent").hide(); + $(".CheckoutSignPercent").hide(); + + toggleDivs("#ContractDonePercentDivMobile", "#ContractDonePercentDivMobile .mainMobilePersonal1"); + + scrolltext(); + + $('#appendTableWorkshop').html(''); + $('#loading').show(); + $('#personnelSection').html(''); + $('#loadingPersonnel').show(); + + $("#ContractDonePercentDiv").click(); + }); + $('#ContractSignPercent').click(function (e) { + $("#ContractDonePercent").removeClass("active"); + $("#ContractSignPercent").addClass("active"); + $("#CheckoutDonePercent").removeClass("active"); + $("#CheckoutSignPercent").removeClass("active"); + + $(".ContractDonePercent").hide(); + $(".ContractSignPercent").show(); + $(".CheckoutDonePercent").hide(); + $(".CheckoutSignPercent").hide(); + + toggleDivs("#ContractSignPercentDivMobile", "#ContractSignPercentDivMobile .mainMobilePersonal2"); + + scrolltext(); + + $('#appendTableWorkshop').html(''); + $('#loading').show(); + $('#personnelSection').html(''); + $('#loadingPersonnel').show(); + + $("#ContractSignPercentDiv").click(); + }); + $('#CheckoutDonePercent').click(function (e) { + $("#ContractDonePercent").removeClass("active"); + $("#ContractSignPercent").removeClass("active"); + $("#CheckoutDonePercent").addClass("active"); + $("#CheckoutSignPercent").removeClass("active"); + + $(".ContractDonePercent").hide(); + $(".ContractSignPercent").hide(); + $(".CheckoutDonePercent").show(); + $(".CheckoutSignPercent").hide(); + + toggleDivs("#CheckoutDonePercentDivMobile", "#CheckoutDonePercentDivMobile .mainMobilePersonal3"); + + scrolltext(); + + $('#appendTableWorkshop').html(''); + $('#loading').show(); + $('#personnelSection').html(''); + $('#loadingPersonnel').show(); + + $("#CheckoutDonePercentDiv").click(); + }); + $('#CheckoutSignPercent').click(function (e) { + $("#ContractDonePercent").removeClass("active"); + $("#ContractSignPercent").removeClass("active"); + $("#CheckoutDonePercent").removeClass("active"); + $("#CheckoutSignPercent").addClass("active"); + + $(".ContractDonePercent").hide(); + $(".ContractSignPercent").hide(); + $(".CheckoutDonePercent").hide(); + $(".CheckoutSignPercent").show(); + + toggleDivs("#CheckoutSignPercentDivMobile", "#CheckoutSignPercentDivMobile .mainMobilePersonal4"); + + scrolltext(); + + $('#appendTableWorkshop').html(''); + $('#loading').show(); + $('#personnelSection').html(''); + $('#loadingPersonnel').show(); + + $("#CheckoutSignPercentDiv").click(); + }); +}); + +// workshopFirstLoad +function ajaxContractDone(accountId) { + $('#workshopListMobileSection').html(''); + $('#appendTableWorkshop').html(''); + $('#loading').show(); + $('#personnelSection').html(''); + $('#loadingPersonnel').show(); + $.ajax({ + dataType: 'json', + url: '@Url.Page("/Company/Reports/Index", "WorkshopContractDone")', + type: 'GET', + data: { "year": $('#selectYear').val(), "month": $('#selectMonth').val(), "accountId": Number(accountId) }, + headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, + success: function (response) { + if (response.success) { + var workshopList = response.workshopList; + var tableHtml = ` + + + + + + + + + + + + `; + + workshopList.forEach(function (item) { + var color = convertColorPercent(item.contractDonePercent); + tableHtml += ` + + + + + + + + `; + }) + + tableHtml += ` + +
    کد بایگانیکارگاهپردازش انجام کار
    ${item.archiveCode}${item.workshopFullName} +
    +
    +
    +
    ${item.contractDonePercent}% + +
    + `; + var ListMobileHtml = ``; + workshopList.forEach(function (item) { + var color = convertColorPercent(item.contractDonePercent); + ListMobileHtml += ` +
    +
    +
    +
    +
    ${item.workshopFullName}
    +
    +
    +
    +
    +
    + ${item.contractDonePercent}% +
    +
    + +
    + +
    +
    +
    + +
    +
    +
    +
    + `; + }) + + + $('#loading').hide(); + $('#appendTableWorkshop').append(tableHtml); + $('#workshopListMobileSection').append(ListMobileHtml); + $("#ajaxEmployeeContract").click(); + $("#ajaxEmployeeContract").addClass("active"); + } else { + console.log("false"); + } + }, + failure: function (response) { + console.log(5, response); + + } + }); +} + +function ajaxContractSignDone(accountId) { + $('#workshopListMobileSection').html(''); + $('#appendTableWorkshop').html(''); + $('#loading').show(); + $('#personnelSection').html(''); + $('#loadingPersonnel').show(); + $.ajax({ + dataType: 'json', + url: '@Url.Page("/Company/Reports/Index", "WorkshopContractSignDone")', + type: 'GET', + data: { "year": $('#selectYear').val(), "month": $('#selectMonth').val(), "accountId": Number(accountId) }, + headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, + success: function (response) { + if (response.success) { + var workshopList = response.workshopList; + var tableHtml = ` + + + + + + + + + + + + `; + + workshopList.forEach(function (item) { + var color = convertColorPercent(item.contractSignPercent); + tableHtml += ` + + + + + + + + `; + }) + + tableHtml += ` + +
    کد کارگاهکارگاهپردازش انجام کار
    ${item.archiveCode}${item.workshopFullName} +
    +
    +
    +
    ${item.contractSignPercent}% + +
    + `; + var ListMobileHtml = ``; + workshopList.forEach(function (item) { + var color = convertColorPercent(item.contractDonePercent); + ListMobileHtml += ` +
    +
    +
    +
    +
    ${item.workshopFullName}
    +
    +
    +
    +
    +
    + ${item.contractDonePercent}% +
    +
    + +
    + +
    +
    +
    + +
    +
    +
    +
    + `; + }) + + $('#loading').hide(); + $('#appendTableWorkshop').append(tableHtml); + $('#workshopListMobileSection').append(ListMobileHtml); + $("#ajaxEmployeeContractSign").click(); + $("#ajaxEmployeeContractSign").addClass("active"); + } else { + console.log("false"); + } + }, + failure: function (response) { + console.log(5, response); + + } + }); +} + +function ajaxWorkshopCheckoutDone(accountId) { + $('#workshopListMobileSection').html(''); + $('#appendTableWorkshop').html(''); + $('#loading').show(); + $('#personnelSection').html(''); + $('#loadingPersonnel').show(); + $.ajax({ + dataType: 'json', + url: '@Url.Page("/Company/Reports/Index", "WorkshopCheckoutDone")', + type: 'GET', + data: { "year": $('#selectYear').val(), "month": $('#selectMonth').val(), "accountId": Number(accountId) }, + headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, + success: function (response) { + if (response.success) { + var workshopList = response.workshopList; + var tableHtml = ` + + + + + + + + + + + + `; + + workshopList.forEach(function (item) { + var color = convertColorPercent(item.checkoutDonePercent); + tableHtml += ` + + + + + + + + `; + }) + + tableHtml += ` + +
    کد کارگاهکارگاهپردازش انجام کار
    ${item.archiveCode}${item.workshopFullName} +
    +
    +
    +
    ${item.checkoutDonePercent}% + +
    +`; + var ListMobileHtml = ``; + workshopList.forEach(function (item) { + var color = convertColorPercent(item.contractDonePercent); + ListMobileHtml += ` + < div class="table-workshop my-1" onclick = "ajaxEmployeeContract(${item.id})" > +
    +
    +
    +
    ${item.workshopFullName}
    +
    +
    +
    +
    +
    + ${item.contractDonePercent}% +
    +
    + +
    + +
    +
    +
    + +
    +
    +
    +
    + `; + }) + + $('#loading').hide(); + $('#appendTableWorkshop').append(tableHtml); + $('#workshopListMobileSection').append(ListMobileHtml); + $("#ajaxEmployeeCheckout").click(); + $("#ajaxEmployeeCheckout").addClass("active"); + } else { + console.log("false"); + } + }, + failure: function (response) { + console.log(5, response); + + } + }); +} + +function ajaxWorkshopCheckoutSignDone(accountId) { + $('#workshopListMobileSection').html(''); + $('#appendTableWorkshop').html(''); + $('#loading').show(); + $('#personnelSection').html(''); + $('#loadingPersonnel').show(); + $.ajax({ + dataType: 'json', + url: '@Url.Page("/Company/Reports/Index", "WorkshopCheckoutSignDone")', + type: 'GET', + data: { "year": $('#selectYear').val(), "month": $('#selectMonth').val(), "accountId": Number(accountId) }, + headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, + success: function (response) { + if (response.success) { + var workshopList = response.workshopList; + var tableHtml = ` + < table class="table-hover table-transparent table" > + + + کد کارگاه + کارگاه + پردازش انجام کار + + + + + + `; + + workshopList.forEach(function (item) { + var color = convertColorPercent(item.checkoutSignPercent); + tableHtml += ` + + ${item.archiveCode} + ${item.workshopFullName} + +
    +
    +
    + + ${item.checkoutSignPercent}% + + + + + `; + }) + + tableHtml += ` + + + `; + var ListMobileHtml = ``; + workshopList.forEach(function (item) { + var color = convertColorPercent(item.contractDonePercent); + ListMobileHtml += ` + < div class="table-workshop my-1" onclick = "ajaxEmployeeContract(${item.id})" > +
    +
    +
    +
    ${item.workshopFullName}
    +
    +
    +
    +
    +
    + ${item.contractDonePercent}% +
    +
    + +
    + +
    +
    +
    + +
    +
    +
    +
    + `; + }) + + $('#loading').hide(); + $('#appendTableWorkshop').append(tableHtml); + $('#workshopListMobileSection').append(ListMobileHtml); + $("#ajaxEmployeeCheckoutSign").click(); + $("#ajaxEmployeeCheckoutSign").addClass("active"); + } else { + console.log("false"); + } + }, + failure: function (response) { + console.log(5, response); + + } + }); +} + +// EmployeeNotDone +function ajaxEmployeeContract(workshopId) { + $('#employeeList_' + workshopId).html(''); + $('#personnelSection').html(''); + $('#loadingPersonnel').show(); + $.ajax({ + dataType: 'json', + url: '@Url.Page("/Company/Reports/Index", "EmployeeContract")', + type: 'GET', + data: { "year": $('#selectYear').val(), "month": $('#selectMonth').val(), "workshopId": Number(workshopId) }, + headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, + success: function (response) { + if (response.success) { + var employeeList = response.employeeList; + var divHtml = ``; + employeeList.forEach(function (item) { + divHtml += ` + < div class="d-flex align-items-center mb-1" > +
    +
    + ${item.employeeFullName} +
    +
    +
    + + + + + +
    +
    + `; + }) + + var EmployeeListMobile = ``; + employeeList.forEach(function (item) { + EmployeeListMobile += ` + < div class="users-list-work" > +
    +
    +
    + ${item.employeeFullName} +
    +
    +
    + + + + + +
    +
    +
    + `; + }) + $('#loadingPersonnel').hide(); + $('#personnelSection').append(divHtml); + $('#employeeList_' + workshopId).append(EmployeeListMobile); + } else { + console.log("false"); + } + }, + failure: function (response) { + console.log(5, response); + + } + }); +} + +function ajaxEmployeeContractSign(workshopId) { + $('#employeeList_' + workshopId).html(''); + $('#personnelSection').html(''); + $('#loadingPersonnel').show(); + $.ajax({ + dataType: 'json', + url: '@Url.Page("/Company/Reports/Index", "EmployeeContractSign")', + type: 'GET', + data: { "year": $('#selectYear').val(), "month": $('#selectMonth').val(), "workshopId": Number(workshopId) }, + headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, + success: function (response) { + if (response.success) { + var employeeList = response.employeeList; + var divHtml = ``; + employeeList.forEach(function (item) { + divHtml += ` + < div class="d-flex align-items-center mb-1" > +
    +
    + ${item.employeeFullName} +
    +
    +
    + + + + + +
    + + `; + }) + + var EmployeeListMobile = ``; + employeeList.forEach(function (item) { + EmployeeListMobile += ` + < div class="users-list-work" > +
    +
    +
    + ${item.employeeFullName} +
    +
    +
    + + + + + +
    +
    + + `; + }) + $('#loadingPersonnel').hide(); + $('#personnelSection').append(divHtml); + $('#employeeList_' + workshopId).append(EmployeeListMobile); + } else { + console.log("false"); + } + }, + failure: function (response) { + console.log(5, response); + + } + }); +} + +function ajaxEmployeeCheckout(workshopId) { + $('#employeeList_' + workshopId).html(''); + $('#personnelSection').html(''); + $('#loadingPersonnel').show(); + $.ajax({ + dataType: 'json', + url: '@Url.Page("/Company/Reports/Index", "EmployeeCheckout")', + type: 'GET', + data: { "year": $('#selectYear').val(), "month": $('#selectMonth').val(), "workshopId": Number(workshopId) }, + headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, + success: function (response) { + if (response.success) { + var employeeList = response.employeeList; + var divHtml = ``; + employeeList.forEach(function (item) { + divHtml += ` + < div class="d-flex align-items-center mb-1" > +
    +
    + ${item.employeeFullName} +
    +
    +
    + + + + + +
    + + `; + }) + + var EmployeeListMobile = ``; + employeeList.forEach(function (item) { + EmployeeListMobile += ` + < div class="users-list-work" > +
    +
    +
    + ${item.employeeFullName} +
    +
    +
    + + + + + +
    +
    + + `; + }) + $('#loadingPersonnel').hide(); + $('#personnelSection').append(divHtml); + $('#employeeList_' + workshopId).append(EmployeeListMobile); + } else { + console.log("false"); + } + }, + failure: function (response) { + console.log(5, response); + + } + }); +} + +function ajaxEmployeeCheckoutSign(workshopId) { + $('#employeeList_' + workshopId).html(''); + $('#personnelSection').html(''); + $('#loadingPersonnel').show(); + $.ajax({ + dataType: 'json', + url: '@Url.Page("/Company/Reports/Index", "EmployeeCheckoutSign")', + type: 'GET', + data: { "year": $('#selectYear').val(), "month": $('#selectMonth').val(), "workshopId": Number(workshopId) }, + headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, + success: function (response) { + if (response.success) { + var employeeList = response.employeeList; + var divHtml = ``; + employeeList.forEach(function (item) { + divHtml += ` + < div class="d-flex align-items-center mb-1" > +
    +
    + ${item.employeeFullName} +
    +
    +
    + + + + + +
    + + `; + }) + + var EmployeeListMobile = ``; + employeeList.forEach(function (item) { + EmployeeListMobile += ` + < div class="users-list-work" > +
    +
    +
    + ${item.employeeFullName} +
    +
    +
    + + + + + +
    +
    + + `; + }) + $('#loadingPersonnel').hide(); + $('#personnelSection').append(divHtml); + $('#employeeList_' + workshopId).append(EmployeeListMobile); + } else { + console.log("false"); + } + }, + failure: function (response) { + console.log(5, response); + + } + }); +} + +$(document).ready(function () { + if ($(window).width() < 992) { + // ********************** باز شدن جزئیات مربوط به کارگاه *************************** + $(document).on('click', '.openAction', function () { + $(this).next().find(".operations-btns").slideToggle(500); + $(".operations-btns").not($(this).next().find(".operations-btns")).slideUp(500); + }); + // ********************** باز شدن جزئیات مربوط به کارگاه *************************** + } + +}); + +if ($(window).width() < 992) { + $('.card.btn-card').removeClass('active'); + + $(document).ready(function () { + + $('.mainMobile').slick({ + centerMode: true, + arrows: false, + centerPadding: '60px', + slidesToShow: 3, + rtl: true, + responsive: [ + { + breakpoint: 992, + settings: { + arrows: false, + centerMode: true, + centerPadding: '80px', + slidesToShow: 1, + rtl: true, + } + }, + { + breakpoint: 768, + settings: { + arrows: false, + centerMode: true, + centerPadding: '80px', + slidesToShow: 1, + rtl: true, + } + }, + { + breakpoint: 480, + settings: { + arrows: false, + centerMode: true, + centerPadding: '40px', + slidesToShow: 1 + } + } + ] + }); + + $('.mainMobileSub').slick({ + centerMode: true, + dots: true, + arrows: false, + centerPadding: '60px', + slidesToShow: 1, + rtl: true, + responsive: [ + { + breakpoint: 768, + settings: { + arrows: false, + centerMode: true, + centerPadding: '40px', + slidesToShow: 1 + } + }, + { + breakpoint: 480, + settings: { + arrows: false, + centerMode: true, + centerPadding: '40px', + slidesToShow: 1 + } + } + ] + }); + + + // loadMainMobilePersonal(); + + + }); + +} + +$('#selectYear').on('change', function () { + searchReport(); +}); +$('#selectMonth').on('change', function () { + searchReport(); +}); + +function searchReport() { + let year = $('#selectYear').val(); + let month = $('#selectMonth').val(); + + let parameter = '?year=' + year + '&month=' + month; + let url = `@Url.Page("/Company/Reports/Index")`; + window.location.href = url + parameter; +} + +function convertColorPercent(value) { + + var redDark = "#B91C1C"; + var redLight = "#EF4444"; + + var orangeDark = "#F59E0B"; + var orangeLight = "#FBBF24"; + + var limeDark = "#81CB0F"; + var limeLight = "#A3E635"; + + switch (true) { + case (value <= 16): color = redDark; + break; + case (value <= 33): color = redLight; + break; + case (value <= 49): color = orangeDark; + break; + case (value <= 66): color = orangeLight; + break; + case (value <= 83): color = limeLight; + break; + case (value <= 100): color = limeDark; + break; + default: color = ""; + break; + } + return color; +} + +$(document).ready(function () { + $('.activeBtn').click(function () { + $('.activeBtn').removeClass("active"); + $(this).addClass("active"); + }); + + $(document).on('click', '.tableActive', function () { + $('.tableActive').removeClass("active"); + $(this).addClass("active"); + }); +}); + +$(document).ready(function () { + scrolltext(); +}); + +function scrolltext() { + $('.scrolltext').each(function () { + var container = $(this); + var text = container.find('span'); + var containerWidth = container.width(); + var textWidth = text.width(); + + if (containerWidth < textWidth) { + text.addClass('animate'); + } + }); +} + + +function toggleDivs(showDiv, slickClass) { + $("#ContractDonePercentDivMobile, #ContractSignPercentDivMobile, #CheckoutDonePercentDivMobile, #CheckoutSignPercentDivMobile").hide(); + $(showDiv).show(); + + if ($(slickClass).hasClass('slick-initialized')) { + $(slickClass).slick('unslick'); + } + + initializeSlickSlider(slickClass); + + setTimeout(function () { + $(showDiv).show().addClass('showing'); + }, 100); +} + +function initializeSlickSlider(selector) { + $(selector).slick({ + dots: true, + arrows: false, + slidesToShow: 3, + rtl: true, + responsive: [ + { + breakpoint: 768, + settings: { + arrows: false, + slidesToShow: 3, + } + }, + { + breakpoint: 480, + settings: { + arrows: false, + slidesToShow: 3, + } + } + ] + }); +} + +function searchWorkshop() { + var input, filter, tbody, tr, a, i; + input = document.getElementById("search"); + filter = input.value.toUpperCase(); + tbody = document.getElementById("tbody"); + tr = tbody.getElementsByTagName("tr"); + for (i = 0; i < tr.length; i++) { + td = tr[i].getElementsByTagName("td")[1]; + if (td.innerHTML.toUpperCase().indexOf(filter) > -1) { + tr[i].style.display = ""; + } else { + tr[i].style.display = "none"; + } + } +} + +function printAllAction(id, handler) { + let year = $('#selectYear').val(); + let month = $('#selectMonth').val(); + var accoundId = Number(id); + var url = `#showmodal = /Admin/Company / Reports / Index ? year = ${year}& month=${month}& accountId=${accoundId}& handler=${handler} `; + window.location.href = url; +} + +function printAllContractDone(id) { + printAllAction(id, 'PrintAllContractDone'); +} + +function PrintAllContractSignDone(id) { + printAllAction(id, 'PrintAllContractSignDone'); +} + +function printAllCheckoutDone(id) { + printAllAction(id, 'PrintAllCheckoutDone'); +} + +function printAllCheckoutSignDone(id) { + printAllAction(id, 'PrintAllCheckoutSignDone'); +} + +function printAllEmployeeAction(id, handler) { + let year = $('#selectYear').val(); + let month = $('#selectMonth').val(); + var workshopId = Number(id); + var url = `#showmodal = /Admin/Company / Reports / Index ? year = ${year}& month=${month}& workshopId=${workshopId}& handler=${handler} `; + console.log(url) + window.location.href = url; +} + +function PrintWorkshopContractDone(id) { + printAllEmployeeAction(id, 'PrintEmployeeContract'); +} + +function PrintWorkshopContractSignDone(id) { + printAllEmployeeAction(id, 'PrintEmployeeContractSign'); +} + +function PrintWorkshopCheckoutDone(id) { + printAllEmployeeAction(id, 'PrintEmployeeCheckout'); +} + +function PrintWorkshopCheckoutSignDone(id) { + printAllEmployeeAction(id, 'PrintEmployeeCheckoutSign'); +} diff --git a/ServiceHost/wwwroot/AssetsAdminNew/Tasks/css/DetailModal.css b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/css/DetailModal.css new file mode 100644 index 00000000..5027bfd7 --- /dev/null +++ b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/css/DetailModal.css @@ -0,0 +1,216 @@ + + +.modal-content { + /* width: 900px; */ +} + +.errored { + animation: shake 300ms; + color: #eb3434 !important; + background-color: #fef2f2 !important; + border: 1px solid #eb3434 !important; + border-radius: 7px; +} + +/* Start Select2 */ +.select2.select2-container .select2-selection { + display: flex !important; + height: 0 !important; + padding: 0px; +} + +.select2.select2-container .select2-selection--multiple .select2-selection__rendered { + margin: 0; +} + +.select2-container--default .select2-search--inline .select2-search__field { + line-height: 32px; + padding: 0 0; + font-family: 'IRANYekanX'; +} +/* End Select2 */ + +.validTime { + color: #4d7c0f !important; +} + +.invalidTime { + color: #b91c1c !important; +} + +.upload-box-voice { + width: 100%; +} + + + +.lightboxpreview { + transition: all 0.3s linear; + padding-top: 60%; + cursor: pointer; + background-size: cover; +} + +.lightbox-content { + max-height: 75vh; + height: 75vh; + width: 100%; + max-width: 1000px; +} + +.lightbox-close { + cursor: pointer; + margin-left: auto; + position: absolute; + right: -30px; + top: -30px; + color: white; + font-size: 2rem; + font-weight: 700; + line-height: 1; +} + +.modal_inner_image { + min-height: 400px; + z-index: 1000; +} + +.modal-content { + width: 100%; +} + +.modalscale { + transform: scale(0); + opacity: 0; +} + +.lightbox-container, +.lightbox-btn, +.lightbox-image-wrapper, +.lightbox-enabled { + transition: all 0.4s ease-in-out; +} + +.lightbox_img_wrap { + /* padding-top: 65%; + position: relative; + overflow: hidden; */ +} + +.lightbox-enabled:hover { + transform: scale(1.1); +} + +.lightbox-enabled { + width: 100%; + height: 100%; + position: absolute; + top: 0; + right: 0; + object-fit: cover; + cursor: pointer; +} + +.lightbox-container { + width: 100vw; + height: 100vh; + position: fixed; + top: 0; + left: 0; + display: flex; + align-items: center; + justify-content: center; + background-color: rgba(0, 0, 0, 0.6); + z-index: 9999; + opacity: 0; + pointer-events: none; +} + + .lightbox-container.active { + opacity: 1; + pointer-events: all; + } + +.lightbox-image-wrapper { + display: flex; + transform: scale(0); + align-items: center; + justify-content: center; + max-width: 90vw; + max-height: 90vh; + position: relative; +} + +.lightbox-container.active .lightbox-image-wrapper { + transform: scale(1); +} + +.lightbox-btn, +#close { + color: white; + z-index: 9999999; + cursor: pointer; + position: absolute; + font-size: 50px; +} + + .lightbox-btn:focus { + outline: none; + } + +.left { + left: 50px; +} + +.right { + right: 50px; +} + +#close { + top: 50px; + right: 50px; +} + +.lightbox-image { + width: 100%; + -webkit-box-shadow: 5px 5px 20px 2px rgba(0, 0, 0, 0.19); + box-shadow: 5px 5px 20px 2px rgba(0, 0, 0, 0.19); + max-height: 95vh; + object-fit: cover; +} + +@keyframes slideleft { + 33% { + transform: translateX(-300px); + opacity: 0; + } + + 66% { + transform: translateX(300px); + opacity: 0; + } +} + +.slideleft { + animation-name: slideleft; + animation-duration: 0.5s; + animation-timing-function: ease; +} + +@keyframes slideright { + 33% { + transform: translateX(300px); + opacity: 0; + } + + 66% { + transform: translateX(-300px); + opacity: 0; + } +} + +.slideright { + animation-name: slideright; + animation-duration: 0.5s; + animation-timing-function: ease; +} diff --git a/ServiceHost/wwwroot/AssetsAdminNew/Tasks/css/Edit.css b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/css/Edit.css new file mode 100644 index 00000000..0604e63f --- /dev/null +++ b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/css/Edit.css @@ -0,0 +1,35 @@ + +.errored { + animation: shake 300ms; + color: #eb3434 !important; + background-color: #fef2f2 !important; + border: 1px solid #eb3434 !important; + border-radius: 7px; + } + +.select2.select2-container .select2-selection { + display: flex !important; + height: 0 !important; + padding: 0px; +} + +.select2.select2-container .select2-selection--multiple .select2-selection__rendered { + margin: 0; +} + +.select2-container--default .select2-search--inline .select2-search__field { + line-height: 32px; + padding: 0 0; + font-family: 'IRANYekanX'; +} + +.validTime { + color: #4d7c0f !important; +} + +.invalidTime { + color: #b91c1c !important; +} + + + diff --git a/ServiceHost/wwwroot/AssetsAdminNew/Tasks/css/Index.css b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/css/Index.css new file mode 100644 index 00000000..ad37274d --- /dev/null +++ b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/css/Index.css @@ -0,0 +1,162 @@ + + +.errored { + animation: shake 300ms; + color: #eb3434 !important; + background-color: #fef2f2 !important; + border: 1px solid #eb3434 !important; + border-radius: 7px; +} + +.DesLimit { + overflow: hidden; + display: -webkit-box; + -webkit-line-clamp: 1; + line-clamp: 1; + -webkit-box-orient: vertical; +} + +.sweet-alert { + font-family: 'IranSans' !important +} + +.select2.select2-container.select2-selection--multiple { + height: 0; +} + + .select2.select2-container.select2-selection--multiple.select2-selection__rendered { + margin: 0; + } + + .select2.select2-container.select2-selection--multiple.select2-search--inline.select2-search__field { + height: 0; + } + + .select2.select2-container.select2-selection--multiple.select2-selection__rendered { + line-height: 0; + } + + .select2.select2-container.select2-selection--multiple.select2-selection__choice { + margin: 0 4px 0 0; + } + +.select2.select2-container.select2-selection { + padding: 4px 0; +} + + +.tooltipfull-container { + cursor: pointer; + position: relative; +} + +.tooltipfull { + opacity: 0; + z-index: 99; + color: #fff; + display: grid; + font-size: 12px; + padding: 5px 10px; + border-radius: 8px; + background: #23a8a8; + border: 1px solid #23a8a8; + -webkit-transition: all .2s ease -in -out; + -moz-transition: all .2s ease -in -out; + -o-transition: all .2s ease -in -out; + transition: all .2s ease -in -out; + -webkit-transform: scale(0); + -moz-transform: scale(0); + -o-transform: scale(0); + -ms-transform: scale(0); + transform: scale(0); + position: absolute; + right: -2px; + bottom: 30px; + white-space: nowrap; +} + + .tooltipfull-container:hover .tooltipfull, a:hover.tooltipfull { + opacity: 1; + -webkit-transform: scale(1); + -moz-transform: scale(1); + -o-transform: scale(1); + -ms-transform: scale(1); + transform: scale(1); + } + + .tooltipfull:before, .tooltipfull:after { + content: ''; + border-left: 10px solid transparent; + border-right: 10px solid transparent; + border-top: 10px solid #23a8a8; + position: absolute; + bottom: -10px; + right: 20px; + } + +.btn-register { + padding: 10px 30px; + width: 210px; + text-align: center; +} + +.btnTaskList { + padding: 10px 30px; + border-radius: 8px; + font-size: 14px; + font-weight: 600; + background-color: #bef1f1; + color: #494949; + width: 210px; + text-align: center; + transition: all ease -in -out .3s +} + +.btnTaskRequest { + padding: 10px 30px; + border-radius: 8px; + font-size: 14px; + font-weight: 600; + background-color: #bef1f1; + color: #494949; + width: 210px; + justify-content: center; + transition: all ease -in -out .3s +} + + .btnTaskList.active, + .btnTaskRequest.active { + color: #ffffff; + background-color: #42e5e5; + pointer-events: none; + } + + +.goToTop { + position: fixed; + bottom: -10px; + margin-right: 100px; + z-index: 100; + color: #fff; + background-color: #25acacd6; +} + + .goToTop:hover { + color: #fff; + background-color: #2ca4a4; + } + +.ellipsed { + font-size: 12px; +} + +@media screen and(max-width: 767px) { + .goToTop { + position: fixed; + bottom: 54px; + margin-right: 39 %; + z-index: 100; + color: #fff; + background-color: #25acac70; + } +} diff --git a/ServiceHost/wwwroot/AssetsAdminNew/Tasks/css/OperationRequestModal.css b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/css/OperationRequestModal.css new file mode 100644 index 00000000..475a2c02 --- /dev/null +++ b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/css/OperationRequestModal.css @@ -0,0 +1,25 @@ + +.errored { + animation: shake 300ms; + color: #eb3434 !important; + background-color: #fef2f2 !important; + border: 1px solid #eb3434 !important; + border-radius: 7px; + } + +.select2.select2-container .select2-selection { + display: flex !important; + height: 0 !important; + padding: 0px; +} + +.select2.select2-container .select2-selection--multiple .select2-selection__rendered { + margin: 0; +} + +.select2-container--default .select2-search--inline .select2-search__field { + line-height: 32px; + padding: 0 0; + font-family: 'IRANYekanX'; +} + diff --git a/ServiceHost/wwwroot/AssetsAdminNew/Tasks/css/create.css b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/css/create.css new file mode 100644 index 00000000..37e4d6b1 --- /dev/null +++ b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/css/create.css @@ -0,0 +1,62 @@ + + + +.errored { + animation: shake 300ms; + color: #eb3434 !important; + background-color: #fef2f2 !important; + border: 1px solid #eb3434 !important; + border-radius: 7px; + } + +/* Start Select2 */ +.select2.select2-container .select2-selection { + display: flex !important; + height: 0 !important; + padding: 0px; +} + +.select2.select2-container .select2-selection--multiple .select2-selection__rendered { + margin: 0; +} + +.select2-container--default .select2-search--inline .select2-search__field { + line-height: 32px; + padding: 0 0; + font-family: 'IRANYekanX'; +} +/*.select2.select2-container .select2-selection--multiple { + height: 0; + } + .select2.select2-container .select2-selection--multiple .select2-selection__rendered { + margin: 0; + } + + .select2.select2-container .select2-selection--multiple .select2-search--inline .select2-search__field { + height: 0; + } + + .select2.select2-container .select2-selection--multiple .select2-selection__rendered { + line-height: 0; + } + + .select2.select2-container .select2-selection--multiple .select2-selection__choice { + margin: 0 4px 0 0; + } + + .select2.select2-container .select2-selection { + padding: 4px 0; + } + + */ +/* End Select2 */ + +.validTime { + color: #4d7c0f !important; +} + +.invalidTime { + color: #b91c1c !important; +} + + diff --git a/ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/CreateCRUDTaskSubjectModal.js b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/CreateCRUDTaskSubjectModal.js new file mode 100644 index 00000000..37940761 --- /dev/null +++ b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/CreateCRUDTaskSubjectModal.js @@ -0,0 +1,213 @@ + + + $(document).ready(function () { + loadSubjectList(); + + $('#btn-add').on('click', + function (e) { + e.preventDefault(); + + var subject = $("#NewSubject").val().trim(); + + if (subject != '') + { + $.ajax({ + async: false, + dataType: 'json', + type: 'POST', + url: CreateTaskSubjectAjax, + headers: { "RequestVerificationToken": antiForgeryToken }, + data: { subject: subject }, + success: function (response) { + if (response.isSuccess) { + loadSubjectList(); + $("#NewSubject").val(''); + } + }, + error: function (err) { + console.log(err); + } + }); + + } + }); + + + $('#NewSubject').on('keyup keypress', function (e) { + if ($('#NewSubject').val() != '') { + //کلید دمکه اینتر 13 + var keyCode = e.keyCode || e.which; + if (keyCode === 13) { + $('#btn-add').click(); + } + } + }); + + }); + + function loadSubjectList() { + + var htmlItem = ''; + + $.ajax({ + url: listTaskSubjectAjax, + type: 'GET', + success: function (response) { + var items = response.result; + + items.forEach(function (item) { + htmlItem += `
    +
    +
    + ${item.subject} + +
    + +
    + + +
    + + +
    +
    `; + }); + + $('#loadSubjectList').html(htmlItem); + }, + error: function (xhr, status, error) { + console.error(xhr.responseText); + } + }); + } + + + // $(".editSubject").on('keyup keypress', function (e) { + // if (this.val() != '') { + // //کلید دمکه اینتر 13 + // var keyCode = e.keyCode || e.which; + // if (keyCode === 13) { + // editSubject(id); + // } + // } + // }); + + function editSubject(id) { + + var subjectTitle = $("#editSubject_" + id).val(); + + if (subjectTitle.trim() != '') { + $.ajax({ + async: false, + dataType: 'json', + type: 'POST', + url: editTaskSubjectAjax, + headers: { "RequestVerificationToken": antiForgeryToken }, + data: { id: Number(id), subject: subjectTitle }, + success: function (response) { + if (response.isSuccess) { + loadSubjectList(); + } + }, + error: function (err) { + console.log(err); + } + }); + } + + loadSubjectList(); + } + + function removeSubject(id) { + swal({ + title: "آیا از حذف این عنوان اطمینان دارید؟", + text: "", + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText: "بله", + cancelButtonText: "خیر", + closeOnConfirm: true, + closeOnCancel: true + }, function (isConfirm) { + if (isConfirm) { + deleteSubject(id); + } + }); + } + + function deleteSubject(id) { + var ID = Number(id); + + $.ajax({ + async: false, + dataType: 'json', + type: 'POST', + url: RemoveTaskSubjectAjax, + headers: { "RequestVerificationToken": antiForgeryToken }, + data: {id: Number(ID) }, + success: function (response) { + console.log(response); + if (response.isSuccess) { + loadSubjectList(); + } + }, + error: function (err) { + console.log(err); + } + }); + } + + + function searchSubjectTask() { + + var input, filter, tbody, tr, a, i; + input = document.getElementById("SearchSubject"); + + + filter = input.value.toUpperCase(); + tbody = document.getElementById("loadSubjectList"); + tr = tbody.getElementsByClassName("items"); + for (i = 0; i < tr.length; i++) { + td = tr[i].getElementsByClassName("searchItem")[0]; + if (td.innerHTML.toUpperCase().indexOf(filter) > -1) { + tr[i].style.display = ""; + } else { + tr[i].style.display = "none"; + } + } + } + + + function editOperation(id) { + $("#editOperation_" + id).css('display', 'none'); + $("#editConfirm_" + id).css('display', 'flex'); + + var subjectTitleSpan = $("#editSubjectSpan_" + id); + subjectTitleSpan.css('display', 'none'); + + var subjectTitle = $("#editSubject_" + id); + subjectTitle.css('display', 'block'); + subjectTitle.focus(); + } + + diff --git a/ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/DetailModal.js b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/DetailModal.js new file mode 100644 index 00000000..99134581 --- /dev/null +++ b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/DetailModal.js @@ -0,0 +1,721 @@ + + + +$(document).on('keydown', '#EndTaskDate', function () { + $("input:radio").prop('checked', false); +}) + +function updateDateInput(daysToAdd) { + var today = new Date(); + today.setDate(today.getDate() + daysToAdd); + var jalaaliDate = jalaali.toJalaali(today); + var formattedDate = jalaaliDate.jy + '/' + (jalaaliDate.jm < 10 ? '0' + jalaaliDate.jm : jalaaliDate.jm) + '/' + (jalaaliDate.jd < 10 ? '0' + jalaaliDate.jd : jalaaliDate.jd); + $('#EndTaskDate').val(formattedDate); + //computeDays(); +} + + +$(document).ready(function () { + + updateDateInput(0); + + $(document).on('click', '#today', function () { + updateDateInput(0); + $("#today").prop('checked', true); + }); + + $(document).on('click', '#tommorow', function () { + updateDateInput(1); + $("#tommorow").prop('checked', true); + }); + + $(document).on('click', '#two-day-later', function () { + updateDateInput(2); + $("#two-day-later").prop('checked', true); + }); + + + $('.select2Member').select2({ + placeholder: { + id: '-1', // the value of the option + text: "انتخاب اعضاء ..." + } + }); + + $('.select2Group').select2({ + placeholder: { + id: '-1', // the value of the option + text: "انتخاب گروهی ..." + } + }); + + + $(document).on('click', '#memberSelect', function () { + $('#select2MemberList').show(); + $('#select2GroupList').hide(); + if ($('#memberSelect').is(':checked')) { + $('#Command_PositionId').val(null).trigger('change'); + } + + }); + + $(document).on('click', '#groupSelect', function () { + $('#select2MemberList').hide(); + $('#select2GroupList').show(); + if ($('#groupSelect').is(':checked')) { + $('#Command_ReceiverId').val(null).trigger('change'); + } + }); + + + // let bodyArray = [ + // { 'ReceiverId': $('#CreateTask.ReceiverId').val() }, + // { 'ContractingPartyName': $('#CreateTask.ContractingPartyName').val() }, + // { 'Title': $('#CreateTask.Title').val() }, + // { 'EndTaskDate': $('#CreateTask.EndTaskDate').val() }, + // { 'EndTaskTime': $('#CreateTask.EndTaskTime').val() }, + // { 'Description': $('#CreateTask.Description').val() }, + // ]; + + // var body = new FormData(); + // body.append('ReceiverId', $('#CreateTask.ReceiverId').val()); + // body.append('ContractingPartyName', $('#CreateTask.ContractingPartyName').val()); + // body.append('Title', $('#CreateTask.Title').val()); + // body.append('CreateTask.EndTaskDate', $('#CreateTask.EndTaskDate').val()); + // body.append('CreateTask.EndTaskTime', $('#CreateTask.EndTaskTime').val()); + // body.append('CreateTask.Description', $('#CreateTask.Description').val()); + + // if (files) { + // body.append('CreateTask.Picture', files); + // } + + // var command = {}; + // command.ReceiverId = $('#ReceiverId').val(); + // command.ContractingPartyName = $('#partyNameSearch').val(); + // command.Title = $('#title').val(); + // command.EndTaskDate = $('#EndTaskDate').val(); + // command.EndTaskTime = $('#EndTaskTime').val(); + // command.Description = $('#Command_Description').val(); + + $('#save').on('click', function (e) { + e.preventDefault(); + + var member = $('.select2Member').select2('data'); + var group = $('.select2Group').select2('data'); + + if ($('#memberSelect').is(':checked')) { + if (member.length == 0) { + $('#select2MemberList').addClass('errored'); + $('.alert-msg').show(); + $('.alert-msg p').text('لطفا انتخاب اعضاء را مشخص نمائید.'); + setTimeout(function () { + $('.alert-msg').hide(); + $('.alert-msg p').text(''); + $('#select2MemberList').removeClass('errored'); + }, 3500); + return; + } + } + + if ($('#groupSelect').is(':checked')) { + if (group.length == 0) { + $('#select2GroupList').addClass('errored'); + $('.alert-msg').show(); + $('.alert-msg p').text('لطفا انتخاب گروهی را مشخص نمائید.'); + setTimeout(function () { + $('.alert-msg').hide(); + $('.alert-msg p').text(''); + $('#select2GroupList').removeClass('errored'); + }, 3500); + return; + } + } + + + var textArea = $('#Command_Description'); + var content = textArea.val(); + content = content.replace(/\n/g, '
    '); + textArea.val(content); + + // var fileUpload = $("#Command_Picture1").get(0).files; + // var files = fileUpload.files; + // var fileData = new FormData(); + + + var data = new FormData(this.form); + + $.ajax({ + async: false, + dataType: 'json', + type: 'POST', + processData: false, + contentType: false, + url: createSaveTaskAjax, + headers: { "RequestVerificationToken": antiForgeryToken }, + data: data, + success: function (response) { + console.log(response); + if (response.isSuccedded) { + $('.alert-success-msg').show(); + $('.alert-success-msg p').text(response.message); + setTimeout(function () { + $('.alert-success-msg').hide(); + $('.alert-success-msg p').text(''); + window.location.replace('/AdminNew/Company/Task') + }, 1500); + + } else { + + if (response.message == 'لطفا عنوان وظیفه خود ار وارد کنید') { + $('#Command_Title').addClass('errored'); + $('.alert-msg p').text('لطفا انتخاب گروهی را مشخص نمائید.'); + setTimeout(function () { + $('#Command_Title').removeClass('errored'); + }, 3500); + } + + if (response.message == 'لطفا طرف حساب خودرا وارد کنید') { + $('#partyNameSearch').addClass('errored'); + $('.alert-msg p').text('لطفا انتخاب گروهی را مشخص نمائید.'); + setTimeout(function () { + $('#partyNameSearch').removeClass('errored'); + }, 3500); + } + + if (response.message == 'لطفا تاریخ انجام وظیفه را وارد کنید') { + $('#Command_EndTaskDate').addClass('errored'); + $('.alert-msg p').text('لطفا انتخاب گروهی را مشخص نمائید.'); + setTimeout(function () { + $('#Command_EndTaskDate').removeClass('errored'); + }, 3500); + } + + + $('.alert-msg').show(); + $('.alert-msg p').text(response.message); + setTimeout(function () { + $('.alert-msg').hide(); + $('.alert-msg p').text(''); + }, 3500); + } + }, + error: function (err) { + console.log(err); + } + }); + + // if ($('.errored').length < 1) { + // console.log('hello') + // $('#saveFinaly').click(); + // } else { + // $('.alert-msg').show(); + // $('.alert-msg p').text('لطفا خطاها را برطرف کنید.'); + // setTimeout(function () { + // $('.alert-msg').hide(); + // $('.alert-msg p').text(''); + // }, 3500); + // } + }); + + + $(".date").mask("0000/00/00"); + $('.date').on('input', + function () { + let startDate = this.value; + if (startDate.length == 10) { + let submitcheck = dateValidcheck(this); + if (submitcheck) { + + $(this).removeClass('errored'); + //if ($('#EndTaskDate').val() != '') { + //computeDays(); + //} + + + } else { + $(this).addClass('errored'); + + } + + } else { + $(this).addClass('errored'); + } + }); + + function dateValidcheck(inputField1) { + + let persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g], + arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g], + fixNumbers = function (str) { + if (typeof str === 'string') { + for (var i = 0; i < 10; i++) { + str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i); + } + } + return str; + }; + let getdate = inputField1.value; + + let m1, m2; + let y1, y2, y3, y4; + let d1, d2; + let s1, s2; + for (var i = 0; i < getdate.length; i++) { + if (i === 0) { + y1 = fixNumbers(getdate[i]); + } + if (i === 1) { + y2 = fixNumbers(getdate[i]); + } + if (i === 2) { + y3 = fixNumbers(getdate[i]); + } + if (i === 3) { + y4 = fixNumbers(getdate[i]); + } + if (i === 4) { + s1 = fixNumbers(getdate[i]); + } + if (i === 5) { + m1 = fixNumbers(getdate[i]); + } + if (i === 6) { + m2 = fixNumbers(getdate[i]); + } + if (i === 7) { + s2 = fixNumbers(getdate[i]); + } + if (i === 8) { + d1 = fixNumbers(getdate[i]); + } + if (i === 9) { + d2 = fixNumbers(getdate[i]); + } + + } + let yRes = y1 + y2 + y3 + y4; + let year = parseInt(yRes); + let mRes = m1 + m2; + let month = parseInt(mRes); + let dRes = d1 + d2; + let day = parseInt(dRes); + let fixResult = yRes + s1 + mRes + s2 + dRes; + let test1 = checkEnValid(inputField1.value); + + let isValid = /^([1][3-4][0-9][0-9][/])([0][1-9]|[1][0-2])([/])([0][1-9]|[1-2][0-9]|[3][0-1])$/.test(fixResult); + + + if (isValid && test1) { + // inputField1.style.backgroundColor = '#a6e9a6'; + start1valid = true; + + + } else { + + if (inputField1.value != "") { + // inputField1.style.backgroundColor = '#f94c4c'; + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا تاریخ را بصورت صحیح وارد کنید"); + start1valid = false; + } + + + } + return start1valid; + + } + + function checkEnValid(fixDate1) { + + let persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g], + arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g], + fixNumbers = function (str) { + if (typeof str === 'string') { + for (var i = 0; i < 10; i++) { + str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i); + } + } + return str; + }; + let getdate = fixDate1; + + let m1, m2; + let y1, y2, y3, y4; + let d1, d2; + for (let i = 0; i < getdate.length; i++) { + if (i === 0) { + y1 = fixNumbers(getdate[i]); + } + if (i === 1) { + y2 = fixNumbers(getdate[i]); + } + if (i === 2) { + y3 = fixNumbers(getdate[i]); + } + if (i === 3) { + y4 = fixNumbers(getdate[i]); + } + if (i === 5) { + m1 = fixNumbers(getdate[i]); + } + if (i === 6) { + m2 = fixNumbers(getdate[i]); + } + if (i === 8) { + d1 = fixNumbers(getdate[i]); + } + if (i === 9) { + d2 = fixNumbers(getdate[i]); + } + } + let yRes = y1 + y2 + y3 + y4; + let year = parseInt(yRes); + let mRes = m1 + m2; + let month = parseInt(mRes); + let dRes = d1 + d2; + let day = parseInt(dRes); + let kabiseh = false; + if (month <= 6 && day > 31) { + return false; + } else if (month > 6 && month < 12 && day > 30) { + return false; + } else if (month === 12) { + + switch (year) { + case 1346: + kabiseh = true; + break; + case 1350: + kabiseh = true; + break; + case 1354: + kabiseh = true; + break; + case 1358: + kabiseh = true; + break; + case 1362: + kabiseh = true; + break; + case 1366: + kabiseh = true; + break; + case 1370: + kabiseh = true; + break; + case 1375: + kabiseh = true; + break; + case 1379: + kabiseh = true; + break; + case 1383: + kabiseh = true; + break; + case 1387: + kabiseh = true; + break; + case 1391: + kabiseh = true; + break; + case 1395: + kabiseh = true; + break; + case 1399: + kabiseh = true; + break; + case 1403: + kabiseh = true; + break; + case 1408: + kabiseh = true; + break; + case 1412: + kabiseh = true; + break; + case 1416: + kabiseh = true; + break; + case 1420: + kabiseh = true; + break; + case 1424: + kabiseh = true; + break; + case 1428: + kabiseh = true; + break; + case 1432: + kabiseh = true; + break; + case 1436: + kabiseh = true; + break; + case 1441: + kabiseh = true; + break; + case 1445: + kabiseh = true; + break; + default: + kabiseh = false; + + } + if (kabiseh == true && day > 30) { + return false; + } else if (kabiseh == false && day > 29) { + return false; + } else { + return true; + } + } else { + return true; + } + } + $('#EndTaskTime').on("keyup", + function () { + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test($(this).val()); + if (isValid) { + $(this).addClass("validTime"); + $(this).removeClass("invalidTime"); + // if ($('#EndTaskTime').val() != null) { + // computeDays(); + // } + } else { + $(this).removeClass("validTime"); + $(this).addClass("invalidTime"); + } + }); + +}); + +function remove(id) { + console.log('#Command_Document' + id); + $('#Command_Document' + id).val(''); + $('.inBox' + id).html(''); + $('.inBox' + id).addClass('empty'); +} + +$(document).ready(function () { + $(document).on('click', '#upload-doc', function (e) { + e.preventDefault() + let file1 = document.getElementById("Command_Document1"); + let file2 = document.getElementById("Command_Document2"); + let file3 = document.getElementById("Command_Document3"); + let file4 = document.getElementById("Command_Document4"); + let file5 = document.getElementById("Command_Document5"); + let file6 = document.getElementById("Command_Document6"); + + if (file1.files.length == 0) { + console.log('#Command_Document1 = ' + file1.files.length); + $('#Command_Document1').on('change', function () { + var fileInput1 = file1.files[0]; + if (fileInput1) { + console.log('repeat'); + var reader = new FileReader(); + reader.onload = function (e) { + var img1 = $('').attr('src', e.target.result); + var box1 = $('.inBox1'); + if (box1.length) { + box1.removeClass('empty'); + //addDeleteButton(box1, 1); + var deleteBtn1 = $('
    '); + $('.b1').remove(); + box1.append(img1); + box1.append(deleteBtn1); + } + } + reader.readAsDataURL(fileInput1); + } + }).click(); + return false; + } else if (file2.files.length == 0) { + console.log('#Command_Document2 = ' + file2.files.length); + $('#Command_Document2').on('change', function () { + var fileInput2 = file2.files[0]; + if (fileInput2) { + var reader = new FileReader(); + reader.onload = function (e) { + var img2 = $('').attr('src', e.target.result); + var box2 = $('.inBox2'); + if (box2.length) { + box2.removeClass('empty'); + //addDeleteButton(box2,2); + var deleteBtn2 = $('
    '); + $('.b2').remove(); + box2.append(img2); + box2.append(deleteBtn2); + } + } + reader.readAsDataURL(fileInput2); + } + }).click(); + return false; + } else if (file3.files.length == 0) { + console.log('#Command_Document3 = ' + file3.files.length); + $('#Command_Document3').on('change', function () { + var fileInput3 = file3.files[0]; + if (fileInput3) { + var reader = new FileReader(); + reader.onload = function (e) { + var img3 = $('').attr('src', e.target.result); + var box3 = $('.inBox3'); + if (box3.length) { + box3.removeClass('empty'); + //addDeleteButton(box3, 3); + var deleteBtn3 = $('
    '); + $('.b3').remove(); + box3.append(img3); + box3.append(deleteBtn3); + } + } + reader.readAsDataURL(fileInput3); + } + }).click(); + return false; + } else if (file4.files.length == 0) { + console.log('#Command_Document4 = ' + file4.files.length); + $('#Command_Document4').on('change', function () { + var fileInput4 = file4.files[0]; + if (fileInput4) { + var reader = new FileReader(); + reader.onload = function (e) { + var img4 = $('').attr('src', e.target.result); + var box4 = $('.inBox4'); + if (box4.length) { + box4.removeClass('empty'); + //addDeleteButton(box4, 4); + var deleteBtn4 = $('
    '); + $('.b4').remove(); + box4.append(img4); + box4.append(deleteBtn4); + } + } + reader.readAsDataURL(fileInput4); + } + }).click(); + return false; + } else if (file5.files.length == 0) { + console.log('#Command_Document5 = ' + file5.files.length); + $('#Command_Document5').on('change', function () { + var fileInput5 = file5.files[0]; + if (fileInput5) { + var reader = new FileReader(); + reader.onload = function (e) { + var img5 = $('').attr('src', e.target.result); + var box5 = $('.inBox5'); + if (box5.length) { + box5.removeClass('empty'); + //addDeleteButton(box5, 5); + var deleteBtn5 = $('
    '); + $('.b5').remove(); + box5.append(img5); + box5.append(deleteBtn5); + } + } + reader.readAsDataURL(fileInput5); + } + }).click(); + return false; + } else if (file6.files.length == 0) { + console.log('#Command_Document6 = ' + file6.files.length); + $('#Command_Document6').on('change', function () { + var fileInput6 = file6.files[0]; + if (fileInput6) { + var reader = new FileReader(); + reader.onload = function (e) { + var img6 = $('').attr('src', e.target.result); + var box6 = $('.inBox6'); + if (box6.length) { + box6.removeClass('empty'); + //addDeleteButton(box6, 6); + var deleteBtn6 = $('
    '); + $('.b6').remove(); + box6.append(img6); + box6.append(deleteBtn6); + } + } + reader.readAsDataURL(fileInput6); + } + }).click(); + return false; + } + + }); +}); + + + +if ($('.gallery').length) { + // Lightbox Gallery + (function () { + var lightboxEnabled = document.querySelectorAll('.lightbox-enabled'); + var lightboxArray = Array.from(lightboxEnabled); + var lastImage = lightboxArray.length - 1; + var lightboxContainer = document.querySelector('.lightbox-container'); + var lightboxImage = document.querySelector('.lightbox-image'); + var lightboxBtns = document.querySelectorAll('.lightbox-btn'); + var lightboxBtnRight = document.querySelector('#right'); + var lightboxBtnLeft = document.querySelector('#left'); + var close = document.querySelector('#close'); + let activeImage; + + var showLightBox = () => { lightboxContainer.classList.add('active'); } + + var hideLightBox = () => { lightboxContainer.classList.remove('active'); } + + var setActiveImage = (image) => { + lightboxImage.src = image.dataset.imgsrc; + activeImage = lightboxArray.indexOf(image); + } + + var transitionSlidesLeft = () => { + lightboxBtnLeft.focus(); + $('.lightbox-image').addClass('slideright'); + setTimeout(function () { + activeImage === 0 ? setActiveImage(lightboxArray[lastImage]) : setActiveImage(lightboxArray[activeImage - 1]); + }, 250); + + setTimeout(function () { + $('.lightbox-image').removeClass('slideright'); + }, 500); + } + + var transitionSlidesRight = () => { + lightboxBtnRight.focus(); + $('.lightbox-image').addClass('slideleft'); + setTimeout(function () { + activeImage === lastImage ? setActiveImage(lightboxArray[0]) : setActiveImage(lightboxArray[activeImage + 1]); + }, 250); + setTimeout(function () { + $('.lightbox-image').removeClass('slideleft'); + }, 500); + } + + var transitionSlideHandler = (moveItem) => { + moveItem.includes('left') ? transitionSlidesLeft() : transitionSlidesRight(); + } + + lightboxEnabled.forEach(image => { + image.addEventListener('click', (e) => { + showLightBox(); + setActiveImage(image); + }); + }); + + lightboxContainer.addEventListener('click', () => { hideLightBox(); }); + close.addEventListener('click', () => { hideLightBox(); }); + + lightboxBtns.forEach(btn => { + btn.addEventListener('click', (e) => { + e.stopPropagation(); + transitionSlideHandler(e.currentTarget.id); + }); + }); + + lightboxImage.addEventListener('click', (e) => { + e.stopPropagation(); + }); + })(); +} + + diff --git a/ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/Edit.js b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/Edit.js new file mode 100644 index 00000000..d5744769 --- /dev/null +++ b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/Edit.js @@ -0,0 +1,885 @@ + + +document.getElementById("MainModal").style.visibility = "visible"; + +$(document).on('keydown', '#EndTaskDate', function () { + $("input:radio").prop('checked', false); +}); + +$(document).ready(function () { + $(document).on('click', '#today', function () { + updateDateInput(0); + $("#today").prop('checked', true); + }); + + $(document).on('click', '#tommorow', function () { + updateDateInput(1); + $("#tommorow").prop('checked', true); + }); + + $(document).on('click', '#two-day-later', function () { + updateDateInput(2); + $("#two-day-later").prop('checked', true); + }); + + + $('.select2Member').select2({ + placeholder: { + id: '-1', // the value of the option + text: "انتخاب اعضاء ..." + } + }); + + $('.select2Group').select2({ + placeholder: { + id: '-1', // the value of the option + text: "انتخاب گروهی ..." + } + }); + + // $(document).on('click', '#memberSelect', function () { + // $('#select2MemberList').show(); + // $('#select2GroupList').hide(); + // if ($('#memberSelect').is(':checked')) { + // $('#Command_PositionId').val(null).trigger('change'); + // } + + // }); + + // $(document).on('click', '#groupSelect', function () { + // $('#select2MemberList').hide(); + // $('#select2GroupList').show(); + // if ($('#groupSelect').is(':checked')) { + // $('#Command_ReceiverId').val(null).trigger('change'); + // } + // }); + + $('#save').on('click', function (e) { + e.preventDefault(); + + var member = $('.select2Member').select2('data'); + //var group = $('.select2Group').select2('data'); + + if ($('#memberSelect').is(':checked')) { + if (member.length == 0) { + $('#select2MemberList').addClass('errored'); + $('.alert-msg').show(); + $('.alert-msg p').text('لطفا انتخاب اعضاء را مشخص نمائید.'); + setTimeout(function () { + $('.alert-msg').hide(); + $('.alert-msg p').text(''); + $('#select2MemberList').removeClass('errored'); + }, 3500); + return; + } + } + + // if ($('#groupSelect').is(':checked')) { + // if (group.length == 0) { + // $('#select2GroupList').addClass('errored'); + // $('.alert-msg').show(); + // $('.alert-msg p').text('لطفا انتخاب گروهی را مشخص نمائید.'); + // setTimeout(function () { + // $('.alert-msg').hide(); + // $('.alert-msg p').text(''); + // $('#select2GroupList').removeClass('errored'); + // }, 3500); + // return; + // } + // } + + + var textArea = $('#Command_Description'); + var content = textArea.val(); + content = content.replace(/\n/g, '
    '); + textArea.val(content); + + + var data = new FormData(this.form); + + $.ajax({ + async: false, + dataType: 'json', + type: 'POST', + processData: false, + contentType: false, + url: EditSaveTask , + headers: { "RequestVerificationToken": AntiForgeryToken }, + data: data, + success: function (response) { + console.log(response); + if (response.isSuccess) { + $('.alert-success-msg').show(); + $('.alert-success-msg p').text(response.message); + setTimeout(function () { + $('.alert-success-msg').hide(); + $('.alert-success-msg p').text(''); + window.location.replace('/AdminNew/Company/Task'); + }, 1500); + + } else { + if (response.message == 'لطفا عنوان وظیفه خود ار وارد کنید') { + $('#Command_Title').addClass('errored'); + $('.alert-msg p').text('لطفا انتخاب گروهی را مشخص نمائید.'); + setTimeout(function () { + $('#Command_Title').removeClass('errored'); + }, 3500); + } + + if (response.message == 'لطفا طرف حساب خودرا وارد کنید') { + $('#partyNameSearch').addClass('errored'); + $('.alert-msg p').text('لطفا انتخاب گروهی را مشخص نمائید.'); + setTimeout(function () { + $('#partyNameSearch').removeClass('errored'); + }, 3500); + } + + if (response.message == 'لطفا تاریخ انجام وظیفه را وارد کنید') { + $('#Command_EndTaskDate').addClass('errored'); + $('.alert-msg p').text('لطفا انتخاب گروهی را مشخص نمائید.'); + setTimeout(function () { + $('#Command_EndTaskDate').removeClass('errored'); + }, 3500); + } + + $('.alert-msg').show(); + $('.alert-msg p').text(response.message); + setTimeout(function () { + $('.alert-msg').hide(); + $('.alert-msg p').text(''); + }, 3500); + } + }, + error: function (err) { + console.log(err); + } + }); + }); + + + $(".date").mask("0000/00/00"); + $('.date').on('input', function () { + let startDate = this.value; + if (startDate.length == 10) { + let submitcheck = dateValidcheck(this); + if (submitcheck) { + + $(this).removeClass('errored'); + } else { + $(this).addClass('errored'); + + } + + } else { + $(this).addClass('errored'); + } + }); + + $('#EndTaskTime').on("keyup", function () { + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test($(this).val()); + if (isValid) { + $(this).addClass("validTime"); + $(this).removeClass("invalidTime"); + // if ($('#EndTaskTime').val() != null) { + // computeDays(); + // } + } else { + $(this).removeClass("validTime"); + $(this).addClass("invalidTime"); + } + }); + +}); + +function updateDateInput(daysToAdd) { + var today = new Date(); + today.setDate(today.getDate() + daysToAdd); + var jalaaliDate = jalaali.toJalaali(today); + var formattedDate = jalaaliDate.jy + '/' + (jalaaliDate.jm < 10 ? '0' + jalaaliDate.jm : jalaaliDate.jm) + '/' + (jalaaliDate.jd < 10 ? '0' + jalaaliDate.jd : jalaaliDate.jd); + $('#EndTaskDate').val(formattedDate); + //computeDays(); +} + +function dateValidcheck(inputField1) { + + let persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g], + arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g], + fixNumbers = function (str) { + if (typeof str === 'string') { + for (var i = 0; i < 10; i++) { + str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i); + } + } + return str; + }; + let getdate = inputField1.value; + + let m1, m2; + let y1, y2, y3, y4; + let d1, d2; + let s1, s2; + for (var i = 0; i < getdate.length; i++) { + if (i === 0) { + y1 = fixNumbers(getdate[i]); + } + if (i === 1) { + y2 = fixNumbers(getdate[i]); + } + if (i === 2) { + y3 = fixNumbers(getdate[i]); + } + if (i === 3) { + y4 = fixNumbers(getdate[i]); + } + if (i === 4) { + s1 = fixNumbers(getdate[i]); + } + if (i === 5) { + m1 = fixNumbers(getdate[i]); + } + if (i === 6) { + m2 = fixNumbers(getdate[i]); + } + if (i === 7) { + s2 = fixNumbers(getdate[i]); + } + if (i === 8) { + d1 = fixNumbers(getdate[i]); + } + if (i === 9) { + d2 = fixNumbers(getdate[i]); + } + + } + let yRes = y1 + y2 + y3 + y4; + let year = parseInt(yRes); + let mRes = m1 + m2; + let month = parseInt(mRes); + let dRes = d1 + d2; + let day = parseInt(dRes); + let fixResult = yRes + s1 + mRes + s2 + dRes; + let test1 = checkEnValid(inputField1.value); + + let isValid = /^([1][3-4][0-9][0-9][/])([0][1-9]|[1][0-2])([/])([0][1-9]|[1-2][0-9]|[3][0-1])$/.test(fixResult); + + + if (isValid && test1) { + // inputField1.style.backgroundColor = '#a6e9a6'; + start1valid = true; + + + } else { + + if (inputField1.value != "") { + // inputField1.style.backgroundColor = '#f94c4c'; + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا تاریخ را بصورت صحیح وارد کنید"); + start1valid = false; + } + + + } + return start1valid; + +} + +function checkEnValid(fixDate1) { + + let persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g], + arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g], + fixNumbers = function (str) { + if (typeof str === 'string') { + for (var i = 0; i < 10; i++) { + str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i); + } + } + return str; + }; + let getdate = fixDate1; + + let m1, m2; + let y1, y2, y3, y4; + let d1, d2; + for (let i = 0; i < getdate.length; i++) { + if (i === 0) { + y1 = fixNumbers(getdate[i]); + } + if (i === 1) { + y2 = fixNumbers(getdate[i]); + } + if (i === 2) { + y3 = fixNumbers(getdate[i]); + } + if (i === 3) { + y4 = fixNumbers(getdate[i]); + } + if (i === 5) { + m1 = fixNumbers(getdate[i]); + } + if (i === 6) { + m2 = fixNumbers(getdate[i]); + } + if (i === 8) { + d1 = fixNumbers(getdate[i]); + } + if (i === 9) { + d2 = fixNumbers(getdate[i]); + } + } + let yRes = y1 + y2 + y3 + y4; + let year = parseInt(yRes); + let mRes = m1 + m2; + let month = parseInt(mRes); + let dRes = d1 + d2; + let day = parseInt(dRes); + let kabiseh = false; + if (month <= 6 && day > 31) { + return false; + } else if (month > 6 && month < 12 && day > 30) { + return false; + } else if (month === 12) { + + switch (year) { + case 1346: + kabiseh = true; + break; + case 1350: + kabiseh = true; + break; + case 1354: + kabiseh = true; + break; + case 1358: + kabiseh = true; + break; + case 1362: + kabiseh = true; + break; + case 1366: + kabiseh = true; + break; + case 1370: + kabiseh = true; + break; + case 1375: + kabiseh = true; + break; + case 1379: + kabiseh = true; + break; + case 1383: + kabiseh = true; + break; + case 1387: + kabiseh = true; + break; + case 1391: + kabiseh = true; + break; + case 1395: + kabiseh = true; + break; + case 1399: + kabiseh = true; + break; + case 1403: + kabiseh = true; + break; + case 1408: + kabiseh = true; + break; + case 1412: + kabiseh = true; + break; + case 1416: + kabiseh = true; + break; + case 1420: + kabiseh = true; + break; + case 1424: + kabiseh = true; + break; + case 1428: + kabiseh = true; + break; + case 1432: + kabiseh = true; + break; + case 1436: + kabiseh = true; + break; + case 1441: + kabiseh = true; + break; + case 1445: + kabiseh = true; + break; + default: + kabiseh = false; + + } + if (kabiseh == true && day > 30) { + return false; + } else if (kabiseh == false && day > 29) { + return false; + } else { + return true; + } + } else { + return true; + } +} + +var indexCount = 0; +function remove(index, id) { + console.log('#EditTask_Document' + index); + $('#EditTask_Document' + index).val(''); + $('.inBox' + index).html(''); + $('.inBox' + index).addClass('empty'); + + var input = ``; + var inputDelete = `"`; + + $('.inBox' + index).html(input); + $('#deletedItems').append(inputDelete); + indexCount++; +} + +function removeVoice(id) { + console.log('#EditTask_Voice'); + $('#EditTask_Voice').val(''); + $('#NewVoice').removeClass('d-none'); + $('#NewVoice').addClass('d-block d-md-flex'); + $('#OldVoice').addClass('d-none'); + $('#OldVoice').removeClass('d-block d-md-flex'); + + // var inputDelete = `"`; + var inputDelete = `"`; + + $('#deletedItems').append(inputDelete); +} + + +$(document).ready(function () { + $(document).on('click', '#upload-doc', function (e) { + e.preventDefault(); + + let file1 = document.getElementById("EditTask_Document1"); + let file2 = document.getElementById("EditTask_Document2"); + let file3 = document.getElementById("EditTask_Document3"); + let file4 = document.getElementById("EditTask_Document4"); + let file5 = document.getElementById("EditTask_Document5"); + let file6 = document.getElementById("EditTask_Document6"); + + if (file1.type == "file" && file1.files.length == 0) { + console.log('#EditTask_Document1 = ' + file1.files.length); + $('#EditTask_Document1').on('change', function () { + var fileInput1 = file1.files[0]; + if (fileInput1) { + console.log('repeat'); + var reader = new FileReader(); + reader.onload = function (e) { + var img1 = $('').attr('src', e.target.result); + var box1 = $('.inBox1'); + if (box1.length) { + box1.removeClass('empty'); + //addDeleteButton(box1, 1); + var deleteBtn1 = $('
    '); + $('.b1').remove(); + box1.append(img1); + box1.append(deleteBtn1); + } + } + reader.readAsDataURL(fileInput1); + } + }).click(); + return false; + } else if (file2.type == "file" && file2.files.length == 0) { + console.log('#EditTask_Document2 = ' + file2.files.length); + $('#EditTask_Document2').on('change', function () { + var fileInput2 = file2.files[0]; + if (fileInput2) { + var reader = new FileReader(); + reader.onload = function (e) { + var img2 = $('').attr('src', e.target.result); + var box2 = $('.inBox2'); + if (box2.length) { + box2.removeClass('empty'); + //addDeleteButton(box2,2); + var deleteBtn2 = $('
    '); + $('.b2').remove(); + box2.append(img2); + box2.append(deleteBtn2); + } + } + reader.readAsDataURL(fileInput2); + } + }).click(); + return false; + } else if (file3.type == "file" && file3.files.length == 0) { + console.log('#EditTask_Document3 = ' + file3.files.length); + $('#EditTask_Document3').on('change', function () { + var fileInput3 = file3.files[0]; + if (fileInput3) { + var reader = new FileReader(); + reader.onload = function (e) { + var img3 = $('').attr('src', e.target.result); + var box3 = $('.inBox3'); + if (box3.length) { + box3.removeClass('empty'); + //addDeleteButton(box3, 3); + var deleteBtn3 = $('
    '); + $('.b3').remove(); + box3.append(img3); + box3.append(deleteBtn3); + } + } + reader.readAsDataURL(fileInput3); + } + }).click(); + return false; + } else if (file4.type == "file" && file4.files.length == 0) { + console.log('#EditTask_Document4 = ' + file4.files.length); + $('#EditTask_Document4').on('change', function () { + var fileInput4 = file4.files[0]; + if (fileInput4) { + var reader = new FileReader(); + reader.onload = function (e) { + var img4 = $('').attr('src', e.target.result); + var box4 = $('.inBox4'); + if (box4.length) { + box4.removeClass('empty'); + //addDeleteButton(box4, 4); + var deleteBtn4 = $('
    '); + $('.b4').remove(); + box4.append(img4); + box4.append(deleteBtn4); + } + } + reader.readAsDataURL(fileInput4); + } + }).click(); + return false; + } else if (file5.type == "file" && file5.files.length == 0) { + console.log('#EditTask_Document5 = ' + file5.files.length); + $('#EditTask_Document5').on('change', function () { + var fileInput5 = file5.files[0]; + if (fileInput5) { + var reader = new FileReader(); + reader.onload = function (e) { + var img5 = $('').attr('src', e.target.result); + var box5 = $('.inBox5'); + if (box5.length) { + box5.removeClass('empty'); + //addDeleteButton(box5, 5); + var deleteBtn5 = $('
    '); + $('.b5').remove(); + box5.append(img5); + box5.append(deleteBtn5); + } + } + reader.readAsDataURL(fileInput5); + } + }).click(); + return false; + } else if (file6.type == "file" && file6.files.length == 0) { + console.log('#EditTask_Document6 = ' + file6.files.length); + $('#EditTask_Document6').on('change', function () { + var fileInput6 = file6.files[0]; + if (fileInput6) { + var reader = new FileReader(); + reader.onload = function (e) { + var img6 = $('').attr('src', e.target.result); + var box6 = $('.inBox6'); + if (box6.length) { + box6.removeClass('empty'); + //addDeleteButton(box6, 6); + var deleteBtn6 = $('
    '); + $('.b6').remove(); + box6.append(img6); + box6.append(deleteBtn6); + } + } + reader.readAsDataURL(fileInput6); + } + }).click(); + return false; + } + + }); + +}); + + +// نمایش اسامی کارگاه +var container = $('#partyName'); +var searchBox = $('#partyNameSearch'); +var searchResul = $('.searchResult'); +var mixContainerAndSerchResult = $('#partyName , .searchResult'); + +container.hide(); +var liList; +var liPointer; +var count = 0; + +//close search Employee when click on body +$(document).on('click', function (event) { + if (!$(event.target).closest(container).length) { + container.hide(); + } +}); +//select option by mouse +function selectItem(employeeFullName) { + searchBox.val(employeeFullName); + container.hide(); +}; +//search by Ajax +searchBox.on('keyup keypress', + function (e) { + searchResul.html(''); + + //stop submit form with enter + var keyCode = e.keyCode || e.which; + if (keyCode === 13) { + e.preventDefault(); + if (count > 0 && count <= liList.length) { + liPointer.click(); + } + return false; + } + + let searchText = $(this).val(); + + if (searchText.length > 1) { + + $.ajax({ + async: false, + contentType: 'charset=utf-8', + dataType: 'json', + type: 'GET', + url: SearchContractingParties, + data: { "searchName": searchText }, + headers: { "RequestVerificationToken": AntiForgeryToken }, + + success: function (response) { + $(".opt").remove(); + if (response.list.length > 0) { + $(".noResult").remove(); + container.show(); + $.each(response.list, + function (i, item) { + let li = `
  • ${item.fullName}
  • `; + searchResul.append(li); + }); + } else { + $(".noResult").remove(); + container.show(); + let noResult = `
  • نتیجه ای یافت نشد!
  • `; + searchResul.append(noResult); + } + }// endOfSuccess + + }); //endOfAjax + + } else { + container.hide(); + count = 0; + } + }); +// نمایش اسامی کارگاه + + + + +// صدا +var msg_box = document.getElementById('msg_box'), + button = document.getElementById('upload-voice'), + canvas = document.getElementById('canvas'), + lang = { + 'mic_error': 'خطا! به میکروفون دسترسی ندارد.', + 'press_to_start': 'برای ضبط صدا، پیام صوتی را کلیک نمائید', + 'recording': 'در حال ضبط پیام صوتی ...', + 'play': 'پخش', + 'stop': 'متوقف', + 'download': 'دانلود', + 'use_https': 'This application in not working over insecure connection. Try to use HTTPS' + }, + time; + +msg_box.innerHTML = lang.press_to_start; + +if (navigator.mediaDevices === undefined) { + navigator.mediaDevices = {}; +} + +if (navigator.mediaDevices.getUserMedia === undefined) { + navigator.mediaDevices.getUserMedia = function (constrains) { + var getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia + if (!getUserMedia) { + return Promise.reject(new Error('getUserMedia is not implemented in this browser')); + } + + return new Promise(function (resolve, reject) { + getUserMedia.call(navigator, constrains, resolve, reject); + }); + } +} + +if (navigator.mediaDevices.getUserMedia) { + var btn_status = 'inactive', + mediaRecorder, + chunks = [], + audio = new Audio(), + mediaStream, + audioSrc, + type = { + 'type': 'audio/ogg,codecs=opus' + }, + ctx, + analys, + blob; + + button.onclick = function () { + if (btn_status == 'inactive') { + start(); + } else if (btn_status == 'recording') { + stop(); + } + } + + function parseTime(sec) { + var h = parseInt(sec / 3600); + var m = parseInt(sec / 60); + var sec = sec - (h * 3600 + m * 60); + + h = h == 0 ? '' : h + ':'; + sec = sec < 10 ? '0' + sec : sec; + + return h + m + ':' + sec; + } + + function start() { + console.log('start') + navigator.mediaDevices.getUserMedia({ 'audio': true }).then(function (stream) { + mediaRecorder = new MediaRecorder(stream); + mediaRecorder.start(); + + button.classList.add('recording'); + btn_status = 'recording'; + + msg_box.innerHTML = lang.recording; + + if (navigator.vibrate) navigator.vibrate(150); + + time = Math.ceil(new Date().getTime() / 1000); + + mediaRecorder.ondataavailable = function (event) { + chunks.push(event.data); + } + + mediaRecorder.onstop = function () { + stream.getTracks().forEach(function (track) { track.stop() }); + + blob = new Blob(chunks, type); + audioSrc = window.URL.createObjectURL(blob); + + audio.src = audioSrc; + + chunks = []; + + // Save the Blob to the input element + saveToInput(blob); + } + + }).catch(function (error) { + if (location.protocol != 'https:') { + msg_box.innerHTML = lang.mic_error + '
    ' + lang.use_https; + } else { + msg_box.innerHTML = lang.mic_error; + } + button.disabled = true; + }); + } + + function stop() { + console.log('stop'); + mediaRecorder.stop(); + button.classList.remove('recording'); + btn_status = 'inactive'; + + if (navigator.vibrate) navigator.vibrate([200, 100, 200]); + + var now = Math.ceil(new Date().getTime() / 1000); + var t = parseTime(now - time); + + msg_box.innerHTML = '' + lang.play + ' (' + t + 's)
    ' + + '' + lang.download + ''; + } + + function play() { + audio.play(); + msg_box.innerHTML = '' + lang.stop + '
    ' + + '' + lang.download + ''; + } + + function pause() { + audio.pause(); + audio.currentTime = 0; + msg_box.innerHTML = '' + lang.play + '
    ' + + '' + lang.download + '' + } + + function roundedRect(ctx, x, y, width, height, radius, fill) { + ctx.beginPath(); + ctx.moveTo(x, y + radius); + ctx.lineTo(x, y + height - radius); + ctx.quadraticCurveTo(x, y + height, x + radius, y + height); + ctx.lineTo(x + width - radius, y + height); + ctx.quadraticCurveTo(x + width, y + height, x + width, y + height - radius); + ctx.lineTo(x + width, y + radius); + ctx.quadraticCurveTo(x + width, y, x + width - radius, y); + ctx.lineTo(x + radius, y); + ctx.quadraticCurveTo(x, y, x, y + radius); + + ctx.fillStyle = fill; + ctx.fill(); + } + + function saveToInput(blob) { + // Create the File object with the actual Blob data + const myFile = new File([blob], 'record.ogg', { + type: 'audio/ogg', + lastModified: new Date(), + }); + + let fileVoice = document.getElementById("EditTask_Voice"); + const dataTransfer = new DataTransfer(); + dataTransfer.items.add(myFile); + fileVoice.files = dataTransfer.files; + } + + function save() { + console.log(audioSrc); + var a = document.createElement('a'); + a.download = 'record.ogg'; + a.href = audioSrc; + document.body.appendChild(a); + a.click(); + + document.body.removeChild(a); + } + +} else { + if (location.protocol != 'https:') { + msg_box.innerHTML = lang.mic_error + '
    ' + lang.use_https; + } else { + msg_box.innerHTML = lang.mic_error; + } + button.disabled = true; +} +// صدا + + + + + diff --git a/ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/Index.js b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/Index.js new file mode 100644 index 00000000..9c083c4d --- /dev/null +++ b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/Index.js @@ -0,0 +1,1241 @@ +$('#MainModal').on('hidden.bs.modal', function () { + $("#ModalContent").html(""); + $(".modal-xl-taskTime").removeClass('modal-xxxl'); +}); + +$(document).on('click', ".openAction", function () { + $(this).next().find(".operations-btns").slideToggle(500); + $(".operations-btns").not($(this).next().find(".operations-btns")).slideUp(500); +}); + + +$(document).on('click', ".btnTaskList", function () { + $('.btnTaskRequest').removeClass('active'); + $('.btnTaskList').addClass('active'); + $('#divTaskList').show(); + $('#divTaskRequest').hide(); + + $('#tasksAjax').html(''); + + Number($('#pageIndex').val(0)); + Number($('#AccountId').val(0)); + $('#StartDate').val(''); + $('#EndDate').val(''); + $('#IsDone').val(''); + + // $('#IsCanceled').val(''); + // $('#IsCancelRequest').val(''); + // $('#IsTimeRequest').val(''); + // $('#TimeRequestAccepted').val(''); + + loadMore(); +}); + +$(document).on('click', ".btnTaskRequest", function () { + $('.btnTaskList').removeClass('active'); + $('.btnTaskRequest').addClass('active'); + $('#divTaskList').hide(); + $('#divTaskRequest').show(); + + $('#taskRequestsAjax').html(''); + + Number($('#pageIndex').val(0)); + Number($('#AccountId').val(0)); + $('#StartDate').val(''); + $('#EndDate').val(''); + $('#IsDone').val(''); + + // $('#IsCanceled').val(''); + // $('#IsCancelRequest').val(''); + // $('#IsTimeRequest').val(''); + // $('#TimeRequestAccepted').val(''); + + loadMoreRequest(); +}); + + +$(document).ready(function () { + $(document).on('click', ".loadingButton", function () { + var button = $(this); + var loadingDiv = button.find('.loading'); + loadingDiv.show(); + }); + $('.goToTop').hide(); +}); + + +$('.goToTop').on('click', + function () { + $('html, body').animate({ scrollTop: 0 }, 360); + return false; + }); + +function loadSticky() { + var stickyDiv = $(".sticky-div"); + var stickyOffset = stickyDiv.offset().top; + + $(window).scroll(function () { + if (window.pageYOffset >= stickyOffset) { + stickyDiv.addClass("sticky"); + } else { + stickyDiv.removeClass("sticky"); + } + + if ($(this).scrollTop() > 100) { + $('.goToTop').show().fadeIn(); + } else { + $('.goToTop').fadeOut().hide(); + } + }); +} + +$('#searchBtn').on('click', function () { + $('#pageIndex').val(0); + $('#tasksAjax').html(''); + loadMore(); +}); + + + +function loadMore() { + let pageIndex = Number($('#pageIndex').val()); + var b = pageIndex % 30; + var AccountId = Number($('#AccountId').val()); + var StartDate = $('#StartDate').val(); + var EndDate = $('#EndDate').val(); + var IsCanceled = $('#IsCanceled').val(); + var IsCancelRequest = $('#IsCancelRequest').val(); + var IsTimeRequest = $('#IsTimeRequest').val(); + var TimeRequestAccepted = $('#TimeRequestAccepted').val(); + var IsDone = $('#IsDone').val(); + var IsDoneRequest = $('#IsDoneRequest').val(); + var index = 1; + var html = ''; + + + if (b === 0) { + // var searchModel = {}; + // searchModel.Status = $('#status').val(); + // searchModel.ContractingPatyId = Number($('#contractingPatyId').val()); + $.ajax({ + async: false, + contentType: 'charset=utf-8', + dataType: 'json', + type: 'GET', + url: `${loadMoreAjax}`, + data: { + pageIndex: pageIndex, + accountId: AccountId, + startDate: StartDate, + endDate: EndDate, + isCanceled: IsCanceled, + isCancelRequest: IsCancelRequest, + isTimeRequest: IsTimeRequest, + timeRequestAccepted: TimeRequestAccepted, + isDoneRequest: IsDoneRequest, + isDone: IsDone, + type: '' + }, + headers: { "RequestVerificationToken": `${antiForgeryToken}` }, + + + success: function (response) { + if (response.pageIndex > 0) { + var n = pageIndex + 1; + var taskList = response.taskList; + if (n == 1) { + + html += `
    +
    ردیف
    +
    +
    ارجاع دهنده
    +
    وظیفه
    `; + + if (response.positions.length > 0) { + response.positions.forEach(function (pos) { + html += `
    ${pos.name}
    `; + }); + } + + html += `
    +
    تاریخ
    +
    طرف حساب
    +
    عنوان وظیفه
    +
    جزئیات
    +
    عملیات
    +
    `; + } + + + taskList.forEach(function (item) { + + var successSend = item.status == "موفق" ? "successSend" : ""; + + html += `
    +
    +
    + + ${n} + +
    +
    + +
    +
    ${item.sender.fullname}
    +
    ${item.selfName}
    `; + if (response.positions.length > 0) { + response.positions.forEach(function (position) { + if ((item.assignList.filter((x) => x.posValue == position.value && x.assignViewModels.length > 0)).length > 0) { + var assignlistt = item.assignList.filter((x) => x.posValue == position.value && x.assignViewModels.length > 0); + + html += ` +
    +

    + ${assignlistt[0].assignViewModels[0].assignedName} +

    + + `; + + assignlistt[0].assignViewModels.forEach(function (aVMs) { + html += `

    ${aVMs.assignedName}

    `; + }); + + html += `
    +
    `; + } + else { + html += `
    -
    `; + } + + }); + } + + html += `
    `; + + + + html += `
    +
    ${item.endTaskTime} ${item.endTaskDateFA}
    +
    + +
    +
    +
    +

    + ${item.contractingPartyName} +

    + + ${item.contractingPartyName} + +
    +
    +
    + +
    +
    +
    +

    + ${item.name} +

    + + ${item.name} + +
    +
    +
    + +
    +
    `; + + if (item.hasAttachment) { + html += ``; + } + + html += `
    +
    + `; + + html += `
    +
    `; + + + + if (!item.isDone && !item.isCancel) { + html += ` + + `; + } else { + html += ``; + } + + html += `
    +
    +
    `; + + + if (!item.isDone && !item.isCancel) { + html += `
    +
    +
    +
    + +
    `; + + + if (response.positions.length > 0) { + response.positions.forEach(function (position) { + if ((item.assignList.filter((x) => x.posValue == position.value && x.assignViewModels.length > 0)).length > 0) { + var assignlistt = item.assignList.filter((x) => x.posValue == position.value && x.assignViewModels.length > 0) + html += `
    +
    ${assignlistt[0].assignViewModels[0].assignedName}
    +
    `; + } + }); + } + + html += `
    +
    +
    +
    ${item.contractingPartyName}
    +
    +
    +
    ${item.endTaskTime} ${item.endTaskDateFA}
    +
    +
    + +
    +
    +
    + + + + + +
    +
    +
    +
    + + + `; + html += `
    +
    +
    +
    `; + } + html += `
    `; + n += 1; + }); + + $('#tasksAjax').append(html); + var newPageIndex = pageIndex + response.pageIndex; + $('#pageIndex').val(newPageIndex); + } + + loadSticky(); + + }, + failure: function (response) { + console.log(5, response); + + } + }); + } +} + + +function loadRequestCount() { + $.ajax({ + async: false, + dataType: 'json', + type: 'GET', + url: `${loadRequestCountAjax}`, + headers: { "RequestVerificationToken": `${antiForgeryToken}` }, + success: function (response) { + $('#badgeRequestCount').text(response.result); + + }, + error: function (err) { + console.log(err); + } + }); +} + + + +function loadMoreRequest() { + loadRequestCount(); + + let pageIndex = Number($('#pageIndex').val()); + var b = pageIndex % 30; + var AccountId = Number($('#AccountId').val()); + var StartDate = $('#StartDate').val(); + var EndDate = $('#EndDate').val(); + var IsCanceled = $('#IsCanceled').val(); + var IsCancelRequest = $('#IsCancelRequest').val(); + var IsTimeRequest = $('#IsTimeRequest').val(); + var TimeRequestAccepted = $('#TimeRequestAccepted').val(); + var IsDone = $('#IsDone').val(); + var IsDoneRequest = $('#IsDoneRequest').val(); + var index = 1; + var html = ''; + + if (b === 0) { + + // var searchModel = {}; + // searchModel.Status = $('#status').val(); + // searchModel.ContractingPatyId = Number($('#contractingPatyId').val()); + $.ajax({ + async: false, + contentType: 'charset=utf-8', + dataType: 'json', + type: 'GET', + url: `${loadMoreAjax}`, + data: { + pageIndex: pageIndex, + accountId: AccountId, + endDate: EndDate, + isCanceled: IsCanceled, + isCancelRequest: IsCancelRequest, + isDone: IsDone, + isTimeRequest: IsTimeRequest, + startDate: StartDate, + timeRequestAccepted: TimeRequestAccepted, + type: 'request' + }, + headers: { "RequestVerificationToken": `${antiForgeryToken}` }, + + + success: function (response) { + if (response.pageIndex > 0) { + var n = pageIndex + 1; + var taskList = response.taskList; + if (n == 1) { + + html += `
    +
    ردیف
    +
    +
    ارجاع دهنده
    +
    وظیفه
    `; + + if (response.positions.length > 0) { + response.positions.forEach(function (pos) { + html += `
    ${pos.name}
    `; + }); + } + + html += `
    +
    تاریخ
    +
    طرف حساب
    +
    عنوان وظیفه
    +
    جزئیات
    +
    عملیات
    +
    `; + } + + taskList.forEach(function (item) { + + var successSend = item.status == "موفق" ? "successSend" : ""; + var operation; + switch (item.color) { + case "red": + operation = "cancel_request"; + break; + case "yellow": + operation = "request_time"; + break; + case "green": + operation = "complete_request"; + break; + + default: + operation = ""; + } + + + html += `
    +
    +
    + + ${n} + +
    +
    + +
    +
    ${item.sender.fullname}
    +
    ${item.selfName}
    `; + if (response.positions.length > 0) { + response.positions.forEach(function (position) { + if ((item.assignList.filter((x) => x.posValue == position.value && x.assignViewModels.length > 0)).length > 0) { + var assignlistt = item.assignList.filter((x) => x.posValue == position.value && x.assignViewModels.length > 0); + + html += ` +
    +

    + ${assignlistt[0].assignViewModels[0].assignedName} +

    + + `; + + assignlistt[0].assignViewModels.forEach(function (aVMs) { + html += `

    ${aVMs.assignedName}

    `; + }); + + html += `
    +
    `; + } + else { + html += `
    -
    `; + } + + }); + } + + html += `
    `; + + + + html += `
    +
    ${item.endTaskTime} ${item.endTaskDateFA}
    +
    + +
    +
    +
    +

    + ${item.contractingPartyName} +

    + + ${item.contractingPartyName} + +
    +
    +
    + +
    +
    +
    +

    + ${item.name} +

    + + ${item.name} + +
    +
    +
    + +
    +
    `; + + // if (item.hasAttachment) { + html += ``; + // } + + html += `
    +
    + `; + + html += `
    +
    `; + + + + html += ``; + + + html += `
    +
    +
    `; + + html += ``; + n += 1; + }); + + $('#taskRequestsAjax').append(html); + var newPageIndex = pageIndex + response.pageIndex; + $('#pageIndex').val(newPageIndex); + index++; + } + + loadSticky(); + + }, + failure: function (response) { + console.log(5, response); + + } + }); + } +} + + +$(document).ready(function () { + loadMore(); + + var filterEmployeeId = $('#AccountId').val(); + var filterStart = $('#StartDate').val().trim(); + var filterEnd = $('#EndDate').val().trim(); + var filterIsDone = $('#IsDone').val().trim(); + + if (filterEmployeeId != 0 || filterStart != '' || filterEnd != '' || filterIsDone != '') { + $('.btn-clear-filter').removeClass('disable'); + } else { + $('.btn-clear-filter').addClass('disable'); + } +}); + + +// var extraHeight = 1680; +// var divHeight = 1550; +// $("#divTaskList").scroll(function () { +// if ($("#divTaskList").scrollTop() + $("#divTaskList").height() > extraHeight - 100) { +// alert("loading.."); +// loadMore(); +// extraHeight += divHeight; + + +// } +// }); +$(window).scroll(function () { + if ($(window).scrollTop() + $(window).height() > $(document).height() - 600) { + loadMore(); + } +}); + + + + + + + +// *************************** مربوط به جستجو در دسکتاپ ******************************** + +const selectedAll = document.querySelectorAll(".wrapper-dropdown"); + +var wrapperDropdown = $(".wrapper-dropdown"); + +$(document).ready(function () { + wrapperDropdown.on("click", function () { + var dropdown = $(this); + var optionsContainer = dropdown.children(".dropdown"); + var optionsList = optionsContainer.find(".item"); + + dropdown.toggleClass("active"); + + if (dropdown.hasClass("active")) { + wrapperDropdown.not(this).removeClass("active"); + } + + optionsList.on("click", function () { + var selectedOption = $(this); + var valueData = selectedOption.data("value"); + + dropdown.removeClass("active"); + dropdown.find(".selected-display").text(selectedOption.text()); + $("#sendSorting").val(valueData); + + optionsList.removeClass("active"); + selectedOption.addClass("active"); + }); + }); + + var defaultValue = $("#sendSorting").val(); + if (defaultValue) { + + let defaultItem = $(".dropdown").find(".item[value-data='" + defaultValue + "']"); + defaultItem.addClass("active"); + var selectedDisplay = wrapperDropdown.find(".selected-display"); + selectedDisplay.text(defaultItem.text()); + } +}); + +$('.dropdown-IsTimeRequest .item').on("click", function () { + let dataVal = $(this).attr("value-data-normal"); + $('#IsTimeRequest').val(dataVal); +}); + +$('.dropdown-IsCanceled .item').on("click", function () { + let dataVal = $(this).attr("value-data-normal"); + $('#IsCanceled').val(dataVal); +}); + +$('.dropdown-IsCancelRequest .item').on("click", function () { + let dataVal = $(this).attr("value-data-normal"); + $('#IsCancelRequest').val(dataVal); +}); + +$('.dropdown-TimeRequestAccepted .item').on("click", function () { + let dataVal = $(this).attr("value-data-normal"); + $('#TimeRequestAccepted').val(dataVal); +}); + +$('.dropdown-IsDone .item').on("click", function () { + let dataVal = $(this).attr("value-data-normal"); + $('#IsDone').val(dataVal); +}); + +$('.dropdown-IsDoneRequest .item').on("click", function () { + let dataVal = $(this).attr("value-data-normal"); + $('#IsDoneRequest').val(dataVal); +}); + + +var sendDropdownNormal = $("#sendSorting").val(); +if (sendDropdownNormal) { + let itemDropdownNormal = $(".dropdown-normal").find(".item[value-data-normal='" + sendDropdownNormal + "']"); + itemDropdownNormal.addClass("active"); + var selectedNormalDisplay = $(".wrapper-dropdown-normal").find(".selected-display"); + selectedNormalDisplay.text(itemDropdownNormal.text()); +} + +var sendDropdownYear = $("#sendDropdownYear").val(); +if (sendDropdownYear) { + let itemDropdownYear = $(".dropdown-year").find(".item[value-data-year='" + sendDropdownYear + "']"); + itemDropdownYear.addClass("active"); + var selectedYearDisplay = $(".wrapper-dropdown-year").find(".selected-display"); + selectedYearDisplay.text(itemDropdownYear.text()); +} + +var sendDropdownMonth = $("#sendDropdownMonth").val(); +if (sendDropdownMonth) { + let itemDropdownMonth = $(".dropdown-month").find(".item[value-data-month='" + sendDropdownMonth + "']"); + itemDropdownMonth.addClass("active"); + var selectedMonthDisplay = $(".wrapper-dropdown-month").find(".selected-display"); + selectedMonthDisplay.text(itemDropdownMonth.text()); +} + +// check if anything else ofther than the dropdown is clicked +window.addEventListener("click", function (e) { + if (e.target.closest(".wrapper-dropdown") === null) { + closeAllDropdowns(); + } +}); + +// close all the dropdowns +function closeAllDropdowns() { + const selectedAll = document.querySelectorAll(".wrapper-dropdown"); + selectedAll.forEach((selected) => { + const optionsContainer = selected.children[2]; + let arrow = selected.children[1]; + + handleDropdown(selected, arrow, false); + }); +} + +// open all the dropdowns +function handleDropdown(dropdown, arrow, open) { + if (open) { + arrow.classList.add("rotated"); + dropdown.classList.add("active"); + } else { + arrow.classList.remove("rotated"); + dropdown.classList.remove("active"); + } +} +// *************************** مربوط به جستجو در دسکتاپ ******************************** + + + +//******************** فیلتر کردن برای جستجو ******************** +$(document).on('click', '.btn-search-click', function () { + $('#filterRemove').show(); + + var filterEmployeeId = $('#AccountId').val(); + var filterStart = $('#StartDate').val().trim(); + var filterEnd = $('#EndDate').val().trim(); + var filterIsDone = $('#IsDone').val().trim(); + + if (filterEmployeeId != 0 || filterStart != '' || filterEnd != '' || filterIsDone != '') { + $('.btn-clear-filter').removeClass('disable'); + } else { + $('.btn-clear-filter').addClass('disable'); + } +}); +$(document).on('click', '.btn-clear-filter', function () { + $(this).hide(); + var filterEmployeeId = $('#AccountId').val(); + var filterStart = $('#StartDate').val().trim(); + var filterEnd = $('#EndDate').val().trim(); + var filterIsDone = $('#IsDone').val().trim(); + + if (filterEmployeeId != 0 || filterStart != '' || filterEnd != '' || filterIsDone != '') { + $('.btn-clear-filter').removeClass('disable'); + } else { + $('.btn-clear-filter').addClass('disable'); + } +}); +//******************** فیلتر کردن برای جستجو ******************** + + + + + + + + + + +//Edit Task +function EditTask(id) { + var ID = Number(id); + + $(".modal-xl-taskTime").addClass('modal-xxxl'); + + var goTo = `#showmodal=/AdminNew/Company/Task/Index?taskId=${ID}&handler=EditTask`; + window.location.href = goTo; +} + + + +function removeConfirm(id) { + swal({ + title: "آیا از حذف این وظیفه اطمینان دارید؟", + text: "", + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText: "بله", + cancelButtonText: "خیر", + closeOnConfirm: true, + closeOnCancel: true + }, function (isConfirm) { + if (isConfirm) { + remove(id); + } + }); +} + +function remove(id) { + var ID = Number(id); + + $.ajax({ + async: false, + dataType: 'json', + type: 'POST', + url: `${removeAjax}`, + headers: { "RequestVerificationToken": `${antiForgeryToken}` }, + data: { taskId: ID }, + success: function (response) { + if (response.isSuccess) { + $('.alert-success-msg').show(); + $('.alert-success-msg p').text(response.message); + setTimeout(function () { + $('.alert-success-msg').hide(); + $('.alert-success-msg p').text(''); + window.location.reload(); + }, 1000); + } else { + $('.alert-msg').show(); + $('.alert-msg p').text(response.message); + setTimeout(function () { + $('.alert-msg').hide(); + $('.alert-msg p').text(''); + }, 3500); + } + }, + error: function (err) { + console.log(err); + } + }); +} + + +function Operation(id, type) { + var task_ID = Number(id); + var goTo = `#showmodal=/AdminNew/Company/Task/Index?taskId=${task_ID}&type=${type}&handler=AssignTo`; + window.location.href = goTo; +} + + +function OperationRequest(id, type) { + var task_ID = Number(id); + var goTo = `#showmodal=/AdminNew/Company/Task/Index?taskId=${task_ID}&type=${type}&handler=OperationRequestTask`; + window.location.href = goTo; +} + +function Detail(id) { + var task_ID = Number(id); + var goTo = `#showmodal=/AdminNew/Company/Task/Index?taskId=${task_ID}&handler=DetailsTask`; + window.location.href = goTo; +} + + + + + +//************************************ برای مشاهده زمان و ساعت **********************************/ +$(".date").mask("0000/00/00"); +$(".date").keyup(function () { + let value = $(this).val(); + let lengthValue = value.length; + if (lengthValue == 10) { + if (!dateValidcheck(this)) { + $(this).addClass("errored"); + } else { + $(this).removeClass("errored"); + } + } else if (lengthValue == 0) { + $(this).removeClass("errored"); + } +}); + +function dateValidcheck(inputField1) { + console.log(inputField1); + let persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g], + arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g], + fixNumbers = function (str) { + if (typeof str === 'string') { + for (var i = 0; i < 10; i++) { + str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i); + } + } + return str; + }; + let getdate = inputField1.value; + + let m1, m2; + let y1, y2, y3, y4; + let d1, d2; + let s1, s2; + for (var i = 0; i < getdate.length; i++) { + if (i === 0) { + y1 = fixNumbers(getdate[i]); + } + if (i === 1) { + y2 = fixNumbers(getdate[i]); + } + if (i === 2) { + y3 = fixNumbers(getdate[i]); + } + if (i === 3) { + y4 = fixNumbers(getdate[i]); + } + if (i === 4) { + s1 = fixNumbers(getdate[i]); + } + if (i === 5) { + m1 = fixNumbers(getdate[i]); + } + if (i === 6) { + m2 = fixNumbers(getdate[i]); + } + if (i === 7) { + s2 = fixNumbers(getdate[i]); + } + if (i === 8) { + d1 = fixNumbers(getdate[i]); + } + if (i === 9) { + d2 = fixNumbers(getdate[i]); + } + + } + let yRes = y1 + y2 + y3 + y4; + let year = parseInt(yRes); + let mRes = m1 + m2; + let month = parseInt(mRes); + let dRes = d1 + d2; + let day = parseInt(dRes); + let fixResult = yRes + s1 + mRes + s2 + dRes; + let test1 = checkEnValid(inputField1.value); + + let isValid = /^([1][3-4][0-9][0-9][/])([0][1-9]|[1][0-2])([/])([0][1-9]|[1-2][0-9]|[3][0-1])$/.test(fixResult); + + + if (isValid && test1) { + // inputField1.style.backgroundColor = '#a6e9a6'; + start1valid = true; + + + } else { + + if (inputField1.value != "") { + // inputField1.style.backgroundColor = '#f94c4c'; + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا تاریخ را بصورت صحیح وارد کنید"); + start1valid = false; + } + + + } + return start1valid; + +} + +function checkEnValid(fixDate1) { + + let persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g], + arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g], + fixNumbers = function (str) { + if (typeof str === 'string') { + for (var i = 0; i < 10; i++) { + str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i); + } + } + return str; + }; + let getdate = fixDate1; + + let m1, m2; + let y1, y2, y3, y4; + let d1, d2; + for (let i = 0; i < getdate.length; i++) { + if (i === 0) { + y1 = fixNumbers(getdate[i]); + } + if (i === 1) { + y2 = fixNumbers(getdate[i]); + } + if (i === 2) { + y3 = fixNumbers(getdate[i]); + } + if (i === 3) { + y4 = fixNumbers(getdate[i]); + } + if (i === 5) { + m1 = fixNumbers(getdate[i]); + } + if (i === 6) { + m2 = fixNumbers(getdate[i]); + } + if (i === 8) { + d1 = fixNumbers(getdate[i]); + } + if (i === 9) { + d2 = fixNumbers(getdate[i]); + } + } + let yRes = y1 + y2 + y3 + y4; + let year = parseInt(yRes); + let mRes = m1 + m2; + let month = parseInt(mRes); + let dRes = d1 + d2; + let day = parseInt(dRes); + let kabiseh = false; + if (month <= 6 && day > 31) { + return false; + } else if (month > 6 && month < 12 && day > 30) { + return false; + } else if (month === 12) { + + switch (year) { + case 1346: + kabiseh = true; + break; + case 1350: + kabiseh = true; + break; + case 1354: + kabiseh = true; + break; + case 1358: + kabiseh = true; + break; + case 1362: + kabiseh = true; + break; + case 1366: + kabiseh = true; + break; + case 1370: + kabiseh = true; + break; + case 1375: + kabiseh = true; + break; + case 1379: + kabiseh = true; + break; + case 1383: + kabiseh = true; + break; + case 1387: + kabiseh = true; + break; + case 1391: + kabiseh = true; + break; + case 1395: + kabiseh = true; + break; + case 1399: + kabiseh = true; + break; + case 1403: + kabiseh = true; + break; + case 1408: + kabiseh = true; + break; + case 1412: + kabiseh = true; + break; + case 1416: + kabiseh = true; + break; + case 1420: + kabiseh = true; + break; + case 1424: + kabiseh = true; + break; + case 1428: + kabiseh = true; + break; + case 1432: + kabiseh = true; + break; + case 1436: + kabiseh = true; + break; + case 1441: + kabiseh = true; + break; + case 1445: + kabiseh = true; + break; + default: + kabiseh = false; + + } + if (kabiseh == true && day > 30) { + return false; + } else if (kabiseh == false && day > 29) { + return false; + } else { + return true; + } + } else { + return true; + } +} +//************************************ برای مشاهده زمان و ساعت **********************************/ + + + + + + + + +//************************************ برای مشاهده پرسنل **********************************/ +$(document).ready(function () { + $(".select2Option").select2({ + language: "fa", + dir: "rtl", + }); + + function formatSelection(val) { + return val.id; + } + + $($('#AccountId').val()).select2({ + formatSelection: formatSelection, + width: 300 + }); + + var employeeIdSelected = $('#EmployeeId').val(); + $.ajax({ + url: `${employeeListAjax}`, + type: 'GET', + success: function (response) { + var employees = response.result; + + var employeeOptionsHtml = ``; + employees.forEach(function (employee) { + employeeOptionsHtml += ``; + }); + $('#AccountId').html(employeeOptionsHtml); + }, + error: function (xhr, status, error) { + console.error(xhr.responseText); + } + }); + + + $('#AccountId').change(function () { + if ($('#AccountId').val() != '') { + var employeeId = $('#AccountId').val(); + $("#EmployeeIdSearch").val(employeeId); + } + }); +}); +//************************************ برای مشاهده پرسنل **********************************/ + diff --git a/ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/OperationModal.js b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/OperationModal.js new file mode 100644 index 00000000..dfc98f87 --- /dev/null +++ b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/OperationModal.js @@ -0,0 +1,334 @@ + + $(document).ready(function () { + $('.loading').hide(); + + $('.select2Member').select2({ + placeholder: { + id: '-1', // the value of the option + text: "انتخاب اعضاء ..." + } + }); + + $('#save').on('click', function () { + if ($('.errored').length < 1) { + $('#saveFinaly').click(); + } else { + $('.alert-msg').show(); + $('.alert-msg p').text('لطفا خطاها را برطرف کنید.'); + setTimeout(function () { + $('.alert-msg').hide(); + $('.alert-msg p').text(''); + }, 3500); + } + }); + + + updateDateInput(0); + + $(document).on('click', '#today', function () { + updateDateInput(0); + $("#today").prop('checked', true); + }); + + $(document).on('click', '#tommorow', function () { + updateDateInput(1); + $("#tommorow").prop('checked', true); + }); + + $(document).on('click', '#two-day-later', function () { + updateDateInput(2); + $("#two-day-later").prop('checked', true); + }); + + + $('.select2Member').select2({ + placeholder: { + id: '-1', // the value of the option + text: "انتخاب اعضاء ..." + } + }); + + + $(".date").mask("0000/00/00"); + $('.date').on('input', + function () { + let startDate = this.value; + if (startDate.length == 10) { + let submitcheck = dateValidcheck(this); + if (submitcheck) { + + $(this).removeClass('errored'); + //if ($('#EndTaskDate').val() != '') { + //computeDays(); + //} + + + } else { + $(this).addClass('errored'); + + } + + } else { + $(this).addClass('errored'); + } + }); + + function dateValidcheck(inputField1) { + + let persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g], + arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g], + fixNumbers = function (str) { + if (typeof str === 'string') { + for (var i = 0; i < 10; i++) { + str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i); + } + } + return str; + }; + let getdate = inputField1.value; + + let m1, m2; + let y1, y2, y3, y4; + let d1, d2; + let s1, s2; + for (var i = 0; i < getdate.length; i++) { + if (i === 0) { + y1 = fixNumbers(getdate[i]); + } + if (i === 1) { + y2 = fixNumbers(getdate[i]); + } + if (i === 2) { + y3 = fixNumbers(getdate[i]); + } + if (i === 3) { + y4 = fixNumbers(getdate[i]); + } + if (i === 4) { + s1 = fixNumbers(getdate[i]); + } + if (i === 5) { + m1 = fixNumbers(getdate[i]); + } + if (i === 6) { + m2 = fixNumbers(getdate[i]); + } + if (i === 7) { + s2 = fixNumbers(getdate[i]); + } + if (i === 8) { + d1 = fixNumbers(getdate[i]); + } + if (i === 9) { + d2 = fixNumbers(getdate[i]); + } + + } + let yRes = y1 + y2 + y3 + y4; + let year = parseInt(yRes); + let mRes = m1 + m2; + let month = parseInt(mRes); + let dRes = d1 + d2; + let day = parseInt(dRes); + let fixResult = yRes + s1 + mRes + s2 + dRes; + let test1 = checkEnValid(inputField1.value); + + let isValid = /^([1][3-4][0-9][0-9][/])([0][1-9]|[1][0-2])([/])([0][1-9]|[1-2][0-9]|[3][0-1])$/.test(fixResult); + + + if (isValid && test1) { + // inputField1.style.backgroundColor = '#a6e9a6'; + start1valid = true; + + + } else { + + if (inputField1.value != "") { + // inputField1.style.backgroundColor = '#f94c4c'; + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا تاریخ را بصورت صحیح وارد کنید"); + start1valid = false; + } + + + } + return start1valid; + + } + + function checkEnValid(fixDate1) { + + let persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g], + arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g], + fixNumbers = function (str) { + if (typeof str === 'string') { + for (var i = 0; i < 10; i++) { + str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i); + } + } + return str; + }; + let getdate = fixDate1; + + let m1, m2; + let y1, y2, y3, y4; + let d1, d2; + for (let i = 0; i < getdate.length; i++) { + if (i === 0) { + y1 = fixNumbers(getdate[i]); + } + if (i === 1) { + y2 = fixNumbers(getdate[i]); + } + if (i === 2) { + y3 = fixNumbers(getdate[i]); + } + if (i === 3) { + y4 = fixNumbers(getdate[i]); + } + if (i === 5) { + m1 = fixNumbers(getdate[i]); + } + if (i === 6) { + m2 = fixNumbers(getdate[i]); + } + if (i === 8) { + d1 = fixNumbers(getdate[i]); + } + if (i === 9) { + d2 = fixNumbers(getdate[i]); + } + } + let yRes = y1 + y2 + y3 + y4; + let year = parseInt(yRes); + let mRes = m1 + m2; + let month = parseInt(mRes); + let dRes = d1 + d2; + let day = parseInt(dRes); + let kabiseh = false; + if (month <= 6 && day > 31) { + return false; + } else if (month > 6 && month < 12 && day > 30) { + return false; + } else if (month === 12) { + + switch (year) { + case 1346: + kabiseh = true; + break; + case 1350: + kabiseh = true; + break; + case 1354: + kabiseh = true; + break; + case 1358: + kabiseh = true; + break; + case 1362: + kabiseh = true; + break; + case 1366: + kabiseh = true; + break; + case 1370: + kabiseh = true; + break; + case 1375: + kabiseh = true; + break; + case 1379: + kabiseh = true; + break; + case 1383: + kabiseh = true; + break; + case 1387: + kabiseh = true; + break; + case 1391: + kabiseh = true; + break; + case 1395: + kabiseh = true; + break; + case 1399: + kabiseh = true; + break; + case 1403: + kabiseh = true; + break; + case 1408: + kabiseh = true; + break; + case 1412: + kabiseh = true; + break; + case 1416: + kabiseh = true; + break; + case 1420: + kabiseh = true; + break; + case 1424: + kabiseh = true; + break; + case 1428: + kabiseh = true; + break; + case 1432: + kabiseh = true; + break; + case 1436: + kabiseh = true; + break; + case 1441: + kabiseh = true; + break; + case 1445: + kabiseh = true; + break; + default: + kabiseh = false; + + } + if (kabiseh == true && day > 30) { + return false; + } else if (kabiseh == false && day > 29) { + return false; + } else { + return true; + } + } else { + return true; + } + } + $('#EndTaskTime').on("keyup", + function () { + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test($(this).val()); + if (isValid) { + $(this).addClass("validTime"); + $(this).removeClass("invalidTime"); + // if ($('#EndTaskTime').val() != null) { + // computeDays(); + // } + } else { + $(this).removeClass("validTime"); + $(this).addClass("invalidTime"); + } + }); + + }); + + + $(document).on('keydown', '#EndTaskDate', function () { + $("input:radio").prop('checked', false); + }) + + function updateDateInput(daysToAdd) { + var today = new Date(); + today.setDate(today.getDate() + daysToAdd); + var jalaaliDate = jalaali.toJalaali(today); + var formattedDate = jalaaliDate.jy + '/' + (jalaaliDate.jm < 10 ? '0' + jalaaliDate.jm : jalaaliDate.jm) + '/' + (jalaaliDate.jd < 10 ? '0' + jalaaliDate.jd : jalaaliDate.jd); + $('#EndTaskDate').val(formattedDate); + } + diff --git a/ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/OperationRequestModal.js b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/OperationRequestModal.js new file mode 100644 index 00000000..a9b327a9 --- /dev/null +++ b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/OperationRequestModal.js @@ -0,0 +1,469 @@ + +$(document).ready(function () { + $('.loading').hide(); + + + // --------------------------------------------- درخواست مهلت --------------------------------------------- + $('#checkActiveDate').on('change', function () { + if ($('#checkActiveDate').is(':checked')) { + $('#inputChangeDate').removeClass('disable'); + $('.btn-change-date').removeClass('disable'); + $('#inputChangeDate').prop('disabled', false); + $('#inputChangeDate').focus(); + $('.btn-change-date').prop('disabled', false); + } else { + $('#inputChangeDate').val(''); + $('#inputChangeDate').addClass('disable'); + $('.btn-change-date').addClass('disable'); + $('#inputChangeDate').prop('disabled', true); + $('.btn-change-date').prop('disabled', true); + } + }); + + $('#saveChangeTimeRequest').on('click', function () { + var TaskId = $("#TaskId").val(); + var inputChangeDate = $("#inputChangeDate").val().trim(); + + if (inputChangeDate.length == 10 && inputChangeDate != '') { + console.log(inputChangeDate); + + $.ajax({ + async: false, + dataType: 'json', + type: 'POST', + url: changeTime, + headers: { "RequestVerificationToken": AntiForgeryToken }, + data: { taskId: Number(TaskId), time: inputChangeDate }, + success: function (response) { + if (response.isSuccess) { + $('#MainModal').modal('hide'); + $('.hideDivRequest' + TaskId).remove(); + loadMoreRequest(); + } + }, + error: function (err) { + console.log(err); + } + }); + } else { + $('.alert-msg').show(); + $('.alert-msg p').text("لطفا تاریخ را وارد نمائید."); + $("#inputChangeDate").addClass('errored'); + setTimeout(function () { + $('.alert-msg').hide(); + $('.alert-msg p').text(''); + $("#inputChangeDate").removeClass('errored'); + }, 3500); + } + }); + + + + $('#saveAcceptTimeRequest').on('click', function () { + var TaskId = $("#TaskId").val(); + + $.ajax({ + async: false, + dataType: 'json', + type: 'POST', + url: AcceptTimeRequest, + headers: { "RequestVerificationToken": AntiForgeryToken }, + data: { id: Number(TaskId) }, + success: function (response) { + if (response.isSuccess) { + $('#MainModal').modal('hide'); + $('.hideDivRequest' + TaskId).remove(); + loadMoreRequest(); + } + }, + error: function (err) { + console.log(err); + } + }); + }); + + $('#saveRejectTimeRequest').on('click', function () { + var TaskId = $("#TaskId").val(); + + $.ajax({ + async: false, + dataType: 'json', + type: 'POST', + url: RejectTimeRequest, + headers: { "RequestVerificationToken": AntiForgeryToken }, + data: { id: Number(TaskId) }, + success: function (response) { + if (response.isSuccess) { + $('#MainModal').modal('hide'); + $('.hideDivRequest' + TaskId).remove(); + loadMoreRequest(); + } + }, + error: function (err) { + console.log(err); + } + }); + }); + + + + $(".date").mask("0000/00/00"); + $(".date").keyup(function () { + let value = $(this).val(); + let lengthValue = value.length; + if (lengthValue == 10) { + if (!dateValidcheck(this)) { + $(this).addClass("errored"); + } else { + $(this).removeClass("errored"); + } + } else if (lengthValue == 0) { + $(this).removeClass("errored"); + } + }); + + function dateValidcheck(inputField1) { + + let persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g], + arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g], + fixNumbers = function (str) { + if (typeof str === 'string') { + for (var i = 0; i < 10; i++) { + str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i); + } + } + return str; + }; + let getdate = inputField1.value; + + let m1, m2; + let y1, y2, y3, y4; + let d1, d2; + let s1, s2; + for (var i = 0; i < getdate.length; i++) { + if (i === 0) { + y1 = fixNumbers(getdate[i]); + } + if (i === 1) { + y2 = fixNumbers(getdate[i]); + } + if (i === 2) { + y3 = fixNumbers(getdate[i]); + } + if (i === 3) { + y4 = fixNumbers(getdate[i]); + } + if (i === 4) { + s1 = fixNumbers(getdate[i]); + } + if (i === 5) { + m1 = fixNumbers(getdate[i]); + } + if (i === 6) { + m2 = fixNumbers(getdate[i]); + } + if (i === 7) { + s2 = fixNumbers(getdate[i]); + } + if (i === 8) { + d1 = fixNumbers(getdate[i]); + } + if (i === 9) { + d2 = fixNumbers(getdate[i]); + } + + } + let yRes = y1 + y2 + y3 + y4; + let year = parseInt(yRes); + let mRes = m1 + m2; + let month = parseInt(mRes); + let dRes = d1 + d2; + let day = parseInt(dRes); + let fixResult = yRes + s1 + mRes + s2 + dRes; + let test1 = checkEnValid(inputField1.value); + + let isValid = /^([1][3-4][0-9][0-9][/])([0][1-9]|[1][0-2])([/])([0][1-9]|[1-2][0-9]|[3][0-1])$/.test(fixResult); + + + if (isValid && test1) { + // inputField1.style.backgroundColor = '#a6e9a6'; + start1valid = true; + + + } else { + + if (inputField1.value != "") { + // inputField1.style.backgroundColor = '#f94c4c'; + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا تاریخ را بصورت صحیح وارد کنید"); + start1valid = false; + } + + + } + return start1valid; + + } + + function checkEnValid(fixDate1) { + + let persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g], + arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g], + fixNumbers = function (str) { + if (typeof str === 'string') { + for (var i = 0; i < 10; i++) { + str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i); + } + } + return str; + }; + let getdate = fixDate1; + + let m1, m2; + let y1, y2, y3, y4; + let d1, d2; + for (let i = 0; i < getdate.length; i++) { + if (i === 0) { + y1 = fixNumbers(getdate[i]); + } + if (i === 1) { + y2 = fixNumbers(getdate[i]); + } + if (i === 2) { + y3 = fixNumbers(getdate[i]); + } + if (i === 3) { + y4 = fixNumbers(getdate[i]); + } + if (i === 5) { + m1 = fixNumbers(getdate[i]); + } + if (i === 6) { + m2 = fixNumbers(getdate[i]); + } + if (i === 8) { + d1 = fixNumbers(getdate[i]); + } + if (i === 9) { + d2 = fixNumbers(getdate[i]); + } + } + let yRes = y1 + y2 + y3 + y4; + let year = parseInt(yRes); + let mRes = m1 + m2; + let month = parseInt(mRes); + let dRes = d1 + d2; + let day = parseInt(dRes); + let kabiseh = false; + if (month <= 6 && day > 31) { + return false; + } else if (month > 6 && month < 12 && day > 30) { + return false; + } else if (month === 12) { + + switch (year) { + case 1346: + kabiseh = true; + break; + case 1350: + kabiseh = true; + break; + case 1354: + kabiseh = true; + break; + case 1358: + kabiseh = true; + break; + case 1362: + kabiseh = true; + break; + case 1366: + kabiseh = true; + break; + case 1370: + kabiseh = true; + break; + case 1375: + kabiseh = true; + break; + case 1379: + kabiseh = true; + break; + case 1383: + kabiseh = true; + break; + case 1387: + kabiseh = true; + break; + case 1391: + kabiseh = true; + break; + case 1395: + kabiseh = true; + break; + case 1399: + kabiseh = true; + break; + case 1403: + kabiseh = true; + break; + case 1408: + kabiseh = true; + break; + case 1412: + kabiseh = true; + break; + case 1416: + kabiseh = true; + break; + case 1420: + kabiseh = true; + break; + case 1424: + kabiseh = true; + break; + case 1428: + kabiseh = true; + break; + case 1432: + kabiseh = true; + break; + case 1436: + kabiseh = true; + break; + case 1441: + kabiseh = true; + break; + case 1445: + kabiseh = true; + break; + default: + kabiseh = false; + + } + if (kabiseh == true && day > 30) { + return false; + } else if (kabiseh == false && day > 29) { + return false; + } else { + return true; + } + } else { + return true; + } + } + $('.date').on("keyup", function () { + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test($(this).val()); + if (isValid) { + $(this).addClass("validTime"); + $(this).removeClass("invalidTime"); + // if ($('#EndTaskTime').val() != null) { + // computeDays(); + // } + } else { + $(this).removeClass("validTime"); + $(this).addClass("invalidTime"); + } + }); + // --------------------------------------------- درخواست مهلت --------------------------------------------- + + // --------------------------------------------- درخواست انصراف وظیفه --------------------------------------------- + $('#saveRejectCancelRequest').on('click', function () { + var TaskId = $("#TaskId").val(); + + $.ajax({ + async: false, + dataType: 'json', + type: 'POST', + url: RejectCancel, + headers: { "RequestVerificationToken": AntiForgeryToken }, + data: { id: Number(TaskId) }, + success: function (response) { + if (response.isSuccess) { + $('#MainModal').modal('hide'); + $('.hideDivRequest' + TaskId).remove(); + loadMoreRequest(); + } + }, + error: function (err) { + console.log(err); + } + }); + }); + + $('#saveAcceptCancelRequest').on('click', function () { + var TaskId = $("#TaskId").val(); + + $.ajax({ + async: false, + dataType: 'json', + type: 'POST', + url: AcceptCancel, + headers: { "RequestVerificationToken": AntiForgeryToken }, + data: { id: Number(TaskId) }, + success: function (response) { + if (response.isSuccess) { + $('#MainModal').modal('hide'); + $('.hideDivRequest' + TaskId).remove(); + loadMoreRequest(); + } + }, + error: function (err) { + console.log(err); + } + }); + }); + // --------------------------------------------- درخواست انصراف وظیفه --------------------------------------------- + + + + // --------------------------------------------- درخواست تائید وظیفه --------------------------------------------- + $('#saveRejectCompleteRequest').on('click', function () { + var TaskId = $("#TaskId").val(); + + $.ajax({ + async: false, + dataType: 'json', + type: 'POST', + url: RejectComplete, + headers: { "RequestVerificationToken": AntiForgeryToken }, + data: { id: Number(TaskId) }, + success: function (response) { + if (response.isSuccess) { + $('#MainModal').modal('hide'); + $('.hideDivRequest' + TaskId).remove(); + loadMoreRequest(); + } + }, + error: function (err) { + console.log(err); + } + }); + }); + + $('#saveAcceptCompleteRequest').on('click', function () { + var TaskId = $("#TaskId").val(); + + $.ajax({ + async: false, + dataType: 'json', + type: 'POST', + url: AcceptComplete, + headers: { "RequestVerificationToken": AntiForgeryToken }, + data: { id: Number(TaskId) }, + success: function (response) { + if (response.isSuccess) { + $('#MainModal').modal('hide'); + $('.hideDivRequest' + TaskId).remove(); + loadMoreRequest(); + } + }, + error: function (err) { + console.log(err); + } + }); + }); + // --------------------------------------------- درخواست تائید وظیفه --------------------------------------------- + +}); + + diff --git a/ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/create.js b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/create.js new file mode 100644 index 00000000..316a962c --- /dev/null +++ b/ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/create.js @@ -0,0 +1,1079 @@ + + + +$(document).on('keydown', '#EndTaskDate', function () { + $("input:radio").prop('checked', false); +}); + +function updateDateInput(daysToAdd) { + var today = new Date(); + today.setDate(today.getDate() + daysToAdd); + var jalaaliDate = jalaali.toJalaali(today); + var formattedDate = jalaaliDate.jy + '/' + (jalaaliDate.jm < 10 ? '0' + jalaaliDate.jm : jalaaliDate.jm) + '/' + (jalaaliDate.jd < 10 ? '0' + jalaaliDate.jd : jalaaliDate.jd); + $('#EndTaskDate').val(formattedDate); + //computeDays(); +} + + +$(document).ready(function () { + + updateDateInput(0); + + $(document).on('click', '#today', function () { + updateDateInput(0); + $("#today").prop('checked', true); + }); + + $(document).on('click', '#tommorow', function () { + updateDateInput(1); + $("#tommorow").prop('checked', true); + }); + + $(document).on('click', '#two-day-later', function () { + updateDateInput(2); + $("#two-day-later").prop('checked', true); + }); + + + $('.select2Member').select2({ + placeholder: { + id: '-1', // the value of the option + text: "انتخاب اعضاء ..." + } + }); + + $('.select2Group').select2({ + placeholder: { + id: '-1', // the value of the option + text: "انتخاب گروهی ..." + } + }); + + + $(document).on('click', '#memberSelect', function () { + $('#select2MemberList').show(); + $('#select2GroupList').hide(); + if ($('#memberSelect').is(':checked')) { + $('#Command_PositionId').val(null).trigger('change'); + } + + }); + + $(document).on('click', '#groupSelect', function () { + $('#select2MemberList').hide(); + $('#select2GroupList').show(); + if ($('#groupSelect').is(':checked')) { + $('#Command_ReceiverId').val(null).trigger('change'); + } + }); + + + // let bodyArray = [ + // { 'ReceiverId': $('#CreateTask.ReceiverId').val() }, + // { 'ContractingPartyName': $('#CreateTask.ContractingPartyName').val() }, + // { 'Title': $('#CreateTask.Title').val() }, + // { 'EndTaskDate': $('#CreateTask.EndTaskDate').val() }, + // { 'EndTaskTime': $('#CreateTask.EndTaskTime').val() }, + // { 'Description': $('#CreateTask.Description').val() }, + // ]; + + // var body = new FormData(); + // body.append('ReceiverId', $('#CreateTask.ReceiverId').val()); + // body.append('ContractingPartyName', $('#CreateTask.ContractingPartyName').val()); + // body.append('Title', $('#CreateTask.Title').val()); + // body.append('CreateTask.EndTaskDate', $('#CreateTask.EndTaskDate').val()); + // body.append('CreateTask.EndTaskTime', $('#CreateTask.EndTaskTime').val()); + // body.append('CreateTask.Description', $('#CreateTask.Description').val()); + + // if (files) { + // body.append('CreateTask.Picture', files); + // } + + // var command = {}; + // command.ReceiverId = $('#ReceiverId').val(); + // command.ContractingPartyName = $('#partyNameSearch').val(); + // command.Title = $('#title').val(); + // command.EndTaskDate = $('#EndTaskDate').val(); + // command.EndTaskTime = $('#EndTaskTime').val(); + // command.Description = $('#Command_Description').val(); + + $('#save').on('click', function (e) { + e.preventDefault(); + + var member = $('.select2Member').select2('data'); + var group = $('.select2Group').select2('data'); + + if ($('#memberSelect').is(':checked')) { + if (member.length == 0) { + $('#select2MemberList').addClass('errored'); + $('.alert-msg').show(); + $('.alert-msg p').text('لطفا انتخاب اعضاء را مشخص نمائید.'); + setTimeout(function () { + $('.alert-msg').hide(); + $('.alert-msg p').text(''); + $('#select2MemberList').removeClass('errored'); + }, 3500); + return; + } + } + + if ($('#groupSelect').is(':checked')) { + if (group.length == 0) { + $('#select2GroupList').addClass('errored'); + $('.alert-msg').show(); + $('.alert-msg p').text('لطفا انتخاب گروهی را مشخص نمائید.'); + setTimeout(function () { + $('.alert-msg').hide(); + $('.alert-msg p').text(''); + $('#select2GroupList').removeClass('errored'); + }, 3500); + return; + } + } + + + var textArea = $('#Command_Description'); + var content = textArea.val(); + content = content.replace(/\n/g, '
    '); + textArea.val(content); + + // var fileUpload = $("#Command_Picture1").get(0).files; + // var files = fileUpload.files; + // var fileData = new FormData(); + + + var data = new FormData(this.form); + + $.ajax({ + async: false, + dataType: 'json', + type: 'POST', + processData: false, + contentType: false, + url: createTaskSaveAjax, + headers: { "RequestVerificationToken": antiForgeryToken }, + data: data, + success: function (response) { + console.log(response); + if (response.isSuccedded) { + $('.alert-success-msg').show(); + $('.alert-success-msg p').text(response.message); + setTimeout(function () { + $('.alert-success-msg').hide(); + $('.alert-success-msg p').text(''); + window.location.replace('/AdminNew/Company/Task') + }, 1500); + + } else { + + if (response.message == 'لطفا عنوان وظیفه خود ار وارد کنید') { + $('#Command_Title').addClass('errored'); + $('.alert-msg p').text('لطفا انتخاب گروهی را مشخص نمائید.'); + setTimeout(function () { + $('#Command_Title').removeClass('errored'); + }, 3500); + } + + if (response.message == 'لطفا طرف حساب خودرا وارد کنید') { + $('#partyNameSearch').addClass('errored'); + $('.alert-msg p').text('لطفا انتخاب گروهی را مشخص نمائید.'); + setTimeout(function () { + $('#partyNameSearch').removeClass('errored'); + }, 3500); + } + + if (response.message == 'لطفا تاریخ انجام وظیفه را وارد کنید') { + $('#Command_EndTaskDate').addClass('errored'); + $('.alert-msg p').text('لطفا انتخاب گروهی را مشخص نمائید.'); + setTimeout(function () { + $('#Command_EndTaskDate').removeClass('errored'); + }, 3500); + } + + + $('.alert-msg').show(); + $('.alert-msg p').text(response.message); + setTimeout(function () { + $('.alert-msg').hide(); + $('.alert-msg p').text(''); + }, 3500); + } + }, + error: function (err) { + console.log(err); + } + }); + + // if ($('.errored').length < 1) { + // console.log('hello') + // $('#saveFinaly').click(); + // } else { + // $('.alert-msg').show(); + // $('.alert-msg p').text('لطفا خطاها را برطرف کنید.'); + // setTimeout(function () { + // $('.alert-msg').hide(); + // $('.alert-msg p').text(''); + // }, 3500); + // } + }); + + + $(".date").mask("0000/00/00"); + $(".date").keyup(function () { + let value = $(this).val(); + let lengthValue = value.length; + if (lengthValue == 10) { + if (!dateValidcheck(this)) { + $(this).addClass("errored"); + } else { + $(this).removeClass("errored"); + } + } else if (lengthValue == 0) { + $(this).removeClass("errored"); + } + }); + + function dateValidcheck(inputField1) { + + let persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g], + arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g], + fixNumbers = function (str) { + if (typeof str === 'string') { + for (var i = 0; i < 10; i++) { + str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i); + } + } + return str; + }; + let getdate = inputField1.value; + + let m1, m2; + let y1, y2, y3, y4; + let d1, d2; + let s1, s2; + for (var i = 0; i < getdate.length; i++) { + if (i === 0) { + y1 = fixNumbers(getdate[i]); + } + if (i === 1) { + y2 = fixNumbers(getdate[i]); + } + if (i === 2) { + y3 = fixNumbers(getdate[i]); + } + if (i === 3) { + y4 = fixNumbers(getdate[i]); + } + if (i === 4) { + s1 = fixNumbers(getdate[i]); + } + if (i === 5) { + m1 = fixNumbers(getdate[i]); + } + if (i === 6) { + m2 = fixNumbers(getdate[i]); + } + if (i === 7) { + s2 = fixNumbers(getdate[i]); + } + if (i === 8) { + d1 = fixNumbers(getdate[i]); + } + if (i === 9) { + d2 = fixNumbers(getdate[i]); + } + + } + let yRes = y1 + y2 + y3 + y4; + let year = parseInt(yRes); + let mRes = m1 + m2; + let month = parseInt(mRes); + let dRes = d1 + d2; + let day = parseInt(dRes); + let fixResult = yRes + s1 + mRes + s2 + dRes; + let test1 = checkEnValid(inputField1.value); + + let isValid = /^([1][3-4][0-9][0-9][/])([0][1-9]|[1][0-2])([/])([0][1-9]|[1-2][0-9]|[3][0-1])$/.test(fixResult); + + + if (isValid && test1) { + // inputField1.style.backgroundColor = '#a6e9a6'; + start1valid = true; + + + } else { + + if (inputField1.value != "") { + // inputField1.style.backgroundColor = '#f94c4c'; + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا تاریخ را بصورت صحیح وارد کنید"); + start1valid = false; + } + + + } + return start1valid; + + } + + function checkEnValid(fixDate1) { + + let persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g], + arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g], + fixNumbers = function (str) { + if (typeof str === 'string') { + for (var i = 0; i < 10; i++) { + str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i); + } + } + return str; + }; + let getdate = fixDate1; + + let m1, m2; + let y1, y2, y3, y4; + let d1, d2; + for (let i = 0; i < getdate.length; i++) { + if (i === 0) { + y1 = fixNumbers(getdate[i]); + } + if (i === 1) { + y2 = fixNumbers(getdate[i]); + } + if (i === 2) { + y3 = fixNumbers(getdate[i]); + } + if (i === 3) { + y4 = fixNumbers(getdate[i]); + } + if (i === 5) { + m1 = fixNumbers(getdate[i]); + } + if (i === 6) { + m2 = fixNumbers(getdate[i]); + } + if (i === 8) { + d1 = fixNumbers(getdate[i]); + } + if (i === 9) { + d2 = fixNumbers(getdate[i]); + } + } + let yRes = y1 + y2 + y3 + y4; + let year = parseInt(yRes); + let mRes = m1 + m2; + let month = parseInt(mRes); + let dRes = d1 + d2; + let day = parseInt(dRes); + let kabiseh = false; + if (month <= 6 && day > 31) { + return false; + } else if (month > 6 && month < 12 && day > 30) { + return false; + } else if (month === 12) { + + switch (year) { + case 1346: + kabiseh = true; + break; + case 1350: + kabiseh = true; + break; + case 1354: + kabiseh = true; + break; + case 1358: + kabiseh = true; + break; + case 1362: + kabiseh = true; + break; + case 1366: + kabiseh = true; + break; + case 1370: + kabiseh = true; + break; + case 1375: + kabiseh = true; + break; + case 1379: + kabiseh = true; + break; + case 1383: + kabiseh = true; + break; + case 1387: + kabiseh = true; + break; + case 1391: + kabiseh = true; + break; + case 1395: + kabiseh = true; + break; + case 1399: + kabiseh = true; + break; + case 1403: + kabiseh = true; + break; + case 1408: + kabiseh = true; + break; + case 1412: + kabiseh = true; + break; + case 1416: + kabiseh = true; + break; + case 1420: + kabiseh = true; + break; + case 1424: + kabiseh = true; + break; + case 1428: + kabiseh = true; + break; + case 1432: + kabiseh = true; + break; + case 1436: + kabiseh = true; + break; + case 1441: + kabiseh = true; + break; + case 1445: + kabiseh = true; + break; + default: + kabiseh = false; + + } + if (kabiseh == true && day > 30) { + return false; + } else if (kabiseh == false && day > 29) { + return false; + } else { + return true; + } + } else { + return true; + } + } + $('#EndTaskTime').on("keyup", + function () { + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test($(this).val()); + if (isValid) { + $(this).addClass("validTime"); + $(this).removeClass("invalidTime"); + // if ($('#EndTaskTime').val() != null) { + // computeDays(); + // } + } else { + $(this).removeClass("validTime"); + $(this).addClass("invalidTime"); + } + }); + +}); + +function remove(id) { + console.log('#Command_Document' + id); + $('#Command_Document' + id).val(''); + $('.inBox' + id).html(''); + $('.inBox' + id).addClass('empty'); +} + +$(document).ready(function () { + + // function addDeleteButton(box, id) { + // var deleteBtn = $('
    '); + // deleteBtn.click(function () { + // box.empty(); + // box.addClass('empty'); + // }); + // box.append(deleteBtn); + // } + + $(document).on('click', '#upload-doc', function (e) { + e.preventDefault() + let file1 = document.getElementById("Command_Document1"); + let file2 = document.getElementById("Command_Document2"); + let file3 = document.getElementById("Command_Document3"); + let file4 = document.getElementById("Command_Document4"); + let file5 = document.getElementById("Command_Document5"); + let file6 = document.getElementById("Command_Document6"); + + if (file1.files.length == 0) { + console.log('#Command_Document1 = ' + file1.files.length); + $('#Command_Document1').on('change', function () { + var fileInput1 = file1.files[0]; + if (fileInput1) { + console.log('repeat'); + var reader = new FileReader(); + reader.onload = function (e) { + var img1 = $('').attr('src', e.target.result); + var box1 = $('.inBox1'); + if (box1.length) { + box1.removeClass('empty'); + //addDeleteButton(box1, 1); + var deleteBtn1 = $('
    '); + $('.b1').remove(); + box1.append(img1); + box1.append(deleteBtn1); + } + } + reader.readAsDataURL(fileInput1); + } + }).click(); + return false; + } else if (file2.files.length == 0) { + console.log('#Command_Document2 = ' + file2.files.length); + $('#Command_Document2').on('change', function () { + var fileInput2 = file2.files[0]; + if (fileInput2) { + var reader = new FileReader(); + reader.onload = function (e) { + var img2 = $('').attr('src', e.target.result); + var box2 = $('.inBox2'); + if (box2.length) { + box2.removeClass('empty'); + //addDeleteButton(box2,2); + var deleteBtn2 = $('
    '); + $('.b2').remove(); + box2.append(img2); + box2.append(deleteBtn2); + } + } + reader.readAsDataURL(fileInput2); + } + }).click(); + return false; + } else if (file3.files.length == 0) { + console.log('#Command_Document3 = ' + file3.files.length); + $('#Command_Document3').on('change', function () { + var fileInput3 = file3.files[0]; + if (fileInput3) { + var reader = new FileReader(); + reader.onload = function (e) { + var img3 = $('').attr('src', e.target.result); + var box3 = $('.inBox3'); + if (box3.length) { + box3.removeClass('empty'); + //addDeleteButton(box3, 3); + var deleteBtn3 = $('
    '); + $('.b3').remove(); + box3.append(img3); + box3.append(deleteBtn3); + } + } + reader.readAsDataURL(fileInput3); + } + }).click(); + return false; + } else if (file4.files.length == 0) { + console.log('#Command_Document4 = ' + file4.files.length); + $('#Command_Document4').on('change', function () { + var fileInput4 = file4.files[0]; + if (fileInput4) { + var reader = new FileReader(); + reader.onload = function (e) { + var img4 = $('').attr('src', e.target.result); + var box4 = $('.inBox4'); + if (box4.length) { + box4.removeClass('empty'); + //addDeleteButton(box4, 4); + var deleteBtn4 = $('
    '); + $('.b4').remove(); + box4.append(img4); + box4.append(deleteBtn4); + } + } + reader.readAsDataURL(fileInput4); + } + }).click(); + return false; + } else if (file5.files.length == 0) { + console.log('#Command_Document5 = ' + file5.files.length); + $('#Command_Document5').on('change', function () { + var fileInput5 = file5.files[0]; + if (fileInput5) { + var reader = new FileReader(); + reader.onload = function (e) { + var img5 = $('').attr('src', e.target.result); + var box5 = $('.inBox5'); + if (box5.length) { + box5.removeClass('empty'); + //addDeleteButton(box5, 5); + var deleteBtn5 = $('
    '); + $('.b5').remove(); + box5.append(img5); + box5.append(deleteBtn5); + } + } + reader.readAsDataURL(fileInput5); + } + }).click(); + return false; + } else if (file6.files.length == 0) { + console.log('#Command_Document6 = ' + file6.files.length); + $('#Command_Document6').on('change', function () { + var fileInput6 = file6.files[0]; + if (fileInput6) { + var reader = new FileReader(); + reader.onload = function (e) { + var img6 = $('').attr('src', e.target.result); + var box6 = $('.inBox6'); + if (box6.length) { + box6.removeClass('empty'); + //addDeleteButton(box6, 6); + var deleteBtn6 = $('
    '); + $('.b6').remove(); + box6.append(img6); + box6.append(deleteBtn6); + } + } + reader.readAsDataURL(fileInput6); + } + }).click(); + return false; + } + + + + }); + + // $('#upload-img').click(function () { + // $('#Command_Picture1').on('change', function () { + // var file = this.files[0]; + // if (file) { + // var reader = new FileReader(); + // reader.onload = function (e) { + // // var input = $('').attr('value', e.target.result); + // var img = $('').attr('src', e.target.result); + // var box = $('#upload-container-img .upload-box.empty:first'); + // if (box.length) { + // box.removeClass('empty'); + // box.html(img); + // addDeleteButton(box); + // // box.append(input); + // } + // } + // reader.readAsDataURL(file); + // } + // }).click(); + // }); + + // $('#upload-voice').click(function () { + // $('').on('change', function () { + // var file = this.files[0]; + // if (file) { + // var reader = new FileReader(); + // reader.onload = function (e) { + // var audio = $('').attr('src', e.target.result); + // var box = $('#upload-container-voice .upload-box-voice.empty:first'); + // if (box.length) { + // box.removeClass('empty'); + // box.html(audio); + // addDeleteButton(box); + // } + // } + // reader.readAsDataURL(file); + // } + // }).click(); + // }); +}); + + + + +// صدا +var msg_box = document.getElementById('msg_box'), + button = document.getElementById('upload-voice'), + canvas = document.getElementById('canvas'), + lang = { + 'mic_error': 'خطا! به میکروفون دسترسی ندارد.', + 'press_to_start': 'برای ضبط صدا، پیام صوتی را کلیک نمائید', + 'recording': 'در حال ضبط پیام صوتی ...', + 'play': 'پخش', + 'stop': 'متوقف', + 'download': 'دانلود', + 'use_https': 'This application in not working over insecure connection. Try to use HTTPS' + }, + time; + +msg_box.innerHTML = lang.press_to_start; + +if (navigator.mediaDevices === undefined) { + navigator.mediaDevices = {}; +} + +if (navigator.mediaDevices.getUserMedia === undefined) { + navigator.mediaDevices.getUserMedia = function (constrains) { + var getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia + if (!getUserMedia) { + return Promise.reject(new Error('getUserMedia is not implemented in this browser')); + } + + return new Promise(function (resolve, reject) { + getUserMedia.call(navigator, constrains, resolve, reject); + }); + } +} + +if (navigator.mediaDevices.getUserMedia) { + var btn_status = 'inactive', + mediaRecorder, + chunks = [], + audio = new Audio(), + mediaStream, + audioSrc, + type = { + 'type': 'audio/ogg,codecs=opus' + }, + ctx, + analys, + blob; + + button.onclick = function () { + if (btn_status == 'inactive') { + start(); + } else if (btn_status == 'recording') { + stop(); + } + } + + function parseTime(sec) { + var h = parseInt(sec / 3600); + var m = parseInt(sec / 60); + var sec = sec - (h * 3600 + m * 60); + + h = h == 0 ? '' : h + ':'; + sec = sec < 10 ? '0' + sec : sec; + + return h + m + ':' + sec; + } + + function start() { + console.log('start') + navigator.mediaDevices.getUserMedia({ 'audio': true }).then(function (stream) { + mediaRecorder = new MediaRecorder(stream); + mediaRecorder.start(); + + button.classList.add('recording'); + btn_status = 'recording'; + + msg_box.innerHTML = lang.recording; + + if (navigator.vibrate) navigator.vibrate(150); + + time = Math.ceil(new Date().getTime() / 1000); + + mediaRecorder.ondataavailable = function (event) { + chunks.push(event.data); + } + + mediaRecorder.onstop = function () { + stream.getTracks().forEach(function (track) { track.stop() }); + + blob = new Blob(chunks, type); + audioSrc = window.URL.createObjectURL(blob); + + audio.src = audioSrc; + + chunks = []; + + // Save the Blob to the input element + saveToInput(blob); + } + + }).catch(function (error) { + if (location.protocol != 'https:') { + msg_box.innerHTML = lang.mic_error + '
    ' + lang.use_https; + } else { + msg_box.innerHTML = lang.mic_error; + } + button.disabled = true; + }); + } + + function stop() { + console.log('stop'); + mediaRecorder.stop(); + button.classList.remove('recording'); + btn_status = 'inactive'; + + if (navigator.vibrate) navigator.vibrate([200, 100, 200]); + + var now = Math.ceil(new Date().getTime() / 1000); + var t = parseTime(now - time); + + msg_box.innerHTML = '' + lang.play + ' (' + t + 's)
    ' + + '' + lang.download + ''; + } + + function play() { + audio.play(); + msg_box.innerHTML = '' + lang.stop + '
    ' + + '' + lang.download + ''; + } + + function pause() { + audio.pause(); + audio.currentTime = 0; + msg_box.innerHTML = '' + lang.play + '
    ' + + '' + lang.download + '' + } + + function roundedRect(ctx, x, y, width, height, radius, fill) { + ctx.beginPath(); + ctx.moveTo(x, y + radius); + ctx.lineTo(x, y + height - radius); + ctx.quadraticCurveTo(x, y + height, x + radius, y + height); + ctx.lineTo(x + width - radius, y + height); + ctx.quadraticCurveTo(x + width, y + height, x + width, y + height - radius); + ctx.lineTo(x + width, y + radius); + ctx.quadraticCurveTo(x + width, y, x + width - radius, y); + ctx.lineTo(x + radius, y); + ctx.quadraticCurveTo(x, y, x, y + radius); + + ctx.fillStyle = fill; + ctx.fill(); + } + + function saveToInput(blob) { + // Create the File object with the actual Blob data + const myFile = new File([blob], 'record.ogg', { + type: 'audio/ogg', + lastModified: new Date(), + }); + + let fileVoice = document.getElementById("Command_Voice"); + const dataTransfer = new DataTransfer(); + dataTransfer.items.add(myFile); + fileVoice.files = dataTransfer.files; + } + + function save() { + console.log(audioSrc); + var a = document.createElement('a'); + a.download = 'record.ogg'; + a.href = audioSrc; + document.body.appendChild(a); + a.click(); + + document.body.removeChild(a); + } + +} else { + if (location.protocol != 'https:') { + msg_box.innerHTML = lang.mic_error + '
    ' + lang.use_https; + } else { + msg_box.innerHTML = lang.mic_error; + } + button.disabled = true; +} +// صدا + + + + + + + + + +// نمایش اسامی کارگاه +var container = $('#partyName'); +var searchBox = $('#partyNameSearch'); +var searchResul = $('.searchResult'); +var mixContainerAndSerchResult = $('#partyName , .searchResult'); + +container.hide(); +var liList; +var liPointer; +let count = 0; + +//close search Employee when click on body +$(document).on('click', function (event) { + if (!$(event.target).closest(container).length) { + container.hide(); + } +}); +//select option by mouse +function selectItem(employeeFullName) { + searchBox.val(employeeFullName); + container.hide(); +}; +//search by Ajax +searchBox.on('keyup keypress', + function (e) { + searchResul.html(''); + + //stop submit form with enter + var keyCode = e.keyCode || e.which; + if (keyCode === 13) { + e.preventDefault(); + if (count > 0 && count <= liList.length) { + liPointer.click(); + } + return false; + } + + let searchText = $(this).val(); + + if (searchText.length > 1) { + + $.ajax({ + async: false, + contentType: 'charset=utf-8', + dataType: 'json', + type: 'GET', + url: searchContractingPartiesAjax, + data: { "searchName": searchText }, + headers: { "RequestVerificationToken": antiForgeryToken }, + + success: function (response) { + $(".opt").remove(); + if (response.list.length > 0) { + $(".noResult").remove(); + container.show(); + $.each(response.list, + function (i, item) { + let li = `
  • ${item.fullName}
  • `; + searchResul.append(li); + }); + } else { + $(".noResult").remove(); + container.show(); + let noResult = `
  • نتیجه ای یافت نشد!
  • `; + searchResul.append(noResult); + } + }// endOfSuccess + + }); //endOfAjax + + } else { + container.hide(); + count = 0; + } + }); +// نمایش اسامی کارگاه + + + + + + +// نمایش عنوان دلبخواه +var containerTitle = $('#TaskTitle'); +var searchBoxTitle = $('.TaskTitleSearch'); +var searchResulTitle = $('.searchTitleResult'); +var mixContainerAndSerchResultTitle = $('#TaskTitle , .searchTitleResult'); + +containerTitle.hide(); +var liListTitle; +var liPointerTitle; +let countTitle = 0; + +//close search Employee when click on body +$(document).on('click', function (event) { + if (!$(event.target).closest(container).length) { + containerTitle.hide(); + } +}); +//select option by mouse +function selectItemTitle(subject) { + searchBoxTitle.val(subject); + containerTitle.hide(); +}; +//search by Ajax +searchBoxTitle.on('keyup keypress', + function (e) { + searchResulTitle.html(''); + + //stop submit form with enter + var keyCode = e.keyCode || e.which; + if (keyCode === 13) { + e.preventDefault(); + if (countTitle > 0 && countTitle <= liListTitle.length) { + liPointerTitle.click(); + } + return false; + } + + let searchTextTitle = $(this).val(); + + if (searchTextTitle.length > 1) { + + $.ajax({ + async: false, + contentType: 'charset=utf-8', + dataType: 'json', + type: 'GET', + url: searchTaskSubject, + data: { "searchSubject": searchTextTitle }, + headers: { "RequestVerificationToken": antiForgeryToken }, + success: function (response) { + if (response.list.length > 0) { + //$(".noResultTitle").remove(); + containerTitle.show(); + $.each(response.list, + function (i, item) { + let li = `
  • ${item.subject}
  • `; + searchResulTitle.append(li); + }); + } else { + //$(".noResult").remove(); + containerTitle.hide(); + //let noResultTitle = `
  • نتیجه ای یافت نشد!
  • `; + //searchResulTitle.append(noResultTitle); + } + }// endOfSuccess + + }); //endOfAjax + + } else { + container.hide(); + count = 0; + } + }); +// نمایش عنوان دلبخواه + + + + +// برای محاسبه تاریخ و ساعت به صورت داینامیک +// function computeDays() { +// $('.resultDays').remove(); +// $.ajax({ +// /* contentType: 'charset=utf-8',*/ +// async: false, +// dataType: 'json', +// type: 'GET', +// url: '@Url.Page("/Company/Task/Create", "ComputeDay")', +// headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, +// data: { "date": $('#EndTaskDate').val(), "time": $('#EndTaskTime').val() }, +// success: function (response) { +// if (response.status == false) { +// $('.sumDays').addClass("note"); +// } else { +// $('.sumDays').removeClass("note"); +// } +// let res = `${response.res}`; +// $('.sumDays').append(res); +// }, +// failure: function (response) { +// console.log(5, response); +// } +// }); +// } + + +function taskSubjectModal() { + var goTo = `#showmodal=${taskSubject}`; + window.location.href = goTo; +} +