protected void Page_Init(object sender, EventArgs e) { security = ConnectionHelper.GetSecurity(typeof(IdentityAuthenticationProvider).Name, HttpContext.Current.User.Identity); objectSpaceProvider = ConnectionHelper.GetObjectSpaceProvider(security); IObjectSpace logonObjectSpace = objectSpaceProvider.CreateObjectSpace(); security.Logon(logonObjectSpace); objectSpace = objectSpaceProvider.CreateObjectSpace(); EmployeeDataSource.Session = ((XPObjectSpace)objectSpace).Session; DepartmentDataSource.Session = ((XPObjectSpace)objectSpace).Session; EmployeeGrid.SettingsText.PopupEditFormCaption = "Employee"; EmployeeGrid.SettingsPopup.EditForm.Width = 1000; }
/// ประเภทอาหารสัตว์ public HttpResponseMessage loadAnimalsupplies() { try { string animalsupplieroid = HttpContext.Current.Request.Form["animalsupplieroid"].ToString(); // string animalsuppliertypeoid = HttpContext.Current.Request.Form["animalsuppliertypeoid"].ToString(); XpoTypesInfoHelper.GetXpoTypeInfoSource(); XafTypesInfo.Instance.RegisterEntity(typeof(AnimalSupplieType)); List <AnimalSupplieType_Model> list = new List <AnimalSupplieType_Model>(); XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null); IObjectSpace ObjectSpace = directProvider.CreateObjectSpace(); IList <AnimalSupplieType> collection = ObjectSpace.GetObjects <AnimalSupplieType>(CriteriaOperator.Parse(" GCRecord is null and IsActive = 1 and [AnimalSupplie.oid] = ? ", animalsupplieroid)); foreach (AnimalSupplieType row in collection) { AnimalSupplieType_Model model = new AnimalSupplieType_Model(); model.animalsupplieoid = row.AnimalSupplie.Oid.ToString(); model.AnimalSupplieTypeOid = row.Oid.ToString(); model.SupplietypeName = row.SupplietypeName; model.AnimalSupplieName = row.AnimalSupplie.AnimalSupplieName; model.SalePrice = row.SalePrice; model.IsActive = row.IsActive; list.Add(model); } return(Request.CreateResponse(HttpStatusCode.OK, list)); } 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)); } }
/// วิธีเก็บเกี่ยว public HttpResponseMessage loadHarvesting(string ForageTypeOid) // เมล็ดพัรธุ์ | เสบียงสัตว์ | ค่าว่าง { try { XpoTypesInfoHelper.GetXpoTypeInfoSource(); XafTypesInfo.Instance.RegisterEntity(typeof(Harvest)); XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null); IObjectSpace ObjectSpace = directProvider.CreateObjectSpace(); IList <Harvest> collection = ObjectSpace.GetObjects <Harvest>(CriteriaOperator.Parse(" GCRecord is null and IsActive = 1", null)); List <PlantModel> list = new List <PlantModel>(); foreach (Harvest row in collection) { PlantModel plant = new PlantModel(); plant.Oid = row.Oid; plant.ForageTypeOid = row.HarvestName; list.Add(plant); } return(Request.CreateResponse(HttpStatusCode.OK, list)); } 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)); } }
public void setup_context() { var objectSpaceProvider = new XPObjectSpaceProvider(new MemoryDataStoreProvider()); application = new TestApplication(); var testModule = new ModuleBase(); beforeSetup(testModule); application.Modules.Add(testModule); application.DatabaseUpdateMode = DatabaseUpdateMode.UpdateDatabaseAlways; application.Setup("TestApplication", objectSpaceProvider); objectSpace = objectSpaceProvider.CreateObjectSpace() as XPObjectSpace; XpoDefault.DataLayer = objectSpace.Session.DataLayer; //Do test-specific tasks in the context method ImageLoader.Reset(); if (!ImageLoader.IsInitialized) { ImageLoader.Init(new AssemblyResourceImageSource(GetType().Assembly.FullName, "Images1")); } context(); }
public HttpResponseMessage get_Gender() { try { XpoTypesInfoHelper.GetXpoTypeInfoSource(); XafTypesInfo.Instance.RegisterEntity(typeof(Gender)); List <Gender_Model> list = new List <Gender_Model>(); XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null); IObjectSpace ObjectSpace = directProvider.CreateObjectSpace(); IList <Gender> collection = ObjectSpace.GetObjects <Gender>(CriteriaOperator.Parse(" GCRecord is null and IsActive = 1", null)); foreach (Gender row in collection) { Gender_Model model = new Gender_Model(); model.Oid = row.Oid.ToString(); model.GenderName = row.GenderName; model.IsActive = row.IsActive; list.Add(model); } return(Request.CreateResponse(HttpStatusCode.OK, list)); } 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)); } }
/// ประเภทเมล็ด public HttpResponseMessage loadSeedType() { try { XpoTypesInfoHelper.GetXpoTypeInfoSource(); XafTypesInfo.Instance.RegisterEntity(typeof(SeedType)); List <SeedType_Model> list = new List <SeedType_Model>(); XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null); IObjectSpace ObjectSpace = directProvider.CreateObjectSpace(); // Activity ActivityOid = ObjectSpace.FindObject<Activity>(CriteriaOperator.Parse("GCRecord is null and IsActive = 1 and ActivityName ='เพื่อช่วยเหลือภัยพิบัติ' ", null)); ForageType objseedtype = ObjectSpace.FindObject <ForageType>(CriteriaOperator.Parse("IsActive = 1 and ForageTypeName = 'เสบียงสัตว์ ' ", null)); IList <SeedType> collection = ObjectSpace.GetObjects <SeedType>(CriteriaOperator.Parse(" GCRecord is null and IsActive = 1 and [ForageTypeOid] ='" + objseedtype.Oid + "' ", null)); foreach (SeedType row in collection) { SeedType_Model model = new SeedType_Model(); model.SeedTypeOid = row.Oid.ToString(); model.SeedTypeName = row.SeedTypeName; model.IsActive = row.IsActive; list.Add(model); } return(Request.CreateResponse(HttpStatusCode.OK, list)); } 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 static void RegistrarObjectSpace() { string connectionString = ""; if (ConfigurationManager.ConnectionStrings["ConnectionString"] != null) { connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; } IDataStore store = XpoDefault.GetConnectionProvider(connectionString, AutoCreateOption.SchemaAlreadyExists); XPDictionary dict = new ReflectionDictionary(); dict.GetDataStoreSchema(System.Reflection.Assembly.GetExecutingAssembly()); XpoDefault.DataLayer = new ThreadSafeDataLayer(dict, store); XpoTypesInfoHelper.ForceInitialize(); XpoTypesInfoHelper.GetXpoTypeInfoSource(); XafTypesInfo.Instance.RegisterEntity(typeof(Venta)); XafTypesInfo.Instance.RegisterEntity(typeof(TipoDocumento)); XafTypesInfo.Instance.RegisterEntity(typeof(CobroPendiente)); XafTypesInfo.Instance.RegisterEntity(typeof(ReporteCxcEmpleado)); XafTypesInfo.Instance.RegisterEntity(typeof(CorteDeCaja)); XafTypesInfo.Instance.RegisterEntity(typeof(Empleado)); XafTypesInfo.Instance.RegisterEntity(typeof(Sucursal)); XafTypesInfo.Instance.RegisterEntity(typeof(ReportDataV2)); XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(connectionString, null, true); ObjectsPaceConnection.PropObjectSpace = directProvider.CreateObjectSpace(); ObjectsPaceConnection.Session = ((XPObjectSpace)ObjectsPaceConnection.PropObjectSpace).Session; }
//Dennis: It is important to set the SequenceGenerator.DefaultDataLayer property to the main application data layer. //If you use a custom IObjectSpaceProvider implementation, ensure that it exposes a working IDataLayer. public static void Initialize() { Guard.ArgumentNotNull(Application, "Application"); XPObjectSpaceProvider provider = Application.ObjectSpaceProvider as XPObjectSpaceProvider; if (provider != null) { Guard.ArgumentNotNull(provider, "provider"); if (provider.DataLayer == null) { provider.CreateObjectSpace(); } if (provider.DataLayer is ThreadSafeDataLayer) { SequenceGenerator.DefaultDataLayer = XpoDefault.GetDataLayer( ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString, XpoTypesInfoHelper.GetXpoTypeInfoSource().XPDictionary, DevExpress.Xpo.DB.AutoCreateOption.None); } else { SequenceGenerator.DefaultDataLayer = provider.DataLayer; } } }
public virtual void SetUp() { XPObjectSpaceProvider objectSpaceProvider = new XPObjectSpaceProvider(new MemoryDataStoreProvider()); objectSpace = objectSpaceProvider.CreateObjectSpace(); }
private void ReIndexAction_Execute(object sender, SimpleActionExecuteEventArgs e) { ObjectSpace.CommitChanges(); if (e.CurrentObject is IElasticSearchIndex index) { try { WaitScreen.Instance.Show(CaptionHelper.GetLocalizedText(ElasticSearchClient.MessageGroup, "ReIndexWaitScreenCaption"), CaptionHelper.GetLocalizedText(ElasticSearchClient.MessageGroup, "ReIndexWaitScreenText")); var rowCount = 0; using (var osp = new XPObjectSpaceProvider(Application.GetConnectionString(), null, true)) using (var objectspace = (XPObjectSpace)osp.CreateObjectSpace()) { index = objectspace.GetObject(index); if (index != null) { ElasticSearchClient.Instance.Reindex(index, (ci, i) => { if (i > 0) { rowCount += i; WaitScreen.Instance.Update(string.Format(CultureInfo.CurrentCulture, CaptionHelper.GetLocalizedText(ElasticSearchClient.MessageGroup, "ReIndexWaitScreenUpdateCaption"), ci.ESTypeName), string.Format(CultureInfo.CurrentCulture, CaptionHelper.GetLocalizedText(ElasticSearchClient.MessageGroup, "ReIndexWaitScreenUpdateText"), rowCount)); } }); } } } finally { WaitScreen.Instance.Hide(); } } View.Refresh(); }
public object GetService(Type serviceType) { if (serviceType.Name != typeof(IObjectSpace).Name) { throw new ArgumentException(); } return(XPObjectSpaceProvider.CreateObjectSpace()); }
static void Main(string[] args) { using (XPObjectSpaceProvider objectSpaceProvider = CreateObjectSpaceProvider()) { IObjectSpace objectSpace = objectSpaceProvider.CreateObjectSpace(); ReportDataV2 reportData = objectSpace.FindObject <ReportDataV2>(new BinaryOperator("DisplayName", "Employees Report")); ExportReport(reportData, objectSpaceProvider); } }
public HttpResponseMessage news_Detail() { try { int number = 0; string newsOid = HttpContext.Current.Request.Form["Oid"].ToString(); XpoTypesInfoHelper.GetXpoTypeInfoSource(); XafTypesInfo.Instance.RegisterEntity(typeof(News)); List <newsmodel> list = new List <newsmodel>(); List <ImageURL_Detail> detail = new List <ImageURL_Detail>(); XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null); IObjectSpace ObjectSpace = directProvider.CreateObjectSpace(); News objNews = ObjectSpace.FindObject <News>(CriteriaOperator.Parse(" GCRecord is null and Oid =?", newsOid)); IList <News> collection = ObjectSpace.GetObjects <News>(CriteriaOperator.Parse("GCRecord is null and Oid='" + newsOid + "'", null)); if (objNews.Oid != null) { newsmodel model = new newsmodel(); model.Oid = objNews.Oid.ToString(); model.CreateDate = objNews.CreateDate; model.Subject = objNews.Subject; model.Details = objNews.Details.Replace("/Images/News/", "http://nutritionit.dld.go.th/Images/News/"); model.TotalTimes = objNews.TotalTimes + 1; String[] spearator = { "<img src=" }; string[] Arr = objNews.Details.ToString().Split(spearator, System.StringSplitOptions.RemoveEmptyEntries); ImageURL_Detail objdetail = null; foreach (var row in Arr) { if (row.Contains("Images")) { String[] spearator2 = { "alt=" }; string[] Arr2 = row.ToString().Split(spearator2, System.StringSplitOptions.RemoveEmptyEntries); objdetail = new ImageURL_Detail(); objdetail.ImageURL = Arr2[0].ToString().Replace(@"""", "").Replace(" ", "").Replace("/Images/News/", "http://nutritionit.dld.go.th/Images/News/"); detail.Add(objdetail); } } model.objImage = detail; ObjectSpace.CommitChanges(); list.Add(model); } return(Request.CreateResponse(HttpStatusCode.OK, list)); } 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)); } }
public IHttpActionResult ReceiveOrderSeed() { object ReceiveOrgOid; try { ReceiveOrgOid = HttpContext.Current.Request.Form["ReceiveOrgOid"].ToString(); XpoTypesInfoHelper.GetXpoTypeInfoSource(); XafTypesInfo.Instance.RegisterEntity(typeof(SendOrderSeed)); XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null); IObjectSpace ObjectSpace = directProvider.CreateObjectSpace(); List <SendOrderSeed_Model> list_detail = new List <SendOrderSeed_Model>(); List <ReceiveOrderSeed_Model> list = new List <ReceiveOrderSeed_Model>(); IList <SendOrderSeed> collection = ObjectSpace.GetObjects <SendOrderSeed>(CriteriaOperator.Parse("GCRecord is null and SendStatus = 2 and ReceiveOrgOid=? ", ReceiveOrgOid)); double sum = 0; string WeightUnit; if (collection.Count > 0) { foreach (SendOrderSeed row in collection) { ReceiveOrderSeed_Model Model = new ReceiveOrderSeed_Model(); Model.ReceiveNo = row.SendNo; Model.ReceiveDate = row.SendDate.ToString("dd-MM-yyyy", new CultureInfo("us-US"));; // FinanceYear = ObjectSpace.GetObject<nutrition.Module.FinanceYear>(CriteriaOperator.Parse(nameof"Oid = @FinanceYearOid ", null)); Model.FinanceYear = row.FinanceYearOid.YearName; Model.ReceiveOrgOid = row.ReceiveOrgOid.Oid; Model.ReceiveOrgName = row.ReceiveOrgOid.SubOrganizeName; Model.SendOrgOid = row.SendOrgOid.Oid; Model.SendOrgName = row.SendOrgOid.SubOrganizeName; foreach (SendOrderSeedDetail row2 in row.SendOrderSeedDetails) { sum = sum + row2.Weight; WeightUnit = row2.WeightUnitOid.ToString(); } Model.Weight_All = sum.ToString() + " " + "กิโลกรัม"; list.Add(Model); } return(Ok(list)); } else { return(BadRequest("NoData")); } } catch (Exception ex) { //Error case เกิดข้อผิดพลาด UserError err = new UserError(); err.code = "6"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ err.message = ex.Message; // Return resual return(BadRequest(ex.Message)); } }
public void SetUp() { connectionString = InMemoryDataStoreProvider.ConnectionString; directProvider = new XPObjectSpaceProvider(connectionString, null); objectSpace = directProvider.CreateObjectSpace(); // generator = new DataGenerator(objectSpace); //objectSpace.CommitChanges(); }
public void OneTimeSetUp() { XpoDefault.Session = null; connectionString = InMemoryDataStoreProvider.ConnectionString; directProvider = new XPObjectSpaceProvider(connectionString, null); objectSpace = directProvider.CreateObjectSpace(); //XafTypesInfo.Instance.RegisterEntity(typeof(Produkt)); XafTypesInfo.Instance.RegisterEntity(typeof(Order)); XafTypesInfo.Instance.RegisterEntity(typeof(Product)); }
public void Setup() { ObjectSpace = (XPObjectSpace)ObjectSpaceProvider.CreateObjectSpace(); // clear database DeleteExportedObjects(module, ObjectSpace.Session); ObjectSpace.CommitChanges(); if (SetupEvent != null) { SetupEvent(this, EventArgs.Empty); } }
public HttpResponseMessage quata_typemanage() { try { string ManageAnimalSupplier = HttpContext.Current.Request.Form["manageanimalsupplieroid"].ToString(); // string animalSupplieOid = HttpContext.Current.Request.Form["animalSupplieOid"].ToString(); string quotatypeoid = HttpContext.Current.Request.Form["quotatypeoid"].ToString(); XpoTypesInfoHelper.GetXpoTypeInfoSource(); XafTypesInfo.Instance.RegisterEntity(typeof(ManageAnimalSupplier)); XafTypesInfo.Instance.RegisterEntity(typeof(QuotaType)); XafTypesInfo.Instance.RegisterEntity(typeof(ManageSubAnimalSupplier)); XafTypesInfo.Instance.RegisterEntity(typeof(AnimalSupplie)); XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null); IObjectSpace ObjectSpace = directProvider.CreateObjectSpace(); List <objManageAnimalSupplier> listdetail = new List <objManageAnimalSupplier>(); ManageAnimalSupplier_Modelinfo2 item = new ManageAnimalSupplier_Modelinfo2(); QuotaType objQuotaType = ObjectSpace.FindObject <QuotaType>(CriteriaOperator.Parse(" GCRecord is null and oid = ? ", quotatypeoid)); IList <ManageSubAnimalSupplier> objmanageSubAnimalSupplier = ObjectSpace.GetObjects <ManageSubAnimalSupplier>(CriteriaOperator.Parse("ProvinceOid.OrganizationOid= '" + ManageAnimalSupplier + "' ", null)); ManageSubAnimalSupplier manageanimalsupplie = ObjectSpace.FindObject <ManageSubAnimalSupplier>(CriteriaOperator.Parse(" GCRecord is null and [ProvinceOid.OrganizationOid]= ? ", ManageAnimalSupplier)); if (objQuotaType.QuotaName == "โควตาปศุสัตว์จังหวัด") { QuotaType_Model itemquota = new QuotaType_Model(); item.QuotaName = objQuotaType.QuotaName; //item.OrganizationOid = manageanimalsupplie.ManageAnimalSupplierOid.OrganizationOid.Oid.ToString(); //item.Organizationname = manageanimalsupplie.ManageAnimalSupplierOid.OrganizationOid.SubOrganizeName; foreach (ManageSubAnimalSupplier row in objmanageSubAnimalSupplier) { objManageAnimalSupplier detail = new objManageAnimalSupplier(); detail.ProvinceOid = row.ProvinceOid.Oid.ToString(); detail.Provincename = row.ProvinceOid.ProvinceNameTH; listdetail.Add(detail); } item.detail = listdetail; } else { item.QuotaName = objQuotaType.QuotaName; } return(Request.CreateResponse(HttpStatusCode.OK, item)); } 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)); } }
public HttpResponseMessage Activity_info() { try { string ObjectTypeOid = "b100c7c1-4755-4af0-812e-3dd6ba372d45"; //เพื่อช่วยเหลือภัยพิบัติ XpoTypesInfoHelper.GetXpoTypeInfoSource(); XafTypesInfo.Instance.RegisterEntity(typeof(Activity)); XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null); IObjectSpace ObjectSpace = directProvider.CreateObjectSpace(); List <activity_Model> list = new List <activity_Model>(); List <activityDetails_Model> detail = new List <activityDetails_Model>(); IList <Activity> collection = ObjectSpace.GetObjects <Activity>(CriteriaOperator.Parse("GCRecord is null and IsActive = 1 and MasterActivity = '" + ObjectTypeOid + "' ", null)); { if (collection.Count > 0) { foreach (Activity row in collection) { activity_Model Item = new activity_Model(); Item.ActivityNameOid = row.Oid.ToString(); Item.ActivityName = row.ActivityName; Item.ObjectTypeOid = row.ObjectTypeOid.Oid.ToString(); Item.ObjectTypeName = row.ObjectTypeOid.ObjectTypeName; if (row.MasterActivity != null) { Item.MasterActivity = row.MasterActivity.Oid.ToString(); } list.Add(Item); } } else { //invalid UserError err = new UserError(); err.status = "false"; err.code = "0"; err.message = "กรุณาใส่ข้อมูลให้เรียบร้อย"; return(Request.CreateResponse(HttpStatusCode.NotFound, err)); } return(Request.CreateResponse(HttpStatusCode.OK, list)); } } catch (Exception ex) { UserError err = new UserError(); err.code = "6"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ err.message = ex.Message; return(Request.CreateResponse(HttpStatusCode.BadRequest, err)); } }
public HttpResponseMessage GetDLD_byORG() { string OrganizationOid = null; try { XpoTypesInfoHelper.GetXpoTypeInfoSource(); XafTypesInfo.Instance.RegisterEntity(typeof(DLDArea)); XafTypesInfo.Instance.RegisterEntity(typeof(Organization)); List <listdetail> DLD = new List <listdetail>(); XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null); IObjectSpace ObjectSpace = directProvider.CreateObjectSpace(); //IList<Organization> collection = ObjectSpace.GetObjects<Organization>(CriteriaOperator.Parse("GCRecord is null and IsActive = 1 and OrganizeNameTH LIKE 'เขต%'", null)); IList <Organization> collection = ObjectSpace.GetObjects <Organization>(CriteriaOperator.Parse("GCRecord is null and IsActive = 1 and OrganizeNameTH like 'เขต%'", null)); var query = from Q in collection orderby Q.OrganizeNameTH select Q; foreach (Organization row in query) { listdetail listsa = new listdetail(); listsa.OId = row.Oid.ToString(); listsa.DLDName = row.OrganizeNameTH; IList <Organization> collection2 = ObjectSpace.GetObjects <Organization>(CriteriaOperator.Parse("GCRecord is null and IsActive = 1 and MasterOrganization ='" + row.Oid + "' ", null)); List <listDLD> listDLDs = new List <listDLD>(); foreach (Organization row2 in collection2) { listDLD item = new listDLD(); item.ORGOid = row2.Oid.ToString(); item.OrganizationName = row2.OrganizeNameTH; listDLDs.Add(item); } listsa.Detail = listDLDs; DLD.Add(listsa); } return(Request.CreateResponse(HttpStatusCode.OK, DLD)); } catch (Exception ex) { err2 err = new err2(); err.message = ex.Message; return(Request.CreateResponse(HttpStatusCode.BadRequest, err)); throw; } }
private IReportObjectSpaceProvider ReportObjectSpaceProvider(Session Session) { connection = ((DevExpress.Xpo.DB.MSSqlConnectionProvider)(((DevExpress.Xpo.Helpers.BaseDataLayer)(Session.DataLayer)).ConnectionProvider)).Connection; provider = new XPObjectSpaceProvider(new ConnectionDataStoreProvider(connection)); objectspace = provider.CreateObjectSpace(); if (currentObject != null) { this.CloneObject(objectspace); } return(new ReportObjectSpaceProvider(objectspace)); }
public WebApi.Jwt.Models.user.get_role_byuser get_Roles(string Username) { user.get_role_byuser roles = new user.get_role_byuser(); try { XpoTypesInfoHelper.GetXpoTypeInfoSource(); XafTypesInfo.Instance.RegisterEntity(typeof(UserInfo)); XafTypesInfo.Instance.RegisterEntity(typeof(RoleInfo)); XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null); IObjectSpace ObjectSpace = directProvider.CreateObjectSpace(); UserInfo User; User = ObjectSpace.FindObject <UserInfo>(new BinaryOperator("UserName", Username)); //nutrition.Module.CtlShowDispyName ctlshow; //ctlshow = ObjectSpace.FindObject<CtlShowDispyName>(new BinaryOperator("Oid", Username)); if (User.UserName != null) { roles.User_Name = User.UserName; roles.Display_name = User.DisplayName; // roles.Role_name = User.UserRoles; //{ List <user.Roles_info> get_Role_Byusers = new List <user.Roles_info>(); foreach (RoleInfo row in User.UserRoles) { user.Roles_info Userget = new user.Roles_info(); Userget.Role_display = row.DisplayName.ToString(); Userget.Role_Name = row.Name; get_Role_Byusers.Add(Userget); } roles.objRoles_info = get_Role_Byusers; roles.Status = 1; roles.Message = "แสดงรายชื่อ User"; } else { roles.Status = 0; roles.Message = "ไม่แสดงรายชื่อ User"; } } catch (Exception ex) { roles.Status = 6; roles.Message = ex.Message; } return(roles); }
public HttpResponseMessage ObjectType() { try { string ObjectTypeOid = HttpContext.Current.Request.Form["ObjectTypeOid"].ToString(); XpoTypesInfoHelper.GetXpoTypeInfoSource(); XafTypesInfo.Instance.RegisterEntity(typeof(ObjectType)); XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null); IObjectSpace ObjectSpace = directProvider.CreateObjectSpace(); List <Objective_Used_Model> list = new List <Objective_Used_Model>(); List <activityDetails_Model> detail = new List <activityDetails_Model>(); IList <ObjectType> collection = ObjectSpace.GetObjects <ObjectType>(CriteriaOperator.Parse("GCRecord is null and IsActive = 1 ", null)); { if (collection.Count > 0) { foreach (ObjectType row in collection) { Objective_Used_Model Item = new Objective_Used_Model(); Item.Oid = row.Oid.ToString(); Item.ObjectTypeName = row.ObjectTypeName; list.Add(Item); } } else { //invalid UserError err = new UserError(); err.status = "false"; err.code = "0"; err.message = "กรุณาใส่ข้อมูลให้เรียบร้อย"; return(Request.CreateResponse(HttpStatusCode.BadRequest, err)); } return(Request.CreateResponse(HttpStatusCode.OK, list)); } } catch (Exception ex) { UserError err = new UserError(); err.code = "6"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ err.message = ex.Message; return(Request.CreateResponse(HttpStatusCode.BadRequest, err)); } finally { SqlConnection.ClearAllPools(); } }
private void DataStoreValidation(TypesInfo typesInfo) { using (var objectSpaceProvider = new XPObjectSpaceProvider(new MemoryDataStoreProvider(), typesInfo, typesInfo.EntityStores.OfType <XpoTypeInfoSource>().First())) { using (var objectSpace = objectSpaceProvider.CreateObjectSpace()) { foreach (var persistentType in typesInfo.PersistentTypes.Where(info => info.IsPersistent)) { if (objectSpace.CanInstantiate(persistentType.Type)) { objectSpace.CreateObject(persistentType.Type); } objectSpace.FindObject(persistentType.Type, null); } } } }
public void SetUp() { XPObjectSpaceProvider objectSpaceProvider = new XPObjectSpaceProvider(new MemoryDataStoreProvider()); application = new TestApplication(); ModuleBase testModule = new ModuleBase(); testModule.AdditionalExportedTypes.Add(typeof(Task)); application.Modules.Add(testModule); application.Modules[0].AdditionalExportedTypes.Add(typeof(Task)); application.Setup("TestApplication", objectSpaceProvider); objectSpace = objectSpaceProvider.CreateObjectSpace(); controller = new PostponeController(); }
public IHttpActionResult SupplierUseAnimalProductDetail() { try { string QuotaType = HttpContext.Current.Request.Form["QuotaType"].ToString(); string BudgetSource = HttpContext.Current.Request.Form["BudgetSource"].ToString(); XpoTypesInfoHelper.GetXpoTypeInfoSource(); XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null); IObjectSpace ObjectSpace = directProvider.CreateObjectSpace(); XafTypesInfo.Instance.RegisterEntity(typeof(SupplierUseAnimalProductDetail)); IList <SupplierUseAnimalProductDetail> collection = ObjectSpace.GetObjects <SupplierUseAnimalProductDetail>(CriteriaOperator.Parse(" BudgetSourceOid.Oid = '" + BudgetSource + "' and GCRecord is null and QuotaTypeOid.Oid = ?", QuotaType)); List <SupplierUseAnimalProductDetail_Model> list_detail = new List <SupplierUseAnimalProductDetail_Model>(); if (collection.Count > 0) { // SupplierUseAnimalProductDetail ObjMaster; foreach (SupplierUseAnimalProductDetail row in collection) { SupplierUseAnimalProductDetail_Model Model = new SupplierUseAnimalProductDetail_Model(); Model.BudgetSource = row.BudgetSourceOid.BudgetName; Model.AnimalSupplie = row.AnimalSupplieOid.AnimalSupplieName; Model.QuotaType = row.QuotaTypeOid.QuotaName; Model.AnimalSupplieType = row.AnimalSupplieTypeOid.SupplietypeName; Model.AnimalSeed = ""; Model.StockUsed = row.StockUsed; Model.StockLimit = row.StockLimit; Model.QuotaQTY = row.QuotaQTY; Model.Amount = row.Amount; list_detail.Add(Model); } return(Ok(list_detail)); } else { return(BadRequest("NoData")); } } catch (Exception ex) { //Error case เกิดข้อผิดพลาด UserError err = new UserError(); err.code = "6"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ err.message = ex.Message; // Return resual return(BadRequest(ex.Message)); } }
public IHttpActionResult ManageAnimalSupplier() { try { string OrganizationOid = HttpContext.Current.Request.Form["OrganizationOid"].ToString(); string FinanceYearOid = HttpContext.Current.Request.Form["FinanceYearOid"].ToString(); XpoTypesInfoHelper.GetXpoTypeInfoSource(); XafTypesInfo.Instance.RegisterEntity(typeof(ManageAnimalSupplier)); List <ManageAnimalSupplier_Model> list_detail = new List <ManageAnimalSupplier_Model>(); XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null); IObjectSpace ObjectSpace = directProvider.CreateObjectSpace(); IList <ManageAnimalSupplier> collection = ObjectSpace.GetObjects <ManageAnimalSupplier>(CriteriaOperator.Parse(" GCRecord is null and Status = 1 and OrganizationOid=? and FinanceYearOid = ?", OrganizationOid, FinanceYearOid)); //ManageAnimalSupplier ObjMaster; //ObjMaster = ObjectSpace.FindObject<ManageAnimalSupplier>(CriteriaOperator.Parse("GCRecord is null and StockType = 1 and OrganizationOid =? and FinanceYearOid = ? ", OrganizationOid, FinanceYearOid)); foreach (ManageAnimalSupplier row in collection) { ManageAnimalSupplier_Model Model = new ManageAnimalSupplier_Model(); Model.Oid = row.Oid.ToString(); Model.FinanceYearOid = row.FinanceYearOid.Oid.ToString(); Model.FinanceYear = row.FinanceYearOid.YearName; Model.OrgZoneOid = row.OrgZoneOid.Oid.ToString(); Model.OrgZone = row.OrgZoneOid.OrganizeNameTH; Model.OrganizationOid = row.OrganizationOid.Oid.ToString(); Model.Organization = row.OrganizationOid.SubOrganizeName; Model.AnimalSupplieOid = row.AnimalSupplieOid.Oid.ToString(); Model.AnimalSupplie = row.AnimalSupplieOid.AnimalSupplieName; Model.ZoneQTY = row.ZoneQTY; Model.CenterQTY = row.CenterQTY; Model.OfficeQTY = row.OfficeQTY; Model.OfficeGAPQTY = row.OfficeGAPQTY; Model.OfficeBeanQTY = row.OfficeBeanQTY; Model.Status = row.Status.ToString(); Model.SortID = row.SortID; list_detail.Add(Model); } return(Ok(true)); } catch (Exception ex) { //Error case เกิดข้อผิดพลาด UserError err = new UserError(); err.code = "6"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ err.message = ex.Message; // Return resual return(BadRequest(ex.Message)); } }
static void Main() { XpoTypesInfoHelper.GetXpoTypeInfoSource(); XafTypesInfo.Instance.RegisterEntity(typeof(Person)); XafTypesInfo.Instance.RegisterEntity(typeof(PermissionPolicyUser)); XafTypesInfo.Instance.RegisterEntity(typeof(PermissionPolicyRole)); Console.WriteLine("Update database..."); DataSet dataSet = new DataSet(); Console.WriteLine("Database has been updated successfully."); XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(new MemoryDataStoreProvider(dataSet)); IObjectSpace directObjectSpace = directProvider.CreateObjectSpace(); UpdateDatabase(directObjectSpace); AuthenticationStandard auth = new AuthenticationStandard(); SecurityStrategyComplex security = new SecurityStrategyComplex(typeof(PermissionPolicyUser), typeof(PermissionPolicyRole), auth); SecuritySystem.SetInstance(security); SecuredObjectSpaceProvider osProvider = new SecuredObjectSpaceProvider(security, new MemoryDataStoreProvider(dataSet)); IObjectSpace securedObjectSpace = osProvider.CreateObjectSpace(); auth.SetLogonParameters(new AuthenticationStandardLogonParameters("User", "")); Console.WriteLine("Logging 'User' user..."); security.Logon(directObjectSpace); Console.WriteLine("'User' is logged on."); Console.WriteLine("List of the 'Person' objects:"); foreach (Person person in securedObjectSpace.GetObjects <Person>()) { Console.WriteLine(person.FirstName); } auth.SetLogonParameters(new AuthenticationStandardLogonParameters("Admin", "")); Console.WriteLine("Logging 'Admin' user..."); security.Logon(directObjectSpace); Console.WriteLine("Admin is logged on."); securedObjectSpace = osProvider.CreateObjectSpace(); Console.WriteLine("List of the 'Person' objects:"); foreach (Person person in securedObjectSpace.GetObjects <Person>()) { Console.WriteLine(person.FirstName); } Console.WriteLine("Press enter to exit..."); Console.ReadLine(); }
public HttpResponseMessage Activity_Sup() { try { string ObjectTypeOid = "a29d77a9-4bcb-4774-9744-ff97a373353e"; XpoTypesInfoHelper.GetXpoTypeInfoSource(); XafTypesInfo.Instance.RegisterEntity(typeof(Activity)); XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null); IObjectSpace ObjectSpace = directProvider.CreateObjectSpace(); List <activitySub_Model> list = new List <activitySub_Model>(); List <activityDetails_Model> detail = new List <activityDetails_Model>(); IList <Activity> collection = ObjectSpace.GetObjects <Activity>(CriteriaOperator.Parse("GCRecord is null and IsActive = 1 and MasterActivity = '" + ObjectTypeOid + "' ", null)); { if (collection.Count > 0) { foreach (Activity row in collection) { activitySub_Model Item = new activitySub_Model(); Item.SubActivityLevelOid = row.Oid.ToString(); Item.SubActivityLevelName = row.ActivityName; list.Add(Item); } } else { //invalid UserError err = new UserError(); err.status = "false"; err.code = "0"; err.message = "กรุณาใส่ข้อมูลให้เรียบร้อย"; return(Request.CreateResponse(HttpStatusCode.BadRequest, err)); } return(Request.CreateResponse(HttpStatusCode.OK, list)); } } catch (Exception ex) { UserError err = new UserError(); err.code = "6"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ err.message = ex.Message; return(Request.CreateResponse(HttpStatusCode.BadRequest, err)); } }
public static void WczytajKursy(List <Notowanie> res) { if (res != null) { using (XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(AppSettings.ConnectionString, null)) { using (IObjectSpace directObjectSpace = directProvider.CreateObjectSpace()) { XafTypesInfo.Instance.RegisterEntity(typeof(KursWaluty)); XafTypesInfo.Instance.RegisterEntity(typeof(Waluta)); WczytajKursy(directObjectSpace, res); directObjectSpace.CommitChanges(); } } } }