コード例 #1
0
        /// <summary>
        /// 开始播放声音
        /// </summary>
        /// <param name="args">参数</param>
        private static void StartPlay(object args)
        {
            String fileName = Application.StartupPath + "\\config\\" + args.ToString();

            if (CFileA.IsFileExist(fileName))
            {
                try
                {
                    int error = mciSendString("open " + fileName, null, 0, new IntPtr(0));
                    if (error == 0)
                    {
                        mciSendString("play " + fileName, null, 0, new IntPtr(0));
                        Thread.Sleep(5000);
                        mciSendString("stop " + fileName, null, 0, new IntPtr(0));
                        mciSendString("close " + fileName, null, 0, new IntPtr(0));
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message + "\r\n" + ex.StackTrace);
                }
            }
            lock (m_plays)
            {
                if (m_plays.ContainsKey(args.ToString()))
                {
                    m_plays.Remove(args.ToString());
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 获取通达信的历史数据的字符串
        /// </summary>
        /// <param name="code">股票代码</param>
        /// <param name="path">本地文件路径</param>
        /// <returns>数据字符串</returns>
        public static String GetTdxHistoryDatasStrByCode(String code, String path)
        {
            String fileName = CStrA.ConvertDBCodeToFileName(code);
            String result   = "";
            String filePath = path + fileName;

            if (CFileA.IsFileExist(filePath))
            {
                CFileA.Read(filePath, ref result);
            }
            return(result);
        }
コード例 #3
0
ファイル: MainFrame.cs プロジェクト: owchart/iteam
        /// <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>());
            }
        }
コード例 #4
0
        /// <summary>
        /// 创建用户状态服务
        /// </summary>
        public UserCookieService()
        {
            String dataDir = DataCenter.GetUserPath();

            if (!CFileA.IsDirectoryExist(dataDir))
            {
                CFileA.CreateDirectory(dataDir);
            }
            String dataBasePath = DataCenter.GetUserPath() + "\\usercookies.db";

            m_connectStr = "Data Source = " + dataBasePath;
            if (!CFileA.IsFileExist(dataBasePath))
            {
                CreateTable();
            }
        }
コード例 #5
0
        /// <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;
                    }
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// 获取或设置是否需要创建表
        /// </summary>
        public void CreateTable()
        {
            String dataBasePath = DataCenter.GetUserPath() + "\\" + DATABASENAME;

            if (!CFileA.IsFileExist(dataBasePath))
            {
                //创建数据库文件
                SQLiteConnection.CreateFile(dataBasePath);
            }
            //创建表
            SQLiteConnection conn = new SQLiteConnection(m_connectStr);

            conn.Open();
            SQLiteCommand cmd = conn.CreateCommand();

            cmd.CommandText = CREATETABLESQL;
            cmd.ExecuteNonQuery();
            conn.Close();
        }
コード例 #7
0
        /// <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;
            }
        }