本文整理汇总了C#中IPersistenceContext.Lock方法的典型用法代码示例。如果您正苦于以下问题:C# IPersistenceContext.Lock方法的具体用法?C# IPersistenceContext.Lock怎么用?C# IPersistenceContext.Lock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPersistenceContext
的用法示例。
在下文中一共展示了IPersistenceContext.Lock方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Import
/// <summary>
/// Import user from CSV format.
/// </summary>
/// <param name="rows">
/// Each string in the list must contain 25 CSV fields, as follows:
/// 0 - UserName
/// 1 - StaffType
/// 2 - Id
/// 3 - FamilyName
/// 4 - GivenName
/// 5 - MiddleName
/// 6 - Prefix
/// 7 - Suffix
/// 8 - Degree
/// </param>
/// <param name="context"></param>
public override void Import(List<string> rows, IUpdateContext context)
{
_context = context;
List<User> importedUsers = new List<User>();
foreach (string row in rows)
{
string[] fields = ParseCsv(row, _numFields);
string userName = fields[0];
string staffId = fields[2];
string staffFamilyName = fields[3];
string staffGivenName = fields[4];
User user = GetUser(userName, importedUsers);
if (user == null)
{
UserInfo userInfo =
new UserInfo(userName, string.Format("{0} {1}", staffFamilyName, staffGivenName), null, null, null);
user = User.CreateNewUser(userInfo, _settings.DefaultTemporaryPassword);
_context.Lock(user, DirtyState.New);
importedUsers.Add(user);
}
}
}
示例2: Execute
public void Execute(ReportPart reportPart, IPersistenceContext context)
{
var order = reportPart.Report.Procedures.First().Order;
foreach (var recipient in order.ResultRecipients)
{
var item = Create(
order.AccessionNumber,
reportPart.Report.GetRef(),
recipient.PractitionerContactPoint.Practitioner.GetRef(),
recipient.PractitionerContactPoint.GetRef());
context.Lock(item, DirtyState.New);
}
}
示例3: Import
//.........这里部分代码省略.........
var epBillingNumber = fields[7];
var addressStreet = fields[8];
var addressUnit = fields[9];
var addressCity = fields[10];
var addressProvince = fields[11];
var addressPostalCode = fields[12];
var addressCountry = fields[13];
var addressValidFrom = ParseDateTime(fields[14]);
var addressValidUntil = ParseDateTime(fields[15]);
var phoneCountryCode = fields[16];
var phoneAreaCode = fields[17];
var phoneNumber = fields[18];
var phoneExtension = fields[19];
var phoneValidFrom = ParseDateTime(fields[20]);
var phoneValidUntil = ParseDateTime(fields[21]);
var faxCountryCode = fields[22];
var faxAreaCode = fields[23];
var faxNumber = fields[24];
var faxExtension = fields[25];
var faxValidFrom = ParseDateTime(fields[26]);
var faxValidUntil = ParseDateTime(fields[27]);
ExternalPractitioner ep = GetExternalPracitioner(epLicense, importedEPs);
if (ep != null)
continue;
ep = new ExternalPractitioner {LicenseNumber = epLicense, BillingNumber = epBillingNumber};
ep.Name = new PersonName(epFamilyName, epGivenName, epMiddlename, epPrefix, epSuffix, epDegree);
// create a single default contact point
var contactPoint = new ExternalPractitionerContactPoint(ep) {Name = "Default", IsDefaultContactPoint = true};
try
{
var epAddress = new Address(
addressStreet,
addressUnit,
addressCity,
addressProvince,
addressPostalCode,
addressCountry,
AddressType.B,
new DateTimeRange(addressValidFrom, addressValidUntil));
validator.Validate(epAddress);
contactPoint.Addresses.Add(epAddress);
}
catch(EntityValidationException)
{
/* invalid address - ignore */
}
try
{
var epTelephone = new TelephoneNumber(
phoneCountryCode,
phoneAreaCode,
phoneNumber,
phoneExtension,
TelephoneUse.WPN,
TelephoneEquipment.PH,
new DateTimeRange(phoneValidFrom, phoneValidUntil));
validator.Validate(epTelephone);
contactPoint.TelephoneNumbers.Add(epTelephone);
}
catch (EntityValidationException)
{
/* invalid phone - ignore */
}
try
{
var epFax = new TelephoneNumber(
faxCountryCode,
faxAreaCode,
faxNumber,
faxExtension,
TelephoneUse.WPN,
TelephoneEquipment.FX,
new DateTimeRange(faxValidFrom, faxValidUntil));
validator.Validate(epFax);
contactPoint.TelephoneNumbers.Add(epFax);
}
catch (EntityValidationException)
{
/* invalid fax - ignore */
}
_context.Lock(ep, DirtyState.New);
importedEPs.Add(ep);
}
}
示例4: CreateSysAdminUser
private static void CreateSysAdminUser(AuthorityGroup adminGroup, SetupCommandLine cmdLine, IPersistenceContext context, TextWriter log)
{
try
{
// create the sa user, if doesn't already exist
IUserBroker userBroker = context.GetBroker<IUserBroker>();
UserSearchCriteria where = new UserSearchCriteria();
where.UserName.EqualTo(cmdLine.SysAdminUserName);
userBroker.FindOne(where);
log.WriteLine(string.Format("User '{0}' already exists.", cmdLine.SysAdminUserName));
}
catch (EntityNotFoundException)
{
HashedSet<AuthorityGroup> groups = new HashedSet<AuthorityGroup>
{
adminGroup
};
// create sa user using initial password, set to expire never
User saUser = User.CreateNewUser(
new UserInfo(cmdLine.SysAdminUserName, cmdLine.SysAdminDisplayName, null, null, null),
Password.CreatePassword(cmdLine.SysAdminInitialPassword, null),
groups);
context.Lock(saUser, DirtyState.New);
}
}
示例5: Import
/// <summary>
/// Import staff from CSV format.
/// </summary>
/// <param name="rows">
/// Each string in the list must contain 25 CSV fields, as follows:
/// 0 - UserName
/// 1 - StaffType
/// 2 - Id
/// 3 - FamilyName
/// 4 - GivenName
/// 5 - MiddleName
/// 6 - Prefix
/// 7 - Suffix
/// 8 - Degree
/// </param>
/// <param name="context"></param>
public override void Import(List<string> rows, IUpdateContext context)
{
_context = context;
List<Staff> importedStaff = new List<Staff>();
foreach (string row in rows)
{
string[] fields = ParseCsv(row, _numFields);
string userName = fields[0];
StaffTypeEnum staffType = context.GetBroker<IEnumBroker>().Find<StaffTypeEnum>(fields[1]);
string staffId = fields[2];
string staffFamilyName = fields[3];
string staffGivenName = fields[4];
string staffMiddlename = fields[5];
string staffPrefix = fields[6];
string staffSuffix = fields[7];
string staffDegree = fields[8];
Staff staff = GetStaff(staffId, importedStaff);
if (staff == null)
{
staff = new Staff();
staff.Id = staffId;
staff.Type = staffType;
staff.Name = new PersonName(staffFamilyName, staffGivenName, staffMiddlename, staffPrefix, staffSuffix, staffDegree);
staff.UserName = userName;
_context.Lock(staff, DirtyState.New);
importedStaff.Add(staff);
}
}
}