コード例 #1
0
ファイル: Sermon.cs プロジェクト: WillOmae/MySermons
        static public string[] GetSermonComponents(int id)
        {
            Database.Sermon dummy  = new Database.Sermon(id);
            Sermon          sermon = new Sermon(dummy.Id, dummy.SeriesId, dummy.DateCreated, dummy.Venue, dummy.Town, dummy.Activity, dummy.Speaker, dummy.KeyText, dummy.Hymn, dummy.Title, dummy.Theme, dummy.Content);

            return(ComponentsToString(sermon));
        }
コード例 #2
0
ファイル: Sermon.cs プロジェクト: WillOmae/MySermons
 static public string[] ComponentsToString(Sermon sermon)
 {
     try
     {
         string[] arraySermonComponents = { sermon.Id.ToString(), sermon.SeriesId.ToString(), sermon.DateCreated.ToString(), sermon.Venue, sermon.Town, sermon.Activity, sermon.Speaker, sermon.Title, sermon.Theme, sermon.KeyText, sermon.Hymn, sermon.Content };
         return(arraySermonComponents);
     }
     catch
     {
         return(null);
     }
 }
コード例 #3
0
 static public string[] OpenSermonFromID(int id)
 {
     return(Sermon.GetSermonComponents(id));
 }
コード例 #4
0
ファイル: RecoverSermons.cs プロジェクト: WillOmae/MySermons
        /* GetPreRecordedSermons();
         * This function is used to recover sermons written in other simple formats e.g. xyz.txt
         * Using predefined tags, it scans through the existing file, extracting data for each tag as required
         */
        private void GetPreRecordedSermons(string szSourceFilename)
        {
            try
            {
                string szLine, szDate = "", szVenue = "", szActivity = "", szSpeaker = "", szKeyText = "",
                       szHymn = "", szTitle = "", szContent = "";

                StreamReader myFile = File.OpenText(szSourceFilename);
                int          iPrevCount = 0, iFinalCount = 0, iError = 0;
                iPrevCount = Sermon.GetSermonCount();

                while ((szLine = myFile.ReadLine()) != null)
                {
                    if (szLine.StartsWith("Venue:") == true)
                    {
                        if (szVenue.Length != 0)
                        {
                            szContent = GenerateRtf(szContent);
                            try
                            {
                                string[] arraySubItems = { "0", "0", szDate, szVenue, szVenue, szActivity, szSpeaker, szTitle, szKeyText, szHymn, szContent };
                                if (Sermon.WriteSermon(arraySubItems) == -1)
                                {
                                    iError++;
                                }
                            }
                            catch
                            {
                                string[] arraySubItems = { "0", "0", "01/01/2015", szVenue, szVenue, szActivity, szSpeaker, szTitle, szKeyText, szHymn, szContent };
                                if (Sermon.WriteSermon(arraySubItems) == -1)
                                {
                                    iError++;
                                }
                            }
                        }
                        szVenue    = szLine.Replace("Venue: ", "");
                        szActivity = "_default_value_"; szDate = "_default_value_";
                        szSpeaker  = "_default_value_"; szTitle = "_default_value_";
                        szKeyText  = "_default_value_"; szHymn = "_default_value_";
                        szContent  = "_default_value_"; szLine = "_default_value_";
                    }
                    else if (szLine.ToLower().StartsWith("activity:") == true)
                    {
                        szActivity = szLine.Replace("Activity: ", "");
                    }
                    else if (szLine.ToLower().StartsWith("date:") == true)
                    {
                        szDate = szLine.Replace("Date: ", "");
                    }
                    else if (szLine.ToLower().StartsWith("speaker:") == true)
                    {
                        szSpeaker = szLine.Replace("Speaker: ", "");
                    }
                    else if (szLine.ToLower().StartsWith("theme: ") == true)
                    {
                        szTitle = szLine.Replace("Theme: ", "");
                    }
                    else if (szLine.ToLower().StartsWith("key text:") == true)
                    {
                        szKeyText = szLine.Replace("Key Text: ", "");
                    }
                    else if (szLine.ToLower().StartsWith("hymn:") == true)
                    {
                        szHymn = szLine.Replace("Hymn: ", "");
                    }
                    else
                    {
                        if (szContent.Contains("_default_value_"))
                        {
                            szContent = "";
                        }
                        szContent += szLine + Environment.NewLine;
                    }
                }
                iFinalCount = Sermon.GetSermonCount();
                MessageBox.Show("Recovered " + (iFinalCount - iPrevCount) + " sermons."
                                + "\n\n" + iError.ToString() + " sermon(s) already exist and were not added.",
                                "SUCCESSFUL RECOVERY!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }