Пример #1
0
        private Dictionary <string, object> GetDomainNameValuePair(IDomain pDomain)
        {
            Dictionary <string, object> myDic = new Dictionary <string, object>();
            ICodedValueDomain           cv    = pDomain as ICodedValueDomain;

            for (int i = 0; i < cv.CodeCount; i++)
            {
                myDic.Add(cv.GetCodeName(i), cv.GetCodeValue(i));
            }
            return(myDic);
        }
Пример #2
0
        private void SetDomainTree()
        {
            if (comboBoxDomains.SelectedIndex < 0 || fieldNamesHasDomain.Count == 0)
            {
                return;
            }

            string     fieldName    = fieldNamesHasDomain[comboBoxDomains.SelectedIndex];
            int        index        = fieldinfos.IndexOf(fieldName);
            IFieldInfo field        = fieldinfos.Get(index);
            IDomain    domainSelect = field.Domain;

            if (domainSelect == null)
            {
                return;
            }

            nodekeyMap.Clear();
            this.treeViewDomain.Nodes.Clear();
            if (domainSelect.DomainType == gviDomainType.gviDomainCodedValue)
            {
                ICodedValueDomain codedomain = domainSelect as ICodedValueDomain;
                int nCodes = codedomain.CodeCount;
                for (int c = 0; c < nCodes; c++)
                {
                    string codename  = codedomain.GetCodeName(c);
                    object codevalue = codedomain.GetCodeValue(c);
                    this.treeViewDomain.Nodes.Add(codevalue.ToString(), codename, 2, 2);
                    nodekeyMap.Add(codename, c);

                    TreeNode pNode = this.treeViewDomain.Nodes.Find(codevalue.ToString(), true)[0];
                    pNode.Checked = true;
                }

                //其它值
                {
                    this.treeViewDomain.Nodes.Add("other", "other", 2, 2);
                    nodekeyMap.Add("other", nCodes);

                    TreeNode pNode = this.treeViewDomain.Nodes.Find("other", true)[0];
                    pNode.Checked = true;
                }
            }
            else
            {
                IRangeDomain rangedomain = domainSelect as IRangeDomain;
                object       minValue    = rangedomain.MinValue;
                object       maxValue    = rangedomain.MaxValue;
            }
        }
Пример #3
0
        private void FillControls(IDataSource ds)
        {
            IDomain           domain           = null;
            IRangeDomain      rangeDomain      = null;
            ICodedValueDomain codedValueDomain = null;

            try
            {
                this.mt.Columns.Add("name", typeof(string));
                this.mt.Columns.Add("description", typeof(string));
                this.mt.Columns.Add("ft", typeof(string));
                this.mt.Columns.Add("dt", typeof(string));
                this.mt.Columns.Add("GUID", typeof(System.Guid));
                this.mt.Columns.Add("IsNew", typeof(bool));
                string[] domainNames = ds.GetDomainNames();
                if (domainNames != null)
                {
                    for (int i = 0; i < domainNames.Length; i++)
                    {
                        this.curtable = new System.Data.DataTable();
                        domain        = ds.GetDomainByName(domainNames[i].ToString());
                        if (domain != null)
                        {
                            string      text  = (domain.DomainType == gviDomainType.gviDomainRange) ? "值域型": "枚举型";
                            string      text2 = this.ConvertFieldTypeByString(domain.FieldType);
                            System.Guid guid  = System.Guid.NewGuid();
                            this.mt.Rows.Add(new object[]
                            {
                                domain.Name,
                                domain.Description,
                                text2,
                                text,
                                guid,
                                false
                            });
                            if (text == "值域型")
                            {
                                rangeDomain = (domain as IRangeDomain);
                                this.curtable.Columns.Add(this.fieldMin, this.GetColumnTypeByString(text2));
                                this.curtable.Columns.Add(this.fieldMax, this.GetColumnTypeByString(text2));
                                this.curtable.Rows.Add(new object[]
                                {
                                    rangeDomain.MinValue,
                                    rangeDomain.MaxValue
                                });
                            }
                            else
                            {
                                this.curtable    = new System.Data.DataTable();
                                codedValueDomain = (domain as ICodedValueDomain);
                                this.curtable.Columns.Add(this.fieldValue, this.GetColumnTypeByString(text2));
                                this.curtable.Columns.Add(this.fieldCode, typeof(string));
                                for (int j = 0; j < codedValueDomain.CodeCount; j++)
                                {
                                    this.curtable.Rows.Add(new object[]
                                    {
                                        codedValueDomain.GetCodeValue(j),
                                        codedValueDomain.GetCodeName(j)
                                    });
                                }
                                for (int k = 0; k < 200; k++)
                                {
                                    this.curtable.Rows.Add(new object[]
                                    {
                                        null,
                                        ""
                                    });
                                }
                            }
                            this.reftable.Add(guid, this.curtable);
                        }
                    }
                }
                for (int l = 0; l < 100; l++)
                {
                    this.mt.Rows.Add(new object[]
                    {
                        "",
                        "",
                        "",
                        "",
                        System.Guid.NewGuid(),
                        true
                    });
                }
                this.gridControl1.DataSource = this.mt;
            }
            catch (System.Exception)
            {
            }
            finally
            {
                if (codedValueDomain != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(codedValueDomain);
                    codedValueDomain = null;
                }
                if (rangeDomain != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(rangeDomain);
                    rangeDomain = null;
                }
                if (domain != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(domain);
                    domain = null;
                }
            }
        }
Пример #4
0
        private void LoadDsDomains()
        {
            IDomain           d  = null;
            IRangeDomain      rd = null;
            ICodedValueDomain cv = null;

            try
            {
                string[] domainList = ds.GetDomainNames();
                if (domainList != null)
                {
                    for (int l = 0; l < domainList.Length; l++)
                    {
                        DataTable curtable = new DataTable();
                        d = ds.GetDomainByName(domainList[l].ToString());
                        if (d == null)
                        {
                            continue;
                        }
                        string dt = d.DomainType == gviDomainType.gviDomainRange ? "值域型" : "枚举型";
                        string ft = ConvertFieldTypeByString(d.FieldType);

                        int iRowIndex = this.dgv_DomainAttr.Rows.Add(new object[] { d.Name, d.Description, ft, dt, false });
                        if (dt == "值域型")
                        {
                            rd = d as IRangeDomain;
                            curtable.Columns.Add(sMinFieldName, GetColumnTypeByString(ft));
                            curtable.Columns.Add(sMaxFieldName, GetColumnTypeByString(ft));
                            curtable.Rows.Add(new object[] { rd.MinValue, rd.MaxValue });
                        }
                        else
                        {
                            cv = d as ICodedValueDomain;
                            curtable.Columns.Add(sEmunFieldName, GetColumnTypeByString(ft));
                            curtable.Columns.Add(sDscribFieldName, typeof(string));
                            for (int k = 0; k < cv.CodeCount; k++)
                            {
                                curtable.Rows.Add(new object[] { cv.GetCodeValue(k), cv.GetCodeName(k) });
                            }
                            //添加空行
                            for (int m = 0; m < 200; m++)
                            {
                                curtable.Rows.Add(new object[] { null, "" });
                            }
                        }
                        this.dgv_DomainAttr.Rows[iRowIndex].Tag = curtable;
                    }
                }
                for (int i = 0; i < 100; i++)
                {
                    this.dgv_DomainAttr.Rows.Add(new object[] { "", "", "", "", true });
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (cv != null)
                {
                    //Marshal.ReleaseComObject(cv);
                    cv = null;
                }
                if (rd != null)
                {
                    //Marshal.ReleaseComObject(rd);
                    rd = null;
                }
                if (d != null)
                {
                    //Marshal.ReleaseComObject(d);
                    d = null;
                }
            }
        }