protected override void OnValueStored() { base.OnValueStored(); //Tạo mới Nơi phát hành nếu chưa tồn tại if (View is DetailView && ((DetailView)View).ViewEditMode == ViewEditMode.Edit) { ASPxComboBox control = this.DropDownEdit.Controls[0] as ASPxComboBox; if (control.Text == control.Value.ToString()) { XPLiteObject doc = View.CurrentObject as XPLiteObject; Type ObjType = CurrentObject.GetType(); UnitOfWork uow = new UnitOfWork(doc.Session.DataLayer); HinhThucThanhToan current = uow.FindObject <HinhThucThanhToan>(new BinaryOperator("TieuDe", control.Text)); if (current == null) { current = new HinhThucThanhToan(uow); current.TieuDe = control.Text; current.Save(); uow.CommitTransaction(); } PropertyInfo TieuDe = ObjType.GetProperty("HinhThucThanhToan"); TieuDe.SetValue(doc, doc.Session.GetObjectByKey <HinhThucThanhToan>(current.Oid)); doc.Save(); doc.Session.CommitTransaction(); } } }
void UpdateAdditionalText() { if (_controlsRule != null && !string.IsNullOrEmpty(_controlsRule.MessageProperty)) { if (CurrentObject != null) { var memberInfo = XafTypesInfo.Instance.FindTypeInfo(CurrentObject.GetType()).FindMember(_controlsRule.MessageProperty); if (memberInfo != null) { if (!string.IsNullOrEmpty(_controlsRule.Message)) { memberInfo.SetValue(CurrentObject, _controlsRule.Message); } AdditionalText = memberInfo.GetValue(CurrentObject) as string; } else { AdditionalText = null; } } else { PropertyInfo propertyInfo = _objectType.GetProperty(_controlsRule.MessageProperty, BindingFlags.Static); if (propertyInfo != null) { AdditionalText = propertyInfo.GetValue(null, null) as string; } } } else { AdditionalText = ""; } }
public void ExecuteProcedure(string io_nameProcedure) { try { CurrentObject.GetType().InvokeMember(io_nameProcedure, BindingFlags.InvokeMethod, null, CurrentObject, null); } catch (Exception lo_ex) { Debug.WriteLine(lo_ex.Message); } }
public void SetProperty(string io_nameProperty, object[] io_params) { try { CurrentObject.GetType().InvokeMember(io_nameProperty, BindingFlags.Public | BindingFlags.SetProperty, null, CurrentObject, io_params); } catch (Exception lo_ex) { QvxLog.Log(QvxLogFacility.Application, QvxLogSeverity.Error, lo_ex.Message); Debug.WriteLine(lo_ex.Message); } }
protected string SaveFile(UploadedFile uploadedFile) { //IObjectSpace os = ((DevExpress.ExpressApp.DetailView)(View)).ObjectSpace; Session sess = (View.ObjectSpace as DevExpress.ExpressApp.Xpo.XPObjectSpace).Session; fileuploads = new FileUploads(sess); string appDir = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath; string appUrl = "./"; if (uploadedFile.IsValid) { fileuploads.Name = uploadedFile.FileName; fileuploads.FileName = uploadedFile.FileName; fileuploads.FileSize = uploadedFile.ContentLength; fileuploads.FileType = uploadedFile.ContentType; //PostedFile fileuploads.FileExt = System.IO.Path.GetExtension(uploadedFile.FileName); string savePath; savePath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + @"Uploads\"; savePath += CurrentObject.GetType().Name + @"\"; if (!Directory.Exists(savePath)) { Directory.CreateDirectory(@savePath); } //Thêm số thứ tự vào tên file để tránh trùng lặp file if (File.Exists(string.Format("{0}{1}", savePath, fileuploads.FileName))) { int i = 1; string tmpFileName = string.Format("{0}.{1}{2}", fileuploads.FileName.Substring(0, fileuploads.FileName.Length - fileuploads.FileExt.Length), i, fileuploads.FileExt); while (File.Exists(string.Format("{0}{1}", savePath, tmpFileName))) { i++; tmpFileName = string.Format("{0}.{1}{2}", fileuploads.FileName.Substring(0, fileuploads.FileName.Length - fileuploads.FileExt.Length), i, fileuploads.FileExt); } fileuploads.FileName = tmpFileName; //File.Delete(string.Format("{0}{1}", savePath, fileuploads.FileName)); } uploadedFile.SaveAs(string.Format("{0}{1}", savePath, fileuploads.FileName)); //uncomment this line fileuploads.FileRealPath = savePath; if (HttpContext.Current != null) { appUrl = HttpContext.Current.Request.Url.Authority; } fileuploads.FileUrl = string.Format("{0}\\{1}{2}", appUrl, fileuploads.FileRealPath.Replace(appDir, ""), fileuploads.FileName); fileuploads.Save(); (CurrentObject as FleAttachments).FileAttachments.Add(fileuploads); (CurrentObject as FleAttachments).Save(); //sess.CommitTransaction(); //fileuploads.Session.CommitTransaction(); } return(fileuploads.Name); }
public Object1C ExecuteFunction(string io_nameFunction, object[] io_params = null) { try { return(new Object1C(CurrentObject.GetType().InvokeMember(io_nameFunction, BindingFlags.Public | BindingFlags.InvokeMethod, null, CurrentObject, io_params))); } catch (Exception lo_ex) { QvxLog.Log(QvxLogFacility.Application, QvxLogSeverity.Error, lo_ex.Message); Debug.WriteLine(lo_ex.Message); } return(null); }
public Object1C GetProperty(string io_nameParam) { object lo_resObject = null; try { lo_resObject = CurrentObject.GetType().InvokeMember(io_nameParam, BindingFlags.GetProperty, null, CurrentObject, null); } catch (Exception lo_ex) { QvxLog.Log(QvxLogFacility.Application, QvxLogSeverity.Error, lo_ex.Message); Debug.WriteLine(lo_ex.Message); } return(new Object1C(lo_resObject)); }
private object CreateObject(TeamEmployeeDisplay Item, object CurrentObjectValue) { object obj = null; obj = _ObjectSpace.CreateObject(MemberInfo.ListElementTypeInfo.Type); if (Item.Employee != null) { obj.SetPropertyValue("Employee", _ObjectSpace.FindObject <Employee>(new BinaryOperator("Oid", Item.ID))); } else { obj.SetPropertyValue("Team", _ObjectSpace.FindObject <Team>(new BinaryOperator("Oid", Item.ID))); } obj.SetPropertyValue(CurrentObject.GetType().BaseType.Name, _ObjectSpace.FindObject(CurrentObject.GetType(), new BinaryOperator("Oid", ((BaseObject)CurrentObject).Oid))); return(obj); }
public static List <TreeNode> PopulateTreeNodes(List <IContainer> ObjectList) { var TreeNodes = new List <TreeNode>(); foreach (var CurrentObject in ObjectList) { var CurrentNode = new TreeNode(CurrentObject.Name); CurrentNode.Tag = CurrentObject; if (CurrentObject.GetType().GetProperty("InnerStorage") != null) { CurrentNode.Nodes.AddRange( PopulateTreeNodes(CurrentObject.InnerStorage).ToArray() ); } TreeNodes.Add(CurrentNode); } return(TreeNodes); }
private void SetValues() { Edit.Items.List.Clear(); IList <TagSourceAttribute> tagSources = MemberInfo.FindAttributes <TagSourceAttribute>().ToList(); IMemberInfo info; #region Set values from tag sources foreach (var tagSource in tagSources) { switch (tagSource.Kind) { case TagSourceKind.TypeSource: if (typeof(Enum).IsAssignableFrom(tagSource.Type)) { IList <String> Names = Enum.GetNames(tagSource.Type); Array Values = Enum.GetValues(tagSource.Type); String format = String.Concat(tagSource.ValueFormat); if (format == "") { format = "{0}"; } for (int i = 0; i < Names.Count; i++) { String imageName = Helpers.GetXafImageName((Enum)Values.GetValue(i)); if (Edit.Items.List.Where(f => f.Text == String.Format(format, Names[i])).Count() == 0) { var item = Edit.Items.Add(); item.Text = String.Format(format, Names[i]); item.Value = String.Concat(Values.GetValue(i)); if (imageName == "") { imageName = String.Concat(tagSource.ImageName); } } } } else { IObjectSpace os = (WebApplication.Instance as XafApplication).CreateObjectSpace(tagSource.Type); CollectionSource cs = new CollectionSource(os, tagSource.Type); if (tagSource.Criteria != null) { cs.Criteria["Criteria"] = PrepareCriteria(tagSource.Criteria); } String format = String.Concat(tagSource.ValueFormat); if (format == "") { ITypeInfo TypeInfo = XafTypesInfo.Instance.FindTypeInfo(tagSource.Type); if (TypeInfo != null) { ObjectCaptionFormatAttribute attr = TypeInfo.FindAttribute <ObjectCaptionFormatAttribute>(); if (attr != null) { format = attr.FormatString; } else { var defPropAttr = TypeInfo.FindAttribute <XafDefaultPropertyAttribute>(); if (defPropAttr != null) { format = "{0:" + defPropAttr.Name + "}"; } } } } IList list = null; switch (String.Concat(tagSource.Sorting).ToLower()) { case "asc": case "ascending": list = cs.List.OfType <object>().OrderBy(f => String.Format(new ObjectFormatter(), format, f)).ToList(); break; case "desc": case "descending": list = cs.List.OfType <object>().OrderByDescending(f => String.Format(new ObjectFormatter(), format, f)).ToList(); break; default: list = cs.List; break; } foreach (object obj in list) { var text = String.Format(new ObjectFormatter(), format, obj); if (Edit.Items.List.Where(f => f.Text == text).Count() == 0) { var item = Edit.Items.Add(); item.Text = String.Format(new ObjectFormatter(), format, obj); item.Value = String.Concat(ObjectFormatValues.GetValueRecursive(tagSource.Key, obj, out info)); } } } break; case TagSourceKind.Values: String Items = ""; try { Boolean IsProperty = false; var property = ObjectFormatValues.GetValueRecursive(tagSource.CommaValues, CurrentObject, out info); IObjectSpace os = (WebApplication.Instance as XafApplication).CreateObjectSpace(CurrentObject.GetType()); if (property is IEnumerable) { var coll = (property as IEnumerable); var format = ""; if (info.MemberTypeInfo != null) { var attr = info.MemberTypeInfo.FindAttribute <ObjectCaptionFormatAttribute>(); if (attr != null) { format = attr.FormatString; } else { var defPropAttr = info.MemberTypeInfo.FindAttribute <XafDefaultPropertyAttribute>(); if (defPropAttr != null) { format = "{0:" + defPropAttr.Name + "}"; } } } Items = String.Join(",", coll.OfType <object>().Select(f => String.Format("{0}|{1}" , (format == "" ? f : String.Format(new ObjectFormatter(), format, f)) , ObjectFormatValues.GetValueRecursive(os.GetKeyPropertyName(f.GetType()), f, out info)))); IsProperty = true; } else { Items = String.Concat(property); } if (!IsProperty) { Items = tagSource.CommaValues; } } catch (Exception ex) { Items = tagSource.CommaValues; } foreach (var item in Items.Split(',').Where(f => String.Concat(f) != "")) { if (Edit.Items.List.Where(f => f.Text == item.Split('|')[0]).Count() == 0) { var tagItem = Edit.Items.Add(); tagItem.Text = item.Split('|')[0]; if (item.Split('|').Count() > 1) { tagItem.Value = item.Split('|')[1]; } String imageName = tagSource.ImageName; if (item.Split('|').Count() > 2) { imageName = item.Split('|')[2]; } if (imageName != "") { tagItem.ImageUrl = DevExpress.ExpressApp.Utils.ImageLoader.Instance.GetImageInfo(tagSource.ImageName).ImageUrl; } } } break; } } #endregion }
public Object1C GetPropertyEx(string io_nameParam) { return(new Object1C(CurrentObject.GetType().InvokeMember(io_nameParam, BindingFlags.GetProperty, null, CurrentObject, null))); }
public void ExecuteProcedureEx(string io_nameProcedure) { CurrentObject.GetType().InvokeMember(io_nameProcedure, BindingFlags.InvokeMethod, null, CurrentObject, null); }
public Object1C ExecuteFunctionEx(string io_nameFunction, object[] io_params = null) { return(new Object1C(CurrentObject.GetType().InvokeMember(io_nameFunction, BindingFlags.Public | BindingFlags.InvokeMethod, null, CurrentObject, io_params))); }
public void SetPropertyEx(string io_nameProperty, object[] io_params) { CurrentObject.GetType().InvokeMember(io_nameProperty, BindingFlags.Public | BindingFlags.SetProperty, null, CurrentObject, io_params); }