Merge branch 'Feature/MainProjectWithCommonAndBase' of https://github.com/kotcheshir73/DepartmentProject into Feature/StudentProgress
This commit is contained in:
commit
ec9ff8c28a
@ -8,7 +8,6 @@ using ModuleTools.Models;
|
|||||||
using ModuleTools.ViewModels;
|
using ModuleTools.ViewModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DatabaseCore
|
namespace DatabaseCore
|
||||||
{
|
{
|
||||||
@ -19,7 +18,7 @@ namespace DatabaseCore
|
|||||||
where L : ListViewModel<E>, new()
|
where L : ListViewModel<E>, new()
|
||||||
where E : ElementViewModel
|
where E : ElementViewModel
|
||||||
{
|
{
|
||||||
public async Task<OperationResultModel> CreateAsync(S model)
|
public OperationResultModel Create(S model)
|
||||||
{
|
{
|
||||||
using var context = DatabaseManager.GetContext;
|
using var context = DatabaseManager.GetContext;
|
||||||
|
|
||||||
@ -33,8 +32,8 @@ namespace DatabaseCore
|
|||||||
if (exsistEntity == null)
|
if (exsistEntity == null)
|
||||||
{
|
{
|
||||||
var entity = Mapper.MapToClass<S, T>(model, true);
|
var entity = Mapper.MapToClass<S, T>(model, true);
|
||||||
await context.Set<T>().AddAsync(entity);
|
context.Set<T>().Add(entity);
|
||||||
await context.SaveChangesAsync();
|
context.SaveChanges();
|
||||||
return OperationResultModel.Success(Mapper.MapToClass<T, E>(entity, true));
|
return OperationResultModel.Success(Mapper.MapToClass<T, E>(entity, true));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -43,7 +42,7 @@ namespace DatabaseCore
|
|||||||
{
|
{
|
||||||
exsistEntity = Mapper.MapToClass(model, exsistEntity, true);
|
exsistEntity = Mapper.MapToClass(model, exsistEntity, true);
|
||||||
exsistEntity.IsDeleted = false;
|
exsistEntity.IsDeleted = false;
|
||||||
await context.SaveChangesAsync();
|
context.SaveChanges();
|
||||||
return OperationResultModel.Success(Mapper.MapToClass<T, E>(exsistEntity, true));
|
return OperationResultModel.Success(Mapper.MapToClass<T, E>(exsistEntity, true));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -53,13 +52,13 @@ namespace DatabaseCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<OperationResultModel> DeleteAsync(G model)
|
public OperationResultModel Delete(G model)
|
||||||
{
|
{
|
||||||
using var context = DatabaseManager.GetContext;
|
using var context = DatabaseManager.GetContext;
|
||||||
using var transaction = context.Database.BeginTransaction();
|
using var transaction = context.Database.BeginTransaction();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var entity = await context.Set<T>().FirstOrDefaultAsync(x => x.Id == model.Id);
|
var entity = context.Set<T>().FirstOrDefault(x => x.Id == model.Id);
|
||||||
if (entity == null)
|
if (entity == null)
|
||||||
{
|
{
|
||||||
return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound);
|
return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound);
|
||||||
@ -78,22 +77,22 @@ namespace DatabaseCore
|
|||||||
entity.IsDeleted = true;
|
entity.IsDeleted = true;
|
||||||
entity.DateDelete = DateTime.Now;
|
entity.DateDelete = DateTime.Now;
|
||||||
|
|
||||||
await context.SaveChangesAsync();
|
context.SaveChanges();
|
||||||
|
|
||||||
AdditionalDeleting(context, entity, model);
|
AdditionalDeleting(context, entity, model);
|
||||||
|
|
||||||
await transaction.CommitAsync();
|
transaction.Commit();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
await transaction.RollbackAsync();
|
transaction.Rollback();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OperationResultModel.Success(true);
|
return OperationResultModel.Success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<OperationResultModel> RestoreAsync(G model)
|
public OperationResultModel Restore(G model)
|
||||||
{
|
{
|
||||||
if (model.Id.HasValue || AdditionalCheckForSingleGet(model))
|
if (model.Id.HasValue || AdditionalCheckForSingleGet(model))
|
||||||
{
|
{
|
||||||
@ -110,14 +109,14 @@ namespace DatabaseCore
|
|||||||
}
|
}
|
||||||
entity.IsDeleted = false;
|
entity.IsDeleted = false;
|
||||||
|
|
||||||
await context.SaveChangesAsync();
|
context.SaveChanges();
|
||||||
|
|
||||||
return OperationResultModel.Success(Mapper.MapToClass<T, E>(entity, true));
|
return OperationResultModel.Success(Mapper.MapToClass<T, E>(entity, true));
|
||||||
}
|
}
|
||||||
return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound);
|
return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<OperationResultModel> ReadAsync(G model)
|
public OperationResultModel Read(G model)
|
||||||
{
|
{
|
||||||
int countPages = 0;
|
int countPages = 0;
|
||||||
using var context = DatabaseManager.GetContext;
|
using var context = DatabaseManager.GetContext;
|
||||||
@ -146,9 +145,6 @@ namespace DatabaseCore
|
|||||||
|
|
||||||
query = IncludingWhenReading(query);
|
query = IncludingWhenReading(query);
|
||||||
|
|
||||||
return await Task.Run(() =>
|
|
||||||
{
|
|
||||||
|
|
||||||
if (model.PageNumber.HasValue && model.PageSize.HasValue)
|
if (model.PageNumber.HasValue && model.PageSize.HasValue)
|
||||||
{
|
{
|
||||||
countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value);
|
countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value);
|
||||||
@ -163,10 +159,9 @@ namespace DatabaseCore
|
|||||||
};
|
};
|
||||||
|
|
||||||
return OperationResultModel.Success(result);
|
return OperationResultModel.Success(result);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<OperationResultModel> UpdateAsync(S model)
|
public OperationResultModel Update(S model)
|
||||||
{
|
{
|
||||||
using var context = DatabaseManager.GetContext;
|
using var context = DatabaseManager.GetContext;
|
||||||
|
|
||||||
@ -193,7 +188,7 @@ namespace DatabaseCore
|
|||||||
}
|
}
|
||||||
entity = Mapper.MapToClass(model, entity, true);
|
entity = Mapper.MapToClass(model, entity, true);
|
||||||
|
|
||||||
await context.SaveChangesAsync();
|
context.SaveChanges();
|
||||||
|
|
||||||
return OperationResultModel.Success(Mapper.MapToClass<T, E>(entity, true));
|
return OperationResultModel.Success(Mapper.MapToClass<T, E>(entity, true));
|
||||||
}
|
}
|
||||||
|
1453
DepartmentPortal/Common/DatabaseCore/Migrations/20210430050931_UpdateStudnet2.Designer.cs
generated
Normal file
1453
DepartmentPortal/Common/DatabaseCore/Migrations/20210430050931_UpdateStudnet2.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,31 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace DatabaseCore.Migrations
|
||||||
|
{
|
||||||
|
public partial class UpdateStudnet2 : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "Email",
|
||||||
|
table: "Students",
|
||||||
|
type: "nvarchar(max)",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "nvarchar(max)");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "Email",
|
||||||
|
table: "Students",
|
||||||
|
type: "nvarchar(max)",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "",
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "nvarchar(max)",
|
||||||
|
oldNullable: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1450
DepartmentPortal/Common/DatabaseCore/Migrations/20210430051530_UpdateStudnet3.Designer.cs
generated
Normal file
1450
DepartmentPortal/Common/DatabaseCore/Migrations/20210430051530_UpdateStudnet3.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,56 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace DatabaseCore.Migrations
|
||||||
|
{
|
||||||
|
public partial class UpdateStudnet3 : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Students_StudentGroups_StudentGroupId",
|
||||||
|
table: "Students");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<Guid>(
|
||||||
|
name: "StudentGroupId",
|
||||||
|
table: "Students",
|
||||||
|
type: "uniqueidentifier",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(Guid),
|
||||||
|
oldType: "uniqueidentifier");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Students_StudentGroups_StudentGroupId",
|
||||||
|
table: "Students",
|
||||||
|
column: "StudentGroupId",
|
||||||
|
principalTable: "StudentGroups",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Students_StudentGroups_StudentGroupId",
|
||||||
|
table: "Students");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<Guid>(
|
||||||
|
name: "StudentGroupId",
|
||||||
|
table: "Students",
|
||||||
|
type: "uniqueidentifier",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
|
||||||
|
oldClrType: typeof(Guid),
|
||||||
|
oldType: "uniqueidentifier",
|
||||||
|
oldNullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Students_StudentGroups_StudentGroupId",
|
||||||
|
table: "Students",
|
||||||
|
column: "StudentGroupId",
|
||||||
|
principalTable: "StudentGroups",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -796,7 +796,6 @@ namespace DatabaseCore.Migrations
|
|||||||
.HasColumnType("nvarchar(max)");
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
b.Property<string>("Email")
|
b.Property<string>("Email")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
b.Property<string>("FirstName")
|
b.Property<string>("FirstName")
|
||||||
@ -828,7 +827,6 @@ namespace DatabaseCore.Migrations
|
|||||||
.HasColumnType("varbinary(max)");
|
.HasColumnType("varbinary(max)");
|
||||||
|
|
||||||
b.Property<Guid?>("StudentGroupId")
|
b.Property<Guid?>("StudentGroupId")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("uniqueidentifier");
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
b.Property<int>("StudentState")
|
b.Property<int>("StudentState")
|
||||||
@ -1332,9 +1330,7 @@ namespace DatabaseCore.Migrations
|
|||||||
{
|
{
|
||||||
b.HasOne("DatabaseCore.Models.Department.StudentGroup", "StudentGroup")
|
b.HasOne("DatabaseCore.Models.Department.StudentGroup", "StudentGroup")
|
||||||
.WithMany("Students")
|
.WithMany("Students")
|
||||||
.HasForeignKey("StudentGroupId")
|
.HasForeignKey("StudentGroupId");
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("DatabaseCore.Models.Security.User", "User")
|
b.HasOne("DatabaseCore.Models.Security.User", "User")
|
||||||
.WithMany("Students")
|
.WithMany("Students")
|
||||||
|
@ -26,7 +26,6 @@ namespace DatabaseCore.Models.Department
|
|||||||
public Guid UserId { get; set; }
|
public Guid UserId { get; set; }
|
||||||
|
|
||||||
[DataMember]
|
[DataMember]
|
||||||
[Required]
|
|
||||||
[MapConfiguration("StudentGroupId")]
|
[MapConfiguration("StudentGroupId")]
|
||||||
public Guid? StudentGroupId { get; set; }
|
public Guid? StudentGroupId { get; set; }
|
||||||
|
|
||||||
@ -55,7 +54,6 @@ namespace DatabaseCore.Models.Department
|
|||||||
public string Patronymic { get; set; }
|
public string Patronymic { get; set; }
|
||||||
|
|
||||||
[DataMember]
|
[DataMember]
|
||||||
[Required]
|
|
||||||
[MapConfiguration("Email")]
|
[MapConfiguration("Email")]
|
||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ namespace DesktopTools.Controls
|
|||||||
_controlViewEntityElement = this;
|
_controlViewEntityElement = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void OpenControl(ControlOpenModel model)
|
public void OpenControl(ControlOpenModel model)
|
||||||
{
|
{
|
||||||
if (model.CloseElement != null)
|
if (model.CloseElement != null)
|
||||||
{
|
{
|
||||||
@ -140,7 +140,7 @@ namespace DesktopTools.Controls
|
|||||||
}
|
}
|
||||||
if (model.ElementId.HasValue)
|
if (model.ElementId.HasValue)
|
||||||
{
|
{
|
||||||
Element = await _businessLogic.GetElementAsync(new G { Id = model.ElementId });
|
Element = _businessLogic.GetElement(new G { Id = model.ElementId });
|
||||||
if (Element == null)
|
if (Element == null)
|
||||||
{
|
{
|
||||||
DialogHelper.MessageException(_businessLogic.Errors, $"{Title}. Ошибки при получении элемента");
|
DialogHelper.MessageException(_businessLogic.Errors, $"{Title}. Ошибки при получении элемента");
|
||||||
@ -165,7 +165,7 @@ namespace DesktopTools.Controls
|
|||||||
|
|
||||||
private void InitEvents()
|
private void InitEvents()
|
||||||
{
|
{
|
||||||
toolStripButtonSave.Click += async (object sender, EventArgs e) => { await SaveAsync(); };
|
toolStripButtonSave.Click += (object sender, EventArgs e) => { Save(); };
|
||||||
toolStripButtonReload.Click += (object sender, EventArgs e) =>
|
toolStripButtonReload.Click += (object sender, EventArgs e) =>
|
||||||
{
|
{
|
||||||
if (DialogHelper.MessageQuestion("Отменить все внесенные изменения?") == DialogResult.Yes)
|
if (DialogHelper.MessageQuestion("Отменить все внесенные изменения?") == DialogResult.Yes)
|
||||||
@ -180,11 +180,11 @@ namespace DesktopTools.Controls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
toolStripButtonClose.Click += async (object sender, EventArgs e) =>
|
toolStripButtonClose.Click += (object sender, EventArgs e) =>
|
||||||
{
|
{
|
||||||
if (_haveChages && DialogHelper.MessageQuestion("Имеется несохраненные данные, вы действительно хотите закрыть элемент?", "Закрытие элемента") == DialogResult.Yes)
|
if (_haveChages && DialogHelper.MessageQuestion("Имеется несохраненные данные, вы действительно хотите закрыть элемент?", "Закрытие элемента") == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
if (!(await SaveAsync()))
|
if (!Save())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -349,7 +349,7 @@ namespace DesktopTools.Controls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> SaveAsync()
|
private bool Save()
|
||||||
{
|
{
|
||||||
if (CheckValues.GetInvocationList().Select(x => (bool)x.DynamicInvoke()).ToList().Any(x => !x))
|
if (CheckValues.GetInvocationList().Select(x => (bool)x.DynamicInvoke()).ToList().Any(x => !x))
|
||||||
{
|
{
|
||||||
@ -369,11 +369,11 @@ namespace DesktopTools.Controls
|
|||||||
{
|
{
|
||||||
if (Element == null)
|
if (Element == null)
|
||||||
{
|
{
|
||||||
Element = await _businessLogic.CreateAsync(model);
|
Element = _businessLogic.Create(model);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Element = await _businessLogic.UpdateAsync(model);
|
Element = _businessLogic.Update(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Element == null)
|
if (Element == null)
|
||||||
|
@ -12,7 +12,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
@ -68,7 +67,7 @@ namespace DesktopTools.Controls
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region IControlViewEntityList
|
#region IControlViewEntityList
|
||||||
public async void OpenControl(ControlOpenModel model)
|
public void OpenControl(ControlOpenModel model)
|
||||||
{
|
{
|
||||||
_openMode = model.OpenMode;
|
_openMode = model.OpenMode;
|
||||||
if (model.CloseList != null)
|
if (model.CloseList != null)
|
||||||
@ -93,13 +92,13 @@ namespace DesktopTools.Controls
|
|||||||
}
|
}
|
||||||
if (!model.LazyLoading)
|
if (!model.LazyLoading)
|
||||||
{
|
{
|
||||||
await LoadListAsync();
|
LoadList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IControl GetInstanceControl() => _genericControlViewEntityList?.GetInstanceGenericControl();
|
public IControl GetInstanceControl() => _genericControlViewEntityList?.GetInstanceGenericControl();
|
||||||
|
|
||||||
public string GetTitleFromIdControl(Guid id) => _businessLogic.GetElementAsync(new G { Id = id }).Result?.ToString();
|
public string GetTitleFromIdControl(Guid id) => _businessLogic.GetElement(new G { Id = id })?.ToString();
|
||||||
|
|
||||||
public string SaveControlToXml() => new XElement("Control",
|
public string SaveControlToXml() => new XElement("Control",
|
||||||
new XAttribute("Type", GetType().FullName),
|
new XAttribute("Type", GetType().FullName),
|
||||||
@ -114,7 +113,7 @@ namespace DesktopTools.Controls
|
|||||||
new XElement("Value", ((toolStripComboBoxPageNames.SelectedItem as PageNamesForPaginationModel)?.Value ?? "-"))),
|
new XElement("Value", ((toolStripComboBoxPageNames.SelectedItem as PageNamesForPaginationModel)?.Value ?? "-"))),
|
||||||
new XElement("ParentId", ParentId?.ToString() ?? "-"))).ToString();
|
new XElement("ParentId", ParentId?.ToString() ?? "-"))).ToString();
|
||||||
|
|
||||||
public async void LoadControlFromXml(string xml)
|
public void LoadControlFromXml(string xml)
|
||||||
{
|
{
|
||||||
var control = XElement.Parse(xml);
|
var control = XElement.Parse(xml);
|
||||||
ControlId = new Guid(control.Attribute("ControlId").Value.ToString());
|
ControlId = new Guid(control.Attribute("ControlId").Value.ToString());
|
||||||
@ -142,7 +141,7 @@ namespace DesktopTools.Controls
|
|||||||
{
|
{
|
||||||
ParentId = new Guid(config.Element("ParentId").Value.ToString());
|
ParentId = new Guid(config.Element("ParentId").Value.ToString());
|
||||||
}
|
}
|
||||||
await LoadListAsync();
|
LoadList();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -290,10 +289,10 @@ namespace DesktopTools.Controls
|
|||||||
{
|
{
|
||||||
toolStripButtonAdd.Click += (object sender, EventArgs e) => { AddElement(); };
|
toolStripButtonAdd.Click += (object sender, EventArgs e) => { AddElement(); };
|
||||||
toolStripButtonUpd.Click += (object sender, EventArgs e) => { UpdElement(); };
|
toolStripButtonUpd.Click += (object sender, EventArgs e) => { UpdElement(); };
|
||||||
toolStripButtonDel.Click += async (object sender, EventArgs e) => { await DelElementAsync(); };
|
toolStripButtonDel.Click += (object sender, EventArgs e) => { DelElement(); };
|
||||||
toolStripButtonSearch.Click += (object sender, EventArgs e) => { panelSearch.Visible = !panelSearch.Visible; };
|
toolStripButtonSearch.Click += (object sender, EventArgs e) => { panelSearch.Visible = !panelSearch.Visible; };
|
||||||
toolStripButtonRef.Click += async (object sender, EventArgs e) => { await LoadListAsync(); };
|
toolStripButtonRef.Click += (object sender, EventArgs e) => { LoadList(); };
|
||||||
toolStripButtonSelect.Click += async (object sender, EventArgs e) => { await SelectElement(); };
|
toolStripButtonSelect.Click += (object sender, EventArgs e) => { SelectElement(); };
|
||||||
toolStripButtonClose.Click += (object sender, EventArgs e) =>
|
toolStripButtonClose.Click += (object sender, EventArgs e) =>
|
||||||
{
|
{
|
||||||
CloseListEvent?.Invoke(ControlId);
|
CloseListEvent?.Invoke(ControlId);
|
||||||
@ -301,10 +300,10 @@ namespace DesktopTools.Controls
|
|||||||
Dispose();
|
Dispose();
|
||||||
};
|
};
|
||||||
|
|
||||||
buttonSearch.Click += async (object sender, EventArgs e) => { await LoadListAsync(); };
|
buttonSearch.Click += (object sender, EventArgs e) => { LoadList(); };
|
||||||
buttonCancelSearch.Click += async (object sender, EventArgs e) => { panelSearch.Visible = false; await LoadListAsync(); };
|
buttonCancelSearch.Click += (object sender, EventArgs e) => { panelSearch.Visible = false; LoadList(); };
|
||||||
|
|
||||||
dataGridViewList.KeyDown += async (object sender, KeyEventArgs e) =>
|
dataGridViewList.KeyDown += (object sender, KeyEventArgs e) =>
|
||||||
{
|
{
|
||||||
switch (e.KeyCode)
|
switch (e.KeyCode)
|
||||||
{
|
{
|
||||||
@ -323,41 +322,41 @@ namespace DesktopTools.Controls
|
|||||||
case Keys.Delete:
|
case Keys.Delete:
|
||||||
if (toolStripButtonDel.Visible)
|
if (toolStripButtonDel.Visible)
|
||||||
{
|
{
|
||||||
await DelElementAsync();
|
DelElement();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
dataGridViewList.CellDoubleClick += async (object sender, DataGridViewCellEventArgs e) =>
|
dataGridViewList.CellDoubleClick += (object sender, DataGridViewCellEventArgs e) =>
|
||||||
{
|
{
|
||||||
if (_openMode == ControlOpenMode.Select && dataGridViewList.SelectedRows.Count > 0)
|
if (_openMode == ControlOpenMode.Select && dataGridViewList.SelectedRows.Count > 0)
|
||||||
{
|
{
|
||||||
await SelectElement();
|
SelectElement();
|
||||||
}
|
}
|
||||||
UpdElement();
|
UpdElement();
|
||||||
};
|
};
|
||||||
|
|
||||||
toolStripButtonPrev.Click += async (object sender, EventArgs e) =>
|
toolStripButtonPrev.Click += (object sender, EventArgs e) =>
|
||||||
{
|
{
|
||||||
if (int.TryParse(toolStripTextBoxPage.Text, out int page))
|
if (int.TryParse(toolStripTextBoxPage.Text, out int page))
|
||||||
{
|
{
|
||||||
toolStripTextBoxPage.Text = (page - 1).ToString();
|
toolStripTextBoxPage.Text = (page - 1).ToString();
|
||||||
await LoadListAsync();
|
LoadList();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
toolStripButtonNext.Click += async (object sender, EventArgs e) =>
|
toolStripButtonNext.Click += (object sender, EventArgs e) =>
|
||||||
{
|
{
|
||||||
if (int.TryParse(toolStripTextBoxPage.Text, out int page))
|
if (int.TryParse(toolStripTextBoxPage.Text, out int page))
|
||||||
{
|
{
|
||||||
toolStripTextBoxPage.Text = (page + 1).ToString();
|
toolStripTextBoxPage.Text = (page + 1).ToString();
|
||||||
await LoadListAsync();
|
LoadList();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
toolStripTextBoxPage.KeyDown += async (object sender, KeyEventArgs e) =>
|
toolStripTextBoxPage.KeyDown += (object sender, KeyEventArgs e) =>
|
||||||
{
|
{
|
||||||
if (e.KeyData == Keys.Enter)
|
if (e.KeyData == Keys.Enter)
|
||||||
{
|
{
|
||||||
await LoadListAsync();
|
LoadList();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -369,12 +368,12 @@ namespace DesktopTools.Controls
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private async void ToolStripComboBoxPageNamesSelectedIndexChanged(object sender, EventArgs e) => await LoadListAsync();
|
private void ToolStripComboBoxPageNamesSelectedIndexChanged(object sender, EventArgs e) => LoadList();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вызов события загрузки данных на datagrid
|
/// Вызов события загрузки данных на datagrid
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task LoadListAsync()
|
private void LoadList()
|
||||||
{
|
{
|
||||||
var cursor = Cursor.Current;
|
var cursor = Cursor.Current;
|
||||||
|
|
||||||
@ -440,7 +439,7 @@ namespace DesktopTools.Controls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data = await _businessLogic.GetListAsync(model);
|
data = _businessLogic.GetList(model);
|
||||||
if (data == null && _businessLogic.Errors.Count > 0)
|
if (data == null && _businessLogic.Errors.Count > 0)
|
||||||
{
|
{
|
||||||
DialogHelper.MessageException(_businessLogic.Errors, $"{Title}. Ошибки при получении данных");
|
DialogHelper.MessageException(_businessLogic.Errors, $"{Title}. Ошибки при получении данных");
|
||||||
@ -463,14 +462,14 @@ namespace DesktopTools.Controls
|
|||||||
{
|
{
|
||||||
Cursor.Current = cursor;
|
Cursor.Current = cursor;
|
||||||
}
|
}
|
||||||
FillDataOnGridAsync(data?.List, selectedGuids);
|
FillDataOnGrid(data?.List, selectedGuids);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Заполнение таблицы
|
/// Заполнение таблицы
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="data"></param>
|
/// <param name="data"></param>
|
||||||
private void FillDataOnGridAsync(List<E> data, List<Guid> selectedGuids)
|
private void FillDataOnGrid(List<E> data, List<Guid> selectedGuids)
|
||||||
{
|
{
|
||||||
if (data == null)
|
if (data == null)
|
||||||
{
|
{
|
||||||
@ -513,7 +512,7 @@ namespace DesktopTools.Controls
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вызов события при удалении элемента
|
/// Вызов события при удалении элемента
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task DelElementAsync()
|
private void DelElement()
|
||||||
{
|
{
|
||||||
if (MessageBox.Show("Удалить выбранные записи?", "Подтверждение", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
if (MessageBox.Show("Удалить выбранные записи?", "Подтверждение", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
@ -523,7 +522,7 @@ namespace DesktopTools.Controls
|
|||||||
Cursor.Current = Cursors.WaitCursor;
|
Cursor.Current = Cursors.WaitCursor;
|
||||||
foreach (DataGridViewRow selected in dataGridViewList.SelectedRows)
|
foreach (DataGridViewRow selected in dataGridViewList.SelectedRows)
|
||||||
{
|
{
|
||||||
await _businessLogic.DeleteAsync(new G { Id = new Guid(selected.Cells[0].Value.ToString()) });
|
_businessLogic.Delete(new G { Id = new Guid(selected.Cells[0].Value.ToString()) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -540,7 +539,7 @@ namespace DesktopTools.Controls
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Cursor.Current = cursor;
|
Cursor.Current = cursor;
|
||||||
await LoadListAsync();
|
LoadList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -548,12 +547,12 @@ namespace DesktopTools.Controls
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вызов события при выборе элемента
|
/// Вызов события при выборе элемента
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task SelectElement()
|
private void SelectElement()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SelectedId = new Guid(dataGridViewList.SelectedRows[0].Cells[0].Value.ToString());
|
SelectedId = new Guid(dataGridViewList.SelectedRows[0].Cells[0].Value.ToString());
|
||||||
SelectedText = (await _businessLogic.GetElementAsync(new G { Id = SelectedId }))?.ToString();
|
SelectedText = _businessLogic.GetElement(new G { Id = SelectedId })?.ToString();
|
||||||
CloseSelectEvent?.Invoke(true);
|
CloseSelectEvent?.Invoke(true);
|
||||||
Dispose();
|
Dispose();
|
||||||
}
|
}
|
||||||
@ -580,8 +579,11 @@ namespace DesktopTools.Controls
|
|||||||
else if (toolStripFooter.Visible && toolStripComboBoxPageNames.Visible)
|
else if (toolStripFooter.Visible && toolStripComboBoxPageNames.Visible)
|
||||||
{
|
{
|
||||||
if (toolStripComboBoxPageNames.SelectedItem is PageNamesForPaginationModel key)
|
if (toolStripComboBoxPageNames.SelectedItem is PageNamesForPaginationModel key)
|
||||||
|
{
|
||||||
|
if (key.Key.GetType().Name == "Guid")
|
||||||
{
|
{
|
||||||
control.ParentId = new Guid(key.Key.ToString());
|
control.ParentId = new Guid(key.Key.ToString());
|
||||||
|
}
|
||||||
control.ParentPropertyName = toolStripComboBoxPageNames.Tag?.ToString();
|
control.ParentPropertyName = toolStripComboBoxPageNames.Tag?.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -596,9 +598,9 @@ namespace DesktopTools.Controls
|
|||||||
{
|
{
|
||||||
OpenMode = ControlOpenMode.List,
|
OpenMode = ControlOpenMode.List,
|
||||||
ElementId = id,
|
ElementId = id,
|
||||||
CloseElement = async (Guid id) =>
|
CloseElement = (Guid id) =>
|
||||||
{
|
{
|
||||||
await LoadListAsync();
|
LoadList();
|
||||||
form.Close();
|
form.Close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -3,7 +3,6 @@ using ModuleTools.Enums;
|
|||||||
using ModuleTools.Interfaces;
|
using ModuleTools.Interfaces;
|
||||||
using ModuleTools.ViewModels;
|
using ModuleTools.ViewModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ModuleTools.BusinessLogics
|
namespace ModuleTools.BusinessLogics
|
||||||
{
|
{
|
||||||
@ -42,7 +41,7 @@ namespace ModuleTools.BusinessLogics
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model"></param>
|
/// <param name="model"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<L> GetListAsync(G model)
|
public L GetList(G model)
|
||||||
{
|
{
|
||||||
Errors.Clear();
|
Errors.Clear();
|
||||||
try
|
try
|
||||||
@ -52,7 +51,7 @@ namespace ModuleTools.BusinessLogics
|
|||||||
{
|
{
|
||||||
throw new MethodAccessException("Нет прав на получение списка");
|
throw new MethodAccessException("Нет прав на получение списка");
|
||||||
}
|
}
|
||||||
var result = await Service.ReadAsync(model);
|
var result = Service.Read(model);
|
||||||
if (!result.IsSucceeded)
|
if (!result.IsSucceeded)
|
||||||
{
|
{
|
||||||
Errors.AddRange(result.Errors);
|
Errors.AddRange(result.Errors);
|
||||||
@ -73,7 +72,7 @@ namespace ModuleTools.BusinessLogics
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model"></param>
|
/// <param name="model"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<E> GetElementAsync(G model)
|
public E GetElement(G model)
|
||||||
{
|
{
|
||||||
Errors.Clear();
|
Errors.Clear();
|
||||||
try
|
try
|
||||||
@ -83,7 +82,7 @@ namespace ModuleTools.BusinessLogics
|
|||||||
{
|
{
|
||||||
throw new MethodAccessException("Нет прав на получение списка");
|
throw new MethodAccessException("Нет прав на получение списка");
|
||||||
}
|
}
|
||||||
var result = await Service.ReadAsync(model);
|
var result = Service.Read(model);
|
||||||
if (!result.IsSucceeded)
|
if (!result.IsSucceeded)
|
||||||
{
|
{
|
||||||
Errors.AddRange(result.Errors);
|
Errors.AddRange(result.Errors);
|
||||||
@ -103,7 +102,7 @@ namespace ModuleTools.BusinessLogics
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model"></param>
|
/// <param name="model"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<E> CreateAsync(S model)
|
public virtual E Create(S model)
|
||||||
{
|
{
|
||||||
Errors.Clear();
|
Errors.Clear();
|
||||||
try
|
try
|
||||||
@ -112,7 +111,7 @@ namespace ModuleTools.BusinessLogics
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var result = await Service.CreateAsync(model);
|
var result = Service.Create(model);
|
||||||
if (!result.IsSucceeded)
|
if (!result.IsSucceeded)
|
||||||
{
|
{
|
||||||
Errors.AddRange(result.Errors);
|
Errors.AddRange(result.Errors);
|
||||||
@ -133,7 +132,7 @@ namespace ModuleTools.BusinessLogics
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model"></param>
|
/// <param name="model"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<E> UpdateAsync(S model)
|
public virtual E Update(S model)
|
||||||
{
|
{
|
||||||
Errors.Clear();
|
Errors.Clear();
|
||||||
try
|
try
|
||||||
@ -142,7 +141,7 @@ namespace ModuleTools.BusinessLogics
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var result = await Service.UpdateAsync(model);
|
var result = Service.Update(model);
|
||||||
if (!result.IsSucceeded)
|
if (!result.IsSucceeded)
|
||||||
{
|
{
|
||||||
Errors.AddRange(result.Errors);
|
Errors.AddRange(result.Errors);
|
||||||
@ -163,7 +162,7 @@ namespace ModuleTools.BusinessLogics
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model"></param>
|
/// <param name="model"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<bool> DeleteAsync(G model)
|
public virtual bool Delete(G model)
|
||||||
{
|
{
|
||||||
Errors.Clear();
|
Errors.Clear();
|
||||||
try
|
try
|
||||||
@ -172,7 +171,7 @@ namespace ModuleTools.BusinessLogics
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var result = await Service.DeleteAsync(model);
|
var result = Service.Delete(model);
|
||||||
if (!result.IsSucceeded)
|
if (!result.IsSucceeded)
|
||||||
{
|
{
|
||||||
Errors.AddRange(result.Errors);
|
Errors.AddRange(result.Errors);
|
||||||
@ -193,7 +192,7 @@ namespace ModuleTools.BusinessLogics
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model"></param>
|
/// <param name="model"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<E> RestoreAsync(G model)
|
public virtual E Restore(G model)
|
||||||
{
|
{
|
||||||
Errors.Clear();
|
Errors.Clear();
|
||||||
try
|
try
|
||||||
@ -202,7 +201,7 @@ namespace ModuleTools.BusinessLogics
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var result = await Service.RestoreAsync(model);
|
var result = Service.Restore(model);
|
||||||
if (!result.IsSucceeded)
|
if (!result.IsSucceeded)
|
||||||
{
|
{
|
||||||
Errors.AddRange(result.Errors);
|
Errors.AddRange(result.Errors);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using ModuleTools.Attributes;
|
using ModuleTools.Attributes;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace ModuleTools.BusinessLogics
|
namespace ModuleTools.BusinessLogics
|
||||||
@ -69,6 +70,11 @@ namespace ModuleTools.BusinessLogics
|
|||||||
value = value.ToString();
|
value = value.ToString();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else if (prop == "Count")
|
||||||
|
{
|
||||||
|
value = (value as ICollection)?.Count;
|
||||||
|
break;
|
||||||
|
}
|
||||||
var bindingProperty = value.GetType().GetProperty(prop);
|
var bindingProperty = value.GetType().GetProperty(prop);
|
||||||
if (bindingProperty != null)
|
if (bindingProperty != null)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using ModuleTools.BindingModels;
|
using ModuleTools.BindingModels;
|
||||||
using ModuleTools.Models;
|
using ModuleTools.Models;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ModuleTools.Interfaces
|
namespace ModuleTools.Interfaces
|
||||||
{
|
{
|
||||||
@ -16,34 +15,34 @@ namespace ModuleTools.Interfaces
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model"></param>
|
/// <param name="model"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<OperationResultModel> ReadAsync(G model);
|
OperationResultModel Read(G model);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Создание новой сущности
|
/// Создание новой сущности
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model"></param>
|
/// <param name="model"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<OperationResultModel> CreateAsync(S model);
|
OperationResultModel Create(S model);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Изменение сущности
|
/// Изменение сущности
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model"></param>
|
/// <param name="model"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<OperationResultModel> UpdateAsync(S model);
|
OperationResultModel Update(S model);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление сущности
|
/// Удаление сущности
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model"></param>
|
/// <param name="model"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<OperationResultModel> DeleteAsync(G model);
|
OperationResultModel Delete(G model);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Восстановление сущности
|
/// Восстановление сущности
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model"></param>
|
/// <param name="model"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<OperationResultModel> RestoreAsync(G model);
|
OperationResultModel Restore(G model);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,6 +16,8 @@ namespace DepartmentBusinessLogic.BindingModels
|
|||||||
public Guid? StudentId { get; set; }
|
public Guid? StudentId { get; set; }
|
||||||
|
|
||||||
public Guid? StudentGroupId { get; set; }
|
public Guid? StudentGroupId { get; set; }
|
||||||
|
|
||||||
|
public OrderStudentMoveType? OrderStudentMoveType { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
using DepartmentBusinessLogic.BindingModels;
|
using DepartmentBusinessLogic.BindingModels;
|
||||||
|
using DepartmentBusinessLogic.Enums;
|
||||||
using DepartmentBusinessLogic.Interfaces;
|
using DepartmentBusinessLogic.Interfaces;
|
||||||
using DepartmentBusinessLogic.ViewModels;
|
using DepartmentBusinessLogic.ViewModels;
|
||||||
using ModuleTools.BusinessLogics;
|
using ModuleTools.BusinessLogics;
|
||||||
using ModuleTools.Enums;
|
using ModuleTools.Enums;
|
||||||
|
using SecurityBusinessLogic.BindingModels;
|
||||||
|
using SecurityBusinessLogic.BusinessLogics;
|
||||||
|
|
||||||
namespace DepartmentBusinessLogic.BusinessLogics
|
namespace DepartmentBusinessLogic.BusinessLogics
|
||||||
{
|
{
|
||||||
@ -12,5 +15,146 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
public class OrderStudentRecordBusinessLogic : GenericBusinessLogic<OrderStudentRecordGetBindingModel, OrderStudentRecordSetBindingModel, OrderStudentRecordListViewModel, OrderStudentRecordViewModel>
|
public class OrderStudentRecordBusinessLogic : GenericBusinessLogic<OrderStudentRecordGetBindingModel, OrderStudentRecordSetBindingModel, OrderStudentRecordListViewModel, OrderStudentRecordViewModel>
|
||||||
{
|
{
|
||||||
public OrderStudentRecordBusinessLogic(IOrderStudentRecordService service) : base(service, "Приказы", AccessOperation.Приказы) { }
|
public OrderStudentRecordBusinessLogic(IOrderStudentRecordService service) : base(service, "Приказы", AccessOperation.Приказы) { }
|
||||||
|
|
||||||
|
public override OrderStudentRecordViewModel Create(OrderStudentRecordSetBindingModel model)
|
||||||
|
{
|
||||||
|
var result = base.Create(model);
|
||||||
|
if (result != null)
|
||||||
|
{
|
||||||
|
var studentLogic = DependencyManager.Instance.Resolve<StudentBusinessLogic>();
|
||||||
|
var userLogic = DependencyManager.Instance.Resolve<UserBusinessLogic>();
|
||||||
|
var student = studentLogic.GetElement(new StudentGetBindingModel { Id = result.StudentId });
|
||||||
|
if (student == null)
|
||||||
|
{
|
||||||
|
Errors.AddRange(studentLogic.Errors);
|
||||||
|
Errors.Add(("Ошибка при получении студента", $"Не удалось получить студента"));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// изменять студента
|
||||||
|
var st = Mapper.MapToClass<StudentViewModel, StudentSetBindingModel>(student, true);
|
||||||
|
var studentName = student.ToString();
|
||||||
|
if (student.StudentGroupId != result.StudentGroupToId)
|
||||||
|
{
|
||||||
|
st.StudentGroupId = result.StudentGroupToId;
|
||||||
|
student = studentLogic.Update(st);
|
||||||
|
if (student == null)
|
||||||
|
{
|
||||||
|
Errors.AddRange(studentLogic.Errors);
|
||||||
|
Errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить группу у студента {studentName}"));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (student.Description != model.Info)
|
||||||
|
{
|
||||||
|
st.Description = model.Info;
|
||||||
|
student = studentLogic.Update(st);
|
||||||
|
if (student == null)
|
||||||
|
{
|
||||||
|
Errors.AddRange(studentLogic.Errors);
|
||||||
|
Errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить описание у студента {studentName}"));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((result.OrderStudentMoveType == OrderStudentMoveType.ЗачислитьПоПриказу ||
|
||||||
|
result.OrderStudentMoveType == OrderStudentMoveType.ПринятьПоПереводу ||
|
||||||
|
result.OrderStudentMoveType == OrderStudentMoveType.ПринятьПоПереводусДругогоВуза ||
|
||||||
|
result.OrderStudentMoveType == OrderStudentMoveType.ПеревестиНаДругоеНаправлениеКафедры)
|
||||||
|
&& student.StudentState != StudentState.Учится)
|
||||||
|
{
|
||||||
|
st.StudentState = StudentState.Учится;
|
||||||
|
student = studentLogic.Update(st);
|
||||||
|
if (student == null)
|
||||||
|
{
|
||||||
|
Errors.AddRange(studentLogic.Errors);
|
||||||
|
Errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить статус у студента {studentName}"));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((result.OrderStudentMoveType == OrderStudentMoveType.ОтправитьВАкадем ||
|
||||||
|
result.OrderStudentMoveType == OrderStudentMoveType.ПродлитьАкадем)
|
||||||
|
&& student.StudentState != StudentState.Академ)
|
||||||
|
{
|
||||||
|
st.StudentState = StudentState.Академ;
|
||||||
|
student = studentLogic.Update(st);
|
||||||
|
if (student == null)
|
||||||
|
{
|
||||||
|
Errors.AddRange(studentLogic.Errors);
|
||||||
|
Errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить статус у студента {studentName}"));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.OrderStudentMoveType == OrderStudentMoveType.ВосстановитьИзАкадема && student.StudentState != StudentState.Учится)
|
||||||
|
{
|
||||||
|
st.StudentState = StudentState.Учится;
|
||||||
|
student = studentLogic.Update(st);
|
||||||
|
if (student == null)
|
||||||
|
{
|
||||||
|
Errors.AddRange(studentLogic.Errors);
|
||||||
|
Errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить статус у студента {studentName}"));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((result.OrderStudentMoveType == OrderStudentMoveType.ОтчислитьВСвязиСПереводом ||
|
||||||
|
result.OrderStudentMoveType == OrderStudentMoveType.ОтчислитьЗаНевыходСАкадема ||
|
||||||
|
result.OrderStudentMoveType == OrderStudentMoveType.ОтчислитьЗаНеуспевамость ||
|
||||||
|
result.OrderStudentMoveType == OrderStudentMoveType.ОтчислитьПоСобственному ||
|
||||||
|
result.OrderStudentMoveType == OrderStudentMoveType.ОтчислитьПоЗавершению) &&
|
||||||
|
student.StudentState != StudentState.Отчислен)
|
||||||
|
{
|
||||||
|
st.StudentState = result.OrderStudentMoveType == OrderStudentMoveType.ОтчислитьПоЗавершению ? StudentState.Завершил : StudentState.Отчислен;
|
||||||
|
student = studentLogic.Update(st);
|
||||||
|
if (student == null)
|
||||||
|
{
|
||||||
|
Errors.AddRange(studentLogic.Errors);
|
||||||
|
Errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить статус у студента {studentName}"));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var delete = studentLogic.Delete(new StudentGetBindingModel { Id = student.Id });
|
||||||
|
if (!delete)
|
||||||
|
{
|
||||||
|
Errors.AddRange(studentLogic.Errors);
|
||||||
|
Errors.Add(("Ошибка удаления студента", $"Не удалось удалить студента {studentName}"));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
delete = userLogic.Delete(new UserGetBindingModel { Id = student.UserId });
|
||||||
|
if (!delete)
|
||||||
|
{
|
||||||
|
Errors.AddRange(studentLogic.Errors);
|
||||||
|
Errors.Add(("Ошибка удаления пользователя по студенту", $"Не удалось удалить пользователя по студенту {studentName}"));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.OrderStudentMoveType == OrderStudentMoveType.Восстановить && student.StudentState != StudentState.Учится)
|
||||||
|
{
|
||||||
|
st.StudentState = StudentState.Учится;
|
||||||
|
student = studentLogic.Update(st);
|
||||||
|
if (student == null)
|
||||||
|
{
|
||||||
|
Errors.AddRange(studentLogic.Errors);
|
||||||
|
Errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить статус у студента {studentName}"));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.OrderStudentMoveType == OrderStudentMoveType.УбратьПоПереводу && student.StudentState != StudentState.Ушел)
|
||||||
|
{
|
||||||
|
st.StudentState = StudentState.Ушел;
|
||||||
|
student = studentLogic.Update(st);
|
||||||
|
if (student == null)
|
||||||
|
{
|
||||||
|
Errors.AddRange(studentLogic.Errors);
|
||||||
|
Errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить статус у студента {studentName}"));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,7 +15,6 @@ using System.Net.Http;
|
|||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DepartmentBusinessLogic.BusinessLogics
|
namespace DepartmentBusinessLogic.BusinessLogics
|
||||||
{
|
{
|
||||||
@ -40,9 +39,9 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
public OrderSyncHistoryBusinessLogic(IOrderSyncHistoryService service) : base(service, "Синхронизация Приказов", AccessOperation.СинхронизацияПриказов) { }
|
public OrderSyncHistoryBusinessLogic(IOrderSyncHistoryService service) : base(service, "Синхронизация Приказов", AccessOperation.СинхронизацияПриказов) { }
|
||||||
|
|
||||||
public async Task<bool> SyncOrders()
|
public bool SyncOrders()
|
||||||
{
|
{
|
||||||
var history = await CreateAsync(new OrderSyncHistorySetBindingModel { SyncDate = DateTime.Now });
|
var history = Create(new OrderSyncHistorySetBindingModel { SyncDate = DateTime.Now });
|
||||||
if (history == null)
|
if (history == null)
|
||||||
{
|
{
|
||||||
Errors.Add(("Ошибка создание истории", "Не удалось создать историю"));
|
Errors.Add(("Ошибка создание истории", "Не удалось создать историю"));
|
||||||
@ -57,12 +56,12 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
_orderStudentRecordLogic = DependencyManager.Instance.Resolve<OrderStudentRecordBusinessLogic>();
|
_orderStudentRecordLogic = DependencyManager.Instance.Resolve<OrderStudentRecordBusinessLogic>();
|
||||||
_userLogic = DependencyManager.Instance.Resolve<UserBusinessLogic>();
|
_userLogic = DependencyManager.Instance.Resolve<UserBusinessLogic>();
|
||||||
|
|
||||||
var address = (await _enviromentSettingLogic.GetListAsync(new EnviromentSettingGetBindingModel { Key = "SyncStudentOrderIpAddress" }))?.List?.FirstOrDefault();
|
var address = _enviromentSettingLogic.GetList(new EnviromentSettingGetBindingModel { Key = "SyncStudentOrderIpAddress" })?.List?.FirstOrDefault();
|
||||||
if (address == null || address.Value.IsEmpty())
|
if (address == null || address.Value.IsEmpty())
|
||||||
{
|
{
|
||||||
Errors = _enviromentSettingLogic.Errors;
|
Errors = _enviromentSettingLogic.Errors;
|
||||||
Errors.Add(("Ошибка получения данных", "Не удалось получить адрес серверая для получения приказов по студентам"));
|
Errors.Add(("Ошибка получения данных", "Не удалось получить адрес серверая для получения приказов по студентам"));
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
_recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
||||||
@ -70,12 +69,12 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var username = (await _enviromentSettingLogic.GetListAsync(new EnviromentSettingGetBindingModel { Key = "SyncStudentOrderUserName" }))?.List?.FirstOrDefault();
|
var username = _enviromentSettingLogic.GetList(new EnviromentSettingGetBindingModel { Key = "SyncStudentOrderUserName" })?.List?.FirstOrDefault();
|
||||||
if (username == null || username.Value.IsEmpty())
|
if (username == null || username.Value.IsEmpty())
|
||||||
{
|
{
|
||||||
Errors = _enviromentSettingLogic.Errors;
|
Errors = _enviromentSettingLogic.Errors;
|
||||||
Errors.Add(("Ошибка получения данных", "Не удалось получить имя пользователя для получения приказов по студентам"));
|
Errors.Add(("Ошибка получения данных", "Не удалось получить имя пользователя для получения приказов по студентам"));
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
_recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
||||||
@ -83,12 +82,12 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var password = (await _enviromentSettingLogic.GetListAsync(new EnviromentSettingGetBindingModel { Key = "SyncStudentOrderPassword" }))?.List?.FirstOrDefault();
|
var password = _enviromentSettingLogic.GetList(new EnviromentSettingGetBindingModel { Key = "SyncStudentOrderPassword" })?.List?.FirstOrDefault();
|
||||||
if (password == null || password.Value.IsEmpty())
|
if (password == null || password.Value.IsEmpty())
|
||||||
{
|
{
|
||||||
Errors = _enviromentSettingLogic.Errors;
|
Errors = _enviromentSettingLogic.Errors;
|
||||||
Errors.Add(("Ошибка получения данных", "Не удалось получить пароль для получения приказов по студентам"));
|
Errors.Add(("Ошибка получения данных", "Не удалось получить пароль для получения приказов по студентам"));
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
_recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
||||||
@ -107,11 +106,11 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
// авторизация
|
// авторизация
|
||||||
|
|
||||||
// получение списка студентов
|
// получение списка студентов
|
||||||
HttpResponseMessage response = await client.GetAsync($"{address.Value}/univer_Testing/hs/Ulstu_StudentsInfo/v1/GetCurrentStudentsOfDepartment");
|
HttpResponseMessage response = client.GetAsync($"{address.Value}/univer/hs/Ulstu_StudentsInfo/v1/GetCurrentStudentsOfDepartment").Result;
|
||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
Errors.Add(("Ошибка получения данных", "Не удалось получить список студентов с сервера"));
|
Errors.Add(("Ошибка получения данных", "Не удалось получить список студентов с сервера"));
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
_recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
||||||
@ -121,7 +120,7 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
var studentFromServer = JsonSerializer.Deserialize<StudentListSyncModel>(response.Content.ReadAsStringAsync().Result);
|
var studentFromServer = JsonSerializer.Deserialize<StudentListSyncModel>(response.Content.ReadAsStringAsync().Result);
|
||||||
if (studentFromServer.CurrentStudentsList.Count == 0)
|
if (studentFromServer.CurrentStudentsList.Count == 0)
|
||||||
{
|
{
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
_recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = "Полученный список студентов пустой"
|
Information = "Полученный список студентов пустой"
|
||||||
@ -129,12 +128,12 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var groups = await _groupsLogic.GetListAsync(new StudentGroupGetBindingModel());
|
var groups = _groupsLogic.GetList(new StudentGroupGetBindingModel());
|
||||||
if (groups == null || groups.List == null)
|
if (groups == null || groups.List == null)
|
||||||
{
|
{
|
||||||
Errors = _groupsLogic.Errors;
|
Errors = _groupsLogic.Errors;
|
||||||
Errors.Add(("Ошибка получения данных", "Не удалось получить список групп"));
|
Errors.Add(("Ошибка получения данных", "Не удалось получить список групп"));
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
_recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
||||||
@ -142,12 +141,12 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var students = await _studentLogic.GetListAsync(new StudentGetBindingModel());
|
var students = _studentLogic.GetList(new StudentGetBindingModel());
|
||||||
if (students == null || students.List == null)
|
if (students == null || students.List == null)
|
||||||
{
|
{
|
||||||
Errors = _studentLogic.Errors;
|
Errors = _studentLogic.Errors;
|
||||||
Errors.Add(("Ошибка получения данных", "Не удалось получить список студентов"));
|
Errors.Add(("Ошибка получения данных", "Не удалось получить список студентов"));
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
_recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
||||||
@ -161,12 +160,12 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
// студент не найден, значит он ушел с кафедры, выясняем почему
|
// студент не найден, значит он ушел с кафедры, выясняем почему
|
||||||
if (studentSync == null)
|
if (studentSync == null)
|
||||||
{
|
{
|
||||||
await SyncStudentOrders(history, student, groups.List, client, address.Value);
|
SyncStudentOrders(history, student, groups.List, client, address.Value);
|
||||||
}
|
}
|
||||||
// не совпадение групп
|
// не совпадение групп
|
||||||
else if (student.StudentGroupName != studentSync.groupName)
|
else if (student.StudentGroupName != studentSync.groupName)
|
||||||
{
|
{
|
||||||
await SyncStudentOrders(history, student, groups.List, client, address.Value);
|
SyncStudentOrders(history, student, groups.List, client, address.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
studentFromServer.CurrentStudentsList.Remove(studentSync);
|
studentFromServer.CurrentStudentsList.Remove(studentSync);
|
||||||
@ -174,75 +173,93 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
// новые студенты и восстановленцы
|
// новые студенты и восстановленцы
|
||||||
foreach (var student in studentFromServer.CurrentStudentsList)
|
foreach (var student in studentFromServer.CurrentStudentsList)
|
||||||
{
|
{
|
||||||
var deletedStudent = await _studentLogic.GetElementAsync(new StudentGetBindingModel { NumberOfBook = student.recordBookName });
|
var deletedStudent = _studentLogic.GetElement(new StudentGetBindingModel { NumberOfBook = student.recordBookName });
|
||||||
if (deletedStudent == null && _studentLogic.Errors.FirstOrDefault(x => x.Message == "Элемент удален") != default)
|
if (deletedStudent == null && _studentLogic.Errors.FirstOrDefault(x => x.Message == "Элемент удален") != default)
|
||||||
{
|
{
|
||||||
// восстановленец
|
// восстановленец
|
||||||
deletedStudent = await _studentLogic.RestoreAsync(new StudentGetBindingModel { NumberOfBook = student.recordBookName });
|
deletedStudent = _studentLogic.Restore(new StudentGetBindingModel { NumberOfBook = student.recordBookName });
|
||||||
if (deletedStudent == null)
|
if (deletedStudent == null)
|
||||||
{
|
{
|
||||||
var errors = _studentLogic.Errors;
|
var errors = _studentLogic.Errors;
|
||||||
errors.Add(("Ошибка при восстановлении студента", $"Не удалось восстановить студента {student.lastName} {student.firstName} {student.patronymicName}"));
|
errors.Add(("Ошибка при восстановлении студента", $"Не удалось восстановить студента {student.lastName} {student.firstName} {student.patronymicName}"));
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
_recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
||||||
});
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var deletedUser = await _userLogic.RestoreAsync(new UserGetBindingModel { Id = deletedStudent.UserId });
|
var deletedUser = _userLogic.Restore(new UserGetBindingModel { Id = deletedStudent.UserId });
|
||||||
if (deletedUser == null)
|
if (deletedUser == null)
|
||||||
{
|
{
|
||||||
var errors = _userLogic.Errors;
|
var errors = _userLogic.Errors;
|
||||||
errors.Add(("Ошибка при восстановлении пользователя студента", $"Не удалось восстановить пользователя студента {student.lastName} {student.firstName} {student.patronymicName}"));
|
errors.Add(("Ошибка при восстановлении пользователя студента", $"Не удалось восстановить пользователя студента {student.lastName} {student.firstName} {student.patronymicName}"));
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
_recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
||||||
});
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
await SyncStudentOrders(history, deletedStudent, groups.List, client, address.Value);
|
SyncStudentOrders(history, deletedStudent, groups.List, client, address.Value);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var user = _userLogic.GetElement(new UserGetBindingModel
|
||||||
|
{
|
||||||
|
Login = student.recordBookName
|
||||||
|
});
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
if (_userLogic.Errors.Count > 0)
|
||||||
|
{
|
||||||
|
var errors = _userLogic.Errors;
|
||||||
|
errors.Add(("Ошибка получения пользователя под студента", $"Не удалось получить пользователя под студента {student.lastName} {student.firstName} {student.patronymicName}"));
|
||||||
|
_recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel
|
||||||
|
{
|
||||||
|
OrderSyncHistoryId = history.Id,
|
||||||
|
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
||||||
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var userName = $"{student.lastName}{(student.firstName.IsNotEmpty() ? $" {student.firstName[0]}." : string.Empty)}{(student.patronymicName.IsNotEmpty() ? $"{student.patronymicName[0]}." : string.Empty)}";
|
var userName = $"{student.lastName}{(student.firstName.IsNotEmpty() ? $" {student.firstName[0]}." : string.Empty)}{(student.patronymicName.IsNotEmpty() ? $"{student.patronymicName[0]}." : string.Empty)}";
|
||||||
var result = await _userLogic.GetListAsync(new UserGetBindingModel { UserNameForSearch = userName });
|
user = _userLogic.Create(new UserSetBindingModel
|
||||||
|
|
||||||
var newuser = await _userLogic.CreateAsync(new UserSetBindingModel
|
|
||||||
{
|
{
|
||||||
Login = userName,
|
Login = student.recordBookName,
|
||||||
Password = student.recordBookName
|
Password = userName
|
||||||
});
|
});
|
||||||
if (newuser == null)
|
|
||||||
|
if (user == null)
|
||||||
{
|
{
|
||||||
var errors = _userLogic.Errors;
|
var errors = _userLogic.Errors;
|
||||||
errors.Add(("Ошибка создания пользователя под студента", $"Не удалось создать пользователя под студента {student.lastName} {student.firstName} {student.patronymicName}"));
|
errors.Add(("Ошибка создания пользователя под студента", $"Не удалось создать пользователя под студента {student.lastName} {student.firstName} {student.patronymicName}"));
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
_recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
||||||
});
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var newStudent = await _studentLogic.CreateAsync(new StudentSetBindingModel
|
var newStudent = _studentLogic.Create(new StudentSetBindingModel
|
||||||
{
|
{
|
||||||
Iduniv = student.iduniv,
|
Iduniv = student.iduniv,
|
||||||
NumberOfBook = student.recordBookName,
|
NumberOfBook = student.recordBookName,
|
||||||
UserId = newuser.Id,
|
UserId = user.Id,
|
||||||
FirstName = student.firstName,
|
FirstName = student.firstName,
|
||||||
LastName = student.lastName,
|
LastName = student.lastName,
|
||||||
Patronymic = student.patronymicName,
|
Patronymic = student.patronymicName,
|
||||||
StudentState = StudentState.Неопределен,
|
StudentState = StudentState.Неопределен,
|
||||||
Description = student.presenatationOfRecordBook
|
Description = string.Empty
|
||||||
});
|
});
|
||||||
|
|
||||||
if (newStudent == null)
|
if (newStudent == null)
|
||||||
{
|
{
|
||||||
var errors = _studentLogic.Errors;
|
var errors = _studentLogic.Errors;
|
||||||
errors.Add(("Ошибка добавления студента", $"Не удалось добавить студента {student.lastName} {student.firstName} {student.patronymicName}"));
|
errors.Add(("Ошибка добавления студента", $"Не удалось добавить студента {student.lastName} {student.firstName} {student.patronymicName}"));
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
_recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
||||||
@ -250,17 +267,14 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
_recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = $"Добавлен студент {newStudent}"
|
Information = $"Добавлен студент {newStudent}"
|
||||||
});
|
});
|
||||||
|
|
||||||
await SyncStudentOrders(history, newStudent, groups.List, client, address.Value);
|
SyncStudentOrders(history, newStudent, groups.List, client, address.Value);
|
||||||
|
|
||||||
studentFromServer.CurrentStudentsList.Remove(student);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,13 +287,13 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
/// <param name="client"></param>
|
/// <param name="client"></param>
|
||||||
/// <param name="address"></param>
|
/// <param name="address"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private async Task SyncStudentOrders(OrderSyncHistoryViewModel history, StudentViewModel student, List<StudentGroupViewModel> groups, HttpClient client, string address)
|
private void SyncStudentOrders(OrderSyncHistoryViewModel history, StudentViewModel student, List<StudentGroupViewModel> groups, HttpClient client, string address)
|
||||||
{
|
{
|
||||||
HttpResponseMessage response = await client.GetAsync($"{address}/univer_Testing/hs/Ulstu_StudentsInfo/v1/GetStudentOrdersByIdAndRecordBook?iduniv={student.Iduniv}&recordBookName={student.NumberOfBook}&allOrders=sppd");
|
HttpResponseMessage response = client.GetAsync($"{address}/univer/hs/Ulstu_StudentsInfo/v1/GetStudentOrdersByIdAndRecordBook?iduniv={student.Iduniv}&recordBookName={student.NumberOfBook}&allOrders=sppd").Result;
|
||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
Errors.Add(("Ошибка получения данных", "Не удалось получить список приказов по студенту"));
|
Errors.Add(("Ошибка получения данных", "Не удалось получить список приказов по студенту"));
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
_recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
||||||
@ -289,24 +303,58 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
var syncOrders = JsonSerializer.Deserialize<StudentOrderListSyncModel>(response.Content.ReadAsStringAsync().Result);
|
var syncOrders = JsonSerializer.Deserialize<StudentOrderListSyncModel>(response.Content.ReadAsStringAsync().Result);
|
||||||
foreach (var syncOrder in syncOrders.StudentOrders)
|
foreach (var syncOrder in syncOrders.StudentOrders)
|
||||||
{
|
{
|
||||||
|
if (syncOrder.markOfApprove.ToLower() != "true")
|
||||||
|
{
|
||||||
|
_recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel
|
||||||
|
{
|
||||||
|
OrderSyncHistoryId = history.Id,
|
||||||
|
Information = $"Приказ {syncOrder.clericNumber} от {syncOrder.clericDate} ({syncOrder.orderTypeName}) по студенту {student} не утврежден "
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (syncOrder.clericNumber.IsEmpty())
|
||||||
|
{
|
||||||
|
_recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel
|
||||||
|
{
|
||||||
|
OrderSyncHistoryId = history.Id,
|
||||||
|
Information = $"Приказ без номера от {syncOrder.clericDate} ({student})"
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (syncOrder.clericDate.IsEmpty())
|
||||||
|
{
|
||||||
|
_recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel
|
||||||
|
{
|
||||||
|
OrderSyncHistoryId = history.Id,
|
||||||
|
Information = $"Приказ {syncOrder.clericNumber} - неизвестная дата ({student})"
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
var orderType = GetOrderType(syncOrder.orderTypeName);
|
var orderType = GetOrderType(syncOrder.orderTypeName);
|
||||||
|
|
||||||
// пропускаем приказы, которые нас не интересуют
|
// пропускаем приказы, которые нас не интересуют
|
||||||
if (orderType == OrderType.Неопределено)
|
if (orderType == OrderType.Неопределено)
|
||||||
{
|
{
|
||||||
|
if (syncOrder.orderTypeName != "Корректировка" && syncOrder.orderTypeName != "Назначение стипендии" &&
|
||||||
|
syncOrder.orderTypeName != "Утверждение тем курсовых работ" && syncOrder.orderTypeName != "Утверждение тем работ"
|
||||||
|
&& syncOrder.orderTypeName != "Смена ФИО")
|
||||||
|
_recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel
|
||||||
|
{
|
||||||
|
OrderSyncHistoryId = history.Id,
|
||||||
|
Information = $"Приказ {syncOrder.clericNumber} неопределенного типа {syncOrder.orderTypeName}"
|
||||||
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// пытаемся найти приказ
|
// пытаемся найти приказ
|
||||||
var order = await _orderLogic.GetElementAsync(new OrderGetBindingModel
|
var order = _orderLogic.GetElement(new OrderGetBindingModel
|
||||||
{
|
{
|
||||||
OrderNumber = syncOrder.clericNumber,
|
OrderNumber = syncOrder.clericNumber
|
||||||
OrderDate = Convert.ToDateTime(syncOrder.clericDate)
|
|
||||||
});
|
});
|
||||||
if (order == null)
|
if (order == null)
|
||||||
{
|
{
|
||||||
// если не нашли - пытаемся создать
|
// если не нашли - пытаемся создать
|
||||||
order = await _orderLogic.CreateAsync(new OrderSetBindingModel
|
order = _orderLogic.Create(new OrderSetBindingModel
|
||||||
{
|
{
|
||||||
OrderNumber = syncOrder.clericNumber,
|
OrderNumber = syncOrder.clericNumber,
|
||||||
OrderDate = Convert.ToDateTime(syncOrder.clericDate),
|
OrderDate = Convert.ToDateTime(syncOrder.clericDate),
|
||||||
@ -316,7 +364,7 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
var errors = _orderLogic.Errors;
|
var errors = _orderLogic.Errors;
|
||||||
errors.Add(("Ошибка добавления приказа", $"Не удалось добавить приказ {syncOrder.clericNumber} {syncOrder.clericDate}"));
|
errors.Add(("Ошибка добавления приказа", $"Не удалось добавить приказ {syncOrder.clericNumber} {syncOrder.clericDate}"));
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
_recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
||||||
@ -325,24 +373,6 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ищем в приказе запись по студенту
|
|
||||||
var studentOrder = await _orderStudentRecordLogic.GetElementAsync(new OrderStudentRecordGetBindingModel
|
|
||||||
{
|
|
||||||
OrderId = order.Id,
|
|
||||||
StudentId = student.Id
|
|
||||||
});
|
|
||||||
|
|
||||||
// если такой приказ по студенту уже есть, просто пропускаем
|
|
||||||
if (studentOrder != null)
|
|
||||||
{
|
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
|
||||||
{
|
|
||||||
OrderSyncHistoryId = history.Id,
|
|
||||||
Information = $"Нерспознанный приказ {syncOrder.orderTypeName} для студента {student}"
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Guid? studentGroupFromId = null;
|
Guid? studentGroupFromId = null;
|
||||||
Guid? studentGroupToId = null;
|
Guid? studentGroupToId = null;
|
||||||
string info = string.Empty;
|
string info = string.Empty;
|
||||||
@ -355,7 +385,8 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
studentGroupToId = groups.FirstOrDefault(x => x.ToString() == syncOrder.groupNameAfter)?.Id;
|
studentGroupToId = groups.FirstOrDefault(x => x.ToString() == syncOrder.groupNameAfter)?.Id;
|
||||||
}
|
}
|
||||||
// игнорируем приказы, не связанные с нашими группами
|
// игнорируем приказы, не связанные с нашими группами
|
||||||
if (!studentGroupFromId.HasValue && !studentGroupToId.HasValue)
|
if (!studentGroupFromId.HasValue && syncOrder.groupNameBefore.IsNotEmpty()
|
||||||
|
&& !studentGroupToId.HasValue && syncOrder.groupNameAfter.IsNotEmpty())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -367,23 +398,22 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
if (syncOrder.orderSubTypeName == "Распределение по группам")
|
if (syncOrder.orderSubTypeName == "Распределение по группам")
|
||||||
{
|
{
|
||||||
orderStudentMoveType = OrderStudentMoveType.Распределить;
|
orderStudentMoveType = OrderStudentMoveType.Распределить;
|
||||||
info = $"Распределение студента {student} в группу {groups.First(x => x.Id == studentGroupToId)}";
|
info = $"Распределение студента {student} в группу {groups.FirstOrDefault(x => x.Id == studentGroupToId)}";
|
||||||
}
|
}
|
||||||
// внутренний перевод
|
|
||||||
else if (studentGroupFromId.HasValue && studentGroupToId.HasValue)
|
else if (studentGroupFromId.HasValue && studentGroupToId.HasValue)
|
||||||
{
|
{
|
||||||
orderStudentMoveType = OrderStudentMoveType.ПеревестиНаДругоеНаправлениеКафедры;
|
orderStudentMoveType = OrderStudentMoveType.ПеревестиНаДругоеНаправлениеКафедры;
|
||||||
info = $"Перевод студента {student} из группы {groups.First(x => x.Id == studentGroupFromId)} в группу {groups.First(x => x.Id == studentGroupToId)}";
|
info = $"Перевод студента {student} из группы {groups.FirstOrDefault(x => x.Id == studentGroupFromId)} в группу {groups.FirstOrDefault(x => x.Id == studentGroupToId)}";
|
||||||
}
|
}
|
||||||
else if (!studentGroupFromId.HasValue && studentGroupToId.HasValue)
|
else if (!studentGroupFromId.HasValue && studentGroupToId.HasValue)
|
||||||
{
|
{
|
||||||
orderStudentMoveType = OrderStudentMoveType.ПринятьПоПереводу;
|
orderStudentMoveType = OrderStudentMoveType.ПринятьПоПереводу;
|
||||||
info = $"Перевод студента {student} c группы {syncOrder.groupNameBefore} другой кафедры в группу {groups.First(x => x.Id == studentGroupToId)}";
|
info = $"Перевод студента {student} c группы {syncOrder.groupNameBefore} другой кафедры в группу {groups.FirstOrDefault(x => x.Id == studentGroupToId)}";
|
||||||
}
|
}
|
||||||
else if (studentGroupFromId.HasValue && !studentGroupToId.HasValue)
|
else if (studentGroupFromId.HasValue && !studentGroupToId.HasValue)
|
||||||
{
|
{
|
||||||
orderStudentMoveType = OrderStudentMoveType.УбратьПоПереводу;
|
orderStudentMoveType = OrderStudentMoveType.УбратьПоПереводу;
|
||||||
info = $"Перевод студента {student} из группы {groups.First(x => x.Id == studentGroupFromId)} на другую кафедру";
|
info = $"Перевод студента {student} из группы {groups.FirstOrDefault(x => x.Id == studentGroupFromId)} на другую кафедру";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "Зачисление в вуз вне приемной кампании":
|
case "Зачисление в вуз вне приемной кампании":
|
||||||
@ -400,16 +430,20 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
break;
|
break;
|
||||||
case "Перевод на следующий курс":
|
case "Перевод на следующий курс":
|
||||||
orderStudentMoveType = OrderStudentMoveType.ПеревестиНаСтаршийКурс;
|
orderStudentMoveType = OrderStudentMoveType.ПеревестиНаСтаршийКурс;
|
||||||
info = $"Перевод студента {student} из группы {groups.First(x => x.Id == studentGroupFromId)} на следующий курс в группу {groups.First(x => x.Id == studentGroupToId)}";
|
info = $"Перевод студента {student} из группы {groups.FirstOrDefault(x => x.Id == studentGroupFromId)} на следующий курс в группу {groups.FirstOrDefault(x => x.Id == studentGroupToId)}";
|
||||||
break;
|
break;
|
||||||
//case "Завершение обучения": // уточнить приказ
|
//case "Завершение обучения": // уточнить приказ
|
||||||
// orderStudentMoveType = OrderStudentMoveType.ОтчислитьПоСобственному;
|
// orderStudentMoveType = OrderStudentMoveType.ОтчислитьПоСобственному;
|
||||||
// info = $"Отчисление студента {student} в связи с окончанием обучения";
|
// info = $"Отчисление студента {student} в связи с окончанием обучения";
|
||||||
// break;
|
// break;
|
||||||
case "Уход в академический отпуск":
|
case "Уход в академический отпуск":
|
||||||
// дата
|
DateTime? date = null;
|
||||||
|
if (syncOrder.dateEnd.IsNotEmpty())
|
||||||
|
{
|
||||||
|
date = Convert.ToDateTime(syncOrder.dateEnd);
|
||||||
|
}
|
||||||
orderStudentMoveType = OrderStudentMoveType.ОтправитьВАкадем;
|
orderStudentMoveType = OrderStudentMoveType.ОтправитьВАкадем;
|
||||||
info = $"Уход в АО студента {student} из группы {groups.First(x => x.Id == studentGroupFromId)}";
|
info = $"Уход в АО студента {student} из группы {groups.FirstOrDefault(x => x.Id == studentGroupFromId)} до {date?.ToShortDateString() ?? string.Empty}";
|
||||||
break;
|
break;
|
||||||
case "Продление академического отпуска":
|
case "Продление академического отпуска":
|
||||||
orderStudentMoveType = OrderStudentMoveType.ПродлитьАкадем;
|
orderStudentMoveType = OrderStudentMoveType.ПродлитьАкадем;
|
||||||
@ -417,38 +451,56 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
break;
|
break;
|
||||||
case "Восстановление из академического отпуска":
|
case "Восстановление из академического отпуска":
|
||||||
orderStudentMoveType = OrderStudentMoveType.ВосстановитьИзАкадема;
|
orderStudentMoveType = OrderStudentMoveType.ВосстановитьИзАкадема;
|
||||||
info = $"Выход из АО студента {student} в группу {groups.First(x => x.Id == studentGroupToId)}";
|
info = $"Выход из АО студента {student} в группу {groups.FirstOrDefault(x => x.Id == studentGroupToId)}";
|
||||||
break;
|
break;
|
||||||
//case "Отчисление по собственному": // уточнить приказ
|
|
||||||
// orderStudentMoveType = OrderStudentMoveType.ОтчислитьПоСобственному;
|
|
||||||
// info = $"Отчисление студента {student} из группы {groups.First(x => x.Id == studentGroupFromId)} по собственному желанию";
|
|
||||||
// break;
|
|
||||||
//case "Отчисление за неуспеваемость": // уточнить приказ
|
|
||||||
// orderStudentMoveType = OrderStudentMoveType.ОтчислитьЗаНеуспевамость;
|
|
||||||
// info = $"Отчисление студента {student} из группы {groups.First(x => x.Id == studentGroupFromId)} за неуспеваемость";
|
|
||||||
// break;
|
|
||||||
//case "Отчисление по невыходу из академа": // уточнить приказ
|
//case "Отчисление по невыходу из академа": // уточнить приказ
|
||||||
// orderStudentMoveType = OrderStudentMoveType.ОтчислитьЗаНевыходСАкадема;
|
// orderStudentMoveType = OrderStudentMoveType.ОтчислитьЗаНевыходСАкадема;
|
||||||
// info = $"Отчисление студента {student} по невыходу из академа";
|
// info = $"Отчисление студента {student} по невыходу из академа";
|
||||||
// break;
|
// break;
|
||||||
case "Отчисление":
|
case "Отчисление":
|
||||||
|
if (syncOrder.reason == "за невыполнение учебного плана")
|
||||||
{
|
{
|
||||||
|
orderStudentMoveType = OrderStudentMoveType.ОтчислитьЗаНеуспевамость;
|
||||||
|
info = $"Отчисление студента {student} из группы {groups.FirstOrDefault(x => x.Id == studentGroupFromId)} за неуспеваемость";
|
||||||
|
}
|
||||||
|
if (syncOrder.reason == "по собственному желанию")
|
||||||
|
{
|
||||||
|
orderStudentMoveType = OrderStudentMoveType.ОтчислитьПоСобственному;
|
||||||
|
info = $"Отчисление студента {student} из группы {groups.FirstOrDefault(x => x.Id == studentGroupFromId)} по собственному желанию";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "Восстановление":
|
case "Восстановление":
|
||||||
orderStudentMoveType = OrderStudentMoveType.Восстановить;
|
orderStudentMoveType = OrderStudentMoveType.Восстановить;
|
||||||
info = $"Восстановление отчисленного студента {student} в группу {groups.First(x => x.Id == studentGroupToId)}";
|
info = $"Восстановление отчисленного студента {student} в группу {groups.FirstOrDefault(x => x.Id == studentGroupToId)}";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orderStudentMoveType == OrderStudentMoveType.Неопределено)
|
if (orderStudentMoveType == OrderStudentMoveType.Неопределено)
|
||||||
|
{
|
||||||
|
_recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel
|
||||||
|
{
|
||||||
|
OrderSyncHistoryId = history.Id,
|
||||||
|
Information = $"Неизветсный приказ {syncOrder.orderTypeName} ({syncOrder.reason}) по студенту {student}"
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ищем в приказе запись по студенту
|
||||||
|
var studentOrder = _orderStudentRecordLogic.GetElement(new OrderStudentRecordGetBindingModel
|
||||||
|
{
|
||||||
|
OrderId = order.Id,
|
||||||
|
StudentId = student.Id,
|
||||||
|
OrderStudentMoveType = orderStudentMoveType
|
||||||
|
});
|
||||||
|
|
||||||
|
// если такой приказ по студенту уже есть, просто пропускаем
|
||||||
|
if (studentOrder != null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// создаем, если не нашли
|
// создаем, если не нашли
|
||||||
studentOrder = await _orderStudentRecordLogic.CreateAsync(new OrderStudentRecordSetBindingModel
|
studentOrder = _orderStudentRecordLogic.Create(new OrderStudentRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderId = order.Id,
|
OrderId = order.Id,
|
||||||
StudentId = student.Id,
|
StudentId = student.Id,
|
||||||
@ -461,7 +513,7 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
var errors = _orderStudentRecordLogic.Errors;
|
var errors = _orderStudentRecordLogic.Errors;
|
||||||
errors.Add(("Ошибка добавления записи приказа по студенту", $"Не удалось добавить запись приказа {syncOrder.orderSubTypeName} по студенту {student}"));
|
errors.Add(("Ошибка добавления записи приказа по студенту", $"Не удалось добавить запись приказа {syncOrder.orderSubTypeName} по студенту {student}"));
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
_recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
||||||
@ -469,192 +521,7 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var st = Mapper.MapToClass<StudentViewModel, StudentSetBindingModel>(student, true);
|
_recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel
|
||||||
var studentName = student.ToString();
|
|
||||||
if (student.StudentGroupId != studentGroupToId)
|
|
||||||
{
|
|
||||||
st.StudentGroupId = studentGroupToId;
|
|
||||||
student = await _studentLogic.UpdateAsync(st);
|
|
||||||
if (student == null)
|
|
||||||
{
|
|
||||||
var errors = _studentLogic.Errors;
|
|
||||||
errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить группу у студента {studentName}"));
|
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
|
||||||
{
|
|
||||||
OrderSyncHistoryId = history.Id,
|
|
||||||
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
|
||||||
{
|
|
||||||
OrderSyncHistoryId = history.Id,
|
|
||||||
Information = $"У студента {student} сменилась группа на {student.StudentGroupName}"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((orderStudentMoveType == OrderStudentMoveType.ЗачислитьПоПриказу || orderStudentMoveType == OrderStudentMoveType.ПринятьПоПереводу
|
|
||||||
|| orderStudentMoveType == OrderStudentMoveType.ПринятьПоПереводусДругогоВуза || orderStudentMoveType == OrderStudentMoveType.ПеревестиНаДругоеНаправлениеКафедры)
|
|
||||||
&& student.StudentState != StudentState.Учится)
|
|
||||||
{
|
|
||||||
st.StudentState = StudentState.Учится;
|
|
||||||
student = await _studentLogic.UpdateAsync(st);
|
|
||||||
if (student == null)
|
|
||||||
{
|
|
||||||
var errors = _studentLogic.Errors;
|
|
||||||
errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить статус у студента {studentName}"));
|
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
|
||||||
{
|
|
||||||
OrderSyncHistoryId = history.Id,
|
|
||||||
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
|
||||||
{
|
|
||||||
OrderSyncHistoryId = history.Id,
|
|
||||||
Information = $"У студента {student} сменился статус на {StudentState.Учится}"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((orderStudentMoveType == OrderStudentMoveType.ОтправитьВАкадем || orderStudentMoveType == OrderStudentMoveType.ПродлитьАкадем)
|
|
||||||
&& student.StudentState != StudentState.Академ)
|
|
||||||
{
|
|
||||||
st.StudentState = StudentState.Академ;
|
|
||||||
student = await _studentLogic.UpdateAsync(st);
|
|
||||||
if (student == null)
|
|
||||||
{
|
|
||||||
var errors = _studentLogic.Errors;
|
|
||||||
errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить статус у студента {studentName}"));
|
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
|
||||||
{
|
|
||||||
OrderSyncHistoryId = history.Id,
|
|
||||||
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
|
||||||
{
|
|
||||||
OrderSyncHistoryId = history.Id,
|
|
||||||
Information = $"У студента {student} сменился статус на {StudentState.Академ}"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (orderStudentMoveType == OrderStudentMoveType.ВосстановитьИзАкадема && student.StudentState != StudentState.Учится)
|
|
||||||
{
|
|
||||||
st.StudentState = StudentState.Учится;
|
|
||||||
student = await _studentLogic.UpdateAsync(st);
|
|
||||||
if (student == null)
|
|
||||||
{
|
|
||||||
var errors = _studentLogic.Errors;
|
|
||||||
errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить статус у студента {studentName}"));
|
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
|
||||||
{
|
|
||||||
OrderSyncHistoryId = history.Id,
|
|
||||||
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
|
||||||
{
|
|
||||||
OrderSyncHistoryId = history.Id,
|
|
||||||
Information = $"У студента {student} сменился статус на {StudentState.Учится}"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((orderStudentMoveType == OrderStudentMoveType.ОтчислитьВСвязиСПереводом || orderStudentMoveType == OrderStudentMoveType.ОтчислитьЗаНевыходСАкадема
|
|
||||||
|| orderStudentMoveType == OrderStudentMoveType.ОтчислитьЗаНеуспевамость || orderStudentMoveType == OrderStudentMoveType.ОтчислитьПоСобственному
|
|
||||||
|| orderStudentMoveType == OrderStudentMoveType.ОтчислитьПоЗавершению) && student.StudentState != StudentState.Отчислен)
|
|
||||||
{
|
|
||||||
st.StudentState = orderStudentMoveType == OrderStudentMoveType.ОтчислитьПоЗавершению ? StudentState.Завершил : StudentState.Отчислен;
|
|
||||||
student = await _studentLogic.UpdateAsync(st);
|
|
||||||
if (student == null)
|
|
||||||
{
|
|
||||||
var errors = _studentLogic.Errors;
|
|
||||||
errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить статус у студента {studentName}"));
|
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
|
||||||
{
|
|
||||||
OrderSyncHistoryId = history.Id,
|
|
||||||
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
|
||||||
{
|
|
||||||
OrderSyncHistoryId = history.Id,
|
|
||||||
Information = $"У студента {student} сменился статус на {(orderStudentMoveType == OrderStudentMoveType.ОтчислитьПоЗавершению ? StudentState.Завершил : StudentState.Отчислен)}"
|
|
||||||
});
|
|
||||||
var result = await _studentLogic.DeleteAsync(new StudentGetBindingModel { Id = student.Id });
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
var errors = _userLogic.Errors;
|
|
||||||
errors.Add(("Ошибка удаления студента", $"Не удалось удалить студента {studentName}"));
|
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
|
||||||
{
|
|
||||||
OrderSyncHistoryId = history.Id,
|
|
||||||
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
result = await _userLogic.DeleteAsync(new UserGetBindingModel { Id = student.UserId });
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
var errors = _userLogic.Errors;
|
|
||||||
errors.Add(("Ошибка удаления пользователя по студенту", $"Не удалось удалить пользователя по студенту {studentName}"));
|
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
|
||||||
{
|
|
||||||
OrderSyncHistoryId = history.Id,
|
|
||||||
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (orderStudentMoveType == OrderStudentMoveType.Восстановить && student.StudentState != StudentState.Учится)
|
|
||||||
{
|
|
||||||
st.StudentState = StudentState.Учится;
|
|
||||||
student = await _studentLogic.UpdateAsync(st);
|
|
||||||
if (student == null)
|
|
||||||
{
|
|
||||||
var errors = _studentLogic.Errors;
|
|
||||||
errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить статус у студента {studentName}"));
|
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
|
||||||
{
|
|
||||||
OrderSyncHistoryId = history.Id,
|
|
||||||
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
|
||||||
{
|
|
||||||
OrderSyncHistoryId = history.Id,
|
|
||||||
Information = $"У студента {student} сменился статус на {StudentState.Учится}"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (orderStudentMoveType == OrderStudentMoveType.УбратьПоПереводу && student.StudentState != StudentState.Ушел)
|
|
||||||
{
|
|
||||||
st.StudentState = StudentState.Ушел;
|
|
||||||
student = await _studentLogic.UpdateAsync(st);
|
|
||||||
if (student == null)
|
|
||||||
{
|
|
||||||
var errors = _studentLogic.Errors;
|
|
||||||
errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить статус у студента {studentName}"));
|
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
|
||||||
{
|
|
||||||
OrderSyncHistoryId = history.Id,
|
|
||||||
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
|
||||||
{
|
|
||||||
OrderSyncHistoryId = history.Id,
|
|
||||||
Information = $"У студента {student} сменился статус на {StudentState.Ушел}"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = $"Добавили запись к приказу {order.OrderNumber} по студенту {student} с формулировкой {info}"
|
Information = $"Добавили запись к приказу {order.OrderNumber} по студенту {student} с формулировкой {info}"
|
||||||
|
@ -9,6 +9,10 @@
|
|||||||
|
|
||||||
public string clericDate { get; set; }
|
public string clericDate { get; set; }
|
||||||
|
|
||||||
|
public string markOfDeletion { get; set; }
|
||||||
|
|
||||||
|
public string markOfApprove { get; set; }
|
||||||
|
|
||||||
public string orderTypeName { get; set; }
|
public string orderTypeName { get; set; }
|
||||||
|
|
||||||
public string orderSubTypeName { get; set; }
|
public string orderSubTypeName { get; set; }
|
||||||
@ -16,5 +20,11 @@
|
|||||||
public string groupNameBefore { get; set; }
|
public string groupNameBefore { get; set; }
|
||||||
|
|
||||||
public string groupNameAfter { get; set; }
|
public string groupNameAfter { get; set; }
|
||||||
|
|
||||||
|
public string dateStart { get; set; }
|
||||||
|
|
||||||
|
public string dateEnd { get; set; }
|
||||||
|
|
||||||
|
public string reason { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -27,11 +27,11 @@ namespace DepartmentBusinessLogic.ViewModels
|
|||||||
|
|
||||||
[ViewModelControlElementProperty("Из группы", ControlType.ControlGuid, MustHaveValue = false, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlStudentGroupList, DepartmentWindowsDesktop")]
|
[ViewModelControlElementProperty("Из группы", ControlType.ControlGuid, MustHaveValue = false, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlStudentGroupList, DepartmentWindowsDesktop")]
|
||||||
[MapConfiguration("StudentGroupFromId")]
|
[MapConfiguration("StudentGroupFromId")]
|
||||||
public Guid StudentGroupFromId { get; set; }
|
public Guid? StudentGroupFromId { get; set; }
|
||||||
|
|
||||||
[ViewModelControlElementProperty("В группу", ControlType.ControlGuid, MustHaveValue = false, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlStudentGroupList, DepartmentWindowsDesktop")]
|
[ViewModelControlElementProperty("В группу", ControlType.ControlGuid, MustHaveValue = false, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlStudentGroupList, DepartmentWindowsDesktop")]
|
||||||
[MapConfiguration("StudentGroupToId")]
|
[MapConfiguration("StudentGroupToId")]
|
||||||
public Guid StudentGroupToId { get; set; }
|
public Guid? StudentGroupToId { get; set; }
|
||||||
|
|
||||||
[ViewModelControlElementProperty("Тип приказа", ControlType.ControlEnum, MustHaveValue = true)]
|
[ViewModelControlElementProperty("Тип приказа", ControlType.ControlEnum, MustHaveValue = true)]
|
||||||
[MapConfiguration("OrderStudentMoveType")]
|
[MapConfiguration("OrderStudentMoveType")]
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using ModuleTools.Attributes;
|
using ModuleTools.Attributes;
|
||||||
using ModuleTools.Enums;
|
using ModuleTools.Enums;
|
||||||
using ModuleTools.ViewModels;
|
using ModuleTools.ViewModels;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace DepartmentBusinessLogic.ViewModels
|
namespace DepartmentBusinessLogic.ViewModels
|
||||||
{
|
{
|
||||||
@ -17,14 +18,11 @@ namespace DepartmentBusinessLogic.ViewModels
|
|||||||
ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlOrderSyncHistoryRecordList, DepartmentWindowsDesktop")]
|
ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlOrderSyncHistoryRecordList, DepartmentWindowsDesktop")]
|
||||||
public class OrderSyncHistoryViewModel : ElementViewModel
|
public class OrderSyncHistoryViewModel : ElementViewModel
|
||||||
{
|
{
|
||||||
[ViewModelControlListProperty("Дата", ColumnWidth = 100, DefaultCellStyleFormat = "dd.MM.yyyy")]
|
|
||||||
[ViewModelControlElementProperty("Дата", ControlType.ControlDateTime, MustHaveValue = true, ReadOnly = true)]
|
[ViewModelControlElementProperty("Дата", ControlType.ControlDateTime, MustHaveValue = true, ReadOnly = true)]
|
||||||
[MapConfiguration("SyncDate")]
|
[MapConfiguration("SyncDate")]
|
||||||
public string SyncDate { get; set; }
|
public DateTime SyncDate { get; set; }
|
||||||
|
|
||||||
[ViewModelControlListProperty("События")]
|
[ViewModelControlListProperty("Дата")]
|
||||||
[ViewModelControlElementProperty("События", ControlType.ControlText, MustHaveValue = true, ReadOnly = true, Width = 300, Height = 500)]
|
public string SyncDateTitle => $"Синхронизация данных от {SyncDate.ToString("dd.MM.yyyy HH:mm")}";
|
||||||
[MapConfiguration("History")]
|
|
||||||
public string History { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,11 +14,9 @@ namespace DepartmentBusinessLogic.ViewModels
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Элемент учебная группа
|
/// Элемент учебная группа
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewModelControlElementClass(HaveDependenceEntities = true, Width = 800, Height = 500)]
|
[ViewModelControlElementClass(HaveDependenceEntities = true, Width = 1000, Height = 900)]
|
||||||
[ViewModelControlElementDependenceEntity(Title = "Студенты", Order = 1, ParentPropertyName = "StudentGroupId",
|
[ViewModelControlElementDependenceEntity(Title = "Студенты", Order = 1, ParentPropertyName = "StudentGroupId",
|
||||||
ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlStudentList, DepartmentWindowsDesktop")]
|
ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlStudentList, DepartmentWindowsDesktop")]
|
||||||
[ViewModelControlElementDependenceEntity(Title = "Приказы", Order = 1, ParentPropertyName = "StudentGroupId",
|
|
||||||
ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlOrderStudentRecordList, DepartmentWindowsDesktop")]
|
|
||||||
public class StudentGroupViewModel : ElementViewModel
|
public class StudentGroupViewModel : ElementViewModel
|
||||||
{
|
{
|
||||||
[ViewModelControlElementProperty("Направление", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEducationDirectionList, DepartmentWindowsDesktop")]
|
[ViewModelControlElementProperty("Направление", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEducationDirectionList, DepartmentWindowsDesktop")]
|
||||||
@ -51,6 +49,10 @@ namespace DepartmentBusinessLogic.ViewModels
|
|||||||
[MapConfiguration("GroupNumber")]
|
[MapConfiguration("GroupNumber")]
|
||||||
public int GroupNumber { get; set; }
|
public int GroupNumber { get; set; }
|
||||||
|
|
||||||
|
[ViewModelControlListProperty("Количество студентов")]
|
||||||
|
[MapConfiguration("Students.Count", IsDifficle = true)]
|
||||||
|
public int StudentCount { get; set; }
|
||||||
|
|
||||||
[ViewModelControlElementProperty("Куратор", ControlType.ControlGuid, MustHaveValue = false, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlLecturerList, DepartmentWindowsDesktop")]
|
[ViewModelControlElementProperty("Куратор", ControlType.ControlGuid, MustHaveValue = false, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlLecturerList, DepartmentWindowsDesktop")]
|
||||||
[MapConfiguration("LecturerId")]
|
[MapConfiguration("LecturerId")]
|
||||||
public Guid? LecturerId { get; set; }
|
public Guid? LecturerId { get; set; }
|
||||||
|
@ -51,7 +51,7 @@ namespace DepartmentDatabaseImplementation.Implementations
|
|||||||
|
|
||||||
protected override bool AdditionalCheckForSingleGet(OrderGetBindingModel model)
|
protected override bool AdditionalCheckForSingleGet(OrderGetBindingModel model)
|
||||||
{
|
{
|
||||||
if (model.OrderDate.HasValue && model.OrderNumber.IsNotEmpty())
|
if (model.OrderNumber.IsNotEmpty())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -60,9 +60,9 @@ namespace DepartmentDatabaseImplementation.Implementations
|
|||||||
|
|
||||||
protected override Order GetSingleRecord(IQueryable<Order> list, OrderGetBindingModel model)
|
protected override Order GetSingleRecord(IQueryable<Order> list, OrderGetBindingModel model)
|
||||||
{
|
{
|
||||||
if (model.OrderDate.HasValue && model.OrderNumber.IsNotEmpty())
|
if (model.OrderNumber.IsNotEmpty())
|
||||||
{
|
{
|
||||||
return list.FirstOrDefault(x => x.OrderDate == model.OrderDate && x.OrderNumber == model.OrderNumber);
|
return list.FirstOrDefault(x => x.OrderNumber == model.OrderNumber);
|
||||||
}
|
}
|
||||||
return base.GetSingleRecord(list, model);
|
return base.GetSingleRecord(list, model);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ namespace DepartmentDatabaseImplementation.Implementations
|
|||||||
|
|
||||||
protected override bool AdditionalCheckForSingleGet(OrderStudentRecordGetBindingModel model)
|
protected override bool AdditionalCheckForSingleGet(OrderStudentRecordGetBindingModel model)
|
||||||
{
|
{
|
||||||
if (model.OrderId.HasValue && model.StudentId.HasValue)
|
if (model.OrderId.HasValue && model.StudentId.HasValue && model.OrderStudentMoveType.HasValue)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -58,9 +58,9 @@ namespace DepartmentDatabaseImplementation.Implementations
|
|||||||
|
|
||||||
protected override OrderStudentRecord GetSingleRecord(IQueryable<OrderStudentRecord> list, OrderStudentRecordGetBindingModel model)
|
protected override OrderStudentRecord GetSingleRecord(IQueryable<OrderStudentRecord> list, OrderStudentRecordGetBindingModel model)
|
||||||
{
|
{
|
||||||
if (model.OrderId.HasValue && model.StudentId.HasValue)
|
if (model.OrderId.HasValue && model.StudentId.HasValue && model.OrderStudentMoveType.HasValue)
|
||||||
{
|
{
|
||||||
return list.FirstOrDefault(x => x.OrderId == model.OrderId && x.StudentId == model.StudentId);
|
return list.FirstOrDefault(x => x.OrderId == model.OrderId && x.StudentId == model.StudentId && x.OrderStudentMoveType == (int)model.OrderStudentMoveType);
|
||||||
}
|
}
|
||||||
return base.GetSingleRecord(list, model);
|
return base.GetSingleRecord(list, model);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ using ModuleTools.Enums;
|
|||||||
using ModuleTools.Models;
|
using ModuleTools.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DepartmentDatabaseImplementation.Implementations
|
namespace DepartmentDatabaseImplementation.Implementations
|
||||||
{
|
{
|
||||||
@ -18,17 +17,17 @@ namespace DepartmentDatabaseImplementation.Implementations
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class OrderSyncHistoryRecordService : IOrderSyncHistoryRecordService
|
public class OrderSyncHistoryRecordService : IOrderSyncHistoryRecordService
|
||||||
{
|
{
|
||||||
public async Task<OperationResultModel> CreateAsync(OrderSyncHistoryRecordSetBindingModel model)
|
public OperationResultModel Create(OrderSyncHistoryRecordSetBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = DatabaseManager.GetContext;
|
using var context = DatabaseManager.GetContext;
|
||||||
|
|
||||||
var entity = Mapper.MapToClass<OrderSyncHistoryRecordSetBindingModel, OrderSyncHistoryRecord>(model, true);
|
var entity = Mapper.MapToClass<OrderSyncHistoryRecordSetBindingModel, OrderSyncHistoryRecord>(model, true);
|
||||||
await context.OrderSyncHistoryRecords.AddAsync(entity);
|
context.OrderSyncHistoryRecords.Add(entity);
|
||||||
await context.SaveChangesAsync();
|
context.SaveChanges();
|
||||||
return OperationResultModel.Success(Mapper.MapToClass<OrderSyncHistoryRecord, OrderSyncHistoryRecordViewModel>(entity, true));
|
return OperationResultModel.Success(Mapper.MapToClass<OrderSyncHistoryRecord, OrderSyncHistoryRecordViewModel>(entity, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<OperationResultModel> DeleteAsync(OrderSyncHistoryRecordGetBindingModel model)
|
public OperationResultModel Delete(OrderSyncHistoryRecordGetBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = DatabaseManager.GetContext;
|
using var context = DatabaseManager.GetContext;
|
||||||
var entity = context.OrderSyncHistoryRecords.FirstOrDefault(x => x.Id == model.Id);
|
var entity = context.OrderSyncHistoryRecords.FirstOrDefault(x => x.Id == model.Id);
|
||||||
@ -37,12 +36,12 @@ namespace DepartmentDatabaseImplementation.Implementations
|
|||||||
return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound);
|
return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound);
|
||||||
}
|
}
|
||||||
context.OrderSyncHistoryRecords.Remove(entity);
|
context.OrderSyncHistoryRecords.Remove(entity);
|
||||||
await context.SaveChangesAsync();
|
context.SaveChanges();
|
||||||
|
|
||||||
return OperationResultModel.Success(true);
|
return OperationResultModel.Success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<OperationResultModel> ReadAsync(OrderSyncHistoryRecordGetBindingModel model)
|
public OperationResultModel Read(OrderSyncHistoryRecordGetBindingModel model)
|
||||||
{
|
{
|
||||||
int countPages = 0;
|
int countPages = 0;
|
||||||
using var context = DatabaseManager.GetContext;
|
using var context = DatabaseManager.GetContext;
|
||||||
@ -69,8 +68,6 @@ namespace DepartmentDatabaseImplementation.Implementations
|
|||||||
|
|
||||||
query = query.Include(x => x.OrderSyncHistory);
|
query = query.Include(x => x.OrderSyncHistory);
|
||||||
|
|
||||||
return await Task.Run(() =>
|
|
||||||
{
|
|
||||||
if (model.PageNumber.HasValue && model.PageSize.HasValue)
|
if (model.PageNumber.HasValue && model.PageSize.HasValue)
|
||||||
{
|
{
|
||||||
countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value);
|
countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value);
|
||||||
@ -85,15 +82,14 @@ namespace DepartmentDatabaseImplementation.Implementations
|
|||||||
};
|
};
|
||||||
|
|
||||||
return OperationResultModel.Success(result);
|
return OperationResultModel.Success(result);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<OperationResultModel> RestoreAsync(OrderSyncHistoryRecordGetBindingModel model)
|
public OperationResultModel Restore(OrderSyncHistoryRecordGetBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<OperationResultModel> UpdateAsync(OrderSyncHistoryRecordSetBindingModel model)
|
public OperationResultModel Update(OrderSyncHistoryRecordSetBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = DatabaseManager.GetContext;
|
using var context = DatabaseManager.GetContext;
|
||||||
|
|
||||||
@ -104,7 +100,7 @@ namespace DepartmentDatabaseImplementation.Implementations
|
|||||||
}
|
}
|
||||||
entity = Mapper.MapToClass(model, entity, true);
|
entity = Mapper.MapToClass(model, entity, true);
|
||||||
|
|
||||||
await context.SaveChangesAsync();
|
context.SaveChanges();
|
||||||
|
|
||||||
return OperationResultModel.Success(Mapper.MapToClass<OrderSyncHistoryRecord, OrderSyncHistoryRecordViewModel>(entity, true));
|
return OperationResultModel.Success(Mapper.MapToClass<OrderSyncHistoryRecord, OrderSyncHistoryRecordViewModel>(entity, true));
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ using ModuleTools.Enums;
|
|||||||
using ModuleTools.Models;
|
using ModuleTools.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DepartmentDatabaseImplementation.Implementations
|
namespace DepartmentDatabaseImplementation.Implementations
|
||||||
{
|
{
|
||||||
@ -17,17 +16,17 @@ namespace DepartmentDatabaseImplementation.Implementations
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class OrderSyncHistoryService : IOrderSyncHistoryService
|
public class OrderSyncHistoryService : IOrderSyncHistoryService
|
||||||
{
|
{
|
||||||
public async Task<OperationResultModel> CreateAsync(OrderSyncHistorySetBindingModel model)
|
public OperationResultModel Create(OrderSyncHistorySetBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = DatabaseManager.GetContext;
|
using var context = DatabaseManager.GetContext;
|
||||||
|
|
||||||
var entity = Mapper.MapToClass<OrderSyncHistorySetBindingModel, OrderSyncHistory>(model, true);
|
var entity = Mapper.MapToClass<OrderSyncHistorySetBindingModel, OrderSyncHistory>(model, true);
|
||||||
await context.OrderSyncHistories.AddAsync(entity);
|
context.OrderSyncHistories.Add(entity);
|
||||||
await context.SaveChangesAsync();
|
context.SaveChanges();
|
||||||
return OperationResultModel.Success(Mapper.MapToClass<OrderSyncHistory, OrderSyncHistoryViewModel>(entity, true));
|
return OperationResultModel.Success(Mapper.MapToClass<OrderSyncHistory, OrderSyncHistoryViewModel>(entity, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<OperationResultModel> DeleteAsync(OrderSyncHistoryGetBindingModel model)
|
public OperationResultModel Delete(OrderSyncHistoryGetBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = DatabaseManager.GetContext;
|
using var context = DatabaseManager.GetContext;
|
||||||
using var transaction = context.Database.BeginTransaction();
|
using var transaction = context.Database.BeginTransaction();
|
||||||
@ -40,24 +39,24 @@ namespace DepartmentDatabaseImplementation.Implementations
|
|||||||
}
|
}
|
||||||
|
|
||||||
context.OrderSyncHistories.Remove(entity);
|
context.OrderSyncHistories.Remove(entity);
|
||||||
await context.SaveChangesAsync();
|
context.SaveChanges();
|
||||||
|
|
||||||
var records = context.OrderSyncHistoryRecords.Where(x => x.OrderSyncHistoryId == model.Id);
|
var records = context.OrderSyncHistoryRecords.Where(x => x.OrderSyncHistoryId == model.Id);
|
||||||
context.OrderSyncHistoryRecords.RemoveRange(records);
|
context.OrderSyncHistoryRecords.RemoveRange(records);
|
||||||
await context.SaveChangesAsync();
|
context.SaveChanges();
|
||||||
|
|
||||||
await transaction.CommitAsync();
|
transaction.Commit();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
await transaction.RollbackAsync();
|
transaction.Rollback();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OperationResultModel.Success(true);
|
return OperationResultModel.Success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<OperationResultModel> ReadAsync(OrderSyncHistoryGetBindingModel model)
|
public OperationResultModel Read(OrderSyncHistoryGetBindingModel model)
|
||||||
{
|
{
|
||||||
int countPages = 0;
|
int countPages = 0;
|
||||||
using var context = DatabaseManager.GetContext;
|
using var context = DatabaseManager.GetContext;
|
||||||
@ -77,8 +76,6 @@ namespace DepartmentDatabaseImplementation.Implementations
|
|||||||
|
|
||||||
query = query.OrderByDescending(x => x.SyncDate);
|
query = query.OrderByDescending(x => x.SyncDate);
|
||||||
|
|
||||||
return await Task.Run(() =>
|
|
||||||
{
|
|
||||||
if (model.PageNumber.HasValue && model.PageSize.HasValue)
|
if (model.PageNumber.HasValue && model.PageSize.HasValue)
|
||||||
{
|
{
|
||||||
countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value);
|
countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value);
|
||||||
@ -93,15 +90,14 @@ namespace DepartmentDatabaseImplementation.Implementations
|
|||||||
};
|
};
|
||||||
|
|
||||||
return OperationResultModel.Success(result);
|
return OperationResultModel.Success(result);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<OperationResultModel> RestoreAsync(OrderSyncHistoryGetBindingModel model)
|
public OperationResultModel Restore(OrderSyncHistoryGetBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<OperationResultModel> UpdateAsync(OrderSyncHistorySetBindingModel model)
|
public OperationResultModel Update(OrderSyncHistorySetBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = DatabaseManager.GetContext;
|
using var context = DatabaseManager.GetContext;
|
||||||
|
|
||||||
@ -112,7 +108,7 @@ namespace DepartmentDatabaseImplementation.Implementations
|
|||||||
}
|
}
|
||||||
entity = Mapper.MapToClass(model, entity, true);
|
entity = Mapper.MapToClass(model, entity, true);
|
||||||
|
|
||||||
await context.SaveChangesAsync();
|
context.SaveChanges();
|
||||||
|
|
||||||
return OperationResultModel.Success(Mapper.MapToClass<OrderSyncHistory, OrderSyncHistoryViewModel>(entity, true));
|
return OperationResultModel.Success(Mapper.MapToClass<OrderSyncHistory, OrderSyncHistoryViewModel>(entity, true));
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ namespace DepartmentDatabaseImplementation.Implementations
|
|||||||
|
|
||||||
protected override StudentGroup GetUniqueEntity(StudentGroupSetBindingModel model, DbContext context) => context.Set<StudentGroup>().FirstOrDefault(x => x.EducationDirectionId == model.EducationDirectionId && x.AcademicCourse == (int)model.AcademicCourse && x.GroupNumber == model.GroupNumber && x.Id != model.Id);
|
protected override StudentGroup GetUniqueEntity(StudentGroupSetBindingModel model, DbContext context) => context.Set<StudentGroup>().FirstOrDefault(x => x.EducationDirectionId == model.EducationDirectionId && x.AcademicCourse == (int)model.AcademicCourse && x.GroupNumber == model.GroupNumber && x.Id != model.Id);
|
||||||
|
|
||||||
protected override IQueryable<StudentGroup> IncludingWhenReading(IQueryable<StudentGroup> query) => query.Include(x => x.EducationDirection).Include(x => x.Lecturer);
|
protected override IQueryable<StudentGroup> IncludingWhenReading(IQueryable<StudentGroup> query) => query.Include(x => x.EducationDirection).Include(x => x.Lecturer).Include(x => x.Students);
|
||||||
|
|
||||||
protected override IQueryable<StudentGroup> OrderingWhenReading(IQueryable<StudentGroup> query) => query.OrderBy(x => x.EducationDirection.Cipher).ThenBy(x => x.AcademicCourse).ThenBy(x => x.GroupNumber);
|
protected override IQueryable<StudentGroup> OrderingWhenReading(IQueryable<StudentGroup> query) => query.OrderBy(x => x.EducationDirection.Cipher).ThenBy(x => x.AcademicCourse).ThenBy(x => x.GroupNumber);
|
||||||
}
|
}
|
||||||
|
@ -35,10 +35,12 @@ namespace DepartmentWindowsDesktop.EntityControls
|
|||||||
|
|
||||||
public IControl GetInstanceGenericControl() => new ControlDisciplineList() { ControlId = Guid.NewGuid() };
|
public IControl GetInstanceGenericControl() => new ControlDisciplineList() { ControlId = Guid.NewGuid() };
|
||||||
|
|
||||||
public ControlViewEntityListConfiguration GetConfigControl() => new()
|
public ControlViewEntityListConfiguration GetConfigControl()
|
||||||
|
{
|
||||||
|
return new ControlViewEntityListConfiguration()
|
||||||
{
|
{
|
||||||
PaginationOn = true,
|
PaginationOn = true,
|
||||||
PageNamesForPagination = _disciplineBlockBusinessLogic.GetListAsync(new DisciplineBlockGetBindingModel()).Result?.List?.Select(x =>
|
PageNamesForPagination = _disciplineBlockBusinessLogic.GetList(new DisciplineBlockGetBindingModel())?.List?.Select(x =>
|
||||||
new PageNamesForPaginationModel
|
new PageNamesForPaginationModel
|
||||||
{
|
{
|
||||||
Key = x.Id,
|
Key = x.Id,
|
||||||
@ -46,6 +48,7 @@ namespace DepartmentWindowsDesktop.EntityControls
|
|||||||
})?.ToList(),
|
})?.ToList(),
|
||||||
ParentPropertyName = "DisciplineBlockId"
|
ParentPropertyName = "DisciplineBlockId"
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private void FillSearchPanel()
|
private void FillSearchPanel()
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,6 @@ using SecurityBusinessLogic.BusinessLogics;
|
|||||||
using SecurityBusinessLogic.ViewModels;
|
using SecurityBusinessLogic.ViewModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DepartmentWindowsDesktop.EntityControls
|
namespace DepartmentWindowsDesktop.EntityControls
|
||||||
{
|
{
|
||||||
@ -38,22 +37,22 @@ namespace DepartmentWindowsDesktop.EntityControls
|
|||||||
{
|
{
|
||||||
ControlOnMoveElem = new Dictionary<string, (string Title, EventHandler Event)>
|
ControlOnMoveElem = new Dictionary<string, (string Title, EventHandler Event)>
|
||||||
{
|
{
|
||||||
{ "ToolStripMenuItemAddUser", ("Добавить пользователя", async (object sender, EventArgs e) => { await AddUserAsync(); }) },
|
{ "ToolStripMenuItemAddUser", ("Добавить пользователя", (object sender, EventArgs e) => { AddUser(); }) },
|
||||||
{ "ToolStripMenuItemPasswordReset", ("Сброс пароля пользователя", async (object sender, EventArgs e) => { await PasswordResetAsync(); }) }
|
{ "ToolStripMenuItemPasswordReset", ("Сброс пароля пользователя", (object sender, EventArgs e) => { PasswordReset(); }) }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Поиск пользователя под учетку, либо добавление нового, если не найдено
|
/// Поиск пользователя под учетку, либо добавление нового, если не найдено
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task AddUserAsync()
|
private void AddUser()
|
||||||
{
|
{
|
||||||
var model = new EmployeeSetBindingModel();
|
var model = new EmployeeSetBindingModel();
|
||||||
if (FillModel(model))
|
if (FillModel(model))
|
||||||
{
|
{
|
||||||
var logic = DependencyManager.Instance.Resolve<UserBusinessLogic>();
|
var logic = DependencyManager.Instance.Resolve<UserBusinessLogic>();
|
||||||
var userName = $"{model.LastName}{(model.FirstName.IsNotEmpty() ? $" {model.FirstName[0]}." : string.Empty)}{(model.Patronymic.IsNotEmpty() ? $"{model.Patronymic[0]}." : string.Empty)}";
|
var userName = $"{model.LastName}{(model.FirstName.IsNotEmpty() ? $" {model.FirstName[0]}." : string.Empty)}{(model.Patronymic.IsNotEmpty() ? $"{model.Patronymic[0]}." : string.Empty)}";
|
||||||
var result = await logic.GetListAsync(new UserGetBindingModel { UserNameForSearch = userName });
|
var result = logic.GetList(new UserGetBindingModel { UserNameForSearch = userName });
|
||||||
if (result != null)
|
if (result != null)
|
||||||
{
|
{
|
||||||
if (result.List.Count > 1)
|
if (result.List.Count > 1)
|
||||||
@ -67,7 +66,7 @@ namespace DepartmentWindowsDesktop.EntityControls
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var newuser = await logic.CreateAsync(new UserSetBindingModel
|
var newuser = logic.Create(new UserSetBindingModel
|
||||||
{
|
{
|
||||||
Login = userName,
|
Login = userName,
|
||||||
Password = model.DateBirth.ToShortDateString(),
|
Password = model.DateBirth.ToShortDateString(),
|
||||||
@ -92,7 +91,7 @@ namespace DepartmentWindowsDesktop.EntityControls
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сброс пароля пользователя
|
/// Сброс пароля пользователя
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task PasswordResetAsync()
|
private void PasswordReset()
|
||||||
{
|
{
|
||||||
if (_element == null)
|
if (_element == null)
|
||||||
{
|
{
|
||||||
@ -102,14 +101,14 @@ namespace DepartmentWindowsDesktop.EntityControls
|
|||||||
if (FillModel(model))
|
if (FillModel(model))
|
||||||
{
|
{
|
||||||
var logic = DependencyManager.Instance.Resolve<UserBusinessLogic>();
|
var logic = DependencyManager.Instance.Resolve<UserBusinessLogic>();
|
||||||
var user = await logic.GetElementAsync(new UserGetBindingModel { Id = _element.UserId });
|
var user = logic.GetElement(new UserGetBindingModel { Id = _element.UserId });
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
DialogHelper.MessageException(logic.Errors, "Ошибка при получении пользователя");
|
DialogHelper.MessageException(logic.Errors, "Ошибка при получении пользователя");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
user.Password = model.DateBirth.ToShortDateString();
|
user.Password = model.DateBirth.ToShortDateString();
|
||||||
user = await logic.UpdateAsync(Mapper.MapToClass<UserViewModel, UserSetBindingModel>(user, true));
|
user = logic.Update(Mapper.MapToClass<UserViewModel, UserSetBindingModel>(user, true));
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
DialogHelper.MessageException(logic.Errors, "Ошибка при получении пользователя");
|
DialogHelper.MessageException(logic.Errors, "Ошибка при получении пользователя");
|
||||||
|
@ -13,7 +13,6 @@ using SecurityBusinessLogic.BusinessLogics;
|
|||||||
using SecurityBusinessLogic.ViewModels;
|
using SecurityBusinessLogic.ViewModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DepartmentWindowsDesktop.EntityControls
|
namespace DepartmentWindowsDesktop.EntityControls
|
||||||
{
|
{
|
||||||
@ -38,22 +37,22 @@ namespace DepartmentWindowsDesktop.EntityControls
|
|||||||
{
|
{
|
||||||
ControlOnMoveElem = new Dictionary<string, (string Title, EventHandler Event)>
|
ControlOnMoveElem = new Dictionary<string, (string Title, EventHandler Event)>
|
||||||
{
|
{
|
||||||
{ "ToolStripMenuItemAddUser", ("Добавить пользователя", async (object sender, EventArgs e) => { await AddUserAsunc(); }) },
|
{ "ToolStripMenuItemAddUser", ("Добавить пользователя", (object sender, EventArgs e) => { AddUser(); }) },
|
||||||
{ "ToolStripMenuItemPasswordReset", ("Сброс пароля пользователя", async (object sender, EventArgs e) => { await PasswordResetAsync(); }) }
|
{ "ToolStripMenuItemPasswordReset", ("Сброс пароля пользователя", (object sender, EventArgs e) => { PasswordReset(); }) }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Поиск пользователя под учетку, либо добавление нового, если не найдено
|
/// Поиск пользователя под учетку, либо добавление нового, если не найдено
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task AddUserAsunc()
|
private void AddUser()
|
||||||
{
|
{
|
||||||
var model = new LecturerSetBindingModel();
|
var model = new LecturerSetBindingModel();
|
||||||
if (FillModel(model))
|
if (FillModel(model))
|
||||||
{
|
{
|
||||||
var logic = DependencyManager.Instance.Resolve<UserBusinessLogic>();
|
var logic = DependencyManager.Instance.Resolve<UserBusinessLogic>();
|
||||||
var userName = $"{model.LastName}{(model.FirstName.IsNotEmpty() ? $" {model.FirstName[0]}." : string.Empty)}{(model.Patronymic.IsNotEmpty() ? $"{model.Patronymic[0]}." : string.Empty)}";
|
var userName = $"{model.LastName}{(model.FirstName.IsNotEmpty() ? $" {model.FirstName[0]}." : string.Empty)}{(model.Patronymic.IsNotEmpty() ? $"{model.Patronymic[0]}." : string.Empty)}";
|
||||||
var result = await logic.GetListAsync(new UserGetBindingModel { UserNameForSearch = userName });
|
var result = logic.GetList(new UserGetBindingModel { UserNameForSearch = userName });
|
||||||
if (result != null)
|
if (result != null)
|
||||||
{
|
{
|
||||||
if (result.List.Count > 1)
|
if (result.List.Count > 1)
|
||||||
@ -67,7 +66,7 @@ namespace DepartmentWindowsDesktop.EntityControls
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var newuser = await logic.CreateAsync(new UserSetBindingModel
|
var newuser = logic.Create(new UserSetBindingModel
|
||||||
{
|
{
|
||||||
Login = userName,
|
Login = userName,
|
||||||
Password = model.DateBirth.ToShortDateString(),
|
Password = model.DateBirth.ToShortDateString(),
|
||||||
@ -92,7 +91,7 @@ namespace DepartmentWindowsDesktop.EntityControls
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сброс пароля пользователя
|
/// Сброс пароля пользователя
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task PasswordResetAsync()
|
private void PasswordReset()
|
||||||
{
|
{
|
||||||
if (_element == null)
|
if (_element == null)
|
||||||
{
|
{
|
||||||
@ -102,14 +101,14 @@ namespace DepartmentWindowsDesktop.EntityControls
|
|||||||
if (FillModel(model))
|
if (FillModel(model))
|
||||||
{
|
{
|
||||||
var logic = DependencyManager.Instance.Resolve<UserBusinessLogic>();
|
var logic = DependencyManager.Instance.Resolve<UserBusinessLogic>();
|
||||||
var user = await logic.GetElementAsync(new UserGetBindingModel { Id = _element.UserId });
|
var user = logic.GetElement(new UserGetBindingModel { Id = _element.UserId });
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
DialogHelper.MessageException(logic.Errors, "Ошибка при получении пользователя");
|
DialogHelper.MessageException(logic.Errors, "Ошибка при получении пользователя");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
user.Password = model.DateBirth.ToShortDateString();
|
user.Password = model.DateBirth.ToShortDateString();
|
||||||
user = await logic.UpdateAsync(Mapper.MapToClass<UserViewModel, UserSetBindingModel>(user, true));
|
user = logic.Update(Mapper.MapToClass<UserViewModel, UserSetBindingModel>(user, true));
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
DialogHelper.MessageException(logic.Errors, "Ошибка при получении пользователя");
|
DialogHelper.MessageException(logic.Errors, "Ошибка при получении пользователя");
|
||||||
|
@ -22,7 +22,7 @@ namespace DepartmentWindowsDesktop.EntityControls
|
|||||||
Title = "Приказы";
|
Title = "Приказы";
|
||||||
ControlId = new Guid("1aa8cf1f-96b0-47aa-bd20-d1563d840534");
|
ControlId = new Guid("1aa8cf1f-96b0-47aa-bd20-d1563d840534");
|
||||||
AccessOperation = AccessOperation.Приказы;
|
AccessOperation = AccessOperation.Приказы;
|
||||||
ControlViewEntityElement = new ControlOrderElement();
|
ControlViewEntityElement = new ControlOrderStudentRecordElement();
|
||||||
_genericControlViewEntityList = this;
|
_genericControlViewEntityList = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ using DesktopTools.Models;
|
|||||||
using ModuleTools.Enums;
|
using ModuleTools.Enums;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DepartmentWindowsDesktop.EntityControls
|
namespace DepartmentWindowsDesktop.EntityControls
|
||||||
{
|
{
|
||||||
@ -26,7 +25,7 @@ namespace DepartmentWindowsDesktop.EntityControls
|
|||||||
Title = "Синхронизация Приказов";
|
Title = "Синхронизация Приказов";
|
||||||
ControlId = new Guid("7b857c17-405e-40fb-961f-7fe74fddf84e");
|
ControlId = new Guid("7b857c17-405e-40fb-961f-7fe74fddf84e");
|
||||||
AccessOperation = AccessOperation.СинхронизацияПриказов;
|
AccessOperation = AccessOperation.СинхронизацияПриказов;
|
||||||
ControlViewEntityElement = new ControlPostElement();
|
ControlViewEntityElement = new ControlOrderSyncHistoryElement();
|
||||||
_genericControlViewEntityList = this;
|
_genericControlViewEntityList = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +43,7 @@ namespace DepartmentWindowsDesktop.EntityControls
|
|||||||
},
|
},
|
||||||
ControlOnMoveElem = new()
|
ControlOnMoveElem = new()
|
||||||
{
|
{
|
||||||
{ "ToolStripMenuItemSyncOrders", ("Синхронизировать студентов", async (object sender, EventArgs e) => { await SyncOrders(); }) }
|
{ "ToolStripMenuItemSyncOrders", ("Синхронизировать студентов", (object sender, EventArgs e) => { SyncOrders(); }) }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -52,13 +51,17 @@ namespace DepartmentWindowsDesktop.EntityControls
|
|||||||
/// Синхронизация приказов
|
/// Синхронизация приказов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private async Task SyncOrders()
|
private void SyncOrders()
|
||||||
{
|
{
|
||||||
var flag = await _businessLogic.SyncOrders();
|
var flag = _businessLogic.SyncOrders();
|
||||||
if (!flag)
|
if (!flag)
|
||||||
{
|
{
|
||||||
DialogHelper.MessageException(_businessLogic.Errors, "Ошибки при синхронизации");
|
DialogHelper.MessageException(_businessLogic.Errors, "Ошибки при синхронизации");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DialogHelper.MessageInformation("Завершено успешно", "Синхронизация приказов");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,7 +24,7 @@ namespace DepartmentWindowsDesktop.EntityControls
|
|||||||
Title = "Записи Синхронизации Приказов";
|
Title = "Записи Синхронизации Приказов";
|
||||||
ControlId = new Guid("8d18e9fa-f056-47c8-b83d-f06f6bf553c2");
|
ControlId = new Guid("8d18e9fa-f056-47c8-b83d-f06f6bf553c2");
|
||||||
AccessOperation = AccessOperation.СинхронизацияПриказов;
|
AccessOperation = AccessOperation.СинхронизацияПриказов;
|
||||||
ControlViewEntityElement = new ControlPostElement();
|
ControlViewEntityElement = new ControlOrderSyncHistoryRecordElement();
|
||||||
_genericControlViewEntityList = this;
|
_genericControlViewEntityList = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ using SecurityBusinessLogic.BusinessLogics;
|
|||||||
using SecurityBusinessLogic.ViewModels;
|
using SecurityBusinessLogic.ViewModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DepartmentWindowsDesktop.EntityControls
|
namespace DepartmentWindowsDesktop.EntityControls
|
||||||
{
|
{
|
||||||
@ -38,48 +37,42 @@ namespace DepartmentWindowsDesktop.EntityControls
|
|||||||
{
|
{
|
||||||
ControlOnMoveElem = new Dictionary<string, (string Title, EventHandler Event)>
|
ControlOnMoveElem = new Dictionary<string, (string Title, EventHandler Event)>
|
||||||
{
|
{
|
||||||
{ "ToolStripMenuItemAddUser", ("Добавить пользователя", async (object sender, EventArgs e) => { await AddUserAsync(); }) },
|
{ "ToolStripMenuItemAddUser", ("Добавить пользователя", (object sender, EventArgs e) => { AddUser(); }) },
|
||||||
{ "ToolStripMenuItemPasswordReset", ("Сброс пароля пользователя", async (object sender, EventArgs e) => { await PasswordResetAsync(); }) }
|
{ "ToolStripMenuItemPasswordReset", ("Сброс пароля пользователя", (object sender, EventArgs e) => { PasswordReset(); }) }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Поиск пользователя под учетку, либо добавление нового, если не найдено
|
/// Поиск пользователя под учетку, либо добавление нового, если не найдено
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task AddUserAsync()
|
private void AddUser()
|
||||||
{
|
{
|
||||||
var model = new StudentSetBindingModel();
|
var model = new StudentSetBindingModel();
|
||||||
if (FillModel(model))
|
if (FillModel(model))
|
||||||
{
|
{
|
||||||
var logic = DependencyManager.Instance.Resolve<UserBusinessLogic>();
|
var logic = DependencyManager.Instance.Resolve<UserBusinessLogic>();
|
||||||
var userName = $"{model.LastName}{(model.FirstName.IsNotEmpty() ? $" {model.FirstName[0]}." : string.Empty)}{(model.Patronymic.IsNotEmpty() ? $"{model.Patronymic[0]}." : string.Empty)}";
|
var userName = $"{model.LastName}{(model.FirstName.IsNotEmpty() ? $" {model.FirstName[0]}." : string.Empty)}{(model.Patronymic.IsNotEmpty() ? $"{model.Patronymic[0]}." : string.Empty)}";
|
||||||
var result = await logic.GetListAsync(new UserGetBindingModel { UserNameForSearch = userName });
|
var user = logic.GetElement(new UserGetBindingModel { Login = model.NumberOfBook });
|
||||||
if (result != null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
if (result.List.Count > 1)
|
if (logic.Errors.Count > 0)
|
||||||
{
|
|
||||||
DialogHelper.MessageException("Существует несколько пользователей с такой сигнатурой", "Ошибка");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (result.List.Count == 1)
|
|
||||||
{
|
|
||||||
model.UserId = result.List[0].Id;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var newuser = await logic.CreateAsync(new UserSetBindingModel
|
|
||||||
{
|
|
||||||
Login = userName,
|
|
||||||
Password = model.NumberOfBook,
|
|
||||||
Avatar = model.Photo
|
|
||||||
});
|
|
||||||
if (newuser == null)
|
|
||||||
{
|
{
|
||||||
DialogHelper.MessageException(logic.Errors, "Ошибка при создании пользователя");
|
DialogHelper.MessageException(logic.Errors, "Ошибка при создании пользователя");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
model.UserId = newuser.Id;
|
user = logic.Create(new UserSetBindingModel
|
||||||
|
{
|
||||||
|
Login = model.NumberOfBook,
|
||||||
|
Password = userName,
|
||||||
|
Avatar = model.Photo
|
||||||
|
});
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
DialogHelper.MessageException(logic.Errors, "Ошибка при создании пользователя");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
model.UserId = user.Id;
|
||||||
var controls = tabPageMain.Controls.Find($"ControlUserId", true);
|
var controls = tabPageMain.Controls.Find($"ControlUserId", true);
|
||||||
if (controls != null)
|
if (controls != null)
|
||||||
{
|
{
|
||||||
@ -87,12 +80,11 @@ namespace DepartmentWindowsDesktop.EntityControls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сброс пароля пользователя
|
/// Сброс пароля пользователя
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task PasswordResetAsync()
|
private void PasswordReset()
|
||||||
{
|
{
|
||||||
if (_element == null)
|
if (_element == null)
|
||||||
{
|
{
|
||||||
@ -102,14 +94,14 @@ namespace DepartmentWindowsDesktop.EntityControls
|
|||||||
if (FillModel(model))
|
if (FillModel(model))
|
||||||
{
|
{
|
||||||
var logic = DependencyManager.Instance.Resolve<UserBusinessLogic>();
|
var logic = DependencyManager.Instance.Resolve<UserBusinessLogic>();
|
||||||
var user = await logic.GetElementAsync(new UserGetBindingModel { Id = _element.UserId });
|
var user = logic.GetElement(new UserGetBindingModel { Id = _element.UserId });
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
DialogHelper.MessageException(logic.Errors, "Ошибка при получении пользователя");
|
DialogHelper.MessageException(logic.Errors, "Ошибка при получении пользователя");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
user.Password = model.NumberOfBook;
|
user.Password = model.NumberOfBook;
|
||||||
user = await logic.UpdateAsync(Mapper.MapToClass<UserViewModel, UserSetBindingModel>(user, true));
|
user = logic.Update(Mapper.MapToClass<UserViewModel, UserSetBindingModel>(user, true));
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
DialogHelper.MessageException(logic.Errors, "Ошибка при получении пользователя");
|
DialogHelper.MessageException(logic.Errors, "Ошибка при получении пользователя");
|
||||||
|
@ -11,6 +11,8 @@ namespace SecurityBusinessLogic.BindingModels
|
|||||||
public class UserGetBindingModel : GetBindingModel
|
public class UserGetBindingModel : GetBindingModel
|
||||||
{
|
{
|
||||||
public string UserNameForSearch { get; set; }
|
public string UserNameForSearch { get; set; }
|
||||||
|
|
||||||
|
public string Login { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -74,5 +74,23 @@ namespace SecurityDatabaseImplementation.Implementations
|
|||||||
protected override IQueryable<User> IncludingWhenReading(IQueryable<User> query) => query;
|
protected override IQueryable<User> IncludingWhenReading(IQueryable<User> query) => query;
|
||||||
|
|
||||||
protected override IQueryable<User> OrderingWhenReading(IQueryable<User> query) => query.OrderBy(x => x.UserName);
|
protected override IQueryable<User> OrderingWhenReading(IQueryable<User> query) => query.OrderBy(x => x.UserName);
|
||||||
|
|
||||||
|
protected override bool AdditionalCheckForSingleGet(UserGetBindingModel model)
|
||||||
|
{
|
||||||
|
if (model.Login.IsNotEmpty())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return base.AdditionalCheckForSingleGet(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override User GetSingleRecord(IQueryable<User> list, UserGetBindingModel model)
|
||||||
|
{
|
||||||
|
if (model.Login.IsNotEmpty())
|
||||||
|
{
|
||||||
|
return list.FirstOrDefault(x => x.UserName == model.Login);
|
||||||
|
}
|
||||||
|
return base.GetSingleRecord(list, model);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -39,7 +39,7 @@ namespace SecurityWindowsDesktop.EntityControls
|
|||||||
public ControlViewEntityListConfiguration GetConfigControl() => new()
|
public ControlViewEntityListConfiguration GetConfigControl() => new()
|
||||||
{
|
{
|
||||||
PaginationOn = true,
|
PaginationOn = true,
|
||||||
PageNamesForPagination = _roleBusinessLogic.GetListAsync(new RoleGetBindingModel()).Result?.List?.Select(x =>
|
PageNamesForPagination = _roleBusinessLogic.GetList(new RoleGetBindingModel())?.List?.Select(x =>
|
||||||
new PageNamesForPaginationModel
|
new PageNamesForPaginationModel
|
||||||
{
|
{
|
||||||
Key = x.Id,
|
Key = x.Id,
|
||||||
|
Loading…
Reference in New Issue
Block a user