public ActionResult Get() { Init(); IQueryable <Department> departments = ObjectSpace.GetObjects <Department>().AsQueryable(); return(Ok(departments)); }
public ActionResult GetPermissions(ODataActionParameters parameters) { ActionResult result = NoContent(); if (parameters.ContainsKey("keys") && parameters.ContainsKey("typeName")) { List <string> keys = new List <string>(parameters["keys"] as IEnumerable <string>); string typeName = parameters["typeName"].ToString(); List <PermissionContainer> permissionContainerList = new List <PermissionContainer>(); ITypeInfo typeInfo = ObjectSpace.TypesInfo.PersistentTypes.FirstOrDefault(t => t.Name == typeName); if (typeInfo != null) { Type type = typeInfo.Type; IList entityList = ObjectSpace.GetObjects(type, new InOperator(typeInfo.KeyMember.Name, keys)); foreach (var entity in entityList) { PermissionContainer permissionContainer = new PermissionContainer(); permissionContainer.Key = typeInfo.KeyMember.GetValue(entity).ToString(); IEnumerable <IMemberInfo> memberList = GetPersistentMembers(typeInfo); foreach (IMemberInfo member in memberList) { bool permission = Security.IsGranted(new PermissionRequest(ObjectSpace, type, SecurityOperations.Read, entity, member.Name)); permissionContainer.Data.Add(member.Name, permission); } permissionContainerList.Add(permissionContainer); } result = Ok(permissionContainerList.AsQueryable()); } } return(result); }
public void DeleteSnapshots() { #region Arrange var ccyAUD = ObjectSpace.FindObject <Currency>(CriteriaOperator.Parse("Name = ?", "AUD")); var account = ObjectSpace.CreateObject <Account>(); account.Name = "VHA ANZ AUD"; account.Currency = ccyAUD; var activity = ObjectSpace.CreateObject <Activity>(); activity.Name = "AR Rcpt"; #endregion #region Create Snapshot for (int i = 0; i < 3; i++) { // create snapshot var snapshot = ObjectSpace.CreateObject <CashFlowSnapshot>(); snapshot.Name = string.Format("Snapshot {0}", i); // create cash flows for (int j = 0; j < 2; j++) { var cf1 = ObjectSpace.CreateObject <CashFlow>(); cf1.Snapshot = snapshot; cf1.TranDate = new DateTime(2014, 03, 31); cf1.Account = account; cf1.Activity = activity; cf1.AccountCcyAmt = 1000; } } ObjectSpace.CommitChanges(); Assert.AreEqual(3 * 2, ObjectSpace.GetObjects <CashFlow>().Count); Assert.AreEqual(4, ObjectSpace.GetObjects <CashFlowSnapshot>().Count); #endregion #region Delete Snapshot var controller = Application.CreateController <CashFlowSnapshotViewController>(); var view = Application.CreateDetailView(ObjectSpace, ObjectSpace.FindObject <CashFlowSnapshot>(null)); controller.SetView(view); var snapshots = ObjectSpace.GetObjects <CashFlowSnapshot>(); controller.DeleteSnapshots(snapshots); ObjectSpace.Session.PurgeDeletedObjects(); #endregion #region Assert Assert.AreEqual(0, ObjectSpace.GetObjects <CashFlow>().Count); Assert.AreEqual(0, ObjectSpace.GetObjects <CashFlowSnapshot>().Count); #endregion }
/// <summary> /// Called when the View is activated. /// </summary> protected override void OnActivated() { filteringCriterionAction.Items.Clear(); IEnumerable <FilteringCriterion> criterions = ObjectSpace.GetObjects <FilteringCriterion>(); criterions = from FilteringCriterion cl in criterions orderby cl.Description select cl; foreach (FilteringCriterion criterion in criterions) { try { if (criterion.Object.IsAssignableFrom(View.ObjectTypeInfo.Type) && (criterion.Public || criterion.User.UserName == SecuritySystem.CurrentUserName)) { filteringCriterionAction.Items.Add( new ChoiceActionItem(criterion.Description, criterion.FilterCriteria)); } } catch (Exception e) { log.Error($"OnActivated[{ criterion.Oid }]", e); } } if (filteringCriterionAction.Items.Count > 0) { filteringCriterionAction.Items.Add(new ChoiceActionItem("Показать все", null)); } }
public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); ObjectSpace.Delete(ObjectSpace.GetObjects <Note>()); ObjectSpace.Delete(ObjectSpace.GetObjects <TaskType>()); ObjectSpace.CommitChanges(); for (int i = 0; i < 1000; i++) { Note note = ObjectSpace.CreateObject <Note>(); note.Name = "note " + i; } TaskType taskType = ObjectSpace.CreateObject <TaskType>(); taskType.Name = "2"; XpoWorkflowDefinition wfDefinition = ObjectSpace.FindObject <XpoWorkflowDefinition>(new BinaryOperator("Name", "Simple performance test")); if (wfDefinition == null) { wfDefinition = ObjectSpace.CreateObject <XpoWorkflowDefinition>(); wfDefinition.Name = "Simple performance test"; wfDefinition.Criteria = "[IsProcessed] = False"; Version ver = typeof(XafApplication).Assembly.GetName().Version; wfDefinition.Xaml = string.Format(Xaml1, ver.Major, ver.Minor); wfDefinition.TargetObjectType = typeof(Note); wfDefinition.AutoStartWhenObjectFitsCriteria = true; wfDefinition.AutoStartWhenObjectIsCreated = false; wfDefinition.IsActive = true; } ObjectSpace.CommitChanges(); }
public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); if (ObjectSpace.GetObjects <DomainObject1>().Count == 0) { double i = 1; double inc = 1.0 / 20.0; while (i < 3) { DomainObject1 do1 = ObjectSpace.CreateObject <DomainObject1>(); i += inc; do1.Property1 = (int)i; i += inc; do1.Property2 = (int)i; i += inc; do1.Property3 = (int)i; i += inc; do1.Property4 = (int)i; i += inc; do1.Property5 = (int)i; i += inc; do1.Property6 = (int)i; do1.Save(); } } CreateReport("XafReport"); }
private void duyetNghiPhep_Execute(object sender, SimpleActionExecuteEventArgs e) { LanNghiPhep lanNghiPhep = (LanNghiPhep)View.CurrentObject; //string condition = CriteriaOperator.And(CriteriaOperator.Parse("[nguoiNghiPhep] = ?",lanNghiPhep.nguoiNghiPhep), CriteriaOperator.Parse("GetMonth([ngayNghi])",DateTime.Today.Month)).ToString(); CriteriaOperator criteria = CriteriaOperator.And(CriteriaOperator.Parse("[nguoiNghiPhep] = ?", lanNghiPhep.nguoiNghiPhep), CriteriaOperator.Parse("IsThisMonth([ngayNghi])")); IList <LanNghiPhep> lanNghiPheps = ObjectSpace.GetObjects <LanNghiPhep>(criteria); CriteriaOperator criteriaOperator = CriteriaOperator.And(CriteriaOperator.Parse("[nguoiNghiPhep] = ?", lanNghiPhep.nguoiNghiPhep), CriteriaOperator.Parse("IsThisMonth([ngayNghi])"), CriteriaOperator.Parse("[ngayDuyet] Is Not Null")); IList <LanNghiPhep> daDuyets = ObjectSpace.GetObjects <LanNghiPhep>(criteriaOperator); lanNghiPhep.ngayDuyet = DateTime.Today; lanNghiPhep.nguoiDuyet = lanNghiPhep.Session.GetObjectByKey <NguoiDung>(SecuritySystem.CurrentUserId); MessageBox.Show("Đã Duyệt Thành Công"); //if (lanNghiPhep.Session.GetObjectByKey<NguoiDung>(SecuritySystem.CurrentUserId).EmployeeRoles.) //{ // if((lanNghiPheps.Count >= 3) && (daDuyets.Count >= 2)) // { // MessageBox.Show("Không Được phép duyệt, vì đã nghỉ 2 ngày trước đó"); // } // else // { // lanNghiPhep.ngayDuyet = DateTime.Today; // lanNghiPhep.nguoiDuyet = lanNghiPhep.Session.GetObjectByKey<NguoiDung>(SecuritySystem.CurrentUserId); // MessageBox.Show("Đã Duyệt Thành Công"); // MessageBox.Show(daDuyets.Count.ToString()); // } //} ObjectSpace.CommitChanges(); ObjectSpace.Refresh(); View.Refresh(); }
protected override void OnActivated() { base.OnActivated(); string condition = CriteriaOperator.And(CriteriaOperator.Parse("[ngayDuyet] Is Null")).ToString(); CriteriaOperator criteria = CriteriaOperator.Parse(condition); IList <LanTangCa> lanTangCas = ObjectSpace.GetObjects <LanTangCa>(criteria); Console.WriteLine("Cap nhat lan tang ca"); foreach (LanTangCa lanTangCa in lanTangCas) { 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.duyetTangCa = false; } lanTangCa.gioCong = gio; } ObjectSpace.CommitChanges(); ObjectSpace.Refresh(); View.Refresh(); // Perform various tasks depending on the target View. }
public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); //string name = "MyName"; //DomainObject1 theObject = ObjectSpace.FindObject<DomainObject1>(CriteriaOperator.Parse("Name=?", name)); //if(theObject == null) { // theObject = ObjectSpace.CreateObject<DomainObject1>(); // theObject.Name = name; //} var cnt = ObjectSpace.GetObjects <Contact>().Count; if (cnt > 0) { return; } for (int i = 0; i < 2; i++) { string contactName = "FirstName" + i; var contact = CreateObject <Contact>("FirstName", contactName); contact.LastName = "LastName" + i; contact.Age = i * 10; for (int j = 0; j < 2; j++) { string taskName = "Subject" + i + " - " + j; var task = CreateObject <MyTask>("Subject", taskName); task.AssignedTo = contact; } } //secur#0 ObjectSpace.CommitChanges(); //Uncomment this line to persist created object(s). }
private void ResetPortal() { var objSpace = (XPObjectSpace)ObjectSpace; var classInfo = objSpace.Session.GetClassInfo <ActionPortal>(); #region repopulate actions var softPortal = new ActionPortalLogic(); var hardPortal = new ActionPortalHardLogic(softPortal); var intlObjs = ObjectSpace.GetObjects <ActionPortal>( CriteriaOperator.Parse("ActionPortalType = ?", ActionPortalType.Internal)); ObjectSpace.Delete(intlObjs); foreach (var portalItem in hardPortal.ActionPortalList) { var portalObj = ObjectSpace.CreateObject <ActionPortal>(); portalObj.ActionPortalType = ActionPortalType.Internal; portalObj.ActionName = portalItem.ActionName; portalObj.ActionDescription = portalItem.ActionDescription; } ObjectSpace.CommitChanges(); #endregion }
ReadOnlyCollection <string> GetStateCaptions(PropertyEditor propertyEditor) { var stateMachineName = propertyEditor.ControlValue as string; return(ObjectSpace.GetObjects <XpoState>(state => state.StateMachine.Name == stateMachineName).Select( state => state.Caption).ToList().AsReadOnly()); }
public void OnCreated() { CreatedDate = DateTime.Now; Creator = GetCurrentUser(); State = OrderState.New; PriceList = ObjectSpace.GetObjects <PriceList>(new BinaryOperator("Name", "Основной прайс-лист")).FirstOrDefault(); }
/// <summary> /// Called when the View is activated. /// </summary> protected override void OnActivated() { filteringCriterionAction.Items.Clear(); IEnumerable <FilteringCriterion> criterions = ObjectSpace.GetObjects <FilteringCriterion>(); criterions = from FilteringCriterion cl in criterions orderby cl.Beschreibung select cl; foreach (FilteringCriterion criterion in criterions) { try { if (criterion.Objekt != null) { if (criterion.Objekt.IsAssignableFrom(View.ObjectTypeInfo.Type) && (criterion.Public || criterion.User.UserName == SecuritySystem.CurrentUserName)) { filteringCriterionAction.Items.Add( new ChoiceActionItem(criterion.Beschreibung, criterion.FilterKriterium)); } } } catch { } } if (filteringCriterionAction.Items.Count > 0) { filteringCriterionAction.Items.Add(new ChoiceActionItem("Alle Datensätze anzeigen", null)); } }
private void ObjectSpace_Committing(object sender, CancelEventArgs e) { var source = from p in ObjectSpace.ModifiedObjects.OfType <I单据编号>() where ObjectSpace.IsNewObject(p) select p; if (source.Any()) { var dictionary = ObjectSpace.GetObjects <单据编号方案>(null, true).ToDictionary(p => p.应用单据); foreach (I单据编号 i单据编号 in source) { if (string.IsNullOrEmpty(i单据编号.编号)) { var key = i单据编号.GetType(); 单据编号方案 solution = null; if (dictionary.ContainsKey(key)) { solution = dictionary[key]; i单据编号.编号 = solution.生成编号(i单据编号 as XPBaseObject); } else { //throw new Exception("错误,没有找到编号方案!"); } } } } }
void CreateXpoWorrkflowDefinitions() { if (ObjectSpace.GetObjects <XpoWorkflowDefinition>().Count == 0) { var definition = ObjectSpace.CreateObject <XpoWorkflowDefinition>(); definition.Name = "Create Task for active Issue"; definition.Xaml = CreateTaskForActiveIssueWorkflowXaml.Replace(".v13.2", AssemblyInfo.VSuffix); definition.TargetObjectType = typeof(Issue); definition.AutoStartWhenObjectFitsCriteria = true; definition.Criteria = "[Active] = True"; definition.IsActive = true; var codeActivityDefinition = ObjectSpace.CreateObject <XpoWorkflowDefinition>(); codeActivityDefinition.Name = "Create Task for active Issue (Code Activity)"; codeActivityDefinition.Xaml = CodeActivityCreateTaskForActiveIssueWorkflowXaml.Replace(".v13.2", AssemblyInfo.VSuffix); codeActivityDefinition.TargetObjectType = typeof(Issue); codeActivityDefinition.AutoStartWhenObjectFitsCriteria = true; codeActivityDefinition.Criteria = "Contains([Subject], 'Code Activity')"; codeActivityDefinition.IsActive = true; var customStartWorkflowActivityDefinition = ObjectSpace.CreateObject <XpoWorkflowDefinition>(); customStartWorkflowActivityDefinition.Name = "Custom start workflow"; customStartWorkflowActivityDefinition.Xaml = StartWorkflowViaReceiveAndCustomContractXaml.Replace(".v13.2", AssemblyInfo.VSuffix); customStartWorkflowActivityDefinition.TargetObjectType = typeof(Task); customStartWorkflowActivityDefinition.IsActive = true; var receiveCorrelationsActivityDefinition = ObjectSpace.CreateObject <XpoWorkflowDefinition>(); receiveCorrelationsActivityDefinition.Name = "Start/stop (correlations) demo"; receiveCorrelationsActivityDefinition.Xaml = ReceiveCorrelationsXaml.Replace(".v13.2", AssemblyInfo.VSuffix); receiveCorrelationsActivityDefinition.TargetObjectType = typeof(Task); receiveCorrelationsActivityDefinition.IsActive = true; } }
private void FillItemWithLeaderEmployeeValues(ChoiceActionItem parentItem) { if (ObjectSpace != null && SecuritySystem.CurrentUser != null) { Employee curEmp = SecuritySystem.CurrentUser as Employee; IList <Employee> lstEmployee = ObjectSpace.GetObjects <Employee>( CriteriaOperator.And(new NotOperator(new NullOperator("Position")), new BinaryOperator("Position.PositionLevel", 50, BinaryOperatorType.GreaterOrEqual), new BinaryOperator("Position.PositionLevel", curEmp.Position.PositionLevel, BinaryOperatorType.LessOrEqual))); //IList<Employee> lstEmployee = ObjectSpace.GetObjects<Employee>(); if (lstEmployee != null) { lstEmployee = lstEmployee.OrderBy(x => x.UserName).ToList(); //Nếu kỹ: phải hạn chế, chỉ cho phép chuyển cho cấp dưới PositionLevel <= current PositionLevel parentItem.Items.Clear(); foreach (Employee emp in lstEmployee) { if (emp != null && curEmp != null && emp.Oid != curEmp.Oid) { ChoiceActionItem item = new ChoiceActionItem(emp.Title, emp); //item.ImageName = ImageLoader.Instance.GetEnumValueImageName(current); parentItem.Items.Add(item); } } } } }
public ActionResult Get() { Init(); IQueryable <Employee> employees = ObjectSpace.GetObjects <Employee>().AsQueryable(); return(Ok(employees)); }
protected virtual IEnumerable<T> GetDataSource() { if (Helper.IsPropertyDataSource) { var dataSource = Helper.CreateCollectionSource(CurrentObject); var enumerable = ((IEnumerable)dataSource.Collection); return enumerable.Cast<T>(); } return ObjectSpace.GetObjects<T>(CriteriaOperator.Parse(Model.ModelMember.DataSourceCriteria)); }
public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); var dashboardDefinitions = ObjectSpace.GetObjects <DashboardDefinition>().ToArray().Where(definition => definition.DashboardTypes.Count > 1).ToArray(); RemoveInvalidDataSources(dashboardDefinitions); RemoveDuplicates(dashboardDefinitions); }
protected override void OnActivated() { base.OnActivated(); IEnumerable<CheckInOut> checkInOuts = ObjectSpace.GetObjects<CheckInOut>(CriteriaOperator.Parse("IsThisYear([Ngay])")); IEnumerable<NhanVien> nvs = ObjectSpace.GetObjects<NhanVien>(); foreach(CheckInOut ck in checkInOuts) // Perform various tasks depending on the target View. }
void CreateTriggers(IJobSchedulerGroup jobSchedulerGroup) { if (jobSchedulerGroup != null) { var objects = ObjectSpace.GetObjects(TypesInfo.FindBussinessObjectType <IXpandJobTrigger>(), ForTheSameGroup(jobSchedulerGroup)).OfType <IXpandJobTrigger>().ToList(); objects.ForEach(ScheduleJob); } }
protected override void OnActivated() { base.OnActivated(); int soNgayChuaCapNhat = 0; /*Tìm ngày cuối cùng lúc trước khi cập nhật*/ CriteriaOperator criteria = new BinaryOperator("Id", new JoinOperand("NgayTinhCong", null, Aggregate.Max, new OperandProperty("Id"))); var ngayTinhCongs = (NgayTinhCong)ObjectSpace.FindObject <NgayTinhCong>(criteria); if (Equals(ngayTinhCongs, null)) { NgayTinhCong ngayTinhCong = ObjectSpace.CreateObject <NgayTinhCong>(); ngayTinhCong.ngayChamCong = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1); IList <NhanVien> nhanViens = ObjectSpace.GetObjects <NhanVien>();// new BinaryOperator("daNghiViec", false)); Console.WriteLine("Danh sach nhan vien"); Console.WriteLine(nhanViens); if (Equals(nhanViens, null)) { MessageBox.Show("Khong co nhan vien"); } else { foreach (NhanVien nhanVien in nhanViens) { GioCong gioCong = ObjectSpace.CreateObject <GioCong>(); gioCong.nguoiChamCong = nhanVien; gioCong.ngay = ngayTinhCong; } ObjectSpace.CommitChanges(); //ObjectSpace.Refresh(); //View.Refresh(); } } else { DateTime ngayCuoiCung = ngayTinhCongs.ngayChamCong; soNgayChuaCapNhat = (int)(DateTime.Today - ngayCuoiCung).TotalDays; if (!Equals(soNgayChuaCapNhat, 0)) { for (int i = 1; i <= soNgayChuaCapNhat; i++) { NgayTinhCong ngayTinhCong = ObjectSpace.CreateObject <NgayTinhCong>(); ngayTinhCong.ngayChamCong = ngayCuoiCung.AddDays(i); IList <NhanVien> nhanViens = ObjectSpace.GetObjects <NhanVien>();//new BinaryOperator("daNghiViec", false)); foreach (NhanVien nhanVien in nhanViens) { GioCong gioCong = ObjectSpace.CreateObject <GioCong>(); gioCong.nguoiChamCong = nhanVien; gioCong.ngay = ngayTinhCong; } } ObjectSpace.CommitChanges(); //ObjectSpace.Refresh(); //View.Refresh(); } } }
private void GenerateOutDoc(FileInOfficial fileInOfficial) { var fileTemplate = ObjectSpace.GetObjects <FileOutTemplate>(CriteriaOperator.Parse("s_FileCode = ? And s_ClientNo = ?", fileInOfficial.s_FileCode, fileInOfficial.FilePatent?.Client?.Code)).FirstOrDefault(f => (fileInOfficial.FilePatent?.s_ApplicantCodes ?? string.Empty).Split(';').Contains(f.s_ApplicantNo));//联合 if (fileTemplate == null) { fileTemplate = ObjectSpace.FindObject <FileOutTemplate>(new GroupOperator(GroupOperatorType.And, new InOperator("s_ApplicantNo", (fileInOfficial.FilePatent?.s_ApplicantCodes ?? string.Empty).Split(';')), CriteriaOperator.Parse("s_FileCode = ? And IsNullOrEmpty(s_ClientNo)", fileInOfficial.s_FileCode)));//申请人 } if (fileTemplate == null) { fileTemplate = ObjectSpace.FindObject <FileOutTemplate>(CriteriaOperator.Parse("s_FileCode = ? And s_ClientNo = ? And IsNullOrEmpty(s_ApplicantNo)", fileInOfficial.s_FileCode, fileInOfficial.FilePatent?.Client?.Code));//客户 } if (fileTemplate == null) { fileTemplate = ObjectSpace.FindObject <FileOutTemplate>(CriteriaOperator.Parse("s_FileCode = ? And IsNullOrEmpty(s_ClientNo) And IsNullOrEmpty(s_ApplicantNo)", fileInOfficial.s_FileCode));//默认 } if (fileTemplate == null || fileTemplate.TemplateData == null) { return; } using (var stream = new MemoryStream()) { fileTemplate.TemplateData.SaveToStream(stream); var doc = DocX.Load(stream); stream.Close(); ReplaceMark(fileInOfficial, doc); ReplaceMark(fileInOfficial, doc);//替换两遍,目的是替换标签内容中的标签 using (var streamWrite = new MemoryStream()) { doc.SaveAs(streamWrite); streamWrite.Position = 0; if (fileInOfficial.OutFileData == null) { fileInOfficial.OutFileData = new FileData(fileInOfficial.Session); } var sFileName = fileTemplate.s_FileName; foreach (Match match in Regex.Matches(fileTemplate.s_FileName, @"(?<=\[\[\[).*?(?=\]\]\])")) { if (!match.Success) { continue; } var markCode = MarkCodeCollection.Instanse.FirstOrDefault(m => m.MarkName == match.Value); if (markCode == null) { continue; } sFileName = sFileName.Replace("[[[" + match.Value + "]]]", markCode.GetValue(fileInOfficial).ToString()); } fileInOfficial.OutFileData.LoadFromStream(sFileName + ".docx", streamWrite); streamWrite.Close(); fileInOfficial.Save(); fileInOfficial.Session.CommitTransaction(); } } }
private void UpdateStaff() { IList <hrmStaff> staffs = ObjectSpace.GetObjects <hrmStaff>( CriteriaOperator.Or( new UnaryOperator(UnaryOperatorType.IsNull, "BuhCode"), new BinaryOperator("BuhCode", "") )); foreach (hrmStaff staff in staffs) { staff.IsClosed = true; } IList <crmContract> contracts = ObjectSpace.GetObjects <crmContract>(new BinaryOperator("UserRegistrator.IsClosed", true), true); foreach (crmContract contract in contracts) { String last_name = contract.UserRegistrator.LastName.Split(' ')[0]; IList <hrmStaff> staff = ObjectSpace.GetObjects <hrmStaff>(CriteriaOperator.And( new BinaryOperator("LastName", last_name), new BinaryOperator("FirstName", contract.UserRegistrator.FirstName), new BinaryOperator("Department.BuhCode", "560"), CriteriaOperator.Or( new BinaryOperator("IsClosed", false), new UnaryOperator(UnaryOperatorType.IsNull, "IsClosed") )), true); if (staff.Count == 1) { contract.UserRegistrator = staff[0]; } else { continue; } } IList <crmContractDeal> deals = ObjectSpace.GetObjects <crmContractDeal>(new BinaryOperator("UserRegistrator.IsClosed", true), true); foreach (crmContractDeal deal in deals) { String last_name = deal.UserRegistrator.LastName.Split(' ')[0]; IList <hrmStaff> staff = ObjectSpace.GetObjects <hrmStaff>(CriteriaOperator.And( new BinaryOperator("LastName", last_name), new BinaryOperator("FirstName", deal.UserRegistrator.FirstName), new BinaryOperator("Department.BuhCode", "560"), CriteriaOperator.Or( new BinaryOperator("IsClosed", false), new UnaryOperator(UnaryOperatorType.IsNull, "IsClosed") )), true); if (staff.Count == 1) { deal.UserRegistrator = staff[0]; } else { continue; } } }
private void FilterDoctorSpecEventAction_Execute(object sender, SingleChoiceActionExecuteEventArgs e) { DoctorSpecTree doctorSpec = (DoctorSpecTree)e.SelectedChoiceActionItem.Data; FilterDoctorEventAction.Items.Clear(); foreach (var doctor in ObjectSpace.GetObjects <Doctor>(Doctor.Fields.Scheduling & Doctor.Fields.SpecialityTree == doctorSpec)) { FilterDoctorEventAction.Items.Add(new ChoiceActionItem(doctor.Oid.ToString(), doctor.FullName, doctor)); } }
IEnumerable <ObjectChangedWorkflow> GetObjectChangedWorkflows() { var groupOperator = new GroupOperator(GroupOperatorType.Or); foreach (var objectChangedEventArgs in _objectChangedEventArgses) { groupOperator.Operands.Add(CriteriaOperator.Parse("TargetObjectType=?", objectChangedEventArgs.Object.GetType(), objectChangedEventArgs.PropertyName)); } return(ObjectSpace.GetObjects <ObjectChangedWorkflow>(groupOperator)); }
public void DeleteSnapshot() { #region Arrange var ccyAUD = ObjectSpace.FindObject <Currency>(CriteriaOperator.Parse("Name = ?", "AUD")); var account = ObjectSpace.CreateObject <Account>(); account.Name = "VHA ANZ AUD"; account.Currency = ccyAUD; var activity = ObjectSpace.CreateObject <Activity>(); activity.Name = "AR Rcpt"; #endregion #region Create Snapshot var snapshot = ObjectSpace.CreateObject <CashFlowSnapshot>(); snapshot.Name = "Snapshot 1"; var tranDate = new DateTime(2014, 03, 31); decimal amount = 1000; int loops = 2; for (int i = 0; i < loops; i++) { var cf1 = ObjectSpace.CreateObject <CashFlow>(); cf1.Snapshot = snapshot; cf1.TranDate = tranDate; cf1.Account = account; cf1.Activity = activity; cf1.AccountCcyAmt = amount; } ObjectSpace.CommitChanges(); Assert.AreEqual(loops, ObjectSpace.GetObjects <CashFlow>().Count); Assert.AreEqual(2, ObjectSpace.GetObjects <CashFlowSnapshot>().Count); #endregion #region Delete Snapshot var controller = Application.CreateController <CashFlowSnapshotViewController>(); var view = Application.CreateDetailView(ObjectSpace, snapshot); controller.SetView(view); controller.DeleteSnapshot(snapshot); #endregion #region Assert Assert.AreEqual(0, ObjectSpace.GetObjects <CashFlow>().Count); Assert.AreEqual(1, ObjectSpace.GetObjects <CashFlowSnapshot>().Count); #endregion }
public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); if (ObjectSpace.GetObjects <Issue>().Count == 0) { Issue issue1 = ObjectSpace.CreateObject <Issue>(); issue1.Subject = "Processed issue"; issue1.Active = false; Issue issue2 = ObjectSpace.CreateObject <Issue>(); issue2.Subject = "Active issue"; issue2.Active = true; } if (ObjectSpace.GetObjects <XpoWorkflowDefinition>().Count == 0) { XpoWorkflowDefinition definition = ObjectSpace.CreateObject <XpoWorkflowDefinition>(); definition.Name = "Create Task for active Issue"; definition.Xaml = GetXaml("WorkflowExample.Module.DatabaseUpdate.CreateTaskForActiveIssue.xml"); definition.TargetObjectType = typeof(Issue); definition.AutoStartWhenObjectFitsCriteria = true; definition.Criteria = "[Active] = True"; definition.IsActive = true; } SecuritySystemRole adminRole = ObjectSpace.FindObject <SecuritySystemRole>( new BinaryOperator("Name", SecurityStrategy.AdministratorRoleName)); if (adminRole == null) { adminRole = ObjectSpace.CreateObject <SecuritySystemRole>(); adminRole.Name = SecurityStrategy.AdministratorRoleName; adminRole.IsAdministrative = true; adminRole.Save(); } SecuritySystemUser adminUser = ObjectSpace.FindObject <SecuritySystemUser>( new BinaryOperator("UserName", "Administrator")); if (adminUser == null) { adminUser = ObjectSpace.CreateObject <SecuritySystemUser>(); adminUser.UserName = "******"; adminUser.SetPassword(""); adminUser.Roles.Add(adminRole); } SecuritySystemUser workflowServiceUser = ObjectSpace.FindObject <SecuritySystemUser>( new BinaryOperator("UserName", "WorkflowService")); if (workflowServiceUser == null) { workflowServiceUser = ObjectSpace.CreateObject <SecuritySystemUser>(); workflowServiceUser.UserName = "******"; workflowServiceUser.SetPassword(""); workflowServiceUser.Roles.Add(adminRole); } ObjectSpace.CommitChanges(); }
public IList GetLookupSource(string filter) { SearchCriteriaBuilder criteriaBuilder = new SearchCriteriaBuilder(); criteriaBuilder.TypeInfo = Helper.LookupObjectTypeInfo; criteriaBuilder.SearchInStringPropertiesOnly = false; criteriaBuilder.SearchText = filter; criteriaBuilder.SearchMode = SearchMode.SearchInObject; criteriaBuilder.SetSearchProperties(Helper.LookupObjectTypeInfo.DefaultMember.BindingName); return(ObjectSpace.GetObjects(Helper.LookupObjectType, criteriaBuilder.BuildCriteria())); }
protected override void OnActivated() { base.OnActivated(); int i = 0; foreach (var o in ObjectSpace.GetObjects(View.ObjectTypeInfo.Type)) { View.ObjectTypeInfo.FindMember("RuntimeMember").SetValue(o, "I am runtime member " + i); i++; } }
/// <summary> /// Loads the snapshot package. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public string LoadSnapshotPackage(LoadPackageContext context) { var result = string.Empty; try { using (var snapshotObjectSpace = new ObjectSpace(context.Package.UnitOfWork)) { // create root context var sourceMaps = snapshotObjectSpace.GetObjects<SnapshotOidMap>(); var rootContext = new SnapshotLoadContext(context, sourceMaps); context.Worker.ReportProgress(string.Format(Localizer.ObjectsFoundInSnapshot, sourceMaps.Count)); // restore all of object from snapshot foreach (var sourceMap in sourceMaps) loadSnapshotObject(rootContext, sourceMap); // fix OidMap references var newMaps = from c in context.ObjectSpace.ModifiedObjects.Cast<object>() where c is OidMap && ((OidMap)c).NewObject != null select c as OidMap; context.ObjectSpace.CommitChanges(); newMaps.ToList().ForEach(x => x.FixReference()); snapshotPostLoad(context.ObjectSpace); restoreLastLoadedNum(context, snapshotObjectSpace); context.ObjectSpace.CommitChanges(); snapshotObjectSpace.Rollback(); } } catch (Exception exception) { result = string.Format(Localizer.SnapshotLoadingIsFailed, exception.Message); context.Worker.ReportError( result); } if (string.IsNullOrEmpty(result)) { if (context.Worker.CancellationPending) result = Localizer.LoadingAborted; context.Worker.ReportProgress(Color.Blue, Localizer.SnapshotLoadingIs, (context.Worker.CancellationPending ? Localizer.Aborted : Localizer.Finished)); } return result; }
private void snapshotPostBuild(ObjectSpace snapshotObjectSpace) { var schedEvents = snapshotObjectSpace.GetObjects<Event>(null, true); schedEvents.ToList().ForEach(x => { x.UpdateResourceIds(); x.Save(); }); var args = new SnapshotPostOperationArgs(snapshotObjectSpace); Owner.OnSnapshotPostBuild(args); }