public void AddReportInfo( U50ReportInfo reportInfo )
        {
            m_ReportInfoByGuid.Add( reportInfo.Guid, reportInfo );

            if ( AddedPolicyInfo != null )
                AddedPolicyInfo( this, EventArgs.Empty );
        }
示例#2
0
        public void AddReportInfo(U50ReportInfo reportInfo)
        {
            m_ReportInfoByGuid.Add(reportInfo.Guid, reportInfo);

            if (AddedPolicyInfo != null)
            {
                AddedPolicyInfo(this, EventArgs.Empty);
            }
        }
示例#3
0
        public U50ReportInfo GetReportInfoByGuid(string strReportGuid)
        {
            U50ReportInfo outReportInfo = null;

            if (m_ReportInfoByGuid.TryGetValue(strReportGuid, out outReportInfo) == true)
            {
                return(outReportInfo);
            }
            else
            {
                return(null);
            }
        }
        public void Init( U50ReportInfo ReportInfo )
        {
            if ( ReportInfo == null )
                return;
            else
                m_ReportInfo = ReportInfo;
            MessageBox.Show( m_ReportInfo.ReportArray.Length.ToString() );

            foreach ( var item in m_ReportInfo.ReportArray )
            {
                ListViewItem listViewItem = new ListViewItem( item.Symbol );
                //ListViewItem.ListViewSubItem subListViewItem1 = new ListViewItem.ListViewSubItem();
                //subListViewItem1.Text = item.Symbol;

                ListViewItem.ListViewSubItem subListViewItem2 = new ListViewItem.ListViewSubItem();
                subListViewItem2.Text = item.ReportSubInfo.S_Date.ToString();

                ListViewItem.ListViewSubItem subListViewItem3 = new ListViewItem.ListViewSubItem();
                subListViewItem3.Text = item.ReportSubInfo.KLineNumber.ToString();

                ListViewItem.ListViewSubItem subListViewItem4 = new ListViewItem.ListViewSubItem();
                subListViewItem4.Text = item.ReportSubInfo.Q_U50.ToString();

                ListViewItem.ListViewSubItem subListViewItem5 = new ListViewItem.ListViewSubItem();
                subListViewItem5.Text = item.ReportSubInfo.Vsc.ToString();

                ListViewItem.ListViewSubItem subListViewItem6 = new ListViewItem.ListViewSubItem();
                subListViewItem6.Text = item.ReportSubInfo.Close.ToString();

                listViewItem.SubItems.Add( subListViewItem2 );
                listViewItem.SubItems.Add( subListViewItem3 );
                listViewItem.SubItems.Add( subListViewItem4 );
                listViewItem.SubItems.Add( subListViewItem5 );
                listViewItem.SubItems.Add( subListViewItem6 );

                this.listView1.Items.Add( listViewItem );
            }
        }
        public static void SaveReport( string strTaskGuid, U50ReportInfo[] reportInfos )
        {
            if ( reportInfos == null )
                return;

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

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

            for ( int iIndex = 0; iIndex < reportInfos.Length; iIndex++ )
            {
                U50ReportInfo reportInfo = reportInfos[iIndex];

                XElement elementU50Report = new XElement( "U50Report", new XAttribute( "Guid", reportInfo.Guid ) );
                elementU50Report.Add( new XAttribute( "ScanTime", reportInfo.ScanTime.ToString() ) );
                elementU50Report.Add( new XAttribute( "ScanSpan", reportInfo.ScanSpan.ToString() ) );
                {
                    XElement elementTask = new XElement( "Task" );
                    {
                        elementU50Report.Add( new XAttribute( "Guid", reportInfo.StaticTaskInfo.Guid ) );
                        {
                            XElement elementGeneral = new XElement( "General" );
                            {
                                elementGeneral.Add( new XAttribute( "SaneType", ( (int)reportInfo.StaticTaskInfo.General.SaneType ).ToString() ) );
                            }
                            elementU50Report.Add( elementGeneral );

                            XElement elementRequest = new XElement( "Request" );
                            {
                                elementRequest.Add( new XAttribute( "SelectType", ( (int)reportInfo.StaticTaskInfo.Request.Select ).ToString() ) );
                                elementRequest.Add( new XAttribute( "Plate", reportInfo.StaticTaskInfo.Request.Plate ) );
                                elementRequest.Add( new XAttribute( "Variety", reportInfo.StaticTaskInfo.Request.Variety ) );

                                for ( int iIndex2 = 0; iIndex2 < reportInfo.StaticTaskInfo.Request.StockInfo.Length; iIndex2++ )
                                {
                                    U50StockInfo stockInfo = reportInfo.StaticTaskInfo.Request.StockInfo[iIndex2];

                                    XElement elementStockInfo = new XElement( "StockInfo" );
                                    {
                                        elementStockInfo.Add( new XAttribute( "Plate", stockInfo.Plate ) );
                                        elementStockInfo.Add( new XAttribute( "Variety", stockInfo.Variety ) );
                                        elementStockInfo.Add( new XAttribute( "Name", stockInfo.Name ) );
                                        elementStockInfo.Add( new XAttribute( "Symbol", stockInfo.Symbol ) );
                                    }
                                    elementRequest.Add( elementStockInfo );
                                }
                            }
                            elementU50Report.Add( elementRequest );

                            XElement elementPolicy = new XElement( "Policy" );
                            {
                                elementPolicy.Add( new XAttribute( "ScanType", ( (int)reportInfo.StaticTaskInfo.Policy.ScanType ).ToString() ) );

                                for ( int iIndex2 = 0; iIndex2 < reportInfo.StaticTaskInfo.Policy.PolicyGuid.Length; iIndex2++ )
                                {
                                    string strPolicyGuid = reportInfo.StaticTaskInfo.Policy.PolicyGuid[iIndex2];

                                    XElement elementPolicyGuid = new XElement( "PolicyGuid" );
                                    {
                                        elementPolicyGuid.Add( new XAttribute( "Guid", strPolicyGuid ) );
                                    }
                                    elementPolicy.Add( elementPolicyGuid );
                                }
                            }
                            elementU50Report.Add( elementPolicy );

                            XElement elementScanResult = new XElement( "ScanResult" );
                            {
                                elementScanResult.Add( new XAttribute( "LastReportGuid", reportInfo.StaticTaskInfo.Result.LastReportGuid ) );
                            }
                            elementU50Report.Add( elementScanResult );
                        }
                    }
                    elementU50Report.Add( elementTask );

                    XElement elementPolicyInfo = new XElement( "PolicyInfo" );
                    {
                        for ( int iIndex2 = 0; iIndex2 < reportInfo.StaticReportInfo.Length; iIndex2++ )
                        {
                            U50PolicyInfo policyInfo = reportInfo.StaticReportInfo[iIndex2];

                            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( "Small", policyInfo.Filtrate.PDU.Small.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( "Small", policyInfo.Filtrate.PCU.Small.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( "Small", policyInfo.Filtrate.TDU.Small.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( "Small", policyInfo.Filtrate.TCD.Small.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( "Small", policyInfo.Filtrate.TBU.Small.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( "Small", policyInfo.Filtrate.VacUC.Small.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( "Small", policyInfo.Extend.Info02.Small.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( "Small", policyInfo.Extend.Info03.Small.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( "Small", policyInfo.Extend.Info05.Small.ToString() ) );
                                    }
                                    elementExtend.Add( elementInfo05 );
                                }
                                elementU50Policy.Add( elementExtend );
                            }
                            elementPolicyInfo.Add( elementU50Policy );
                        }
                    }
                    elementU50Report.Add( elementPolicyInfo );

                    XElement elementReportInfo = new XElement( "ReportInfo" );
                    {
                        for ( int iIndex3 = 0; iIndex3 < reportInfo.ReportArray.Length; iIndex3++ )
                        {
                            U50Report report = reportInfo.ReportArray[iIndex3];

                            XElement elementPolicy = new XElement( "Report" );
                            {
                                elementPolicy.Add( new XAttribute( "Name", report.Name ) );
                                elementPolicy.Add( new XAttribute( "Symbol", report.Symbol ) );
                                //elementPolicy.Add( new XAttribute( "S_Date", report.S_Date.ToString() ) );
                                //elementPolicy.Add( new XAttribute( "Va_U50", report.Va_U50.ToString() ) );
                                //elementPolicy.Add( new XAttribute( "Vsc", report.Vsc.ToString() ) );
                                //elementPolicy.Add( new XAttribute( "Close", report.Close.ToString() ) );
                                //elementPolicy.Add( new XAttribute( "Scanner", report.Scanner.ToString() ) );
                                //elementPolicy.Add( new XAttribute( "Q_U50", report.Q_U50.ToString() ) );
                                //elementPolicy.Add( new XAttribute( "KLineNumber", report.KLineNumber.ToString() ) );
                                elementPolicy.Add( new XAttribute( "ScanTime", report.ScanTime.ToString() ) );
                                elementPolicy.Add( new XAttribute( "ScanSpan", report.ScanSpan.ToString() ) );
                            }
                            elementPolicyInfo.Add( elementPolicy );
                        }
                    }
                    elementU50Report.Add( elementU50Report );
                }
                elementRoot.Add( elementU50Report );
            }

            XDocument documentConfig = new XDocument( new XDeclaration( "1.0", "utf - 8", "yes" ), elementRoot );
            documentConfig.Save( strTaskGuid );
        }
        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 U50ReportInfo ScanTask( U50TaskInfo taskInfo )
        {
            U50ReportInfo reportInfo = new U50ReportInfo();
            reportInfo.Guid = Guid.NewGuid().ToString();
            reportInfo.ScanTime = DateTime.Now;
            reportInfo.StaticTaskInfo = taskInfo;

            List<U50PolicyInfo> policyInfoList = new List<U50PolicyInfo>();
            foreach ( var policyGuid in taskInfo.Policy.PolicyGuid )
            {
                U50PolicyInfo policyInfo = PolicyManager.Instance.GetPolicyInfoByGuid( policyGuid );
                if ( policyInfo == null )
                    continue;
                else
                    policyInfoList.Add( policyInfo );
            }
            reportInfo.StaticReportInfo = policyInfoList.ToArray();

            //MessageBox.Show("reportInfo.StaticReportInf = " + policyInfoList.Count.ToString() );

            List<Demo.Stock.X.Common.StockInfo> stockInfoList = new List<Demo.Stock.X.Common.StockInfo>();
            foreach ( var stockInfo in taskInfo.Request.StockInfo )
            {
                StockManager stockManager = GlobalStockManager.GetStockManagerByPlateAndVariety(stockInfo.Plate, stockInfo.Variety);
                if ( stockManager == null )
                    continue;

                Demo.Stock.X.Common.StockInfo stockInfox = stockManager.GetStockDataByStockCode( GlobalSetting.GetStockCode( stockInfo.Name, stockInfo.Symbol ) );
                if ( stockInfox == null )
                    continue;
                else
                    stockInfoList.Add( stockInfox );
            }

            //MessageBox.Show("stockInfoList = " + stockInfoList.Count.ToString() );

            List<U50Report> reportList = new List<U50Report>();
            foreach ( var stockInfoxx in stockInfoList )
            {
                foreach ( var policyInfoxx in policyInfoList )
                {

                    if ( policyInfoxx.Policy.Priority == U50PriorityType.BaseDate )
                    {
                        if ( policyInfoxx.Policy.IsAllowDate )
                        {

                            //MessageBox.Show( "policyInfoxx.Policy.IsAllowDate" );

                            DateTime iStart = DateTime.Now;
                            if ( policyInfoxx.Policy.IsDateNow != true )
                                iStart = policyInfoxx.Policy.DateSelect;
                            for ( ; iStart > policyInfoxx.Policy.DateEnd; iStart -= TimeSpan.FromDays( policyInfoxx.Policy.DateStep ) )
                            {
                                StockData[] stockDataArray = stockInfoxx.GetStockDataRangeByKn( iStart, (int)policyInfoxx.Policy.KN );

                                //MessageBox.Show( "stockDataArray = " + stockDataArray.Length.ToString() );
                                //MessageBox.Show( "iStart = " + iStart.ToString() );

                                U50Report report = new U50Report();
                                report.Name = stockInfoxx.StockName;
                                report.Symbol = stockInfoxx.StockSymbol;
                                report.Guid = policyInfoxx.Guid;

                                report.ReportSubInfo.S_Date = iStart;

                                report.ScanTime = DateTime.Now;

                                bool isOK = IsPassGeneral( stockDataArray, stockInfoxx, policyInfoxx.Filtrate, policyInfoxx.Extend, ref report.ReportSubInfo );
                                if ( isOK == false )
                                    continue;
                                else
                                {
                                    report.ScanSpan = DateTime.Now - report.ScanTime;
                                    reportList.Add( report );

                                    if ( policyInfoxx.Policy.Output == U50OutputType.One )
                                        break;
                                }
                            }
                        }

                        if ( policyInfoxx.Policy.IsAllowKN )
                        {
                            //MessageBox.Show( "policyInfoxx.Policy.IsAllowKN" );

                            DateTime iStart = DateTime.Now;
                            if ( policyInfoxx.Policy.IsDateNow != true )
                                iStart = policyInfoxx.Policy.DateSelect;
                            for ( int iKn = (int)policyInfoxx.Policy.KN; iKn < policyInfoxx.Policy.KNEnd; iKn += (int)policyInfoxx.Policy.KNStep )
                            {
                                StockData[] stockDataArray = stockInfoxx.GetStockDataRangeByKn( iStart, (int)policyInfoxx.Policy.KN );

                                U50Report report = new U50Report();
                                report.Name = stockInfoxx.StockName;
                                report.Symbol = stockInfoxx.StockSymbol;
                                report.Guid = policyInfoxx.Guid;

                                report.ReportSubInfo.S_Date = iStart;

                                report.ScanTime = DateTime.Now;

                                bool isOK = IsPassGeneral( stockDataArray, stockInfoxx, policyInfoxx.Filtrate, policyInfoxx.Extend, ref report.ReportSubInfo );
                                if ( isOK == false )
                                    continue;
                                else
                                {
                                    report.ScanSpan = DateTime.Now - report.ScanTime;
                                    reportList.Add( report );

                                    if ( policyInfoxx.Policy.Output == U50OutputType.One )
                                        break;
                                }
                            }
                        }

                        if ( policyInfoxx.Policy.IsAllowDate == false && policyInfoxx.Policy.IsAllowKN == false )
                        {
                            //MessageBox.Show( "policyInfoxx.Policy.IsAllowDate&IsAllowKN false" );

                            DateTime iStart = DateTime.Now;
                            if ( policyInfoxx.Policy.IsDateNow != true )
                                iStart = policyInfoxx.Policy.DateSelect;

                            StockData[] stockDataArray = stockInfoxx.GetStockDataRangeByKn( iStart, (int)policyInfoxx.Policy.KN );

                            U50Report report = new U50Report();
                            report.Name = stockInfoxx.StockName;
                            report.Symbol = stockInfoxx.StockSymbol;
                            report.Guid = policyInfoxx.Guid;

                            report.ReportSubInfo.S_Date = iStart;

                            report.ScanTime = DateTime.Now;

                            bool isOK = IsPassGeneral( stockDataArray, stockInfoxx, policyInfoxx.Filtrate, policyInfoxx.Extend, ref report.ReportSubInfo );
                            if ( isOK == false )
                                continue;

                            report.ScanSpan = DateTime.Now - report.ScanTime;

                            reportList.Add( report );
                        }
                    }
                    else if ( policyInfoxx.Policy.Priority == U50PriorityType.BaseKN )
                    {
                        if ( policyInfoxx.Policy.IsAllowKN )
                        {
                            DateTime iStart = DateTime.Now;
                            if ( policyInfoxx.Policy.IsDateNow != true )
                                iStart = policyInfoxx.Policy.DateSelect;
                            for ( int iKn = (int)policyInfoxx.Policy.KN; iKn < policyInfoxx.Policy.KNEnd; iKn += (int)policyInfoxx.Policy.KNStep )
                            {
                                StockData[] stockDataArray = stockInfoxx.GetStockDataRangeByKn( iStart, (int)policyInfoxx.Policy.KN );

                                U50Report report = new U50Report();
                                report.Name = stockInfoxx.StockName;
                                report.Symbol = stockInfoxx.StockSymbol;
                                report.Guid = policyInfoxx.Guid;

                                report.ReportSubInfo.S_Date = iStart;

                                report.ScanTime = DateTime.Now;

                                bool isOK = IsPassGeneral( stockDataArray, stockInfoxx, policyInfoxx.Filtrate, policyInfoxx.Extend, ref report.ReportSubInfo );
                                if ( isOK == false )
                                    continue;

                                else
                                {
                                    report.ScanSpan = DateTime.Now - report.ScanTime;
                                    reportList.Add( report );

                                    if ( policyInfoxx.Policy.Output == U50OutputType.One )
                                        break;
                                }
                            }
                        }

                        if ( policyInfoxx.Policy.IsAllowDate )
                        {
                            DateTime iStart = DateTime.Now;
                            if ( policyInfoxx.Policy.IsDateNow != true )
                                iStart = policyInfoxx.Policy.DateSelect;
                            for ( ; iStart > policyInfoxx.Policy.DateEnd; iStart -= TimeSpan.FromDays( policyInfoxx.Policy.DateStep ) )
                            {
                                StockData[] stockDataArray = stockInfoxx.GetStockDataRangeByKn( iStart, (int)policyInfoxx.Policy.KN );

                                U50Report report = new U50Report();
                                report.Name = stockInfoxx.StockName;
                                report.Symbol = stockInfoxx.StockSymbol;
                                report.Guid = policyInfoxx.Guid;

                                report.ReportSubInfo.S_Date = iStart;

                                report.ScanTime = DateTime.Now;

                                bool isOK = IsPassGeneral( stockDataArray, stockInfoxx, policyInfoxx.Filtrate, policyInfoxx.Extend, ref report.ReportSubInfo );
                                if ( isOK == false )
                                    continue;
                                else
                                {
                                    report.ScanSpan = DateTime.Now - report.ScanTime;
                                    reportList.Add( report );

                                    if ( policyInfoxx.Policy.Output == U50OutputType.One )
                                        break;
                                }
                            }
                        }

                        if ( policyInfoxx.Policy.IsAllowDate == false && policyInfoxx.Policy.IsAllowKN == false )
                        {
                            DateTime iStart = DateTime.Now;
                            if ( policyInfoxx.Policy.IsDateNow != true )
                                iStart = policyInfoxx.Policy.DateSelect;

                            StockData[] stockDataArray = stockInfoxx.GetStockDataRangeByKn( iStart, (int)policyInfoxx.Policy.KN );

                            U50Report report = new U50Report();
                            report.Name = stockInfoxx.StockName;
                            report.Symbol = stockInfoxx.StockSymbol;
                            report.Guid = policyInfoxx.Guid;

                            report.ReportSubInfo.S_Date = iStart;

                            report.ScanTime = DateTime.Now;

                            bool isOK = IsPassGeneral( stockDataArray, stockInfoxx, policyInfoxx.Filtrate, policyInfoxx.Extend, ref report.ReportSubInfo );
                            if ( isOK == false )
                                continue;

                            report.ScanSpan = DateTime.Now - report.ScanTime;

                            reportList.Add( report );
                        }
                    }
                    else
                    {
                        if ( policyInfoxx.Policy.IsAllowKN )
                        {
                            DateTime iStart = DateTime.Now;
                            if ( policyInfoxx.Policy.IsDateNow != true )
                                iStart = policyInfoxx.Policy.DateSelect;
                            for ( int iKn = (int)policyInfoxx.Policy.KN; iKn < policyInfoxx.Policy.KNEnd; iKn += (int)policyInfoxx.Policy.KNStep )
                            {
                                StockData[] stockDataArray = stockInfoxx.GetStockDataRangeByKn( iStart, (int)policyInfoxx.Policy.KN );

                                U50Report report = new U50Report();
                                report.Name = stockInfoxx.StockName;
                                report.Symbol = stockInfoxx.StockSymbol;
                                report.Guid = policyInfoxx.Guid;

                                report.ReportSubInfo.S_Date = iStart;

                                report.ScanTime = DateTime.Now;

                                bool isOK = IsPassGeneral( stockDataArray, stockInfoxx, policyInfoxx.Filtrate, policyInfoxx.Extend, ref report.ReportSubInfo );
                                if ( isOK == false )
                                    continue;
                                else
                                {
                                    report.ScanSpan = DateTime.Now - report.ScanTime;
                                    reportList.Add( report );

                                    if ( policyInfoxx.Policy.Output == U50OutputType.One )
                                        break;
                                }
                            }
                        }

                        if ( policyInfoxx.Policy.IsAllowDate )
                        {
                            DateTime iStart = DateTime.Now;
                            if ( policyInfoxx.Policy.IsDateNow != true )
                                iStart = policyInfoxx.Policy.DateSelect;
                            for ( ; iStart > policyInfoxx.Policy.DateEnd; iStart -= TimeSpan.FromDays( policyInfoxx.Policy.DateStep ) )
                            {
                                StockData[] stockDataArray = stockInfoxx.GetStockDataRangeByKn( iStart, (int)policyInfoxx.Policy.KN );

                                U50Report report = new U50Report();
                                report.Name = stockInfoxx.StockName;
                                report.Symbol = stockInfoxx.StockSymbol;
                                report.Guid = policyInfoxx.Guid;

                                report.ReportSubInfo.S_Date = iStart;

                                report.ScanTime = DateTime.Now;

                                bool isOK = IsPassGeneral( stockDataArray, stockInfoxx, policyInfoxx.Filtrate, policyInfoxx.Extend, ref report.ReportSubInfo );
                                if ( isOK == false )
                                    continue;
                                else
                                {
                                    report.ScanSpan = DateTime.Now - report.ScanTime;
                                    reportList.Add( report );

                                    if ( policyInfoxx.Policy.Output == U50OutputType.One )
                                        break;
                                }
                            }
                        }


                        if ( policyInfoxx.Policy.IsAllowDate == false && policyInfoxx.Policy.IsAllowKN == false )
                        {
                            DateTime iStart = DateTime.Now;
                            if ( policyInfoxx.Policy.IsDateNow != true )
                                iStart = policyInfoxx.Policy.DateSelect;

                            StockData[] stockDataArray = stockInfoxx.GetStockDataRangeByKn( iStart, (int)policyInfoxx.Policy.KN );

                            U50Report report = new U50Report();
                            report.Name = stockInfoxx.StockName;
                            report.Symbol = stockInfoxx.StockSymbol;
                            report.Guid = policyInfoxx.Guid;

                            report.ReportSubInfo.S_Date = iStart;

                            report.ScanTime = DateTime.Now;

                            bool isOK = IsPassGeneral( stockDataArray, stockInfoxx, policyInfoxx.Filtrate, policyInfoxx.Extend, ref report.ReportSubInfo );
                            if ( isOK == false )
                                continue;

                            report.ScanSpan = DateTime.Now - report.ScanTime;

                            reportList.Add( report );
                        }
                    }

                }
            }

            reportInfo.ReportArray = reportList.ToArray();
            reportInfo.ScanSpan = DateTime.Now - reportInfo.ScanTime;

            return reportInfo;
        }
 public void FromConfigReportInfo( U50ReportInfo[] reportInfoArray )
 {
     for ( int iIndex = 0; iIndex < reportInfoArray.Length; iIndex++ )
         AddReportInfo( reportInfoArray[iIndex] );
 }