void Generate(IClassInfoGraphNode classInfoGraphNode, ITypeInfo memberInfo, ObjectSpace objectSpace, Action<IList<IMemberInfo>> action) { foreach (var infoGraphNode in GetGraph(objectSpace, memberInfo.Type, action)) { classInfoGraphNode.Children.Add(infoGraphNode); } }
public void Setup(ObjectSpace objectSpace, XafApplication application) { if (helper == null) helper = new LookupEditorHelper(application, objectSpace, ObjectTypeInfo, Model); helper.SetObjectSpace(objectSpace); }
IClassInfoGraphNode addClassInfoGraphNode(ObjectSpace objectSpace, IMemberInfo memberInfo, NodeType nodeType) { var classInfoGraphNode =(IClassInfoGraphNode)objectSpace.CreateObject(TypesInfo.Instance.ClassInfoGraphNodeType); classInfoGraphNode.Name = memberInfo.Name; classInfoGraphNode.TypeName = getSerializedType(memberInfo).Name; classInfoGraphNode.NodeType=nodeType; return classInfoGraphNode; }
/// <summary> /// Parses an OPath query into an ObjectExpression using the mappings from the specified ObjectSpace. /// </summary> /// <param name="query">OPathQuery to be processed.</param> /// <param name="os">ObjectSpaces containing the mappings to use.</param> /// <returns>ObjectExpression containing the parser results, which are ready to be compiled.</returns> public static ObjectExpression Parse(OPathQuery query, ObjectSpace os) { if( query == null ) throw new ArgumentNullException("query"); if( os == null ) throw new ArgumentNullException("os"); return Parse(query, os.context.Mappings); }
public ExcelImportWizard(ObjectSpace objectSpace, ITypeInfo typeInfo, CollectionSourceBase collectionSourceBase) { //set local variable values if (objectSpace == null) throw new ArgumentNullException("objectSpace", @"ObjectSpace cannot be NULL"); ObjectSpace = objectSpace; CurrentCollectionSource = collectionSourceBase; //_ImportUOW = new UnitOfWork(((ObjectSpace)ObjectSpace).Session.DataLayer); Type = typeInfo.Type; //this.typeInfo = typeInfo; InitializeComponent(); ImportMapLookUp.Properties.DataSource = ImportMapsCollection.ToList(); //ImportMapLookUp.Properties.DisplayMember = "Name"; //disable next, until file and other info is selected wizardPage1.AllowNext = false; gridLookUpEdit1.Properties.View.OptionsBehavior.AutoPopulateColumns = true; gridLookUpEdit1.Properties.DataSource = MappableColumns;//.ToList(); // gridLookUpEdit1.Properties.SearchMode = SearchMode.OnlyInPopup; var col = gridLookUpEdit2View.Columns.ColumnByFieldName("Mapped"); if (col != null) { col.Visible = false; col.FilterInfo = new ColumnFilterInfo(new BinaryOperator("Mapped", false)); } col = gridLookUpEdit2View.Columns.ColumnByFieldName("Oid"); if (col != null) col.Visible = false; }
IClassInfoGraphNode addComplexNode(IMemberInfo memberInfo, ObjectSpace objectSpace) { NodeType nodeType=memberInfo.MemberTypeInfo.IsPersistent?NodeType.Object : NodeType.Collection; IClassInfoGraphNode classInfoGraphNode = addClassInfoGraphNode(objectSpace, memberInfo,nodeType); classInfoGraphNode.SerializationStrategy = SerializationStrategy.SerializeAsObject; generate(objectSpace, ReflectionHelper.GetType(classInfoGraphNode.TypeName)); return classInfoGraphNode; }
public override void SaveDifference(Dictionary diffDictionary) { if (diffDictionary != null){ objectSpace = application.CreateObjectSpace(); ModelDifferenceObject modelDifferenceObject = GetActiveDifferenceObject() ?? GetNewDifferenceObject(objectSpace). InitializeMembers(Application.Title, application.GetType().FullName); OnDifferenceObjectSaving(modelDifferenceObject,diffDictionary); } }
public void Setup(ObjectSpace objectSpace, XafApplication application) { if (helper == null) helper = new LookupEditorHelper(application, objectSpace, ObjectTypeInfo, Info); if (objectSpace == null) { // DestroyPopupForm(); } helper.SetObjectSpace(objectSpace); }
void generate(ObjectSpace objectSpace, Type typeToSerialize) { if (!SerializationConfigurationQuery.ConfigurationExists(objectSpace.Session, typeToSerialize)) { var serializationConfiguration = (ISerializationConfiguration) objectSpace.CreateObject(TypesInfo.Instance.SerializationConfigurationType); serializationConfiguration.TypeToSerialize = typeToSerialize; Generate(serializationConfiguration); } }
public IPersistentAssemblyInfo Build(string customer, string order, string orderLine, string masterDetailDynamicAssembly) { var unitOfWork = new UnitOfWork(_session.DataLayer); var objectSpace = new ObjectSpace(unitOfWork, XafTypesInfo.Instance); var persistentAssemblyBuilder = PersistentAssemblyBuilder.BuildAssembly(objectSpace, masterDetailDynamicAssembly); IClassInfoHandler classInfoHandler = persistentAssemblyBuilder.CreateClasses(GetClassNames(customer, order, orderLine)); classInfoHandler.CreateTemplateInfos(persistentClassInfo => GetTemplateInfos(persistentClassInfo, customer, order)); classInfoHandler.SetInheritance(info => GetInheritance(info)); classInfoHandler.CreateReferenceMembers(classInfo => GetReferenceMembers(classInfo, customer, order, orderLine), true); objectSpace.CommitChanges(); return persistentAssemblyBuilder.PersistentAssemblyInfo; }
public override void SaveDifference(ModelApplicationBase model) { if (model != null) { _objectSpace = _application.CreateObjectSpace() as ObjectSpace; ModelDifferenceObject modelDifferenceObject = GetActiveDifferenceObject(model.Id) ?? GetNewDifferenceObject(_objectSpace) .InitializeMembers(model.Id == "Application" ? Application.Title : model.Id, Application.Title, Application.GetType().FullName); OnDifferenceObjectSaving(modelDifferenceObject, model); } }
public void CurrentObject_Model_Should_Be_Validated_Every_Time_CurrentObject_Is_Saving(){ var editor = new ModelEditorPropertyEditor(null, null); bool validated = false; Isolate.WhenCalled(() => editor.Control.Controller.Dictionary.GetDiffs()).ReturnRecursiveFake(); Isolate.WhenCalled(() => editor.Control.Controller.Dictionary.Validate()).DoInstead(context => validated=true); var objectSpace = new ObjectSpace(new UnitOfWork(XpoDefault.DataLayer),XafTypesInfo.Instance); var modelDifferenceObject = new ModelDifferenceObject(objectSpace.Session) { PersistentApplication = new PersistentApplication(objectSpace.Session) }; editor.CurrentObject = modelDifferenceObject; editor.Setup(objectSpace, Isolate.Fake.Instance<XafApplication>()); objectSpace.CommitChanges(); Assert.IsTrue(validated); }
public static XPBaseObject GetXpObjectByKeyValue(ObjectSpace oSpace, string value, Type type) { if (string.IsNullOrEmpty(value)) return null; if (!type.IsSubclassOf(typeof(XPBaseObject))) return null; var keyPropertyName = oSpace.Session.GetClassInfo(type). PersistentProperties. OfType<XPMemberInfo>(). Where(p => p.HasAttribute(typeof(KeyPropertyAttribute))). Select(p => p.Name). FirstOrDefault() ?? oSpace.Session.GetClassInfo(type). PersistentProperties. OfType<XPMemberInfo>(). Where(p => p.Name == "Name" || p.Name == "Code") .Select(p => p.Name) .FirstOrDefault() ?? "Oid"; var item = (XPBaseObject)oSpace.FindObject( type, new BinaryOperator(keyPropertyName, value), true); if (item != null) return item; var nestedObjectSpace = oSpace.CreateNestedObjectSpace(); item = (XPBaseObject)nestedObjectSpace.CreateObject(type); item.ClassInfo.PersistentProperties. OfType<XPMemberInfo>(). Where(p => p.Name == keyPropertyName). FirstOrDefault(). SetValue(item, value); item.Save(); nestedObjectSpace.CommitChanges(); return oSpace.GetObject(item); }
private Permissao CadastrarTarefa() { Permissao CadTarefa = ObjectSpace.FindObject <Permissao>(new BinaryOperator("Name", "CadastrarTarefa")); if (CadTarefa == null) { CadTarefa = ObjectSpace.CreateObject <Permissao>(); CadTarefa.Name = "CadastrarTarefa"; } CadTarefa.PermissionPolicy = SecurityPermissionPolicy.DenyAllByDefault; CadTarefa.AddTypePermissionsRecursively <Tarefa>("Create;Write;Read;Delete", SecurityPermissionState.Allow); CadTarefa.AddTypePermissionsRecursively <SubTarefa>("Create;Write;Read;Delete", SecurityPermissionState.Allow); CadTarefa.AddTypePermissionsRecursively <Versao>("Read", SecurityPermissionState.Allow); CadTarefa.AddTypePermissionsRecursively <Usuario>("Read", SecurityPermissionState.Allow); CadTarefa.AddNavigationPermission(@"Application/NavigationItems/Items/Tarefas/Items/ConsultarTarefa_ListView", SecurityPermissionState.Allow); CadTarefa.AddNavigationPermission(@"Application/NavigationItems/Items/Tarefas/Items/CriarTarefa_DetailView", SecurityPermissionState.Allow); CadTarefa.AddNavigationPermission(@"Application/NavigationItems/Items/Tarefas/Items/Criar SubTarefa", SecurityPermissionState.Allow); CadTarefa.Save(); return(CadTarefa); }
void BindMember(IMemberInfo memberInfo) { var pivotedPropertyAttribute = memberInfo.FindAttribute <PivotedPropertyAttribute>(); IAnalysisInfo analysisInfo; if (string.IsNullOrEmpty(pivotedPropertyAttribute.AnalysisCriteria)) { analysisInfo = (IAnalysisInfo)ObjectSpace.CreateObject(memberInfo.MemberType); var pivotedType = View.ObjectTypeInfo.FindMember(pivotedPropertyAttribute.CollectionName).ListElementType; ((XPObjectSpace)ObjectSpace).Session.GetClassInfo(analysisInfo).GetMember(analysisInfo.GetPropertyName(x => x.DataType)).SetValue(analysisInfo, pivotedType); } else { analysisInfo = ObjectSpace.FindObject(memberInfo.MemberType, CriteriaOperator.Parse(pivotedPropertyAttribute.AnalysisCriteria)) as IAnalysisInfo; if (analysisInfo == null) { throw new UserFriendlyException(new Exception("Could not find a " + memberInfo.MemberType.Name + " object that can fit " + pivotedPropertyAttribute.AnalysisCriteria)); } } memberInfo.SetValue(View.CurrentObject, analysisInfo); }
//private Permissao ConsultarTarefa() //{ // Permissao consultarT = ObjectSpace.FindObject<Permissao>(new BinaryOperator("Name", "ConsultarTarefa")); // if (consultarT == null) // { // consultarT = ObjectSpace.CreateObject<Permissao>(); // consultarT.Name = "ConsultarTarefa"; // } // consultarT.PermissionPolicy = SecurityPermissionPolicy.DenyAllByDefault; // consultarT.Save(); // return consultarT; //} private Permissao DefinirResponsavel() { Permissao DefResp = ObjectSpace.FindObject <Permissao>(new BinaryOperator("Name", "DefinirResponsavel")); if (DefResp == null) { DefResp = ObjectSpace.CreateObject <Permissao>(); DefResp.Name = "DefinirResponsavel"; } DefResp.PermissionPolicy = SecurityPermissionPolicy.DenyAllByDefault; DefResp.AddTypePermissionsRecursively <Tarefa>("Write;Read", SecurityPermissionState.Allow); DefResp.AddTypePermissionsRecursively <SubTarefa>("Write;Read", SecurityPermissionState.Allow); DefResp.AddTypePermissionsRecursively <Usuario>("Read", SecurityPermissionState.Allow); DefResp.AddTypePermissionsRecursively <Versao>("Read", SecurityPermissionState.Allow); DefResp.AddTypePermissionsRecursively <Projeto>("Read", SecurityPermissionState.Allow); DefResp.AddNavigationPermission(@"Application/NavigationItems/Items/Tarefas/Items/ConsultarTarefa_ListView", SecurityPermissionState.Allow); DefResp.Save(); return(DefResp); }
public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); if (ObjectSpace.FindObject <Customer>(null) == null) { var customer = ObjectSpace.CreateObject <Customer>(); customer.Name = "Apostolis Bekiaris"; var order = ObjectSpace.CreateObject <Order>(); order.Quantity = 2; customer.Orders.Add(order); order = ObjectSpace.CreateObject <Order>(); order.Quantity = 3; customer.Orders.Add(order); order = ObjectSpace.CreateObject <Order>(); order.Quantity = 4; customer.Orders.Add(order); ObjectSpace.CommitChanges(); } }
public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); if (!ObjectSpace.GetObjectsQuery <Order>().Any()) { for (int i = 0; i < 2; i++) { var product = ObjectSpace.CreateObject <Product>(); product.ProductName = $"{nameof(Product.ProductName)}{i}"; var accessory = ObjectSpace.CreateObject <Accessory>(); accessory.Product = product; accessory.AccessoryName = $"{nameof(Accessory.AccessoryName)}{i}"; var order = ObjectSpace.CreateObject <Order>(); order.Product = product; order.Accessory = accessory; order.AggregatedOrders.Add(order); } ObjectSpace.CommitChanges(); } }
private void treeList_CellValueChanged(object sender, CellValueChangedEventArgs e) { object newValue = e.Value; if (e.Value is IXPSimpleObject) { newValue = ObjectSpace.GetObject(e.Value); } object focusedObject = treeList.FocusedObject; if (focusedObject != null) { IMemberInfo focusedColumnMemberInfo = ObjectSpace.TypesInfo.FindTypeInfo(focusedObject.GetType()).FindMember(e.Column.FieldName); if (focusedColumnMemberInfo != null) { focusedColumnMemberInfo.SetValue(focusedObject, Convert.ChangeType(newValue, focusedColumnMemberInfo.MemberType)); } } }
private void CreateDataToBeAnalysed() { Analysis taskAnalysis1 = ObjectSpace.FindObject <Analysis>(CriteriaOperator.Parse("Name='Completed tasks'")); if (taskAnalysis1 == null) { taskAnalysis1 = ObjectSpace.CreateObject <Analysis>(); taskAnalysis1.Name = "Completed tasks"; taskAnalysis1.ObjectTypeName = typeof(DemoTask).FullName; /*taskAnalysis1.Criteria = "[Status] = 'Completed'";*/ taskAnalysis1.Criteria = "[Status_Int] = " + ((Int32)TaskStatus.Completed).ToString(); } Analysis taskAnalysis2 = ObjectSpace.FindObject <Analysis>(CriteriaOperator.Parse("Name='Estimated and actual work comparison'")); if (taskAnalysis2 == null) { taskAnalysis2 = ObjectSpace.CreateObject <Analysis>(); taskAnalysis2.Name = "Estimated and actual work comparison"; taskAnalysis2.ObjectTypeName = typeof(DemoTask).FullName; } }
public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); if (!ObjectSpace.GetObjectsQuery <DocumentObject>().Any()) { var assembly = GetType().Assembly; var documentObject = ObjectSpace.CreateObject <DocumentObject>(); documentObject.Name = "Test document 1"; documentObject.Content = assembly.GetManifestResourceStream(assembly.GetManifestResourceNames().First(s => s.Contains("Lorem"))).Bytes(); documentObject = ObjectSpace.CreateObject <DocumentObject>(); documentObject.Name = "Test document 2"; documentObject.Content = assembly.GetManifestResourceStream(assembly.GetManifestResourceNames().First(s => s.Contains("Lorem2"))).Bytes(); documentObject = ObjectSpace.CreateObject <DocumentObject>(); documentObject.Name = "Test document 3"; documentObject.Content = assembly.GetManifestResourceStream(assembly.GetManifestResourceNames().First(s => s.Contains("Lorem3"))).Bytes(); documentObject = ObjectSpace.CreateObject <DocumentObject>(); documentObject.Name = "Template"; documentObject.Content = assembly.GetManifestResourceStream(assembly.GetManifestResourceNames().First(s => s.Contains("LoresumV2"))).Bytes(); ObjectSpace.CommitChanges(); } }
public void CreateFieldMapsFromStream() { var csvText = @"Description,Amount,MockLookupObject1,MockLookupObject2 Hello 1,10,Parent 1,Parent B1 Hello 2,11,Parent 2,Parent B2 Hello 3,12,Parent 3,Parent B3 Hello 4,13,Parent 4,Parent B4 "; var param = ObjectSpace.CreateObject <ImportHeadersParam>(); param.ObjectTypeName = "MockFactObject"; var csvStream = StringUtils.ConvertToCsvStream(csvText); var mapCreator = new FieldMapListCreator(csvStream); var fieldMaps = param.HeaderToFieldMaps; mapCreator.AppendFieldMaps(ObjectSpace.Session, fieldMaps); Assert.AreEqual(4, fieldMaps.Count); }
bool CancelNotSentMessage(UnitOfWork unitOfWork, object obj, MessageGeneratorRule rule) { var cancellationCriteriaResult = ObjectSpace.IsObjectFitForCriteria(obj, CriteriaOperator.Parse(rule.CancellationCriteria)); if (cancellationCriteriaResult != true) { return(false); } var classInfo = unitOfWork.GetClassInfo(obj); var key = classInfo.KeyProperty.GetValue(obj).ToString(); var notSentMessage = unitOfWork.Query <DoSoMessageBase>().Where(x => x.ExpiredOn == null && !x.IsSent && !x.IsCanceled && x.ObjectKey == key && x.ObjectTypeName == obj.GetType().FullName); foreach (var item in notSentMessage) { item.IsCanceled = true; item.StatusComment = string.Format("Cancelled From Rule - {0} {1}{2}{3}", rule.ID, DateTime.Now, Environment.NewLine, rule.CancellationComment); } return(true); }
/// <summary> /// Creates the log record. /// </summary> /// <param name="packageEventType">Type of the event.</param> /// <param name="comments">The comments.</param> public void CreateLogRecord(PackageEventType packageEventType, string comments) { if (IsInvalidated) { return; } var obs = ObjectSpace.FindObjectSpaceByObject(this); if (obs != null) { var nodeRecord = obs.CreateObject <PackageLogRecord>(); nodeRecord.FileName = FileName; nodeRecord.PackageEventType = packageEventType; nodeRecord.Comments = comments; if (XafDeltaModule.Instance.UseTickets && TicketEventTypes.Contains(packageEventType)) { Ticket.CreateForLogRecord(obs, nodeRecord, this); } } }
public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); #if !EASYTEST // Create 100 Issue objects with random Status: Random random = new Random(); for (int i = 0; i < 100; i++) { Issue issue = ObjectSpace.CreateObject <Issue>(); issue.Subject = String.Format("Issue {0:D3}", i); if (random.Next(3) == 0) { issue.Status = IssueStatus.Active; } else { issue.Status = IssueStatus.Closed; } } #endif }
private void AddRecipientAction_Execute(object sender, PopupWindowShowActionExecuteEventArgs e) { //Schedule currentSchedule = (Schedule)View.CurrentObject; Announcement currentAnnouncement = (Announcement)View.CurrentObject; View.ObjectSpace.SetModified(currentAnnouncement); foreach (Employee emp in e.PopupWindow.View.SelectedObjects) { Employee nEmp = ObjectSpace.GetObjectByKey <Employee>(emp.Oid); AnnouncementRecepients nRec = new AnnouncementRecepients(currentAnnouncement.Session); nRec.Employee = nEmp; nRec.Email = nEmp.CorporateEmail; currentAnnouncement.AnnouncementRecepients.Add(nRec); } if (View is DetailView && ((DetailView)View).ViewEditMode == ViewEditMode.View) { View.ObjectSpace.CommitChanges(); } }
public void ExceptionIfInsertInvalidHeader() { var xpoMapper = new XpoFieldMapper(); string csvText = @"Description,WrongAmount Hello 1,10 Hello 2,20 Hello 3,30"; var param = GetHeadMockParamObject(); var csvStream = ConvertToCsvStream(csvText); var request = ObjectSpace.CreateObject <ImportRequest>(); var logger = new ImportLogger(request); ICsvToXpoLoader loader = new HeadCsvToXpoInserter(param, csvStream, xpoMapper, logger); var ex = Assert.Throws <ArgumentException>(() => loader.Execute()); Assert.AreEqual("field", ex.ParamName); }
protected ImportHeadersParam GetHeadMockParamObject() { var map1 = ObjectSpace.CreateObject <HeaderToFieldMap>(); map1.SourceName = "Description"; map1.TargetName = map1.SourceName; var map2 = ObjectSpace.CreateObject <HeaderToFieldMap>(); map2.SourceName = "Amount"; map2.TargetName = map2.SourceName; var param = ObjectSpace.CreateObject <ImportHeadersParam>(); param.HeaderToFieldMaps.Add(map1); param.HeaderToFieldMaps.Add(map2); param.ObjectTypeName = "MockFactObject"; return(param); }
IPermissionPolicyRole InitVideoRentalSecurityData() { var defaultRole = (PermissionPolicyRole)ObjectSpace.GetDefaultRole(); if (ObjectSpace.IsNewObject(defaultRole)) { var employersRole = (IPermissionPolicyRole)ObjectSpace.GetRole("Employers"); var dashboardRole = (PermissionPolicyRole)ObjectSpace.GetRole("Dashboard View Role"); var user = (PermissionPolicyUser)((ISecurityRole)employersRole).GetUser("User"); var dashboardUser = (PermissionPolicyUser)dashboardRole.GetUser("DashboardUser"); user.Roles.Add(defaultRole); dashboardUser.Roles.Add(defaultRole); dashboardUser.Roles.Add(dashboardRole); ((ISecurityRole)employersRole).AddNewFullPermissionAttributes(); return(employersRole); } return(null); }
private PermissionPolicyRole CreateDefaultRole() { PermissionPolicyRole defaultRole = ObjectSpace.FindObject <PermissionPolicyRole>(new BinaryOperator("Name", "Default")); if (defaultRole == null) { defaultRole = ObjectSpace.CreateObject <PermissionPolicyRole>(); defaultRole.Name = "Default"; defaultRole.AddObjectPermission <PermissionPolicyUser>(SecurityOperations.Read, "[Oid] = CurrentUserId()", SecurityPermissionState.Allow); defaultRole.AddNavigationPermission(@"Application/NavigationItems/Items/Default/Items/MyDetails", SecurityPermissionState.Allow); defaultRole.AddMemberPermission <PermissionPolicyUser>(SecurityOperations.Write, "ChangePasswordOnFirstLogon", "[Oid] = CurrentUserId()", SecurityPermissionState.Allow); defaultRole.AddMemberPermission <PermissionPolicyUser>(SecurityOperations.Write, "StoredPassword", "[Oid] = CurrentUserId()", SecurityPermissionState.Allow); defaultRole.AddTypePermissionsRecursively <PermissionPolicyRole>(SecurityOperations.Read, SecurityPermissionState.Deny); defaultRole.AddTypePermissionsRecursively <ModelDifference>(SecurityOperations.ReadWriteAccess, SecurityPermissionState.Allow); defaultRole.AddTypePermissionsRecursively <ModelDifferenceAspect>(SecurityOperations.ReadWriteAccess, SecurityPermissionState.Allow); defaultRole.AddTypePermissionsRecursively <ModelDifference>(SecurityOperations.Create, SecurityPermissionState.Allow); defaultRole.AddTypePermissionsRecursively <ModelDifferenceAspect>(SecurityOperations.Create, SecurityPermissionState.Allow); } return(defaultRole); }
private void Duyet_Execute(object sender, SimpleActionExecuteEventArgs e) { LanTangCa lanTangCa = (LanTangCa)View.CurrentObject; lanTangCa.ngayDuyet = DateTime.Today; lanTangCa.nguoiDuyet = lanTangCa.Session.GetObjectByKey <NguoiDung>(SecuritySystem.CurrentUserId); CriteriaOperator criteriaOperator = CriteriaOperator.And(CriteriaOperator.Parse("[nguoiChamCong] = ?", lanTangCa.nguoiTangCa), CriteriaOperator.Parse("[ngay.ngayChamCong] = ?", lanTangCa.ngayTangCa)); GioCong gio = ObjectSpace.FindObject <GioCong>(criteriaOperator); if (!Equals(gio, null)) { gio.soGioTangCa = lanTangCa.thoiGianTangCa; gio.ngayDuyet = lanTangCa.ngayDuyet; lanTangCa.gioCong = gio; } ObjectSpace.CommitChanges(); ObjectSpace.Refresh(); View.Refresh(); }
private void CreateStateMachines() { if (ObjectSpace.QueryObject <XpoStateMachine>(machine => machine.Name == "Payment") == null) { var stateMachine = ObjectSpace.CreateObject <XpoStateMachine>(); stateMachine.Name = "Payment"; stateMachine.Active = true; stateMachine.TargetObjectType = typeof(PaymentTask); stateMachine.StatePropertyName = new StringObject("PaymentStatus"); stateMachine.States.AddRange(CreatePaymentStatusStates()); stateMachine.StartState = stateMachine.States.First(state => state.Caption == "New"); stateMachine = ObjectSpace.CreateObject <XpoStateMachine>(); stateMachine.Name = "Bill"; stateMachine.Active = true; stateMachine.TargetObjectType = typeof(PaymentTask); stateMachine.StatePropertyName = new StringObject("BillStatus"); stateMachine.States.AddRange(CreateBillStatusStates()); stateMachine.StartState = stateMachine.States.First(state => state.Caption == "Active"); } }
public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); if (ObjectSpace.QueryObject <PersistentAssemblyInfo>(info => info.Name == NorthWind) != null) { return; } var manifestResourceStream = GetType().Assembly.GetManifestResourceStream(GetType(), NorthWind + ".xml"); if (manifestResourceStream != null) { var connectionStringSettings = ConfigurationManager.ConnectionStrings["NorthWind"]; if (connectionStringSettings != null) { string connectionString = connectionStringSettings.ConnectionString; var readToEnd = new StreamReader(manifestResourceStream).ReadToEnd().Replace(@"XpoProvider=MSSqlServer;data source=(local);integrated security=SSPI;initial catalog=Northwind", connectionString); new ImportEngine().ImportObjects(readToEnd, info => ObjectSpace); } } }
private void ImportInContractBsrAction_Execute(object sender, SimpleActionExecuteEventArgs e) { TrwBudgetPeriod period = View.CurrentObject as TrwBudgetPeriod; if (period == null) { return; } OpenFileDialog dialog = new OpenFileDialog(); if (dialog.ShowDialog() != DialogResult.OK) { return; } using (IObjectSpace os = ObjectSpace.CreateNestedObjectSpace()) { period = os.GetObject <TrwBudgetPeriod>(period); StreamReader reader = File.OpenText(dialog.FileName); TrwBudgetPeriodLogic.ImportInContractBSR(period, os, reader); os.CommitChanges(); } }
public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); if (!ObjectSpace.GetObjectsQuery <PersistentAssemblyInfo>().Any(info => info.Name == "OneToMany")) { var persistentAssemblyInfo = ObjectSpace.CreateObject <PersistentAssemblyInfo>(); persistentAssemblyInfo.Name = "OneToMany"; var projectCassInfo = persistentAssemblyInfo.CreateClass("Project"); var contributorClassInfo = persistentAssemblyInfo.CreateClass("Contributor"); projectCassInfo.TypeAttributes.Add(ObjectSpace.CreateObject <PersistentDefaultClassOptionsAttribute>()); projectCassInfo.CreateSimpleMember(DBColumnType.String, "Name"); projectCassInfo.CreateCollection(contributorClassInfo).CreateAssociation("Project-Contributors"); contributorClassInfo.TypeAttributes.Add(ObjectSpace.CreateObject <PersistentDefaultClassOptionsAttribute>()); contributorClassInfo.CreateSimpleMember(DBColumnType.String, "Name"); contributorClassInfo.CreateReferenceMember(projectCassInfo).CreateAssociation("Project-Contributors"); ObjectSpace.CommitChanges(); } }
private void ViewOnCurrentObjectChanged(object sender, EventArgs args) { if (_previousObject != null && !(ObjectSpace.IsDisposedObject(_previousObject))) { _logicRuleExecutor.InvertExecution(View, ExecutionContext.CurrentObjectChanged, _previousObject, args); var notifyPropertyChanged = _previousObject as INotifyPropertyChanged; if (notifyPropertyChanged != null) { notifyPropertyChanged.PropertyChanged -= OnPropertyChanged; } } if (!_isRefreshing) { _logicRuleExecutor.Execute(ExecutionContext.CurrentObjectChanged, args, View); var notifyPropertyChanged = View.CurrentObject as INotifyPropertyChanged; if (notifyPropertyChanged != null) { notifyPropertyChanged.PropertyChanged += OnPropertyChanged; } } }
public void UpdateQuantityOnHand(EnumInventoryRecordType RecordType, Shop Shop, Unit TransactionUnit, double Quantity) { var itemQuantity = this.Inventory.FirstOrDefault(x => x.Shop == Shop); if (itemQuantity == null) { itemQuantity = ObjectSpace.CreateObject <ItemQuantity>(); itemQuantity.Shop = Shop; itemQuantity.LastPurchaseDate = DateTime.MinValue; itemQuantity.ItemCard = this; Inventory.Add(itemQuantity); } if (RecordType == EnumInventoryRecordType.In) { itemQuantity.QuantityOnHand += Math.Round(Quantity * TransactionUnit.ConversionRate, 3); } else { itemQuantity.QuantityOnHand -= Math.Round(Quantity * TransactionUnit.ConversionRate, 3); } }
protected override object CreateControlsCore() { var grid = base.CreateControlsCore(); var objectSapce = ObjectSpace.CreateNestedObjectSpace(); flightReportFilter = objectSapce.CreateObject <FlightReportFilter>(); //flightReportFilter = new FlightReportFilter(); string detailViewId = Application.FindDetailViewId(typeof(FlightReportFilter)); var view = Application.CreateDetailView(objectSapce, flightReportFilter, false); view.ViewEditMode = ViewEditMode.Edit; view.CreateControls(); //var editor = new DevExpress.ExpressApp.Web.Editors.WebLookupEditorHelper(Application, objectSapce, XafTypesInfo.CastTypeToTypeInfo(typeof(AircraftRegister)),null); // var editor = new ASPxLookupPropertyEditor(typeof(Aircraft), null); // editor.CreateControl(); var table = RenderHelper.CreateTable(); var mainViewRow = new TableRow(); var filterViewRow = new TableRow(); var mainViewTableCell = new TableCell(); var filterTableCell = new TableCell(); mainViewTableCell.Controls.Add((System.Web.UI.Control)grid); filterTableCell.Controls.Add((System.Web.UI.Control)view.Control); //filterTableCell.Controls.Add((System.Web.UI.Control)editor.Control); mainViewRow.Cells.Add(filterTableCell); filterViewRow.Cells.Add(mainViewTableCell); table.Rows.Add(mainViewRow); table.Rows.Add(filterViewRow); table.Style.Add("width", "auto"); table.Style.Add("border-spacing", "1px"); return(table); }
public void InsertSimpleOrdCsv() { // arrange parameters var map1 = ObjectSpace.CreateObject <OrdinalToFieldMap>(); map1.SourceOrdinal = 0; map1.TargetName = "Description"; var map2 = ObjectSpace.CreateObject <OrdinalToFieldMap>(); map2.SourceOrdinal = 1; map2.TargetName = "Amount"; var param = ObjectSpace.CreateObject <ImportOrdinalsParam>(); param.OrdToFieldMaps.Add(map1); param.OrdToFieldMaps.Add(map2); param.ObjectTypeName = "MockFactObject"; string csvText = @"Hello 1,10 Hello 2,20 Hello 3,30"; var csvStream = ConvertToCsvStream(csvText); var request = ObjectSpace.CreateObject <ImportRequest>(); var logger = new ImportLogger(request); var xpoMapper = new XpoFieldMapper(); ICsvToXpoLoader loader = new OrdCsvToXpoInserter(param, csvStream, xpoMapper, logger); loader.Execute(); var inserted = new XPQuery <MockFactObject>(ObjectSpace.Session); MockFactObject obj = inserted.Where(x => x.Description == "Hello 3").FirstOrDefault(); Assert.AreEqual(3, inserted.Count()); Assert.AreEqual(30, obj.Amount); Assert.AreEqual(null, obj.MockLookupObject1); }
public void DeleteLookupObjects() { #region Arrange for (int i = 0; i < 2; i++) { var lookup1 = ObjectSpace.CreateObject <MockLookupObject1>(); var lookup2 = ObjectSpace.CreateObject <MockLookupObject2>(); for (int j = 0; j < 2; j++) { var fact = ObjectSpace.CreateObject <MockFactObject>(); fact.LookupObject1 = lookup1; fact.LookupObject2 = lookup2; } } ObjectSpace.CommitChanges(); #endregion #region Delete Lookup Objects { var deleter = new BatchDeleter(ObjectSpace); var lookup1s = ObjectSpace.GetObjects <MockLookupObject1>(); deleter.Delete(lookup1s); } #endregion #region Assert { var facts = ObjectSpace.GetObjects <MockFactObject>(); var lookup1s = ObjectSpace.GetObjects <MockLookupObject1>(); var lookup2s = ObjectSpace.GetObjects <MockLookupObject2>(); Assert.AreEqual(0, lookup1s.Count); Assert.AreEqual(2, lookup2s.Count); Assert.AreEqual(0, facts.Count); } #endregion }
private void InitialDataEntryController_Activated(object sender, EventArgs e) { //เริ่มสร้าง OpenSendScore oss = ObjectSpace.FindObject <OpenSendScore>(CriteriaOperator.Parse("Open = ?", true)); if (oss != null) { if (oss.ERound != null) { Employee owner = ObjectSpace.GetObjectByKey <Employee>(SecuritySystem.CurrentUserId); Score oscore = ObjectSpace.FindObject <Score>(CriteriaOperator.Parse("ERound = ? AND Office=?", oss.ERound, 995)); if (oscore == null) { CreateAll(oss, owner); } else { MessageOptions options = new MessageOptions(); options.Duration = 2000; options.Message = string.Format("{0} มีการสร้างตารางข้อมูลแล้ว!!!", oss.ERound.Title); options.Type = InformationType.Error; options.Web.Position = InformationPosition.Top; options.Win.Caption = "Error"; options.Win.Type = WinMessageType.Flyout; Application.ShowViewStrategy.ShowMessage(options); } } } else { MessageOptions options = new MessageOptions(); options.Duration = 2000; options.Message = string.Format("ยังไม่เปิดให้บันทึกข้อมูล หรือ ไม่มีรอบประเมินที่เปิด!!!"); options.Type = InformationType.Error; options.Web.Position = InformationPosition.Top; options.Win.Caption = "Error"; options.Win.Type = WinMessageType.Flyout; Application.ShowViewStrategy.ShowMessage(options); } }
private IDCRole GetDefaultRole() { IDCRole defaultRole = ObjectSpace.FindObject <IDCRole>(new BinaryOperator("Name", "Default")); if (defaultRole == null) { defaultRole = ObjectSpace.CreateObject <IDCRole>(); defaultRole.Name = "Default"; IDCTypePermissions securityDemoUserPermissions = ObjectSpace.CreateObject <IDCTypePermissions>(); securityDemoUserPermissions.TargetType = typeof(IDCUser); defaultRole.TypePermissions.Add(securityDemoUserPermissions); IDCObjectPermissions myDetailsPermission = ObjectSpace.CreateObject <IDCObjectPermissions>(); myDetailsPermission.Criteria = "[Oid] = CurrentUserId()"; myDetailsPermission.AllowNavigate = true; myDetailsPermission.AllowRead = true; securityDemoUserPermissions.ObjectPermissions.Add(myDetailsPermission); IDCTypePermissions userPermissions = ObjectSpace.CreateObject <IDCTypePermissions>(); userPermissions.TargetType = typeof(IDCUser); defaultRole.TypePermissions.Add(userPermissions); IDCMemberPermissions ownPasswordPermission = ObjectSpace.CreateObject <IDCMemberPermissions>(); ownPasswordPermission.Members = "ChangePasswordOnFirstLogon; StoredPassword"; ownPasswordPermission.AllowWrite = true; userPermissions.MemberPermissions.Add(ownPasswordPermission); IDCTypePermissions securityRolePermissions = ObjectSpace.CreateObject <IDCTypePermissions>(); securityRolePermissions.TargetType = typeof(IDCRole); defaultRole.TypePermissions.Add(userPermissions); IDCObjectPermissions defaultRolePermission = ObjectSpace.CreateObject <IDCObjectPermissions>(); defaultRolePermission.Criteria = "[Name] = 'Default'"; defaultRolePermission.AllowNavigate = true; defaultRolePermission.AllowRead = true; securityRolePermissions.ObjectPermissions.Add(defaultRolePermission); } return(defaultRole); }
private PermissionPolicyRole GetAccountantRole() { PermissionPolicyRole role = ObjectSpace.FindObject <PermissionPolicyRole>(new BinaryOperator("Name", "Accountants")); if (role == null) { role = ObjectSpace.CreateObject <PermissionPolicyRole>(); role.Name = "Accountants"; role.AddNavigationPermission("Application/NavigationItems/Items/Default/Items/MyDetails", SecurityPermissionState.Allow); role.AddNavigationPermission("Application/NavigationItems/Items/Default/Items/Department_ListView", SecurityPermissionState.Allow); role.AddNavigationPermission("Application/NavigationItems/Items/Default/Items/Employee_ListView", SecurityPermissionState.Allow); role.AddNavigationPermission("Application/NavigationItems/Items/Default/Items/Customer_ListView", SecurityPermissionState.Allow); role.AddNavigationPermission("Application/NavigationItems/Items/Default/Items/Invoice_ListView", SecurityPermissionState.Allow); role.AddObjectPermission <Department>(SecurityOperations.Read, "Employees[Oid=CurrentUserId()]", SecurityPermissionState.Allow); role.SetTypePermission <Employee>(SecurityOperations.Create, SecurityPermissionState.Allow); role.AddObjectPermission <Employee>(SecurityOperations.FullObjectAccess, "IsNull(Department) || Department.Employees[Oid=CurrentUserId()]", SecurityPermissionState.Allow); role.SetTypePermission <EmployeeTask>(SecurityOperations.Create, SecurityPermissionState.Allow); role.AddObjectPermission <EmployeeTask>(SecurityOperations.FullObjectAccess, "IsNull(AssignedTo) || IsNull(AssignedTo.Department) || AssignedTo.Department.Employees[Oid=CurrentUserId()]", SecurityPermissionState.Allow); role.SetTypePermission <PermissionPolicyRole>(SecurityOperations.Read, SecurityPermissionState.Allow); role.SetTypePermission <Department>(SecurityOperations.Read, SecurityPermissionState.Allow); // role.SetTypePermission<Invoice>(SecurityOperations.Create, SecurityPermissionState.Allow); role.SetTypePermission <InvoiceItem>(SecurityOperations.FullObjectAccess, SecurityPermissionState.Allow); role.SetTypePermission <Product>(SecurityOperations.Read, SecurityPermissionState.Allow); role.SetTypePermission <Customer>(SecurityOperations.Read, SecurityPermissionState.Allow); role.AddObjectPermission <Invoice>(SecurityOperations.FullObjectAccess, "[Klient] Is Null Or [Klient.Consultant] Is Null Or [Klient.Consultant.Department.Employees][[Oid] = CurrentUserId()]", SecurityPermissionState.Allow); role.AddObjectPermission <Customer>(SecurityOperations.FullObjectAccess, "[Consultant] Is Null Or [Consultant.Department.Employees][[Oid] = CurrentUserId()]", SecurityPermissionState.Allow); // role.AddObjectPermission<Empl>(SecurityOperations.FullObjectAccess, "[Consultant] Is Null Or [Consultant.Department.Employees][[Oid] = CurrentUserId()]", SecurityPermissionState.Allow); } return(role); }
public int ImportObjects(Stream stream, ObjectSpace objectSpace) { var unitOfWork = ((UnitOfWork) objectSpace.Session); stream.Position = 0; using (var streamReader = new StreamReader(stream)) { var xDocument = XDocument.Load(streamReader); if (xDocument.Root != null) { foreach (XElement element in xDocument.Root.Nodes()) { using (var nestedUnitOfWork = unitOfWork.BeginNestedUnitOfWork()) { ITypeInfo typeInfo = GetTypeInfo(element); IEnumerable<XElement> elements = element.Descendants("Property"); var xElements = elements.Where(xElement => xElement.GetAttributeValue("isKey").MakeFirstCharUpper() == true.ToString()); CriteriaOperator objectKeyCriteria = getObjectKeyCriteria(typeInfo, xElements); createObject(element, nestedUnitOfWork,typeInfo, objectKeyCriteria); nestedUnitOfWork.CommitChanges(); } } unitOfWork.CommitChanges(); } } return 0; }
IEnumerable<IClassInfoGraphNode> GetGraph(ObjectSpace objectSpace, Type typeToSerialize, Action<IList<IMemberInfo>> action) { var classInfoGraphNodes = new List<IClassInfoGraphNode>(); IList<IMemberInfo> memberInfos = GetMemberInfos(typeToSerialize); if (action != null) action.Invoke(memberInfos); foreach (IMemberInfo memberInfo in memberInfos) { var classInfoGraphNode = (IClassInfoGraphNode)objectSpace.CreateObject(TypesInfo.Instance.ClassInfoGraphNodeType); classInfoGraphNode.Name = memberInfo.Name; classInfoGraphNodes.Add(classInfoGraphNode); if (memberInfo.MemberTypeInfo.IsPersistent) Generate(classInfoGraphNode, memberInfo.MemberTypeInfo, objectSpace, action); else if (memberInfo.MemberTypeInfo.IsListType) { string name = memberInfo.Owner.Name; Generate(classInfoGraphNode, memberInfo.ListElementTypeInfo, objectSpace, infos => infos.Remove(infos.Where(info => info.Name == name).Single())); } } return classInfoGraphNodes; }
/// <summary> /// Compiles this ObjectExpression using the mappings found the specified ObjectSpace instance. /// </summary> /// <param name="os">ObjectSpace instance to use.</param> /// <returns>A CompiledQuery that is the result of this instance being compiled.</returns> public CompiledQuery Compile(ObjectSpace os) { if( os == null ) throw new ArgumentNullException("os"); _maps = os.context.Mappings; return new CompiledQuery(this); }
public Updater(ObjectSpace objectSpace, Version currentDBVersion) : base(objectSpace, currentDBVersion) { }
public static bool IsConfictPrerequisite(ObjectSpace objectspace, string studentCode, string subjectCode, out int checkresult, out string subjectcoderesult) { XPCollection<SubjectRelations> xpcSubjectRelation = new XPCollection<SubjectRelations>(objectspace.Session, new BinaryOperator("Subject2.SubjectCode",subjectCode)); checkresult = 0; subjectcoderesult = ""; if (xpcSubjectRelation.Count == 0) return false; else { foreach (SubjectRelations subjectRelation in xpcSubjectRelation) { if (subjectRelation.Type == 1) //học trước { XPCollection<StudentResult> xpcStudResult = new XPCollection<StudentResult>(objectspace.Session, new GroupOperator(GroupOperatorType.And,new BinaryOperator("Student.StudentCode",studentCode), new BinaryOperator("Lesson.Subject.SubjectCode", subjectRelation.Subject1.SubjectCode))); if (xpcStudResult.Count == 0) { checkresult = 1; subjectcoderesult = subjectRelation.Subject1.SubjectCode; return true; } } else if (subjectRelation.Type == 2) // tiên quyết { XPCollection<StudentResult> xpcStudResult = new XPCollection<StudentResult>(objectspace.Session, new GroupOperator(GroupOperatorType.And, new BinaryOperator("Student.StudentCode", studentCode), new BinaryOperator("Lesson.Subject.SubjectCode", subjectRelation.Subject1.SubjectCode), CriteriaOperator.Parse("AvgMark4>=1.5"))); if (xpcStudResult.Count == 0) { checkresult = 2; subjectcoderesult = subjectRelation.Subject1.SubjectCode; return true; } } } return false; } }
protected internal override ModelDifferenceObject GetNewDifferenceObject(ObjectSpace session) { return new ModelDifferenceObject(ObjectSpace.Session); }
public ExtraInfoBuilder(ObjectSpace objectSpace, AttributeMapper attributeMapper) { _attributeMapper = attributeMapper; _objectSpace = objectSpace; }
public static XPCollection<ClassTransactionTracking> CreateStudentClassTrackingData(ObjectSpace objectSpace, string semesterName) { string strParse = ""; try { using (XPCollection<StudentClass> xpw = new XPCollection<StudentClass>(objectSpace.Session)) { foreach (StudentClass studentClass in xpw) { ClassTransactionTracking ct = objectSpace.FindObject<ClassTransactionTracking> (CriteriaOperator.Parse("StudentClass.ClassCode = ? and Semester.SemesterName = ?", studentClass.ClassCode, semesterName)); if (ct == null) { ct = objectSpace.CreateObject< ClassTransactionTracking>(); ct.Semester = objectSpace.FindObject<Semester>(CriteriaOperator.Parse("SemesterName=?", semesterName)); ct.StudentClass = objectSpace.FindObject<StudentClass>(CriteriaOperator.Parse("ClassCode=?", studentClass.ClassCode)); ct.Save(); } strParse += (strParse == "" ? string.Format("StudentClass.ClassCode='{0}'", studentClass.ClassCode) : string.Format(" or StudentClass.ClassCode='{0}'", studentClass.ClassCode)); } objectSpace.CommitChanges(); strParse = string.Format("({0}) and Semester.SemesterName= '{1}'", strParse, semesterName); } } catch (Exception ex) { throw new UserFriendlyException(string.Format("Lỗi thực hiện: {0}\r\n Strack trace:{1}", ex.Message, ex.StackTrace)); } return new XPCollection<ClassTransactionTracking>(objectSpace.Session, CriteriaOperator.Parse(strParse)); }
/// <summary> /// Compiles this OPathQuery using the mappings found in the specified ObjectSpace instance. /// </summary> /// <param name="os">ObjectSpace instance to use.</param> /// <returns>A CompiledQuery that is the result of this instance being compiled.</returns> public CompiledQuery Compile(ObjectSpace os) { ObjectExpression oe = OPath.Parse(this, os.context.Mappings); return new CompiledQuery(oe); }
public static XPCollection<AccountTransactionTracking> CreateStudentClassTransactionTrackingData(ObjectSpace objectSpace, string classCode, string semesterName) { try { using (XPCollection<AccountTransactionTracking> xpw = new XPCollection<AccountTransactionTracking>(objectSpace.Session, new BinaryOperator("Student.StudentClass.ClassCode", classCode))) { objectSpace.Delete(xpw); objectSpace.CommitChanges(); StudentClass studentClass = objectSpace.FindObject<StudentClass>( new BinaryOperator("ClassCode", classCode)); Semester semester = objectSpace.FindObject<Semester>( new BinaryOperator("SemesterName", semesterName)); DateTime semesterLastDate = semester.StartDate.AddDays(semester.NumberOfWeek * 7); decimal beforedebtvalue=0; decimal requestvalue= 0; decimal paidvalue = 0; if (studentClass != null && semester != null) { foreach (Student student in studentClass.Students) { beforedebtvalue = 0; requestvalue = 0; paidvalue = 0; foreach (AccountTransaction accTrans in student.AccountTransactions) { if ((accTrans.Semester != null && Convert.ToInt32(accTrans.Semester.SemesterName)<Convert.ToInt32(semester.SemesterName))) //||accTrans.TransactingDate< semester.StartDate) beforedebtvalue += accTrans.MoneyAmount; else if (//accTrans.TransactingDate <= semesterLastDate || (accTrans.Semester!=null && accTrans.Semester.SemesterName ==semester.SemesterName)) { if (accTrans.MoneyAmount < 0) //money has to paid { requestvalue += (-accTrans.MoneyAmount); } else //money has paid { paidvalue += accTrans.MoneyAmount; } } } AccountTransactionTracking accTracking = objectSpace.CreateObject<AccountTransactionTracking>(); accTracking.Student = student; accTracking.Semester = semester; accTracking.BeforeDebtValue = -beforedebtvalue; accTracking.PaidValue= paidvalue; accTracking.RequestValue = requestvalue; accTracking.Save(); } objectSpace.CommitChanges(); } } } catch (Exception ex) { throw new UserFriendlyException("Lỗi thực hiện: " + ex.Message); } return new XPCollection<AccountTransactionTracking>(objectSpace.Session, new BinaryOperator("Student.StudentClass.ClassCode", classCode)); }
public LinqServerCollectionSource(ObjectSpace objectSpace, Type objectType,IQueryable queryable) : base(objectSpace, objectType) { Query=queryable; }
protected override CollectionSourceBase CreateCollectionSourceCore(ObjectSpace objectSpace, Type objectType, string listViewID) { CollectionSourceBase result = null; if(Model != null) { if(!String.IsNullOrEmpty(listViewID)) { DictionaryNode listViewNode = FindViewInfo(listViewID); if(listViewNode != null) { var listViewInfo = new ListViewInfoNodeWrapper(listViewNode); if(listViewInfo.UseServerMode && (!listViewInfo.AllowEdit)) { result = new LinqServerCollectionSource(objectSpace, objectType); } } } } return result ?? (new LinqCollectionSource(objectSpace, objectType)); }
public LinqServerCollectionSource(ObjectSpace objectSpace, Type objectType) : base(objectSpace, objectType) { }
public static XPCollection<WeekReportData> CreateClassroomTimetableData(ObjectSpace objectSpace, string classroomCode, string semesterName) { ConstrainstParameter cp = objectSpace.FindObject<ConstrainstParameter>( new BinaryOperator("Code", "AFTERNOONPERIODCOUNT")); int afternoonPeriodCount = Convert.ToInt32(cp.Value); cp = objectSpace.FindObject<ConstrainstParameter>( new BinaryOperator("Code", "MORNINGPERIODCOUNT")); int morningPeriodCount = Convert.ToInt32(cp.Value); try { using (XPCollection<WeekReportData> xpw = new XPCollection<WeekReportData>(objectSpace.Session, new ContainsOperator("Classrooms", new BinaryOperator("ClassroomCode", classroomCode)))) { objectSpace.Delete(xpw); objectSpace.CommitChanges(); using (XPCollection<TkbSemester> xpctkbSemester = new XPCollection<TkbSemester>(objectSpace.Session, new GroupOperator(GroupOperatorType.And, new BinaryOperator("Lesson.Semester.SemesterName", semesterName), new BinaryOperator("Classroom.ClassroomCode", classroomCode)))) { Dictionary<string, WeekReportData> dicTimePeriodforWeekData = new Dictionary<string, WeekReportData>(); WeekReportData currentWeekData; foreach (TkbSemester tkbSem in xpctkbSemester) { string[] strperiod = tkbSem.Period.Split(','); List<string> periodTimeList = new List<string>(); foreach (string s in strperiod) { if (Convert.ToInt32(s) >= 1 && Convert.ToInt32(s) <= morningPeriodCount) if (!periodTimeList.Contains("Sáng")) periodTimeList.Add("Sáng"); if (Convert.ToInt32(s) > morningPeriodCount && Convert.ToInt32(s) <= (morningPeriodCount + afternoonPeriodCount)) if (!periodTimeList.Contains("Chiều")) periodTimeList.Add("Chiều"); if (Convert.ToInt32(s) > (morningPeriodCount + afternoonPeriodCount)) if (!periodTimeList.Contains("Tối")) periodTimeList.Add("Tối"); } foreach (String period in periodTimeList) { if (!dicTimePeriodforWeekData.ContainsKey(period)) { currentWeekData = objectSpace.CreateObject<WeekReportData>(); currentWeekData.Semester = objectSpace.FindObject<Semester>( CriteriaOperator.Parse("SemesterName = ?", semesterName)); currentWeekData.Classrooms.Add(objectSpace.FindObject<Classroom>( CriteriaOperator.Parse("ClassroomCode=?", classroomCode))); currentWeekData.PeriodTime = period; dicTimePeriodforWeekData.Add(period, currentWeekData); } dicTimePeriodforWeekData[period][tkbSem.Day] += string.Format("Lớp:{0}\r\n Môn:{1}-{2}\r\nTiết:{3}\r\nTuần:{4}\r\n\r\n", tkbSem.Lesson.ClassIDs, tkbSem.Lesson.Subject.SubjectCode, tkbSem.Lesson.Subject.SubjectName, Utils.ShortStringPeriod(tkbSem.Period), Utils.ShortStringWeek(tkbSem.StringWeeks)); } } objectSpace.CommitChanges(); } } } catch (Exception ex) { throw new UserFriendlyException("Lỗi thực hiện: " + ex.Message); } return new XPCollection<WeekReportData>(objectSpace.Session, new GroupOperator(GroupOperatorType.And, new BinaryOperator("Semester.SemesterName", semesterName), new ContainsOperator("Classrooms", new BinaryOperator("ClassroomCode", classroomCode)))); }
public void Setup(ObjectSpace space, XafApplication app) { _application = app; space.ObjectSaving+=SpaceOnObjectSaving; }
public ColumnMapper(DataTypeMapper dataTypeMapper, AttributeMapper attributeMapper) { _dataTypeMapper = dataTypeMapper; _attributeMapper = attributeMapper; _objectSpace = _attributeMapper.ObjectSpace; _extraInfoBuilder = new ExtraInfoBuilder(_objectSpace, _attributeMapper); }
public TableMapper(ObjectSpace objectSpace,Database database,AttributeMapper attributeMapper) { _objectSpace = objectSpace; _database = database; _attributeMapper = attributeMapper; _extraInfoBuilder = new ExtraInfoBuilder(_objectSpace, _attributeMapper); }