public BuildBPComposition(BPColumn col)
     : base(col)
 {
     _templateCode = BPCodeTemplate.CompositionTemplate;
   
     if (this._col.IsNull && string.IsNullOrEmpty(col.RefGuid) && this._col.TypeString.ToLower() != "string")
     {
         _templateCode = _templateCode.Replace(Attributes.IsNull, "?");
     }
     else
     {
         _templateCode = _templateCode.Replace(Attributes.IsNull, "");
     }
 }
 public static BuildBPColumn Create(BPColumn col)
 {
     BuildBPColumn bc = null;
     if (col.DataType == DataTypeEnum.CommonType)
     {
         bc = new BuildBPCommon(col);
     }
     else if (col.DataType == DataTypeEnum.RefreceType)
     {
         bc = new BuildBPRefrence(col);
     }
     else if (col.DataType == DataTypeEnum.CompositionType)
     {
         bc = new BuildBPComposition(col);
     }
     return bc;
 }
        private bool DataCollect()
        {
            if (this._currentProj == null || this._currentProjNode == null) return true;
            this._currentProj.Namespace = this.tbNameSpace.Text;
            if (this._collectDataNode == null) return true;
            try
            {
                #region 实体类型
                if (this._collectDataNode.NodeType == NodeType.BEEntity)
                {
                    BEEntity prevEntity = this._currentProj.Get(this._collectDataNode.Guid) as BEEntity;
                    if (prevEntity != null)
                    {
                        if (prevEntity == null) return true;
                        prevEntity.ViewRange = (ViewRangeEnum)this.cbViewRange.SelectedIndex;
                        prevEntity.OrgFilter = this.cbOrgFilter.Checked;
                        prevEntity.Code = this.tbCode.Text;
                        prevEntity.Name = this.tbDisplayName.Text;
                        prevEntity.TableName = this.tbTableName.Text;
                        prevEntity.InhertGuid = this.tbInhertGuid.Text;
                        prevEntity.InhertName = this.tbInhertClass.Text;
                        foreach (BEEntity entity in this._currentProj.EntityList)
                        {
                            if (entity.Guid != prevEntity.Guid)
                            {
                                if (prevEntity.Code == entity.Code)
                                {
                                    MessageBox.Show("当前实体的编码不能与项目中已有的实体编码相同,实体名称:" + entity.Name, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    //return false;
                                }
                            }
                        }
                        for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
                        {
                            DataGridViewRow r = this.dataGridView1.Rows[i];
                            if (r.Cells[1].EditedFormattedValue == null || string.IsNullOrEmpty(r.Cells[1].EditedFormattedValue.ToString()))
                            {
                                continue;
                            }
                            string guid = r.Cells[0].Value == null ? string.Empty : r.Cells[0].Value.ToString();
                            BEColumn col = prevEntity.Get(guid);
                            if (col == null)
                            {
                                col = new BEColumn(r.Cells[0].Value.ToString(), this._currentProj as BEProj, prevEntity);
                                prevEntity.ColumnList.Add(col);
                            }
                            if (r.Cells[1].EditedFormattedValue == null || string.IsNullOrEmpty(r.Cells[1].EditedFormattedValue.ToString()))
                            {
                                MessageBox.Show("属性编码不能为空,行号:" + i, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                //return false;
                            }
                            col.Code = r.Cells[1].EditedFormattedValue.ToString();
                            if (r.Cells[2].EditedFormattedValue == null)
                            {
                                r.Cells[2].Value = string.Empty;
                            }
                            col.Name = r.Cells[2].EditedFormattedValue.ToString();
                            string strDataType = string.Empty;
                            if (r.Cells[3].EditedFormattedValue != null)
                            {
                                strDataType = r.Cells[3].EditedFormattedValue.ToString();
                            }
                            if (string.IsNullOrEmpty(strDataType))
                            {
                                MessageBox.Show("属性类型不能为空,属性:" + col.Name, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                // return false;
                            }
                            //基础类型
                            //引用类型
                            //聚合类型
                            if (strDataType == "基础类型")
                            {
                                col.DataType = DataTypeEnum.CommonType;
                            }
                            else if (strDataType == "引用类型")
                            {
                                col.DataType = DataTypeEnum.RefreceType;
                            }
                            else
                            {
                                col.DataType = DataTypeEnum.CompositionType;
                            }
                            if (r.Cells[4].EditedFormattedValue == null || string.IsNullOrEmpty(r.Cells[4].EditedFormattedValue.ToString()))
                            {
                                MessageBox.Show("属性类型名称不能为空,属性:" + col.Name, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                // return false;
                            }
                            col.TypeString = r.Cells[4].EditedFormattedValue.ToString();
                            col.IsNull = (bool)r.Cells[5].EditedFormattedValue;
                            col.IsViewer = (bool)r.Cells[9].EditedFormattedValue;
                            col.IsBizKey = (bool)r.Cells[10].EditedFormattedValue;

                            col.RefGuid = r.Cells[6].EditedFormattedValue.ToString();

                            if (string.IsNullOrEmpty(col.RefGuid) && col.TypeString == "string")
                            {
                                try
                                {
                                    if (string.IsNullOrEmpty(r.Cells[7].EditedFormattedValue.ToString()))
                                    {
                                        col.Length = 100;
                                    }
                                    else
                                    {
                                        col.Length = int.Parse(r.Cells[7].EditedFormattedValue.ToString());
                                    }
                                }
                                catch (Exception ex)
                                {
                                    col.Length = 100;
                                }
                            }
                            else
                            {
                                col.Length = 0;
                            }
                        }
                    }

                }
                #endregion

                #region DTO类型
                else if (this._bindDataNode.NodeType == NodeType.DTOEntity)
                {
                    DTOEntity prevEntity = this._currentProj.Get(this._collectDataNode.Guid) as DTOEntity;
                    if (prevEntity != null)
                    {
                        prevEntity.Code = this.tbCode.Text;
                        prevEntity.Name = this.tbDisplayName.Text;
                        prevEntity.InhertGuid = this.tbInhertGuid.Text;
                        prevEntity.InhertName = this.tbInhertClass.Text;
                        foreach (DTOEntity entity in this._currentProj.DTOList)
                        {
                            if (entity.Guid != prevEntity.Guid)
                            {
                                if (prevEntity.Code == entity.Code)
                                {
                                    MessageBox.Show("当前DTO的编码不能与项目中已有的DTO编码相同,DTO名称:" + entity.Name, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    //   return false;
                                }
                            }
                        }
                        for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
                        {
                            DataGridViewRow r = this.dataGridView1.Rows[i];
                            if (r.Cells[1].EditedFormattedValue == null || string.IsNullOrEmpty(r.Cells[1].EditedFormattedValue.ToString()))
                            {
                                continue;
                            }
                            string guid = r.Cells[0].Value == null ? string.Empty : r.Cells[0].Value.ToString();
                            DTOColumn col = prevEntity.Get(guid);
                            if (col == null)
                            {
                                col = new DTOColumn(r.Cells[0].Value.ToString(), this._currentProj, prevEntity);
                                prevEntity.ColumnList.Add(col);
                            }
                            if (r.Cells[1].EditedFormattedValue == null || string.IsNullOrEmpty(r.Cells[1].EditedFormattedValue.ToString()))
                            {
                                MessageBox.Show("属性编码不能为空,行号:" + i, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                //  return false;
                            }
                            col.Code = r.Cells[1].EditedFormattedValue.ToString();
                            if (r.Cells[2].EditedFormattedValue == null)
                            {
                                r.Cells[2].Value = string.Empty;
                            }
                            col.Name = r.Cells[2].EditedFormattedValue.ToString();
                            string strDataType = string.Empty;
                            if (r.Cells[3].EditedFormattedValue != null)
                            {
                                strDataType = r.Cells[3].EditedFormattedValue.ToString();
                            }
                            if (string.IsNullOrEmpty(strDataType))
                            {
                                MessageBox.Show("属性类型不能为空,属性:" + col.Name, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                //  return false;
                            }
                            //基础类型
                            //引用类型
                            //聚合类型
                            if (strDataType == "基础类型")
                            {
                                col.DataType = DataTypeEnum.CommonType;
                            }
                            else if (strDataType == "引用类型")
                            {
                                col.DataType = DataTypeEnum.RefreceType;
                            }
                            else
                            {
                                col.DataType = DataTypeEnum.CompositionType;
                            }
                            if (r.Cells[4].EditedFormattedValue == null || string.IsNullOrEmpty(r.Cells[4].EditedFormattedValue.ToString()))
                            {
                                MessageBox.Show("属性类型名称不能为空,属性:" + col.Name, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                //   return false;
                            }
                            col.TypeString = r.Cells[4].EditedFormattedValue.ToString();
                            col.IsNull = (bool)r.Cells[5].EditedFormattedValue;
                            col.IsViewer = (bool)r.Cells[9].EditedFormattedValue;
                            col.RefGuid = r.Cells[6].EditedFormattedValue.ToString();
                        }
                    }
                }
                #endregion

                #region BP类型
                else if (this._bindDataNode.NodeType == NodeType.BPEntity)
                {
                    BPEntity prevEntity = this._currentProj.Get(this._collectDataNode.Guid) as BPEntity;
                    if (prevEntity != null)
                    {
                        prevEntity.Code = this.tbCode.Text;
                        prevEntity.Name = this.tbDisplayName.Text;
                        prevEntity.ReturnGuid = this.tbInhertGuid.Text;
                        prevEntity.ReturnName = this.tbReturnType.Text;
                        prevEntity.IsList = this.cbList.Checked;
                        prevEntity.IsAuth = this.cbAuth.Checked;
                        prevEntity.Trans = this.cbTrans.SelectedIndex;
                        prevEntity.IsEntity = this.ckIsEntity.Checked;
                        foreach (BPEntity entity in this._currentProj.EntityList)
                        {
                            if (entity.Guid != prevEntity.Guid)
                            {
                                if (prevEntity.Code == entity.Code)
                                {
                                    MessageBox.Show("当前BP的编码不能与项目中已有的BP编码相同,BP名称:" + entity.Name, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    //   return false;
                                }
                            }
                        }
                        for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
                        {
                            DataGridViewRow r = this.dataGridView1.Rows[i];
                            if (r.Cells[1].EditedFormattedValue == null || string.IsNullOrEmpty(r.Cells[1].EditedFormattedValue.ToString()))
                            {
                                continue;
                            }
                            string guid = r.Cells[0].Value == null ? string.Empty : r.Cells[0].Value.ToString();
                            BPColumn col = prevEntity.Get(guid);
                            if (col == null)
                            {
                                col = new BPColumn(r.Cells[0].Value.ToString(), this._currentProj as BPProj, prevEntity);
                                prevEntity.ColumnList.Add(col);
                            }
                            if (r.Cells[1].EditedFormattedValue == null || string.IsNullOrEmpty(r.Cells[1].EditedFormattedValue.ToString()))
                            {
                                MessageBox.Show("属性编码不能为空,行号:" + i, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                //  return false;
                            }
                            col.Code = r.Cells[1].EditedFormattedValue.ToString();
                            if (r.Cells[2].EditedFormattedValue == null)
                            {
                                r.Cells[2].Value = string.Empty;
                            }
                            col.Name = r.Cells[2].EditedFormattedValue.ToString();
                            string strDataType = string.Empty;
                            if (r.Cells[3].EditedFormattedValue != null)
                            {
                                strDataType = r.Cells[3].EditedFormattedValue.ToString();
                            }
                            if (string.IsNullOrEmpty(strDataType))
                            {
                                MessageBox.Show("属性类型不能为空,属性:" + col.Name, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                //  return false;
                            }
                            //基础类型
                            //引用类型
                            //聚合类型
                            if (strDataType == "基础类型")
                            {
                                col.DataType = DataTypeEnum.CommonType;
                            }
                            else if (strDataType == "引用类型")
                            {
                                col.DataType = DataTypeEnum.RefreceType;
                            }
                            else
                            {
                                col.DataType = DataTypeEnum.CompositionType;
                            }
                            if (r.Cells[4].EditedFormattedValue == null || string.IsNullOrEmpty(r.Cells[4].EditedFormattedValue.ToString()))
                            {
                                MessageBox.Show("属性类型名称不能为空,属性:" + col.Name, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                //   return false;
                            }
                            col.TypeString = r.Cells[4].EditedFormattedValue.ToString();
                            col.IsNull = (bool)r.Cells[5].EditedFormattedValue;
                            col.RefGuid = r.Cells[6].EditedFormattedValue.ToString();
                        }
                    }

                }
                #endregion

                #region 枚举类型
                else if (this._bindDataNode.NodeType == NodeType.EnumEntity)
                {
                    EnumEntity prevEntity = this._currentProj.Get(this._collectDataNode.Guid) as EnumEntity;
                    if (prevEntity != null)
                    {
                        prevEntity.Code = this.tbCode.Text;
                        prevEntity.Name = this.tbDisplayName.Text;

                        foreach (EnumEntity entity in this._currentProj.EnumList)
                        {
                            if (entity.Guid != prevEntity.Guid)
                            {
                                if (prevEntity.Code == entity.Code)
                                {
                                    MessageBox.Show("当前Enum的编码不能与项目中已有的Enum编码相同,DTO名称:" + entity.Name, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    //   return false;
                                }
                            }
                        }
                        for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
                        {
                            DataGridViewRow r = this.dataGridView1.Rows[i];
                            if (r.Cells[1].EditedFormattedValue == null || string.IsNullOrEmpty(r.Cells[1].EditedFormattedValue.ToString()))
                            {
                                continue;
                            }
                            string guid = r.Cells[0].Value == null ? string.Empty : r.Cells[0].Value.ToString();
                            EnumColumn col = prevEntity.Get(guid);
                            if (col == null)
                            {
                                col = new EnumColumn(r.Cells[0].Value.ToString(), this._currentProj, prevEntity);
                                prevEntity.ColumnList.Add(col);
                            }
                            if (r.Cells[1].EditedFormattedValue == null || string.IsNullOrEmpty(r.Cells[1].EditedFormattedValue.ToString()))
                            {
                                MessageBox.Show("属性编码不能为空,行号:" + i, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                //  return false;
                            }
                            col.Code = r.Cells[1].EditedFormattedValue.ToString();
                            if (r.Cells[2].EditedFormattedValue == null)
                            {
                                r.Cells[2].Value = string.Empty;
                            }
                            col.Name = r.Cells[2].EditedFormattedValue.ToString();
                            col.EnumValue = int.Parse(r.Cells[8].EditedFormattedValue.ToString());
                        }
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show("录入数据有误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
            return true;
        }
 public BuildBPColumn(BPColumn col)
 {
     _col = col;
 }
 public BuildBPRefrence(BPColumn col)
     : base(col)
 {
     _templateCode = BPCodeTemplate.RefrenceTemplate;
     _templateCode = _templateCode.Replace(Attributes.IsNull, "");
 }
示例#6
0
        public override void FromXML(XmlNode node)
        { 
            this._guid = node.Attributes["Guid"].Value;
            this.Code = node.Attributes["Code"].Value;
            if (string.IsNullOrEmpty(this.Code))
            {
                this.Code = "BizBP";
            }
            this.Name = node.Attributes["Name"].Value;
            if (string.IsNullOrEmpty(this.Name))
            {
                this.Name = "未命名BP";
            }
            if (node.Attributes["FloderGuid"] != null)
            {
                this.FloderGuid = node.Attributes["FloderGuid"].Value.ToString();
            }
            else {
                this.FloderGuid = string.Empty;
            }
            if (node.Attributes["List"] != null)
            {
                this.IsList = node.Attributes["List"].Value.ToString() == "1" ? true : false;
            }
            if (node.Attributes["Auth"] != null) {
                this.IsAuth = node.Attributes["Auth"].Value.ToString() == "1" ? true : false;
            }
 
            if (node.Attributes["Trans"] != null) {
                this.Trans = Convert.ToInt32(node.Attributes["Trans"].Value);
            }
            if (node.Attributes["IsEntity"] != null)
            {
                this.IsEntity = node.Attributes["IsEntity"].Value.ToString() == "1" ? true : false;
            }
            if (node.Attributes["ReturnGuid"] != null)
            {
                this.ReturnGuid = node.Attributes["ReturnGuid"].Value;
                XmlNode entityNode = this.Proj.GetEntityNode(this.ReturnGuid);
                if (entityNode != null)
                {
                    string inhertNameSpace = entityNode.ParentNode.ParentNode.Attributes["namespace"].Value.ToString();
                    if (!string.IsNullOrEmpty(inhertNameSpace))
                    {
                        this.ReturnName = inhertNameSpace + ".";
                        this.ReturnProxyName = inhertNameSpace + "." + DTOEntity.AssemblyEndTag + ".";
                    }

                    if (entityNode.Name == "Entity")
                    {
                        this.ReturnName += entityNode.Attributes["Code"].Value.ToString();
                        this.ReturnProxyName += entityNode.Attributes["Code"].Value.ToString() + DTOEntity.AttrEndTag;
                    }
                    else
                    {
                        this.ReturnName += entityNode.Attributes["Code"].Value.ToString();
                        this.ReturnProxyName += entityNode.Attributes["Code"].Value.ToString();
                    }
                }
            }
            else if (node.Attributes["ReturnName"] != null)
            {
                this.ReturnName = node.Attributes["ReturnName"].Value.ToString();
                this.ReturnProxyName = this.ReturnName;
            }
            else
            {
                this.ReturnName = this.ReturnProxyName = "void";
            }
            //如果返回值不是实体的话则BP返回值和proxy返回值是一样的
            if (!IsEntity)
            {
                this.ReturnName = this.ReturnProxyName;
            }
            this.DataState = DataState.Update;
            this.ColumnList.Clear();
            XmlNodeList nodeList = node.SelectNodes("Attributes/Attribute");
            //查找当前工程文件下所有的实体
            foreach (XmlNode n in nodeList)
            {
                BPColumn col = new BPColumn(string.Empty, this.Proj, this);
                col.FromXML(n);
                this.ColumnList.Add(col);
            }
            this.IsChanged = false;
        }
 public BuildBPCommon(BPColumn col)
     : base(col)
 {
     _templateCode = BPCodeTemplate.CommonTemplate;
 }