Exemple #1
0
        public static void Load_NewsList()
        {
            try
            {
                int news_count = 0;
                try
                {
                    string[] fileEntries = Directory.GetFiles(Environment.CurrentDirectory + @"\Settings\News", @"????-??-??.*");
                    if (fileEntries.Length > 0)
                    {
                        Array.Sort(fileEntries);
                        Array.Reverse(fileEntries);

                        foreach (string fName in fileEntries)
                        {
                            if (news_count < 10)
                            {
                                DateTime aDate;
                                if (DateTime.TryParse(Path.GetFileNameWithoutExtension(fName), out aDate))
                                {
                                    using (StreamReader aFile = new StreamReader(fName, Encoding.ASCII))
                                    {
                                        string line = aFile.ReadLine(); // read Headline
                                        if (line != null)
                                        {
                                            string line2 = aFile.ReadToEnd(); // read Content
                                            if (line2 != null)
                                            {
                                                NewsList nl = new NewsList();
                                                nl.Head = line;
                                                nl.Msg = line2;
                                                nl.Day = (short)aDate.Day;
                                                nl.Month = (short)aDate.Month;
                                                nl.Year = (short)aDate.Year;
                                                Systems.News_List.Add(nl);
                                                news_count++;
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                Console.WriteLine("Please remove old news, only 10 are loaded!");
                            }
                        }
                    }
                }
                catch { }
                string articles = "Article";
                if (news_count > 1) articles = "Articles";
                Console.WriteLine("[INFO] Loaded " + news_count + " news " + articles + "");
            }
            catch (Exception ex)
            {
                Console.WriteLine("News error " + ex);
            }
        }
Exemple #2
0
 private void editNews_Click(object sender, EventArgs e)
 {
     if (nwsList.SelectedItem == null)
     {
         MessageBox.Show("You must first select a news item to edit..", "[SRX]", MessageBoxButtons.OK, MessageBoxIcon.Hand);
     }
     else
     {
         //Populate informational gui boxes
         NewsList article = Systems.getarticle(nwsList.SelectedItem.ToString());
         nwsTitle.Text = article.Head;
         nwsBody.Text  = article.Msg;
     }
 }
Exemple #3
0
        public void ReloadArticles()
        {
            int news_count = 0;

            string[] fileEntries = Directory.GetFiles(Environment.CurrentDirectory + @"\Settings\News", @"????-??-??.*");
            if (fileEntries.Length > 0)
            {
                Array.Sort(fileEntries);
                Array.Reverse(fileEntries);

                foreach (string fName in fileEntries)
                {
                    if (news_count < 10)
                    {
                        DateTime aDate;
                        if (DateTime.TryParse(Path.GetFileNameWithoutExtension(fName), out aDate))
                        {
                            using (StreamReader aFile = new StreamReader(fName))
                            {
                                string line = aFile.ReadLine(); // read Headline
                                if (line != null)
                                {
                                    string line2 = aFile.ReadToEnd(); // read Content
                                    if (line2 != null)
                                    {
                                        NewsList nl = new NewsList();
                                        nl.Head  = line;
                                        nl.Msg   = line2;
                                        nl.Day   = (short)aDate.Day;
                                        nl.Month = (short)aDate.Month;
                                        nl.Year  = (short)aDate.Year;
                                        Systems.News_List.Add(nl);
                                        news_count++;
                                        nwsList.Items.Add(nl.Head);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #4
0
        public void ReloadArticles()
        {
            int news_count = 0;
            string[] fileEntries = Directory.GetFiles(Environment.CurrentDirectory + @"\Settings\News", @"????-??-??.*");
            if (fileEntries.Length > 0)
            {
                Array.Sort(fileEntries);
                Array.Reverse(fileEntries);

                foreach (string fName in fileEntries)
                {
                    if (news_count < 10)
                    {
                        DateTime aDate;
                        if (DateTime.TryParse(Path.GetFileNameWithoutExtension(fName), out aDate))
                        {
                            using (StreamReader aFile = new StreamReader(fName))
                            {
                                string line = aFile.ReadLine(); // read Headline
                                if (line != null)
                                {
                                    string line2 = aFile.ReadToEnd(); // read Content
                                    if (line2 != null)
                                    {
                                        NewsList nl = new NewsList();
                                        nl.Head = line;
                                        nl.Msg = line2;
                                        nl.Day = (short)aDate.Day;
                                        nl.Month = (short)aDate.Month;
                                        nl.Year = (short)aDate.Year;
                                        Systems.News_List.Add(nl);
                                        news_count++;
                                        nwsList.Items.Add(nl.Head);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #5
0
        public static void Load_NewsList()
        {
            try
            {
                int news_count = 0;
                try
                {
                    string[] fileEntries = Directory.GetFiles(Environment.CurrentDirectory + @"\Settings\News", @"????-??-??.*");
                    if (fileEntries.Length > 0)
                    {
                        Array.Sort(fileEntries);
                        Array.Reverse(fileEntries);

                        foreach (string fName in fileEntries)
                        {
                            if (news_count < 10)
                            {
                                DateTime aDate;
                                if (DateTime.TryParse(Path.GetFileNameWithoutExtension(fName), out aDate))
                                {
                                    using (StreamReader aFile = new StreamReader(fName, Encoding.ASCII))
                                    {
                                        string line = aFile.ReadLine(); // read Headline
                                        if (line != null)
                                        {
                                            string line2 = aFile.ReadToEnd(); // read Content
                                            if (line2 != null)
                                            {
                                                NewsList nl = new NewsList();
                                                nl.Head  = line;
                                                nl.Msg   = line2;
                                                nl.Day   = (short)aDate.Day;
                                                nl.Month = (short)aDate.Month;
                                                nl.Year  = (short)aDate.Year;
                                                Systems.News_List.Add(nl);
                                                news_count++;
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                Console.WriteLine("Please remove old news, only 10 are loaded!");
                            }
                        }
                    }
                }
                catch { }
                string articles = "Article";
                if (news_count > 1)
                {
                    articles = "Articles";
                }
                Console.WriteLine("[INFO] Loaded " + news_count + " news " + articles + "");
            }
            catch (Exception ex)
            {
                Console.WriteLine("News error " + ex);
            }
        }