本文整理汇总了C#中ServiceStack.Redis.RedisClient.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# RedisClient.ContainsKey方法的具体用法?C# RedisClient.ContainsKey怎么用?C# RedisClient.ContainsKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceStack.Redis.RedisClient
的用法示例。
在下文中一共展示了RedisClient.ContainsKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessRequest
public void ProcessRequest(HttpContext context)
{
var land = (context.Request["land"] ?? "").ToLower() == "true";
var image = context.Request["image"] ?? "";
var width = context.Request["width"] ?? "0";
var height = context.Request["height"] ?? "0";
var redis = new RedisClient(ConfigurationManager.AppSettings["ServerRedisMaster"] ?? "", int.Parse(ConfigurationManager.AppSettings["PortRedisMaster"] ?? "0"));
var key = string.Format("storage:imagehandler:{0}", image);
var done = (redis.ContainsKey(key) && !string.IsNullOrEmpty(redis.Get<string>(key) ?? ""));
var noimage = ConfigurationManager.AppSettings["StorageNoImage"] ?? "Common/CEO/noimage.jpg";
//var file = ConfigurationManager.AppSettings["StorageNoImage"] ?? "Common/CEO/noimage.jpg";
var imgPath = ConfigurationManager.AppSettings["imgPath"] ?? "http://images1.cafef.vn/";
var storageServer = ConfigurationManager.AppSettings["StorageServer"] ?? "http://testcafef.vcmedia.vn/";
string imageSrc = storageServer + noimage;
if (!done)
{
if (!string.IsNullOrEmpty(image))
{
imgPath += (land ? "batdongsan/" : "");
if (image.StartsWith(imgPath) && StorageUtils.Utils.checkImageExtension(image))
{
if (StorageUtils.Utils.UploadSiteImage(image, imgPath, (land ? "Common/BDS/" : "")) == "Storage : OK")
{
//file = image.Replace(imgPath, "");
}
}
}
int iw, ih;
if (!int.TryParse(width, out iw)) iw = 0;
if (!int.TryParse(height, out ih)) ih = 0;
imageSrc = image.Contains(imgPath) ? image : (imgPath + image); //GetStorageImage(file, iw, ih, land);
if (!CheckFileExist(imageSrc))
{
imageSrc = storageServer + noimage;
}
if (redis.ContainsKey(key))
redis.Set(key, imageSrc, new TimeSpan(0, 5, 0));
else
redis.Add(key, imageSrc, new TimeSpan(0, 5, 0));
}
else
{
imageSrc = redis.Get<string>(key) ?? (storageServer + noimage);
}
context.Response.ContentType = StorageUtils.Utils.MimeType(imageSrc);
context.Response.Redirect(imageSrc);
//context.Response.BinaryWrite(StorageUtils.Utils.GetFileBinary("", imageSrc));
}
示例2: button2_Click
private void button2_Click(object sender, EventArgs e)
{
var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
var id = "58231";
var compactkey = string.Format(RedisKey.KeyCompanyNewsCompact, id);
if (redis.ContainsKey(compactkey))
redis.Remove(compactkey);
var detailkey = string.Format(RedisKey.KeyCompanyNewsDetail, id);
if (redis.ContainsKey(detailkey))
redis.Remove(detailkey);
}
示例3: button1_Click
private void button1_Click(object sender, EventArgs e)
{
//var ls = GetTopBCTC("SSI", "BSheet", 2011, 1, 4);
var log = new LogUtils(LogType.TextLog, true, AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"log\");
var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
var symbols = SqlDb.GetBCTCSymbols();
textBox1.Text = "Begin : " + DateTime.Now.ToString() + Environment.NewLine;
var types = new List<string>() {"IncSta", "BSheet", "CashFlow", "CashFlowDirect"};
foreach (DataRow dr in symbols.Rows)
{
var symbol = dr["Symbol"].ToString();
//if(symbol!="SSI") continue;
textBox1.Text += symbol + ",";
log.WriteEntry(symbol + ",", EventLogEntryType.Warning);
for(var year = 2005; year <= 2011; year++)
{
for(var quarter = 0; quarter<=4; quarter++)
{
if(year==2011 && quarter!= 1) continue;
foreach (var type in types)
{
var o = GetBCTC(symbol, type, year, quarter);
if(o==null) continue;
var key = string.Format(RedisKey.BCTCKey, symbol.ToUpper(), type.ToUpper(), quarter == 0 ? 0 : 1, year, quarter);
if (redis.ContainsKey(key))
redis.Set(key, o);
else
redis.Add(key, o);
Thread.Sleep(1000);
}
}
}
}
textBox1.Text += "End : " + DateTime.Now.ToString() + Environment.NewLine;
}
示例4: button6_Click
private void button6_Click(object sender, EventArgs e)
{
var symbol = "PTC";
var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
var keylist = string.Format(RedisKey.InternalHistoryKeys, symbol);
//var ls = redis.ContainsKey(keylist) ? redis.Get<List<String>>(keylist) : new List<string>();
var ls = new List<string>();
var pdt = SqlDb.GetInternalHistory(symbol, -1);
foreach (DataRow pdr in pdt.Rows)
{
var key = string.Format(RedisKey.InternalHistory, symbol, (((DateTime?)pdr["NgayThongBao"]) ?? DateTime.Now).ToString("yyyyMMdd"), pdr["ID"], pdr["ShareHolder_ID"]);
var order = new InternalHistory() { Stock = symbol, TransactionMan = pdr["FullName"].ToString(), TransactionManPosition = pdr["ChucVu"].ToString(), RelatedMan = pdr["NguoiLienQuan"].ToString(), RelatedManPosition = pdr["ChucVuNguoiLienQuan"].ToString(), VolumeBeforeTransaction = double.Parse(pdr["SLCPTruocGD"].ToString()), PlanBuyVolume = double.Parse(pdr["DangKy_Mua"].ToString()), PlanSellVolume = double.Parse(pdr["DangKy_Ban"].ToString()), PlanBeginDate = pdr["DangKy_TuNgay"].Equals(DBNull.Value) ? null : (DateTime?)pdr["DangKy_TuNgay"], PlanEndDate = pdr["DangKy_DenNgay"].Equals(DBNull.Value) ? null : (DateTime?)pdr["DangKy_DenNgay"], RealBuyVolume = double.Parse(pdr["ThucHien_Mua"].ToString()), RealSellVolume = double.Parse(pdr["ThucHien_Ban"].ToString()), RealEndDate = pdr["ThucHien_NgayKetThuc"].Equals(DBNull.Value) ? null : (DateTime?)pdr["ThucHien_NgayKetThuc"], PublishedDate = pdr["NgayThongBao"].Equals(DBNull.Value) ? null : (DateTime?)pdr["NgayThongBao"], VolumeAfterTransaction = double.Parse(pdr["SLCPSauGD"].ToString()), TransactionNote = pdr["GhiChu"].ToString() };
if (redis.ContainsKey(key))
redis.Set<InternalHistory>(key, order);
else
redis.Add<InternalHistory>(key, order);
if (!ls.Contains(key)) ls.Add(key);
}
ls.Sort();
ls.Reverse();
if (redis.ContainsKey(keylist))
redis.Set<List<string>>(keylist, ls);
else
redis.Add<List<string>>(keylist, ls);
var test = redis.Get<List<string>>(keylist);
}
示例5: button7_Click
private void button7_Click(object sender, EventArgs e)
{
var symbol = "SSI";
var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
var keylist = string.Format(RedisKey.FundHistoryKeys, "SSI");
var ls = redis.ContainsKey(keylist) ? redis.Get<List<String>>(keylist) : new List<string>();
var pdt = SqlDb.GetFundHistory(symbol, -1);
foreach (DataRow pdr in pdt.Rows)
{
var key = string.Format(RedisKey.FundHistory, "SSI", ((DateTime)pdr["TradingDate"]).ToString("yyyyMMdd"));
var order = new FundHistory() { Symbol = symbol, TradeDate = (DateTime)pdr["TradingDate"], TransactionType = pdr["Buy_Sale"].ToString() == "s" ? "Bán" : "Mua", PlanVolume = double.Parse(pdr["RegisteredVol"].ToString()), TodayVolume = double.Parse(pdr["TodayTradingVol"].ToString()), AccumulateVolume = double.Parse(pdr["AccumVol"].ToString()), ExpiredDate = (DateTime)pdr["ExpireDate"] };
if (redis.ContainsKey(key))
redis.Set<FundHistory>(key, order);
else
redis.Add<FundHistory>(key, order);
if (!ls.Contains(key)) ls.Add(key);
}
ls.Sort();
ls.Reverse();
if (redis.ContainsKey(keylist))
redis.Set<List<string>>(keylist, ls);
else
redis.Add<List<string>>(keylist, ls);
var test = redis.Get<List<string>>(keylist);
}
示例6: UpdateBoxHangHoa
public void UpdateBoxHangHoa()
{
try
{
if ((ConfigurationManager.AppSettings["ProductBoxAllowance"] ?? "") != "TRUE")
{
return;
}
var tabVN = new List<string>() { ChiTieuCrawler.TabVietnam.VangTheGioi, ChiTieuCrawler.TabVietnam.VangSJC, ChiTieuCrawler.TabVietnam.USDSIN, ChiTieuCrawler.TabVietnam.USDHKD, ChiTieuCrawler.TabVietnam.CNY, ChiTieuCrawler.TabVietnam.BangAnh, ChiTieuCrawler.TabVietnam.USDVCB, ChiTieuCrawler.TabVietnam.EURVCB }; /*, ChiTieuCrawler.TabVietnam.USDtudo, ChiTieuCrawler.TabVietnam.EURtudo*/
var tabTG = new List<string>() { ChiTieuCrawler.TabTheGioi.USDIndex, ChiTieuCrawler.TabTheGioi.DowJones, ChiTieuCrawler.TabTheGioi.Nasdaq, ChiTieuCrawler.TabTheGioi.SP500, ChiTieuCrawler.TabTheGioi.FTSE100, ChiTieuCrawler.TabTheGioi.DAX, ChiTieuCrawler.TabTheGioi.Nikkei225, ChiTieuCrawler.TabTheGioi.HangSeng, ChiTieuCrawler.TabTheGioi.StraitTimes };
var tabHH = new List<string>() { ChiTieuCrawler.TabHangHoa.CrudeOil, ChiTieuCrawler.TabHangHoa.NaturalGas, ChiTieuCrawler.TabHangHoa.Gold, ChiTieuCrawler.TabHangHoa.Copper, ChiTieuCrawler.TabHangHoa.Silver, ChiTieuCrawler.TabHangHoa.Corn, ChiTieuCrawler.TabHangHoa.Sugar, ChiTieuCrawler.TabHangHoa.Coffee, ChiTieuCrawler.TabHangHoa.Cotton, ChiTieuCrawler.TabHangHoa.RoughRice, ChiTieuCrawler.TabHangHoa.Wheat, ChiTieuCrawler.TabHangHoa.Soybean, ChiTieuCrawler.TabHangHoa.Ethanol };
var tabMobile = new List<string>() { ChiTieuCrawler.TabMobile.VangSJC, ChiTieuCrawler.TabMobile.USDVCB, ChiTieuCrawler.TabMobile.VangTD, ChiTieuCrawler.TabMobile.USDTD };
var bFirstTime = true;
while (ServiceStarted)
{
try
{
var dt = SqlDb.GetCrawlerData();
var manual = SqlDb.GetManualProductData();
var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
#region Tab Viet Nam
//tab vietnam
var key = string.Format(RedisKey.KeyProductBox, 1);
var ls = redis.ContainsKey(key) ? redis.Get<List<ProductBox>>(key) : new List<ProductBox>();
var data = new List<ProductBox>();
ProductBox box, newbox, otherbox;
foreach (var item in tabVN)
{
if (int.Parse(item) < 0)
{
newbox = otherbox = null;
box = FindBox(item, ls);
otherbox = null;
if (manual.Rows.Count > 0)
{
switch (item)
{
case ChiTieuCrawler.TabVietnam.EURtudo:
if (double.Parse(manual.Rows[0]["Price_EURO"].ToString()) == 0) continue;
otherbox = new ProductBox() { ProductName = "EUR (tự do)", CurrentPrice = double.Parse(manual.Rows[0]["Price_EURO"].ToString()), OtherPrice = double.Parse(manual.Rows[0]["Price_Euro_Sale"].ToString()), PrevPrice = 0, UpdateDate = DateTime.Now, DbId = "-2" };
break;
case ChiTieuCrawler.TabVietnam.USDtudo:
if (double.Parse(manual.Rows[0]["Price_USD"].ToString()) == 0) continue;
otherbox = new ProductBox() { ProductName = "USD (tự do)", CurrentPrice = double.Parse(manual.Rows[0]["Price_USD"].ToString()), OtherPrice = double.Parse(manual.Rows[0]["Price_USD_Sale"].ToString()), PrevPrice = 0, UpdateDate = DateTime.Now, DbId = "-1" };
break;
}
}
if (otherbox != null)
{
otherbox.UpdatePrevPrice(bFirstTime ? null : box);
data.Add(otherbox);
}
continue;
}
var drs = dt.Select("ID=" + item);
if (drs.Length == 0) continue;
var dr = drs[0];
try
{
newbox = otherbox = null;
box = FindBox(dr["ID"].ToString(), ls);
switch (dr["ID"].ToString())
{
case ChiTieuCrawler.TabVietnam.VangTheGioi:
newbox = new ProductBox() { ProductName = "Vàng TG(USD)", CurrentPrice = double.Parse(dr["MuaVao"].ToString()), OtherPrice = 0, PrevPrice = double.Parse(dr["MuaVao"].ToString()) - double.Parse(dr["ThayDoi"].ToString()), UpdateDate = DateTime.Now, DbId = box.DbId };
break;
case ChiTieuCrawler.TabVietnam.VangSJC:
newbox = new ProductBox() { ProductName = "Vàng SJC", CurrentPrice = double.Parse(dr["MuaVao"].ToString().Replace(",", "")), OtherPrice = double.Parse(dr["BanRa"].ToString().Replace(",", "")), PrevPrice = 0, UpdateDate = DateTime.Now, DbId = box.DbId };
break;
case ChiTieuCrawler.TabVietnam.USDVCB:
newbox = new ProductBox() { ProductName = "USD (VCB)", CurrentPrice = double.Parse(dr["MuaVao"].ToString().Replace(",", "")), OtherPrice = double.Parse(dr["BanRa"].ToString().Replace(",", "")), PrevPrice = 0, UpdateDate = DateTime.Now, DbId = box.DbId };
break;
case ChiTieuCrawler.TabVietnam.EURVCB:
newbox = new ProductBox() { ProductName = "EUR (VCB)", CurrentPrice = double.Parse(dr["MuaVao"].ToString().Replace(",", "")), OtherPrice = double.Parse(dr["BanRa"].ToString().Replace(",", "")), PrevPrice = 0, UpdateDate = DateTime.Now, DbId = box.DbId };
break;
case ChiTieuCrawler.TabVietnam.CNY:
newbox = new ProductBox() { ProductName = "CNY", CurrentPrice = double.Parse(dr["MuaVao"].ToString().Replace(",", "")), OtherPrice = double.Parse(dr["BanRa"].ToString().Replace(",", "")), PrevPrice = 0, UpdateDate = DateTime.Now, DbId = box.DbId };
break;
case ChiTieuCrawler.TabVietnam.USDSIN:
newbox = new ProductBox() { ProductName = "SGD", CurrentPrice = double.Parse(dr["MuaVao"].ToString().Replace(",", "")), OtherPrice = double.Parse(dr["BanRa"].ToString().Replace(",", "")), PrevPrice = 0, UpdateDate = DateTime.Now, DbId = box.DbId };
break;
case ChiTieuCrawler.TabVietnam.USDHKD:
newbox = new ProductBox() { ProductName = "HKD", CurrentPrice = double.Parse(dr["MuaVao"].ToString().Replace(",", "")), OtherPrice = double.Parse(dr["BanRa"].ToString().Replace(",", "")), PrevPrice = 0, UpdateDate = DateTime.Now, DbId = box.DbId };
break;
case ChiTieuCrawler.TabVietnam.BangAnh:
newbox = new ProductBox() { ProductName = "Bảng Anh", CurrentPrice = double.Parse(dr["MuaVao"].ToString().Replace(",", "")), OtherPrice = double.Parse(dr["BanRa"].ToString().Replace(",", "")), PrevPrice = 0, UpdateDate = DateTime.Now, DbId = box.DbId };
break;
default:
newbox = null;
break;
}
if (newbox != null)
{
if (newbox.DbId != ChiTieuCrawler.TabVietnam.VangTheGioi) newbox.UpdatePrevPrice(bFirstTime ? null : box);
data.Add(newbox);
}
}
catch (Exception ex) { log.WriteEntry("GetBox : " + dr["ID"] + ":" + ex.ToString(), EventLogEntryType.Error); }
//.........这里部分代码省略.........
示例7: button2_Click
private void button2_Click(object sender, EventArgs e)
{
var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
var sql = new SqlDb();
#region FN
try
{
var keylist = string.Format(RedisKey.KeyCompanyNewsByCate, 0); //Tất cả
var ls = new List<string>();
var pdt = sql.GetCompanyNews("A", 1000);
var key1 = string.Format(RedisKey.KeyCompanyNewsByCate, 1); //Tình hình SXKD & Phân tích khác
var key2 = string.Format(RedisKey.KeyCompanyNewsByCate, 2); // Cổ tức - Chốt quyền
var key3 = string.Format(RedisKey.KeyCompanyNewsByCate, 3); // Thay đổi nhân sự
var key4 = string.Format(RedisKey.KeyCompanyNewsByCate, 4); // Tăng vốn - Cổ phiếu quỹ
var key5 = string.Format(RedisKey.KeyCompanyNewsByCate, 5); // GD cđ lớn & cđ nội bộ
var cate1 = (redis.ContainsKey(key1)) ? redis.Get<List<string>>(key1) : new List<string>();
var cate2 = (redis.ContainsKey(key2)) ? redis.Get<List<string>>(key2) : new List<string>();
var cate3 = (redis.ContainsKey(key3)) ? redis.Get<List<string>>(key3) : new List<string>();
var cate4 = (redis.ContainsKey(key4)) ? redis.Get<List<string>>(key4) : new List<string>();
var cate5 = (redis.ContainsKey(key5)) ? redis.Get<List<string>>(key5) : new List<string>();
foreach (DataRow rdr in pdt.Rows)
{
var compact = new StockNews() { ID = int.Parse(rdr["ID"].ToString()), Body = "", DateDeploy = (DateTime)rdr["PostTime"], Image = "", Title = rdr["title"].ToString(), Sapo = "", TypeID = rdr["ConfigId"].ToString(), Symbol = rdr["StockSymbols"].ToString() };
var obj = new StockNews() { ID = int.Parse(rdr["ID"].ToString()), Body = rdr["Content"].ToString(), DateDeploy = (DateTime)rdr["PostTime"], Image = rdr["ImagePath"].ToString(), Title = rdr["title"].ToString(), Sapo = rdr["SubContent"].ToString(), TypeID = rdr["ConfigId"].ToString(), Symbol = rdr["StockSymbols"].ToString() };
var key = obj.DateDeploy.ToString("yyyyMMddHHmm") + obj.ID;
var compactkey = string.Format(RedisKey.KeyCompanyNewsCompact, obj.ID);
if (redis.ContainsKey(compactkey))
redis.Set(compactkey, compact);
else
redis.Add(compactkey, compact);
var detailkey = string.Format(RedisKey.KeyCompanyNewsDetail, obj.ID);
if (redis.ContainsKey(detailkey))
redis.Set(detailkey, obj);
else
redis.Add(detailkey, obj);
if (!ls.Contains(key)) ls.Add(key);
#region Update category list
if (obj.TypeID.Contains("1"))
{
if (!cate1.Contains(key)) cate1.Add(key);
}
else
{
if (cate1.Contains(key)) cate1.Remove(key);
}
if (obj.TypeID.Contains("2"))
{
if (!cate2.Contains(key)) cate2.Add(key);
}
else
{
if (cate2.Contains(key)) cate2.Remove(key);
}
if (obj.TypeID.Contains("3"))
{
if (!cate3.Contains(key)) cate3.Add(key);
}
else
{
if (cate3.Contains(key)) cate3.Remove(key);
}
if (obj.TypeID.Contains("4"))
{
if (!cate4.Contains(key)) cate4.Add(key);
}
else
{
if (cate4.Contains(key)) cate4.Remove(key);
}
if (obj.TypeID.Contains("5"))
{
if (!cate5.Contains(key)) cate5.Add(key);
}
else
{
if (cate5.Contains(key)) cate5.Remove(key);
}
#endregion
}
ls.Sort();
ls.Reverse();
if (redis.ContainsKey(keylist))
redis.Set(keylist, ls);
else
redis.Add(keylist, ls);
#region Update category list
cate1.Sort();
cate1.Reverse();
if (redis.ContainsKey(key1))
redis.Set(key1, cate1);
else
redis.Add(key1, cate1);
cate2.Sort();
cate2.Reverse();
//.........这里部分代码省略.........
示例8: button15_Click
private void button15_Click(object sender, EventArgs e)
{
//Việt Nam
var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
var key = string.Format(RedisKey.KeyProductBox, 1);
var data = new List<ProductBox>();
data.Add(new ProductBox() { ProductName = "Vàng SJC", CurrentPrice = 37.330, OtherPrice = 37.420, PrevPrice = 36.95 });
data.Add(new ProductBox() { ProductName = "USD (VCB)", CurrentPrice = 20785, OtherPrice = 20885, PrevPrice = 20885 });
data.Add(new ProductBox() { ProductName = "USD (tự do)", CurrentPrice = 20785, OtherPrice = 20885, PrevPrice = 20885 });
data.Add(new ProductBox() { ProductName = "EUR (VCB)", CurrentPrice = 28494.07, OtherPrice = 29140.67, PrevPrice = 20885 });
data.Add(new ProductBox() { ProductName = "EUR (tự do)", CurrentPrice = 28494.07, OtherPrice = 29140.67, PrevPrice = 20885 });
data.Add(new ProductBox() { ProductName = "CNY", CurrentPrice = 3290, OtherPrice = 3310, PrevPrice = 3310 });
data.Add(new ProductBox() { ProductName = "USD Singapo", CurrentPrice = 16610, OtherPrice = 16839, PrevPrice = 16739 });
data.Add(new ProductBox() { ProductName = "USD Singapo", CurrentPrice = 16610, OtherPrice = 16839, PrevPrice = 16739 });
data.Add(new ProductBox() { ProductName = "USD Singapo", CurrentPrice = 16610, OtherPrice = 16839, PrevPrice = 16739 });
if (redis.ContainsKey(key))
redis.Set(key, data);
else
redis.Add(key, data);
}
示例9: UpdateKby
private void UpdateKby()
{
try
{
var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
//var pdt = bFirst ? sql.GetAllPrice(centerId) : sql.GetChangedPriceSymbols(centerId);
var sql = new SqlDb();
var dt = sql.GetKbyFolder();
if (redis.ContainsKey(RedisKey.KeyKby))
redis.Set(RedisKey.KeyKby, dt);
else
redis.Add(RedisKey.KeyKby, dt);
}
catch (Exception ex)
{
log.WriteEntry("UpdateKby : " + ex.ToString(), EventLogEntryType.Error);
}
}
示例10: button10_Click
private void button10_Click(object sender, EventArgs e)
{
var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
var keylist = RedisKey.KeyAnalysisReport;
var ls = new List<string>();
var rdt = SqlDb.GetAnalysisReports("A", -1);
foreach (DataRow rdr in rdt.Rows)
{
var key = string.Format(RedisKey.KeyAnalysisReportDetail, rdr["ID"]);
var obj = new Reports() { ID = int.Parse(rdr["ID"].ToString()), Body = rdr["Des"].ToString(), DateDeploy = (DateTime)rdr["PublishDate"], file = new FileObject() { FileName = rdr["FileName"].ToString(), FileUrl = "http://images1.cafef.vn/Images/Uploaded/DuLieuDownload/PhanTichBaoCao/" + rdr["FileName"] }, IsHot = (rdr["IsHot"].ToString() == "1"), ResourceCode = rdr["Source"].ToString(), Symbol = rdr["Symbol"].ToString(), Title = rdr["title"].ToString(), SourceID = int.Parse(rdr["SourceId"].ToString()), ResourceName = rdr["SourceFullName"].ToString(), ResourceLink = rdr["SourceUrl"].ToString() };
var cateId = 0;
if (!string.IsNullOrEmpty(obj.Symbol) && !obj.Symbol.Contains(","))
{
var stock = redis.Get<Stock>(string.Format(RedisKey.Key, obj.Symbol));
cateId = stock == null ? 0 : stock.CompanyProfile.basicInfos.category.ID;
}
obj.CategoryID = cateId;
if (redis.ContainsKey(key))
redis.Set(key, obj);
else
redis.Add(key, obj);
if (!ls.Contains(key)) ls.Add(key);
}
if (redis.ContainsKey(keylist))
redis.Set(keylist, ls);
else
redis.Add(keylist, ls);
}
示例11: UpdateList
private bool UpdateList(string updateKey, string related, string updateType, ref SqlDb sql)
{
var ret = true;
try
{
var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
var symbol = updateKey;
var date = "";
if (updateKey.Contains("."))
{
symbol = updateKey.Substring(0, updateKey.IndexOf("."));
date = updateKey.Substring(updateKey.IndexOf(".") + 1);
}
switch (related)
{
case "FP":
#region FP
try
{
var keylist = string.Format(RedisKey.PriceHistoryKeys, symbol);
var ls = redis.ContainsKey(keylist) ? redis.Get<List<String>>(keylist) : new List<string>();
//log.WriteEntry(symbol + "-price-" + DateTime.Now, EventLogEntryType.Information);
var pdt = (date == "" || ls.Count == 0) ? sql.GetPriceHistory(symbol, -1) : sql.GetPriceHistory(symbol, date);
//log.WriteEntry(symbol + "-price-" + DateTime.Now, EventLogEntryType.Information);
foreach (DataRow pdr in pdt.Rows)
{
var key = string.Format(RedisKey.PriceHistory, symbol, ((DateTime)pdr["TradeDate"]).ToString("yyyyMMdd"));
var price = new StockHistory() { TradeDate = (DateTime)pdr["TradeDate"], ClosePrice = double.Parse(pdr["ClosePrice"].ToString()), AveragePrice = double.Parse(pdr["AveragePrice"].ToString()), BasicPrice = double.Parse(pdr["BasicPrice"].ToString()), Ceiling = double.Parse(pdr["Ceiling"].ToString()), Floor = double.Parse(pdr["Floor"].ToString()), Volume = double.Parse(pdr["Volume"].ToString()), TotalValue = double.Parse(pdr["TotalValue"].ToString()), AgreedValue = double.Parse(pdr["AgreedValue"].ToString()), AgreedVolume = double.Parse(pdr["AgreedVolume"].ToString()), Symbol = symbol, KLGDDot1 = double.Parse(pdr["VolumePhase1"].ToString()), KLGDDot2 = double.Parse(pdr["VolumePhase2"].ToString()), KLGDDot3 = double.Parse(pdr["VolumePhase3"].ToString()), OpenPrice = double.Parse(pdr["OpenPrice"].ToString()), HighPrice = double.Parse(pdr["HighPrice"].ToString()), LowPrice = double.Parse(pdr["LowPrice"].ToString()) };
if (redis.ContainsKey(key))
redis.Set<StockHistory>(key, price);
else
redis.Add<StockHistory>(key, price);
if (!ls.Contains(key)) ls.Add(key);
}
ls.Sort();
ls.Reverse();
if (redis.ContainsKey(keylist))
redis.Set<List<string>>(keylist, ls);
else
redis.Add<List<string>>(keylist, ls);
}
catch (Exception ex)
{
log.WriteEntry(symbol + " : FP : " + ex.ToString(), EventLogEntryType.Error);
ret = false;
}
//var test = redis.Get<List<string>>(keylist);
#endregion
break;
case "FO":
#region FO
try
{
var keylist = string.Format(RedisKey.OrderHistoryKeys, symbol);
var ls = redis.ContainsKey(keylist) ? redis.Get<List<String>>(keylist) : new List<string>();
var pdt = (date == "" || ls.Count == 0) ? sql.GetOrderHistory(symbol, 1000) : sql.GetOrderHistory(symbol, date);
foreach (DataRow pdr in pdt.Rows)
{
var key = string.Format(RedisKey.OrderHistory, symbol, ((DateTime)pdr["Trading_Date"]).ToString("yyyyMMdd"));
var order = new OrderHistory() { TradeDate = (DateTime)pdr["Trading_Date"], BuyOrderCount = double.Parse(pdr["Bid_Order"].ToString()), BuyVolume = double.Parse(pdr["Bid_Volume"].ToString()), SellOrderCount = double.Parse(pdr["Offer_Order"].ToString()), SellVolume = double.Parse(pdr["Offer_Volume"].ToString()), Symbol = symbol }; //Volume = double.Parse(pdr["Volume"].ToString()), Price = double.Parse(pdr["Price"].ToString()), BasicPrice = double.Parse(pdr["BasicPrice"].ToString()), Ceiling = double.Parse(pdr["Ceiling"].ToString()), Floor = double.Parse(pdr["Floor"].ToString()),
if (redis.ContainsKey(key))
redis.Set<OrderHistory>(key, order);
else
redis.Add<OrderHistory>(key, order);
if (!ls.Contains(key)) ls.Add(key);
}
ls.Sort();
ls.Reverse();
if (redis.ContainsKey(keylist))
redis.Set<List<string>>(keylist, ls);
else
redis.Add<List<string>>(keylist, ls);
}
catch (Exception ex)
{
log.WriteEntry(symbol + " : FO : " + ex.ToString(), EventLogEntryType.Error);
ret = false;
}
#endregion
break;
case "FIT":
#region FIT
try
{
var keylist = string.Format(RedisKey.InternalHistoryKeys, symbol);
var ls = new List<string>(); //redis.ContainsKey(keylist) ? redis.Get<List<String>>(keylist) : new List<string>();
var pdt = sql.GetInternalHistory(symbol, -1);
foreach (DataRow pdr in pdt.Rows)
{
var key = string.Format(RedisKey.InternalHistory, symbol, (((DateTime?)pdr["NgayThongBao"]) ?? DateTime.Now).ToString("yyyyMMdd"), pdr["ID"], pdr["ShareHolder_ID"] + ":" + pdr["ShareHolderCode"]);
var order = new InternalHistory() { Stock = symbol, RelatedMan = pdr["NguoiLienQuan"].ToString(), RelatedManPosition = pdr["ChucVuNguoiLienQuan"].ToString(), VolumeBeforeTransaction = double.Parse(pdr["SLCPTruocGD"].ToString()), PlanBuyVolume = double.Parse(pdr["DangKy_Mua"].ToString()), PlanSellVolume = double.Parse(pdr["DangKy_Ban"].ToString()), PlanBeginDate = pdr["DangKy_TuNgay"].Equals(DBNull.Value) ? null : (DateTime?)pdr["DangKy_TuNgay"], PlanEndDate = pdr["DangKy_DenNgay"].Equals(DBNull.Value) ? null : (DateTime?)pdr["DangKy_DenNgay"], RealBuyVolume = double.Parse(pdr["ThucHien_Mua"].ToString()), RealSellVolume = double.Parse(pdr["ThucHien_Ban"].ToString()), RealEndDate = pdr["ThucHien_NgayKetThuc"].Equals(DBNull.Value) ? null : (DateTime?)pdr["ThucHien_NgayKetThuc"], PublishedDate = pdr["NgayThongBao"].Equals(DBNull.Value) ? null : (DateTime?)pdr["NgayThongBao"], VolumeAfterTransaction = double.Parse(pdr["SLCPSauGD"].ToString()), TransactionNote = pdr["GhiChu"].ToString(), HolderID = pdr["ShareHolder_ID"].ToString(), ShareHolderCode = pdr["ShareHolderCode"].ToString() }; //TransactionMan = pdr["FullName"].ToString(), TransactionManPosition = pdr["ChucVu"].ToString(),
//.........这里部分代码省略.........
示例12: button3_Click
private void button3_Click(object sender, EventArgs e)
{
var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
var keylist = RedisKey.KeyAnalysisReport;
var ls = (redis.ContainsKey(keylist)) ? redis.Get<List<string>>(keylist) : new List<string>();
ls.Sort();
ls.Reverse();
if (redis.ContainsKey(keylist))
redis.Set(keylist, ls);
else
redis.Add(keylist, ls);
}
示例13: UpdateStock
private bool UpdateStock(string symbol, List<string> related, ref SqlDb sql)
{
var ret = true;
//log.WriteEntry(symbol + "-1-" + ret, EventLogEntryType.Information);
try
{
var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
var key = string.Format(RedisKey.Key, symbol.ToUpper());
var bExisted = (redis.ContainsKey(key));
var stock = bExisted ? redis.Get<Stock>(key) : new Stock() { Symbol = symbol };
#region Update stock from sql
//stock.Symbol = "AAA";
//load stock data
//profile
var profile = bExisted ? stock.CompanyProfile : new CompanyProfile { Symbol = stock.Symbol };
var basicInfo = bExisted ? profile.basicInfos : new BasicInfo() { Symbol = stock.Symbol };
var basicCommon = bExisted ? profile.basicInfos.basicCommon : new BasicCommon() { Symbol = stock.Symbol };
var category = bExisted ? profile.basicInfos.category : new CategoryObject();
var firstInfo = bExisted ? profile.basicInfos.firstInfo : new FirstInfo() { Symbol = stock.Symbol };
var commonInfo = bExisted ? profile.commonInfos : new CommonInfo() { Symbol = stock.Symbol };
//basic information
#region SB
if (!bExisted || related.Contains("SB"))
{
try
{
var dt = sql.GetSymbolData(symbol);
if (dt.Rows.Count <= 0) return true;
var row = dt.Rows[0];
#region StockCompactInfo
var compactkey = string.Format(RedisKey.KeyCompactStock, symbol.ToUpper());
var compact = new StockCompactInfo() { Symbol = symbol.ToUpper(), TradeCenterId = int.Parse(row["TradeCenterId"].ToString()), CompanyName = row["CompanyName"].ToString(), EPS = double.Parse(row["EPS"].ToString()), FolderChart = row["FolderChart"].ToString(), ShowTradeCenter = row["ShowTradeCenter"].ToString().ToUpper() == "TRUE", IsBank = row["IsBank"].ToString().ToUpper() == "TRUE", IsCCQ = row["IsCCQ"].ToString().ToUpper() == "TRUE" };
if (redis.ContainsKey(compactkey))
redis.Set(compactkey, compact);
else
redis.Add(compactkey, compact);
#endregion
stock.Symbol = row["Symbol"].ToString();
stock.TradeCenterId = int.Parse(row["TradeCenterId"].ToString());
stock.IsDisabled = row["IsDisabled"].ToString() == "TRUE";
stock.StatusText = row["StatusText"].ToString();
stock.ShowTradeCenter = row["ShowTradeCenter"].ToString().ToUpper() == "TRUE";
stock.FolderImage = row["FolderChart"].ToString();
stock.IsBank = row["IsBank"].ToString() == "TRUE";
stock.IsCCQ = row["IsCCQ"].ToString().ToUpper() == "TRUE";
//profile - basicInfo
basicInfo.Name = row["CompanyName"].ToString();
basicInfo.TradeCenter = stock.TradeCenterId.ToString();
//profile - basicInfo - basicCommon
/*PE = double.Parse(row["PE"].ToString()),*/
basicCommon.AverageVolume = double.Parse(row["AVG10SS"].ToString());
basicCommon.Beta = double.Parse(row["Beta"].ToString());
basicCommon.EPS = double.Parse(row["EPS"].ToString());
basicCommon.TotalValue = double.Parse(row["MarketCap"].ToString());
basicCommon.ValuePerStock = double.Parse(row["BookValue"].ToString());
basicCommon.VolumeTotal = double.Parse(row["SLCPNY"].ToString());
basicCommon.OutstandingVolume = double.Parse(row["TotalShare"].ToString());
basicCommon.PE = basicCommon.EPS != 0 ? (double.Parse(row["LastPrice"].ToString()) / basicCommon.EPS) : 0;
basicCommon.EPSDate = row["EPSDate"].ToString();
basicCommon.CCQv3 = double.Parse(row["CCQv3"].ToString());
basicCommon.CCQv6 = double.Parse(row["CCQv6"].ToString());
basicCommon.CCQdate = DateTime.ParseExact(row["CCQdate"].ToString(), "yyyy.MM.dd", CultureInfo.InvariantCulture, DateTimeStyles.None);
basicInfo.basicCommon = basicCommon;
//profile - basicInfo - category
category.ID = int.Parse(row["CategoryId"].ToString());
category.Name = row["CategoryName"].ToString();
basicInfo.category = category;
//profile - basicInfo - firstInfo
firstInfo.FirstPrice = double.Parse(row["FirstPrice"].ToString());
firstInfo.FirstTrade = row["FirstTrade"].Equals(DBNull.Value) ? null : ((DateTime?)row["FirstTrade"]);
firstInfo.FirstVolume = double.Parse(row["FirstVolume"].ToString());
basicInfo.firstInfo = firstInfo;
profile.basicInfos = basicInfo;
//profile - commonInfo
commonInfo.Capital = double.Parse(row["VonDieuLe"].ToString());
commonInfo.Category = row["CategoryName"].ToString();
commonInfo.Content = row["About"].ToString();
commonInfo.OutstandingVolume = double.Parse(row["TotalShare"].ToString());
commonInfo.TotalVolume = double.Parse(row["SLCPNY"].ToString());
commonInfo.Content += "<p><b>Địa chỉ:</b> " + row["Address"].ToString() + "</p>";
commonInfo.Content += "<p><b>Điện thoại:</b> " + row["Phone"].ToString() + "</p>";
commonInfo.Content += "<p><b>Người phát ngôn:</b> " + row["Spokenman"].ToString() + "</p>";
if (!string.IsNullOrEmpty(row["Email"].ToString())) commonInfo.Content += "<p><b>Email:</b> <a href='mailto:" + row["Email"] + "'>" + row["Email"] + "</a></p>";
if (!string.IsNullOrEmpty(row["Website"].ToString())) commonInfo.Content += "<p><b>Website:</b> <a href='" + row["Website"] + "' target='_blank'>" + row["Website"] + "</a></p>";
commonInfo.AuditFirmName = row["AuditName"].ToString();
commonInfo.AuditFirmSite = row["AuditSite"].ToString().Trim();
commonInfo.ConsultantName = row["ConsultantName"].ToString();
commonInfo.ConsultantSite = row["ConsultantSite"].ToString();
commonInfo.BusinessLicense = row["BusinessLicense"].ToString();
//.........这里部分代码省略.........
示例14: UpdateCeoImage
public void UpdateCeoImage()
{
try
{
if ((ConfigurationManager.AppSettings["CeoImageAllowance"] ?? "") != "TRUE") return;
var bfirstTime = true;
//Thread.Sleep(index * 1000);
var sql = new SqlDb();
var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
while (ServiceStarted)
{
try
{
if (!bfirstTime) Thread.Sleep(reportInterval);
bfirstTime = false;
sql.OpenDb();
var ldt = sql.GetAllLandProjects();
//var cdt = sql.GetAllCeos();
sql.CloseDb();
landImages = GetAllLandImages();
var keys = redis.SearchKeys(string.Format(RedisKey.BDSKey, "*", "*"));
foreach(var key in keys)
{
var t = key.Substring(key.IndexOf(":tiendocode:"), key.IndexOf(":Object") - key.IndexOf(":tiendocode:")).Replace(":tiendocode:", "");
if (ldt.Select("MaTienDo = '" + t + "'").Length == 0)
{
redis.Remove(key);
continue;
}
var o = redis.Get<TienDoBDS>(key);
if(o==null) continue;
var s = o.MaTienDo;
if (string.IsNullOrEmpty(s)) continue;
o.BDSImages = landImages.FindAll(i => i.ToUpper().StartsWith(s));
redis.Set(key, o);
}
ceoPhotos = GetCeoPhotos();
foreach (var photo in ceoPhotos)
{
if (!photo.Contains(".")) continue;
var code = photo.Substring(0, photo.IndexOf("."));
if (redis.ContainsKey(string.Format(RedisKey.CeoImage, code)))
{
redis.Set(string.Format(RedisKey.CeoImage, code), photo);
}
else
{
redis.Add(string.Format(RedisKey.CeoImage, code), photo);
}
//var o = redis.Get<Ceo>(string.Format(RedisKey.CeoKey, code));
//if (o == null) continue;
//o.CeoImage = photo;
//redis.Set(string.Format(RedisKey.CeoKey, code), o);
}
var keywords = SqlDb.GetGoogleTag(-1);
var ls = new List<string>();
foreach (DataRow keyword in keywords.Rows)
{
if(!ls.Contains(keyword["keyword"].ToString())) ls.Add(keyword["keyword"].ToString());
}
//if (redis.ContainsKey(RedisKey.GoogleTag))
// redis.Set(RedisKey.GoogleTag, ls);
//else
// redis.Add(RedisKey.GoogleTag, ls);
}
catch (Exception ex)
{
log.WriteEntry("UpdateCeoImage - " + ex.ToString(), EventLogEntryType.Error);
}
}
}
catch (Exception ex)
{
log.WriteEntry("UpdateCeoImage - " + ex.ToString(), EventLogEntryType.Error);
}
}
示例15: GetBCTC
public void GetBCTC()
{
try
{
if ((ConfigurationManager.AppSettings["BCTCAllowance"] ?? "") != "TRUE") return;
var bfirstTime = true;
Thread.Sleep(index * 1000);
var sql = new SqlDb();
while (ServiceStarted)
{
try
{
if (!bfirstTime) Thread.Sleep(reportInterval);
bfirstTime = false;
//log.WriteEntry("BCTC : Started", EventLogEntryType.Information);
//string user = ConfigurationManager.AppSettings["user"]??"";
//string pass = ConfigurationManager.AppSettings["pass"]??"";
//string domain = ConfigurationManager.AppSettings["domain"]??"";
//log.WriteEntry("BCTC : " + user + "-" + pass + "-" + domain + "-" + (Update_DanhSach_BCTC.impersonateValidUser(user, domain, pass)), EventLogEntryType.Information);
var full = Update_DanhSach_BCTC.GetAllData();
if (full.Rows.Count == 0) continue;
//log.WriteEntry("BCTC : " + full.Rows[0]["Symbol"], EventLogEntryType.Information);
//sql.OpenDb();
//var sdt = sql.GetSymbolList(-1);
//sql.CloseDb();
var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
var sls = redis.Get<List<StockCompact>>(RedisKey.KeyStockList) ?? new List<StockCompact>();
foreach (var stock in sls)
{
var symbol = stock.Symbol;
//var obj = new FinanceReport() { Symbol = symbol, HtmlContent = Update_DanhSach_BCTC.ReturnHTML_BCTC(full.Select("Symbol = '" + symbol + "'")) };
var obj = Update_DanhSach_BCTC.ReturnHTML_BCTC(full.Select("Symbol = '" + symbol + "'"));
var key = String.Format(RedisKey.KeyFinanceReport, symbol);
if (redis.ContainsKey(key))
redis.Set(key, obj);
else
redis.Add(key, obj);
}
//log.WriteEntry("BCTC : Done", EventLogEntryType.Information);
}
catch (Exception ex)
{
log.WriteEntry(ex.ToString(), EventLogEntryType.Error);
}
}
}
catch (Exception ex)
{
log.WriteEntry(ex.ToString(), EventLogEntryType.Error);
}
finally
{
//Thread.CurrentThread.Abort();
}
}