csharp Invoke.Check
Example.cs
[Invoke]
public bool CheckRsPaymentByID(string strId)
{
ValidationManager.CheckUserValidation();
return this.ObjectContext.RS_PAYMENT.Any(p => p.PAYMENT_ID == strId);
}
csharp SearchLayout.Combo.Dictionary
Example.cs
comboPLAN_TYPE = RadComboBoxExtension.CreateRadComboBoxWithSourceBind<PmPlanMasterFilter, FilterOperation, PmPlanMasterProperty,
HD.SVR.SDM.DataAccess.DataModels.SYS_DICTIONARY>(FilterOperation.IsEqualTo, PmPlanMasterProperty.PLAN_TYPE, StyleList.radComboBox,
s => s.ITEM_NAME, s => s.ITEM_NAME, new List<HD.SVR.SDM.DataAccess.DataModels.SYS_DICTIONARY>(0));
this.searchLayout.AddField<PmPlanMasterFilterData>(p => p.PLAN_TYPE, "", StyleList.dataNullable, comboPLAN_TYPE, "", 1, 1);
csharp Combo.YesNo
Example.cs
validMaster.RegisterValidation<RsTransport>(p => p.USE_FLAG, new RequirementValidation());
var comboUSE_FLAG = RadComboBoxExtension.CreateRadComboBoxWithSourceBind<RsTransport, SystemStatus>(t => t.USE_FLAG, s => s.StatusName,
s => s.StatusID, StyleList.radComboBox, new SystemOption().GetYesOrNoOption, validMaster);
gridLayout.AddField<RsTransport>(p => p.USE_FLAG, "", StyleList.dataNullable, comboUSE_FLAG, "", 1, 1, validMaster);
csharp Page.Edit
Edit.Xaml
<commonData:SecurityPage
xmlns:commonData="clr-namespace:HD.SL.Common.Data.CommonData;assembly=HD.SL.Common.Data"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
x:Class="HD.SL.***Edit"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
d:DesignWidth="640" d:DesignHeight="480"
Title="***Edit Page">
<telerik:RadBusyIndicator x:Name="busyIndicator">
<Grid x:Name="gridLayout" Margin="2,10,2,2">
<StackPanel Orientation="Horizontal" Margin="0,4,0,0" HorizontalAlignment="Right">
<telerik:RadButton x:Name="btnSave" Content="保 存" Width="90" Height="24" Click="btnSave_Click" Margin="0,0,4,0"/>
<telerik:RadButton x:Name="btnClose" Content="关 闭" Width="90" Height="24" Click="btnClose_Click"/>
</StackPanel>
</Grid>
</telerik:RadBusyIndicator>
</commonData:SecurityPage>
Edit.Xaml.cs
using System;
using System.Linq;
using System.Collections.Generic;
using System.Windows;
using HD.SL.Common.Data.CommonData;
using Telerik.Windows.Controls;
using HD.SL.Common.Controls;
using HD.SL.Common.Data.Operation;
using HD.SL.Common.Data.UI.Validation;
using HD.SL.Common.Asset.ResouceLists;
using HD.SVR.RSM.DataAccess.DataServices;
using HD.SL.RSM.DataAccess.DataModels;
using HD.SVR.RSM.DataAccess.DataModels;
namespace HD.SL.RSM.Config.MetaData
{
public partial class TransportEdit : SecurityPage
{
protected static TransportEdit currentObject;
public static TransportEdit GetInstance(string strId)
{
if (currentObject == null)
{
currentObject = new TransportEdit();
currentObject.OnDispose += (sender, e) =>
{
currentObject = null;
};
}
currentObject.InitialPage(strId);
return currentObject;
}
private DBContext ctx;
private ValidationManager validMaster;
private TransportEdit()
{
ctx = new DBContext();
InitializeComponent();
validMaster = new ValidationManager();
#region 设置验证
validMaster.RegisterValidation<RsTransport>(p => p.TRANS_NAME, new RequirementValidation());
validMaster.RegisterValidation<RsTransport>(p => p.USE_FLAG, new RequirementValidation());
#endregion
SmartTextBox txtTRANS_ID = TextBoxExtension.CreateSmartTextBoxWithBind<RsTransport>(p => p.TRANS_ID, StyleList.dataSmartTextBox, validMaster);
txtTRANS_ID.IsReadOnly = true;
SmartTextBox txtTRANS_NAME = TextBoxExtension.CreateSmartTextBoxWithBind<RsTransport>(p => p.TRANS_NAME, StyleList.dataSmartTextBox, validMaster);
var comboUSE_FLAG = RadComboBoxExtension.CreateRadComboBoxWithSourceBind<RsTransport, SystemStatus>(t => t.USE_FLAG, s => s.StatusName,
s => s.StatusID, StyleList.radComboBox, new SystemOption().GetYesOrNoOption, validMaster);
RadNumericUpDown numberTRANS_SEQ = RadNumericUpDownExtension.CreateNumericUpDownWithBind<RsTransport>(p => p.TRANS_SEQ, StyleList.rdNumericUpDown, validMaster);
SmartTextBox txtREMARK = TextBoxExtension.CreateSmartTextBoxWithBind<RsTransport>(p => p.REMARK, StyleList.dataSmartTextBox, validMaster);
gridLayout.AddField<RsTransport>(p => p.TRANS_ID, "", StyleList.dataNullable, txtTRANS_ID, "", 1, 1, validMaster);
gridLayout.AddField<RsTransport>(p => p.TRANS_NAME, "", StyleList.dataNullable, txtTRANS_NAME, "", 1, 1, validMaster);
gridLayout.AddField<RsTransport>(p => p.TRANS_SEQ, "", StyleList.dataNullable, numberTRANS_SEQ, "", 1, 1, validMaster);
gridLayout.AddField<RsTransport>(p => p.USE_FLAG, "", StyleList.dataNullable, comboUSE_FLAG, "", 1, 1, validMaster);
gridLayout.AddField<RsTransport>(p => p.REMARK, "", StyleList.dataNullable, txtREMARK, "", 1, 1, validMaster);
gridLayout.SetLayout(100, 200, 1);
}
private async void InitialPage(string keyCode)
{
this.gridLayout.ClearValError_ForAllChildCtrls();
this.ctx.EntityContainer.Clear();
this.busyIndicator.IsBusy = true;
this.busyIndicator.BusyContent = "正在初始化中...";
await ctx.Load(ctx.GetRsTransportByIDQuery(keyCode)).AsTask();
this.busyIndicator.IsBusy = false;
var m_RS_TRANSPORT = this.ctx.RS_TRANSPORTs.FirstOrDefault();
if (this.CheckValidation(m_RS_TRANSPORT == null, true, "未找到该信息")) return;
var m_RsTransport = new RsTransport();
DataExchange.CopyDataItem<RS_TRANSPORT, RsTransport>(m_RS_TRANSPORT, m_RsTransport);
this.gridLayout.DataContext = m_RsTransport;
}
private async void btnSave_Click(object sender, RoutedEventArgs e)
{
var currentItem = this.gridLayout.DataContext as RsTransport;
if (!validMaster.ValidMasterItem(currentItem)) return;
this.busyIndicator.BusyContent = "正在保存中...";
this.busyIndicator.IsBusy = true;
var m_RS_TRANSPORT = this.ctx.RS_TRANSPORTs.FirstOrDefault();
DataExchange.CopyDataItem<RsTransport, RS_TRANSPORT>(currentItem, m_RS_TRANSPORT);
DataExchange.SetUpdateLog(m_RS_TRANSPORT);
var operationSave = await ctx.SubmitChanges().AsTask();
this.busyIndicator.IsBusy = false;
if (!this.CheckLoadDataArgs(ExceptionManager.CheckDataContextResult(operationSave))) return;
RadWindowExtension.CloseRadWindow(this, true);
}
private void btnClose_Click(object sender, RoutedEventArgs e)
{
RadWindowExtension.CloseRadWindow(this, false);
}
}
}
csharp Page.New
New.Xaml
<commonData:SecurityPage
xmlns:commonData="clr-namespace:HD.SL.Common.Data.CommonData;assembly=HD.SL.Common.Data"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
x:Class="HD.SL.***New"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
d:DesignWidth="640" d:DesignHeight="480"
Title="TransportNew Page">
<telerik:RadBusyIndicator x:Name="busyIndicator" >
<Grid x:Name="gridLayout" Margin="2,10,2,2">
<StackPanel Orientation="Horizontal" Margin="0,4,0,0" HorizontalAlignment="Right">
<telerik:RadButton x:Name="btnCreate" Content="创 建" Width="90" Height="24" Click="btnCreate_Click" Margin="0,0,4,0"/>
<telerik:RadButton x:Name="btnClose" Content="关 闭" Width="90" Height="24" Click="btnClose_Click"/>
</StackPanel>
</Grid>
</telerik:RadBusyIndicator>
</commonData:SecurityPage>
New.Xaml.cs
using System;
using System.Linq;
using System.Collections.Generic;
using System.Windows;
using HD.SL.Common.Data.CommonData;
using Telerik.Windows.Controls;
using HD.SL.Common.Controls;
using HD.SL.Common.Data.Operation;
using HD.SL.Common.Data.UI.Validation;
using HD.SL.Common.Asset.ResouceLists;
using HD.SVR.***.DataAccess.DataServices;
using HD.SL.***.DataAccess.DataModels;
using HD.SVR.***.DataAccess.DataModels;
namespace HD.SL.***
{
public partial class ***New : SecurityPage
{
protected static ***New currentObject;
public static ***New GetInstance()
{
if (currentObject == null)
{
currentObject = new ***New();
currentObject.OnDispose += (sender, e) =>
{
currentObject = null;
};
}
currentObject.InitialPage();
return currentObject;
}
private DBContext ctx;
private ValidationManager validMaster;
private ***New()
{
ctx = new DBContext();
InitializeComponent();
validMaster = new ValidationManager();
#region 设置验证
validMaster.RegisterValidation<RsTransport>(p => p.TRANS_ID, new RequirementValidation());
#endregion
SmartTextBox txtTRANS_ID = TextBoxExtension.CreateSmartTextBoxWithBind<RsTransport>(p => p.TRANS_ID, StyleList.dataSmartTextBox, validMaster);
SmartTextBox txtTRANS_NAME = TextBoxExtension.CreateSmartTextBoxWithBind<RsTransport>(p => p.TRANS_NAME, StyleList.dataSmartTextBox, validMaster);
var comboUSE_FLAG = RadComboBoxExtension.CreateRadComboBoxWithSourceBind<RsTransport, SystemStatus>(t => t.USE_FLAG, s => s.StatusName,
s => s.StatusID, StyleList.radComboBox, new SystemOption().GetYesOrNoOption, validMaster);
RadNumericUpDown numberTRANS_SEQ = RadNumericUpDownExtension.CreateNumericUpDownWithBind<RsTransport>(p => p.TRANS_SEQ, StyleList.rdNumericUpDown, validMaster);
gridLayout.AddField<RsTransport>(p => p.TRANS_ID, "", StyleList.dataNullable, txtTRANS_ID, "", 1, 1, validMaster);
gridLayout.AddField<RsTransport>(p => p.TRANS_NAME, "", StyleList.dataNullable, txtTRANS_NAME, "", 1, 1, validMaster);
gridLayout.AddField<RsTransport>(p => p.TRANS_SEQ, "", StyleList.dataNullable, numberTRANS_SEQ, "", 1, 1, validMaster);
gridLayout.AddField<RsTransport>(p => p.USE_FLAG, "", StyleList.dataNullable, comboUSE_FLAG, "", 1, 1, validMaster);
gridLayout.SetLayout(100, 200, 1);
}
private void InitialPage()
{
this.busyIndicator.IsBusy = false;
this.gridLayout.ClearValError_ForAllChildCtrls();
this.ctx.EntityContainer.Clear();
this.gridLayout.DataContext = new RsTransport();
}
private async void btnCreate_Click(object sender, RoutedEventArgs e)
{
var currentItem = this.gridLayout.DataContext as RsTransport;
if (!validMaster.ValidMasterItem(currentItem)) return;
this.busyIndicator.BusyContent = "正在保存中...";
this.busyIndicator.IsBusy = true;
var checkOper = await ctx.CheckRsTransportByID(currentItem.TRANS_ID).AsTask();
if (checkOper.Value)
{
MessageBox.Show("已存在该编号");
this.busyIndicator.IsBusy = false;
return;
}
var m_RS_TRANSPORT = new RS_TRANSPORT();
DataExchange.CopyDataItem(currentItem, m_RS_TRANSPORT);
DataExchange.SetCreationLog(m_RS_TRANSPORT);
this.ctx.RS_TRANSPORTs.Add(m_RS_TRANSPORT);
var operationSave = await ctx.SubmitChanges().AsTask();
this.busyIndicator.IsBusy = false;
if (!this.CheckLoadDataArgs(ExceptionManager.CheckDataContextResult(operationSave))) return;
RadWindowExtension.CloseRadWindow(this, true);
}
private void btnClose_Click(object sender, RoutedEventArgs e)
{
RadWindowExtension.CloseRadWindow(this, false);
}
}
}
csharp 页面预览
View.xml
<commonData:SecurityPage
xmlns:commonData="clr-namespace:HD.SL.Common.Data.CommonData;assembly=HD.SL.Common.Data"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
x:Class="HD.SL.***View"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
Title="SaleAreaView Page">
<telerik:RadBusyIndicator x:Name="busyIndicator">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Border Grid.Row="0" BorderThickness="1" BorderBrush="Gray">
<Grid x:Name="searchLayout" Margin="2,10,2,2">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<telerik:RadButton x:Name="btnSearch" Content="查 询" Style="{StaticResource commonButton}" Click="btnSearch_Click" Margin="2,2,2,2"></telerik:RadButton>
</StackPanel>
</Grid>
</Border>
<telerik:RadGridView Grid.Row="1" Height="Auto" x:Name="gridView" AutoGenerateColumns="False" EnableLostFocusSelectedState="False"
ShowGroupPanel="False"
IsSynchronizedWithCurrentItem="False" CanUserSelect="True"
SelectionMode="Single"
IsReadOnly="True"
>
<telerik:RadGridView.Columns>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
<telerik:RadDataPager Grid.Row="2" DisplayMode="All" x:Name="dataPager" PageSize="10" NumericButtonCount="10" IsTotalItemCountFixed="True" Style="{StaticResource RadDataPagerStyle_Ext}" />
<StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Right">
<telerik:RadButton x:Name="btnAdd" Content="新 增" Style="{StaticResource commonButton}" Click="btnAdd_Click"></telerik:RadButton>
<telerik:RadButton x:Name="btnEdit" Content="编 辑" Style="{StaticResource commonButton}" Click="btnEdit_Click"></telerik:RadButton>
<telerik:RadButton x:Name="btnDelete" Content="删 除" Style="{StaticResource commonButton}" Click="btnDelete_Click"></telerik:RadButton>
</StackPanel>
</Grid>
</telerik:RadBusyIndicator>
</commonData:SecurityPage>
View.xml.cs
using System;
using System.Linq;
using System.Collections.Generic;
using System.Windows;
using HD.SL.Common.Data.CommonData;
using Telerik.Windows.Controls;
using HD.SL.Common.Controls;
using HD.SL.Common.Data.Operation;
using HD.SL.Common.Data.UI.Validation;
using HD.SL.Common.Asset.ResouceLists;
using System.Reflection;
using System.ServiceModel.DomainServices.Client;
using System.Threading.Tasks;
using HD.Web.Utils.DataFilters;
using HD.SVR.***.DataAccess.DataFilters;
using HD.SVR.***.DataAccess.DataModels;
using HD.SVR.***.DataAccess.DataServices;
using HD.SL.***.DataAccess.DataModels;
namespace HD.SL.***
{
public partial class ***View : SecurityPage
{
protected static ***View currentObject;
public static ***View GetInstance()
{
if (currentObject == null)
{
currentObject = new ***View();
currentObject.OnDispose += (sender, e) =>
{
currentObject = null;
};
}
currentObject.InitialPage();
return currentObject;
}
private DBContext ctx;
private SortDirection currentDirection;
private ***View()
{
ctx = new DBContext();
InitializeComponent();
***
SmartTextBox txtOWNER_NAME = TextBoxExtension.CreateSmartTextBoxWithBind<RsSaleAreaFilter, FilterOperation, RsSaleAreaProperty>
(FilterOperation.Contains, RsSaleAreaProperty.OWNER_NAME, StyleList.dataSmartTextBox, 50);
this.searchLayout.AddField<RsSaleArea>(p => p.OWNER_NAME, "", StyleList.dataNullable, txtOWNER_NAME, "", 1, 1);
this.searchLayout.SetSearchLayout(100, 160, 3);
***gridView.CreateDataColumnWithBind<RsSaleArea>(p => p.REMARK, "", 160, "", true, false);
this.gridView.RegisterCellCopy();
this.gridView.Sorting += gridView_Sorting;
this.dataPager.PageIndexChanged += dataPager_PageIndexChanged;
this.RegisterEnterAction<object, RoutedEventArgs>(btnSearch_Click);
this.gridView.InitialColumnVisibilityMenu(this.GetType().FullName, (pageSize) => { this.dataPager.PageSize = pageSize; GetFirstPage(); });
AppObject.GetAppObject<AppData>().OnRequestPageRefresh += Page_OnRequestPageRefresh;
}
async void Page_OnRequestPageRefresh(object sender, Common.Data.DataArgs.SecurityPageArgs e)
{
if (e.RefreshPageIds.Contains(this.GetType().FullName))
{
await GetPageData(this.dataPager.PageIndex);
}
}
private async void InitialPage()
{
searchLayout.InitialAllChildren(null);
this.busyIndicator.IsBusy = true;
currentDirection = SortDirection.ASC;
currentSortPath = RsSaleAreaProperty.CREATION_DATE;
this.currentFilter = CreateFilterDescriptors();
await GetPageData(0);
this.busyIndicator.IsBusy = false;
}
private async void btnSearch_Click(object sender, RoutedEventArgs e)
{
this.busyIndicator.IsBusy = true;
this.currentFilter = CreateFilterDescriptors();
await GetPageData(0);
this.busyIndicator.IsBusy = false;
}
private void btnAdd_Click(object sender, RoutedEventArgs e)
{
DialogParameters dlgParameter = new DialogParameters()
{
Header = "创建信息",
Content = OrderTypeNew.GetInstance(),
Closed = AddEdit_Done
};
dlgParameter.WindowStyle = new Style(typeof(RadWindow));
//dlgParameter.WindowStyle.Setters.Add(new Setter(RadWindow.WidthProperty, 860D));
//dlgParameter.WindowStyle.Setters.Add(new Setter(RadWindow.HeightProperty, 600D));
RadWindowExtension.ShowModalDialogWindow(dlgParameter);
}
private async void AddEdit_Done(object sender, WindowClosedEventArgs e)
{
if (e.DialogResult == true)
{
await GetPageData(this.dataPager.PageIndex);
}
}
private void btnEdit_Click(object sender, RoutedEventArgs e)
{
if (this.CheckValidation((this.gridView.SelectedItem == null), true, "请选择一行数据")) return;
var currentItem = this.gridView.SelectedItem as RS_SALE_AREA;
DialogParameters dlgParameter = new DialogParameters()
{
Header = "编辑信息",
Content = OrderTypeEdit.GetInstance(currentItem.ORDER_TYPE_ID),
Closed = AddEdit_Done
};
dlgParameter.WindowStyle = new Style(typeof(RadWindow));
//dlgParameter.WindowStyle.Setters.Add(new Setter(RadWindow.WidthProperty, 860D));
//dlgParameter.WindowStyle.Setters.Add(new Setter(RadWindow.HeightProperty, 600D));
RadWindowExtension.ShowModalDialogWindow(dlgParameter);
}
private void btnDelete_Click(object sender, RoutedEventArgs e)
{
DialogParameters dlgParameter = RadWindowExtension.CreateConfirmParameter("确定要删除选定的信息吗?", btnDelete_Click_Confirmed);
RadWindowExtension.ShowConfirmWindow(dlgParameter);
}
private async void btnDelete_Click_Confirmed(object sender, WindowClosedEventArgs e)
{
if (e.DialogResult != true) return;
if (this.CheckValidation((this.gridView.SelectedItem == null), true, "请选择一行数据")) return;
List<string> keyCodes = new List<string>();
foreach (var SelectedItem in gridView.SelectedItems)
{
var currentItem = SelectedItem as RS_SALE_AREA;
keyCodes.Add(currentItem.AREA_CODE);
}
this.busyIndicator.IsBusy = true;
await ctx.DeleteRsSaleArea(keyCodes.ToArray()).AsTask();
await GetPageData(this.dataPager.PageIndex);
this.busyIndicator.IsBusy = false;
}
private RsSaleAreaProperty currentSortPath;
private RsSaleAreaCompositionFilter currentFilter;
private RsSaleAreaCompositionFilter CreateFilterDescriptors()
{
RsSaleAreaCompositionFilter filter = new RsSaleAreaCompositionFilter();
filter.FilterItems = searchLayout.GetFilterItems<RsSaleAreaFilter>(null);
filter.CompositionItems = new List<RsSaleAreaCompositionFilter>(0);
filter.CurrentLogic = FilterLogic.And;
return filter;
}
private async void GetFirstPage()
{
this.busyIndicator.IsBusy = true;
await GetPageData(0);
this.busyIndicator.IsBusy = false;
}
private async Task GetPageData(int pageIndex)
{
var result = await ctx.GetRsSaleAreaPage(this.currentFilter, currentSortPath, currentDirection,
pageIndex * this.dataPager.PageSize + 1, (pageIndex + 1) * this.dataPager.PageSize).AsTask();
this.gridView.ItemsSource = result.Value;
var operation = await ctx.GetRsSaleAreaCount(this.currentFilter).AsTask();
this.dataPager.ItemCount = operation.Value;
this.dataPager.PageIndex = pageIndex;
}
async void gridView_Sorting(object sender, GridViewSortingEventArgs e)
{
currentSortPath = (RsSaleAreaProperty)Enum.Parse(typeof(RsSaleAreaProperty), e.Column.SortMemberPath, true);
currentDirection = (SortDirection)Enum.Parse(typeof(SortDirection), gridView.GetSortDirection(e.NewSortingState), true);
this.busyIndicator.IsBusy = true;
await GetPageData(0);
this.busyIndicator.IsBusy = false;
}
private async void dataPager_PageIndexChanged(object sender, PageIndexChangedEventArgs e)
{
this.busyIndicator.IsBusy = true;
await GetPageData(e.NewPageIndex);
this.busyIndicator.IsBusy = false;
}
private async void btnExport_Click(object sender, RoutedEventArgs e)
{
Dictionary<string, string> dicParam = await HD.SL.SDM.DataAccess.Utilities.PrintEngine.CreatePrintParam(this.GetType().FullName);
if (dicParam == null)
{
RadWindow.Alert("未找到导出配置信息");
return;
}
this.busyIndicator.IsBusy = true;
var regOper = await this.ctx.RegRsSaleAreaExport(dicParam, this.currentFilter).AsTask();
this.busyIndicator.IsBusy = false;
AppData.NavigatePage(regOper.Value.ToString());
}
}
}
csharp GridView.Cells.Judge
example.cs
for (int i = 0; i < this.gridViewField.Rows.Count; i++)
{
if (gridViewField.Rows[i].Cells["isSelected"].EditedFormattedValue.ToString() == "True")
{
//TODO
}
}
csharp 上传的文件限制(IIS Express)
[多部分主体长度限制超出异常](https://stackoverflow.com/questions/40364226/multipart-body-length-limit-exceeded-exception)<br/> [在ASP.NET核心中上传大文件](http: //www.binaryintellect.net/articles/612cf2d1-5b3d-40eb-a5ff-924005955a62.aspx)
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.Configure<FormOptions>(x => {
x.ValueLengthLimit = 1_048_576_000; //1 TB
x.MultipartBodyLengthLimit = 1_048_576_000; // In case of multipart
})
}
web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1048576000" />
</requestFiltering>
</security>
</system.webServer>
</configuration>
Index.cshtml.cs
[HttpPost]
[RequestFormLimits(MultipartBodyLengthLimit = 1_048_576_000)]
public IActionResult Upload(IFormFile file, [FromServices] IHostingEnvironment env)
csharp TwoGridViewsAddAndRemoveInTime
xaml
<telerik:GroupBox Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="2,2,2,0" Header="目标联系人">
<telerik:RadGridView x:Name="gridViewContactHave"
AutoGenerateColumns="False"
EnableLostFocusSelectedState="False"
ShowGroupPanel="False"
IsSynchronizedWithCurrentItem="False"
CanUserSelect="True"
SelectionMode="Extended"
IsReadOnly="True">
<telerik:RadGridView.Columns>
<telerik:GridViewSelectColumn></telerik:GridViewSelectColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</telerik:GroupBox>
<telerik:RadButton Grid.Row="1" Grid.Column="0" Click="btnAddContact_Click" Template="{StaticResource rdButtonUp}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<telerik:RadButton Grid.Row="1" Grid.Column="1" Click="btnRemoveContact_Click" Template="{StaticResource rdButtonDown}" HorizontalAlignment="Center" VerticalAlignment="Center" />
<telerik:GroupBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="2,2,2,0" Header="待合并联系人">
<telerik:RadGridView x:Name="gridViewContactAvailable"
AutoGenerateColumns="False"
EnableLostFocusSelectedState="False"
ShowGroupPanel="False"
CanUserSelect="True"
SelectionMode="Extended"
IsReadOnly="True">
<telerik:RadGridView.Columns>
<telerik:GridViewSelectColumn></telerik:GridViewSelectColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</telerik:GroupBox>
xaml.cs
private ObservableCollection<RsContact> contactAvailableItems;
private ObservableCollection<RsContact> contactHaveItems;
private async void InitialPage(string keyCode)
{
contactAvailableItems = new ObservableCollection<RsContact>();
contactHaveItems = new ObservableCollection<RsContact>();
this.busyIndicator.IsBusy = true;
//加载gridViewContactAvailable内容
var getAllContactItems = await ctxRSM.GetRsContactItems(customerItem.CUSTOMER_ID).AsTask();
foreach (var contactItem in getAllContactItems.Value)
{
var m_RsContact = new RsContact();
DataExchange.CopyDataItem<RS_CONTACT, RsContact>(contactItem, m_RsContact);
contactAvailableItems.Add(m_RsContact);
}
this.gridViewContactAvailable.ItemsSource = contactAvailableItems;
//挂载gridViewContactHave内容
this.gridViewContactHave.ItemsSource = contactHaveItems;
this.busyIndicator.IsBusy = false;
}
private void btnAddContact_Click(object sender, RoutedEventArgs e)
{
for (int i = this.gridViewContactAvailable.SelectedItems.Count(); i > 0; i--)
{
int index = i - 1;
var currentItem = this.gridViewContactAvailable.SelectedItems[index] as RsContact;
this.contactHaveItems.Add(currentItem);
this.contactAvailableItems.Remove(this.contactAvailableItems.Where(p => p.CONTACT_ID == currentItem.CONTACT_ID).FirstOrDefault());
}
}
private void btnRemoveContact_Click(object sender, RoutedEventArgs e)
{
for (int i = this.gridViewContactHave.SelectedItems.Count(); i > 0; i--)
{
int index = i - 1;
var currentItem = this.gridViewContactHave.SelectedItems[index] as RsContact;
this.contactAvailableItems.Add(currentItem);
this.contactHaveItems.Remove(this.contactHaveItems.Where(p => p.CONTACT_ID == currentItem.CONTACT_ID).FirstOrDefault());
}
}
csharp SendGrid C#多封电子邮件
SendGrid.cs
//npm below
using SendGrid;
using SendGrid.Helpers.Mail;
//code
var apiKey = config["SendGridApiKey"];
var sgClient = new SendGridClient(apiKey);
var from = new EmailAddress(config["FromEmail"]);
var subject = "Activity Summary report for " + config["client"];
var tos = new List<EmailAddress>{
new EmailAddress(config["DevToEmail"]),
new EmailAddress(config["Client]")
};
var plainTextContent = new StringBuilder();
var missingActivitiesListHtml = "<ul>";
missingActivitiesListHtml = "</ul>";
var body = "";
body = "<div>Hi</div>";
body += "<p>Activity completion report in the past 7 days<br/>";
body += "<br/>Total number of courses -- "+totalOrders+ " <br/> Completed activities -- " + capturedCompletions + "<br/> Probable missing activities --" + missingActivityList.Count + " <br/> Processing or Yet to complete ones -- " + yetToProcess + "";
body += "<br/>Missing ones are below:";
body += "<br/>"+ missingActivitiesListHtml;
body += "</p>";
body += "Thanks, <br/>Activity Summarizer";
plainTextContent.AppendLine(body);
var msg = MailHelper.CreateSingleEmailToMultipleRecipients(from, tos, subject, plainTextContent.ToString(), plainTextContent.ToString());
var response = await sgClient.SendEmailAsync(msg);
log.Info($"Email sent to - {tos}");