using PdmSwPlugin.Commmon.Util.UI;
|
using PdmSwPlugin.Common.Entity.DrawAudit;
|
using PdmSwPlugin.Common.Util.Http;
|
using System.ComponentModel;
|
using System.Runtime.CompilerServices;
|
using System.Threading.Tasks;
|
using System.Windows;
|
using log4net;
|
using System;
|
using System.Net.Http;
|
using PdmSwPlugin.Common.Interface;
|
using SolidWorks.Interop.sldworks;
|
using PdmSwPlugin.Common.Util;
|
|
namespace PdmSwPlugin.DrawApprove
|
{
|
/// <summary>
|
/// RejectWindow.xaml 的交互逻辑
|
/// </summary>
|
public partial class RejectWindow : Window, INotifyPropertyChanged, ISwAppSetter
|
{
|
#region ...
|
public virtual event PropertyChangedEventHandler PropertyChanged;
|
|
public virtual void RaisePropertyChanged(string name)
|
{
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
}
|
|
public void RaiseAndSetIfChanged<T>(ref T old, T @new, [CallerMemberName] string propertyName = null)
|
{
|
old = @new;
|
if (propertyName != null)
|
{
|
RaisePropertyChanged(propertyName);
|
}
|
}
|
#endregion
|
|
private string _title;
|
|
public string title
|
{
|
get => _title;
|
set => RaiseAndSetIfChanged(ref _title, value);
|
}
|
|
public SldWorks SwApp => this.swApp;
|
|
private readonly DrawAudit drawInfo;
|
private readonly ILog Logger;
|
private readonly HttpClient Client;
|
private readonly SldWorks swApp;
|
|
|
public RejectWindow(string title, DrawAudit da, HttpClient Client, ILog Logger, SldWorks swApp)
|
{
|
this.title = title ?? string.Empty;
|
drawInfo = da;
|
this.Client = Client;
|
this.Logger = Logger;
|
this.swApp = swApp;
|
DataContext = this;
|
InitializeComponent();
|
}
|
|
private void Ok_Click(object sender, RoutedEventArgs e)
|
{
|
if (string.IsNullOrEmpty(textarea.Text))
|
{
|
this.Warning("请输入驳回原因");
|
return;
|
}
|
string comment = textarea.Text;
|
MaskAdorner.ShowMask(content, "请求中,请稍候...");
|
Task.Run(() =>
|
{
|
try
|
{
|
drawInfo.pass = false;
|
drawInfo.comment = comment;
|
Result<object> res = Client.PostSyncAction<object>(drawInfo, "drawAudit/complete");
|
object obj = res.HandleResult();
|
Dispatcher.Invoke(() =>
|
{
|
DialogResult = true;
|
});
|
}
|
catch (Exception ex)
|
{
|
Logger.Error("Draw complete failed.", ex);
|
this.Error($"驳回失败!{ex.Message}");
|
}
|
finally
|
{
|
MaskAdorner.HideMask(content);
|
}
|
});
|
}
|
|
private void Cancel_Click(object sender, RoutedEventArgs e)
|
{
|
DialogResult = false;
|
}
|
|
public void SetSwApp(SldWorks SwApp)
|
{
|
//throw new NotImplementedException();
|
}
|
}
|
}
|