public void CommmonTest()
        {
            //AppForm form = new AppForm();
            //var tab = new AppFormTab();
            //var section = new AppFormSection();
            //var item = new AppFormItem();
            //item.Options = new List<SelectOption>();
            //SelectOption so1 = new SelectOption();
            //so1.Value = "1";
            //so1.Text = "yes ";
            //SelectOption so2 = new SelectOption();
            //so2.Value = "0";
            //so2.Text = "no ";
            //item.Options.Add(so1);
            //item.Options.Add(so2);
            //section.Items.Add(item);
            //tab.Sections.Add(section);
            //form.Tabs.Add(tab);

            //var formXml = XmlHelper.XmlSerialize(form);
            System.Threading.Thread.Sleep(100000);

            DbAccessManager.Init("Server=wh-pc066;database=dotnet_erp302sp1_scxxw;user id=sa;password=95938");
            MapPage    page       = GetPage();
            PageResult pageresult = AppValidationManager.ValidatePage(page);

            foreach (Result result in pageresult.Results)
            {
                Debug.WriteLine(string.Format("Level: {0}, Title: {1}, Message: {2}", result.Level, result.Title, result.Message));
            }
        }
        public static List <PageResult> ValidateFiles(List <string> files)
        {
            DbAccessManager.Init(AppConfigManager.ConnectionString);

            List <PageResult> pageResults = new List <PageResult>();

            if (files != null)
            {
                int total = files.Count <string>();
                for (int i = 0; i < total; i++)
                {
                    Exception  ex;
                    PageResult pr   = null;
                    string     file = files[i];
                    Notify(string.Format("检测({0}/{1}):{2}", i + 1, total, file));

                    MapPage page = null;

                    try
                    {
                        page = GetPage(file);
                    }
                    catch (Exception exception1)
                    {
                        ex = exception1;
                        if (IsMapXml(file))
                        {
                            pr = GetPageResult("配置文件不规范", ex.Message, file);
                        }
                        else
                        {
                            pr = GetPageResult("忽略文件", "非MAP配置文件。", file, Level.Message);
                        }
                        pageResults.Add(pr);
                    }

                    if (page != null)
                    {
                        pr = new PageResult();

                        try
                        {
                            pr = ValidatePage(page);
                        }
                        catch (Exception exception2)
                        {
                            ex = exception2;
                            pr.Results.Add(new Result("验证执行出错", ex.StackTrace, Level.Warn, typeof(AppValidationManager)));
                        }

                        if (pr.Results.Count > 0)
                        {
                            pageResults.Add(pr);
                        }
                    }
                }
            }
            return(pageResults);
        }
示例#3
0
        public MainForm()
        {
            // The VS designer doesn't allow the form icon to be specified
            // from a resource, so we'll do it manually here
            this.Icon = Properties.Resources.IconApplication;

            InitializeComponent();

            DbAccessManager.Init(AppConfigManager.ConnectionString);
            context = SynchronizationContext.Current;
        }
示例#4
0
        public void Run1()
        {
            Logger msgLogger       = new Logger("平台控件使用情况.log");
            Logger exceptionLogger = new Logger("异常.log");

            StringBuilder msgBuilder = new StringBuilder();

            #region 平台有多少控件

            msgLogger.Write("\r\n== 平台有多少控件 ==================================================\r\n");

            string           format     = "平台共有{0}个控件,分别如下:";
            MapControlType[] enumValues = EnumHelper <MapControlType> .GetValues();

            msgBuilder.AppendFormat(format, enumValues.Length).AppendLine();
            var index = 1;
            foreach (var enumValue in enumValues)
            {
                msgBuilder.AppendFormat("\t{0}({1})", enumValue.ToString(),
                                        enumValue.GetAttachedData(MapControlTypeAttachData.Name));
                if (index % 4 == 0)
                {
                    msgBuilder.AppendLine();
                }
                index++;
            }
            msgBuilder.AppendLine();
            msgLogger.Write(msgBuilder.ToString());
            #endregion



            IEnumerable <FileInfo> enumerable = new DirectoryInfo(
                @"E:\MySoftCode\项目任务\ERP3.0.4平台更新03.12\Trunk - 副本\ERP\明源整体解决方案\Map")
                                                .GetFilesByExtensions(".xml");

            List <MapPage> lstmp = new List <MapPage>();

            foreach (var fileInfo in enumerable)
            {
                try {
                    lstmp.Add(MapXmlHelper.DeserializeFromFile(fileInfo.FullName, Encoding.UTF8));
                }
                catch (Exception ex) {
                    exceptionLogger.Write(string.Format("{0},异常:\r\n{1}", fileInfo.FullName, ex.Message));
                }
            }

            #region 每个页面使用了哪些控件

            msgLogger.Write("\r\n== 每个页面使用了哪些控件 ==================================================\r\n");
            msgBuilder.Length = 0;
            format            = "页面{0}使用了以下控件:";
            foreach (var mapPage in lstmp)
            {
                msgBuilder.AppendFormat(format, mapPage.PageXml).AppendLine();
                foreach (var appControl in mapPage.Controls)
                {
                    if (appControl.Control != null)
                    {
                        msgBuilder.AppendFormat("\t{0}({1})", appControl.Control.ControlType.ToString(),
                                                appControl.Control.ControlType.GetAttachedData(
                                                    MapControlTypeAttachData.Name));
                    }
                }
                msgBuilder.AppendLine().AppendLine();
            }
            msgBuilder.AppendLine();
            msgLogger.Write(msgBuilder.ToString());

            #endregion


            DbAccessManager.Init();



            #region 依控件类型查找控件在哪些页面中使用

            msgLogger.Write("\r\n== 每个控件在哪些页面中使用 ==================================================\r\n");
            msgBuilder.Length = 0;
            format            = "控件{0}({1}),在以下{2}个页面中使用";
            foreach (var enumValue in enumValues)
            {
                var mapPage = lstmp.Where(m => m.Controls.Any(n => n.Control != null && n.Control.ControlType == enumValue));
                var name    = enumValue.GetAttachedData(MapControlTypeAttachData.Name);

                msgBuilder.AppendLine(string.Format(format, enumValue.ToString(), name, mapPage.Count()));

                foreach (var page in mapPage)
                {
                    if (string.IsNullOrEmpty(page.Funcid) == true)
                    {
                        exceptionLogger.Write(string.Format("文件{0}未配置functionid", page.PageXml));
                        continue;
                    }

                    var funcIdAry = page.Funcid.Split(new string[] { ";", "," }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var s in funcIdAry)
                    {
                        MyFunction myFunction = DbAccessManager.GetPageLocation(s);
                        if (myFunction != null)
                        {
                            msgBuilder.AppendLine(myFunction.ToString());
                        }
                    }
                }

                msgBuilder.AppendLine();
            }
            msgBuilder.AppendLine();
            msgLogger.Write(msgBuilder.ToString());

            #endregion


            #region 控件组合使用情况
            msgLogger.Write("\r\n== 控件组合使用明细 ==================================================\r\n");
            msgBuilder.Length = 0;

            List <MapConntrolTypeGroup> mapConntrolTypeGroups = new List <MapConntrolTypeGroup>();

            foreach (var page in lstmp)
            {
                var result = page.Controls.Where(n => n.Control != null)
                             .Select(n => n.Control.ControlType).Distinct().ToList();

                bool exists = mapConntrolTypeGroups.Any(n => CompareToList(n.controlTypes, result) == true);
                if (exists == false)
                {
                    mapConntrolTypeGroups.Add(new MapConntrolTypeGroup()
                    {
                        controlTypes = result
                    });
                }
            }

            msgBuilder.AppendLine(string.Format("平台控件有如下{0}组合使用情况", mapConntrolTypeGroups.Count));
            foreach (var mapConntrolTypeGroup in mapConntrolTypeGroups)
            {
                msgBuilder.AppendLine(mapConntrolTypeGroup.ToString());
            }
            msgBuilder.AppendLine();
            msgLogger.Write(msgBuilder.ToString());
            #endregion

            #region 控件每种组合页面使用情况
            msgLogger.Write("\r\n== 控件每种组合页面使用情况 ==================================================\r\n");
            msgBuilder.Length = 0;

            foreach (var mapConntrolTypeGroup in mapConntrolTypeGroups)
            {
                msgBuilder.AppendLine(mapConntrolTypeGroup.ToString());
                int count = 0;
                foreach (var page in lstmp)
                {
                    var controlTypes = page.Controls.Where(n => n.Control != null)
                                       .Select(n => n.Control.ControlType).ToList();
                    if (CompareToList(mapConntrolTypeGroup.controlTypes, controlTypes) == true)
                    {
                        if (string.IsNullOrEmpty(page.Funcid) == true)
                        {
                            exceptionLogger.Write(string.Format("文件{0}未配置functionid", page.PageXml));
                            continue;
                        }
                        var funcIdAry = page.Funcid.Split(new string[] { ";", "," }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (var s in funcIdAry)
                        {
                            MyFunction myFunction = DbAccessManager.GetPageLocation(s);
                            if (myFunction != null)
                            {
                                msgBuilder.Append(myFunction.ToString()).AppendLine();
                                count++;
                            }
                        }
                        /*msgBuilder.Append("\t").Append(page.PageXml).AppendLine();*/
                    }
                }
                System.Console.WriteLine(mapConntrolTypeGroup.ToString() + " 共 " + count);

                msgBuilder.AppendLine();
            }
            msgBuilder.AppendLine();
            msgLogger.Write(msgBuilder.ToString());
            #endregion
        }