Exemple #1
0
        public EditLinkForm(DomainObjectInquiry inquiry, DomainLinkConfig link = null)
        {
            InitializeComponent();

            m_inquiry = inquiry;
            m_link = link;

            FillObjects();

            if (link != null)
            {
                txtLinkCode.Enabled = false;
                txtLinkTableName.Enabled = false;

                rgLeftRelation.Enabled = false;
                rgRightRelation.Enabled = false;

                txtLeftIdField.Enabled = false;
                txtRightIdField.Enabled = false;

                gridLeftObject.Enabled = false;
                gridRightObject.Enabled = false;

                txtLinkCode.Text = link.Code;
                txtLinkTableName.Text = link.LinkTable;

                rgLeftRelation.SelectedIndex = link.LeftRelation == eRelation.One ? 0 : 1;
                rgRightRelation.SelectedIndex = link.RightRelation == eRelation.One ? 0 : 1;

                txtLeftIdField.Text = link.LeftObjectIdField;
                txtRightIdField.Text = link.RightObjectIdField;

                gridLeftObjectCodeColumn.View.ActiveFilterString = String.Format("[Code] LIKE '{0}'", link.LeftObject.Code);
                gridRightObjectCodeColumn.View.ActiveFilterString = String.Format("[Code] LIKE '{0}'", link.RightObject.Code);

                cbIsLeftToRight.Checked = link.IsLeftToRightActive;
                cbIsRightToLeft.Checked = link.IsRightToLeftActive;

                txtLeftCollectionName.Text = link.LeftCollectionName;
                txtRightCollectionName.Text = link.RightCollectionName;

                txtLeftToRightDescription.Text = link.LeftToRightDescription;
                txtRightToLeftDescription.Text = link.RightToLeftDescription;
            }
            else
            {
                rgLeftRelation.SelectedIndex = 0;
                rgRightRelation.SelectedIndex = 1;
            }

            EnableControlByRelation();
        }
        public static string DomainLinkCode(DomainLinkConfig linkConfig)
        {
            throw new NotImplementedException();

            //CodeMemberField linkCodeConst = null;
            //CodeMemberProperty link = null;
            //EntityLinkCode(linkConfig, out linkCodeConst, out link);

            //CodeDomProvider provider = CreateProvider();
            //CodeGeneratorOptions createGeneratorOptions = CreateGeneratorOptions();

            //StringBuilder resultCode = new StringBuilder();
            //using (StringWriter sourceWriter = new StringWriter(resultCode))
            //{
            //    provider.GenerateCodeFromMember(linkCodeConst, sourceWriter, createGeneratorOptions);
            //    provider.GenerateCodeFromMember(link, sourceWriter, createGeneratorOptions);
            //}

            //return resultCode.ToString();
        }
        private static CodeMemberField DomainLinkCodeConstCode(DomainLinkConfig linkConfig)
        {
            string linkConstName = String.Format("Link{0}", linkConfig.Code);
            CodeMemberField linkCodeConst = new CodeMemberField
            {
                Attributes = MemberAttributes.Family | MemberAttributes.Const,
                Name = linkConstName,
                Type = new CodeTypeReference(typeof(String)),
                InitExpression = new CodePrimitiveExpression(linkConfig.Code)
            };

            SetSummaryComment(linkCodeConst, String.Format("Код ссылки '{0}'", linkConfig.Code));

            return linkCodeConst;
        }
 public override void SaveLink(DomainLinkConfig link, EditLinkParams editParams)
 {
     throw new NotImplementedException();
 }
 public override void DeleteLink(DomainLinkConfig link)
 {
     throw new NotImplementedException();
 }
        public void DeleteLink(DomainLinkConfig link)
        {
            if (link == null)
                throw new ArgumentNullException("link");

            if (link.LeftRelation == eRelation.Many && link.RightRelation == eRelation.Many)
            {
                Connection.RemoveTable(link.LinkTable);
            }
            else
            {
                if (link.LeftRelation == eRelation.One)
                {
                    Connection.RemoveTableField(link.RightObject.TableName, link.LeftObjectIdField);
                }
                else
                {
                    Connection.RemoveTableField(link.LeftObject.TableName, link.RightObjectIdField);
                }
            }

            m_provider.DeleteLink(link);

            ALinks.Remove(link);

            if (DeleteLinkCompleted != null)
                DeleteLinkCompleted(this, new LinkConfigArgs(link));

            IsModified = true;
        }
 private void AppendLinkConfigNode(DomainObjectInquiry inquiry, TreeListNode objLinksNode, DomainLinkConfig link)
 {
     AppendNode(objLinksNode, GetNodeTitle(link), new ObjectExplorerNodeTag(inquiry, eObjectExplorerNode.LinkConfig, link));
 }
 private static CodeMemberField LeftLinkPrivateCollection(DomainLinkConfig linkConfig)
 {
     return new CodeMemberField(typeof(DomainObjectCollection), String.Format("m_{0}{1}", linkConfig.LeftCollectionName.ToLower()[0], linkConfig.LeftCollectionName.Substring(1)));
 }
Exemple #9
0
 public void DeleteLinkConfig(DomainObjectInquiry inquiry, DomainLinkConfig link)
 {
     if (MessageBox.Show(String.Format(UILocalization.DeleteEntityObjectLinkQuestion, link.Code), UILocalization.DeleteEntityObjectLinkCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         throw new NotImplementedException();
         //DomainObjectConfig parentObject = inquiry.AObject[link.BaseObjectCode];
         //inquiry.RemoveLink(parentObject, link.DirectCode);
     }
 }
 public abstract void SaveLink(DomainLinkConfig link, EditLinkParams editParams);
 public abstract void DeleteLink(DomainLinkConfig link);
 public DomainLinkBrokerBuilder(DomainLinkConfig linkConfig, IDbCommonConnection dbConnection)
 {
     m_linkConfig = linkConfig;
     m_dbConnection = dbConnection;
 }
 public LinkConfigArgs(DomainLinkConfig link)
 {
     Link = link;
 }
 public EditLinkConfigArgs(DomainLinkConfig link)
     : base(link)
 {
     //throw new NotImplementedException("add prev state changed params");
 }
        public void SaveLink(DomainLinkConfig link, EditLinkParams editParams)
        {
            if (!editParams.IsLeftToRightActive && !editParams.IsRightToLeftActive)
                throw new ArgumentException();

            if (!Utils.CheckEnglishString(editParams.LeftCollectionName))
                throw new ArgumentOutOfRangeException("editParams.LeftCollectionName", Resources.OnlyLatinString);

            if (!Utils.CheckEnglishString(editParams.RightCollectionName))
                throw new ArgumentOutOfRangeException("editParams.RightCollectionName", Resources.OnlyLatinString);

            m_provider.SaveLink(link, editParams);

            link.Update(editParams);

            if (EditLinkCompleted != null)
                EditLinkCompleted(this, new EditLinkConfigArgs(link));

            IsModified = true;
        }
Exemple #16
0
 public void EditLinkConfig(DomainObjectInquiry inquiry, DomainLinkConfig link)
 {
     using (EditLinkForm form = new EditLinkForm(inquiry, link))
     {
         form.ShowDialog();
     }
 }
        private static CodeMemberProperty LeftLinkCollection(DomainLinkConfig linkConfig, CodeMemberField privateCollection)
        {
            CodeMemberProperty link = new CodeMemberProperty()
            {
                Name = linkConfig.LeftCollectionName,
                Attributes = MemberAttributes.Public | MemberAttributes.Final,
                Type = new CodeTypeReference(typeof(DomainObjectCollection)),
            };

            link.GetStatements.Add(new CodeMethodReturnStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), privateCollection.Name)));

            SetSummaryComment(link, linkConfig.LeftToRightDescription);

            return link;
        }
        public override void DeleteLink(DomainLinkConfig link)
        {
            DbCommonCommand command = m_removeLinkCommand.Value;

            command["ID"].Value = link.Id;
            command.ExecuteNonQuery(SessionIdentifier.SHARED_SESSION);
        }
 private static CodeMemberProperty RightLinkCollection(DomainLinkConfig linkConfig)
 {
     throw new NotImplementedException();
 }
        public override List<DomainLinkConfig> LoadLink()
        {
            List<DomainLinkConfig> result = new List<DomainLinkConfig>();
            DbCommonCommand command = m_loadLinkCommand.Value;

            using (IDbCommonDataReader reader = command.ExecuteReader(SessionIdentifier.SHARED_SESSION))
            {
                while (reader.Read())
                {
                    CreateLinkParams createParams = new CreateLinkParams();

                    createParams.Id = reader.GetValue<long>(0);
                    createParams.Code = reader.GetValue<String>(1);
                    createParams.LeftRelation = (eRelation)reader.GetValue<Int32>(2);
                    createParams.RightRelation = (eRelation)reader.GetValue<Int32>(3);

                    string leftObjectCode = reader.GetValue<string>(4);
                    createParams.LeftObject = m_objectConfig[leftObjectCode];

                    string rightObjectCode = reader.GetValue<string>(5);
                    createParams.RightObject = m_objectConfig[rightObjectCode];

                    createParams.LinkTable = reader.GetValue<string>(6);
                    createParams.LeftObjectIdField = reader.GetValue<string>(7);
                    createParams.RightObjectIdField = reader.GetValue<string>(8);

                    EditLinkParams editParams = new EditLinkParams();

                    editParams.IsLeftToRightActive = reader.GetValue<bool>(9);
                    editParams.IsRightToLeftActive = reader.GetValue<bool>(10);
                    editParams.LeftToRightDescription = reader.GetValue<string>(11);
                    editParams.RightToLeftDescription = reader.GetValue<string>(12);
                    editParams.LeftCollectionName = reader.GetValue<string>(13);
                    editParams.RightCollectionName = reader.GetValue<string>(14);

                    DomainLinkConfig loadLink = new DomainLinkConfig(createParams, editParams);
                    result.Add(loadLink);
                }
                reader.Close();
            }

            return result;
        }
 private static string GetNodeTitle(DomainLinkConfig link)
 {
     return String.Format("{0}, {1} | {2}", link.LeftObject.Code, link.RightObject.Code, link.Code);
 }
        public override void SaveLink(DomainLinkConfig link, EditLinkParams editParams)
        {
            DbCommonCommand command = m_editLinkCommand.Value;

            command["ID"].Value = link.Id;
            command["IS_LEFT_TO_RIGHT_ACTIVE"].Value = editParams.IsLeftToRightActive;
            command["IS_RIGHT_TO_LEFT_ACTIVE"].Value = editParams.IsRightToLeftActive;
            command["LEFT_COLLECTION_NAME"].Value = editParams.LeftCollectionName;
            command["RIGHT_COLLECTION_NAME"].Value = editParams.RightCollectionName;
            command["LEFT_TO_RIGHT_DESCRIPTION"].Value = editParams.LeftToRightDescription;
            command["RIGHT_TO_LEFT_DESCRIPTION"].Value = editParams.RightToLeftDescription;

            command.ExecuteNonQuery(SessionIdentifier.SHARED_SESSION);
        }
Exemple #23
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (m_link == null)
                {
                    CreateLinkParams createParams = new CreateLinkParams();

                    createParams.Code = txtLinkCode.Text.Trim();

                    createParams.LeftObject = viewLeftObject.GetFocusedRow() as DomainObjectConfig;
                    createParams.RightObject = viewRightObject.GetFocusedRow() as DomainObjectConfig;

                    createParams.LeftRelation = rgLeftRelation.SelectedIndex == 0 ? eRelation.One : eRelation.Many;
                    createParams.RightRelation = rgRightRelation.SelectedIndex == 0 ? eRelation.One : eRelation.Many;

                    createParams.LeftObjectIdField = txtLeftIdField.Text.Trim();
                    createParams.RightObjectIdField = txtRightIdField.Text.Trim();

                    createParams.LinkTable = txtLinkTableName.Text.Trim();

                    m_link = m_inquiry.CreateLink(createParams);
                }

                EditLinkParams editParams = new EditLinkParams();

                editParams.IsLeftToRightActive = cbIsLeftToRight.Checked;
                editParams.IsRightToLeftActive = cbIsRightToLeft.Checked;

                editParams.LeftCollectionName = txtLeftCollectionName.Text.Trim();
                editParams.RightCollectionName = txtRightCollectionName.Text.Trim();

                editParams.LeftToRightDescription = txtLeftToRightDescription.Text.Trim();
                editParams.RightToLeftDescription = txtRightToLeftDescription.Text.Trim();

                m_inquiry.SaveLink(m_link, editParams);

                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
            }
        }
        public DomainLinkConfig CreateLink(CreateLinkParams createParams)
        {
            if (createParams == null)
                throw new ArgumentNullException("createParams");

            if (String.IsNullOrEmpty(createParams.Code))
                throw new ArgumentNullException("createParams.Code", Resources.EmptyLinkCode);

            if (!Utils.CheckEnglishString(createParams.Code))
            {
                throw new ArgumentOutOfRangeException("createParams.Code", Resources.OnlyLatinString);
            }

            if (createParams.LeftObject == null)
                throw new ArgumentNullException("createParams.LeftObject", Resources.LeftObjectNotAssigned);

            if (createParams.RightObject == null)
                throw new ArgumentNullException("createParams.RightObject", Resources.RightObjectNotAssigned);

            if (createParams.LeftRelation == eRelation.One && createParams.RightRelation == eRelation.One)
                throw new NotSupportedException();

            if (IsLinkExist(createParams))
                throw new ArgumentException("link with this params already exists");

            if (createParams.LeftRelation == eRelation.Many && createParams.RightRelation == eRelation.Many)
            {
                Connection.CreateLinkTable(createParams.LinkTable, createParams.LeftObjectIdField, createParams.RightObjectIdField);
            }
            else
            {
                if (createParams.LeftRelation == eRelation.One)
                {
                    Connection.AddTableField(createParams.RightObject.TableName, createParams.LeftObjectIdField, typeof(long));
                }
                else
                {
                    Connection.AddTableField(createParams.LeftObject.TableName, createParams.RightObjectIdField, typeof(long));
                }
            }

            long newId = Connection.NewSequence();
            createParams.Id = newId;

            m_provider.CreateLink(createParams);

            DomainLinkConfig newLink = new DomainLinkConfig(createParams);
            ALinks.Add(newLink);

            if (CreateLinkCompleted != null)
                CreateLinkCompleted(this, new LinkConfigArgs(newLink));

            IsModified = true;

            return newLink;
        }