Exemplo n.º 1
0
        public static void createFillDataSet(this AtawPageConfigView _this, string formName)
        {
            AtawFormConfigView _form      = _this.Forms[formName];
            DataTable          dt         = _this.Data.Tables[_form.TableName];
            List <string>      tmpComluns = new List <string>();

            foreach (DataRow row in dt.Rows)
            {
                _form.Columns.ForEach(col =>
                {
                    //-----------
                    string _val = row[col.Name].ToString();
                    if (!col.Options.RegName.IsEmpty())
                    {
                        //------------
                        string _indexName = col.Name + "_CODEINDEX";
                        if (row.Table.Columns.Contains(_indexName))
                        {
                            if (row[_indexName] is int[])
                            {
                                int[] _indexs        = row[_indexName].Value <int[]>();
                                DataTable _codetable = _this.Data.Tables[col.Options.RegName];
                                List <string> _texts = new List <string>();
                                foreach (int index in _indexs)
                                {
                                    if (index >= 0)
                                    {
                                        DataRow _row = _codetable.Rows[index];

                                        string _text = _row["CODE_TEXT"].ToString();
                                        Regex reg    = new Regex(@"<[^<>]+>");
                                        // string str = "_text";
                                        // ;
                                        bool isMath = true;
                                        while (isMath)
                                        {
                                            var math = reg.Match(_text);
                                            isMath   = math.Success;
                                            if (isMath)
                                            {
                                                _text = _text.Replace(math.Value, "");
                                            }
                                        }

                                        _texts.Add(_text);
                                    }
                                }
                                //if()
                                if (row.Table.Columns[col.Name].DataType == typeof(string))
                                {
                                    row[col.Name] = _texts.JoinString(",");
                                }
                                else
                                {
                                    if (!row.Table.Columns.Contains(col.Name + "_temp"))
                                    {
                                        row.Table.Columns.Add(col.Name + "_temp", typeof(string));
                                        tmpComluns.Add(col.Name + "_temp");
                                    }
                                    row[col.Name + "_temp"] = _texts.JoinString(",");
                                }
                            }
                            else
                            {
                                int _index           = row[_indexName].Value <int>();
                                DataTable _codetable = _this.Data.Tables[col.Options.RegName];
                                DataRow _row         = _codetable.Rows[_index];
                                string _text         = _row["CODE_TEXT"].ToString();
                                //-------------
                                row[col.Name] = _text;
                            }
                        }
                    }
                });
            }

            foreach (string col in tmpComluns)
            {
                string _c   = col;
                string _col = col.Remove(col.LastIndexOf("_temp"));
                dt.Columns.Remove(_col);
                dt.Columns[_c].ColumnName = _col;
            }

            //----------
            //   return this.Data;
        }
Exemplo n.º 2
0
        public string Module(string ds, string xml, string pageStyle, string keyValue)
        {
            try
            {
                xml = Xml(xml);
                AtawDebug.AssertNotNullOrEmpty(xml, "亲 ,modulexml 注册名不可以为空的", this);
                ModuleConfig mc = xml.SingletonByPage <ModuleConfig>();
                if (mc.Mode == ModuleMode.None)
                {
                    throw new AtawException("ModuleXml的Mode节点不能为空", this);
                }

                var tool = GetPageViewTool(mc);
                tool.BeginModuleInterceptor(ref ds, ref xml, ref pageStyle, ref keyValue, ref mc);

                //if (!AtawAppContext.Current.IsAuthenticated)
                //{
                //    JsResponseResult<object> ree = new JsResponseResult<object>()
                //    {
                //        ActionType = JsActionType.Alert,
                //        Content = "请登录,匿名暂不开放...."
                //    };
                //    return FastJson(ree);
                //}
                mc = xml.SingletonByPage <ModuleConfig>();
                if (!AtawBasePageViewCreator.IsSupportPage(mc.SupportPage, pageStyle.Value <PageStyle>()))
                {
                    JsResponseResult <object> ree = new JsResponseResult <object>()
                    {
                        ActionType = JsActionType.Alert,
                        Content    = "无权访问该页面"
                    };
                    return(FastJson(ree));
                }
                bool isXml2Db = AtawAppContext.Current.ApplicationXml.IsMigration && !mc.IsNoDb;
                if (isXml2Db && mc.DataBase == null)
                {
                    mc.Forms.Cast <FormConfig>().ToList().ForEach(a =>
                    {
                        var dataForm = a.File.XmlConfig <DataFormConfig>();
                        AtawAppContext.Current.Xml2Db.Migrations(dataForm);
                    }
                                                                  );
                }

                if (isXml2Db)
                {
                    AtawTrace.WriteFile(LogType.DatabaseStructure, AtawAppContext.Current.Xml2Db.GetLogMessage());
                    var dbContext = AtawAppContext.Current.UnitOfData;
                    if (dbContext != null)
                    {
                        AtawAppContext.Current.UnitOfData.Submit();
                        AtawAppContext.Current.UnitOfData = null;
                    }
                }

                AtawBasePageViewCreator pageCreator = (pageStyle + "PageView").SingletonByPage <AtawBasePageViewCreator>();
                pageCreator.Initialize(mc, JsonConvert.DeserializeObject <DataSet>(ds ?? ""), keyValue, "", false);
                var apcv = pageCreator.Create();
                apcv.RegName = xml;


                return(tool.EndModuleInterceptor(apcv));
            }
            catch (Exception ex)
            {
                RecoredException(ex);
                AtawPageConfigView apcv = new AtawPageConfigView();
                apcv.Header         = new PageHeader();
                apcv.Header.IsValid = false;
                apcv.Header.Message = "<h2>系统出现异常,请跟管理员联系!</h2><p>异常信息是:{0}</p>".AkFormat(ex.Message);
                return(ReturnJson(apcv));
            }
            //return ReturnJson(apcv);
        }