/// <summary> /// 下拉框报告期数据源 /// </summary> /// <returns>下拉框报告期数据源</returns> public static DataTable QueryModReporttypexlk() { if (_modReporttypexlkDataTable != null) { return(_modReporttypexlkDataTable); } try { if (CommonService.ISCLIENT == ClientType.Config) { _modReporttypexlkDataTable = DataHelper.QueryData("MOD_REPORTTYPEXLK", null, null, null, null).Tables[0]; return(_modReporttypexlkDataTable); } //定义文件夹 String fileName = DataCenter.GetAppPath() + "\\NecessaryData\\MOD_REPORTTYPEXLK"; if (File.Exists(fileName)) { _modReporttypexlkDataTable = JSONHelper.DeserializeObject <DataSet>(File.ReadAllText(fileName)).Tables[0]; return(_modReporttypexlkDataTable); } return(DataHelper.QueryData("MOD_REPORTTYPEXLK", null, null, null, null).Tables[0]); } catch { return(DataHelper.QueryData("MOD_REPORTTYPEXLK", null, null, null, null).Tables[0]); } }
/// <summary> /// 加载 /// </summary> /// <param name="name">名称</param> public void LoadXml(String name) { if (name == "PlanWindow") { DataCenter.ExportService = new ExportService(); DataCenter.PlanService = new PlanService(); m_xml = new PlanWindow(); DataCenter.PlanWindow = m_xml as PlanWindow; } m_xml.CreateNative(); m_native = m_xml.Native; m_native.Paint = new GdiPlusPaintEx(); m_host = new WinHostEx(); m_host.Native = m_native; m_native.Host = m_host; m_host.HWnd = Handle; m_native.AllowScaleSize = true; m_native.DisplaySize = new SIZE(ClientSize.Width, ClientSize.Height); m_xml.ResetScaleSize(GetClientSize()); m_xml.Script = new GaiaScript(m_xml); m_xml.Native.ResourcePath = DataCenter.GetAppPath() + "\\config"; m_xml.Load(DataCenter.GetAppPath() + "\\config\\" + name + ".html"); m_host.ToolTip = new ToolTipA(); m_host.ToolTip.Font = new FONT("SimSun", 20, true, false, false); (m_host.ToolTip as ToolTipA).InitialDelay = 250; m_native.Update(); Invalidate(); }
static DataCenter() { String idFile = DataCenter.GetAppPath() + "\\config\\userid.txt"; String content = File.ReadAllText(idFile); users.AddRange(content.Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries)); }
/// <summary> /// 查询专题最大报告期数据源 /// </summary> /// <returns>专题最大报告期数据源</returns> public static DataTable QueryModMaxreportdate() { if (_modMaxreportdateDataTable != null) { return(_modMaxreportdateDataTable); } //while (!AppBaseServices.NecessaryDataIsLoaded) //{ // Thread.Sleep(10); //} try { if (CommonService.ISCLIENT == ClientType.Config) { return(DataHelper.QueryData("MOD_MAXREPORTDATE").Tables[0]); } //定义文件夹 String fileName = DataCenter.GetAppPath() + "\\NecessaryData\\MOD_MAXREPORTDATE"; if (File.Exists(fileName)) { _modMaxreportdateDataTable = JSONHelper.DeserializeObject <DataSet>(File.ReadAllText(fileName)).Tables[0]; return(_modMaxreportdateDataTable); } return(null); } catch { return(DataHelper.QueryData("MOD_MAXREPORTDATE").Tables[0]); } }
///// <summary> ///// 通过数据源名称进行数据查询 ///// </summary> ///// <param name="datasourcename">数据源名称</param> ///// <returns>数据表</returns> //public static DataTable QueryByDatasoureName(String datasourcename) //{ // DataSet ds = QueryData(datasourcename); // if (ds != null && ds.Tables.Count > 0) // return ds.Tables[0]; // else // return null; //} /// <summary> /// 查询专题分类 /// </summary> /// <returns>专题分类数据表</returns> public static DataTable QuerySpeicalTopicCatory() { //if (EmReportWatch.SpecialCommon.CommonService.ISCLIENT == ClientType.Config) //{ // return QueryByDatasoureName("MOD_STC_ALL"); if (CommonService.ISCLIENT == ClientType.Config) { List <String> feilds = new List <String>() { "CATEGORYCODE", "CATEGORYNAME", "PCATEGORYCODE", "SORTCODE" }; return(QueryData("MOD_STC_ALL", feilds.ToArray()).Tables[0]); } //} try { //定义文件夹 String fileName = DataCenter.GetAppPath() + "\\NecessaryData\\MOD_STC_ALL"; if (File.Exists(fileName)) { return(JSONHelper.DeserializeObject <DataSet>(File.ReadAllText(fileName)).Tables[0]); } return(null); } catch { return(null); } }
public static String QuerySpecialTreeData(String pid) { String path = DataCenter.GetAppPath() + @"\SpecialXmlData\"; Directory.CreateDirectory(path); path = path + pid; try { object obj2 = DataAccess.IDataQuery.NewQueryGlobalData("1005◎UID◎SpecialService◎◎◎1," + pid); String data = Encoding.UTF8.GetString(obj2 as byte[]); //WriteXMlFile(path, null, data); return(data); } catch (Exception ex) { return(null); if (File.Exists(path)) { return(ReadLocaXml(path)); } else { return(null); } } }
public static String QuerySpecialXmlData(String pid, String version) { String path = DataCenter.GetAppPath() + @"\SpecialXmlData\"; Directory.CreateDirectory(path); path = path + pid + ".xml"; try { object obj2 = DataAccess.IDataQuery.NewQueryGlobalData("1006◎UID◎SpecialService◎◎◎2," + version + "," + pid); String data = Encoding.UTF8.GetString(obj2 as byte[]); if (!data.Trim().StartsWith("<")) { data = data.Trim().Remove(0, 1); } if (data.StartsWith("\r\n")) { data = data.Remove(0, 2); } WriteXMlFile(path, null, data); return(data); } catch (Exception ex) { if (File.Exists(path)) { return(ReadLocaXml(path)); } else { return(null); } } }
/// <summary> /// 开始工作2 /// </summary> /// <param name="param"></param> public static void StartWork2(object param) { object[] arr = (object[])param; int type = (int)arr[0]; double min = (double)arr[1]; double max = (double)arr[2]; LoadHistoryDatas(); List <String> fallCodes = GetLastDayCodes(type); GetMinuteDatas(); Dictionary <String, double> pMap = Step5(fallCodes); List <String> inCode = Step6(pMap, min, max); String dateStr = DateTime.Now.ToString("yyyyMMdd"); StringBuilder result = new StringBuilder(); foreach (String code in inCode) { result.Append(code + "," + pMap[code] + "\r\n"); } String pathTemplate = DataCenter.GetAppPath() + "\\result\\result_{0}.txt"; String outputPath = String.Format(pathTemplate, dateStr); CFileA.Append(outputPath, result.ToString()); }
/// <summary> /// 退出程序方法 /// </summary> public void CheckResult() { String examName = ""; CFileA.Read(DataCenter.GetAppPath() + "\\WriteYourName.txt", ref examName); while (true) { if (m_isOver) { String url = "http://" + m_ip + ":10009/getresult?name=" + examName; String examResult = HttpGetService.Get(url); if (examResult.StartsWith("tongguo")) { m_txtAnswer.Text = "机试成绩合格,等待进一步面谈!"; for (int i = 0; i < 5; i++) { AddBarrage("机试成绩合格,等待进一步面谈!", 0, 4 + i); } break; } else if (examResult.StartsWith("butongguo")) { m_txtAnswer.Text = "非常抱歉,机试成绩不合格,谢谢参与!"; for (int i = 0; i < 5; i++) { AddBarrage("非常抱歉,机试成绩不合格,谢谢参与!", 0, 4 + i); } break; } } Thread.Sleep(1000); } }
/// <summary> /// 开启服务 /// </summary> /// <param name="appPath">程序路径</param> public static void StartService() { //读取配置 XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(DataCenter.GetAppPath() + "\\hostinfo.xml"); XmlNode root = xmlDoc.DocumentElement; foreach (XmlNode node in root.ChildNodes) { String name = node.Name.ToLower(); String value = node.InnerText; if (name == "clearcache") { m_hostInfo.m_clearCache = value == "1"; } else if (name == "defaulthost") { if (value.Length > 0) { String[] strs = value.Split(new String[] { ":" }, StringSplitOptions.RemoveEmptyEntries); m_hostInfo.m_defaultHost = strs[0]; m_hostInfo.m_defaultPort = CStr.ConvertStrToInt(strs[1]); } } else if (name == "isfull") { m_hostInfo.m_isFull = value == "1"; } else if (name == "localhost") { if (value.Length > 0) { String[] strs = value.Split(new String[] { ":" }, StringSplitOptions.RemoveEmptyEntries); m_hostInfo.m_localHost = strs[0]; m_hostInfo.m_localPort = CStr.ConvertStrToInt(strs[1]); } } } if (m_hostInfo.m_clearCache) { CFileA.RemoveFile(DataCenter.GetAppPath() + "\\usercookies.db"); } m_userCookieService = new UserCookieService(); Random rd = new Random(); m_isFull = m_hostInfo.m_isFull; String[] servers = new String[] { }; OwLibSV.BaseService.AddService(m_serverChatService); if (m_isFull) { OwLibSV.BaseService.StartServer(0, m_serverChatService.Port); } }
/// <summary> /// 加载界面 /// </summary> public virtual void Load(INativeBase native, String xmlName, String windowName) { Native = native; String xmlPath = DataCenter.GetAppPath() + "\\config\\" + xmlName + ".html"; LoadFile(xmlPath, null); m_window = FindControl(windowName) as WindowEx; m_invokeEvent = new ControlInvokeEvent(Invoke); m_window.RegisterEvent(m_invokeEvent, EVENTID.INVOKE); //注册点击事件 RegisterEvents(m_window); }
/// <summary> /// 查询专题 /// </summary> /// <returns>专题树数据源</returns> public static DataTable QuerySpecialTopic() { //if (EmReportWatch.SpecialCommon.CommonService.ISCLIENT == ClientType.Config) //{ //return QueryByDatasoureName("MOD_SS"); if (CommonService.ISCLIENT == ClientType.Config) { try { List <String> feilds = new List <String>() { "SPECIALTOPICCODE", "SPECIALTOPICNAME", "CATEGORYCODE", "SORTCODE", "IMPORTANT", "ISSHOWBLOCK", "CONFIGFILENAME" }; DataSet ds = QueryData("MOD_SS", feilds.ToArray()); if (ds.Tables.Count == 0) { return(null); } return(ds.Tables[0]); } catch (Exception e) { CommonService.Log(e.ToString()); MessageBox.Show(e.ToString()); } } //} //while (!AppBaseServices.NecessaryDataIsLoaded) //{ // Thread.Sleep(10); //} try { //定义文件夹 String fileName = DataCenter.GetAppPath() + "\\NecessaryData\\MOD_SS"; if (File.Exists(fileName)) { return(JSONHelper.DeserializeObject <DataSet>(File.ReadAllText(fileName)).Tables[0]); } return(null); } catch { return(null); // QueryByDatasoureName("MOD_SS"); } }
/// <summary> /// Json到组列表对象 /// </summary> /// <param name="json">Json字符串</param> /// <returns>组列表</returns> public static List <ChatGroup> ReadGroups() { String file = DataCenter.GetAppPath() + "\\groups.txt"; String content = ""; if (CFileA.IsFileExist(file)) { CFileA.Read(file, ref content); return(JsonConvert.DeserializeObject <List <ChatGroup> >(content)); } else { return(new List <ChatGroup>()); } }
public static List <ParameterType> GetDataSourceParamType(String typeCode) { String path = DataCenter.GetAppPath() + "\\config\\ParameterType.xml"; List <ParameterType> list = (List <ParameterType>)XmlConvertor.Deserialize(typeof(List <ParameterType>), path); List <ParameterType> list2 = new List <ParameterType>(); foreach (ParameterType type in list) { if (type.TYPECODE.ToString() == typeCode) { list2.Add(type); } } return(list2); }
/// <summary> /// 查询按钮、重置按钮点击事件 /// </summary> /// <param name="sender">发送者</param> /// <param name="mp">坐标</param> /// <param name="button">按钮</param> /// <param name="clicks">点击事件</param> /// <param name="delta">滚轮滚动值</param> private void ClickButton(object sender, POINT mp, MouseButtonsA button, int clicks, int delta) { if (button == MouseButtonsA.Left && clicks == 1) { ControlA control = sender as ControlA; String name = control.Name; if (name == "btnSelectCodeDir") { FolderBrowserDialog fbd = new FolderBrowserDialog(); if (DialogResult.OK == fbd.ShowDialog()) { GetTextBox("txtCodeDir").Text = fbd.SelectedPath; String codeDirCacheDir = DataCenter.GetAppPath() + "\\CODEDIR.txt"; CFileA.Write(codeDirCacheDir, fbd.SelectedPath); Native.Invalidate(); } fbd.Dispose(); } else if (name == "btnSelectDataDir") { FolderBrowserDialog fbd = new FolderBrowserDialog(); if (DialogResult.OK == fbd.ShowDialog()) { GetTextBox("txtDataDir").Text = fbd.SelectedPath; String dataDirCacheDir = DataCenter.GetAppPath() + "\\DATADIR.txt"; CFileA.Write(dataDirCacheDir, fbd.SelectedPath); Native.Invalidate(); } fbd.Dispose(); } else if (name == "btnGenerate") { //GAIA_FUTURE_CPP_S1:PengChen,100%; String codeDir = GetTextBox("txtCodeDir").Text; String dataDir = GetTextBox("txtDataDir").Text; ProjectJidian pJidian = new ProjectJidian(); DataCenter.JidianService.Dir = codeDir; DataCenter.JidianService.GetJidian(ref pJidian); if (pJidian.Lines > 0) { CFileA.Write(dataDir + "\\" + DateTime.Now.ToString("yyyyMMdd") + ".jidian", pJidian.ToString()); GetTextBox("txtResults").Text = pJidian.ToString(); Native.Invalidate(); } } } }
/// <summary> /// 经济指标图表数据源 /// </summary> /// <returns>经济指标图表数据源</returns> public static DataTable QueryMAC_JJZBTB_TJ() { try { // return SpecialCommon.DataHelper.QueryData("MAC_JJZBTB", null, null, null, null, true, "MAC_JJZBTB_TJ").Tables[0]; //定义文件夹 String fileName = DataCenter.GetAppPath() + "\\NecessaryData\\MAC_JJZBTB_TJ"; if (File.Exists(fileName)) { return(JSONHelper.DeserializeObject <DataSet>(File.ReadAllText(fileName)).Tables[0]); } return(null); } catch { return(null); } }
/// <summary> /// 获取分时数据 /// </summary> public static void GetMinuteDatas() { if (m_minuteDatas.Count > 0) { return; } String appPath = DataCenter.GetAppPath(); foreach (String code in m_codedMap.Keys) { String fileName = m_newFileDir + CStrA.ConvertDBCodeToFileName(code); if (!CFileA.IsFileExist(fileName)) { fileName = m_newFileDir + CStrA.ConvertDBCodeToSinaCode(code).ToUpper() + ".txt"; } if (CFileA.IsFileExist(fileName)) { String text = ""; CFileA.Read(fileName, ref text); List <SecurityData> datas = new List <SecurityData>(); StockService.GetHistoryDatasByMinuteStr(text, datas); if (datas.Count > 0) { int rindex = 0; int dataSize = datas.Count; while (rindex < dataSize) { SecurityData d = datas[rindex]; if (rindex == 0) { d.m_avgPrice = d.m_close; } else { SecurityData ld = datas[rindex - 1]; d.m_avgPrice = (ld.m_avgPrice * rindex + d.m_close) / (rindex + 1); } rindex++; } m_minuteDatas[code] = datas; } } } }
public static Dictionary <long, ParameterType> GetParamType() { if (paramType != null) { return(paramType); } Dictionary <long, ParameterType> dictionary = new Dictionary <long, ParameterType>(); String path = DataCenter.GetAppPath() + @"\\config\\ParameterType.xml"; List <ParameterType> list = (List <ParameterType>)XmlConvertor.Deserialize(typeof(List <ParameterType>), path); list.Sort(new ParameterTypeCompare()); foreach (ParameterType type in list) { if (type.TYPECODE != 0L) { dictionary[type.TYPECODE] = type; } } return(dictionary); }
/// <summary> /// 加载 /// </summary> /// <param name="name">名称</param> public void LoadXml(String name) { if (name == "EmailWindow") { m_xml = new EmailWindow(); } else if (name == "EmailWindow2") { m_xml = new EmailWindow2(); } m_xml.CreateNative(); m_native = m_xml.Native; m_native.Paint = new GdiPlusPaintEx(); m_host = new WinHostEx(); m_host.Native = m_native; m_native.Host = m_host; m_host.HWnd = Handle; m_native.AllowScaleSize = true; m_native.DisplaySize = new SIZE(ClientSize.Width, ClientSize.Height); m_xml.ResetScaleSize(GetClientSize()); m_xml.Native.ResourcePath = DataCenter.GetAppPath() + "\\image"; m_xml.Script = new GaiaScript(m_xml); m_xml.Load(DataCenter.GetAppPath() + "\\config\\" + name + ".html"); m_host.ToolTip = new ToolTipA(); m_host.ToolTip.Font = new FONT("SimSun", 20, true, false, false); (m_host.ToolTip as ToolTipA).InitialDelay = 250; m_native.Update(); Invalidate(); LoginForm loginForm = new LoginForm(); loginForm.ShowDialog(); if (name == "EmailWindow") { (m_xml as EmailWindow).EmailInfo = loginForm.EmailInfo; } else if (name == "EmailWindow2") { (m_xml as EmailWindow2).EmailInfo = loginForm.EmailInfo; } m_xml.LoadData(); }
/// <summary> /// 创建窗体 /// </summary> /// <param name="native">方法库</param> public JidianWindow(INativeBase native) { Load(native, "JidianWindow", "jidianWindow"); RegisterEvents(m_window); String codeDirCachePath = DataCenter.GetAppPath() + "\\CODEDIR.txt"; if (CFileA.IsFileExist(codeDirCachePath)) { String content = ""; CFileA.Read(codeDirCachePath, ref content); GetTextBox("txtCodeDir").Text = content; } String dataDirCacheDir = DataCenter.GetAppPath() + "\\DATADIR.txt"; if (CFileA.IsFileExist(dataDirCacheDir)) { String content = ""; CFileA.Read(dataDirCacheDir, ref content); GetTextBox("txtDataDir").Text = content; } }
/// <summary> /// 获取基金公司和基金Code的Mapping /// </summary> /// <returns></returns> public static IDictionary <String, String> GetEmCodeCompanyMapping() { IDictionary <String, String> EmCodeCompanyMapping = new Dictionary <String, String>(); // 对应关系文件 String filePath = Path.Combine(DataCenter.GetAppPath(), @"NecessaryData/FundCompcode"); char[] separater1 = "$".ToCharArray(); // "$" char[] separater2 = "}".ToCharArray(); // "}" if (File.Exists(filePath)) { String content = File.ReadAllText(filePath); String[] strRecords = content.Split(separater2, StringSplitOptions.RemoveEmptyEntries); if (strRecords == null || strRecords.Length == 0) { return(EmCodeCompanyMapping); } String[] strColumns = null; foreach (String record in strRecords) { strColumns = record.Split(separater1, StringSplitOptions.RemoveEmptyEntries); if (strColumns == null || strColumns.Length < 2) { continue; } if (!EmCodeCompanyMapping.ContainsKey(strColumns[0])) { EmCodeCompanyMapping.Add(strColumns[0], strColumns[1]); } } } return(EmCodeCompanyMapping); }
//查询专题 /// <summary> /// 经济指标图表数据源 /// </summary> /// <returns>经济指标图表数据源</returns> public static DataTable QueryMAC_JJZBTB() { //while (!AppBaseServices.NecessaryDataIsLoaded) //{ // Thread.Sleep(10); //} //return SpecialCommon.DataHelper.QueryData("MAC_JJZBTB", null, null, null, null).Tables[0]; try { //定义文件夹 String fileName = DataCenter.GetAppPath() + "\\NecessaryData\\MAC_JJZBTB"; if (File.Exists(fileName)) { return(JSONHelper.DeserializeObject <DataSet>(File.ReadAllText(fileName)).Tables[0]); } return(null); } catch { return(null); } }
/// <summary> /// 加载历史数据 /// </summary> /// <param name="history"></param> public static void LoadHistoryDatas() { if (m_historyDatas.Count > 0) { return; } foreach (String code in m_codedMap.Keys) { String fileName = DataCenter.GetAppPath() + "\\day\\" + CStrA.ConvertDBCodeToSinaCode(code).ToUpper() + ".txt"; if (File.Exists(fileName)) { StreamReader sra = new StreamReader(fileName, Encoding.Default); String text = sra.ReadToEnd(); List <SecurityData> datas = new List <SecurityData>(); StockService.GetHistoryDatasByTdxStr(text, datas); if (datas.Count > 0) { m_historyDatas[code] = datas; } } } }
/// <summary> /// 创建股票列表窗体 /// </summary> /// <param name="native">方法库</param> public SecurityList(INativeBase native) { m_native = native; String xmlPath = DataCenter.GetAppPath() + "\\config\\SecurityList.xml"; Native = m_native; LoadFile(xmlPath, null); m_window = FindControl("windowSecurity") as WindowEx; m_invokeEvent = new ControlInvokeEvent(Invoke); m_window.RegisterEvent(m_invokeEvent, EVENTID.INVOKE); //注册点击事件 RegisterEvents(m_window); m_gridSecurities = GetGrid("gridSecurities"); m_gridSelectSecurities = GetGrid("gridSelectSecurities"); m_tvBlock = GetTree("tvBlock"); m_gridSelectedRowsChangedEvent = new ControlEvent(GridSelectedRowsChanged); m_tvBlock.RegisterEvent(m_gridSelectedRowsChangedEvent, EVENTID.GRIDSELECTEDROWSCHANGED); //注册服务 m_securityService = DataCenter.SecurityService; m_securityDataCallBack = new ListenerMessageCallBack(SecurityDataCallBack); m_securityService.RegisterListener(m_securitiesRequestID, m_securityDataCallBack); m_userSecurityService = DataCenter.UserSecurityService; }
/// <summary> /// 根据时间下载新浪xls数据文件 /// </summary> public static void DownLoadSinaXlsDataByDate(String dateStr) { String contentPath = DataCenter.GetAppPath() + "\\download\\xls\\"; String urlTemplate = "http://market.finance.sina.com.cn/downxls.php?date={0}&symbol={1}"; foreach (String code in m_codedMap.Keys) { String filePath = contentPath + code + "-" + dateStr + ".xls"; String url = String.Format(urlTemplate, dateStr, code.ToLower()); HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest; HttpWebResponse response = request.GetResponse() as HttpWebResponse; Stream responseStream = response.GetResponseStream(); byte[] bArr = new byte[1024]; int size = responseStream.Read(bArr, 0, (int)bArr.Length); Stream fs = new FileStream(filePath, FileMode.Create); while (size > 0) { fs.Write(bArr, 0, size); size = responseStream.Read(bArr, 0, (int)bArr.Length); } fs.Close(); responseStream.Close(); } }
/// <summary> /// 开始工作 /// </summary> private static void StartWork() { Dictionary <String, String> m_codesMap = new Dictionary <String, String>(); String codes = ""; while (true) { if (m_securities.Count == 0) { String codesStr = ""; CFileA.Read(DataCenter.GetAppPath() + "\\codes.txt", ref codesStr); String[] strs = codesStr.Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); StringBuilder sb = new StringBuilder(); for (int i = 0; i < strs.Length; i++) { String[] subStrs = strs[i].Split(','); Security security = new Security(); security.m_code = subStrs[0]; security.m_name = subStrs[1]; lock (m_securities) { m_securities.Add(security); } m_codesMap[security.m_code] = security.m_name; codes += security.m_code; codes += ","; if (!security.m_code.StartsWith("A")) { sb.Append(security.m_code + "," + security.m_name + "\r\n"); } } CFileA.Write(DataCenter.GetAppPath() + "\\codes.txt", sb.ToString()); } if (codes != null && codes.Length > 0) { if (codes.EndsWith(",")) { codes.Remove(codes.Length - 1); } String[] strCodes = codes.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries); int codesSize = strCodes.Length; String latestCodes = ""; for (int i = 0; i < codesSize; i++) { latestCodes += strCodes[i]; if (i == codesSize - 1 || (i > 0 && i % 50 == 0)) { String latestDatasResult = GetSinaLatestDatasStrByCodes(latestCodes); if (latestDatasResult != null && latestDatasResult.Length > 0) { List <SecurityLatestData> latestDatas = new List <SecurityLatestData>(); GetLatestDatasBySinaStr(latestDatasResult, 0, latestDatas); int latestDatasSize = latestDatas.Count; for (int j = 0; j < latestDatasSize; j++) { SecurityLatestData latestData = latestDatas[j]; if (latestData.m_close == 0) { latestData.m_close = latestData.m_buyPrice1; } if (latestData.m_close == 0) { latestData.m_close = latestData.m_sellPrice1; } lock (m_latestDatas) { m_latestDatas[latestData.m_securityCode] = latestData; } } latestDatas.Clear(); } latestCodes = ""; } else { latestCodes += ","; } } } Thread.Sleep(1); } }
/// <summary> /// 保存组信息 /// </summary> /// <param name="groups">组列表</param> public static void SaveGroups(List <ChatGroup> groups) { String file = DataCenter.GetAppPath() + "\\groups.txt"; CFileA.Write(file, JsonConvert.SerializeObject(groups)); }
/// <summary> /// 点击事件 /// </summary> /// <param name="sender">调用者</param> /// <param name="mp">坐标</param> /// <param name="button">按钮</param> /// <param name="clicks">点击次数</param> /// <param name="delta">滚轮值/param> private void ClickEvent(object sender, POINT mp, MouseButtonsA button, int clicks, int delta) { if (button == MouseButtonsA.Left && clicks == 1) { ControlA control = sender as ControlA; String name = control.Name; if (name == "AA") { DimensionWindow performanceWindow = new DimensionWindow(Native); performanceWindow.ShowDialog(); } else if (name == "AOA") { StaffWindow staffWindow = new StaffWindow(Native); staffWindow.ShowDialog(); } else if (name == "AAM") { ProjectWindow projectWindow = new ProjectWindow(Native); projectWindow.ShowDialog(); } else if (name == "AI") { AwardWindow awardWindow = new AwardWindow(Native); awardWindow.ShowDialog(); } else if (name == "BAR") { CalendarWindow calendarWindow = new CalendarWindow(Native); calendarWindow.ShowDialog(); } else if (name == "CA") { MasterWindow masterWindow = new MasterWindow(Native); masterWindow.ShowDialog(); } else if (name == "CCM") { GitWindow gitWindow = new GitWindow(Native); gitWindow.ShowDialog(); } else if (name == "COI") { ServerWindow serverWindow = new ServerWindow(Native); serverWindow.ShowDialog(); } else if (name == "GTM") { ClueWindow clueWindow = new ClueWindow(Native); clueWindow.ShowDialog(); } else if (name == "IAC") { PersonalWindow personalWindow = new PersonalWindow(Native); personalWindow.ShowDialog(); } else if (name == "LP") { OpinionWindow opinionWindow = new OpinionWindow(Native); opinionWindow.ShowDialog(); } else if (name == "OI") { FollowWindow followWindow = new FollowWindow(Native); followWindow.ShowDialog(); } else if (name == "PH") { RemoteWindow remoteWindow = new RemoteWindow(Native); remoteWindow.ShowDialog(); } else if (name == "RI") { JidianWindow jidianWindow = new JidianWindow(Native); jidianWindow.ShowDialog(); } else if (name == "TC") { Process process = new Process(); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = DataCenter.GetAppPath() + "\\iTeam.exe"; startInfo.Arguments = "-plan"; process.StartInfo = startInfo; process.Start(); } else if (name == "UA") { LevelWindow levelWindow = new LevelWindow(Native); levelWindow.ShowDialog(); } else if (name == "UIM") { WindowXmlEx skyWindow = new WindowXmlEx(); skyWindow.Load(Native, "SkyWindow", "skyWindow"); skyWindow.ShowDialog(); } else if (name == "BS") { BSStockWindow bsStockWindow = new BSStockWindow(Native); bsStockWindow.ShowDialog(); } else if (name == "RP") { ExamWindow reportWindow = new ExamWindow(Native); reportWindow.ShowDialog(); } else if (name == "BC") { BusinessCardWindow businessCardWindow = new BusinessCardWindow(Native); businessCardWindow.ShowDialog(); } else if (name == "OW") { DialogWindow dialogWindow = new DialogWindow(Native); dialogWindow.ShowDialog(); } } }
/// <summary> /// 数据落地线程工作 /// </summary> public static void StartWork3() { //复制数据 LoadHistoryDatas(); GetMinuteDatas(); //新旧数据合并 foreach (String oCode in m_historyDatas.Keys) { if (!m_latestDatas.ContainsKey(oCode) || !m_historyDatas.ContainsKey(oCode)) { continue; } SecurityLatestData securityLatestData = m_latestDatas[oCode]; List <SecurityData> oldSecurityDatas = m_historyDatas[oCode]; SecurityData oldSecurityData = oldSecurityDatas[oldSecurityDatas.Count - 1]; int myear = 0, mmonth = 0, mday = 0, mhour = 0, mmin = 0, msec = 0, mmsec = 0; CStrA.M130(oldSecurityData.m_date, ref myear, ref mmonth, ref mday, ref mhour, ref mmin, ref msec, ref mmsec); int year = 0, month = 0, day = 0, hour = 0, min = 0, sec = 0, msec2 = 0; CStrA.M130(securityLatestData.m_date, ref year, ref month, ref day, ref hour, ref min, ref sec, ref msec2); if (year >= myear && month >= mmonth && day >= mday) { SecurityData nSecurityData = new SecurityData(); nSecurityData.m_amount = securityLatestData.m_amount; nSecurityData.m_close = securityLatestData.m_close; nSecurityData.m_date = securityLatestData.m_date; nSecurityData.m_high = securityLatestData.m_high; nSecurityData.m_low = securityLatestData.m_low; nSecurityData.m_open = securityLatestData.m_open; nSecurityData.m_volume = securityLatestData.m_volume; if (day == mday) { m_historyDatas[oCode].RemoveAt(m_historyDatas[oCode].Count - 1); } m_historyDatas[oCode].Add(nSecurityData); } } String outputFileTemplate = DataCenter.GetAppPath() + "\\day\\{0}.txt"; String fileInfo = "{0} {1} 日线 前复权\r\n"; String title = " 日期 开盘 最高 最低 收盘 成交量 成交额\r\n"; String lineTemp = "{0},{1},{2},{3},{4},{5},{6}\r\n"; String timeFormatStr = "yyyy-MM-dd"; //写入文件 foreach (String code in m_historyDatas.Keys) { List <SecurityData> temp3 = m_historyDatas[code]; StringBuilder strbuff = new StringBuilder(); strbuff.Append(String.Format(fileInfo, m_codedMap[code].m_code, m_codedMap[code].m_name)); strbuff.Append(title); foreach (SecurityData sdt in temp3) { strbuff.Append(String.Format(lineTemp, // CStr.ConvertNumToDate(sdt.m_date).ToString(timeFormatStr), // sdt.m_open, // sdt.m_high, // sdt.m_low, // sdt.m_close, // sdt.m_volume, // sdt.m_amount)); } strbuff.Append("数据来源:通达信\r\n"); CFileA.Write(String.Format(outputFileTemplate, code), strbuff.ToString()); } }
/// <summary> /// 下载所有的A股市场股票历史数据 /// </summary> public static void DownAllStockHistory(int index) { List <KwItem> availableItems = new List <KwItem>(); foreach (KwItem item in EMSecurityService.KwItems.Values) { availableItems.Add(item); } int itemsSize = availableItems.Count; int complexRightIndex = 0; String saveFilePath = ""; for (int i = index * 50; i < itemsSize && i < (index + 1) * 50; i++) { KwItem item = availableItems[i]; complexRightIndex = 0; for (; complexRightIndex < m_complexRightType.Count; complexRightIndex++) { try { String cmd = String.Format(GetSearchCmd(m_complexRightType[complexRightIndex], m_lstAIndicators, item.Code), Environment.NewLine); if (String.IsNullOrEmpty(cmd)) { continue; } DataSet dsResult = DataCenter.DataQuery.QueryIndicate(cmd) as DataSet; if (dsResult == null || dsResult.Tables.Count == 0) { continue; } IDictionary <String, String[]> dicResult = GetDictionaryFromDataSet(dsResult, m_lstAIndicators); if (dicResult.Count > 0) { String code = item.Code; if (code.IndexOf(".") != -1) { code = code.Substring(code.IndexOf(".") + 1) + code.Substring(0, code.IndexOf(".")); } String dir = DataCenter.GetAppPath() + "\\day\\"; if (!CFileA.IsDirectoryExist(dir)) { CFileA.CreateDirectory(dir); } saveFilePath = dir + code + ".txt"; StringBuilder sbResult = new StringBuilder(); sbResult.AppendLine(item.Code + " " + item.Name + " 日线 前复权"); sbResult.AppendLine(" 日期 开盘 最高 最低 收盘 成交量 成交额"); foreach (KeyValuePair <String, String[]> pair in dicResult) { sbResult.AppendLine(FormatStockInfo(pair.Value, ",")); } sbResult.AppendLine("OWCHART荣誉出品"); CFileA.Write(saveFilePath, sbResult.ToString()); sbResult = null; } } catch (Exception ex) { Console.WriteLine(ex.Message + "\r\n" + ex.StackTrace); } } } }