本文整理汇总了C#中SaveRequest.HasFlagSet方法的典型用法代码示例。如果您正苦于以下问题:C# SaveRequest.HasFlagSet方法的具体用法?C# SaveRequest.HasFlagSet怎么用?C# SaveRequest.HasFlagSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SaveRequest
的用法示例。
在下文中一共展示了SaveRequest.HasFlagSet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveUserSecurityEntity
public BusinessMessageResponse SaveUserSecurityEntity(SaveRequest<SecurityEntity> request)
{
var response = new BusinessMessageResponse();
try
{
if (request.Item != null)
{
SecurityEntity se = request.Item;
bool updatePassword = request.HasFlagSet("UpdatePassword");
var resp1 = GenericGetEntity<SecurityEntity>(new IDRequest(se.ID));
bool exists = ServiceMessageHelper.IsSuccess(resp1);
if (exists)
{
se.Salt = resp1.Item.Salt;
if (!updatePassword) se.LoginPassword = resp1.Item.LoginPassword;
}
if (updatePassword)
{
if (se.Salt == Guid.Empty) se.Salt = AuthenticationHelper.GenerateSalt();
se.LoginPassword = Convert.ToBase64String(AuthenticationHelper.ComputePasswordHash(se.Salt, se.LoginPassword));
}
object date = se.LastLogonDate;
if (se.LastLogonDate == default(DateTime)) date = null;
//# gs-353 check for se.LoginEnabled
bool emptyUser = se.LoginEnabled && string.IsNullOrEmpty(se.LoginUsername);
bool emptyPwd = se.LoginEnabled && string.IsNullOrEmpty(se.LoginPassword);
bool emptySalt = se.LoginEnabled && se.Salt == Guid.Empty;
//. gs-353
if (emptyUser || emptyPwd || emptySalt)
{
var resp0 = new BusinessMessageResponse { Status = false, StatusMessage = "Empty user, password or salt" };
string err = "INse|ImardaSecurity.GetUserSecurityEntity:SecurityEntity|{0}{1}{2}";
resp0.ErrorCode = string.Format(err, (emptyUser ? " Usr" : ""), (emptyPwd ? " Pwd" : ""),
(emptySalt ? " Salt" : ""));
return resp0;
}
response = GenericSaveEntity<SecurityEntity>("SecurityEntity",
se.ID,
se.EntityName,
se.EntityType,
se.LoginEnabled,
se.LoginUsername,
se.LoginPassword,
se.IsTemplate, //& gs-353
se.CompanyID, //& gs-351
se.Path,
se.UserID,
se.CRMId,
se.Description,
se.BranchID,
date,
se.Active,
se.Deleted,
string.IsNullOrEmpty(se.TimeZone) || se.TimeZone.StartsWith("(") ? "UTC" : se.TimeZone,
se.Locale ?? "en",
se.PreferredUnitSystemID,
se.EnableTimeZoneSelect,
se.IsAdmin,
se.Salt,
updatePassword
);
}
response.Status = true;
}
catch (Exception ex)
{
return ErrorHandler.Handle(ex);
}
return response;
}