我想在Xamarin中添加验证.为此,我使用这篇文章作为参考点:使用Data Annotation进行验证.以下是我的行为.
public class EntryValidationBehavior : Behavior<Entry>
{
private Entry _associatedObject;
protected override void OnAttachedTo(Entry bindable)
{
base.OnAttachedTo(bindable);
// Perform setup
_associatedObject = bindable;
_associatedObject.TextChanged += _associatedObject_TextChanged;
}
void _associatedObject_TextChanged(object sender, TextChangedEventArgs e)
{
var source = _associatedObject.BindingContext as ValidationBase;
if (source != null && !string.IsNullOrEmpty(PropertyName))
{
var errors = source.GetErrors(PropertyName).Cast<string>();
if (errors != null && errors.Any())
{
var borderEffect = _associatedObject.Effects.FirstOrDefault(eff => eff is BorderEffect);
if (borderEffect == null)
{
_associatedObject.Effects.Add(new BorderEffect());
}
if (Device.OS != TargetPlatform.Windows) …
Run Code Online (Sandbox Code Playgroud) 我想恢复使用ClickOnce发布的以前版本的C#应用程序,如果数据库迁移失败,因为数据库不是最新的,并且它不支持最新版本的应用程序.
细节
我正在开发一个应用程序,将在没有互联网的偏远地区本地使用.一个人会偶尔以某种方式通过互联网更新他/她的应用程序,然后将在本地网络上部署该应用程序.从那里每个人都可以获得更新版本的应用程序.我现在想要的是使用此应用程序使用数据库迁移,如果应用程序失败它应该还原到以前的版本.我已经使用FluentMigrator进行数据库迁移,并使用ClickOnce来部署应用程序.我也经历过这里的几乎所有链接,看看我该怎么做.我现在知道使用ClickOnce是不可能的.任何人都可以通过其他方式告诉我或者可能是某种黑客攻击吗?我正在使用ClickOnce,因为它具有自动更新功能,所以现在不想丢失该功能.任何帮助将不胜感激.
我正在使用xamarin并尝试使用一种方法来使用所有服务.为此我写了一个TaskExtension.因此,从应用程序的每个页面我都可以调用该扩展方法.这是为了禁用按钮,显示加载屏幕,响应处理以及从一点开始处理异常处理.我在下面附上我的代码.需要您对此解决方案的专家意见
这是我的扩展类
public static class TaskExtensions
{
public static async Task<ResultViewModel<U>> ExecuteAsyncOperation<U>(this Task<HttpResponseMessage> operation, object sender = null)
{
ResultViewModel<U> resultModel = new ResultViewModel<U>();
Button button = BeforeAsyncCall(sender);
try
{
await BackgroundOperation(operation, resultModel);
}
catch (Exception ex)
{
resultModel.Status = HttpStatusCode.InternalServerError;
resultModel.Errors = new List<string>() { "Some error occurred. Please try again." };
}
finally
{
AfterAsyncCall(button);
}
return resultModel;
}
static async Task BackgroundOperation<U>(Task<HttpResponseMessage> operation, ResultViewModel<U> resultModel)
{
HttpResponseMessage RawResult = await operation;
var Response = await RawResult.Content.ReadAsStringAsync();
resultModel.Status …
Run Code Online (Sandbox Code Playgroud) 我一直在使用生物识别设备已有一段时间了.我一直能够连接生物识别设备并从中获取数据.但这次我一直在给一台连接到服务器的旧设备(Pegasus PB-7).我只获得远程桌面连接和访问生物识别设备.我面临的问题是远程桌面上已经安装了软件,当我提供IP和端口时,它会在几秒钟内连接到它.但是,当我使用zkemSdk时,我一直用它来连接到其他设备,它没有连接,以下方法返回-7给我.
int idwErrorCode = -1;
this.objCZKEM.GetLastError(ref idwErrorCode);
Run Code Online (Sandbox Code Playgroud)
SDK手册中未定义此代码.我能够ping设备,telnet也可以工作.请给出一些可能出现问题的建议.
我已覆盖 Microsoft Identity 提供的默认 IdentityUser 和 UserStore。
public class ApplicationUser<TIdentityKey, TClientKey> : IdentityUser<TIdentityKey>, IApplicationUser<TIdentityKey, TClientKey>
where TIdentityKey : IEquatable<TIdentityKey>
where TClientKey : IEquatable<TClientKey>
{
public TClientKey TenantId { get; set; }
}
public class ApplicationUserStore<TUser, TRole, TIdentityKey, TClientKey> : UserStore<TUser, TRole, IdentityServerDbContext<TIdentityKey, TClientKey>, TIdentityKey>
where TUser : ApplicationUser<TIdentityKey, TClientKey>
where TRole : ApplicationRole<TIdentityKey>
where TIdentityKey : IEquatable<TIdentityKey>
where TClientKey : IEquatable<TClientKey>
{
private readonly IdentityServerDbContext<TIdentityKey, TClientKey> _context;
private readonly ITenantService<TIdentityKey, TClientKey> _tenantService;
public ApplicationUserStore(IdentityServerDbContext<TIdentityKey, TClientKey> context, ITenantService<TIdentityKey, TClientKey> tenantService) : …
Run Code Online (Sandbox Code Playgroud) c# dependency-injection marker-interfaces asp.net-identity asp.net-core
我正在为 WPF 实施授权。我对屏幕有绑定权限。例如,有一个叫地板的屏幕。它有四个与之关联的权限。
除了每个权限,我们还有四个级别的权限。
因此,如果用户具有权限级别为 {ALL} 的 {View Floor} 权限。他们可以查看任何用户创建的所有楼层。
如果用户具有 {Self} 权限级别。他们只能查看自己创建的楼层。
如果用户的权限级别为 {Role}。他们可以查看针对指定角色分配的所有楼层。
权限级别的角色分配如下:
Roles: Supervisor, Technician
Run Code Online (Sandbox Code Playgroud)
如果 BranchManager 具有上述权限级别。然后他可以查看自己创建的楼层以及任何具有主管或技术人员角色的用户创建的楼层。
权限级别 {User} 与 {Role} 相同。
这是我用于获取楼层的 IQueryable:
IQueryable<FloorModel> FloorsQueryable = (from f in Floors
join b in Branches on f.BranchId equals b.Id
where (string.IsNullOrEmpty(filters.Name) || f.Name.ToLower().Contains(filters.Name.ToLower()))
&& (string.IsNullOrEmpty(filters.BranchName) || b.Name.ToLower().Contains(filters.BranchName.ToLower()))
&& (f.IsDeleted == null || f.IsDeleted == false)
&& f.BranchId == CurrentBranchId
&& f.ApplicationId == CurrentApplicationId
select new FloorModel
{ …
Run Code Online (Sandbox Code Playgroud) linq entity-framework iqueryable automapper entity-framework-6
public Guid AddJobs(JObject parametrs)
{
dynamic jsonParameters = parametrs;
JobViewModel job = jsonParameters.Job.ToObject<JobViewModel>();
}
Run Code Online (Sandbox Code Playgroud)
以上是我的代码。我正在尝试使用上述方法反序列化此模型。问题是它一直给我一个例外,即日期格式不正确,因为它不期望“dd-mm-yyyy”。请帮我解决这个问题。
c# ×6
xamarin ×2
.net ×1
asp.net-core ×1
async-await ×1
automapper ×1
behavior ×1
biometrics ×1
clickonce ×1
fingerprint ×1
generics ×1
iqueryable ×1
json.net ×1
linq ×1
networking ×1