Пример #1
0
        internal static T InternalGetDefaultValue <T>(string strValue, T defaultValue,
                                                      bool throwException)
        {
            Type          type      = typeof(T);
            TypeConverter converter = TypeDescriptor.GetConverter(type);

            if (throwException)
            {
                AtawDebug.AssertNotNull(converter, string.Format(ObjectUtil.SysCulture,
                                                                 "无法获取类型{0}的TypeConverter,请确认是否为其配置TypeConverterAttribute",
                                                                 type), null);
            }
            else
            {
                if (converter == null)
                {
                    return(default(T));
                }
            }
            try
            {
                return(strValue == null?InternalGetDefaultValue(defaultValue)
                           : (T)converter.ConvertFromString(strValue));
            }
            catch
            {
                return(InternalGetDefaultValue(defaultValue));
            }
        }
Пример #2
0
 private void JudgeListContainCurrentException(ListNode <T> current)
 {
     AtawDebug.AssertNotNull(fHead, "该链表为空!", this);
     //判断当前节点是否为当前链表中
     //传送LinkList<T>对象给ListNode<T>构造函数,是为了确定不同的节点对应到各自不同的类节点链表里面
     //判断当前节点是否在this链表中
     AtawDebug.Assert(current.List == this, "您插入的当前链表不匹配!", this);
 }
Пример #3
0
        public static T Convert<T>(this object objValue) where T : class
        {
            AtawDebug.AssertArgumentNull(objValue, "objValue", null);

            T result = objValue as T;
            AtawDebug.AssertNotNull(result, string.Format(ObjectUtil.SysCulture,
                "将类型{0}转换为类型{1}失败,请确认代码", objValue.GetType(), typeof(T)), objValue);
            return result;
        }
        private PageHeader ValidHeader()
        {
            PageHeader header = new PageHeader();

            header.IsValid = true;
            if (!AtawAppContext.Current.IsAuthenticated)
            {
                header.IsValid = false;
                header.Message = "未登录";
            }
            else
            {
                if (PageStyle != PageStyle.None && ModuleConfig.Right != null && ModuleConfig.Right.FunctionRights != null)
                {
                    var pageStyleRight = ModuleConfig.Right.FunctionRights.PageStyleRights.FirstOrDefault(a => a.PageStyle == PageStyle);
                    if (pageStyleRight != null)
                    {
                        var rightUnit = ModuleConfig.Right.FunctionRights.RightUnits.FirstOrDefault(a => a.Name == pageStyleRight.Name);
                        AtawDebug.AssertNotNull(rightUnit, string.Format("需要配置名为{0}的RightUnit", pageStyleRight.Name), this);
                        //if (!AtawAppContext.Current.IsAuthenticated)
                        //{
                        //    header.IsValid = false;
                        //    header.Message = "未登录";
                        //}
                        //else
                        //{
                        if (rightUnit.RightType == RightType.MvcFilter)
                        {
                            var type = RightUtil.RightVerification(rightUnit.RegName);
                            switch (type)
                            {
                            case RightFilterType.UnRenew:
                                header.IsValid = false;
                                header.Message = "未续费";
                                break;

                            case RightFilterType.DenyPermission:
                                header.IsValid = false;
                                header.Message = "没有权限";
                                break;
                            }
                        }
                        // }
                    }
                }
            }
            BasePageView.Header = header;
            return(header);
        }
Пример #5
0
        public static object GetValue(object sender, Type type, string strValue,
                                      object defaultValue)
        {
            AtawDebug.AssertArgumentNull(type, "type", sender);

            TypeConverter converter = TypeDescriptor.GetConverter(type);

            AtawDebug.AssertNotNull(converter, string.Format(ObjectUtil.SysCulture,
                                                             "无法获取类型{0}的TypeConverter,请确认是否为其配置TypeConverterAttribute",
                                                             type), sender);
            try
            {
                return(strValue == null?GetDefaultValue(type, defaultValue, converter)
                           : converter.ConvertFromString(strValue));
            }
            catch
            {
                return(GetDefaultValue(type, defaultValue, converter));
            }
        }
        /// <summary>
        /// 对ModuleConfig进行再处理,FormName不为空时则只对单个Form处理(例如,多表中对某张表进行查询)
        /// </summary>
        /// <param name="moduleConfig"></param>
        /// <returns></returns>
        private ModuleConfig AnalysisModule(ModuleConfig moduleConfig)
        {
            FormConfigs = moduleConfig.Forms.Where(a => a is FormConfig)
                          .Cast <FormConfig>()
                          .Where(a => IsSupportPage(a.SupportPage, this.PageStyle));
            MvcFormConfigs = moduleConfig.Forms.Where(a => a is MvcFormConfig) == null ? null :
                             moduleConfig.Forms.Where(a => a is MvcFormConfig).Cast <MvcFormConfig>();
            SeaFormConfigs = moduleConfig.Forms.Where(a => a is SeaFormConfig) == null ? null :
                             moduleConfig.Forms.Where(a => a is SeaFormConfig).Cast <SeaFormConfig>();

            ScriptFormConfigs = moduleConfig.Forms.Where(a => a is ScriptFormConfig) == null ? null :
                                moduleConfig.Forms.Where(a => a is ScriptFormConfig).Cast <ScriptFormConfig>();

            //if (moduleConfig.Mode == ModuleMode.MasterDetail)
            //{
            // AtawDebug.AssertArgumentNull(moduleConfig.Relations, "主从表必须配置Relation", this);
            //BasePageView.KeyValue = KeyValue;  //主从表修改时,主表主键需要传递给前台
            // }
            #region 非空属性赋值
            //Form配置中Name或TableName或Title可能没有值,此时需要赋值
            moduleConfig.Forms.ForEach(a =>
            {
                if (a is FormConfig)
                {
                    var form     = a as FormConfig;
                    var dataForm = form.File.InstanceByPage <DataFormConfig>(a.Name);

                    if (form.TableName.IsEmpty())
                    {
                        form.TableName = dataForm.TableName;
                    }
                    if (form.TableName.IsEmpty())
                    {
                        form.TableName = form.DataPlug.InstanceByPage <IListDataTable>(a.Name).RegName;
                    }
                    if (a.Name.IsEmpty())
                    {
                        a.Name = dataForm.Name;
                    }
                    if (a.Name.IsEmpty())
                    {
                        a.Name = form.TableName;
                    }
                    a.Width    = form.Width;
                    string msg = string.Format("数据源为{0}插件的form的名称不能为空", form.DataPlug);
                    AtawDebug.AssertNotNullOrEmpty(form.Name, msg, this);

                    if (a.Title.IsEmpty())
                    {
                        a.Title = dataForm.Title;
                    }
                    if (a.Title.IsEmpty())
                    {
                        a.Title = moduleConfig.Title;
                    }
                }
                if (a is MvcFormConfig)
                {
                    var mvcForm = a as MvcFormConfig;
                    AtawDebug.AssertNotNull(mvcForm.DataRoute, "MvcForm需要配置DataRoute", this);
                    var dataRoute = AtawAppContext.Current.MvcConfigXml.DataRoutes.FirstOrDefault(route => route.Name == mvcForm.DataRoute.Name);
                    if (dataRoute != null)
                    {
                        mvcForm.DataRoute.ActionName  = dataRoute.ActionName;
                        mvcForm.DataRoute.ControlName = dataRoute.ControlName;
                        mvcForm.DataRoute.AreaName    = dataRoute.AreaName;
                        mvcForm.DataRoute.NameSpace   = dataRoute.NameSpace;
                    }
                    else
                    {
                        if (mvcForm.DataRoute.ControlName.IsEmpty())
                        {
                            AtawDebug.AssertNotNullOrEmpty(mvcForm.DataRoute.ControlName, "DataRoute的ControlName不能为空", this);
                        }
                        if (mvcForm.DataRoute.ActionName.IsEmpty())
                        {
                            AtawDebug.AssertNotNullOrEmpty(mvcForm.DataRoute.ActionName, "DataRoute的ActionName不能为空", this);
                        }
                        if (mvcForm.DataRoute.AreaName.IsEmpty())
                        {
                            AtawDebug.AssertNotNullOrEmpty(mvcForm.DataRoute.AreaName, "DataRoute的AreaName不能为空", this);
                        }
                        if (mvcForm.DataRoute.NameSpace.IsEmpty())
                        {
                            AtawDebug.AssertNotNullOrEmpty(mvcForm.DataRoute.NameSpace, "DataRoute的NameSpace不能为空", this);
                        }
                    }
                }
            });
            #endregion

            #region 主从表批量修改或显示明细时,现只针对主表操作
            if (PostDataSet != null && PostDataSet.Tables.Count > 0)
            {
                DataTable dt = PostDataSet.Tables["_KEY"];
                if (dt != null)
                {
                    if (dt.Rows.Count > 1)
                    {
                        moduleConfig.Mode = ModuleMode.Single;
                    }
                    //else if (dt.Rows.Count == 1)
                    //    BasePageView.KeyValue = dt.Rows[0][0].ToString();


                    var keyValueList = new List <string>();
                    foreach (DataRow row in dt.Rows)
                    {
                        string _key = row["KeyValue"].ToString();
                        keyValueList.Add(_key);
                    }
                    BasePageView.KeyValue = String.Join <string>(",", keyValueList);
                }
            }
            #endregion

            if (FormName.IsEmpty())
            {
                if (moduleConfig.Mode == ModuleMode.Single || moduleConfig.Mode == ModuleMode.MasterDetail ||
                    moduleConfig.Mode == ModuleMode.SingleToSingle)
                {
                    var form     = FormConfigs.FirstOrDefault(a => a.IsMainTable);
                    var mainForm = form == null?FormConfigs.FirstOrDefault() : form;  //若没有配置主表,则指定第一个为主表

                    mainForm.IsMainTable = true;
                    switch (PageStyle)
                    {
                    case PageStyle.List:
                        moduleConfig.Forms.Clear();
                        mainForm.HasSearch = true;
                        moduleConfig.Forms.Add(mainForm);
                        moduleConfig.HasReview = mainForm.HasReview;
                        break;

                    case PageStyle.Insert:
                    case PageStyle.Update:
                    case PageStyle.Review:
                    case PageStyle.Detail:
                        mainForm.FormType = FormType.Normal;
                        if (moduleConfig.Mode == ModuleMode.Single)
                        {
                            moduleConfig.Forms.Clear();
                            moduleConfig.Forms.Add(mainForm);
                            moduleConfig.HasReview = mainForm.HasReview;
                        }
                        else
                        {
                            //var detailForms = FormConfigs.Where(a => !a.IsMainTable);
                            //foreach (FormConfig item in detailForms)
                            //{
                            //    item.FormType = FormType.Grid;
                            //}
                        }
                        break;
                    }
                }
            }
            else
            {
                var form = moduleConfig.Forms.Find(a => a.Name == FormName);
                AtawDebug.AssertNotNull(form, string.Format(ObjectUtil.SysCulture, "请求的formname:  {0}不存在,请检查xml文件是否有问题", FormName), this);
                //var mainForm = form == null ? moduleConfig.Forms.First() : form;//若没有配置主表,则指定第一个为主表
                //if (PageStyle == PageStyle.Insert || PageStyle == PageStyle.Detail || PageStyle == PageStyle.Update)
                //{
                //    mainForm.FormType = FormType.Normal;
                //}
                //if (moduleConfig.Mode == ModuleMode.Single)
                //{
                moduleConfig.Forms.Clear();
                moduleConfig.Forms.Add(form);
                // }
            }

            return(moduleConfig);
        }
        public virtual AtawPageConfigView Create()
        {
            //BasePageView.Title = ModuleConfig.Title;
            #region 验证
            PageHeader header = ValidHeader();
            if (!header.IsValid)
            {
                return(BasePageView);
            }
            #endregion

            #region  钮初始化



            SetDefaultButton();
            ModuleConfig.Buttons.ToList().ForEach(
                a =>
            {
                bool isData = a.IsData;
                var bt      = new CustomButtonConfigView()
                {
                    Client      = a.Client,
                    Name        = a.Name,
                    Server      = a.Server,
                    Text        = a.Text,
                    Unbatchable = a.Unbatchable,
                    BtnCss      = a.BtnCss,
                    Icon        = a.Icon
                };

                #region  钮验证
                bool IsAuthenticated = true;
                if (ModuleConfig.Right != null && ModuleConfig.Right.FunctionRights != null)
                {
                    var buttonRight = ModuleConfig.Right.FunctionRights.ButtonRights.FirstOrDefault(b => b.ButtonName == a.Name);
                    if (buttonRight != null)
                    {
                        var rightUnit = ModuleConfig.Right.FunctionRights.RightUnits.FirstOrDefault(b => b.Name == buttonRight.Name);
                        AtawDebug.AssertNotNull(rightUnit, string.Format("需要配置名为{0}的RightUnit", buttonRight.Name), this);
                        if (rightUnit.RightType == RightType.MvcFilter)
                        {
                            var type        = RightUtil.RightVerification(rightUnit.RegName);
                            IsAuthenticated = type == RightFilterType.Success;
                        }
                    }
                }
                #endregion
                if (IsAuthenticated)
                {
                    if (isData)
                    {
                        if (!BasePageView.DataButtons.Keys.Contains(a.Name))
                        {
                            BasePageView.DataButtons.Add(a.Name, bt);
                        }
                    }
                    else
                    {
                        if (!BasePageView.PageButtons.Keys.Contains(a.Name))
                        {
                            BasePageView.PageButtons.Add(a.Name, bt);
                        }
                    }
                }
            }
                );
            #endregion

            Dictionary <string, AtawFormConfigView> formViewDict = new Dictionary <string, AtawFormConfigView>();
            //创建Form
            FormConfigs.ToList().ForEach(form =>
            {
                FillDataSet(form);
                AtawBaseFormViewCreator formViewCreator = null;
                if (PageStyle != PageStyle.None)
                {
                    formViewCreator = (PageStyle.ToString() + "Form").InstanceByPage <AtawBaseFormViewCreator>(form.Name);
                }
                else
                {
                    form.Action = form.Action == PageStyle.None ? PageStyle.List : form.Action;
                    if (form.Action == PageStyle.Insert)  //ModulePage中如果Form的Action为Insert,则视为Update状态下的批量新增
                    {
                        formViewCreator = ("UpdateForm").InstanceByPage <AtawBaseFormViewCreator>(form.Name);
                    }
                    else
                    {
                        formViewCreator = (form.Action.ToString() + "Form").InstanceByPage <AtawBaseFormViewCreator>(form.Name);
                    }
                }
                formViewCreator.Initialize(ModuleConfig, form, BasePageView);
                var formViews = formViewCreator.Create();
                formViews.ToList().ForEach(view =>
                {
                    formViewDict.Add(view.Name, view);
                });
                //viewDict.Add(formView.Name, formView);
                //var info = new FormConfigInfo();
                //info.DataForm = dataForm;
                //info.FormConfig = a;
                //info.FormView = formView;
                //infoList.Add(info);
            });

            Dictionary <string, AtawMvcFormConfigView> mvcFormViewDict = new Dictionary <string, AtawMvcFormConfigView>();
            //创建MvcForm
            if (MvcFormConfigs != null)
            {
                MvcFormConfigs.Cast <MvcFormConfig>().ToList().ForEach(a =>
                {
                    AtawMvcFormConfigView mvcFormView = new AtawMvcFormConfigView();
                    mvcFormView.Title     = a.Title;
                    mvcFormView.Name      = a.Name;
                    mvcFormView.ShowType  = a.ShowType;
                    mvcFormView.ShowKind  = a.ShowKind;
                    mvcFormView.DataRoute = a.DataRoute;
                    mvcFormViewDict.Add(mvcFormView.Name, mvcFormView);
                });
            }

            Dictionary <string, AtawSeaFormConfigView> seaFormViewDict = new Dictionary <string, AtawSeaFormConfigView>();
            //创建MvcForm
            if (SeaFormConfigs != null)
            {
                SeaFormConfigs.Cast <SeaFormConfig>().ToList().ForEach(a =>
                {
                    AtawSeaFormConfigView seaFormView = new AtawSeaFormConfigView();
                    seaFormView.Title          = a.Title;
                    seaFormView.Name           = a.Name;
                    seaFormView.ShowType       = a.ShowType;
                    seaFormView.ShowKind       = a.ShowKind;
                    seaFormView.SeaInformation = a.SeaInformation;
                    seaFormViewDict.Add(seaFormView.Name, seaFormView);
                });
            }


            Dictionary <string, AtawScriptFormConfigView> scriptFormViewDict = new Dictionary <string, AtawScriptFormConfigView>();
            //创建MvcForm
            if (ScriptFormConfigs != null)
            {
                ScriptFormConfigs.Cast <ScriptFormConfig>().ToList().ForEach(a =>
                {
                    AtawScriptFormConfigView scriptFormView = new AtawScriptFormConfigView();
                    scriptFormView.Title    = a.Title;
                    scriptFormView.Name     = a.Name;
                    scriptFormView.ShowKind = a.ShowKind;
                    if (a.ScriptFunName.IsEmpty())
                    {
                        scriptFormView.ScriptFormFunName = a.Name;
                    }
                    else
                    {
                        scriptFormView.ScriptFormFunName = a.ScriptFunName;
                    }
                    scriptFormViewDict.Add(scriptFormView.Name, scriptFormView);
                });
            }



            //设置布局:当form不以tab连续布局时,则默认tile布局
            #region Layout
            BasePageView.Layout = new List <PanelList>();
            var previousKind = ShowKind.None;
            int i            = 0;
            //int count = 0;
            ModuleConfig.Forms.ForEach(a =>
            {
                PanelList panelList = null;
                if (ModuleConfig.Forms.Count > 1)
                {
                    if (i == 0)
                    {
                        if (a.ShowKind == ShowKind.Tab && ModuleConfig.Forms[i + 1].ShowKind == ShowKind.Tile)
                        {
                            a.ShowKind = ShowKind.Tile;
                        }
                    }
                    else if (i == ModuleConfig.Forms.Count - 1)
                    {
                        if (a.ShowKind == ShowKind.Tab && ModuleConfig.Forms[i - 1].ShowKind == ShowKind.Tile)
                        {
                            a.ShowKind = ShowKind.Tile;
                        }
                    }
                    else if (a.ShowKind == ShowKind.Tab && ModuleConfig.Forms[i - 1].ShowKind == ShowKind.Tile &&
                             ModuleConfig.Forms[i + 1].ShowKind == ShowKind.Tile)
                    {
                        a.ShowKind = ShowKind.Tile;
                    }
                    i++;
                }
                else
                {
                    a.ShowKind = ShowKind.Tile;
                }

                if (previousKind != a.ShowKind)
                {
                    panelList = new PanelList();

                    //panelList.VerticalTab = a.VerticalTab;
                    //if (panelList.VerticalTab)
                    //{
                    //    count++;

                    //}
                    //else if (count > 0)
                    //{
                    //    panelList.VerticalTab = false ? true : true;
                    //}
                    panelList.ShowKind  = a.ShowKind;
                    previousKind        = a.ShowKind;
                    List <Panel> panels = new List <Panel>();
                    Panel panel         = new Panel();
                    panel.FormName      = a.Name;
                    panels.Add(panel);
                    panelList.Panels = panels;
                    BasePageView.Layout.Add(panelList);
                }
                else
                {
                    Panel panel    = new Panel();
                    panel.FormName = a.Name;
                    //BasePageView.Layout[BasePageView.Layout.Count - 1].VerticalTab = a.VerticalTab;
                    //if (BasePageView.Layout[BasePageView.Layout.Count - 1].VerticalTab)
                    //{
                    //    count++;
                    //}
                    //if (count > 0)
                    //{
                    //    BasePageView.Layout[BasePageView.Layout.Count - 1].VerticalTab = false ? true : true;
                    //}

                    BasePageView.Layout[BasePageView.Layout.Count - 1].Panels.Add(panel);
                }
            });

            BasePageView.Layout.ForEach(a =>
            {
                if (a.ShowKind == ShowKind.Tab)
                {
                    var form = ModuleConfig.Forms.FirstOrDefault(b => b.VerticalTab);
                    if (form != null)
                    {
                        a.VerticalTab = true;
                    }
                }
            });
            #endregion

            //FormViews = viewDict;
            //FormInfoList = infoList;
            BasePageView.Title      = ModuleConfig.Title;
            BasePageView.PageLayout = ModuleConfig.Layout;
            BasePageView.Route      = ModuleConfig.Route;
            BasePageView.IsPart     = ModuleConfig.IsPart;

            BasePageView.BeforeHook = ModuleConfig.BeforeHook;
            BasePageView.AfterHook  = ModuleConfig.AfterHook;
            BasePageView.TsHook     = ModuleConfig.TsHook;

            //BasePageView.Forms = FormViews;
            SetReturnUrl();
            BasePageView.Forms       = formViewDict;
            BasePageView.MvcForms    = mvcFormViewDict;
            BasePageView.SeaForms    = seaFormViewDict;
            BasePageView.ScriptForms = scriptFormViewDict;
            //动态加载的js赋值
            if (ModuleConfig.Mode == ModuleMode.None)
            {
                BasePageView.Scripts = ModuleConfig.Scripts.Where(a => a.Style == Core.PageStyle.All || a.Style == Core.PageStyle.None).ToList();
            }
            else
            {
                var scripts = ModuleConfig.Scripts.Where(a => a.Style == Core.PageStyle.All || a.Style == Core.PageStyle.None || a.Style == PageStyle).ToList();
                //FirstOrDefault(a => (a.Style & PageStyle) == PageStyle);
                BasePageView.Scripts = scripts;
            }
            BasePageView.Scripts.ForEach(a =>
            {
                if (a != null && !a.Path.IsEmpty() && a.Path.IndexOf("/") != 0) //相对路径
                {
                    a.Path = string.Format("/Scripts/{0}", a);
                }
            });

            BasePageView.PageSourceData = AtawAppContext.Current.PageFlyweight.PageItems["PageSourceData"].Value <string>();

            return(BasePageView);
        }
Пример #8
0
        public void Initialization()
        {
            IsInit = true;
            SignTime("启动");
            string appGuid = Guid.NewGuid().ToString();

            StringBuilder exSb = new StringBuilder();

            LoadApplicationXml();
            SignTime("全局配置完毕...");
            // Logger = LogManager.GetLogger(typeof(AtawAppContext), ApplicationXml.HasLogger);
            FastJson  = JSON.Current;
            AtawCache = DefaultAtawCache.Current;
            //if (ApplicationXml.HasLogger)
            //{
            string fpath = Path.Combine(BinPath, AtawApplicationConfig.REAL_PATH, "AtawLogs\\log\\log.txt");

            LogManager.Configure(fpath, 1000, false);
            //  }
            // Logger.Debug("程序初始化开始: " + appGuid);
            var dconn = DBConfigXml.Databases.First(a => a.IsDefault);

            AtawDebug.AssertNotNull(dconn, "至少有一个默认的数据库连接字符串", this);
            DefaultConnString = dconn.ConnectionString;
            // MemCachedCache mcc = MemCachedCache.Current;
            SignTime("日志初始化完毕....");
            if ("EBS".AppKv <bool>(false))
            {
                //初始化 消息总线
                //AtawBus = ServiceBus.Create().Start();
            }
            SignTime("消息总线初始化完毕....");
            //载入代码插件
            //AssamblyTable at = new AssamblyTable();
            //at.Exe();
            //------------web的程序装载器
            IAppRegistration webApp = AtawIocContext.Current.FetchInstance <IAppRegistration>(ATAW_WEB_REGNAME);

            AtawDebug.AssertNotNull(webApp, "web的程序装载器 加载失败", this);
            //webApp.Initialization();
            //this.
            AppDomainTypeFinder finder = new AppDomainTypeFinder();

            finder.LoadMatchingAssemblies(Path.Combine(BinPath, "bin"));
            var assList = finder.GetAssemblies();

            assList.ForEach(
                a =>
            {
                try
                {
                    LogBuilder(System.Environment.NewLine + "开始检查程序集:" + a.FullName);
                    var types = a.GetTypes();
                    var dll   = this.dllLog(a.FullName);
                    foreach (var t in types)
                    {
                        try
                        {
                            LogBuilder(System.Environment.NewLine + "开始检查类型:" + t.FullName);
                            SetAssamblyClassType(t, dll);
                            webApp.SetAssamblyClassType(t);
                        }
                        catch (ReflectionTypeLoadException rtlex)
                        {
                            // LogBuilder();

                            string _mesg = string.Join(System.Environment.NewLine, rtlex.LoaderExceptions.Select(b => b.Message));
                            LogBuilder(t.FullName + "插件异常单个记录", _mesg);
                            //exSb.Append(System.Environment.NewLine);
                            //SysTxtBuilder.Current.NewLine();

                            //exSb.Append(rtlex.Message);
                            //SysTxtBuilder.Current.Append(rtlex.Message);

                            //exSb.Append(System.Environment.NewLine);
                            //SysTxtBuilder.Current.NewLine();
                        }
                        catch (Exception ex)
                        {
                            // if(ex.InnerException != null)


                            LogBuilder(t.FullName + "插件异常单个记录", ex.Message, ex.InnerException == null ? "" : ex.InnerException.Message);
                            //exSb.Append(System.Environment.NewLine);
                            //SysTxtBuilder.Current.NewLine();
                            dll.ClassInfoList.Add(
                                new ClassInfo()
                            {
                                Error = t.FullName + "插件异常单个记录" +
                                        ex.Message +
                                        (ex.InnerException == null ? "" : ex.InnerException.Message)
                            }
                                );
                            //exSb.Append(ex.Message);
                            //SysTxtBuilder.Current.Append(ex.Message);

                            //exSb.Append(System.Environment.NewLine);
                            //SysTxtBuilder.Current.NewLine();
                        }
                    }
                }

                catch (ReflectionTypeLoadException rtlex)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (Exception exc in rtlex.LoaderExceptions)
                    {
                        sb.AppendLine("dll载入异常记录 " + exc.Message + (exc.InnerException == null ? "" : exc.InnerException.Message));

                        // LogBuilder("dll载入异常记录", exc.Message, exc.InnerException == null ? "" : exc.InnerException.Message);
                    }

                    this.dllErrorLog(sb.ToString());
                }
                catch (Exception ex2)
                {
                    LogBuilder(a.FullName + "插件程序集异常单个记录", ex2.Message, ex2.InnerException == null ? "" : ex2.InnerException.Message);
                    //exSb.Append(System.Environment.NewLine);
                    //SysTxtBuilder.Current.NewLine();
                    this.dllErrorLog(a.FullName + "插件程序集异常单个记录 " + ex2.Message + (ex2.InnerException == null ? "" : ex2.InnerException.Message));
                    //exSb.Append(ex2.Message);
                    //SysTxtBuilder.Current.Append(ex2.Message);

                    //exSb.Append(System.Environment.NewLine);
                    //SysTxtBuilder.Current.NewLine();
                }
            }
                );
            SignTime("程序集插件注册完毕....");
            //注册享元插件
            PageFlyweight = AtawIocContext.Current.FetchInstance <IFlyweight>("PageFlyweight");
            ////把工作单元做为享元
            //PageFlyweight.Set<IUnitOfData>("PFW_UFD", CreateDbContext());
            //载入xml 插件

            //执行全局配置的宏插件
            //   this.ApplicationXml.ExeMacro();
            SignTime("执行全局配置的宏插件完毕....");

            string rightRegName = ApplicationXml.RightBuilder.RegName;

            AtawRightBuilder = new Lazy <IAtawRightBuilder>(
                () => AtawIocContext.Current.FetchInstance <IAtawRightBuilder>(rightRegName)
                );

            string groupRegName = ApplicationXml.GroupBuilder.RegName;

            GroupBuilder = new Lazy <IGroupBuilder>(
                () => AtawIocContext.Current.FetchInstance <IGroupBuilder>(groupRegName)
                );

            //注册gps
            string gpsRegName = ApplicationXml.GPSBuilder.RegName;

            GPSBuilder = new Lazy <IGPSBuilder>(
                () => AtawIocContext.Current.FetchInstance <IGPSBuilder>(gpsRegName)
                );

            //注册gpsSet
            string gpsSetRegName = ApplicationXml.GPSSetBuilder.RegName;

            GPSSetBuilder = new Lazy <IGPSSet>(
                () => AtawIocContext.Current.FetchInstance <IGPSSet>(gpsSetRegName)
                );

            //注册内部服务
            string ServiceRegName = ApplicationXml.ServiceBuilder.RegName;

            AtawServiceBuilder = new Lazy <IAtawServiceBuilder>(
                () => AtawIocContext.Current.FetchInstance <IAtawServiceBuilder>(ServiceRegName)
                );
            //注册内部信息接口
            string MessagesRegName = ApplicationXml.MessagesBuilder.RegName;

            AtawMessagesBuilder = new Lazy <IMessagesBuilder>(
                () => AtawIocContext.Current.FetchInstance <IMessagesBuilder>(MessagesRegName)
                );
            ////注册工作流模式接口
            //string WorkflowDefRegName = ApplicationXml.WorkflowDefBuilder.RegName;
            //AtawWorkflowDefBuilder = new Lazy<IWorkflowDefBuilder>(
            //    () => AtawIocContext.Current.FetchInstance<IWorkflowDefBuilder>(WorkflowDefRegName)
            //    );
            //载入  codeTable xml
            SignTime("app配置注册完毕....");
            InitAppXml();

            SignTime("固定接口注册完毕....");
            InitCodeTableXml();
            SignTime("XMl代码表注册完毕....");
            InitDataDictXml();
            SignTime("XMl数据字典注册完毕....");
            InitCustomScriptXml();


            SignTime("自定义js注册完毕....");
            //载入控制器
            //AtawIocContext.Current.FetchInstance<IAppRegistration>(AtawAppContext.ATAW_WEB_REGNAME).Initialization();
            webApp.Initialization();

            ExeAppRegistration();
            SignTime("全局插件执行完毕....");
            // Logger.Debug("程序初始化结束: " + appGuid);
            //  Logger.Debug("插件异常总结: " + exSb.ToString());
            // SysTxtBuilder.Current.Flush(LogType.Plugin);
            AtawTrace.WriteFile(LogType.Plugin, this.fLogInfo.ToJson());


            if ("CombineJs".AppKv <bool>(false))
            {
                //ICombineJs combine = "CombineJs".CodePlugIn<ICombineJs>();
                //bool CombinJsResult = combine.init(AtawAppContext.Current.BinPath);
                //if (!CombinJsResult)
                //{
                //    throw new AtawException("压缩JS出错!", this);
                //}
                //SignTime("js压缩执行完毕....");
            }
        }
Пример #9
0
 /// <summary>
 /// 判断常规异常
 /// </summary>
 /// <param>链表是空的</param>
 /// <param>索引过小</param>
 /// <param >索引过大</param>
 private void JudgeNormalException(int index)
 {
     AtawDebug.AssertNotNull(fHead, "链表是空的。", this);
     //Assert的bool值参数如果返回false则报错!
     AtawDebug.Assert(index >= 0 && index < fCount, "索引超出链表范围。", this);
 }
Пример #10
0
 void IReadXmlCallback.OnReadXml()
 {
     AtawDebug.AssertNotNull(Databases.First(a => a.IsDefault), "应该有一个默认的连接字符串", this);
 }