Example #1
0
        void SetMemberValue(XPBaseObject selectedObject, IClassInfoGraphNode classInfoGraphNode,
                            XElement propertyElement)
        {
            var xpMemberInfo = selectedObject.ClassInfo.FindMember(classInfoGraphNode.Name);

            if (xpMemberInfo != null)
            {
                var memberValue = selectedObject.GetMemberValue(classInfoGraphNode.Name);
                if (xpMemberInfo.Converter != null)
                {
                    memberValue = (xpMemberInfo.Converter.ConvertToStorageType(memberValue));
                }
                if (memberValue is byte[])
                {
                    memberValue = Convert.ToBase64String((byte[])memberValue);
                }
                if (memberValue is DateTime)
                {
                    memberValue = ((DateTime)memberValue).Ticks;
                }

                if (memberValue is string)
                {
                    memberValue = IAFModule.SanitizeXmlString((string)memberValue);
                    propertyElement.Add(new XCData(memberValue.ToString()));
                }
                else
                {
                    propertyElement.Value = GetInvariantValue(memberValue);
                }
            }
        }
Example #2
0
 /// <summary>
 /// Фукус на искомой записи
 /// </summary>
 public void FocusRecord(XPBaseObject record)
 {
     if (DBInterface != null)
     {
         DBInterface.FocusRecord(record);
     }
 }
Example #3
0
        void ExportCore(XPBaseObject selectedObject, IEnumerable <IClassInfoGraphNode> serializedClassInfoGraphNodes,
                        XElement root)
        {
            var objectInfo = new ObjectInfo(selectedObject.GetType(),
                                            selectedObject.ClassInfo.KeyProperty.GetValue(selectedObject));

            if (!(exportedObjecs.ContainsKey(objectInfo)))
            {
                exportedObjecs.Add(objectInfo, null);
                var serializedObjectElement = new XElement("SerializedObject");
                serializedObjectElement.Add(new XAttribute("type", selectedObject.GetType().Name));
                root.Add(serializedObjectElement);
                foreach (
                    var classInfoGraphNode in
                    serializedClassInfoGraphNodes.Where(
                        node => node.SerializationStrategy != SerializationStrategy.DoNotSerialize))
                {
                    XElement propertyElement = GetPropertyElement(serializedObjectElement, classInfoGraphNode);
                    switch (classInfoGraphNode.NodeType)
                    {
                    case NodeType.Simple:
                        SetMemberValue(selectedObject, classInfoGraphNode, propertyElement);
                        break;

                    case NodeType.Object:
                        CreateObjectProperty(selectedObject, propertyElement, classInfoGraphNode, root);
                        break;

                    case NodeType.Collection:
                        CreateCollectionProperty(selectedObject, classInfoGraphNode, root, propertyElement);
                        break;
                    }
                }
            }
        }
Example #4
0
        /// <summary>
        /// Поиск записи из коллекции.
        /// </summary>
        public static int FindRecordPossition(System.ComponentModel.Component сollection, XPBaseObject record)
        {
            if (record == null)
            {
                return(0);
            }

            if (сollection is XPCollection)
            {
                XPCollection xpCollection = сollection as XPCollection;
                string       propertyName = DBAttribute.GetKey(record.GetType());
                int          idRecord     = (int)record.GetMemberValue(propertyName);

                for (int i = 0; i < xpCollection.Count; i++)
                {
                    XPBaseObject recordInt = (XPBaseObject)xpCollection[i];

                    int idRecordInt = (int)recordInt.GetMemberValue(propertyName);

                    if (idRecordInt == idRecord)
                    {
                        return(i);
                    }
                }
            }
            return(0);
        }
Example #5
0
 public static bool IsOutdated(this XPBaseObject obj)
 {
     using (UnitOfWork uow = new UnitOfWork(obj.Session.DataLayer)) {
         XPBaseObject obj1 = (XPBaseObject)uow.GetObjectByKey(obj.GetType(), obj.Session.GetKeyValue(obj));
         return(!Equals(obj1.ClassInfo.OptimisticLockField.GetValue(obj1), obj.ClassInfo.OptimisticLockField.GetValue(obj)));
     }
 }
Example #6
0
        public static object GetXpMemberInfoValue(string propertyName, XPBaseObject o)
        {
            if (propertyName.IndexOf(".") > -1)
            {
                XPMemberInfo info  = o.ClassInfo.GetMember(propertyName.Split(".".ToCharArray())[0]);
                object       value = info.GetValue(o);
                if (typeof(XPBaseObject).IsAssignableFrom(info.MemberType))
                {
                    o = value as XPBaseObject;
                    return(o == null
                               ? null
                               : GetXpMemberInfoValue(propertyName.Substring(propertyName.IndexOf(".") + 1), o));
                }
                return
                    (value != null
                        ? GetPropertyInfoValue(propertyName.Substring(propertyName.IndexOf(".") + 1), info.GetValue(o))
                        : null);
            }
            XPMemberInfo xpMemberInfo = o.ClassInfo.GetMember(propertyName);

            if (xpMemberInfo == null)
            {
                throw new PropertyMissingException(o.GetType().FullName, propertyName);
            }
            return(xpMemberInfo.GetValue(o));
        }
Example #7
0
        public static void SetXpMemberProperty(string propertyName, object value, XPBaseObject dbObject, bool save)
        {
            if (propertyName.IndexOf(".") > -1)
            {
                XPMemberInfo member = dbObject.ClassInfo.GetMember(propertyName.Split(".".ToCharArray())[0]);
                object       o      = member.GetValue(dbObject);
                if (typeof(XPBaseObject).IsAssignableFrom(member.MemberType))
                {
                    dbObject = o as XPBaseObject;
                    SetXpMemberProperty(propertyName.Substring(propertyName.IndexOf(".") + 1), value, dbObject, save);
                    return;
                }
                SetPropertyValue(o.GetType().GetProperty(propertyName.Substring(propertyName.IndexOf(".") + 1)), o,
                                 value);
                return;
            }
            XPMemberInfo xpMemberInfo = dbObject.ClassInfo.GetMember(propertyName);

            if (xpMemberInfo == null)
            {
                throw new PropertyMissingException(dbObject.GetType().FullName, propertyName);
            }
            xpMemberInfo.SetValue(dbObject,
                                  xpMemberInfo.Owner.ClassType.GetProperty(propertyName) == null
                                      ? value
                                      : ChangeType(value, xpMemberInfo.MemberType));
            if (save)
            {
                dbObject.Save();
            }
        }
Example #8
0
 public void OnControlCreated(string column, ASPxEdit control, XPBaseObject obj)
 {
     if (ControlCreated != null)
     {
         ControlCreated(column, control, obj);
     }
 }
Example #9
0
 void ExportCore(XPBaseObject selectedObject, IEnumerable<IClassInfoGraphNode> serializedClassInfoGraphNodes,
                 XElement root) {
     var objectInfo = new ObjectInfo(selectedObject.GetType(),
                                     selectedObject.ClassInfo.KeyProperty.GetValue(selectedObject));
     if (!(exportedObjecs.ContainsKey(objectInfo))) {
         exportedObjecs.Add(objectInfo, null);
         var serializedObjectElement = new XElement("SerializedObject");
         serializedObjectElement.Add(new XAttribute("type", selectedObject.GetType().Name));
         root.Add(serializedObjectElement);
         foreach (
             var classInfoGraphNode in
                 serializedClassInfoGraphNodes.Where(
                     node => node.SerializationStrategy != SerializationStrategy.DoNotSerialize)) {
             XElement propertyElement = GetPropertyElement(serializedObjectElement, classInfoGraphNode);
             switch (classInfoGraphNode.NodeType) {
                 case NodeType.Simple:
                     SetMemberValue(selectedObject, classInfoGraphNode, propertyElement);
                     break;
                 case NodeType.Object:
                     CreateObjectProperty(selectedObject, propertyElement, classInfoGraphNode, root);
                     break;
                 case NodeType.Collection:
                     CreateCollectionProperty(selectedObject, classInfoGraphNode, root, propertyElement);
                     break;
             }
         }
     }
 }
Example #10
0
        private void SetMemberValueOfItem(XPBaseObject item, IModelColumn column, ASPxEdit cellControl)
        {
            var edit = cellControl as ASPxSpinEdit;

            if (edit != null && edit.NumberType == SpinEditNumberType.Integer)
            {
                item.SetMemberValue(column.PropertyName,
                                    column.ModelMember.MemberInfo.MemberType == typeof(int)
                        ? Convert.ToInt32(cellControl.Value)
                        : Convert.ToInt64(cellControl.Value));
            }
            else
            {
                if (typeof(XPBaseObject).IsAssignableFrom(column.ModelMember.MemberInfo.MemberType) &&
                    !typeof(IFileData).IsAssignableFrom(column.ModelMember.MemberInfo.MemberType))
                {
                    object o = _objectSpace.GetObjectByKey(column.ModelMember.MemberInfo.MemberType, cellControl.Value);
                    item.SetMemberValue(column.PropertyName, o);
                }
                else
                {
                    item.SetMemberValue(column.PropertyName, cellControl.Value);
                }
            }
        }
Example #11
0
        public IEnumerable <IClassInfoGraphNode> GetSerializedClassInfoGraphNodes(XPBaseObject theObject, string typeName)
        {
            var type = ReflectionHelper.GetType(typeName);
            ISerializationConfiguration configuration = GetConfiguration(theObject.Session, type);

            return(GetSerializedClassInfoGraphNodes(configuration));
        }
Example #12
0
        void ImportComplexProperties(XElement element, IObjectSpace nestedObjectSpace, Action <XPBaseObject, XElement> instance, NodeType nodeType)
        {
            IEnumerable <XElement> objectElements = GetObjectRefElements(element, nodeType);
            ITypeInfo typeInfo = GetTypeInfo(element);

            foreach (XElement objectElement in objectElements)
            {
                ITypeInfo memberTypeInfo = GetTypeInfo(objectElement);
                if (memberTypeInfo != null)
                {
                    var          refObjectKeyCriteria = GetObjectKeyCriteria(memberTypeInfo, objectElement.Descendants("Key"));
                    XPBaseObject xpBaseObject         = null;
                    XElement     element1             = objectElement;
                    if (objectElement.GetAttributeValue("strategy") ==
                        SerializationStrategy.SerializeAsObject.ToString())
                    {
                        var findObjectFromRefenceElement = objectElement.FindObjectFromRefenceElement();
                        HandleErrorComplex(objectElement, typeInfo, () => {
                            if (findObjectFromRefenceElement != null)
                            {
                                xpBaseObject = CreateObject(findObjectFromRefenceElement, nestedObjectSpace, memberTypeInfo, refObjectKeyCriteria);
                            }
                            instance.Invoke(xpBaseObject, element1);
                        });
                    }
                    else
                    {
                        HandleErrorComplex(objectElement, typeInfo, () => {
                            xpBaseObject = GetObject(memberTypeInfo, refObjectKeyCriteria);
                            instance.Invoke(xpBaseObject, element1);
                        });
                    }
                }
            }
        }
        public static MemberProtectedInfo IsProtected(XPBaseObject baseObject, string propertyName){
            propertyName = propertyName.Replace("!", "");
            XPMemberInfo memberInfo = ReflectorHelper.GetXpMemberInfo(baseObject.Session, baseObject.GetType(),
                                                                      propertyName);

//            XPClassInfo xpClassInfo = memberInfo.ReferenceType;
//            FilterRecordAttribute attributeInfo = xpClassInfo != null
//                                                      ? (FilterRecordAttribute)
//                                                        xpClassInfo.FindAttributeInfo(
//                                                            typeof (FilterRecordAttribute))
//                                                      :
//                                                          null;

            if ( memberInfo.IsPersistent)
            {
//                if (attributeInfo != null &&attributeSatisfyUser(attributeInfo)&&
//                    criteriaSatisfyMember(propertyName, baseObject, xpClassInfo, attributeInfo))
//                    return new MemberProtectedInfo(true, true);
                var b = (bool?) ReflectorHelper.GetXpMemberInfoValue(propertyName +
                                                                     MemberLevelSecuritySuffix, baseObject);
                return new MemberProtectedInfo(false, b.HasValue && b.Value);
            }
            
            return new MemberProtectedInfo(false, false);
        }
 public override string GetRuleResult(XPBaseObject instance)
 {
     if (!string.IsNullOrEmpty(属性名称) && (所属方案 != null))
     {
         return Convert.ToString(instance.GetMemberValue(属性名称));
     }
     return "";
 }
Example #15
0
 public override string GetRuleResult(XPBaseObject instance)
 {
     if (!string.IsNullOrEmpty(属性名称) && (所属方案 != null))
     {
         return(Convert.ToString(instance.GetMemberValue(属性名称)));
     }
     return("");
 }
Example #16
0
 private decimal GetTempvalue(bool isUnboundColumn, XPBaseObject selectedObject, string columnName)
 {
     return(isUnboundColumn
         ? +Convert.ToDecimal(selectedObject.Evaluate(_gridView.FocusedColumn.UnboundExpression))
         : (columnName.Contains(".")
             ? +Convert.ToDecimal(selectedObject.Evaluate(CriteriaOperator.Parse(columnName)))
             : +Convert.ToDecimal(selectedObject.GetMemberValue(columnName))));
 }
 object[] GetArguments(XPBaseObject xpBaseObject) {
     if (!string.IsNullOrEmpty(_criteria))
         return new object[] {
                             xpBaseObject.Session,
                             new CriteriaWrapper(_criteria, xpBaseObject).CriteriaOperator
                         };
     return new object[] { xpBaseObject.Session };
 }
Example #18
0
 void createCollectionProperty(XPBaseObject selectedObject, IClassInfoGraphNode classInfoGraphNode, XElement root,
                               XElement propertyElement) {
     XPMemberInfo memberInfo = selectedObject.ClassInfo.GetMember(classInfoGraphNode.Name);
     var theObjects = (XPBaseCollection)memberInfo.GetValue(selectedObject);
     foreach (XPBaseObject theObject in theObjects) {
         CreateRefElelement(classInfoGraphNode,theObject.GetType().Name, root,  theObject, propertyElement);
     }
 }
Example #19
0
 object GetMemberValue(XPBaseObject selectedObject, IClassInfoGraphNode classInfoGraphNode) {
     var memberValue = selectedObject.GetMemberValue(classInfoGraphNode.Name);
     var xpMemberInfo = selectedObject.ClassInfo.GetMember(classInfoGraphNode.Name);
     if (xpMemberInfo.Converter!= null){
         return xpMemberInfo.Converter.ConvertToStorageType(memberValue);
     }
     return memberValue;
 }
 public static void ResetAssociations(XPBaseObject newObject)
 {
     foreach (var member in newObject.ClassInfo.ObjectProperties.
              Cast <XPMemberInfo>().
              Where(mi => mi.IsAssociation))
     {
         member.SetValue(newObject, null);
     }
 }
Example #21
0
 protected override void TriggerObjectChanged(ObjectChangeEventArgs args)
 {
     XPBaseObject.RaiseChangedEvent(this, args);
     if (IsInvalidated)
     {
         return;
     }
     base.TriggerObjectChanged(args);
 }
Example #22
0
        void CreateObjectProperty(XPBaseObject selectedObject, XElement propertyElement, IClassInfoGraphNode classInfoGraphNode, XElement root)
        {
            XPMemberInfo memberInfo = selectedObject.ClassInfo.FindMember(classInfoGraphNode.Name);

            if (memberInfo != null)
            {
                var theObject = (XPBaseObject)memberInfo.GetValue(selectedObject);
                CreateRefElelement(classInfoGraphNode, theObject != null?theObject.GetType().Name:memberInfo.MemberType.Name, root, theObject, propertyElement);
            }
        }
Example #23
0
 public string 生成编号(XPBaseObject ins)
 {
     var enumerable = 编号规则.OrderBy(x => x.序号).ToArray();
     var builder = new StringBuilder();
     foreach (var i单据编号规则 in enumerable)
     {
         builder.Append(i单据编号规则.GetRuleResult(ins));
     }
     return builder.ToString();
 }
        private void gridView1_ValidatingEditor(object sender, BaseContainerValidateEditorEventArgs e)
        {
            GridView     view = (GridView)sender;
            XPBaseObject row  = (XPBaseObject)view.GetFocusedRow();
            Dictionary <string, object> customValues = new Dictionary <string, object>();

            customValues.Add(view.FocusedColumn.FieldName, e.Value);
            e.ErrorText = new Validator(row, customValues).Validate(view.FocusedColumn.FieldName);
            e.Valid     = string.IsNullOrEmpty(e.ErrorText);
        }
        public static void RemoveTLObjects <T>(XPBaseCollection collection, XPBaseObject ob)
            where T : class
        {
            var obAsT = ob as T;

            if (obAsT != null)
            {
                collection.BaseRemove(ob);
            }
        }
        void LoadData()
        {
            using (UnitOfWork dataSession = new UnitOfWork(dataStorage)) {
                InitDataDictionary(dataSession);

                XPClassInfo  classCustomer = dataSession.GetClassInfo("", "Customer");
                XPBaseObject customer      = (XPBaseObject)dataSession.FindObject(classCustomer, null);
                IList        orders        = (IList)customer.GetMemberValue("Orders");
            }
        }
 private void schedulerStorage1_AppointmentsInserted(object sender, PersistentObjectsEventArgs e)
 {
     foreach (Appointment apt in e.Objects)
     {
         XPBaseObject o = apt.GetSourceObject(schedulerStorage1) as XPBaseObject;
         if (o != null)
         {
             o.Save();
         }
     }
 }
 private void schedulerStorage1_AppointmentsChanged(object sender, DevExpress.XtraScheduler.PersistentObjectsEventArgs e)
 {
     foreach (Appointment apt in e.Objects)
     {
         XPBaseObject o = apt.GetSourceObject(schedulerStorage1) as XPBaseObject;
         if (o != null)
         {
             o.Save();
         }
     }
 }
Example #29
0
        public string 生成编号(XPBaseObject ins)
        {
            var enumerable = 编号规则.OrderBy(x => x.序号).ToArray();
            var builder    = new StringBuilder();

            foreach (var i单据编号规则 in enumerable)
            {
                builder.Append(i单据编号规则.GetRuleResult(ins));
            }
            return(builder.ToString());
        }
 private void schedulerStorage1_AppointmentDependenciesChanged(object sender, PersistentObjectsEventArgs e)
 {
     foreach (AppointmentDependency dependency in e.Objects)
     {
         XPBaseObject xpObject = dependency.GetSourceObject(schedulerStorage1) as XPBaseObject;
         if (xpObject != null)
         {
             xpObject.Save();
         }
     }
 }
 XPBaseCollection GetAuditTrail(Session session, XPBaseObject xpBaseObject, Type auditedObjectWeakReferenceType) {
     var binaryOperator = new BinaryOperator("TargetType", session.GetObjectType(xpBaseObject));
     var operands = new BinaryOperator("TargetKey", XPWeakReference.KeyToString(session.GetKeyValue(xpBaseObject)));
     var auditObjectWR = (XPWeakReference) session.FindObject(auditedObjectWeakReferenceType,new GroupOperator(binaryOperator,operands));
     if (auditObjectWR != null) {
         var baseCollection = (XPBaseCollection) auditObjectWR.ClassInfo.GetMember("AuditDataItems").GetValue(auditObjectWR);
         baseCollection.BindingBehavior = CollectionBindingBehavior.AllowNone;
         return baseCollection;
     }
     return null;
 }
 private void SchedulerStorage_AppointmentsModified(object sender, PersistentObjectsEventArgs e)
 {
     foreach (Appointment apt in e.Objects)
     {
         XPBaseObject o = apt.GetSourceObject(schedulerControl1.Storage.GetCoreStorage()) as XPBaseObject;
         if (o != null)
         {
             o.Save();
         }
     }
 }
 private void OnAppointmentCollectionChanged(object sender, PersistentObjectsEventArgs e)
 {
     foreach (Appointment apt in e.Objects)
     {
         XPBaseObject o = apt.GetSourceObject(schedulerStorage) as XPBaseObject;
         if (o != null)
         {
             o.Save();
         }
     }
 }
Example #34
0
 void ImportProperties(UnitOfWork nestedUnitOfWork, XPBaseObject xpBaseObject, XElement element) {
     ImportSimpleProperties(element, xpBaseObject);
     ImportComplexProperties(element, nestedUnitOfWork,
                             (o, xElement) =>
                             xpBaseObject.SetMemberValue(xElement.Parent.GetAttributeValue("name"), o),
                             NodeType.Object);
     ImportComplexProperties(element, nestedUnitOfWork,
                             (baseObject, element1) =>
                             ((IList) xpBaseObject.GetMemberValue(element1.Parent.GetAttributeValue("name"))).Add(
                                 baseObject), NodeType.Collection);
 }
 void OnAppointmentsChanged(object sender, PersistentObjectsEventArgs e)
 {
     foreach (Appointment apt in e.Objects)
     {
         XPBaseObject o = apt.GetSourceObject((SchedulerDataStorage)sender) as XPBaseObject;
         if (o != null)
         {
             o.Save();
         }
     }
 }
Example #36
0
        XPBaseObject CreateObject(XElement element, IObjectSpace nestedObjectSpace, ITypeInfo typeInfo, CriteriaOperator objectKeyCriteria)
        {
            XPBaseObject xpBaseObject = GetObject(typeInfo, objectKeyCriteria);
            var          keyValuePair = new KeyValuePair <ITypeInfo, CriteriaOperator>(typeInfo, objectKeyCriteria);

            if (!importedObjecs.ContainsKey(keyValuePair))
            {
                importedObjecs.Add(keyValuePair, null);
                ImportProperties(nestedObjectSpace, xpBaseObject, element);
            }
            return(xpBaseObject);
        }
Example #37
0
 void ImportProperties(IObjectSpace nestedObjectSpace, XPBaseObject xpBaseObject, XElement element)
 {
     ImportSimpleProperties(element, xpBaseObject);
     ImportComplexProperties(element, nestedObjectSpace,
                             (o, xElement) =>
                             xpBaseObject.SetMemberValue(xElement.Parent.GetAttributeValue("name"), o),
                             NodeType.Object);
     ImportComplexProperties(element, nestedObjectSpace,
                             (baseObject, element1) =>
                             ((IList)xpBaseObject.GetMemberValue(element1.Parent.GetAttributeValue("name"))).Add(
                                 baseObject), NodeType.Collection);
 }
Example #38
0
 object[] GetArguments(XPBaseObject xpBaseObject)
 {
     if (!string.IsNullOrEmpty(_criteria))
     {
         return new object[] {
                    xpBaseObject.Session,
                    new CriteriaWrapper(_criteria, xpBaseObject).CriteriaOperator
         }
     }
     ;
     return(new object[] { xpBaseObject.Session });
 }
Example #39
0
        void CreateRefElelement(IClassInfoGraphNode classInfoGraphNode, string typeName, XElement root,  XPBaseObject theObject, XElement propertyElement) {
            var serializedObjectRefElement = new XElement("SerializedObjectRef");
            propertyElement.Add(serializedObjectRefElement);
            serializedObjectRefElement.Add(new XAttribute("type", typeName));
            serializedObjectRefElement.Add(new XAttribute("strategy", classInfoGraphNode.SerializationStrategy));

            if (theObject != null) {
                IEnumerable<IClassInfoGraphNode> classInfoGraphNodes = GetClassInfoGraphNodes(theObject, typeName);

                createRefKeyElements(classInfoGraphNodes, theObject, serializedObjectRefElement);
                if (serializedObjectRefElement.FindObjectFromRefenceElement(true) == null &&classInfoGraphNode.SerializationStrategy == SerializationStrategy.SerializeAsObject)
                    ExportCore(theObject, classInfoGraphNodes, root);
            }
        }
        private string GetItemText(XPBaseObject xpObject)
        {
            if (xpObject == null)
            {
                return(null);
            }

            if (!ReferenceEquals(ItemTextCriteria, null))
            {
                var result = xpObject.Evaluate(ItemTextCriteria);
                return(Convert.ToString(result));
            }
            return(null);
        }
Example #41
0
 void SetMemberValue(XPBaseObject selectedObject, IClassInfoGraphNode classInfoGraphNode, XElement propertyElement) {
     var memberValue = selectedObject.GetMemberValue(classInfoGraphNode.Name);
     var xpMemberInfo = selectedObject.ClassInfo.FindMember(classInfoGraphNode.Name);
     if (xpMemberInfo != null ) {
         if (xpMemberInfo.Converter != null)
             memberValue = (xpMemberInfo.Converter.ConvertToStorageType(memberValue));
         if (memberValue is byte[])
             memberValue = Convert.ToBase64String((byte[])memberValue);
         if (memberValue is DateTime)
             memberValue = ((DateTime)memberValue).Ticks;
         if (memberValue is string)
             propertyElement.Add(new XCData(memberValue.ToString()));
         else                {
             propertyElement.Value = GetInvariantValue(memberValue);
         }
     }
 }
 public static void SetEditorButtonKind(RepositoryItemButtonEdit repositoryItemButtonEdit, XPBaseObject baseObject, string propertyName){
     EditorButton button = GetEditorButton(repositoryItemButtonEdit);
     if (button != null && baseObject != null){
         MemberProtectedInfo isProtected = IsProtected(baseObject, propertyName);
         button.Appearance.BackColor2 = Color.FromArgb(0, 0, 0);
         if (isProtected.IsProtected && button.Kind != ButtonPredefines.Minus){
             button.Kind = ButtonPredefines.Minus;
             button.Appearance.BackColor2=Color.BlueViolet;
             if (isProtected.IsClassProtected)
                 button.Appearance.ForeColor=Color.Red;
         }
         else 
             button.Kind = ButtonPredefines.Plus;
         repositoryItemButtonEdit.ButtonClick +=
             (sender1, e1) => ChangeLockStatus(e1, baseObject, propertyName);
     }
 }
Example #43
0
 void ExportCore(XPBaseObject selectedObject, IEnumerable<IClassInfoGraphNode> serializedClassInfoGraphNodes, XElement root) {
     var serializedObjectElement = new XElement("SerializedObject");
     serializedObjectElement.Add(new XAttribute("type", selectedObject.GetType().Name));
     root.Add(serializedObjectElement);
     foreach (var classInfoGraphNode in serializedClassInfoGraphNodes) {
         XElement propertyElement = GetPropertyElement(serializedObjectElement, classInfoGraphNode);
         switch (classInfoGraphNode.NodeType) {
             case NodeType.Simple:
                 propertyElement.Value = GetMemberValue(selectedObject, classInfoGraphNode) + "";
                 break;
             case NodeType.Object:
                 createObjectProperty(selectedObject, propertyElement, classInfoGraphNode, root);
                 break;
             case NodeType.Collection:
                 createCollectionProperty(selectedObject, classInfoGraphNode, root, propertyElement);
                 break;
         }
     }
 }
 public IEnumerable<IClassInfoGraphNode> GetSerializedClassInfoGraphNodes(XPBaseObject baseObject) {
     var configuration = GetConfiguration(baseObject.Session, baseObject.GetType());
     return GetSerializedClassInfoGraphNodes(configuration);
 }
 public IEnumerable<IClassInfoGraphNode> GetSerializedClassInfoGraphNodes(XPBaseObject theObject, string typeName) {
     var type = ReflectionHelper.GetType(typeName);
     ISerializationConfiguration configuration = GetConfiguration(theObject.Session, type);
     return GetSerializedClassInfoGraphNodes(configuration);
 }
Example #46
0
 public ChangedMemberCollector(XPBaseObject xpBaseObject) {
     _memberInfoCollection=new MemberInfoCollection(xpBaseObject.ClassInfo);
     _xpBaseObject = xpBaseObject;
 }
 object CreateInstance(XPBaseObject xpBaseObject) {
     var auditedObjectWeakReferenceType = ApplicationHelper.Instance.Application.TypesInfo.FindTypeInfo("DevExpress.Persistent.BaseImpl.AuditedObjectWeakReference").Type;
     return GetAuditTrail(xpBaseObject.Session, xpBaseObject, auditedObjectWeakReferenceType);
 }
 object CreateInstance(XPBaseObject xpBaseObject) {
     var auditedObjectWeakReferenceType = ApplicationHelper.Instance.Application.TypesInfo.FindTypeInfo(typeof(XpandAuditedObjectWeakReference)).Type;
     return GetAuditTrail(xpBaseObject.Session, xpBaseObject, auditedObjectWeakReferenceType);
 }
 public override string GetRuleResult(XPBaseObject instance)
 {
     return 手工输入;
 }
Example #50
0
 void CreateObjectProperty(XPBaseObject selectedObject, XElement propertyElement, IClassInfoGraphNode classInfoGraphNode, XElement root) {
     XPMemberInfo memberInfo = selectedObject.ClassInfo.FindMember(classInfoGraphNode.Name);
     if (memberInfo != null) {
         var theObject = (XPBaseObject) memberInfo.GetValue(selectedObject);
         CreateRefElelement(classInfoGraphNode,theObject!= null?theObject.GetType().Name:memberInfo.MemberType.Name, root,  theObject, propertyElement);
     }
 }
Example #51
0
 void ImportSimpleProperties(XElement element, XPBaseObject xpBaseObject) {            
     foreach (var simpleElement in element.Properties(NodeType.Simple)){
         string propertyName = simpleElement.GetAttributeValue("name");
         XPMemberInfo xpMemberInfo = xpBaseObject.ClassInfo.FindMember(propertyName);
         if (xpMemberInfo != null) {
             object value = GetValue(simpleElement, xpMemberInfo);
             xpBaseObject.SetMemberValue(propertyName, value);
         }
     }
 }
Example #52
0
 void CreateCollectionProperty(XPBaseObject selectedObject, IClassInfoGraphNode classInfoGraphNode, XElement root,
                               XElement propertyElement) {
     XPMemberInfo memberInfo = selectedObject.ClassInfo.FindMember(classInfoGraphNode.Name);
     if (memberInfo != null) {
         var theObjects = (IEnumerable)memberInfo.GetValue(selectedObject);
         foreach (XPBaseObject theObject in theObjects) {
             CreateRefElelement(classInfoGraphNode,theObject.GetType().Name, root,  theObject, propertyElement);
         }
     }
 }
Example #53
0
 public static void SetXpMemberProperty(string propertyName, object value, XPBaseObject dbObject) {
     SetXpMemberProperty(propertyName, value, dbObject, false);
 }
Example #54
0
        public static void SetXpMemberProperty(string propertyName, object value, XPBaseObject dbObject, bool save) {
            if (propertyName.IndexOf(".", StringComparison.Ordinal) > -1) {
                XPMemberInfo member = dbObject.ClassInfo.GetMember(propertyName.Split(".".ToCharArray())[0]);
                object o = member.GetValue(dbObject);
                if (typeof(XPBaseObject).IsAssignableFrom(member.MemberType)) {
                    dbObject = o as XPBaseObject;
                    SetXpMemberProperty(propertyName.Substring(propertyName.IndexOf(".", StringComparison.Ordinal) + 1), value, dbObject, save);
                    return;
                }
                SetPropertyValue(o.GetType().GetProperty(propertyName.Substring(propertyName.IndexOf(".", StringComparison.Ordinal) + 1)), o,
                                 value);
                return;
            }
            XPMemberInfo xpMemberInfo = dbObject.ClassInfo.GetMember(propertyName);
            if (xpMemberInfo == null)
                throw new PropertyMissingException(dbObject.GetType().FullName, propertyName);
            xpMemberInfo.SetValue(dbObject,
                                  xpMemberInfo.Owner.ClassType.GetProperty(propertyName) == null
                                      ? value
                                      : ChangeType(value, xpMemberInfo.MemberType));
            if (save)
                dbObject.Save();

        }
Example #55
0
 public static object GetXpMemberInfoValue(string propertyName, XPBaseObject o) {
     if (propertyName.IndexOf(".", StringComparison.Ordinal) > -1) {
         XPMemberInfo info = o.ClassInfo.GetMember(propertyName.Split(".".ToCharArray())[0]);
         object value = info.GetValue(o);
         if (typeof(XPBaseObject).IsAssignableFrom(info.MemberType)) {
             o = value as XPBaseObject;
             return o == null
                        ? null
                        : GetXpMemberInfoValue(propertyName.Substring(propertyName.IndexOf(".", StringComparison.Ordinal) + 1), o);
         }
         return
             value != null
                 ? GetPropertyInfoValue(propertyName.Substring(propertyName.IndexOf(".", StringComparison.Ordinal) + 1), info.GetValue(o))
                 : null;
     }
     XPMemberInfo xpMemberInfo = o.ClassInfo.GetMember(propertyName);
     if (xpMemberInfo == null)
         throw new PropertyMissingException(o.GetType().FullName, propertyName);
     return xpMemberInfo.GetValue(o);
 }
Example #56
0
 IEnumerable<IClassInfoGraphNode> GetSerializedClassInfoGraphNodes(XPBaseObject baseObject, ISerializationConfiguration serializationConfiguration) {
     ISerializationConfiguration configuration = baseObject.GetType() ==serializationConfiguration.TypeToSerialize? serializationConfiguration
                                                     : SerializationConfigurationQuery.Find(baseObject.Session, baseObject.GetType());
     return GetSerializedClassInfoGraphNodes(configuration);
 }
 public override string GetRuleResult(XPBaseObject instance)
 {
     return DateTime.Now.ToString(格式化字符串); ;
 }
Example #58
0
 void CreateRefKeyElements(IEnumerable<IClassInfoGraphNode> serializedClassInfoGraphNodes, XPBaseObject theObject, XElement serializedObjectRefElement) {
     foreach (var infoGraphNode in serializedClassInfoGraphNodes.Where(node => node.Key)) {
         var serializedObjectRefKeyElement = new XElement("Key");
         serializedObjectRefKeyElement.Add(new XAttribute("name",infoGraphNode.Name));
         serializedObjectRefKeyElement.Value = theObject.GetMemberValue(infoGraphNode.Name).ToString();
         serializedObjectRefElement.Add(serializedObjectRefKeyElement);
     }
 }
Example #59
0
 IEnumerable<IClassInfoGraphNode> GetClassInfoGraphNodes(XPBaseObject theObject, string typeName) {
     var configuration =(ISerializationConfiguration)theObject.Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction,
                                                                                  TypesInfo.Instance.SerializationConfigurationType, SerializationConfigurationQuery.GetCriteria(ReflectionHelper.GetType(typeName)));
     return GetSerializedClassInfoGraphNodes(configuration);
 }
 public override string GetRuleResult(XPBaseObject instance)
 {
     return SequenceGenerator.GenerateNextSequence(this.所属方案.应用单据.FullName).ToString(格式化字符串);
 }