Esempio n. 1
0
        private void button14_Click(object sender, EventArgs e)
        {
            var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
            var symbol = "CEO_00662";
            var sql = new SqlDb();
            #region CEO

            var ceokey = string.Format(RedisKey.CeoKey, symbol);
            var cdt = sql.GetCeosNew_Profile(symbol);
            if (cdt.Rows.Count == 0)
            {
                if (redis.ContainsKey(ceokey)) redis.Remove(ceokey);
            }
            else
            {
                var ceo = new Ceo();
                ceo.CeoName = cdt.Rows[0]["CeoName"].ToString(); ceo.CeoBirthday = cdt.Rows[0]["CeoBirthday"].ToString(); ceo.CeoIdNo = cdt.Rows[0]["CeoIdNo"].ToString(); ceo.CeoAchievements = cdt.Rows[0]["CeoAchievements"].ToString(); ceo.CeoHomeTown = cdt.Rows[0]["CeoHomeTown"].ToString(); ceo.CeoSchoolDegree = cdt.Rows[0]["CeoLevel"].ToString();
                ceo.CeoCode = cdt.Rows[0]["CeoCode"].ToString();
                if (ceo.CeoBirthday != "" && ceo.CeoBirthday.Contains("/"))
                {
                    ceo.CeoBirthday = ceo.CeoBirthday.Substring(ceo.CeoBirthday.LastIndexOf("/") + 1);
                }
                ceo.CeoImage = "";
                //photo
                //school title
                var css = new List<CeoSchool>();
                var sdt = sql.GetCeosNew_School(symbol);
                foreach (DataRow sdr in sdt.Rows)
                {
                    css.Add(new CeoSchool() { CeoTitle = sdr["CeoTitle"].ToString(), SchoolTitle = sdr["SchoolTitle"].ToString(), SchoolYear = sdr["SchoolYear"].ToString() });
                }
                ceo.CeoSchool = css;

                //ceo position
                var cps = new List<CeoPosition>();
                var pdt = sql.GetCeosNew_Position(symbol);
                foreach (DataRow pdr in pdt.Rows)
                {
                    var cp = new CeoPosition() { PositionTitle = pdr["PositionTitle"].ToString(), PositionCompany = pdr["PositionCompany"].ToString() };
                    if (string.IsNullOrEmpty(cp.PositionTitle)) cp.PositionTitle = pdr["PositionName"].ToString();
                    if (string.IsNullOrEmpty(cp.PositionCompany)) cp.PositionCompany = pdr["FullName"].ToString();

                    //__/01/2007
                    string cpd = pdr["CeoPosDate"].ToString();
                    if (cpd.Contains("/"))
                    {
                        int day, month, year;
                        if (!int.TryParse(cpd.Substring(0, cpd.IndexOf("/")), out day)) day = 0;
                        cpd = cpd.Substring(cpd.IndexOf("/") + 1);
                        if (!int.TryParse(cpd.Substring(0, cpd.IndexOf("/")), out month)) month = 0;
                        cpd = cpd.Substring(cpd.IndexOf("/") + 1);
                        if (!int.TryParse(cpd, out year)) year = 0;
                        if (year == 0)
                        {
                            cp.CeoPosDate = "";
                        }
                        else if (day == 0 && month == 0)
                        {
                            cp.CeoPosDate = "" + year;
                        }
                        else if (month > 0 && day == 0)
                        {
                            cp.CeoPosDate = month + "/" + year;
                        }
                        else if (day > 0 && month > 0)
                        {
                            cp.CeoPosDate = day + "/" + month + "/" + year;
                        }
                        else
                        {
                            cp.CeoPosDate = "";
                        }
                    }

                    cps.Add(cp);
                }
                ceo.CeoPosition = cps;

                //asset
                var cas = new List<CeoAsset>();
                var adt = sql.GetCeosNew_Asset(symbol);
                foreach (DataRow adr in adt.Rows)
                {
                    cas.Add(new CeoAsset() { Symbol = adr["Symbol"].ToString(), AssetVolume = double.Parse(adr["AssetVolume"].ToString()).ToString("#,##0"), UpdatedDate = ((DateTime)adr["UpdatedDate"]).ToString("MM/yyyy") });
                }
                ceo.CeoAsset = cas;

                //relation
                var crs = new List<CeoRelation>();
                var rdt = sql.GetCeosNew_Relation(symbol);
                foreach (DataRow rdr in rdt.Rows)
                {
                    crs.Add(new CeoRelation() { Symbol = rdr["Symbol"].ToString(), AssetVolume = double.Parse(rdr["AssetVolume"].ToString()).ToString("#,##0"), UpdatedDate = ((DateTime)rdr["UpdatedDate"]).ToString("MM/yyyy"), Name = rdr["CeoName"].ToString(), CeoCode = rdr["CeoCode"].ToString(), RelationTitle = rdr["RelationTitle"].ToString() });
                }
                ceo.CeoRelation = crs;

                //process
                var cos = new List<CeoProcess>();
                var odt = sql.GetCeosNew_Process(symbol);
                foreach (DataRow odr in odt.Rows)
                {
                    cos.Add(new CeoProcess() { ProcessBegin = odr["ProcessBegin"].ToString(), ProcessEnd = odr["ProcessEnd"].ToString(), ProcessDesc = odr["ProcessDesc"].ToString(), Symbol = odr["Symbol"].ToString()});
                }
                ceo.CeoRelation = crs;

                //news
                var cns = new List<CeoNews>();
                var wdt = sql.GetCeosNew_News(symbol);
                var ids = "";
                foreach (DataRow ndr in wdt.Rows)
                {
                    ids += "," + ndr["NewsId"];
                }
                var wdt2 = sql.GetCeosNew_NewsDetail(ids);
                foreach (DataRow ndr in wdt2.Rows)
                {
                    cns.Add(new CeoNews() { Title = ndr["News_Title"].ToString(), PublishDate = (DateTime)ndr["News_PublishDate"], NewsLink = string.Format("/{0}CA{1}/{2}.chn", ndr["News_Id"], ndr["Cat_ID"], CafeF.Redis.BL.Utils.UnicodeToKoDauAndGach(ndr["News_Title"].ToString())) });
                }
                ceo.CeoRelation = crs;

                if (redis.ContainsKey(ceokey))
                {
                    redis.Set(ceokey, ceo);
                }
                else
                {
                    redis.Add(ceokey, ceo);
                }
            }
            #endregion
        }