Exemplo n.º 1
0
        public static List <BigData> Parse(string sid, string time, string bigdeal)
        {
            List <BigData> list = new List <BigData>();

            bigdeal = bigdeal.Replace("-", ",-").Replace("+", ",+");

            bigdeal = bigdeal.StartsWith(",") ? bigdeal.Substring(1, bigdeal.Length - 1) : bigdeal;
            string[] bigs = bigdeal.Split(',');
            foreach (string b in bigs)
            {
                string type = b.StartsWith("+") ? "B" : "S";

                string code = MyBase64.UnCompressNumber(b.Substring(1, b.Length - 1)).ToString();

                for (int j = 0; j < (14 - code.Length); j++)
                {
                    code = "0" + code;
                }

                list.Add(
                    new BigData()
                {
                    sid          = sid,
                    shares       = int.Parse(code.Substring(0, 3)),
                    minutes      = int.Parse(code.Substring(3, 3)),
                    rateToOpen   = int.Parse(code.Substring(6, 4).StartsWith("0") ? "-" + code.Substring(7, 3) : code.Substring(7, 3)),
                    rateToChange = int.Parse(code.Substring(10, 4).StartsWith("0") ? "-" + code.Substring(11, 3) : code.Substring(11, 3)),
                    time         = BizCommon.ParseToDate(time),
                    type         = type
                });
            }

            return(list);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 返回参数
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public JObject GetParameter(HttpContext context)
        {
            JObject obj = new JObject();

            try
            {
                YZRequest request = new YZRequest(context);
                //获取数据连接信息
                int           connectId = request.GetInt32("connectId");
                ConnectInfo   con       = ConnectInfoManager.GetConnectInfo(connectId);
                SapLogin      login     = JObject.Parse(con.connectStr).ToObject <SapLogin>();
                ISourceHandle handle    = new SapHandle(login);
                //接口名称
                string          rfcName = request.GetString("rfcName");
                QueryDepictInfo info    = handle.GetQueryInfo(rfcName);

                //序列化
                JArray parameterArray = new JArray();
                obj["parameter"] = parameterArray;
                if (info.parameter != null && info.parameter.Count > 0)
                {
                    if (CommonHandle.IsParameterNoType(info.parameter))
                    {
                        obj[YZJsonProperty.success]      = false;
                        obj[YZJsonProperty.errorMessage] = "输入参数中有不符合规定的类型,无法进行配置!";
                        return(obj);
                    }
                    foreach (ColumnInfo item in info.parameter)
                    {
                        parameterArray.Add(BizCommon.GetColumnJson(item));
                    }
                }
                //输出参数
                JArray schemaArray = new JArray();
                obj["schema"] = schemaArray;
                if (info.schema != null && info.schema.Count > 0)
                {
                    foreach (var item in info.schema)
                    {
                        schemaArray.Add(BizCommon.GetColumnJson(item));
                    }
                }
                else
                {
                    obj[YZJsonProperty.success]      = false;
                    obj[YZJsonProperty.errorMessage] = "该接口没有返回值,不可调用!";
                    return(obj);
                }
                obj[YZJsonProperty.success] = true;
                return(obj);
            }
            catch (Exception ex)
            {
                obj[YZJsonProperty.success]      = false;
                obj[YZJsonProperty.errorMessage] = ex.ToString();
                return(obj);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 返回源详细信息
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public JObject GetSourceInfo(HttpContext context)
        {
            YZRequest       request  = new YZRequest(context);
            int             sourceId = request.GetInt32("sourceId");
            SourceInfo      entity   = SourceInfoManager.GetSourceInfo(sourceId);
            JObject         obj      = JObject.FromObject(entity);
            QueryDepictInfo info     = JObject.Parse(entity.sourceStr).ToObject <QueryDepictInfo>();

            obj["sourceStr"]            = BizCommon.GetQueryDepictInfoJson(info);
            obj[YZJsonProperty.success] = true;
            return(obj);
        }
Exemplo n.º 4
0
        public static string QueryAnalyze1(string sid, string level, string tag, string old, string daybefore)
        {
            tag = BizCommon.ProcessWeekend(tag);
            int      level_val   = 1;
            DateTime now         = DateTime.Now;
            int      i_daybeofre = 0;

            if (string.IsNullOrEmpty(tag))
            {
                tag = BizCommon.ParseToString(now);
            }
            else
            {
                now = BizCommon.ParseToDate(tag);
            }
            if (string.IsNullOrEmpty(daybefore))
            {
                i_daybeofre = 0;
            }
            else
            {
                i_daybeofre = int.Parse(daybefore);
            }
            if (!string.IsNullOrEmpty(level))
            {
                level_val = Int32.Parse(level);
            }
            if (string.IsNullOrEmpty(old))
            {
                old = Constant.ANALYZE_TIME;
            }

            string vv = "";

            string[] list = old.Split('-');
            foreach (string v in list)
            {
                int o = -Int32.Parse(v);


                DateTime end_date   = now.AddDays(-i_daybeofre);
                DateTime start_date = end_date.AddMonths(o);


                vv += BizApi.QueryAnalyzeDataValue(sid, tag, start_date, end_date, level_val) + ",";
            }

            return(vv.Substring(0, vv.Length - 1));;
        }
Exemplo n.º 5
0
        public static void Main(string[] args)
        {
            string path = ""; string time = "";

            if (args.Length == 2)
            {
                path = args[0];
                time = args[1];
            }
            else
            {
                path = @"C:\work\web\";
                time = BizCommon.ParseToString(DateTime.Now);
            }
            Generate.GenerateAll(path, time);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 获取某个字典
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public string GetDicts(string req)
        {
            try
            {
                reqdata = this.AnaRequestData(req);
                QueryItemCollection[] objs = json.Deserialize <QueryItemCollection[]>(reqdata.reqdata);

                string DOMAINNAMEIDEN = string.Empty;
                string dicttype       = string.Empty;

                for (int i = 0; i < objs.Length; i++)
                {
                    if (objs[i].queryItemKey.ToUpper() == "DOMAINNAMEIDEN".ToUpper())
                    {
                        DOMAINNAMEIDEN = objs[i].queryItemValue;
                    }
                    if (objs[i].queryItemKey.ToUpper() == "dicttype".ToUpper())
                    {
                        dicttype = objs[i].queryItemValue;
                    }
                }

                List <Xxx.Entities.SSY_BIZ_DICT> objResult = this._comSomebiz.GetDicts(DOMAINNAMEIDEN, BizCommon.GetDictType(dicttype), base.envirObj.distManagerParam);

                if (UtilitysForT <Xxx.Entities.SSY_BIZ_DICT> .ListHasData(objResult))
                {
                    resdata = this.MakeResponseData("1", string.Empty, json.Serialize(objResult), string.Empty);
                }
                else
                {
                    resdata = this.MakeResponseData("0", this.GetI18nLangItem("noFindData", this.i18nCommonCurrLang), string.Empty, string.Empty);
                }
            }
            catch (Exception ex)
            {
                resdata = this.MakeResponseData("0", this.GetI18nLangItem("findDataErr", this.i18nCommonCurrLang) + ex.Message, string.Empty, string.Empty);
            }

            return(json.Serialize(resdata));
        }
Exemplo n.º 7
0
        public static string Generate(string level, string tag, string old, string daybefore, string industry, string location, string type)
        {
            DateTime now        = BizCommon.ParseToDate(tag);
            DateTime end_date   = now.AddDays((double)(-Int32.Parse(daybefore)));
            DateTime start_date = end_date.AddMonths(-Int32.Parse(old));

            List <AnalyzeData> data = BizApi.QueryAnalyzeData(tag, start_date, end_date, Int32.Parse(level), industry, location, type);

            var newRow = "";

            newRow += "Start:" + BizCommon.ParseToString(start_date) + "  End:" + BizCommon.ParseToString(end_date);

            for (int i = 0; i < data.Count; i++)
            {
                newRow += "<tr>";
                var big = data[i].big;
                var sid = data[i].sid;


                var link = "<a target='_parent' href='/web/single_dynamic.html?sid=" + sid + "&big=" + big + "'>" + sid + "</a>";
                newRow += "<td>" + link + "</td>";
                newRow += "<td>" + data[i].name + "</td>";

                var ind1 = data[i].firstlevel;
                var ind2 = data[i].secondlevel;

                var ind_link1 = "<a target='_parent' href='/web/company.html?industry1=" + ind1 + "'>" + ind1 + "</a>";
                newRow += "<td>" + ind_link1 + "</td>";
                var ind_link2 = "<a target='_parent' href='/web/company.html?industry1=" + ind1 + "&industry2=" + ind2 + "'>" + ind2 + "</a>";
                newRow += "<td>" + ind_link2 + "</td>";

                var enddate   = data[i].enddate;
                var startdate = data[i].startdate;



                //newRow += "<td>" + start_date + "</td>";
                //newRow += "<td>" + end_date + "</td>";

                //排名情况
                var y = "/rest/rest/analyzevalue?level=" + level + "&tag=" + tag + "&sid=" + sid + "&daybefore=" + daybefore;

                newRow += "<td>" + QueryAnalyze1(sid, level, tag, old, daybefore) + "</td>";
                //newRow += "<td>" + data[i].rank + "</td>";
                newRow += "<td>" + data[i].value + "</td>";

                //财务信息

                InfoExtData data1 = BizApi.QueryInfoExtById(sid);

                newRow += "<td>" + data1.shiyinglv + "</td>";
                newRow += "<td>" + data1.shijinglv + "</td>";
                newRow += "<td>" + data1.jingzichan + "</td>";
                newRow += "<td>" + data1.shourutongbi + "</td>";
                newRow += "<td>" + data1.jingliruntongbi + "</td>";
                newRow += "<td>" + data1.meiguweifenpeilirun + "</td>";
                newRow += "<td>" + data1.zongguben + "</td>";
                newRow += "<td>" + data1.liutonggu + "</td>";

                //最新价格
                newRow += "<td>" + BizApi.QueryLatestPrice(sid, tag) + "</td>";

                //价格范围
                newRow += "<td>" + BizApi.QueryMaxMinPriceByRange(sid, 12) + "</td>";
            }

            return(newRow);
        }
Exemplo n.º 8
0
        public static InfoData BuildBasicInfo(InfoData id)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();

            WebClient client = new WebClient();

            byte[] page = client.DownloadData(string.Format("http://stockpage.10jqka.com.cn/{0}/company/", BizCommon.ProcessStockId(id.sid)));

            string content = System.Text.Encoding.UTF8.GetString(page);

            //string content = "成交额:1.62 亿元";

            string[] match = { @"所属地域:", @"所属行业:" };


            Regex           re      = new Regex(match[0] + "</strong><span>(.*)</span>");
            MatchCollection matches = re.Matches(content);
            string          value   = matches.Count > 0 ? matches[0].Groups[1].Value : "empty";

            id.location = value;

            Regex           re1      = new Regex(match[1] + "</strong><span>(.*)</span>");
            MatchCollection matches1 = re1.Matches(content);
            string          value1   = matches1.Count > 0 ? matches1[0].Groups[1].Value : "empty";

            if (value1.Equals("-"))
            {
                string[] list = value1.Split('—');

                id.firstlevel  = "";
                id.secondlevel = "";
            }
            else
            {
                string[] list = value1.Split('—');

                id.firstlevel  = string.IsNullOrEmpty(list[0]) ? "" : list[0].Trim();
                id.secondlevel = string.IsNullOrEmpty(list[1]) ? "" : list[1].Trim();
            }
            return(id);
        }
Exemplo n.º 9
0
        public static InfoData BuildShare(InfoData id)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();
            WebClient client = new WebClient();

            // Stream data = client.OpenRead(string.Format("http://stockpage.10jqka.com.cn/{0}/company/", stock));
            // StreamReader reader = new StreamReader(data);
            //string s = reader.ReadToEnd();
            byte[] page = client.DownloadData(string.Format("http://stockpage.10jqka.com.cn/{0}/holder/", BizCommon.ProcessStockId(id.sid)));

            string content = System.Text.Encoding.UTF8.GetString(page);

            //string content = "成交额:1.62 亿元";

            string[] match = { @"前十大流通股东累计持有:<em>(.*)</em>万股", @"累计占流通股比:<em>(.*)%</em>", @"前十大股东累计持有:<em>(.*)</em>万股", @"累计占总股本比:<em>(.*)%</em>" };

            string[] values = new string[match.Length];
            for (int i = 0; i < match.Length; i++)
            {
                Regex           re      = new Regex(match[i]);
                MatchCollection matches = re.Matches(content);
                values[i] = matches.Count > 0 ? matches[0].Groups[1].Value : "empty";
            }
            for (int j = 0; j < values.Length; j++)
            {
                values[j] = values[j] == "empty" ? "1" : values[j];
            }
            decimal floatshare = (Decimal.Parse(values[0]) / Decimal.Parse(values[1] == "empty" ? "1" : values[1]) * 100);

            id.totalshare = (Double)(Decimal.Parse(values[2]) / Decimal.Parse(values[3]) * 100);
            id.floatshare = (Double)floatshare;
            id.top10total = Decimal.Parse(values[1]);
            id.top10float = Decimal.Parse(values[3]);
            id.weight     = GetWeight(floatshare);
            int w = (int)Math.Round(id.weight * 10);

            id.list = string.Format("{0},{1},{2}", 50 * w, 100 * w, 200 * w);
            if (id.totalshare == 100f || id.floatshare == 100f)
            {
                id.valid = 0;
            }
            else
            {
                id.valid = 1;
            }
            return(id);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 返回输出参数
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public JObject GetSchema(HttpContext context)
        {
            JObject obj = new JObject();

            try
            {
                YZRequest request = new YZRequest(context);
                //获取数据连接信息
                int             connectId = request.GetInt32("connectId");
                ConnectInfo     con       = ConnectInfoManager.GetConnectInfo(connectId);
                WebServiceLogin login     = JObject.Parse(con.connectStr).ToObject <WebServiceLogin>();
                ISourceHandle   handle    = new WebServiceHandle(login);
                //获取接口信息
                string          functionName = request.GetString("functionName");
                QueryDepictInfo info         = handle.GetQueryInfo(functionName);

                //获取输入值
                StreamReader reader = new StreamReader(context.Request.InputStream);
                using (JsonTextReader streamReader = new JsonTextReader(reader))
                {
                    //获取参数配置
                    JsonSerializer serializer = new JsonSerializer();
                    JArray         array      = serializer.Deserialize(streamReader) as JArray;
                    //清空输入参数原始值
                    CommonHandle.ClearParameter(info.parameter);
                    //更新输入参数
                    foreach (JObject item in array)
                    {
                        ColumnInfo column = info.parameter.First(n => n.columnName == item["columnName"].ToString());
                        SetParameterValue(column, item);
                    }
                }
                //如果输入参数无法识别
                if (CommonHandle.IsSchemaNoType(info.schema))
                {
                    //当输出参数无法识别通过访问再次进行解析
                    info = handle.GetQueryInfo(info);
                }
                //返回输出参数结构
                JArray schemaArray = new JArray();
                obj["schema"] = schemaArray;
                if (info.schema != null && info.schema.Count > 0)
                {
                    foreach (var item in info.schema)
                    {
                        schemaArray.Add(BizCommon.GetColumnJson(item));
                    }
                    obj[YZJsonProperty.success] = true;
                }
                else
                {
                    obj[YZJsonProperty.success]      = false;
                    obj[YZJsonProperty.errorMessage] = "该接口没有返回值,不可调用!";
                }
                return(obj);
            }
            catch (Exception ex)
            {
                obj[YZJsonProperty.success]      = false;
                obj[YZJsonProperty.errorMessage] = ex.ToString();
                return(obj);
            }
        }
Exemplo n.º 11
0
        public static InfoExtData1 QueryInfoExtFromTonghuashun(string sid)
        {
            InfoExtData1 ifd = new InfoExtData1();

            ifd.sid = sid;
            //Console.WriteLine("start");
            try
            {
                string       url      = "http://stockpage.10jqka.com.cn/" + BizCommon.ProcessStockId(sid);
                WebClient    client   = new WebClient();
                byte[]       gg       = client.DownloadData(url);
                string       haha     = System.Text.Encoding.UTF8.GetString(gg);
                TextReader   stream   = new StringReader(haha);
                HtmlDocument document = new HtmlDocument();
                document.Load(stream);

                HtmlNode           rootNode = document.DocumentNode;
                HtmlNodeCollection c        = rootNode.SelectNodes("//dl[@class='company_details']");

                //处理html
                string innerString = c[0].InnerText;
                innerString = innerString.Replace(System.Environment.NewLine, "");
                innerString = innerString.Replace("\t", " ");
                innerString = System.Text.RegularExpressions.Regex.Replace(innerString, @"\s{1,}", " ", RegexOptions.IgnoreCase);
                innerString = innerString.Replace(": ", ":");

                string[] array = innerString.Split(' ');
                foreach (string item in array)
                {
                    if (item.Trim().Length > -1 && item.IndexOf(":") > -1)
                    {
                        string[] bb = item.Split(':');
                        switch (bb[0].Trim())
                        {
                        case "总股本":     //亿股
                            ifd.zongguben = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                            break;

                        case "流通股":    //亿股
                            ifd.liutonggu = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                            break;

                        case "营业收入增长率":
                            ifd.yingyeshouruzengzhanglv = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                            break;

                        case "营业收入":     //亿元
                            ifd.yingyeshouru = decimal.Parse(bb[1].Substring(0, bb[1].Length - 2));
                            break;

                        case "净利润":    //亿元
                            ifd.jinglirun = decimal.Parse(bb[1].Substring(0, bb[1].Length - 2));
                            break;

                        case "净利润增长率":
                            ifd.jinglirunzengzhanglv = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                            break;

                        case "每股收益":    //元
                            ifd.meigujingzichan = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                            break;

                        case "每股净资产":    //元
                            ifd.meigujingzichan = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                            break;

                        case "净资产收益率":
                            ifd.jingzichanshouyilv = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                            break;

                        case "每股现金流":    //元
                            ifd.meiguxianjinliu = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                            break;

                        case "每股公积金":    //元
                            ifd.meigugongjijin = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                            break;

                        case "每股未分配利润":    //元
                            ifd.meiguweifenpeilirun = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                            break;
                        }
                    }
                }
            }
            catch
            {
                StockLog.Log.Error(sid + " infoext import fail");
            }

            return(ifd);
        }