コード例 #1
0
        void _createItem(S_T_ISODefine isoDefine, Dictionary <string, object> parent, List <Dictionary <string, object> > result, string EngineeringInfoID)
        {
            var db = SQLHelper.CreateSqlHelper(isoDefine.ConnName);

            if (String.IsNullOrWhiteSpace(isoDefine.TableName))
            {
                return;
            }
            var sql = "select * from " + isoDefine.TableName + " where EngineeringInfoID='" + EngineeringInfoID + "'";
            var dt  = db.ExecuteDataTable(sql);

            if (String.IsNullOrEmpty(isoDefine.NameFieldInfo) && !dt.Columns.Contains("Name"))
            {
                throw new Formula.Exceptions.BusinessValidationException("【" + isoDefine.Name + "】定义配置中,数据源SQL必须定义NAME列");
            }
            parent.SetValue("FileCount", dt.Rows.Count);
            foreach (DataRow row in dt.Rows)
            {
                var formItem = FormulaHelper.DataRowToDic(row);
                formItem.SetValue("ParentID", isoDefine.ID);
                formItem.SetValue("ID", row["ID"].ToString());
                formItem.SetValue("Type", "ISOForm");
                formItem.SetValue("FormTmpCode", isoDefine.FormCode);
                formItem.SetValue("CanDelete", isoDefine.CanAddNewForm);
                var enumDefList = new List <Dictionary <string, object> >();
                if (!String.IsNullOrEmpty(isoDefine.EnumFieldInfo))
                {
                    enumDefList = JsonHelper.ToList(isoDefine.EnumFieldInfo);
                }
                string name = StringFunction.ReplaceRegString(isoDefine.NameFieldInfo, FormulaHelper.DataRowToDic(row), enumDefList);
                formItem.SetValue("Name", name);

                if (!String.IsNullOrWhiteSpace(isoDefine.LinkFormUrl))
                {
                    var url = "";
                    if (isoDefine.LinkFormUrl.IndexOf("?") >= 0)
                    {
                        url = isoDefine.LinkFormUrl + "&ID=" + row["ID"].ToString() + "";
                    }
                    else
                    {
                        url = isoDefine.LinkFormUrl + "?ID=" + row["ID"].ToString() + "";
                    }
                    url += "&FuncType=View";
                    var urlParams = url.Split('?')[1].Split('&');
                    foreach (var paramsString in urlParams)
                    {
                        if (paramsString.Split('=')[0].ToLowerInvariant() == "flowcode")
                        {
                            url = url.Replace(paramsString, "");
                        }
                    }

                    formItem.SetValue("LinkUrl", url);
                }
                result.Add(formItem);
            }
        }