本文整理汇总了C#中IObjectSpace.CommitChanges方法的典型用法代码示例。如果您正苦于以下问题:C# IObjectSpace.CommitChanges方法的具体用法?C# IObjectSpace.CommitChanges怎么用?C# IObjectSpace.CommitChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IObjectSpace
的用法示例。
在下文中一共展示了IObjectSpace.CommitChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Authenticate
public override object Authenticate(IObjectSpace objectSpace)
{
string systemUserName = WindowsIdentity.GetCurrent().Name;
string enteredUserName = ((AuthenticationStandardLogonParameters)LogonParameters).UserName;
if (string.IsNullOrEmpty(enteredUserName))
{
throw new ArgumentException(SecurityExceptionLocalizer.GetExceptionMessage(SecurityExceptionId.UserNameIsEmpty));
}
if (!String.Equals(systemUserName, enteredUserName))
{
throw new AuthenticationException(enteredUserName, "Invalid user name");
}
object user = objectSpace.FindObject(UserType, new BinaryOperator("UserName", systemUserName));
if (user == null)
{
user = objectSpace.CreateObject(UserType);
((IAuthenticationActiveDirectoryUser)user).UserName = systemUserName;
bool strictSecurityStrategyBehavior = SecurityModule.StrictSecurityStrategyBehavior;
SecurityModule.StrictSecurityStrategyBehavior = false;
objectSpace.CommitChanges();
SecurityModule.StrictSecurityStrategyBehavior = strictSecurityStrategyBehavior;
}
if (!((IAuthenticationStandardUser)user).ComparePassword(((AuthenticationStandardLogonParameters)LogonParameters).Password))
{
throw new AuthenticationException(systemUserName, SecurityExceptionLocalizer.GetExceptionMessage(SecurityExceptionId.RetypeTheInformation));
}
return user;
}
示例2: InitializeSecurity
public static void InitializeSecurity(IObjectSpace objectSpace) {
var defaultRole = objectSpace.GetDefaultRole();
var administratorRole = objectSpace.GetAdminRole("Administrator");
var modelRole = objectSpace.GetDefaultModelRole("ModelDifference");
objectSpace.GetUser("Admin", "Admin", administratorRole);
objectSpace.GetUser("User", "", defaultRole, modelRole);
objectSpace.CommitChanges();
}
示例3: InitializeSecurity
public static void InitializeSecurity(IObjectSpace objectSpace) {
var defaultRole = objectSpace.GetDefaultRole();
var administratorRole = objectSpace.GetAdminRole("Administrator");
var modelRole = objectSpace.GetDefaultModelRole("ModelDifference");
var user = objectSpace.GetUser("Admin", "Admin", administratorRole);
UserFilterProvider.UpdaterUserKey = ((SecuritySystemUser)user).Oid;
user = objectSpace.GetUser("User", "", defaultRole, modelRole);
UserFilterProvider.UpdaterUserKey = ((SecuritySystemUser)user).Oid;
objectSpace.CommitChanges();
}
示例4: ImportObjects
int ImportObjects(XDocument document, IObjectSpace objectSpace) {
_objectSpace = objectSpace;
if (document.Root != null) {
foreach (XElement element in document.Root.Nodes().OfType<XElement>()) {
using (IObjectSpace nestedObjectSpace = objectSpace.CreateNestedObjectSpace()) {
ITypeInfo typeInfo = GetTypeInfo(element);
if (typeInfo != null) {
var keys = GetKeys(element);
CriteriaOperator objectKeyCriteria = GetObjectKeyCriteria(typeInfo, keys);
if (!ReferenceEquals(objectKeyCriteria, null)) {
CreateObject(element, nestedObjectSpace, typeInfo, objectKeyCriteria);
nestedObjectSpace.CommitChanges();
}
}
}
}
objectSpace.CommitChanges();
}
return 0;
}
示例5: Process
public void Process(XafApplication application,IObjectSpace objectSpace) {
var user = objectSpace.FindObject(XpandModuleBase.UserType, new GroupOperator(GroupOperatorType.Or,new BinaryOperator("UserName", UserName),new BinaryOperator("Email",Email)),true) as IAuthenticationStandardUser;
if (user != null&&!objectSpace.IsNewObject(user))
throw new ArgumentException(CaptionHelper.GetLocalizedText(XpandSecurityModule.XpandSecurity, "AlreadyRegistered"));
var securityUserWithRoles = objectSpace.IsNewObject(user)? (ISecurityUserWithRoles) user
: (ISecurityUserWithRoles)objectSpace.CreateObject(XpandModuleBase.UserType);
User = securityUserWithRoles;
var userTypeInfo = application.TypesInfo.FindTypeInfo(XpandModuleBase.UserType);
var modelRegistration = (IModelRegistration)((IModelOptionsRegistration)application.Model.Options).Registration;
AddRoles(modelRegistration, userTypeInfo, securityUserWithRoles, objectSpace);
userTypeInfo.FindMember("UserName").SetValue(securityUserWithRoles,UserName);
userTypeInfo.FindMember("IsActive").SetValue(securityUserWithRoles,modelRegistration.ActivateUser);
modelRegistration.EmailMember.MemberInfo.SetValue(securityUserWithRoles,Email);
var activationLinkMember = modelRegistration.ActivationIdMember;
if (activationLinkMember!=null) {
activationLinkMember.MemberInfo.SetValue(securityUserWithRoles, Guid.NewGuid().ToString());
}
securityUserWithRoles.CallMethod("SetPassword", Password);
objectSpace.CommitChanges();
}
示例6: InitializeDefaultSolution
public static void InitializeDefaultSolution(IObjectSpace os)
{
var enumerable = ReflectionHelper.FindTypeDescendants(ReflectionHelper.FindTypeInfoByName(typeof(I单据编号).FullName));
var dictionary = os.GetObjects<单据编号方案>(null, true).ToDictionary(p => p.应用单据);
foreach (ITypeInfo info2 in enumerable)
{
if (!info2.IsAbstract && info2.IsPersistent)
{
var key = info2.Type;
单据编号方案 i单据编号方案 = null;
if (dictionary.ContainsKey(key))
{
i单据编号方案 = dictionary[key];
}
else
{
i单据编号方案 = os.CreateObject<单据编号方案>();
i单据编号方案.名称 = key.FullName;
i单据编号方案.应用单据 = info2.Type;
var item = os.CreateObject<单据编号自动编号规则>();
item.格式化字符串 = "00000";
i单据编号方案.编号规则.Add(item);
dictionary.Add(key, i单据编号方案);
}
}
}
os.CommitChanges();
}
示例7: AuthenticateActiveDirectory
private object AuthenticateActiveDirectory(IObjectSpace objectSpace) {
var windowsIdentity = WindowsIdentity.GetCurrent();
if (windowsIdentity != null) {
string userName = windowsIdentity.Name;
var user = (IAuthenticationActiveDirectoryUser)objectSpace.FindObject(UserType, new BinaryOperator("UserName", userName));
if (user == null) {
if (_createUserAutomatically) {
var args = new CustomCreateUserEventArgs(objectSpace, userName);
if (!args.Handled) {
user = (IAuthenticationActiveDirectoryUser)objectSpace.CreateObject(UserType);
user.UserName = userName;
if (Security != null) {
//Security.InitializeNewUser(objectSpace, user);
Security.CallMethod("InitializeNewUser", new object[]{objectSpace, user});
}
}
objectSpace.CommitChanges();
}
}
if (user == null) {
throw new AuthenticationException(userName);
}
return user;
}
return null;
}
示例8: MassUpdateDataType
public static void MassUpdateDataType(IObjectSpace objectSpace, string oldDataType, Type newDataType)
{
foreach (ReportData reportData in objectSpace.GetObjects<ReportData>(new BinaryOperator("dataTypeName", oldDataType)))
{
XafReport report = reportData.LoadXtraReport(objectSpace);
report.DataType = newDataType;
reportData.SaveXtraReport(report);
}
objectSpace.CommitChanges();
}
示例9: OnRequestProcessed
protected virtual void OnRequestProcessed(IObjectSpace objectSpace, ObjectChangedXpoStartWorkflowRequest request) {
objectSpace.Delete(request);
objectSpace.CommitChanges();
}
示例10: Download
/// <summary>
/// Downloads XafDelta messages into replication storage database.
/// </summary>
/// <param name="xafDeltaModule">The xaf delta module.</param>
/// <param name="objectSpace">The object space.</param>
/// <param name="worker">The worker.</param>
public void Download(XafDeltaModule xafDeltaModule, IObjectSpace objectSpace, ActionWorker worker)
{
worker.ReportProgress(Localizer.DownloadStarted);
var transportList = (from m in xafDeltaModule.ModuleManager.Modules
where m is IXafDeltaTransport && ((IXafDeltaTransport) m).UseForDownload
select m).Cast<IXafDeltaTransport>().ToList();
worker.ReportProgress(string.Format(Localizer.TransportFound, transportList.Count()));
foreach (var transport in transportList.TakeWhile(x => !worker.CancellationPending))
{
worker.ReportProgress(string.Format(Localizer.DownloadUsing, transport));
try
{
worker.ReportProgress(string.Format(Localizer.OpenTransport, transport));
transport.Open(TransportMode.Download, worker);
var existingReplicaNames = from c in objectSpace.GetObjects<Package>() select c.FileName;
var fileNames = transport.GetFileNames(worker,
@"(" + Ticket.FileMask + "|" + Package.FileMask + ")").ToList();
fileNames = fileNames.Except(existingReplicaNames).ToList();
worker.ReportProgress(string.Format(Localizer.FilesForDownload, fileNames.Count));
foreach (var fileName in fileNames.TakeWhile(x => !worker.CancellationPending))
{
// worker.ReportProgress(string.Format(Localizer.DownloadFile, fileName));
var fileData = transport.DownloadFile(fileName, worker);
if(fileData != null && fileData.Length > 0)
{
if (fileName.EndsWith(Package.PackageFileExtension))
{
var replica = Package.ImportFromBytes(objectSpace, fileName, fileData);
replica.Save();
}
else
{
var replicaTicket = Ticket.ImportTicket(objectSpace, fileData);
replicaTicket.Save();
}
if (!fileName.Contains(ReplicationNode.AllNodes))
transport.DeleteFile(fileName, worker);
objectSpace.CommitChanges();
}
}
}
catch (Exception exception)
{
objectSpace.Rollback();
worker.ReportError(Localizer.DownloadError, exception.Message);
}
finally
{
worker.ReportProgress(Localizer.CloseTransport, transport);
transport.Close();
}
}
worker.ReportProgress(Color.Blue, Localizer.DownloadFinished);
}
示例11: Upload
/// <summary>
/// Uploads pending XafDelta messages to intermidiate net storages.
/// </summary>
/// <param name="xafDeltaModule">The xaf delta module.</param>
/// <param name="objectSpace">The object space.</param>
/// <param name="worker">The worker.</param>
public void Upload(XafDeltaModule xafDeltaModule, IObjectSpace objectSpace, ActionWorker worker)
{
worker.ReportProgress(Localizer.UploadStarted);
var transportList = (from m in XafDeltaModule.XafApp.Modules
where m is IXafDeltaTransport && ((IXafDeltaTransport)m).UseForUpload
select m).Cast<IXafDeltaTransport>().ToList().AsReadOnly();
if (transportList.Count > 0)
{
var replicas = (from r in objectSpace.GetObjects<Package>() where r.IsOutput
&& r.GetEventDateTime(PackageEventType.Sent) == DateTime.MinValue
orderby r.PackageDateTime
select r).ToList();
var tickets = (from t in objectSpace.GetObjects<Ticket>(CriteriaOperator.Parse("IsNull(ProcessingDateTime)"), true)
where t.Package != null && t.Package.IsInput
orderby t.TicketDateTime select t).ToList();
var messages = replicas.Cast<IReplicationMessage>().Union(tickets.Cast<IReplicationMessage>()).ToList();
var uploadData = new Dictionary<IXafDeltaTransport, List<IReplicationMessage>>();
worker.ReportProgress(string.Format(Localizer.FoundForUpload, messages.Count()));
foreach (var message in messages.TakeWhile(x => !worker.CancellationPending))
{
var args = new SelectUploadTransportArgs(message, transportList[0]);
Owner.OnSelectUploadTransport(args);
if(args.Transport != null)
{
List<IReplicationMessage> list;
if(!uploadData.TryGetValue(args.Transport, out list))
{
list = new List<IReplicationMessage>();
uploadData.Add(args.Transport, list);
}
list.Add(message);
}
}
if(!worker.CancellationPending && uploadData.Keys.Count > 0)
{
foreach (var transport in uploadData.Keys.TakeWhile(x => !worker.CancellationPending))
{
try
{
worker.ReportProgress(string.Format(Localizer.OpenTransport, transport));
transport.Open(TransportMode.Upload, worker);
var messageList = uploadData[transport];
foreach (var message in messageList)
{
var recipientAddress = message.RecipientAddress;
// worker.ReportProgress(string.Format(Localizer.UploadingFile, message));
transport.UploadFile(message.ToString(), message.GetData(), recipientAddress, worker);
if (message is Package)
((Package)message).CreateLogRecord(PackageEventType.Sent);
else
((Ticket) message).ProcessingDateTime = DateTime.Now;
objectSpace.CommitChanges();
}
}
catch (Exception exception)
{
objectSpace.Rollback();
worker.ReportError(Localizer.UploadError, exception.Message);
}
finally
{
worker.ReportProgress(string.Format(Localizer.CloseTransport, transport));
transport.Close();
}
}
}
}
else
worker.ReportProgress(Color.BlueViolet, Localizer.UploadTransportNotFound);
worker.ReportProgress(Color.Blue, Localizer.UploadFinished);
}
示例12: CloseObjectSpace
protected virtual void CloseObjectSpace(IObjectSpace objectSpace, bool success)
{
if (objectSpace != null && !objectSpace.IsDisposed)
{
if (success)
{
objectSpace.CommitChanges();
}
else
{
objectSpace.Rollback();
}
objectSpace.Dispose();
}
}
示例13: InitWMSDataController
public InitWMSDataController()
{
this.components = new System.ComponentModel.Container();
this.TargetWindowType = WindowType.Main;
var initData = new SimpleAction(this.components);
initData.Category = "Tools";
initData.Caption = "生成默认数据";
initData.Id = "InitData";
initData.Execute += (snd, e) => {
ObjectSpace = Application.CreateObjectSpace();
var inited = ObjectSpace.GetObjectsCount(typeof(产品), null) > 0;
var tdch = new CIIP.Module.DatabaseUpdate.TestDataGeneratorHelper();
if (!inited)
{
var t = CreateUnit("台");
var g = CreateUnit("个");
CreateProduct("Surface 3 64G 2G", t, 2000, 2999);
CreateProduct("Surface 3 128G 4G", t, 2000, 4888);
CreateProduct("Surface Pro 3 I3 64G 4G", t, 3000, 4499);
CreateProduct("Surface Pro 3 I5 128G 4G", t, 4500, 5699);
CreateProduct("Surface Pro 3 I5 256G 8G", t, 6388, 6999);
CreateProduct("Surface Pro 3 I7 256G 8G", t, 7000, 8888);
CreateProduct("Surface Pro 3 I7 512G 8G", t, 8000, 9999);
CreateProduct("Surface Pro 4 CoreM 128G 8G", t, 5688, 6688);
CreateProduct("Surface Pro 4 I5 128G 8G", t, 6388, 7388);
CreateProduct("Surface Pro 4 I5 256G 8G", t, 6388, 9688);
CreateProduct("Surface Pro 4 I7 256G 16G", t, 6388, 13388);
CreateProduct("Surface Notebook I5 128G 8G", t, 10000, 11088);
CreateProduct("Surface Notebook I5 256G 16G", t, 10000, 14088);
CreateProduct("Surface Notebook I7 256G 16G", t, 13000, 15588);
CreateProduct("Surface Notebook I7 512G 16G", t, 15000, 20088);
var microsoft = CreateCompany("Microsoft", "比尔.盖茨", "13800001111", "徐家汇", true, true);
var google = CreateCompany("Google", "拉里·佩奇", "13988881111", "徐家汇", true, true);
var baidu = CreateCompany("Baidu", "李彦宏", "13900001111", "陆家嘴", true, true);
var tencent = CreateCompany("Tencent", "15912111211", "马化腾", "陆家嘴", true, true);
var ali = CreateCompany("Alibaba", "15612121212", "马云", "陆家嘴", true, true);
//500个客户
}
var area = ObjectSpace.FindObject<省份>(null);
if (area == null)
{
var js = CreateSF("江苏");
CreateCity(js, "苏州", "姑苏区,相城区,吴中区,虎丘区,工业园区,吴江区,张家港市,常熟市,太仓巿,昆山市");
CreateCity(js, "南京", "鼓楼区,白下区,玄武区,秦淮区,建邺区,下关区,雨花台区,栖霞区,高淳县,溧水县,六合区,浦口区,江宁区");
var tjs = CreateSF("天津");
CreateCity(tjs, "天津", "和平区,河东区,河西区,南开区,河北区,红桥区,滨海新区,东丽区,西青区,津南区,北辰区,武清区,宝坻区,宁河区,静海区,蓟县");
var cqs = CreateSF("重庆");
CreateCity(cqs, "重庆",
"渝中区,大渡口区,江北区,沙坪坝区,九龙坡区,南岸区,北碚区,渝北区,巴南区,涪陵区,綦江区,大足区,长寿区,江津区,合川区,永川区,南川区,璧山区,铜梁区,潼南区,荣昌区,万州区,梁平县,城口县,丰都县,垫江县,忠县,开县,云阳县,奉节县,巫山县,巫溪县,黔江区,武隆县,石柱土家族自治县,秀山土家族苗族自治县,酉阳土家族苗族自治县,彭水苗族土家族自治县");
var zjs = CreateSF("浙江");
CreateCity(zjs, "杭州", "市区,上城区,下城区,江干区,拱墅区,西湖区,滨江区,萧山区,余杭区,富阳区,桐庐县,淳安县,建德市,临安市");
var scs = CreateSF("四川");
CreateCity(scs, "成都", "武侯区,锦江区,青羊区,金牛区,成华区,龙泉驿区,温江区,新都区,青白江区,双流区,郫县,蒲江县,大邑县,金堂县,新津县,都江堰市,彭州市,邛崃市,崇州市");
var gds = CreateSF("广东");
CreateCity(gds, "广州", "越秀区,荔湾区,海珠区,天河区,白云区,黄埔区,番禺区,花都区,南沙区,增城区,从化区");
var szs = CreateSF("深圳");
CreateCity(szs, "深圳", "福田区,罗湖区,南山区,盐田区,宝安区,龙岗区");
var shs = CreateSF("上海");
CreateCity(shs, "上海", "黄浦区,浦东新区,徐汇区,长宁区,静安区,普陀区,虹口区,杨浦区,闵行区,宝山区,嘉定区,金山区,松江区,青浦区,奉贤区,崇明县");
var bjs = CreateSF("北京");
CreateCity(bjs, "北京", "东城区,西城区,海淀区,朝阳区,丰台区,石景山区,门头沟区,通州区,顺义区,房山区,大兴区,昌平区,怀柔区,平谷区,密云区,延庆区");
ObjectSpace.CommitChanges();
var s = ObjectSpace.GetObjects<销售区域>();
var customers = tdch.GetRandomNames(500);
//.........这里部分代码省略.........
示例14: CreateSystemTypes
//.........这里部分代码省略.........
var baseType = bos.SingleOrDefault(x => x.FullName == fullName);
bob.Base = baseType;
if (bob.Base == null)
{
Debug.WriteLine(type.FullName + "没有找到基类:" + fullName);
}
}
if (type.IsGenericType)
{
bob.DisableCreateGenericParameterValues = true;
foreach (var item in type.GetGenericArguments())
{
var gp = ObjectSpace.CreateObject<GenericParameter>();
gp.Owner = bob;
gp.Name = item.Name;
if (item.IsGenericParameter)
{
gp.ParameterIndex = item.GenericParameterPosition;
}
else
{
}
if (!string.IsNullOrEmpty(item.FullName))
gp.ParameterValue = exists.SingleOrDefault(x => x.FullName == item.FullName);
var att =
item.GetCustomAttributes(typeof (ItemTypeAttribute), false)
.OfType<ItemTypeAttribute>()
.FirstOrDefault();
if (att != null)
{
var gi = bos.SingleOrDefault(x => x.FullName == att.ItemType.FullName);
gp.DefaultGenericType = gi;
}
}
}
var typeInfo = CaptionHelper.ApplicationModel.BOModel.GetClass(type);
if (typeInfo != null && false)
{
foreach (var tim in typeInfo.OwnMembers)
{
if (tim.MemberInfo.IsAssociation)
{
var collectionMember = ObjectSpace.CreateObject<CollectionProperty>();
collectionMember.Owner = bob;
collectionMember.Aggregated = tim.MemberInfo.IsAggregated;
collectionMember.名称 = tim.Name;
collectionMember.PropertyType = bos.SingleOrDefault(x => x.FullName == tim.Type.FullName);
if (collectionMember.PropertyType == null)
{
Debug.WriteLine("没有找到属性类型:" + tim.Type.FullName);
//throw new Exception("没有找到属性类型" + tim.Type.FullName);
}
}
else
{
var member = ObjectSpace.CreateObject<Property>();
member.Owner = bob;
member.名称 = tim.Name;
member.PropertyType = exists.SingleOrDefault(x => x.FullName == tim.Type.FullName);
member.Owner = bob;
if (member.PropertyType == null)
{
Debug.WriteLine("没有找到属性类型:" + tim.Type.FullName);
//throw new Exception("没有找到属性类型" + tim.Type.FullName);
}
}
}
}
else
{
Debug.WriteLine("没有找到类型:" + type.FullName);
}
}
//第三步,设置属性的关联属性,因为可能用到第二步中创建的属性,及,创建关系.
foreach (var bob in bos.Where(x => !x.IsRuntimeDefine))
{
if (bob.CollectionProperties.Count > 0)
{
var type = ReflectionHelper.FindType(bob.FullName);
var typeInfo = CaptionHelper.ApplicationModel.BOModel.GetClass(type);
foreach (var cp in bob.CollectionProperties)
{
var mi = typeInfo.FindMember(cp.名称);
cp.RelationProperty = cp.PropertyType.FindProperty(mi.MemberInfo.AssociatedMemberInfo.Name);
}
}
}
#endregion
ObjectSpace.CommitChanges();
}
示例15: CreateWMS
public static void CreateWMS(IObjectSpace os,bool deleteExist)
{
WMSPackage wms = new WMSPackage(os);
wms.Create(deleteExist);
wms.AutoRun();
os.CommitChanges();
}