예제 #1
0
        public void AddStockInfo(U50PolicyInfo policyInfo)
        {
            m_PolicyInfoByGuid.Add(policyInfo.Guid, policyInfo);

            if (AddedPolicyInfo != null)
            {
                AddedPolicyInfo(this, EventArgs.Empty);
            }
        }
예제 #2
0
        public U50PolicyInfo GetPolicyInfoByGuid(string strPolicyGuid)
        {
            U50PolicyInfo outPolicyInfo = null;

            if (m_PolicyInfoByGuid.TryGetValue(strPolicyGuid, out outPolicyInfo) == true)
            {
                return(outPolicyInfo);
            }
            else
            {
                return(null);
            }
        }
        public static void SavePolicySetting( string strConfigFile, U50PolicyInfo[] policyInfos )
        {
            if ( policyInfos == null )
                return;

            if ( File.Exists( strConfigFile ) == true )
                File.Delete( strConfigFile );

            XElement elementRoot = new XElement( "Demo.Stock", new XAttribute( "Ver", "0.0.1.0" ) );

            for ( int iIndex = 0; iIndex < policyInfos.Length; iIndex++ )
            {
                U50PolicyInfo policyInfo = policyInfos[iIndex];

                XElement elementU50Policy = new XElement( "U50Policy", new XAttribute( "Name", policyInfo.Name ) );
                elementU50Policy.Add( new XAttribute( "Guid", policyInfo.Guid ) );
                {
                    XElement elementPolicy = new XElement( "Policy" );
                    {
                        XElement elementDateTime = new XElement( "DateTime" );
                        {
                            elementDateTime.Add( new XAttribute( "IsDateNow", policyInfo.Policy.IsDateNow ) );
                            elementDateTime.Add( new XAttribute( "KN", policyInfo.Policy.KN ) );
                            elementDateTime.Add( new XAttribute( "Date", policyInfo.Policy.DateSelect.ToShortDateString() ) );
                        }
                        elementPolicy.Add( elementDateTime );

                        XElement elementExOption = new XElement( "ExOption" );
                        {
                            elementExOption.Add( new XAttribute( "Priority", ( (int)policyInfo.Policy.Priority ).ToString() ) );
                            elementExOption.Add( new XAttribute( "Output", ( (int)policyInfo.Policy.Output ).ToString() ) );

                            XElement elementDate = new XElement( "Date" );
                            {
                                elementDate.Add( new XAttribute( "Allow", policyInfo.Policy.IsAllowDate.ToString() ) );
                                elementDate.Add( new XAttribute( "Step", policyInfo.Policy.DateStep.ToString() ) );
                                elementDate.Add( new XAttribute( "End", policyInfo.Policy.DateEnd.ToString() ) );
                            }
                            elementExOption.Add( elementDate );

                            XElement elementKN = new XElement( "KN" );
                            {
                                elementKN.Add( new XAttribute( "Allow", policyInfo.Policy.IsAllowKN.ToString() ) );
                                elementKN.Add( new XAttribute( "Step", policyInfo.Policy.KNStep.ToString() ) );
                                elementKN.Add( new XAttribute( "End", policyInfo.Policy.KNEnd.ToString() ) );
                            }
                            elementExOption.Add( elementKN );
                        }
                        elementPolicy.Add( elementExOption );
                    }
                    elementU50Policy.Add( elementPolicy );

                    XElement elementFiltrate = new XElement( "Filtrate" );
                    {
                        XElement elementPDU = new XElement( "PDU" );
                        {
                            elementPDU.Add( new XAttribute( "Enabled", policyInfo.Filtrate.PDU.Enabled.ToString() ) );
                            elementPDU.Add( new XAttribute( "Select", ( (int)policyInfo.Filtrate.PDU.Select ).ToString() ) );
                            elementPDU.Add( new XAttribute( "Big", policyInfo.Filtrate.PDU.Big.ToString() ) );
                            elementPDU.Add( new XAttribute( "Big2", policyInfo.Filtrate.PDU.Big2.ToString() ) );
                            elementPDU.Add( new XAttribute( "Small", policyInfo.Filtrate.PDU.Small.ToString() ) );
                            elementPDU.Add( new XAttribute( "Small2", policyInfo.Filtrate.PDU.Small2.ToString() ) );
                        }
                        elementFiltrate.Add( elementPDU );

                        XElement elementPCU = new XElement( "PCU" );
                        {
                            elementPCU.Add( new XAttribute( "Enabled", policyInfo.Filtrate.PCU.Enabled.ToString() ) );
                            elementPCU.Add( new XAttribute( "Select", ( (int)policyInfo.Filtrate.PCU.Select ).ToString() ) );
                            elementPCU.Add( new XAttribute( "Big", policyInfo.Filtrate.PCU.Big.ToString() ) );
                            elementPCU.Add( new XAttribute( "Big2", policyInfo.Filtrate.PCU.Big2.ToString() ) );
                            elementPCU.Add( new XAttribute( "Small", policyInfo.Filtrate.PCU.Small.ToString() ) );
                            elementPCU.Add( new XAttribute( "Small2", policyInfo.Filtrate.PCU.Small2.ToString() ) );
                        }
                        elementFiltrate.Add( elementPCU );

                        XElement elementTDU = new XElement( "TDU" );
                        {
                            elementTDU.Add( new XAttribute( "Enabled", policyInfo.Filtrate.TDU.Enabled.ToString() ) );
                            elementTDU.Add( new XAttribute( "Select", ( (int)policyInfo.Filtrate.TDU.Select ).ToString() ) );
                            elementTDU.Add( new XAttribute( "Big", policyInfo.Filtrate.TDU.Big.ToString() ) );
                            elementTDU.Add( new XAttribute( "Big2", policyInfo.Filtrate.TDU.Big2.ToString() ) );
                            elementTDU.Add( new XAttribute( "Small", policyInfo.Filtrate.TDU.Small.ToString() ) );
                            elementTDU.Add( new XAttribute( "Small2", policyInfo.Filtrate.TDU.Small2.ToString() ) );
                        }
                        elementFiltrate.Add( elementTDU );

                        XElement elementTCD = new XElement( "TCD" );
                        {
                            elementTCD.Add( new XAttribute( "Enabled", policyInfo.Filtrate.TCD.Enabled.ToString() ) );
                            elementTCD.Add( new XAttribute( "Select", ( (int)policyInfo.Filtrate.TCD.Select ).ToString() ) );
                            elementTCD.Add( new XAttribute( "Big", policyInfo.Filtrate.TCD.Big.ToString() ) );
                            elementTCD.Add( new XAttribute( "Big2", policyInfo.Filtrate.TCD.Big2.ToString() ) );
                            elementTCD.Add( new XAttribute( "Small", policyInfo.Filtrate.TCD.Small.ToString() ) );
                            elementTCD.Add( new XAttribute( "Small2", policyInfo.Filtrate.TCD.Small2.ToString() ) );
                        }
                        elementFiltrate.Add( elementTCD );

                        XElement elementTBU = new XElement( "TBU" );
                        {
                            elementTBU.Add( new XAttribute( "Enabled", policyInfo.Filtrate.TBU.Enabled.ToString() ) );
                            elementTBU.Add( new XAttribute( "Select", ( (int)policyInfo.Filtrate.TBU.Select ).ToString() ) );
                            elementTBU.Add( new XAttribute( "Big", policyInfo.Filtrate.TBU.Big.ToString() ) );
                            elementTBU.Add( new XAttribute( "Big2", policyInfo.Filtrate.TBU.Big2.ToString() ) );
                            elementTBU.Add( new XAttribute( "Small", policyInfo.Filtrate.TBU.Small.ToString() ) );
                            elementTBU.Add( new XAttribute( "Small2", policyInfo.Filtrate.TBU.Small2.ToString() ) );
                        }
                        elementFiltrate.Add( elementTBU );

                        XElement elementVacUC = new XElement( "Vac-UC" );
                        {
                            elementVacUC.Add( new XAttribute( "Enabled", policyInfo.Filtrate.VacUC.Enabled.ToString() ) );
                            elementVacUC.Add( new XAttribute( "Select", ( (int)policyInfo.Filtrate.VacUC.Select ).ToString() ) );
                            elementVacUC.Add( new XAttribute( "Big", policyInfo.Filtrate.VacUC.Big.ToString() ) );
                            elementVacUC.Add( new XAttribute( "Big2", policyInfo.Filtrate.VacUC.Big2.ToString() ) );
                            elementVacUC.Add( new XAttribute( "Small", policyInfo.Filtrate.VacUC.Small.ToString() ) );
                            elementVacUC.Add( new XAttribute( "Small2", policyInfo.Filtrate.VacUC.Small2.ToString() ) );
                        }
                        elementFiltrate.Add( elementVacUC );
                    }
                    elementU50Policy.Add( elementFiltrate );

                    XElement elementExtend = new XElement( "Extend" );
                    {
                        XElement elementInfo01 = new XElement( "Info01" );
                        {
                            elementInfo01.Add( new XAttribute( "Enabled", policyInfo.Extend.Info01.Enabled.ToString() ) );
                            elementInfo01.Add( new XAttribute( "Select", ( (int)policyInfo.Extend.Info01.Select ).ToString() ) );
                            elementInfo01.Add( new XAttribute( "HighNumber", policyInfo.Extend.Info01.HighNumber.ToString() ) );
                        }
                        elementExtend.Add( elementInfo01 );

                        XElement elementInfo02 = new XElement( "Info02" );
                        {
                            elementInfo02.Add( new XAttribute( "Enabled", policyInfo.Extend.Info02.Enabled.ToString() ) );
                            elementInfo02.Add( new XAttribute( "Select", ( (int)policyInfo.Extend.Info02.Select ).ToString() ) );
                            elementInfo02.Add( new XAttribute( "Big", policyInfo.Extend.Info02.Big.ToString() ) );
                            elementInfo02.Add( new XAttribute( "Big2", policyInfo.Extend.Info02.Big2.ToString() ) );
                            elementInfo02.Add( new XAttribute( "Small", policyInfo.Extend.Info02.Small.ToString() ) );
                            elementInfo02.Add( new XAttribute( "Small2", policyInfo.Extend.Info02.Small2.ToString() ) );
                        }
                        elementExtend.Add( elementInfo02 );

                        XElement elementInfo03 = new XElement( "Info03" );
                        {
                            elementInfo03.Add( new XAttribute( "Enabled", policyInfo.Extend.Info03.Enabled.ToString() ) );
                            elementInfo03.Add( new XAttribute( "Select", ( (int)policyInfo.Extend.Info03.Select ).ToString() ) );
                            elementInfo03.Add( new XAttribute( "Big", policyInfo.Extend.Info03.Big.ToString() ) );
                            elementInfo03.Add( new XAttribute( "Big2", policyInfo.Extend.Info03.Big2.ToString() ) );
                            elementInfo03.Add( new XAttribute( "Small", policyInfo.Extend.Info03.Small.ToString() ) );
                            elementInfo03.Add( new XAttribute( "Small2", policyInfo.Extend.Info03.Small2.ToString() ) );
                        }
                        elementExtend.Add( elementInfo03 );

                        XElement elementInfo04 = new XElement( "Info04" );
                        {
                            elementInfo04.Add( new XAttribute( "Enabled", policyInfo.Extend.Info04.Enabled.ToString() ) );
                            elementInfo04.Add( new XAttribute( "Select", ( (int)policyInfo.Extend.Info04.Select ).ToString() ) );
                        }
                        elementExtend.Add( elementInfo04 );

                        XElement elementInfo05 = new XElement( "Info05" );
                        {
                            elementInfo05.Add( new XAttribute( "Enabled", policyInfo.Extend.Info05.Enabled.ToString() ) );
                            elementInfo05.Add( new XAttribute( "Select", ( (int)policyInfo.Extend.Info05.Select ).ToString() ) );
                            elementInfo05.Add( new XAttribute( "Big", policyInfo.Extend.Info05.Big.ToString() ) );
                            elementInfo05.Add( new XAttribute( "Big2", policyInfo.Extend.Info05.Big2.ToString() ) );
                            elementInfo05.Add( new XAttribute( "Small", policyInfo.Extend.Info05.Small.ToString() ) );
                            elementInfo05.Add( new XAttribute( "Small2", policyInfo.Extend.Info05.Small2.ToString() ) );
                        }
                        elementExtend.Add( elementInfo05 );
                    }
                    elementU50Policy.Add( elementExtend );
                }
                elementRoot.Add( elementU50Policy );
            }

            XDocument documentConfig = new XDocument( new XDeclaration( "1.0", "utf - 8", "yes" ), elementRoot );
            documentConfig.Save( strConfigFile );
        }
        public static U50ReportInfo[] LoadReports( string strTaskGuid )
        {
            U50ReportInfo[] reportInfos = new U50ReportInfo[0];

            if ( File.Exists( strTaskGuid ) == false )
                SaveReport( U50GlobalSetting.TaskFilePath, reportInfos );

            XDocument documentConfig = XDocument.Load( strTaskGuid );
            if ( documentConfig == null )
                return null;

            XElement elementRoot = documentConfig.Element( (XName)"Demo.Stock" );
            if ( elementRoot == null )
                return null;

            XAttribute attributeVer = elementRoot.Attribute( (XName)"Ver" );
            if ( attributeVer == null )
                return null;

            //////////////////////////////////////////////////////////////////////////
            // <Settings>
            IEnumerable<XElement> elementU50Reports = elementRoot.Elements( (XName)"U50Report" );
            if ( elementU50Reports == null )
                return null;

            List<U50ReportInfo> reportInfoList = new List<U50ReportInfo>();
            foreach ( var elementU50Task in elementU50Reports )
            {
                XAttribute attributeGuid = elementU50Task.Attribute( (XName)"Guid" );
                if ( attributeGuid == null )
                    continue;

                XAttribute attributeScanTime = elementU50Task.Attribute( (XName)"ScanTime" );
                if ( attributeScanTime == null )
                    continue;

                XAttribute attributeScanSpan = elementU50Task.Attribute( (XName)"ScanSpan" );
                if ( attributeScanSpan == null )
                    continue;

                U50ReportInfo reportInfo = new U50ReportInfo();
                reportInfo.Guid = attributeGuid.Value;
                reportInfo.ScanTime = DateTime.Parse( attributeScanTime.Value );
                reportInfo.ScanSpan = TimeSpan.Parse( attributeScanSpan.Value );

                XElement elementTask = elementU50Task.Element( (XName)"Task" );
                if ( elementTask == null )
                    continue;
                {
                    XAttribute attributeName = elementU50Task.Attribute( (XName)"Name" );
                    if ( attributeName == null )
                        continue;

                    XAttribute attributeGuid1 = elementU50Task.Attribute( (XName)"Guid" );
                    if ( attributeGuid1 == null )
                        continue;

                    U50TaskInfo taskInfo = new U50TaskInfo();
                    taskInfo.Name = attributeName.Value;
                    taskInfo.Guid = attributeGuid1.Value;

                    // U50Task -> General
                    XElement elementGeneral = elementU50Task.Element( (XName)"General" );
                    if ( elementGeneral == null )
                        continue;
                    {
                        XAttribute attributeAutoScan = elementGeneral.Attribute( (XName)"SaneType" );
                        if ( attributeAutoScan == null )
                            continue;
                        else
                            taskInfo.General.SaneType = (U50TaskSaneType)int.Parse( attributeAutoScan.Value );
                    }

                    // U50Task -> Request
                    XElement elementRequest = elementU50Task.Element( (XName)"Request" );
                    if ( elementRequest == null )
                        continue;
                    {
                        XAttribute attributeSelectType = elementRequest.Attribute( (XName)"SelectType" );
                        if ( attributeSelectType == null )
                            continue;
                        else
                            taskInfo.Request.Select = (U50TaskSelectType)int.Parse( attributeSelectType.Value );

                        XAttribute attributePlate = elementRequest.Attribute( (XName)"Plate" );
                        if ( attributePlate == null )
                            continue;
                        else
                            taskInfo.Request.Plate = attributePlate.Value;

                        XAttribute attributeVariety = elementRequest.Attribute( (XName)"Variety" );
                        if ( attributeVariety == null )
                            continue;
                        else
                            taskInfo.Request.Variety = attributeVariety.Value;

                        // U50Task -> Request -> StockInfo
                        IEnumerable<XElement> elementStockInfo = elementRequest.Elements( (XName)"StockInfo" );
                        if ( elementStockInfo == null )
                            continue;
                        {
                            List<U50StockInfo> stockInfoList = new List<U50StockInfo>();

                            foreach ( var item in elementStockInfo )
                            {
                                U50StockInfo stockInfo = new U50StockInfo();

                                XAttribute attributePlateSub = item.Attribute( (XName)"Plate" );
                                if ( attributePlateSub == null )
                                    continue;
                                else
                                    stockInfo.Variety = attributeVariety.Value;

                                XAttribute attributeVarietySub = item.Attribute( (XName)"Variety" );
                                if ( attributeVarietySub == null )
                                    continue;
                                else
                                    stockInfo.Variety = attributeVariety.Value;

                                XAttribute attributeNameSub = item.Attribute( (XName)"Name" );
                                if ( attributeNameSub == null )
                                    continue;
                                else
                                    stockInfo.Name = attributeVariety.Value;

                                XAttribute attributeSymbolSub = item.Attribute( (XName)"Symbol" );
                                if ( attributeSymbolSub == null )
                                    continue;
                                else
                                    stockInfo.Symbol = attributeVariety.Value;

                                stockInfoList.Add( stockInfo );
                            }

                            taskInfo.Request.StockInfo = stockInfoList.ToArray();
                        }
                    }

                    // U50Task -> Policy
                    XElement elementPolicy = elementU50Task.Element( (XName)"Policy" );
                    if ( elementPolicy == null )
                        continue;
                    {
                        XAttribute attributeScanType = elementPolicy.Attribute( (XName)"ScanType" );
                        if ( attributeScanType == null )
                            continue;
                        else
                            taskInfo.Policy.ScanType = (U50ScanType)int.Parse( attributeScanType.Value );

                        // U50Task -> Policy -> PolicyGuid
                        IEnumerable<XElement> elementPolicyGuid = elementPolicy.Elements( (XName)"PolicyGuid" );
                        if ( elementRequest == null )
                            continue;
                        {
                            List<string> stockPolicyList = new List<string>();

                            foreach ( var item in elementPolicyGuid )
                            {
                                XAttribute attributeNameSub = item.Attribute( (XName)"Guid" );
                                if ( attributeNameSub == null )
                                    continue;
                                else
                                    stockPolicyList.Add( attributeNameSub.Value );
                            }

                            taskInfo.Policy.PolicyGuid = stockPolicyList.ToArray();
                        }
                    }

                    // U50Task -> Result
                    XElement elementResult = elementU50Task.Element( (XName)"Result" );
                    if ( elementResult == null )
                        continue;
                    {
                        // U50Task -> Request -> LastReportGuid
                        XAttribute attributeStockInfo = elementResult.Attribute( (XName)"LastReportGuid" );
                        if ( attributeStockInfo == null )
                            continue;
                        else
                            taskInfo.Result.LastReportGuid = attributeStockInfo.Value;
                    }

                    reportInfo.StaticTaskInfo = taskInfo;
                }

                IEnumerable<XElement> elementPolicyInfo = elementU50Task.Elements( (XName)"PolicyInfo" );
                if ( elementPolicyInfo == null )
                    continue;
                {
                    List<U50PolicyInfo> rolicyInfo = new List<U50PolicyInfo>();
                    foreach ( var item in elementPolicyInfo )
                    {
                        XAttribute attributeName = item.Attribute( (XName)"Name" );
                        if ( attributeName == null )
                            continue;

                        XAttribute attributeGuid11 = item.Attribute( (XName)"Guid" );
                        if ( attributeGuid11 == null )
                            continue;

                        U50PolicyInfo policyInfo = new U50PolicyInfo { Name = attributeName.Value, Guid = attributeGuid11.Value };

                        // U50Policy -> Policy
                        XElement elementPolicy = item.Element( (XName)"Policy" );
                        if ( elementPolicy == null )
                            continue;

                        // U50Policy -> Policy -> DateTime
                        XElement elementDateTime = elementPolicy.Element( (XName)"DateTime" );
                        if ( elementDateTime == null )
                            continue;
                        {
                            XAttribute attributeIsDateNow = elementDateTime.Attribute( (XName)"IsDateNow" );
                            if ( attributeIsDateNow == null )
                                continue;
                            else
                                policyInfo.Policy.IsDateNow = bool.Parse( attributeIsDateNow.Value );

                            XAttribute attributeKN = elementDateTime.Attribute( (XName)"KN" );
                            if ( attributeKN == null )
                                continue;
                            else
                                policyInfo.Policy.KN = uint.Parse( attributeKN.Value );

                            XAttribute attributeDate = elementDateTime.Attribute( (XName)"Date" );
                            if ( attributeDate == null )
                                continue;
                            else
                                policyInfo.Policy.DateSelect = DateTime.Parse( attributeDate.Value );
                        }

                        // U50Policy -> Policy -> ExOption
                        XElement elementExOption = elementPolicy.Element( (XName)"ExOption" );
                        if ( elementExOption == null )
                            continue;
                        {
                            XAttribute attributePriority = elementExOption.Attribute( (XName)"Priority" );
                            if ( attributePriority == null )
                                continue;
                            else
                                policyInfo.Policy.Priority = (U50PriorityType)int.Parse( attributePriority.Value );

                            XAttribute attributeOutput = elementExOption.Attribute( (XName)"Output" );
                            if ( attributeOutput == null )
                                continue;
                            else
                                policyInfo.Policy.Output = (U50OutputType)int.Parse( attributeOutput.Value );

                            // U50Policy -> Policy -> ExOption -> Date
                            XElement elementDate = elementExOption.Element( (XName)"Date" );
                            if ( elementDate == null )
                                continue;
                            {
                                XAttribute attributeDateAllow = elementDate.Attribute( (XName)"Allow" );
                                if ( attributeDateAllow == null )
                                    continue;
                                else
                                    policyInfo.Policy.IsAllowDate = bool.Parse( attributeDateAllow.Value );

                                XAttribute attributeDateStep = elementDate.Attribute( (XName)"Step" );
                                if ( attributeDateStep == null )
                                    continue;
                                else
                                    policyInfo.Policy.DateStep = uint.Parse( attributeDateStep.Value );

                                XAttribute attributeDateEnd = elementDate.Attribute( (XName)"End" );
                                if ( attributeDateEnd == null )
                                    continue;
                                else
                                    policyInfo.Policy.DateEnd = DateTime.Parse( attributeDateEnd.Value );
                            }

                            // U50Policy -> Policy -> ExOption -> KN
                            XElement elementKN = elementExOption.Element( (XName)"KN" );
                            if ( elementKN == null )
                                continue;
                            {
                                XAttribute attributeKNAllow = elementKN.Attribute( (XName)"Allow" );
                                if ( attributeKNAllow == null )
                                    continue;
                                else
                                    policyInfo.Policy.IsAllowKN = bool.Parse( attributeKNAllow.Value );

                                XAttribute attributeKNStep = elementKN.Attribute( (XName)"Step" );
                                if ( attributeKNStep == null )
                                    continue;
                                else
                                    policyInfo.Policy.KNStep = uint.Parse( attributeKNStep.Value );

                                XAttribute attributeKNEnd = elementKN.Attribute( (XName)"End" );
                                if ( attributeKNEnd == null )
                                    continue;
                                else
                                    policyInfo.Policy.KNEnd = uint.Parse( attributeKNEnd.Value );
                            }
                        }

                        // U50Policy -> Filtrate
                        XElement elementFiltrate = item.Element( (XName)"Filtrate" );
                        if ( elementFiltrate == null )
                            continue;
                        {
                            // U50Policy -> Filtrate -> PDU
                            XElement elementPDU = elementFiltrate.Element( (XName)"PDU" );
                            if ( elementPDU == null )
                                continue;
                            {
                                XAttribute attributePDUEnabled = elementPDU.Attribute( (XName)"Enabled" );
                                if ( attributePDUEnabled == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.PDU.Enabled = bool.Parse( attributePDUEnabled.Value );

                                XAttribute attributePDUSelect = elementPDU.Attribute( (XName)"Select" );
                                if ( attributePDUSelect == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.PDU.Select = (U50SelectType)int.Parse( attributePDUSelect.Value );

                                XAttribute attributePDUBig = elementPDU.Attribute( (XName)"Big" );
                                if ( attributePDUBig == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.PDU.Big = float.Parse( attributePDUBig.Value );

                                XAttribute attributePDUSmall = elementPDU.Attribute( (XName)"Small" );
                                if ( attributePDUSmall == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.PDU.Small = float.Parse( attributePDUSmall.Value );
                            }

                            // U50Policy -> Filtrate -> PCU
                            XElement elementPCU = elementFiltrate.Element( (XName)"PCU" );
                            if ( elementPCU == null )
                                continue;
                            {
                                XAttribute attributePCUEnabled = elementPCU.Attribute( (XName)"Enabled" );
                                if ( attributePCUEnabled == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.PCU.Enabled = bool.Parse( attributePCUEnabled.Value );

                                XAttribute attributePCUSelect = elementPCU.Attribute( (XName)"Select" );
                                if ( attributePCUSelect == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.PCU.Select = (U50SelectType)int.Parse( attributePCUSelect.Value );

                                XAttribute attributePCUBig = elementPCU.Attribute( (XName)"Big" );
                                if ( attributePCUBig == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.PCU.Big = float.Parse( attributePCUBig.Value );

                                XAttribute attributePCUSmall = elementPCU.Attribute( (XName)"Small" );
                                if ( attributePCUSmall == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.PCU.Small = float.Parse( attributePCUSmall.Value );
                            }

                            // U50Policy -> Filtrate -> TDU
                            XElement elementTDU = elementFiltrate.Element( (XName)"TDU" );
                            if ( elementTDU == null )
                                continue;
                            {
                                XAttribute attributeTDUEnabled = elementTDU.Attribute( (XName)"Enabled" );
                                if ( attributeTDUEnabled == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.TDU.Enabled = bool.Parse( attributeTDUEnabled.Value );

                                XAttribute attributeTDUSelect = elementTDU.Attribute( (XName)"Select" );
                                if ( attributeTDUSelect == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.TDU.Select = (U50SelectType)int.Parse( attributeTDUSelect.Value );

                                XAttribute attributeTDUBig = elementTDU.Attribute( (XName)"Big" );
                                if ( attributeTDUBig == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.TDU.Big = float.Parse( attributeTDUBig.Value );

                                XAttribute attributeTDUSmall = elementTDU.Attribute( (XName)"Small" );
                                if ( attributeTDUSmall == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.TDU.Small = float.Parse( attributeTDUSmall.Value );
                            }

                            // U50Policy -> Filtrate -> TCD
                            XElement elementTCD = elementFiltrate.Element( (XName)"TCD" );
                            if ( elementTCD == null )
                                continue;
                            {
                                XAttribute attributeTCDEnabled = elementTCD.Attribute( (XName)"Enabled" );
                                if ( attributeTCDEnabled == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.TCD.Enabled = bool.Parse( attributeTCDEnabled.Value );

                                XAttribute attributeTCDSelect = elementTCD.Attribute( (XName)"Select" );
                                if ( attributeTCDSelect == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.TCD.Select = (U50SelectType)int.Parse( attributeTCDSelect.Value );

                                XAttribute attributeTCDBig = elementTCD.Attribute( (XName)"Big" );
                                if ( attributeTCDBig == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.TCD.Big = float.Parse( attributeTCDBig.Value );

                                XAttribute attributeTCDSmall = elementTCD.Attribute( (XName)"Small" );
                                if ( attributeTCDSmall == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.TCD.Small = float.Parse( attributeTCDSmall.Value );
                            }

                            // U50Policy -> Filtrate -> TBU
                            XElement elementTBU = elementFiltrate.Element( (XName)"TBU" );
                            if ( elementTBU == null )
                                continue;
                            {
                                XAttribute attributeTCUEnabled = elementTBU.Attribute( (XName)"Enabled" );
                                if ( attributeTCUEnabled == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.TBU.Enabled = bool.Parse( attributeTCUEnabled.Value );

                                XAttribute attributeTCUSelect = elementTBU.Attribute( (XName)"Select" );
                                if ( attributeTCUSelect == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.TBU.Select = (U50SelectType)int.Parse( attributeTCUSelect.Value );

                                XAttribute attributeTCUBig = elementTBU.Attribute( (XName)"Big" );
                                if ( attributeTCUBig == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.TBU.Big = float.Parse( attributeTCUBig.Value );

                                XAttribute attributeTCUSmall = elementTBU.Attribute( (XName)"Small" );
                                if ( attributeTCUSmall == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.TBU.Small = float.Parse( attributeTCUSmall.Value );
                            }

                            // U50Policy -> Filtrate -> Vac-UC
                            XElement elementVacUC = elementFiltrate.Element( (XName)"Vac-UC" );
                            if ( elementVacUC == null )
                                continue;
                            {
                                XAttribute attributeVacUCEnabled = elementVacUC.Attribute( (XName)"Enabled" );
                                if ( attributeVacUCEnabled == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.VacUC.Enabled = bool.Parse( attributeVacUCEnabled.Value );

                                XAttribute attributeVacUCSelect = elementVacUC.Attribute( (XName)"Select" );
                                if ( attributeVacUCSelect == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.VacUC.Select = (U50SelectType)int.Parse( attributeVacUCSelect.Value );

                                XAttribute attributeVacUCBig = elementVacUC.Attribute( (XName)"Big" );
                                if ( attributeVacUCBig == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.VacUC.Big = float.Parse( attributeVacUCBig.Value );

                                XAttribute attributeVacUCSmall = elementVacUC.Attribute( (XName)"Small" );
                                if ( attributeVacUCSmall == null )
                                    continue;
                                else
                                    policyInfo.Filtrate.VacUC.Small = float.Parse( attributeVacUCSmall.Value );
                            }
                        }

                        // U50Policy -> Extend
                        XElement elementExtend = item.Element( (XName)"Extend" );
                        if ( elementExtend == null )
                            continue;
                        {
                            // U50Policy -> Extend -> Info01
                            XElement elementInfo01 = elementExtend.Element( (XName)"Info01" );
                            if ( elementInfo01 == null )
                                continue;
                            {
                                XAttribute attributeInfo01Enabled = elementInfo01.Attribute( (XName)"Enabled" );
                                if ( attributeInfo01Enabled == null )
                                    continue;
                                else
                                    policyInfo.Extend.Info01.Enabled = bool.Parse( attributeInfo01Enabled.Value );

                                XAttribute attributeInfo01Select = elementInfo01.Attribute( (XName)"Select" );
                                if ( attributeInfo01Select == null )
                                    continue;
                                else
                                    policyInfo.Extend.Info01.Select = (U50ExtendInfo01Type)int.Parse( attributeInfo01Select.Value );

                                XAttribute attributeInfo01Big = elementInfo01.Attribute( (XName)"HighNumber" );
                                if ( attributeInfo01Big == null )
                                    continue;
                                else
                                    policyInfo.Extend.Info01.HighNumber = int.Parse( attributeInfo01Big.Value );
                            }

                            // U50Policy -> Extend -> Info02
                            XElement elementInfo02 = elementExtend.Element( (XName)"Info02" );
                            if ( elementInfo02 == null )
                                continue;
                            {
                                XAttribute attributeInfo02Enabled = elementInfo02.Attribute( (XName)"Enabled" );
                                if ( attributeInfo02Enabled == null )
                                    continue;
                                else
                                    policyInfo.Extend.Info02.Enabled = bool.Parse( attributeInfo02Enabled.Value );

                                XAttribute attributeInfo02Select = elementInfo02.Attribute( (XName)"Select" );
                                if ( attributeInfo02Select == null )
                                    continue;
                                else
                                    policyInfo.Extend.Info02.Select = (U50SelectType)int.Parse( attributeInfo02Select.Value );

                                XAttribute attributeInfo02Big = elementInfo02.Attribute( (XName)"Big" );
                                if ( attributeInfo02Big == null )
                                    continue;
                                else
                                    policyInfo.Extend.Info02.Big = long.Parse( attributeInfo02Big.Value );

                                XAttribute attributeInfo02Small = elementInfo02.Attribute( (XName)"Small" );
                                if ( attributeInfo02Small == null )
                                    continue;
                                else
                                    policyInfo.Extend.Info02.Small = long.Parse( attributeInfo02Small.Value );
                            }

                            // U50Policy -> Extend -> Info03
                            XElement elementInfo03 = elementExtend.Element( (XName)"Info03" );
                            if ( elementInfo03 == null )
                                continue;
                            {
                                XAttribute attributeInfo03Enabled = elementInfo03.Attribute( (XName)"Enabled" );
                                if ( attributeInfo03Enabled == null )
                                    continue;
                                else
                                    policyInfo.Extend.Info03.Enabled = bool.Parse( attributeInfo03Enabled.Value );

                                XAttribute attributeInfo03Select = elementInfo03.Attribute( (XName)"Select" );
                                if ( attributeInfo03Select == null )
                                    continue;
                                else
                                    policyInfo.Extend.Info03.Select = (U50SelectType)int.Parse( attributeInfo03Select.Value );

                                XAttribute attributeInfo03Big = elementInfo03.Attribute( (XName)"Big" );
                                if ( attributeInfo03Big == null )
                                    continue;
                                else
                                    policyInfo.Extend.Info03.Big = int.Parse( attributeInfo03Big.Value );

                                XAttribute attributeInfo03Small = elementInfo03.Attribute( (XName)"Small" );
                                if ( attributeInfo03Small == null )
                                    continue;
                                else
                                    policyInfo.Extend.Info03.Small = int.Parse( attributeInfo03Small.Value );
                            }

                            // U50Policy -> Extend -> Info04
                            XElement elementInfo04 = elementExtend.Element( (XName)"Info04" );
                            if ( elementInfo04 == null )
                                continue;
                            {
                                XAttribute attributeInfo04Enabled = elementInfo04.Attribute( (XName)"Enabled" );
                                if ( attributeInfo04Enabled == null )
                                    continue;
                                else
                                    policyInfo.Extend.Info04.Enabled = bool.Parse( attributeInfo04Enabled.Value );

                                XAttribute attributeInfo04Select = elementInfo04.Attribute( (XName)"Select" );
                                if ( attributeInfo04Select == null )
                                    continue;
                                else
                                    policyInfo.Extend.Info04.Select = (U50ExtendInfo04Type)int.Parse( attributeInfo04Select.Value );
                            }

                            // U50Policy -> Extend -> Info05
                            XElement elementInfo05 = elementExtend.Element( (XName)"Info05" );
                            if ( elementInfo05 == null )
                                continue;
                            {
                                XAttribute attributeInfo05Enabled = elementInfo05.Attribute( (XName)"Enabled" );
                                if ( attributeInfo05Enabled == null )
                                    continue;
                                else
                                    policyInfo.Extend.Info05.Enabled = bool.Parse( attributeInfo05Enabled.Value );

                                XAttribute attributeInfo05Select = elementInfo05.Attribute( (XName)"Select" );
                                if ( attributeInfo05Select == null )
                                    continue;
                                else
                                    policyInfo.Extend.Info05.Select = (U50SelectType)int.Parse( attributeInfo05Select.Value );

                                XAttribute attributeInfo05Big = elementInfo05.Attribute( (XName)"Big" );
                                if ( attributeInfo05Big == null )
                                    continue;
                                else
                                    policyInfo.Extend.Info05.Big = int.Parse( attributeInfo05Big.Value );

                                XAttribute attributeInfo05Small = elementInfo05.Attribute( (XName)"Small" );
                                if ( attributeInfo05Small == null )
                                    continue;
                                else
                                    policyInfo.Extend.Info05.Small = int.Parse( attributeInfo05Small.Value );
                            }
                        }

                        rolicyInfo.Add( policyInfo );
                    }

                    reportInfo.StaticReportInfo = rolicyInfo.ToArray();
                }

                IEnumerable<XElement> elementReportInfo = elementU50Task.Elements( (XName)"ReportInfo" );
                if ( elementReportInfo == null )
                    continue;
                {
                    List<U50Report> reportList = new List<U50Report>();
                    foreach ( var item in elementReportInfo )
                    {
                        U50Report report = new U50Report();

                        XAttribute attributeName = item.Attribute( (XName)"Name" );
                        if ( attributeName == null )
                            continue;
                        else
                            report.Name = attributeName.Value;

                        XAttribute attributeSymbol = item.Attribute( (XName)"Symbol" );
                        if ( attributeSymbol == null )
                            continue;
                        else
                            report.Symbol = attributeSymbol.Value;

                        //XAttribute attributeS_Date = item.Attribute( (XName)"S_Date" );
                        //if ( attributeS_Date == null )
                        //    continue;
                        //else
                        //    report.S_Date = DateTime.Parse( attributeS_Date.Value );

                        //XAttribute attributeVa_U50 = item.Attribute( (XName)"Va_U50" );
                        //if ( attributeVa_U50 == null )
                        //    continue;
                        //else
                        //    report.Va_U50 = int.Parse( attributeVa_U50.Value );

                        //XAttribute attributeVsc = item.Attribute( (XName)"Vsc" );
                        //if ( attributeVsc == null )
                        //    continue;
                        //else
                        //    report.Vsc = int.Parse( attributeVsc.Value );

                        //XAttribute attributeClose = item.Attribute( (XName)"Close" );
                        //if ( attributeClose == null )
                        //    continue;
                        //else
                        //    report.Close = int.Parse( attributeClose.Value );

                        //XAttribute attributeScanner = item.Attribute( (XName)"Scanner" );
                        //if ( attributeScanner == null )
                        //    continue;
                        //else
                        //    report.Scanner = attributeScanner.Value;

                        //XAttribute attributeQ_U50 = item.Attribute( (XName)"Q_U50" );
                        //if ( attributeQ_U50 == null )
                        //    continue;
                        //else
                        //    report.Q_U50 = int.Parse( attributeQ_U50.Value );

                        //XAttribute attributeKLineNumber = item.Attribute( (XName)"KLineNumber" );
                        //if ( attributeKLineNumber == null )
                        //    continue;
                        //else
                        //    report.KLineNumber = int.Parse( attributeKLineNumber.Value );

                        XAttribute attributeScanTime1 = item.Attribute( (XName)"ScanTime" );
                        if ( attributeScanTime1 == null )
                            continue;
                        else
                            report.ScanTime = DateTime.Parse( attributeScanTime1.Value );

                        XAttribute attributeScanSpan1 = item.Attribute( (XName)"ScanSpan" );
                        if ( attributeScanSpan1 == null )
                            continue;
                        else
                            report.ScanSpan = TimeSpan.Parse( attributeScanSpan1.Value );

                        reportList.Add( report );
                    }

                    reportInfo.ReportArray = reportList.ToArray();
                }

                reportInfoList.Add( reportInfo );
            }

            return reportInfos;
        }
        public static U50PolicyInfo[] LoadPolicySetting( string strConfigFile )
        {
            if ( File.Exists( strConfigFile ) == false )
            {
                if ( U50GlobalSetting.PolicyFilePath == strConfigFile ) // 创建一个新的文件
                    SavePolicySetting( U50GlobalSetting.PolicyFilePath, U50GlobalSetting.PolicyInfos );
                else
                    return null;
            }

            XDocument documentConfig = XDocument.Load( strConfigFile );
            if ( documentConfig == null )
                return null;

            XElement elementRoot = documentConfig.Element( (XName)"Demo.Stock" );
            if ( elementRoot == null )
                return null;

            XAttribute attributeVer = elementRoot.Attribute( (XName)"Ver" );
            if ( attributeVer == null )
                return null;

            //////////////////////////////////////////////////////////////////////////
            // <Settings>
            IEnumerable<XElement> elementU50Policys = elementRoot.Elements( (XName)"U50Policy" );
            if ( elementU50Policys == null )
                return null;

            List<U50PolicyInfo> policyInfoList = new List<U50PolicyInfo>();
            foreach ( var u50Policy in elementU50Policys )
            {
                XAttribute attributeName = u50Policy.Attribute( (XName)"Name" );
                if ( attributeName == null )
                    continue;

                XAttribute attributeGuid = u50Policy.Attribute( (XName)"Guid" );
                if ( attributeGuid == null )
                    continue;

                U50PolicyInfo policyInfo = new U50PolicyInfo { Name = attributeName.Value, Guid = attributeGuid.Value };

                // U50Policy -> Policy
                XElement elementPolicy = u50Policy.Element( (XName)"Policy" );
                if ( elementPolicy == null )
                    continue;

                // U50Policy -> Policy -> DateTime
                XElement elementDateTime = elementPolicy.Element( (XName)"DateTime" );
                if ( elementDateTime == null )
                    continue;
                {
                    XAttribute attributeIsDateNow = elementDateTime.Attribute( (XName)"IsDateNow" );
                    if ( attributeIsDateNow == null )
                        continue;
                    else
                        policyInfo.Policy.IsDateNow = bool.Parse( attributeIsDateNow.Value );

                    XAttribute attributeKN = elementDateTime.Attribute( (XName)"KN" );
                    if ( attributeKN == null )
                        continue;
                    else
                        policyInfo.Policy.KN = uint.Parse( attributeKN.Value );

                    XAttribute attributeDate = elementDateTime.Attribute( (XName)"Date" );
                    if ( attributeDate == null )
                        continue;
                    else
                        policyInfo.Policy.DateSelect = DateTime.Parse( attributeDate.Value );
                }

                // U50Policy -> Policy -> ExOption
                XElement elementExOption = elementPolicy.Element( (XName)"ExOption" );
                if ( elementExOption == null )
                    continue;
                {
                    XAttribute attributePriority = elementExOption.Attribute( (XName)"Priority" );
                    if ( attributePriority == null )
                        continue;
                    else
                        policyInfo.Policy.Priority = (U50PriorityType)int.Parse( attributePriority.Value );

                    XAttribute attributeOutput = elementExOption.Attribute( (XName)"Output" );
                    if ( attributeOutput == null )
                        continue;
                    else
                        policyInfo.Policy.Output = (U50OutputType)int.Parse( attributeOutput.Value );

                    // U50Policy -> Policy -> ExOption -> Date
                    XElement elementDate = elementExOption.Element( (XName)"Date" );
                    if ( elementDate == null )
                        continue;
                    {
                        XAttribute attributeDateAllow = elementDate.Attribute( (XName)"Allow" );
                        if ( attributeDateAllow == null )
                            continue;
                        else
                            policyInfo.Policy.IsAllowDate = bool.Parse( attributeDateAllow.Value );

                        XAttribute attributeDateStep = elementDate.Attribute( (XName)"Step" );
                        if ( attributeDateStep == null )
                            continue;
                        else
                            policyInfo.Policy.DateStep = uint.Parse( attributeDateStep.Value );

                        XAttribute attributeDateEnd = elementDate.Attribute( (XName)"End" );
                        if ( attributeDateEnd == null )
                            continue;
                        else
                            policyInfo.Policy.DateEnd = DateTime.Parse( attributeDateEnd.Value );
                    }

                    // U50Policy -> Policy -> ExOption -> KN
                    XElement elementKN = elementExOption.Element( (XName)"KN" );
                    if ( elementKN == null )
                        continue;
                    {
                        XAttribute attributeKNAllow = elementKN.Attribute( (XName)"Allow" );
                        if ( attributeKNAllow == null )
                            continue;
                        else
                            policyInfo.Policy.IsAllowKN = bool.Parse( attributeKNAllow.Value );

                        XAttribute attributeKNStep = elementKN.Attribute( (XName)"Step" );
                        if ( attributeKNStep == null )
                            continue;
                        else
                            policyInfo.Policy.KNStep = uint.Parse( attributeKNStep.Value );

                        XAttribute attributeKNEnd = elementKN.Attribute( (XName)"End" );
                        if ( attributeKNEnd == null )
                            continue;
                        else
                            policyInfo.Policy.KNEnd = uint.Parse( attributeKNEnd.Value );
                    }
                }

                // U50Policy -> Filtrate
                XElement elementFiltrate = u50Policy.Element( (XName)"Filtrate" );
                if ( elementFiltrate == null )
                    continue;
                {
                    // U50Policy -> Filtrate -> PDU
                    XElement elementPDU = elementFiltrate.Element( (XName)"PDU" );
                    if ( elementPDU == null )
                        continue;
                    {
                        XAttribute attributePDUEnabled = elementPDU.Attribute( (XName)"Enabled" );
                        if ( attributePDUEnabled == null )
                            continue;
                        else
                            policyInfo.Filtrate.PDU.Enabled = bool.Parse( attributePDUEnabled.Value );

                        XAttribute attributePDUSelect = elementPDU.Attribute( (XName)"Select" );
                        if ( attributePDUSelect == null )
                            continue;
                        else
                            policyInfo.Filtrate.PDU.Select = (U50SelectType)int.Parse( attributePDUSelect.Value );

                        XAttribute attributePDUBig = elementPDU.Attribute( (XName)"Big" );
                        if ( attributePDUBig == null )
                            continue;
                        else
                            policyInfo.Filtrate.PDU.Big = float.Parse( attributePDUBig.Value );

                        XAttribute attributePDUBig2 = elementPDU.Attribute( (XName)"Big2" );
                        if ( attributePDUBig2 == null )
                            continue;
                        else
                            policyInfo.Filtrate.PDU.Big2 = float.Parse( attributePDUBig2.Value );

                        XAttribute attributePDUSmall = elementPDU.Attribute( (XName)"Small" );
                        if ( attributePDUSmall == null )
                            continue;
                        else
                            policyInfo.Filtrate.PDU.Small = float.Parse( attributePDUSmall.Value );

                        XAttribute attributePDUSmall2 = elementPDU.Attribute( (XName)"Small2" );
                        if ( attributePDUSmall2 == null )
                            continue;
                        else
                            policyInfo.Filtrate.PDU.Small2 = float.Parse( attributePDUSmall2.Value );
                    }

                    // U50Policy -> Filtrate -> PCU
                    XElement elementPCU = elementFiltrate.Element( (XName)"PCU" );
                    if ( elementPCU == null )
                        continue;
                    {
                        XAttribute attributePCUEnabled = elementPCU.Attribute( (XName)"Enabled" );
                        if ( attributePCUEnabled == null )
                            continue;
                        else
                            policyInfo.Filtrate.PCU.Enabled = bool.Parse( attributePCUEnabled.Value );

                        XAttribute attributePCUSelect = elementPCU.Attribute( (XName)"Select" );
                        if ( attributePCUSelect == null )
                            continue;
                        else
                            policyInfo.Filtrate.PCU.Select = (U50SelectType)int.Parse( attributePCUSelect.Value );

                        XAttribute attributePCUBig = elementPCU.Attribute( (XName)"Big" );
                        if ( attributePCUBig == null )
                            continue;
                        else
                            policyInfo.Filtrate.PCU.Big = float.Parse( attributePCUBig.Value );

                        XAttribute attributePCUBig2 = elementPCU.Attribute( (XName)"Big2" );
                        if ( attributePCUBig2 == null )
                            continue;
                        else
                            policyInfo.Filtrate.PCU.Big2 = float.Parse( attributePCUBig2.Value );

                        XAttribute attributePCUSmall = elementPCU.Attribute( (XName)"Small" );
                        if ( attributePCUSmall == null )
                            continue;
                        else
                            policyInfo.Filtrate.PCU.Small = float.Parse( attributePCUSmall.Value );

                        XAttribute attributePCUSmall2 = elementPCU.Attribute( (XName)"Small2" );
                        if ( attributePCUSmall2 == null )
                            continue;
                        else
                            policyInfo.Filtrate.PCU.Small2 = float.Parse( attributePCUSmall2.Value );
                    }

                    // U50Policy -> Filtrate -> TDU
                    XElement elementTDU = elementFiltrate.Element( (XName)"TDU" );
                    if ( elementTDU == null )
                        continue;
                    {
                        XAttribute attributeTDUEnabled = elementTDU.Attribute( (XName)"Enabled" );
                        if ( attributeTDUEnabled == null )
                            continue;
                        else
                            policyInfo.Filtrate.TDU.Enabled = bool.Parse( attributeTDUEnabled.Value );

                        XAttribute attributeTDUSelect = elementTDU.Attribute( (XName)"Select" );
                        if ( attributeTDUSelect == null )
                            continue;
                        else
                            policyInfo.Filtrate.TDU.Select = (U50SelectType)int.Parse( attributeTDUSelect.Value );

                        XAttribute attributeTDUBig = elementTDU.Attribute( (XName)"Big" );
                        if ( attributeTDUBig == null )
                            continue;
                        else
                            policyInfo.Filtrate.TDU.Big = float.Parse( attributeTDUBig.Value );

                        XAttribute attributeTDUBig2 = elementTDU.Attribute( (XName)"Big2" );
                        if ( attributeTDUBig2 == null )
                            continue;
                        else
                            policyInfo.Filtrate.TDU.Big2 = float.Parse( attributeTDUBig2.Value );

                        XAttribute attributeTDUSmall = elementTDU.Attribute( (XName)"Small" );
                        if ( attributeTDUSmall == null )
                            continue;
                        else
                            policyInfo.Filtrate.TDU.Small = float.Parse( attributeTDUSmall.Value );

                        XAttribute attributeTDUSmall2 = elementTDU.Attribute( (XName)"Small2" );
                        if ( attributeTDUSmall2 == null )
                            continue;
                        else
                            policyInfo.Filtrate.TDU.Small2 = float.Parse( attributeTDUSmall2.Value );
                    }

                    // U50Policy -> Filtrate -> TCD
                    XElement elementTCD = elementFiltrate.Element( (XName)"TCD" );
                    if ( elementTCD == null )
                        continue;
                    {
                        XAttribute attributeTCDEnabled = elementTCD.Attribute( (XName)"Enabled" );
                        if ( attributeTCDEnabled == null )
                            continue;
                        else
                            policyInfo.Filtrate.TCD.Enabled = bool.Parse( attributeTCDEnabled.Value );

                        XAttribute attributeTCDSelect = elementTCD.Attribute( (XName)"Select" );
                        if ( attributeTCDSelect == null )
                            continue;
                        else
                            policyInfo.Filtrate.TCD.Select = (U50SelectType)int.Parse( attributeTCDSelect.Value );

                        XAttribute attributeTCDBig = elementTCD.Attribute( (XName)"Big" );
                        if ( attributeTCDBig == null )
                            continue;
                        else
                            policyInfo.Filtrate.TCD.Big = float.Parse( attributeTCDBig.Value );

                        XAttribute attributeTCDBig2 = elementTCD.Attribute( (XName)"Big2" );
                        if ( attributeTCDBig2 == null )
                            continue;
                        else
                            policyInfo.Filtrate.TCD.Big2 = float.Parse( attributeTCDBig2.Value );

                        XAttribute attributeTCDSmall = elementTCD.Attribute( (XName)"Small" );
                        if ( attributeTCDSmall == null )
                            continue;
                        else
                            policyInfo.Filtrate.TCD.Small = float.Parse( attributeTCDSmall.Value );

                        XAttribute attributeTCDSmall2 = elementTCD.Attribute( (XName)"Small2" );
                        if ( attributeTCDSmall2 == null )
                            continue;
                        else
                            policyInfo.Filtrate.TCD.Small2 = float.Parse( attributeTCDSmall2.Value );
                    }

                    // U50Policy -> Filtrate -> TBU
                    XElement elementTBU = elementFiltrate.Element( (XName)"TBU" );
                    if ( elementTBU == null )
                        continue;
                    {
                        XAttribute attributeTCUEnabled = elementTBU.Attribute( (XName)"Enabled" );
                        if ( attributeTCUEnabled == null )
                            continue;
                        else
                            policyInfo.Filtrate.TBU.Enabled = bool.Parse( attributeTCUEnabled.Value );

                        XAttribute attributeTCUSelect = elementTBU.Attribute( (XName)"Select" );
                        if ( attributeTCUSelect == null )
                            continue;
                        else
                            policyInfo.Filtrate.TBU.Select = (U50SelectType)int.Parse( attributeTCUSelect.Value );

                        XAttribute attributeTCUBig = elementTBU.Attribute( (XName)"Big" );
                        if ( attributeTCUBig == null )
                            continue;
                        else
                            policyInfo.Filtrate.TBU.Big = float.Parse( attributeTCUBig.Value );

                        XAttribute attributeTCUBig2 = elementTBU.Attribute( (XName)"Big2" );
                        if ( attributeTCUBig2 == null )
                            continue;
                        else
                            policyInfo.Filtrate.TBU.Big2 = float.Parse( attributeTCUBig2.Value );

                        XAttribute attributeTCUSmall = elementTBU.Attribute( (XName)"Small" );
                        if ( attributeTCUSmall == null )
                            continue;
                        else
                            policyInfo.Filtrate.TBU.Small = float.Parse( attributeTCUSmall.Value );

                        XAttribute attributeTCUSmall2 = elementTBU.Attribute( (XName)"Small2" );
                        if ( attributeTCUSmall2 == null )
                            continue;
                        else
                            policyInfo.Filtrate.TBU.Small2 = float.Parse( attributeTCUSmall2.Value );
                    }

                    // U50Policy -> Filtrate -> Vac-UC
                    XElement elementVacUC = elementFiltrate.Element( (XName)"Vac-UC" );
                    if ( elementVacUC == null )
                        continue;
                    {
                        XAttribute attributeVacUCEnabled = elementVacUC.Attribute( (XName)"Enabled" );
                        if ( attributeVacUCEnabled == null )
                            continue;
                        else
                            policyInfo.Filtrate.VacUC.Enabled = bool.Parse( attributeVacUCEnabled.Value );

                        XAttribute attributeVacUCSelect = elementVacUC.Attribute( (XName)"Select" );
                        if ( attributeVacUCSelect == null )
                            continue;
                        else
                            policyInfo.Filtrate.VacUC.Select = (U50SelectType)int.Parse( attributeVacUCSelect.Value );

                        XAttribute attributeVacUCBig = elementVacUC.Attribute( (XName)"Big" );
                        if ( attributeVacUCBig == null )
                            continue;
                        else
                            policyInfo.Filtrate.VacUC.Big = float.Parse( attributeVacUCBig.Value );

                        XAttribute attributeVacUCBig2 = elementVacUC.Attribute( (XName)"Big2" );
                        if ( attributeVacUCBig2 == null )
                            continue;
                        else
                            policyInfo.Filtrate.VacUC.Big2 = float.Parse( attributeVacUCBig2.Value );

                        XAttribute attributeVacUCSmall = elementVacUC.Attribute( (XName)"Small" );
                        if ( attributeVacUCSmall == null )
                            continue;
                        else
                            policyInfo.Filtrate.VacUC.Small = float.Parse( attributeVacUCSmall.Value );

                        XAttribute attributeVacUCSmall2 = elementVacUC.Attribute( (XName)"Small2" );
                        if ( attributeVacUCSmall2 == null )
                            continue;
                        else
                            policyInfo.Filtrate.VacUC.Small2 = float.Parse( attributeVacUCSmall2.Value );
                    }
                }

                // U50Policy -> Extend
                XElement elementExtend = u50Policy.Element( (XName)"Extend" );
                if ( elementExtend == null )
                    continue;
                {
                    // U50Policy -> Extend -> Info01
                    XElement elementInfo01 = elementExtend.Element( (XName)"Info01" );
                    if ( elementInfo01 == null )
                        continue;
                    {
                        XAttribute attributeInfo01Enabled = elementInfo01.Attribute( (XName)"Enabled" );
                        if ( attributeInfo01Enabled == null )
                            continue;
                        else
                            policyInfo.Extend.Info01.Enabled = bool.Parse( attributeInfo01Enabled.Value );

                        XAttribute attributeInfo01Select = elementInfo01.Attribute( (XName)"Select" );
                        if ( attributeInfo01Select == null )
                            continue;
                        else
                            policyInfo.Extend.Info01.Select = (U50ExtendInfo01Type)int.Parse( attributeInfo01Select.Value );

                        XAttribute attributeInfo01Big = elementInfo01.Attribute( (XName)"HighNumber" );
                        if ( attributeInfo01Big == null )
                            continue;
                        else
                            policyInfo.Extend.Info01.HighNumber = int.Parse( attributeInfo01Big.Value );
                    }

                    // U50Policy -> Extend -> Info02
                    XElement elementInfo02 = elementExtend.Element( (XName)"Info02" );
                    if ( elementInfo02 == null )
                        continue;
                    {
                        XAttribute attributeInfo02Enabled = elementInfo02.Attribute( (XName)"Enabled" );
                        if ( attributeInfo02Enabled == null )
                            continue;
                        else
                            policyInfo.Extend.Info02.Enabled = bool.Parse( attributeInfo02Enabled.Value );

                        XAttribute attributeInfo02Select = elementInfo02.Attribute( (XName)"Select" );
                        if ( attributeInfo02Select == null )
                            continue;
                        else
                            policyInfo.Extend.Info02.Select = (U50SelectType)int.Parse( attributeInfo02Select.Value );

                        XAttribute attributeInfo02Big = elementInfo02.Attribute( (XName)"Big" );
                        if ( attributeInfo02Big == null )
                            continue;
                        else
                            policyInfo.Extend.Info02.Big = long.Parse( attributeInfo02Big.Value );

                        XAttribute attributeInfo02Big2 = elementInfo02.Attribute( (XName)"Big2" );
                        if ( attributeInfo02Big2 == null )
                            continue;
                        else
                            policyInfo.Extend.Info02.Big2 = long.Parse( attributeInfo02Big2.Value );

                        XAttribute attributeInfo02Small = elementInfo02.Attribute( (XName)"Small" );
                        if ( attributeInfo02Small == null )
                            continue;
                        else
                            policyInfo.Extend.Info02.Small = long.Parse( attributeInfo02Small.Value );

                        XAttribute attributeInfo02Small2 = elementInfo02.Attribute( (XName)"Small2" );
                        if ( attributeInfo02Small2 == null )
                            continue;
                        else
                            policyInfo.Extend.Info02.Small2 = long.Parse( attributeInfo02Small2.Value );
                    }

                    // U50Policy -> Extend -> Info03
                    XElement elementInfo03 = elementExtend.Element( (XName)"Info03" );
                    if ( elementInfo03 == null )
                        continue;
                    {
                        XAttribute attributeInfo03Enabled = elementInfo03.Attribute( (XName)"Enabled" );
                        if ( attributeInfo03Enabled == null )
                            continue;
                        else
                            policyInfo.Extend.Info03.Enabled = bool.Parse( attributeInfo03Enabled.Value );

                        XAttribute attributeInfo03Select = elementInfo03.Attribute( (XName)"Select" );
                        if ( attributeInfo03Select == null )
                            continue;
                        else
                            policyInfo.Extend.Info03.Select = (U50SelectType)int.Parse( attributeInfo03Select.Value );

                        XAttribute attributeInfo03Big = elementInfo03.Attribute( (XName)"Big" );
                        if ( attributeInfo03Big == null )
                            continue;
                        else
                            policyInfo.Extend.Info03.Big = int.Parse( attributeInfo03Big.Value );

                        XAttribute attributeInfo03Big2 = elementInfo03.Attribute( (XName)"Big2" );
                        if ( attributeInfo03Big2 == null )
                            continue;
                        else
                            policyInfo.Extend.Info03.Big2 = int.Parse( attributeInfo03Big2.Value );

                        XAttribute attributeInfo03Small = elementInfo03.Attribute( (XName)"Small" );
                        if ( attributeInfo03Small == null )
                            continue;
                        else
                            policyInfo.Extend.Info03.Small = int.Parse( attributeInfo03Small.Value );

                        XAttribute attributeInfo03Small2 = elementInfo03.Attribute( (XName)"Small2" );
                        if ( attributeInfo03Small2 == null )
                            continue;
                        else
                            policyInfo.Extend.Info03.Small2 = int.Parse( attributeInfo03Small2.Value );
                    }

                    // U50Policy -> Extend -> Info04
                    XElement elementInfo04 = elementExtend.Element( (XName)"Info04" );
                    if ( elementInfo04 == null )
                        continue;
                    {
                        XAttribute attributeInfo04Enabled = elementInfo04.Attribute( (XName)"Enabled" );
                        if ( attributeInfo04Enabled == null )
                            continue;
                        else
                            policyInfo.Extend.Info04.Enabled = bool.Parse( attributeInfo04Enabled.Value );

                        XAttribute attributeInfo04Select = elementInfo04.Attribute( (XName)"Select" );
                        if ( attributeInfo04Select == null )
                            continue;
                        else
                            policyInfo.Extend.Info04.Select = (U50ExtendInfo04Type)int.Parse( attributeInfo04Select.Value );
                    }

                    // U50Policy -> Extend -> Info05
                    XElement elementInfo05 = elementExtend.Element( (XName)"Info05" );
                    if ( elementInfo05 == null )
                        continue;
                    {
                        XAttribute attributeInfo05Enabled = elementInfo05.Attribute( (XName)"Enabled" );
                        if ( attributeInfo05Enabled == null )
                            continue;
                        else
                            policyInfo.Extend.Info05.Enabled = bool.Parse( attributeInfo05Enabled.Value );

                        XAttribute attributeInfo05Select = elementInfo05.Attribute( (XName)"Select" );
                        if ( attributeInfo05Select == null )
                            continue;
                        else
                            policyInfo.Extend.Info05.Select = (U50SelectType)int.Parse( attributeInfo05Select.Value );

                        XAttribute attributeInfo05Big = elementInfo05.Attribute( (XName)"Big" );
                        if ( attributeInfo05Big == null )
                            continue;
                        else
                            policyInfo.Extend.Info05.Big = int.Parse( attributeInfo05Big.Value );

                        XAttribute attributeInfo05Big2 = elementInfo05.Attribute( (XName)"Big2" );
                        if ( attributeInfo05Big2 == null )
                            continue;
                        else
                            policyInfo.Extend.Info05.Big2 = int.Parse( attributeInfo05Big2.Value );

                        XAttribute attributeInfo05Small = elementInfo05.Attribute( (XName)"Small" );
                        if ( attributeInfo05Small == null )
                            continue;
                        else
                            policyInfo.Extend.Info05.Small = int.Parse( attributeInfo05Small.Value );

                        XAttribute attributeInfo05Small2 = elementInfo05.Attribute( (XName)"Small2" );
                        if ( attributeInfo05Small2 == null )
                            continue;
                        else
                            policyInfo.Extend.Info05.Small2 = int.Parse( attributeInfo05Small2.Value );
                    }
                }

                policyInfoList.Add( policyInfo );
            }

            return policyInfoList.ToArray();
        }
        public void NewPolicy()
        {
            if ( m_IsInitializing == false )
                ConfigForm_Load( this, EventArgs.Empty );

            U50PolicyInfo policyInfo = new U50PolicyInfo();
            policyInfo.Guid = Guid.NewGuid().ToString();

            do
            {
                policyInfo.Name = string.Format( "U50策略{0}", m_PolicyCount++ );

                if ( m_PolicyName.Contains( policyInfo.Name ) == false )
                    break;
            } while ( true );

            // U50策略01
            TreeNode newTreeNodePolicy = new TreeNode( policyInfo.Name );
            TreeNode newTreeNodePolicySub = new TreeNode( "常规选项" );
            TreeNode newTreeNodePolicySub1 = new TreeNode( "取样方法" );
            TreeNode newTreeNodePolicySub2 = new TreeNode( "形态函数" );
            TreeNode newTreeNodePolicySub3 = new TreeNode( "增强刷选" );
            newTreeNodePolicy.Nodes.Add( newTreeNodePolicySub );
            newTreeNodePolicy.Nodes.Add( newTreeNodePolicySub1 );
            newTreeNodePolicy.Nodes.Add( newTreeNodePolicySub2 );
            newTreeNodePolicy.Nodes.Add( newTreeNodePolicySub3 );


            PolicyBControl configBControl = new PolicyBControl { Dock = DockStyle.Fill, Visible = false };

            this.m_AllConfigControlInfo.Add( newTreeNodePolicy, configBControl );
            this.m_AllConfigControlInfo.Add( newTreeNodePolicySub, configBControl );

            this.Panel.Controls.Add( configBControl );

            PolicyCControl configCControl = new PolicyCControl { Dock = DockStyle.Fill, Visible = false };
            policyInfo.Policy = configCControl.GetConfigPolicy();

            this.m_AllConfigControlInfo.Add( newTreeNodePolicySub1, configCControl );

            this.Panel.Controls.Add( configCControl );

            PolicyDControl configDControl = new PolicyDControl { Dock = DockStyle.Fill, Visible = false };
            policyInfo.Filtrate = configDControl.GetConfigFiltrate();

            this.m_AllConfigControlInfo.Add( newTreeNodePolicySub2, configDControl );

            this.Panel.Controls.Add( configDControl );

            PolicyEControl configEControl = new PolicyEControl { Dock = DockStyle.Fill, Visible = false };
            configEControl.EventButtonSetting += new EventHandler( OnEventButtonSetting );
            m_ButtonSetting.Add( configEControl, newTreeNodePolicySub2 );
            policyInfo.Extend = configEControl.GetConfigExtend();

            this.m_AllConfigControlInfo.Add( newTreeNodePolicySub3, configEControl );

            this.Panel.Controls.Add( configEControl );

            this.TreeView.Nodes.Add( newTreeNodePolicy );

            this.TreeView.SelectedNode = newTreeNodePolicy;

            m_NewTreeNode.Add( newTreeNodePolicy );

            m_TreeNodePolicyInfo.Add( newTreeNodePolicy, policyInfo );
        }
        private void NewPolicy( U50PolicyInfo policyInfo )
        {
            m_PolicyName.Add( policyInfo.Name );

            // U50策略01
            TreeNode newTreeNodePolicy = new TreeNode( policyInfo.Name );
            TreeNode newTreeNodePolicySub = new TreeNode( "常规选项" );
            TreeNode newTreeNodePolicySub1 = new TreeNode( "取样方法" );
            TreeNode newTreeNodePolicySub2 = new TreeNode( "形态函数" );
            TreeNode newTreeNodePolicySub3 = new TreeNode( "增强刷选" );
            newTreeNodePolicy.Nodes.Add( newTreeNodePolicySub );
            newTreeNodePolicy.Nodes.Add( newTreeNodePolicySub1 );
            newTreeNodePolicy.Nodes.Add( newTreeNodePolicySub2 );
            newTreeNodePolicy.Nodes.Add( newTreeNodePolicySub3 );


            PolicyBControl configBControl = new PolicyBControl();
            configBControl.Dock = DockStyle.Fill;
            configBControl.Visible = false;

            this.m_AllConfigControlInfo.Add( newTreeNodePolicy, configBControl );
            this.m_AllConfigControlInfo.Add( newTreeNodePolicySub, configBControl );

            this.Panel.Controls.Add( configBControl );

            PolicyCControl configCControl = new PolicyCControl();
            configCControl.Dock = DockStyle.Fill;
            configCControl.Visible = false;
            configCControl.SetConfigPolicy( policyInfo.Policy );

            this.m_AllConfigControlInfo.Add( newTreeNodePolicySub1, configCControl );

            this.Panel.Controls.Add( configCControl );

            PolicyDControl configDControl = new PolicyDControl();
            configDControl.Dock = DockStyle.Fill;
            configDControl.Visible = false;
            configDControl.SetConfigFiltrate( policyInfo.Filtrate );

            this.m_AllConfigControlInfo.Add( newTreeNodePolicySub2, configDControl );

            this.Panel.Controls.Add( configDControl );

            PolicyEControl configEControl = new PolicyEControl();
            configEControl.Dock = DockStyle.Fill;
            configEControl.Visible = false;
            configEControl.EventButtonSetting += new EventHandler( OnEventButtonSetting );
            m_ButtonSetting.Add( configEControl, newTreeNodePolicySub2 );
            configEControl.SetConfigExtend( policyInfo.Extend );

            this.m_AllConfigControlInfo.Add( newTreeNodePolicySub3, configEControl );

            this.Panel.Controls.Add( configEControl );

            this.TreeView.Nodes.Add( newTreeNodePolicy );

            this.TreeView.SelectedNode = newTreeNodePolicy;

            m_TreeNodePolicyInfo.Add( newTreeNodePolicy, policyInfo );
        }