public void Dispose() { if (objectSpace != null) { objectSpace.Dispose(); objectSpace = null; } }
protected override void OnDeactivated() { base.OnDeactivated(); _objectSpace.Dispose(); SchedulerStorage.Instance.AppointmentChanging -= SchedulerStorageAppointmentChanging; SchedulerStorage.Instance.ReminderAlert -= ShowReminderAlerts; }
public bool GetCurrentUserViewPriceStatus() { bool rtn = false; IObjectSpace ios = Application.CreateObjectSpace(); SystemUsers user = null; if (!string.IsNullOrEmpty(SecuritySystem.CurrentUserId.ToString())) { user = ios.GetObjectByKey <SystemUsers>(SecuritySystem.CurrentUserId); } if (user != null) { string temp = View.ObjectTypeInfo.Type.ToString(); string[] classname = temp.Split('.'); temp = classname[classname.Length - 1]; //temp = temp.Replace("Ajiya.Module.BusinessObjects.", ""); temp = temp.Replace("Detail", ""); rtn = user.CheckAccessVP(temp); //if (user.Roles.Where(p => p.Name == "C_" + temp + GeneralValues.viewpricestring).Count() > 0) // rtn = true; //if (!rtn) // rtn = user.Roles.Where(p => p.IsAdministrative).Count() > 0 ? true : false; } ios.Dispose(); return(rtn); }
private void ShowInPlaceReportAction_Execute(object sender, SingleChoiceActionExecuteEventArgs e) { if (checkObjectType()) { IList <int> oids = new List <int>(); string reportname = e.SelectedChoiceActionItem.Data.ToString(); if (typeof(ClassDocument).IsAssignableFrom(View.ObjectTypeInfo.Type)) { if (View is ListView) { foreach (ClassDocument dtl in View.SelectedObjects) { oids.Add(dtl.Oid); } } else if (View is DetailView) { oids.Add(((ClassDocument)View.CurrentObject).Oid); } } else if (typeof(ClassStockTransferDocument).IsAssignableFrom(View.ObjectTypeInfo.Type)) { if (View is ListView) { foreach (ClassStockTransferDocument dtl in View.SelectedObjects) { oids.Add(dtl.Oid); } } else if (View is DetailView) { oids.Add(((ClassStockTransferDocument)View.CurrentObject).Oid); } } if (oids.Count > 0) { string temp = ""; foreach (int dtl in oids) { if (temp == "") { temp = dtl.ToString(); } else { temp += "," + dtl.ToString(); } } IObjectSpace objectSpace = ReportDataProvider.ReportObjectSpaceProvider.CreateObjectSpace(typeof(ReportDataV2)); IReportDataV2 reportData = objectSpace.FindObject <ReportDataV2>(CriteriaOperator.Parse("[DisplayName] = '" + reportname + "'")); objectSpace.Dispose(); string handle = ReportDataProvider.ReportsStorage.GetReportContainerHandle(reportData); Frame.GetController <ReportServiceController>().ShowPreview(handle, CriteriaOperator.Parse("Oid in (" + temp + ")")); } } }
public override void TearDownSession() { if (securedObjectSpace != null) { securedObjectSpace.Dispose(); securedObjectSpace = null; } securedObjectHelper = null; }
protected override void Dispose(bool disposing) { if (disposing) { objectSpace?.Dispose(); securityProvider?.Dispose(); } base.Dispose(disposing); }
protected override void OnDeactivated() { base.OnDeactivated(); Application.ObjectSpaceCreated -= Application_ObjectSpaceCreated; if (additionalObjectSpace != null) { additionalObjectSpace.Dispose(); additionalObjectSpace = null; } }
/// <summary> /// This method adds imported objects into the required ListView. /// </summary> /// <typeparam name="T">Any persistent object type supporting the IXPSimpleObject interface.</typeparam> /// <param name="count">The count of of objects to be imported.</param> /// <param name="importDataDelegate">A function of the ImportDataDelegate type that can create persistent objects.</param> /// <param name="customValidateDataDelegate">A function of the ValidateDataDelegate type that can be used to additionally validated created persistent objects. Note that by default, the created objects are already validated using the XAF's Validation system. So, you can set this parameter to null or Nothing in VB.NET</param> /// <param name="targetListView">A ListView to which objects will be imported.</param> /// <returns>The real count of imported objects.</returns> /// Dennis: This method reuses the UnitOfWork/NestedUnitOfWork classes, but it's also correct to use independent (that doesn't belong to a View) ObjectSpace/NestedObjectSpace classes here. public int ImportData <T>(int count, ImportDataDelegate <T> importDataDelegate, ValidateDataDelegate <T> customValidateDataDelegate, ListView targetListView) where T : IXPSimpleObject { if (targetListView == null) { throw new ArgumentNullException("targetlistView"); } IObjectSpace importObjectSpace = null; int countOK = 0; try { importObjectSpace = Application.CreateObjectSpace(targetListView.CollectionSource.ObjectTypeInfo.Type); for (int i = 0; i < count; i++) { using (IObjectSpace nestedImportObjectSpace = importObjectSpace.CreateNestedObjectSpace()) { PropertyCollectionSource pcs = targetListView.CollectionSource as PropertyCollectionSource; object masterObject = pcs != null?nestedImportObjectSpace.GetObjectByKey(pcs.MasterObjectType, nestedImportObjectSpace.GetKeyValue(pcs.MasterObject)) : null; T obj = importDataDelegate(nestedImportObjectSpace, masterObject, i); if (obj != null) { bool isValid = false; try { RuleSetValidationResult validationResult = Validator.RuleSet.ValidateTarget(null, obj, new ContextIdentifiers(DefaultContexts.Save.ToString())); isValid = validationResult.State != ValidationState.Invalid && (customValidateDataDelegate != null ? customValidateDataDelegate(obj, masterObject, i) : true); if (isValid) { nestedImportObjectSpace.CommitChanges(); } } catch (Exception) { isValid = false; } finally { if (isValid) { countOK++; } } } } } importObjectSpace.CommitChanges(); targetListView.ObjectSpace.Refresh(); } catch (Exception commitException) { try { importObjectSpace.Rollback(); } catch (Exception rollBackException) { throw new Exception(String.Format("An exception of type {0} was encountered while attempting to roll back the transaction while importing the data of the {1} type.\nError Message:{2}\nStackTrace:{3}", rollBackException.GetType(), typeof(T), rollBackException.Message, rollBackException.StackTrace), rollBackException); } throw new UserFriendlyException(String.Format("Importing can't be finished!\nAn exception of type {0} was encountered while importing the data of the {1} type.\nError message = {2}\nStackTrace:{3}\nNo records were imported.", commitException.GetType(), typeof(T), commitException.Message, commitException.StackTrace)); } finally { importObjectSpace.Dispose(); importObjectSpace = null; } return(countOK); }
private void ObjectSpace_Disposed(object sender, EventArgs e) { NonPersistentObjectSpace objectSpace = sender as NonPersistentObjectSpace; objectSpace.ObjectsGetting -= ObjectSpace_ObjectsGetting; objectSpace.ObjectByKeyGetting -= ObjectSpace_ObjectByKeyGetting; objectSpace.ObjectsCountGetting -= ObjectSpace_ObjectsCountGetting; objectSpace.ObjectGetting -= ObjectSpace_ObjectGetting; objectSpace.Committing -= ObjectSpace_Committing; additionalObjectSpace.Dispose(); additionalObjectSpace = null; }
private void Application_ObjectSpaceCreated(object sender, ObjectSpaceCreatedEventArgs e) { if (e.ObjectSpace is NonPersistentObjectSpace) { IObjectSpace additionalObjectSpace = Application.CreateObjectSpace(typeof(MCategory)); ((NonPersistentObjectSpace)e.ObjectSpace).AdditionalObjectSpaces.Add(additionalObjectSpace); ((NonPersistentObjectSpace)e.ObjectSpace).ObjectGetting += ObjectSpace_ObjectGetting; e.ObjectSpace.Disposed += (s, args) => { ((NonPersistentObjectSpace)s).ObjectGetting -= ObjectSpace_ObjectGetting; additionalObjectSpace.Dispose(); }; } }
public HttpResponseMessage Count_NumberAccepet() { try { string OrganizationOid = HttpContext.Current.Request.Form["OrganizationOid"].ToString(); SqlConnection objConn = new SqlConnection(scc); if (objConn.State != ConnectionState.Open) { objConn.Open(); } DataSet ds = SqlHelper.ExecuteDataset(scc, CommandType.StoredProcedure, "SP_CountNumber_Approve", new SqlParameter("@OrganizationOid", OrganizationOid)); if (ds.Tables[0].Rows.Count > 0) { XpoTypesInfoHelper.GetXpoTypeInfoSource(); XafTypesInfo.Instance.RegisterEntity(typeof(Organization)); XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null); IObjectSpace ObjectSpace = directProvider.CreateObjectSpace(); Organization Organization = ObjectSpace.FindObject <Organization>(CriteriaOperator.Parse("GCRecord is null and Oid =?", OrganizationOid)); Count_Number number = new Count_Number(); number.OrganizationName = Organization.OrganizeNameTH; number.CountNumber = (int)ds.Tables[0].Rows[0]["Count_Total"]; directProvider.Dispose(); ObjectSpace.Dispose(); return(Request.CreateResponse(HttpStatusCode.OK, number)); } else { UserError err = new UserError(); err.code = "-1"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ err.message = "ไม่พบข้อมูลรายการ"; return(Request.CreateResponse(HttpStatusCode.NotFound, err)); } } catch (Exception ex) { UserError err = new UserError(); err.code = "6"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ err.message = ex.Message; return(Request.CreateResponse(HttpStatusCode.BadRequest, err)); } }
protected override void Dispose(bool disposing) { try { if (disposing) { if (newObjectWindowAction != null) { newObjectWindowAction.Execute -= new PopupWindowShowActionExecuteEventHandler(newObjectWindowAction_OnExecute); newObjectWindowAction.CustomizePopupWindowParams -= new CustomizePopupWindowParamsEventHandler(newObjectWindowAction_OnCustomizePopupWindowParams); DisposeAction(newObjectWindowAction); newObjectWindowAction = null; } if (newObjectViewController != null) { newObjectViewController.ObjectCreating -= new EventHandler <ObjectCreatingEventArgs>(newObjectViewController_ObjectCreating); newObjectViewController.ObjectCreated -= new EventHandler <ObjectCreatedEventArgs>(newObjectViewController_ObjectCreated); newObjectViewController = null; } if (frame != null) { frame.SetView(null); frame.Dispose(); frame = null; } if (newObjectSpace != null && !newObjectSpace.IsDisposed) { newObjectSpace.Dispose(); } newObject = null; newObjectSpace = null; } } finally { base.Dispose(disposing); } }
public static IObservable <Unit> ConnectDocumentStyleManager(this ApplicationModulesManager manager) => manager.WhenApplication(application => application.WhenListViewCreating(typeof(DocumentStyleLinkTemplate)) .SelectMany(t => { var nonPersistentObjectSpace = ((NonPersistentObjectSpace)t.e.ObjectSpace); var objectSpaces = nonPersistentObjectSpace.AdditionalObjectSpaces; var needPersistentObjectSpace = objectSpaces.Any(space => space.IsKnownType(t.e.CollectionSource.ObjectTypeInfo.Type)); IObjectSpace objectSpace = null; if (!needPersistentObjectSpace) { objectSpace = application.CreateObjectSpace(typeof(DocumentStyleLinkTemplate)); objectSpaces.Add(objectSpace); } return(nonPersistentObjectSpace.WhenDisposed().Do(_ => { if (needPersistentObjectSpace) { objectSpace?.Dispose(); } })); })) .Do(tuple => {}) .ToUnit();
public HttpResponseMessage ManageSubAnimalSupplierList() { List <AnimalProductDetail> animalDatail = new List <AnimalProductDetail>(); AnimalProductDetail animal = new AnimalProductDetail(); try { // string QuotaName = HttpContext.Current.Request.Form["QuotaName"].ToString(); string OrganizationOid = HttpContext.Current.Request.Form["OrganizationOid"].ToString(); //string AnimalSupplieOid = HttpContext.Current.Request.Form["AnimalSupplieOid"].ToString(); //string AnimalSupplieTypeOid = HttpContext.Current.Request.Form["AnimalSupplieTypeOid"].ToString(); string QuotaTypeOid = HttpContext.Current.Request.Form["QuotaTypeOid"].ToString(); List <QuotaType_Model> listquo = new List <QuotaType_Model>(); QuotaType_Model quota = new QuotaType_Model(); XpoTypesInfoHelper.GetXpoTypeInfoSource(); XafTypesInfo.Instance.RegisterEntity(typeof(QuotaType)); XafTypesInfo.Instance.RegisterEntity(typeof(ManageAnimalSupplier)); XafTypesInfo.Instance.RegisterEntity(typeof(ManageSubAnimalSupplier)); XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null); List <ManageAnimalSupplier_Model2> list = new List <ManageAnimalSupplier_Model2>(); IObjectSpace ObjectSpace = directProvider.CreateObjectSpace(); QuotaType quotaType; // var ManageSubAnimalSupplierOid = null; quotaType = ObjectSpace.FindObject <QuotaType>(CriteriaOperator.Parse("GCRecord is null and IsActive = 1 and Oid = '" + QuotaTypeOid + "' ", null)); ManageAnimalSupplier ObjManageAnimalSupplier = ObjectSpace.FindObject <ManageAnimalSupplier>(CriteriaOperator.Parse("[OrganizationOid]=? and Status=1", OrganizationOid)); if (ObjManageAnimalSupplier != null) { switch (quotaType.QuotaName) { case "โควตาสำนัก": animal.QuotaName = "โควตาสำนัก"; //ผิด animal.AnimalSupplieTypeOid = ObjectSpace.FindObject <AnimalSupplieType>(CriteriaOperator.Parse("[SupplietypeName]='หญ้าแห้ง'", null)).Oid.ToString(); animal.AnimalSupplieTypeName = ObjectSpace.FindObject <AnimalSupplieType>(CriteriaOperator.Parse("[SupplietypeName]='หญ้าแห้ง'", null)).SupplietypeName; break; case "โควตาศูนย์ฯ": animal.QuotaName = "โควตาศูนย์ฯ"; animal.AnimalSupplieTypeOid = ObjectSpace.FindObject <AnimalSupplieType>(CriteriaOperator.Parse("[SupplietypeName]='หญ้าแห้ง'", null)).Oid.ToString(); animal.AnimalSupplieTypeName = ObjectSpace.FindObject <AnimalSupplieType>(CriteriaOperator.Parse("[SupplietypeName]='หญ้าแห้ง'", null)).SupplietypeName; animal.QuotaQTY = ObjManageAnimalSupplier.CenterQTY; break; case "โควตาปศุสัตว์เขต": animal.QuotaName = "โควตาปศุสัตว์เขต"; animal.AnimalSupplieTypeOid = ObjectSpace.FindObject <AnimalSupplieType>(CriteriaOperator.Parse("[SupplietypeName]='หญ้าแห้ง'", null)).Oid.ToString(); animal.AnimalSupplieTypeName = ObjectSpace.FindObject <AnimalSupplieType>(CriteriaOperator.Parse("[SupplietypeName]='หญ้าแห้ง'", null)).SupplietypeName; animal.QuotaQTY = ObjManageAnimalSupplier.ZoneQTY; break; //case "โควตาปศุสัตว์จังหวัด": // animal.QuotaName = "โควตาปศุสัตว์จังหวัด"; // animal.AnimalSupplieTypeOid = ObjectSpace.FindObject<AnimalSupplieType>(CriteriaOperator.Parse("[SupplietypeName]='หญ้าแห้ง'", null)).Oid.ToString(); // animal.AnimalSupplieTypeName = ObjectSpace.FindObject<AnimalSupplieType>(CriteriaOperator.Parse("[SupplietypeName]='หญ้าแห้ง'", null)).SupplietypeName; // animal.QuotaQTY = ObjManageAnimalSupplier.ZoneQTY; // break; case "โควตาอื่นๆ": animal.QuotaName = "โควตาอื่นๆ"; animal.AnimalSupplieTypeOid = ObjectSpace.FindObject <AnimalSupplieType>(CriteriaOperator.Parse("[SupplietypeName]='หญ้าแห้ง'", null)).Oid.ToString(); animal.AnimalSupplieTypeName = ObjectSpace.FindObject <AnimalSupplieType>(CriteriaOperator.Parse("[SupplietypeName]='หญ้าแห้ง'", null)).SupplietypeName; animal.QuotaQTY = ObjManageAnimalSupplier.OtherQTY; break; case "โควตาปศุสัตว์จังหวัด": if (ObjManageAnimalSupplier != null) { animal.AnimalSupplieTypeOid = ObjectSpace.FindObject <AnimalSupplieType>(CriteriaOperator.Parse("[SupplietypeName]='หญ้าแห้ง'", null)).Oid.ToString(); animal.AnimalSupplieTypeName = ObjectSpace.FindObject <AnimalSupplieType>(CriteriaOperator.Parse("[SupplietypeName]='หญ้าแห้ง'", null)).SupplietypeName; animal.manageSubAnimalSupplierOid = ObjManageAnimalSupplier.Oid.ToString(); List <ManageSubAnimalSupplier_Province> Detail2 = new List <ManageSubAnimalSupplier_Province>(); IList <ManageSubAnimalSupplier> objmanageSubAnimalSupplier = ObjectSpace.GetObjects <ManageSubAnimalSupplier>(CriteriaOperator.Parse("[ManageAnimalSupplierOid]= '" + ObjManageAnimalSupplier.Oid + "' ", null)); if (objmanageSubAnimalSupplier.Count > 0) { foreach (ManageSubAnimalSupplier row2 in objmanageSubAnimalSupplier) { ManageSubAnimalSupplier_Province subanimal = new ManageSubAnimalSupplier_Province(); subanimal.ManageAnimalSupplierOid = row2.ManageAnimalSupplierOid.Oid.ToString(); subanimal.ManageSubAnimalSupplierOid = row2.Oid.ToString(); subanimal.ProvinceOid = row2.ProvinceOid.Oid.ToString(); subanimal.ProvinceName = row2.ProvinceOid.ProvinceNameTH; Detail2.Add(subanimal); } animal.QuotaName = quotaType.QuotaName; animal.ObjProvinceName = Detail2; } } break; } directProvider.Dispose(); ObjectSpace.Dispose(); return(Request.CreateResponse(HttpStatusCode.OK, animal)); } else { UserError err2 = new UserError(); err2.code = "3"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ err2.message = "ไม่พบข้อมูล"; return(Request.CreateResponse(HttpStatusCode.BadRequest, err2)); } } catch (Exception ex) { //Error case เกิดข้อผิดพลาด UserError err = new UserError(); err.code = "6"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ err.message = ex.Message; // Return resual return(Request.CreateResponse(HttpStatusCode.BadRequest, err)); } }
private void DisposeUpdatingSession(IObjectSpace objectSpace) { OnUpdatingSessionDisposing(objectSpace); objectSpace.Dispose(); }
public void Dispose() { objectSpace?.Dispose(); securityProvider?.Dispose(); }
public HttpResponseMessage GetSendOrderSeed() { try { string org_oid = HttpContext.Current.Request.Form["Org_Oid"].ToString(); string type = HttpContext.Current.Request.Form["type"].ToString(); //รับ=1/ส่ง=2 if (org_oid != "" && type != "") { XpoTypesInfoHelper.GetXpoTypeInfoSource(); XafTypesInfo.Instance.RegisterEntity(typeof(SendOrderSeed)); List <SendOrderSeedType> SendItems = new List <SendOrderSeedType>(); List <ReceiveOrderSeedType> ReceiveItems = new List <ReceiveOrderSeedType>(); SendOrderSeedModel lists = new SendOrderSeedModel(); lists.org_oid = org_oid; XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null); IObjectSpace ObjectSpace = directProvider.CreateObjectSpace(); if (type == "2") { //หน่วยส่ง IList <SendOrderSeed> collection = ObjectSpace.GetObjects <SendOrderSeed>(CriteriaOperator.Parse("GCRecord is null and SendStatus=1 and [SendOrgOid.Oid]='" + org_oid + "'", null)); var query = from Q in collection orderby Q.SendNo select Q; if (collection.Count > 0) { foreach (SendOrderSeed row in query) { SendOrderSeedType item = new SendOrderSeedType(); item.SendNo = row.SendNo; item.SendDate = row.SendDate.ToString("dd/MM/yyyy"); item.SendOrgOid = row.SendOrgOid.Oid.ToString(); item.SendOrgName = row.SendOrgOid.SubOrganizeName; item.SendOrgFullName = row.SendOrgOid.OrganizeNameTH; item.Remark = row.Remark; item.SendStatus = row.SendStatus.ToString(); item.FinanceYear = row.FinanceYearOid.YearName; item.CancelMsg = row.CancelMsg; item.ReceiveOrgOid = row.ReceiveOrgOid.Oid.ToString(); item.ReceiveOrgName = row.ReceiveOrgOid.SubOrganizeName; item.ReceiveOrgFullName = row.ReceiveOrgOid.OrganizeNameTH; item.RefNo = row.SendNo + "|" + row.SendOrgOid.Oid.ToString() + "|2"; item.TotalWeight = row.SendOrderSeedDetails.Sum((c => c.Weight)).ToString() + " กิโลกรัม"; SendItems.Add(item); } } //lists.Sender = null; //SendItems; return(Request.CreateResponse(HttpStatusCode.OK, SendItems)); } else if (type == "1") { //รับ IList <SendOrderSeed> collection2 = ObjectSpace.GetObjects <SendOrderSeed>(CriteriaOperator.Parse("GCRecord is null and SendStatus = 2 and ReceiveStatus=1 and ReceiveOrgOid.Oid='" + org_oid + "'", null)); var query = from Q in collection2 orderby Q.SendNo select Q; if (collection2.Count > 0) { foreach (SendOrderSeed row in query) { ReceiveOrderSeedType item = new ReceiveOrderSeedType(); item.SendNo = row.SendNo; item.SendDate = row.SendDate.ToString("dd/MM/yyyy"); item.SendOrgOid = row.SendOrgOid.Oid.ToString(); item.SendOrgName = row.SendOrgOid.SubOrganizeName; item.SendOrgFullName = row.SendOrgOid.OrganizeNameTH; item.Remark = row.Remark; item.ReceiveOrderStatus = row.ReceiveStatus.ToString(); item.FinanceYear = row.FinanceYearOid.YearName; item.CancelMsg = row.CancelMsg; item.ReceiveOrgOid = row.ReceiveOrgOid.Oid.ToString(); item.ReceiveOrgName = row.ReceiveOrgOid.SubOrganizeName; item.ReceiveOrgFullName = row.ReceiveOrgOid.OrganizeNameTH; item.RefNo = row.SendNo + "|" + row.ReceiveOrgOid.Oid.ToString() + "|1"; item.TotalWeight = row.SendOrderSeedDetails.Sum((c => c.Weight)).ToString() + " กิโลกรัม"; ReceiveItems.Add(item); } directProvider.Dispose(); ObjectSpace.Dispose(); //lists.Receive = ReceiveItems; return(Request.CreateResponse(HttpStatusCode.OK, ReceiveItems)); } } //invalid UserError err = new UserError(); err.status = "false"; err.code = "0"; err.message = "กรุณาใส่ข้อมูล Org_Oid และ type ให้เรียบร้อยก่อน"; return(Request.CreateResponse(HttpStatusCode.BadRequest, err)); } else { UserError err = new UserError(); err.status = "false"; err.code = "0"; err.message = "กรุณาใส่ข้อมูล Org_Oid ให้เรียบร้อยก่อน"; return(Request.CreateResponse(HttpStatusCode.BadRequest, err)); } } catch (Exception ex) { UserError err = new UserError(); err.status = "false"; err.code = "6"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ err.message = "ไม่พบข้อมูล"; return(Request.CreateResponse(HttpStatusCode.BadRequest, err)); } finally { SqlConnection.ClearAllPools(); } }
protected void Page_Unload(object sender, EventArgs e) { objectSpace.Dispose(); security.Dispose(); objectSpaceProvider.Dispose(); }
public void TearDown() { directProvider.Dispose(); objectSpace.Dispose(); // generator.Dispose(); }
public void DisposeObjectSpace(IObjectSpace os) { os.Dispose(); }
/// <summary> /// Commits the object space on load. /// </summary> /// <param name="objectSpace">The object space.</param> /// <param name="activeObjectSpaces">The active object spaces.</param> private void commitObjectSpaceOnLoad(IObjectSpace objectSpace, Dictionary<Guid, IObjectSpace> activeObjectSpaces) { var children = from s in activeObjectSpaces.Values where s is NestedObjectSpace && ((NestedObjectSpace) s).ParentObjectSpace == objectSpace select s; foreach (var child in children) commitObjectSpaceOnLoad(child, activeObjectSpaces); var newMaps = from c in objectSpace.ModifiedObjects.Cast<object>() where c is OidMap && ((OidMap) c).NewObject != null select c as OidMap; objectSpace.CommitChanges(); newMaps.ToList().ForEach(x => x.FixReference()); objectSpace.CommitChanges(); objectSpace.Dispose(); var sessionId = (from a in activeObjectSpaces where a.Value == objectSpace select a.Key).FirstOrDefault(); activeObjectSpaces.Remove(sessionId); }
public HttpResponseMessage RodBreedList() { try { string Org = HttpContext.Current.Request.Form["organizationOid"].ToString(); // string type = HttpContext.Current.Request.Form["type"].ToString(); XpoTypesInfoHelper.GetXpoTypeInfoSource(); XafTypesInfo.Instance.RegisterEntity(typeof(SupplierRodBreedUseProduct)); XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null); IObjectSpace ObjectSpace = directProvider.CreateObjectSpace(); List <Rodbreed_model> Detail = new List <Rodbreed_model>(); IList <SupplierRodBreedUseProduct> collection = ObjectSpace.GetObjects <SupplierRodBreedUseProduct>(CriteriaOperator.Parse(" GCRecord is null and Status = 1 and OrganizationOid = ? ", Org)); var query = from Q in collection orderby Q.UseNo select Q; if (collection.Count > 0) { foreach (SupplierRodBreedUseProduct row in query) { Rodbreed_model item = new Rodbreed_model(); item.SupplierRodBreedUseProductOid = row.Oid.ToString(); item.FinanceYearOid = row.FinanceYearOid.Oid.ToString(); item.FinanceYear = row.FinanceYearOid.YearName; item.ActivityNameOid = row.ActivityOid.Oid.ToString(); item.ActivityName = row.ActivityOid.ActivityName; if (row.SubActivityLevelOid != null) { item.SubActivityLevelOid = row.SubActivityLevelOid.Oid.ToString(); item.SubActivityLevelName = row.SubActivityLevelOid.ActivityName; } item.FinanceYearOid = row.FinanceYearOid.Oid.ToString(); item.FinanceYear = row.FinanceYearOid.YearName; item.UseNo = row.UseNo; item.UseDate = row.UseDate.ToString("dd/MM/yy"); item.OrganizationOid = row.OrganizationOid.Oid.ToString(); item.OrganizationName = row.OrganizationOid.SubOrganizeName; if (row.EmployeeOid != null) { item.EmployeeOid = row.EmployeeOid.Oid.ToString(); item.EmployeeName = row.EmployeeOid.FullName; } if (row.RegisCusServiceOid != null) { item.RegisCusServiceOid = row.RegisCusServiceOid.Oid.ToString(); item.FullName = row.RegisCusServiceOid.DisPlayName; item.FullAddress = row.RegisCusServiceOid.FullAddress; } if (row.OrgeServiceOid != null) { item.OrgeServiceOid = row.OrgeServiceOid.Oid.ToString(); item.FullName = row.OrgeServiceOid.OrgeServiceName; item.FullAddress = row.OrgeServiceOid.FullAddress; } item.ServiceCount = row.ServiceCount; item.TotalWeight = row.SupplierRodBreedUseProductDetails.Sum((c => c.Weight)).ToString() + " กิโลกรัม"; Detail.Add(item); } directProvider.Dispose(); ObjectSpace.Dispose(); //lists.Receive = ReceiveItems; return(Request.CreateResponse(HttpStatusCode.OK, Detail)); } else { UserError err2 = new UserError(); err2.status = "false"; err2.code = "-9"; err2.message = "ไม่มีข้อมูลรายการ การใช้ท่อนพันธุ์"; return(Request.CreateResponse(HttpStatusCode.BadRequest, err2)); } } catch (Exception ex) { UserError err = new UserError(); err.status = "false"; err.code = "6"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ err.message = ex.ToString(); return(Request.CreateResponse(HttpStatusCode.BadRequest, err)); } }
protected virtual void CloseObjectSpace(IObjectSpace objectSpace, bool success) { if (objectSpace != null && !objectSpace.IsDisposed) { if (success) { objectSpace.CommitChanges(); } else { objectSpace.Rollback(); } objectSpace.Dispose(); } }