protected void PropertiesStore_ReadData(object sender, StoreReadDataEventArgs e) { //GEtting the filter from the page string filter = string.Empty; int totalCount = 1; //Fetching the corresponding list //in this test will take a list of News AssetManagementCategoryPropertyListRequest request = new AssetManagementCategoryPropertyListRequest(); if (string.IsNullOrEmpty(currentCategory.Text)) { return; } request.categoryId = currentCategory.Text; request.Filter = ""; ListResponse <AssetManagementCategoryProperty> routers = _assetManagementService.ChildGetAll <AssetManagementCategoryProperty>(request); if (!routers.Success) { Common.errorMessage(routers); } routers.Items.ForEach(x => { switch (x.mask) { case 1: x.maskString = GetLocalResourceObject("TEXT").ToString(); break; case 2: x.maskString = GetLocalResourceObject("NUMERIC").ToString(); break; case 3: x.maskString = GetLocalResourceObject("DATE").ToString(); break; case 4: x.maskString = GetLocalResourceObject("DATE_TIME").ToString(); break; case 5: x.maskString = GetLocalResourceObject("CHECKBOX").ToString(); break; default: x.maskString = ""; break; } }); this.PropertiesStore.DataSource = routers.Items; e.Total = routers.Items.Count;; this.PropertiesStore.DataBind(); }
protected void SaveProperties(object sender, DirectEventArgs e) { string AssetId = currentAsset.Text; string catId = currentCat.Text; string[] values = e.ExtraParams["values"].Split(','); List <string> sentIds = new List <string>(); for (int i = 0; i < values.Length; i++) { sentIds.Add(values[i].Split(':')[0].Replace("\"", "").Replace("{", "")); PostRequest <AssetPropertyValue> req = new PostRequest <AssetPropertyValue>(); req.entity = new AssetPropertyValue() { categoryId = catId, assetId = AssetId, propertyId = values[i].Split(':')[0].Replace("\"", "").Replace("{", ""), value = values[i].Split(':')[1].Replace("\"", "").Replace("}", "") }; PostResponse <AssetPropertyValue> resp = _assetManagementService.ChildAddOrUpdate <AssetPropertyValue>(req); if (!resp.Success) { Common.errorMessage(resp); } } AssetManagementCategoryPropertyListRequest propReq = new AssetManagementCategoryPropertyListRequest(); propReq.categoryId = catId; propReq.categoryId = catId; ListResponse <AssetManagementCategoryProperty> propResp = _assetManagementService.ChildGetAll <AssetManagementCategoryProperty>(propReq); if (!propResp.Success) { Common.errorMessage(propResp); } propResp.Items.ForEach(x => { if (x.mask == 5 && !sentIds.Contains(x.propertyId)) { PostRequest <AssetPropertyValue> req = new PostRequest <AssetPropertyValue>(); req.entity = new AssetPropertyValue() { categoryId = catId, assetId = AssetId, propertyId = x.propertyId, value = "false" }; PostResponse <AssetPropertyValue> resp = _assetManagementService.ChildAddOrUpdate <AssetPropertyValue>(req); if (!resp.Success) { Common.errorMessage(resp); } } }); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); }
protected void Page_Load(object sender, EventArgs e) { if (!X.IsAjaxRequest && !IsPostBack) { SetExtLanguage(); if (string.IsNullOrEmpty(Request.QueryString["_catId"]) || string.IsNullOrEmpty(Request.QueryString["_assetId"])) { X.Msg.Alert("Error", "Error"); } currentAsset.Text = Request.QueryString["_assetId"]; currentCat.Text = Request.QueryString["_catId"]; AssetManagementCategoryPropertyListRequest propReq = new AssetManagementCategoryPropertyListRequest(); propReq.categoryId = Request.QueryString["_catId"].ToString(); AssetPropertyValueListRequest valReq = new AssetPropertyValueListRequest(); valReq.assetId = Request.QueryString["_assetId"].ToString(); valReq.categoryId = Request.QueryString["_catId"].ToString(); ListResponse <AssetManagementCategoryProperty> propResp = _assetManagementService.ChildGetAll <AssetManagementCategoryProperty>(propReq); if (!propResp.Success) { Common.errorMessage(propResp); } ListResponse <AssetPropertyValue> valResp = _assetManagementService.ChildGetAll <AssetPropertyValue>(valReq); if (!valResp.Success) { Common.errorMessage(valResp); } try { propResp.Items.ForEach(x => { if (x.mask.HasValue) { AssetPropertyValue corrVal = valResp.Items.Where(d => d.propertyId == x.propertyId).ToList().Count > 0 ? valResp.Items.Where(d => d.propertyId == x.propertyId).ToList()[0] : null; switch (x.mask) { case 1: propertiesForm.Items.Add(new TextField() { Text = corrVal != null && !string.IsNullOrEmpty(corrVal.value) ? corrVal.value : "", FieldLabel = x.caption, Name = x.propertyId }); break; //text case 2: propertiesForm.Items.Add(new NumberField() { Value = corrVal != null && !string.IsNullOrEmpty(corrVal.value) ? corrVal.GetValueDouble() : 0, FieldLabel = x.caption, Name = x.propertyId }); break; //number case 3: propertiesForm.Items.Add(new DateField() { SelectedDate = corrVal != null && !string.IsNullOrEmpty(corrVal.value) ? corrVal.GetValueDateTime() : DateTime.Now, Name = x.propertyId, FieldLabel = x.caption }); break; //datetime case 5: propertiesForm.Items.Add(new Checkbox() { Checked = corrVal != null && !string.IsNullOrEmpty(corrVal.value) ? corrVal.GetValueBool() : false, FieldLabel = x.caption, Name = x.propertyId, InputValue = "true" }); break; //checkbox } } }); } catch (Exception exp) { X.Msg.Alert("Error", exp.Message); } } }