Example #1
0
    // 读取整个表数据
    public List <object> GetTableData(TableType tableTpye)
    {
        string    tableName = TableDefine.GetTableName(tableTpye);
        TableData tableData = null;

        if (tableDataDic.TryGetValue(tableName, out tableData))
        {
            return(tableData.GetAllData());
        }

        return(null);
    }
Example #2
0
        protected override void VisitTableDefine(TableDefine tree)
        {
            _TrySetResult(tree);
            if (_result != null)
            {
                return;
            }

            foreach (var field in tree.fields)
            {
                VisitAnySyntaxTree(field);
            }
        }
Example #3
0
    public object GetTableData(TableType tableTpye, string keyID)
    {
        string tableName = TableDefine.GetTableName(tableTpye);

        TableData tableData = null;

        if (tableDataDic.TryGetValue(tableName, out tableData))
        {
            return(tableData.GetData(keyID));
        }

        return(null);
    }
Example #4
0
    private TableData GetData(string tableName, TextAsset textAsset)
    {
        TableData tableData = new TableData();

        string[] rowData = textAsset.text.Split(new string[] { "\r\n" }, StringSplitOptions.None);  // 拆分行
        if (rowData.Length < 3)
        {
            return(null);
        }

        List <PropertyInfo> propertyInfoList = GetPropertyInfoList(tableName, rowData[1]);

        for (int i = 3; i < rowData.Length; ++i)
        {
            // 实例化一个 T 类对象
            object      row     = TableDefine.GetTableType(tableName);
            System.Type t       = row.GetType();
            string[]    cloData = rowData[i].Split('`'); // 拆分行
            if (cloData.Length < propertyInfoList.Count || (cloData.Length > 0 && string.IsNullOrEmpty(cloData[0])))
            {
                continue;
            }
            PropertyInfo property;
            for (int j = 0; j < cloData.Length; ++j)
            {
                if (propertyInfoList.Count <= j)
                {
                    UnityEngine.Debug.LogError("属性列不对 " + tableName + "   列:" + j);
                    break;
                }

                property = propertyInfoList[j];
                try
                {
                    property.SetValue(row, Convert.ChangeType(cloData[j], property.PropertyType), null); // 给属性赋值
                }
                catch
                {
                }
            }

            object keyID = -1;  // 主键
            if (propertyInfoList.Count > 0)
            {
                keyID = propertyInfoList[0].GetValue(row, null);  // 获取主键ID
            }
            tableData.AddRowData(keyID, row);
        }

        return(tableData);
    }
Example #5
0
    public void SetDefine(string strDefine)
    {
        this.strDefine = strDefine;
        switch (strDefine)
        {
        case KEY:
            define = TableDefine.Key;
            break;

        case BeTranslate:
            define = TableDefine.BeTranslate;
            break;

        default:
            define = TableDefine.Normal;
            break;
        }
    }
        /// <summary>
        /// 尝试删除下游单据,返回删除结果
        /// </summary>
        /// <param name="tableNumber">下游单据表格编码</param>
        /// <param name="entityIds">下游单据体内码</param>
        /// <returns></returns>
        private IOperationResult DeleteTargetBill(
            string tableNumber, HashSet <long> entityIds)
        {
            IBusinessFlowService bfService   = ServiceHelper.GetService <IBusinessFlowService>();
            TableDefine          tableDefine = bfService.LoadTableDefine(this.Context, tableNumber);

            // 读取下游单据的元数据
            IMetaDataService metaService = ServiceHelper.GetService <IMetaDataService>();
            FormMetadata     meta        = metaService.Load(
                this.Context, tableDefine.FormId) as FormMetadata;

            // 根据下游单据体的内码,读取单据内码
            HashSet <long> billIds = this.LoadTargetBillIds(meta.BusinessInfo, tableDefine.EntityKey, entityIds);

            object[] pkValues = (from p in billIds select(object) p).ToArray();
            // 调用删除服务,删除单据
            IDeleteService   deleteService = ServiceHelper.GetService <IDeleteService>();
            IOperationResult deleteResult  = deleteService.Delete(this.Context, meta.BusinessInfo,
                                                                  pkValues, this.Option);

            return(deleteResult);
        }
        /// <summary>
        /// 分析业务流程实例,输出全部下游单据
        /// </summary>
        /// <param name="entity">上游单据体</param>
        /// <param name="entityIds">上游单据体内码</param>
        /// <param name="bfInstances">相关的业务流程实例</param>
        /// <returns>Dictioanry(下游单据表格编码, 下游单据体内码集合)</returns>
        private Dictionary <string, HashSet <long> > GetTargetEntityIds(
            Entity entity, HashSet <long> entityIds,
            BusinessFlowInstanceCollection bfInstances)
        {
            Dictionary <string, HashSet <long> > dctTargetEntityIds = new Dictionary <string, HashSet <long> >();

            IBusinessFlowService bfService      = ServiceHelper.GetService <IBusinessFlowService>();
            TableDefine          srcTableDefine = bfService.LoadTableDefine(
                this.Context, this.BusinessInfo.GetForm().Id, entity.Key);

            // 逐个实例查找本单的下游单据体内码
            foreach (var instance in bfInstances)
            {
                // 首先找到业务流程实例中,本单所在的节点
                List <RouteTreeNode> srcNodes = instance.SerarchTargetFormNodes(srcTableDefine.TableNumber);
                foreach (RouteTreeNode srcNode in srcNodes)
                {
                    if (entityIds.Contains(srcNode.Id.EId))
                    {
                        // 找到了本单所在的节点,按类别输出其下游节点:
                        foreach (RouteTreeNode targetNode in srcNode.ChildNodes)
                        {
                            if (dctTargetEntityIds.Keys.Contains(targetNode.Id.Tbl) == false)
                            {
                                dctTargetEntityIds.Add(targetNode.Id.Tbl, new HashSet <long>());
                            }
                            if (dctTargetEntityIds[targetNode.Id.Tbl].Contains(targetNode.Id.EId) == false)
                            {
                                dctTargetEntityIds[targetNode.Id.Tbl].Add(targetNode.Id.EId);
                            }
                        }
                    }
                }
            }
            return(dctTargetEntityIds);
        }
Example #8
0
    // 加载所有数据表
    public void LoadAllTable()
    {
        List <string> tableNameList = new List <string>();

        string[] tableFiles = new string[] { };

        for (int i = 0; i < (int)TableType.None; ++i)
        {
            string tableName = TableDefine.GetTableName((TableType)i);
            tableNameList.Add(tableName);
        }

        LoadCallBackHandler LoadTableCallBack = (handlerParam) =>
        {
            TextAsset textAsset = (TextAsset)handlerParam.assetObj;
            GetTableData(handlerParam.assetName, textAsset);
        };

        for (int i = 0; i < tableNameList.Count; ++i)
        {
            // 读取数据表
            AssetPool.Instance.TableData.LoadAsset <TextAsset>(tableNameList[i], LoadTableCallBack, new System.Object[] { tableNameList[i] });
        }
    }
Example #9
0
    // 获取类所有属性
    private List <PropertyInfo> GetPropertyInfoList(string tableName, string attributesRow)
    {
        // 属性名数组
        string[] attributesNameArr = attributesRow.Split('`');

        List <PropertyInfo> propertyInfoList = new List <PropertyInfo>();
        // 实例化一个 T 类对象
        object row = TableDefine.GetTableType(tableName);

        // 获取该类类型
        System.Type t = row.GetType();
        for (int i = 0; i < attributesNameArr.Length; ++i)  // 获取所有属性
        {
            PropertyInfo f_property = t.GetProperty(attributesNameArr[i]);
            if (f_property == null)
            {
                UnityEngine.Debug.LogError("*********发现一列对象与数据表'" + tableName + "'不匹配的属性:" + attributesNameArr[i]);
                continue;
            }
            propertyInfoList.Add(f_property);
        }

        return(propertyInfoList);
    }
Example #10
0
 protected abstract void VisitTableDefine(TableDefine tree);