public static DataTable SimpleTest(String emCode, List <String> MacroIds, IndicateRequestType type)
        {
            String Cmd = String.Format(IndicatorDataPacket.CustomIndicatorsReportCmd,
                                       emCode, String.Join(",", MacroIds.ToArray()), (int)type);
            DataQuery _dataQuery = new DataQuery();
            DataSet   ds         = _dataQuery.QueryMacroIndicate(Cmd) as DataSet;

            return(ds.Tables[0]);
        }
        /// <summary>
        /// Try to Get the customlize macro-indicator Id list from user configer files.
        /// </summary>
        /// <param name="code"> Stock id.</param>
        /// <param name="indicateRequestType"> Indident which side type of request</param>
        /// <param name="custMacroIds"> Output the customlize macro-indicator Id list</param>
        /// <returns> True for the code have the customlize macro-indicator Id list, otherwise false.</returns>
        public static bool TryGetCustIndicatorIds(int code, IndicateRequestType indicateRequestType,
                                                  out HashSet <String> custMacroIds)
        {
            custMacroIds = new HashSet <String>();
            Dictionary <IndicateRequestType, HashSet <String> > innerDic;

            return(DicStockCustIndicator.TryGetValue(code, out innerDic) &&
                   innerDic.TryGetValue(indicateRequestType, out custMacroIds));
        }
        /// <summary>
        /// 解析宏观指标的表名字节流,得到报表请求类型类型及请求code
        /// (当请求股票对应的左右宏观报表,code是股票名称 eg. "000960.SZ";
        /// 当请求宏观指标值,code是指标id eg. "EMI00064805")
        /// </summary>
        /// <param name="tableName">返回的待处理字节流</param>
        /// <param name="requestType">报表请求类型</param>
        /// <param name="tableKeyCode">请求code</param>
        /// <returns></returns>
        private bool TryGetRequestType(String tableName, out IndicateRequestType requestType,
                                       out String tableKeyCode)
        {
            requestType  = IndicateRequestType.LeftIndicatorsReport;
            tableKeyCode = tableName;
            if (String.IsNullOrEmpty(tableName))
            {
                //Log error;
                return(false);
            }
            String[] arr = tableName.Split('_');

            if (arr == null || arr.Length == 0)
            {
                return(false);
            }

            if (arr.Length == 1)
            {
                requestType  = IndicateRequestType.IndicatorValuesReport;
                tableKeyCode = arr[0];
                return(true);
            }

            if (arr.Length == 2)
            {
                if (arr[0].StartsWith("1"))
                {
                    requestType = IndicateRequestType.LeftIndicatorsReport;
                }
                else if (arr[0].StartsWith("2"))
                {
                    requestType = IndicateRequestType.RightIndicatorsReport;
                }

                tableKeyCode = arr[1];
                return(true);
            }

            return(false);
        }
        /// <summary>
        /// Try to add a customlize macro-indicator Id in the user configer files.
        /// </summary>
        /// <param name="code"> Stock id.</param>
        /// <param name="indicateRequestType"> Indident which side type of request</param>
        /// <param name="custIndicatorId"> The macro-indicator id for adding.</param>
        /// <returns> True for the code have been added in the configer file successfully, otherwise false.</returns>
        public static bool TryAddCustIndicatorId(int code, IndicateRequestType indicateRequestType,
                                                 String custIndicatorId)
        {
            bool success = false;

            // del actions.
            if (!File.Exists(FilePath))
            {
                return(false);
            }

            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load(FilePath);
            }
            catch (IOException ioe)
            {
                LogUtilities.LogMessage("Load StockCustIndicatorCfg.xml Error : " + ioe.Message);
                throw;
            }
            catch (XmlException xe)
            {
                LogUtilities.LogMessage("Load StockCustIndicatorCfg.xml Error : " + xe.Message);
                throw;
            }
            catch (Exception ex)
            {
                LogUtilities.LogMessage("Load StockCustIndicatorCfg.xml Error : " + ex.Message);
                throw;
            }

            try
            {
                String  path      = String.Format("{0}[@{1}='{2}']", StockNode, StockAttr, code);
                XmlNode stockNode = doc.SelectSingleNode(path);
                if (stockNode == null || !stockNode.HasChildNodes)
                {
                    return(false);
                }
                String  checkNodePath;
                XmlNode checkNode;
                switch (indicateRequestType)
                {
                case IndicateRequestType.LeftIndicatorsReport:
                    XmlNode leftNode = stockNode.SelectSingleNode(LeftPath);
                    if (leftNode == null)
                    {
                        leftNode = doc.CreateElement(LeftPath);
                        stockNode.AppendChild(leftNode);
                    }
                    // Check if the node exist or not
                    checkNodePath =
                        String.Format("{0}[@{1}='{2}']", FinaNode, idAttr, custIndicatorId);
                    checkNode = leftNode.SelectSingleNode(checkNodePath);

                    if (checkNode == null)
                    {
                        XmlNode      newIndicatorNode = doc.CreateElement(FinaNode);
                        XmlAttribute newIdAttr        = doc.CreateAttribute(idAttr);
                        newIdAttr.InnerXml = custIndicatorId;
                        newIndicatorNode.Attributes.Append(newIdAttr);

                        leftNode.AppendChild(newIndicatorNode);

                        success = true;
                    }
                    break;

                case IndicateRequestType.RightIndicatorsReport:
                    XmlNode rightNode = stockNode.SelectSingleNode(RightPath);
                    if (rightNode == null)
                    {
                        rightNode = doc.CreateElement(RightPath);
                        stockNode.AppendChild(rightNode);
                    }
                    // Check if the node exist or not
                    checkNodePath =
                        String.Format("{0}[@{1}='{2}']", FinaNode, idAttr, custIndicatorId);
                    checkNode = rightNode.SelectSingleNode(checkNodePath);

                    // When the added node exist in the file, do nothing.
                    if (checkNode == null)
                    {
                        XmlNode newIndicatorNode = doc.CreateElement(FinaNode);

                        XmlAttribute newIdAttr = doc.CreateAttribute(idAttr);
                        newIdAttr.InnerXml = custIndicatorId;
                        newIndicatorNode.Attributes.Append(newIdAttr);

                        rightNode.AppendChild(newIndicatorNode);

                        success = true;
                    }
                    break;

                case IndicateRequestType.IndicatorValuesReport:
                    break;
                }

                if (success)
                {
                    doc.Save(FilePath);

                    // Refesh the cache.
                    LoadConfig();
                }
            }
            catch { success = false; }
            return(success);
        }