コード例 #1
0
        static void Main(string[] args)
        {
            string        str;
            int           i     = 0;
            bool          check = true;
            List <string> mas   = new List <string>();

            Console.WriteLine("Введите строку. Чтобы прекратить ввод, добавть пустую строку");

            while (check)
            {
                str = Console.ReadLine();
                mas.Add(str);

                if (str == "")
                {
                    check = false;
                }
            }



            CheckStr st = new CheckStr(s);

            st.Invoke(mas);

            show(mas);

            Console.ReadKey();
        }
コード例 #2
0
        public void Init()
        {
            try
            {
                string       CheckStr;
                StreamReader sr = new StreamReader(@"C:\DesktopSetup\Setup.txt", Encoding.Default);
                while ((CheckStr = sr.ReadLine()) != null)
                {
                    string[] CheckString = CheckStr.Split('=');
                    switch (CheckString[0])
                    {
                    case "變更桌布時間":
                        變更桌布時間 = CheckString[1];
                        break;

                    case "桌布路徑":
                        桌布路徑 = CheckString[1];
                        break;

                    case "變更模式":
                        變更模式 = CheckString[1];
                        break;
                    }
                }
                sr.Close();
                //return true;
            }

            catch (Exception ex1)
            {
                #region 發生例外寫LOG
                String nowtime = DateTime.Now.ToString("yyyyMMdd-HH:mm");

                if (!File.Exists("C:\\LOG\\"))
                {
                    Directory.CreateDirectory("C:\\LOG\\");
                }
                if (!File.Exists("C:\\LOG\\" + nowtime + "程式例外.txt"))
                {
                    FileStream fileStream = new FileStream("C:\\LOG\\" + nowtime + "程式例外.txt", FileMode.Create);
                    fileStream.Close();
                }
                using (StreamWriter file = new StreamWriter("C:\\LOG\\" + nowtime + "程式例外.txt", true))
                {
                    file.WriteLine("[ " + nowtime + " ]" + "程式紀錄出現例外:" + ex1.Message + "\r\n\r\n" +
                                   "StackTrace:" + "[===== " + ex1.StackTrace + " =====]\r\n\r\n" +
                                   "Source:" + ex1.Source + "\r\n\r\n" +
                                   "TargetSite:" + ex1.TargetSite + "\r\n\r\n" +
                                   "DATA:" + ex1.Data + "\r\n\r\n" +
                                   "HResult:" + ex1.HResult + "\r\n\r\n" +
                                   "HelpLink:" + ex1.HelpLink + "\r\n\r\n" +
                                   "InnerException:" + ex1.InnerException);
                }
                #endregion
                MessageBox.Show("讀取不到設定檔");
                //return false;
            }
        }
コード例 #3
0
        public string GetDyamicListJson(int type, int pageIndex, int pageSize)
        {
            string json = "{\"total\":\"" + this.GetDynamicSize(type) + "\",\"rows\":[";

            List <Dynamic> dynamics = base.Search(d => d.dynamic_isDel == false && d.dynamic_class == type, d => d.dynamic_publicTime, pageIndex, pageSize);

            foreach (Dynamic dynamic in dynamics)
            {
                string html = CheckStr.checkStr(dynamic.dynamic_body);
                html = html.Length >= 100 ? html.Substring(0, 100) : html;
                json = json + "{\"id\":\"" + dynamic.dynamic_id + "\",\"title\":\"" + dynamic.dynamic_title + "\",\"body\":\"" + html + "\",\"index\":\"" + this.isIndex(dynamic.dynamic_isIndex, type) + "\",\"time\":\"" + dynamic.dynamic_publicTime + "\"},";
            }
            json = json.Substring(0, json.Length - 1) + "]}";
            return(json);
        }