Пример #1
0
        public EditPropertyForm(DomainObjectInquiry inquiry, DomainObjectConfig obj, DomainPropertyConfig prop)
        {
            InitializeComponent();

            m_inquiry = inquiry;
            m_object = obj;
            m_property = prop;

            FillDataType();

            if (m_property != null)
            {
                txtCode.Text = m_property.Code;
                txtCode.Enabled = false;

                txtCodeName.Text = m_property.CodeName;
                txtDescription.Text = m_property.Description;

                txtDataType.SelectedItem = m_property.DataType;
                txtDataType.Enabled = false;

                txtLength.Value = m_property.Size;
                txtLength.Enabled = false;
            }
        }
Пример #2
0
 internal DomainPropertyConfig(long id, string code, string description, DomainObjectConfig owner, Type dataType, string fieldName, object defaultValue, int size, string codeName)
 {
     Id = id;
     Code = code;
     Description = description;
     Owner = owner;
     DataType = dataType;
     DefaultValue = defaultValue;
     FieldName = fieldName;
     Size = size;
     CodeName = codeName;
 }
Пример #3
0
        public EditObjectForm(DomainObjectInquiry inquiry, DomainObjectConfig obj)
        {
            InitializeComponent();

            m_inquiry = inquiry;
            m_object = obj;

            if (obj != null)
            {
                txtCode.Enabled = false;
                txtCode.Text = obj.Code;
                txtCodeName.Text = obj.CodeName;
                txtDescription.Text = obj.Description;
            }
        }
Пример #4
0
 public override void SaveObject(DomainObjectConfig objConfig)
 {
     throw new NotImplementedException();
 }
Пример #5
0
        public override void CreateObject(DomainObjectConfig objConfig)
        {
            DbCommonCommand command = m_createObjectCommand.Value;

            command["ID"].Value = objConfig.Id;
            command["CODE"].Value = objConfig.Code;
            command["DESCRIPTION"].Value = objConfig.Description;
            command["TABLE_NAME"].Value = objConfig.TableName;
            command["ID_FIELD"].Value = objConfig.IdField;
            command["CODE_NAME"].Value = objConfig.CodeName;

            command.ExecuteNonQuery(SessionIdentifier.SHARED_SESSION);
        }
Пример #6
0
 public EditObjectConfigArgs(DomainObjectConfig newObject, string prevCodeName)
     : base(newObject)
 {
     PrevCodeName = prevCodeName;
 }
Пример #7
0
        private TreeListNode GetPropertiesNode(DomainObjectInquiry inquiry, DomainObjectConfig objectConfig)
        {
            TreeListNode objectConfigNode = GetObjectConfigNode(inquiry, objectConfig);
            TreeListNode propertyCollectionNode = GetNode(objectConfigNode, eObjectExplorerNode.ObjectProperties);

            if (propertyCollectionNode == null)
                throw new ApplicationException(ObjectExplorerControlLocalization.PropertyCollectionNodeNotFoundError);

            return propertyCollectionNode;
        }
Пример #8
0
 public abstract void CreateObject(DomainObjectConfig objConfig);
Пример #9
0
        public static string DomainObjectCode(DomainObjectInquiry inquiry, DomainObjectConfig obj)
        {
            CodeCompileUnit unit = new CodeCompileUnit();
            CodeNamespace targetNamespace = new CodeNamespace("NamespaceName");
            unit.Namespaces.Add(targetNamespace);

            targetNamespace.Imports.Add(new CodeNamespaceImport("System"));
            targetNamespace.Imports.Add(new CodeNamespaceImport("DomainCommonSE"));
            targetNamespace.Imports.Add(new CodeNamespaceImport("DomainCommonSE.Domain"));
            targetNamespace.Imports.Add(new CodeNamespaceImport("DomainCommonSE.DomainConfig"));

            // объявление класса
            CodeTypeDeclaration targetClass = new CodeTypeDeclaration(obj.CodeName)
            {
                IsClass = true,
                TypeAttributes = TypeAttributes.Public
            };
            targetNamespace.Types.Add(targetClass);

            // базовый класс
            targetClass.BaseTypes.Add(typeof(DomainObject));

            // комментарий - описание класса
            SetSummaryComment(targetClass, obj.Description);

            // строковая константа - код класса
            CodeMemberField objectNameConst = new CodeMemberField
            {
                Attributes = MemberAttributes.Public | MemberAttributes.Const,
                Name = ObjectCodeConstFieldName,
                Type = new CodeTypeReference(typeof(String)),
                InitExpression = new CodePrimitiveExpression(obj.Code)
            };

            targetClass.Members.Add(objectNameConst);

            #region Конструктор загрузки объекта из БД
            CodeConstructor loadObjectConstructor = new CodeConstructor();
            loadObjectConstructor.Attributes = MemberAttributes.Public;

            loadObjectConstructor.Parameters.Add(new CodeParameterDeclarationExpression(typeof(SessionIdentifier), "sessionId"));
            loadObjectConstructor.BaseConstructorArgs.Add(new CodeVariableReferenceExpression("sessionId"));

            loadObjectConstructor.Parameters.Add(new CodeParameterDeclarationExpression(typeof(ObjectIdentifier), "objectId"));
            loadObjectConstructor.BaseConstructorArgs.Add(new CodeVariableReferenceExpression("objectId"));

            targetClass.Members.Add(loadObjectConstructor);
            #endregion

            #region Конструктор создания нового объекта
            CodeConstructor newObjectConstructor = new CodeConstructor();
            newObjectConstructor.Attributes = MemberAttributes.Public;

            newObjectConstructor.Parameters.Add(new CodeParameterDeclarationExpression(typeof(SessionIdentifier), "sessionId"));
            newObjectConstructor.BaseConstructorArgs.Add(new CodeVariableReferenceExpression("sessionId"));
            newObjectConstructor.BaseConstructorArgs.Add(new CodeVariableReferenceExpression(ObjectCodeConstFieldName));

            targetClass.Members.Add(newObjectConstructor);
            #endregion

            DomainObjectPropertiesCode(obj, targetClass);
            DomainObjectLinksCode(inquiry, obj, targetClass, loadObjectConstructor, newObjectConstructor);

            StringBuilder resultCode = new StringBuilder();
            using (StringWriter sourceWriter = new StringWriter(resultCode))
            {
                CreateProvider().GenerateCodeFromCompileUnit(unit, sourceWriter, CreateGeneratorOptions());
            }

            return resultCode.ToString();
        }
Пример #10
0
        private static void DomainObjectLinksCode(DomainObjectInquiry inquiry, DomainObjectConfig obj, CodeTypeDeclaration targetClass, CodeConstructor constructor, CodeConstructor newObjectConstructor)
        {
            foreach (DomainLinkConfig link in inquiry.ALinks)
            {
                if (link.LeftObject != obj && link.RightObject != obj)
                    continue;

                CodeMemberField linkCodeConst = DomainLinkCodeConstCode(link);
                targetClass.Members.Add(linkCodeConst);

                if (link.LeftObject == obj)
                {
                    CodeMemberField leftPrivateColl = LeftLinkPrivateCollection(link);
                    targetClass.Members.Add(leftPrivateColl);

                    CodeMemberProperty leftPropField = LeftLinkCollection(link, leftPrivateColl);
                    targetClass.Members.Add(leftPropField);

                    CodeMethodInvokeExpression linkFunc = new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeThisReferenceExpression(), "GetLinkCollection"), new CodeVariableReferenceExpression(linkCodeConst.Name), new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("eLinkSide"), eLinkSide.Left.ToString()));
                    CodeAssignStatement initCollectionStatement = new CodeAssignStatement(new CodeVariableReferenceExpression(leftPrivateColl.Name), linkFunc);

                    constructor.Statements.Add(initCollectionStatement);
                    newObjectConstructor.Statements.Add(initCollectionStatement);
                }

                if (link.RightObject == obj)
                {
                    //CodeMemberProperty rightPropField = RightLinkCollection(link);
                    //targetClass.Members.Add(rightPropField);
                }
            }

            //	throw new NotImplementedException();

            //bool isFirstLink = true;
            //CodeMemberProperty lastLink = null;
            //foreach (EntityLinkConfig linkConfig in obj.Link)
            //{
            //    CodeMemberField linkCodeConst = null;
            //    CodeMemberProperty link = null;
            //    EntityLinkCode(linkConfig, out linkCodeConst, out link);

            //    targetClass.Members.Add(linkCodeConst);

            //    // начало региона свойств
            //    if (isFirstLink)
            //    {
            //        CodeRegionDirective startLinksRegion = new CodeRegionDirective(CodeRegionMode.Start, LinkRegionName);
            //        linkCodeConst.StartDirectives.Add(startLinksRegion);
            //        isFirstLink = false;
            //    }

            //    targetClass.Members.Add(link);
            //    lastLink = link;
            //}

            //// закрываем регион свойств
            //if (lastLink != null)
            //{
            //    CodeRegionDirective endLinksRegion = new CodeRegionDirective(CodeRegionMode.End, string.Empty);
            //    lastLink.EndDirectives.Add(endLinksRegion);
            //}
        }
Пример #11
0
 public void EditObjectConfig(DomainObjectInquiry inquiry, DomainObjectConfig obj = null)
 {
     using (EditObjectForm form = new EditObjectForm(inquiry, obj))
     {
         form.ShowDialog();
     }
 }
Пример #12
0
 public void DeleteObjectConfig(DomainObjectInquiry inquiry, DomainObjectConfig obj)
 {
     if (XtraMessageBox.Show(String.Format(UILocalization.DeleteEntityObjectQuestion, obj.Code), UILocalization.DeleteEntityObjectCaption, MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         inquiry.DeleteObject(obj);
     }
 }
Пример #13
0
 public void CreatePropertyConfig(DomainObjectInquiry inquiry, DomainObjectConfig obj)
 {
     using (EditPropertyForm form = new EditPropertyForm(inquiry, obj, null))
     {
         form.ShowDialog();
     }
 }
Пример #14
0
 public ObjectSqlArgs(DomainObjectInquiry inquiry, DomainObjectConfig obj, eKind kind)
     : base(inquiry)
 {
     AObject = obj;
     Kind = kind;
 }
Пример #15
0
 public void CreateLinkConfig(DomainObjectInquiry inquiry, DomainObjectConfig obj)
 {
     using (EditLinkForm form = new EditLinkForm(inquiry))
     {
         form.ShowDialog();
     }
 }
Пример #16
0
 public abstract void SaveObject(DomainObjectConfig objConfig);
Пример #17
0
 public abstract void DeleteObject(DomainObjectConfig objConfig);
Пример #18
0
        public static string DomainObjectLinksCode(DomainObjectConfig objConfig)
        {
            throw new NotImplementedException();

            //StringBuilder resultCode = new StringBuilder();
            //using (StringWriter sourceWriter = new StringWriter(resultCode))
            //{
            //    CodeDomProvider provider = CreateProvider();
            //    CodeGeneratorOptions createGeneratorOptions = CreateGeneratorOptions();

            //    foreach (EntityLinkConfig linkConfig in objConfig.Link)
            //    {
            //        CodeMemberField linkCodeConst = null;
            //        CodeMemberProperty link = null;
            //        EntityLinkCode(linkConfig, out linkCodeConst, out link);

            //        provider.GenerateCodeFromMember(linkCodeConst, sourceWriter, createGeneratorOptions);
            //        provider.GenerateCodeFromMember(link, sourceWriter, createGeneratorOptions);
            //    }
            //}

            //return resultCode.ToString();
        }
Пример #19
0
        public static string DomainObjectPropertiesCode(DomainObjectConfig objConfig)
        {
            StringBuilder resultCode = new StringBuilder();
            using (StringWriter sourceWriter = new StringWriter(resultCode))
            {
                CodeDomProvider provider = CreateProvider();
                CodeGeneratorOptions createGeneratorOptions = CreateGeneratorOptions();

                foreach (DomainPropertyConfig propConfig in objConfig.Property)
                {
                    CodeMemberField propertyCodeConst = null;
                    CodeMemberProperty prop = null;
                    DomainPropertyCode(propConfig, out propertyCodeConst, out prop);

                    provider.GenerateCodeFromMember(propertyCodeConst, sourceWriter, createGeneratorOptions);
                    provider.GenerateCodeFromMember(prop, sourceWriter, createGeneratorOptions);
                }
            }

            return resultCode.ToString();
        }
Пример #20
0
 public void ShowObjectSql(DomainObjectInquiry app, DomainObjectConfig obj, ObjectSqlArgs.eKind kind)
 {
     if (ObjectSqlRequest != null)
         ObjectSqlRequest(this, new ObjectSqlArgs(app, obj, kind));
 }
Пример #21
0
        private static void DomainObjectPropertiesCode(DomainObjectConfig obj, CodeTypeDeclaration targetClass)
        {
            bool isFirstProperty = true;
            CodeMemberProperty lastProperty = null;
            foreach (DomainPropertyConfig propConfig in obj.Property)
            {
                CodeMemberField propertyCodeConst = null;
                CodeMemberProperty prop = null;
                DomainPropertyCode(propConfig, out propertyCodeConst, out prop);

                targetClass.Members.Add(propertyCodeConst);

                // начало региона свойств
                if (isFirstProperty)
                {
                    CodeRegionDirective startPropertiesRegion = new CodeRegionDirective(CodeRegionMode.Start, PropertyRegionName);
                    propertyCodeConst.StartDirectives.Add(startPropertiesRegion);
                    isFirstProperty = false;
                }

                targetClass.Members.Add(prop);
                lastProperty = prop;
            }

            // закрываем регион свойств
            if (lastProperty != null)
            {
                CodeRegionDirective endPropertiesRegion = new CodeRegionDirective(CodeRegionMode.End, string.Empty);
                lastProperty.EndDirectives.Add(endPropertiesRegion);
            }
        }
Пример #22
0
        private void AppendObjectConfigNode(TreeListNode parentNode, DomainObjectInquiry inquiry, DomainObjectConfig objConfig)
        {
            TreeListNode objNode = AppendNode(parentNode, GetNodeTitle(objConfig), new ObjectExplorerNodeTag(inquiry, eObjectExplorerNode.ObjectConfig, objConfig));

            TreeListNode objPropertiesNode = AppendNode(objNode, ObjectExplorerControlLocalization.PropertiesNodeTitle, new ObjectExplorerNodeTag(inquiry, eObjectExplorerNode.ObjectProperties, objConfig));

            foreach (DomainPropertyConfig prop in objConfig.Property)
            {
                AppendPropertyConfigNode(inquiry, objPropertiesNode, prop);
            }
        }
 public DomainObjectBrokerBuilder(DomainObjectConfig objectConfig, IEnumerable<DomainLinkConfig> links, IDbCommonConnection dbConnection)
 {
     m_objectConfig = objectConfig;
     m_links = links.ToDictionary(link => link.Code);
     m_dbConnection = dbConnection;
 }
Пример #24
0
 public ObjectConfigArgs(DomainObjectConfig aobject)
 {
     AObject = aobject;
 }
Пример #25
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            string code = txtCode.Text.Trim();
            string codeName = txtCodeName.Text.Trim();
            string description = txtDescription.Text.Trim();

            if (String.IsNullOrEmpty(code))
            {
                MessageBox.Show(EditObjectFormLocalization.EnterObjectCodeMessage);
                return;
            }

            if (String.IsNullOrEmpty(codeName))
            {
                MessageBox.Show(EditObjectFormLocalization.EnterObjectClassNameMessage);
                return;
            }

            if (m_object == null)
            {
                if (m_inquiry.AObject.Contains(code))
                {
                    MessageBox.Show(GetCodeAlreadyExistMessage(code));
                    return;
                }

                m_object = m_inquiry.CreateObject(code, description, codeName);
            }
            else
            {
                m_inquiry.SaveObject(m_object, codeName, description);
            }

            DialogResult = DialogResult.OK;
        }
Пример #26
0
        public override void DeleteObject(DomainObjectConfig objConfig)
        {
            DbCommonCommand command = m_removeObjectCommand.Value;

            command["ID"].Value = objConfig.Id;
            command.ExecuteNonQuery(SessionIdentifier.SHARED_SESSION);
        }
Пример #27
0
 private TreeListNode GetObjectConfigNode(DomainObjectInquiry inquiry, DomainObjectConfig objectConfig)
 {
     TreeListNode objectRootNode = GetRootObjectsNode(inquiry);
     return GetNodeByValue(objectRootNode, objectConfig);
 }
Пример #28
0
        public override DomainObjectConfigCollection LoadObject()
        {
            DbCommonCommand command = null;
            IDbCommonDataReader reader = null;

            m_objectConfig = new DomainObjectConfigCollection();

            #region Загрузка объектов
            command = m_loadObjectCommand.Value;

            using (reader = command.ExecuteReader(SessionIdentifier.SHARED_SESSION))
            {
                while (reader.Read())
                {
                    long id = reader.GetValue<long>(0);
                    string code = reader.GetValue<String>(1);
                    string description = reader.GetValue<String>(2);
                    string tableName = reader.GetValue<String>(3);
                    string idField = reader.GetValue<String>(4);
                    string codeName = reader.GetValue<String>(5);

                    DomainObjectConfig configObject = new DomainObjectConfig(id, code, description, tableName, idField, codeName);
                    m_objectConfig.Add(configObject);
                }
                reader.Close();
            }
            #endregion

            #region Загрузка свойств
            command = m_loadPropertyCommand.Value;

            using (reader = command.ExecuteReader(SessionIdentifier.SHARED_SESSION))
            {
                while (reader.Read())
                {
                    long id = reader.GetValue<long>(0);
                    string code = reader.GetValue<String>(1);
                    string description = reader.GetValue<String>(2);
                    string ownerCode = reader.GetValue<String>(3);

                    string dataTypeName = reader.GetValue<String>(4);
                    string assemblyFile = reader.GetValue<String>(5);
                    Type dataType = GetValueType(assemblyFile, dataTypeName);

                    string filedName = reader.GetValue<String>(6);
                    object defaultValue = reader.GetValue(7, typeof(object));
                    int length = reader.GetValue<Int32>(8);
                    string codeName = reader.GetValue<String>(9);

                    DomainObjectConfig owner = m_objectConfig[ownerCode];
                    DomainPropertyConfig property = new DomainPropertyConfig(id, code, description, owner, dataType, filedName, defaultValue, length, codeName);

                    owner.Property.Add(property);
                }
                reader.Close();
            }
            #endregion

            return m_objectConfig;
        }
Пример #29
0
 private static string GetNodeTitle(DomainObjectConfig objConfig)
 {
     return String.Format("{0} ({1})", objConfig.Code, objConfig.Description);
 }
Пример #30
0
        public override void SaveObject(DomainObjectConfig objConfig)
        {
            DbCommonCommand command = m_editObjectCommand.Value;

            command["ID"].Value = objConfig.Id;
            command["CODE_NAME"].Value = objConfig.CodeName;
            command["DESCRIPTION"].Value = objConfig.Description;
            command.ExecuteNonQuery(SessionIdentifier.SHARED_SESSION);
        }