Example #1
0
 public static string GetValue(ECharset type)
 {
     if (type == ECharset.utf_8)
     {
         return("utf-8");
     }
     if (type == ECharset.gb2312)
     {
         return("gb2312");
     }
     if (type == ECharset.big5)
     {
         return("big5");
     }
     if (type == ECharset.iso_8859_1)
     {
         return("iso-8859-1");
     }
     if (type == ECharset.euc_kr)
     {
         return("euc-kr");
     }
     if (type == ECharset.euc_jp)
     {
         return("euc-jp");
     }
     if (type == ECharset.iso_8859_6)
     {
         return("iso-8859-6");
     }
     if (type == ECharset.windows_874)
     {
         return("windows-874");
     }
     if (type == ECharset.iso_8859_9)
     {
         return("iso-8859-9");
     }
     if (type == ECharset.iso_8859_5)
     {
         return("iso-8859-5");
     }
     if (type == ECharset.iso_8859_8)
     {
         return("iso-8859-8");
     }
     if (type == ECharset.iso_8859_7)
     {
         return("iso-8859-7");
     }
     if (type == ECharset.windows_1258)
     {
         return("windows-1258");
     }
     if (type == ECharset.iso_8859_2)
     {
         return("iso-8859-2");
     }
     throw new Exception();
 }
Example #2
0
        public static SeoMetaInfo GetSeoMetaInfo(string siteUrl, ECharset charset)
        {
            siteUrl = PageUtils.AddProtocolToUrl(siteUrl);
            var content = WebClientUtils.GetRemoteFileSource(siteUrl, charset);

            return(GetSeoMetaInfo(content));
        }
Example #3
0
        public GatherFileRuleInfo(string gatherRuleName, int publishmentSystemId, string gatherUrl, ECharset charset, DateTime lastGatherDate, bool isToFile, string filePath, bool isSaveRelatedFiles, bool isRemoveScripts, string styleDirectoryPath, string scriptDirectoryPath, string imageDirectoryPath, int nodeId, bool isSaveImage, bool isChecked, string contentExclude, string contentHtmlClearCollection, string contentHtmlClearTagCollection, string contentTitleStart, string contentTitleEnd, string contentContentStart, string contentContentEnd, string contentAttributes, string contentAttributesXml, bool isAutoCreate)
        {
            GatherRuleName      = gatherRuleName;
            PublishmentSystemId = publishmentSystemId;
            GatherUrl           = gatherUrl;
            Charset             = charset;
            LastGatherDate      = lastGatherDate;
            IsToFile            = isToFile;

            FilePath            = filePath;
            IsSaveRelatedFiles  = isSaveRelatedFiles;
            IsRemoveScripts     = isRemoveScripts;
            StyleDirectoryPath  = styleDirectoryPath;
            ScriptDirectoryPath = scriptDirectoryPath;
            ImageDirectoryPath  = imageDirectoryPath;

            NodeId                        = nodeId;
            IsSaveImage                   = isSaveImage;
            IsChecked                     = isChecked;
            IsAutoCreate                  = isAutoCreate;
            ContentExclude                = contentExclude;
            ContentHtmlClearCollection    = contentHtmlClearCollection;
            ContentHtmlClearTagCollection = contentHtmlClearTagCollection;
            ContentTitleStart             = contentTitleStart;
            ContentTitleEnd               = contentTitleEnd;
            ContentContentStart           = contentContentStart;
            ContentContentEnd             = contentContentEnd;
            ContentAttributes             = contentAttributes;
            ContentAttributesXml          = contentAttributesXml;
        }
Example #4
0
 public static string GetText(ECharset type)
 {
     if (type == ECharset.utf_8)
     {
         return("Unicode (UTF-8)");
     }
     if (type == ECharset.gb2312)
     {
         return("简体中文 (GB2312)");
     }
     if (type == ECharset.big5)
     {
         return("繁体中文 (Big5)");
     }
     if (type == ECharset.iso_8859_1)
     {
         return("西欧 (iso-8859-1)");
     }
     if (type == ECharset.euc_kr)
     {
         return("韩文 (euc-kr)");
     }
     if (type == ECharset.euc_jp)
     {
         return("日文 (euc-jp)");
     }
     if (type == ECharset.iso_8859_6)
     {
         return("阿拉伯文 (iso-8859-6)");
     }
     if (type == ECharset.windows_874)
     {
         return("泰文 (windows-874)");
     }
     if (type == ECharset.iso_8859_9)
     {
         return("土耳其文 (iso-8859-9)");
     }
     if (type == ECharset.iso_8859_5)
     {
         return("西里尔文 (iso-8859-5)");
     }
     if (type == ECharset.iso_8859_8)
     {
         return("希伯来文 (iso-8859-8)");
     }
     if (type == ECharset.iso_8859_7)
     {
         return("希腊文 (iso-8859-7)");
     }
     if (type == ECharset.windows_1258)
     {
         return("越南文 (windows-1258)");
     }
     if (type == ECharset.iso_8859_2)
     {
         return("中欧 (iso-8859-2)");
     }
     throw new Exception();
 }
Example #5
0
        // 获取指定网页的HTML代码
        private static string GetRemoteFileSource(string url, ECharset charset, string cookieString)
        {
            try
            {
                string retval;
                var    uri   = new Uri(PageUtils.AddProtocolToUrl(url.Trim()));
                var    hwReq = (HttpWebRequest)WebRequest.Create(uri);
                if (!string.IsNullOrEmpty(cookieString))
                {
                    hwReq.Headers.Add("Cookie", cookieString);
                }
                var hwRes = (HttpWebResponse)hwReq.GetResponse();
                hwReq.Method = "Get";
                //hwReq.ContentType = "text/html";
                hwReq.KeepAlive = false;

                using (var reader = new System.IO.StreamReader(hwRes.GetResponseStream(), ECharsetUtils.GetEncoding(charset)))
                {
                    retval = reader.ReadToEnd();
                }

                return(retval);
            }
            catch
            {
                throw new Exception($"页面地址“{url}”无法访问!");
            }
        }
Example #6
0
 public static Encoding GetEncoding(ECharset type)
 {
     if (type == ECharset.utf_8)
     {
         return(new UTF8Encoding(false));
     }
     return(Encoding.GetEncoding(GetValue(type)));
 }
Example #7
0
        public static string ReadText(string filePath, ECharset charset)
        {
            var sr   = new StreamReader(filePath, ECharsetUtils.GetEncoding(charset));
            var text = sr.ReadToEnd();

            sr.Close();
            return(text);
        }
Example #8
0
        public static void WriteText(string filePath, ECharset charset, string content)
        {
            DirectoryUtils.CreateDirectoryIfNotExists(DirectoryUtils.GetDirectoryPath(filePath));

            StreamWriter sw = new StreamWriter(filePath, false, ECharsetUtils.GetEncoding(charset));

            sw.Write(content);
            sw.Flush();
            sw.Close();
        }
Example #9
0
        public static ListItem GetListItem(ECharset type, bool selected)
        {
            var item = new ListItem(GetText(type), GetValue(type));

            if (selected)
            {
                item.Selected = true;
            }
            return(item);
        }
Example #10
0
 public TemplateInfo(int templateId, int publishmentSystemId, string templateName, ETemplateType templateType, string relatedFileName, string createdFileFullName, string createdFileExtName, ECharset charset, bool isDefault)
 {
     _templateId          = templateId;
     _publishmentSystemId = publishmentSystemId;
     _templateName        = templateName;
     _templateType        = templateType;
     _relatedFileName     = relatedFileName;
     _createdFileFullName = createdFileFullName;
     _createdFileExtName  = createdFileExtName;
     _charset             = charset;
     _isDefault           = isDefault;
 }
Example #11
0
 public TemplateInfo(int id, int siteId, string templateName, TemplateType templateType, string relatedFileName, string createdFileFullName, string createdFileExtName, ECharset charset, bool isDefault)
 {
     _id                  = id;
     _siteId              = siteId;
     _templateName        = templateName;
     _templateType        = templateType;
     _relatedFileName     = relatedFileName;
     _createdFileFullName = createdFileFullName;
     _createdFileExtName  = createdFileExtName;
     _charset             = charset;
     _isDefault           = isDefault;
 }
Example #12
0
        public static void AppendText(string filePath, ECharset charset, string content)
        {
            DirectoryUtils.CreateDirectoryIfNotExists(DirectoryUtils.GetDirectoryPath(filePath));

            using (FileStream fs = new FileStream(filePath, FileMode.Append, FileAccess.Write))
            {
                using (StreamWriter sw = new StreamWriter(fs, ECharsetUtils.GetEncoding(charset)))
                {
                    sw.Write(content);
                }
            }
        }
Example #13
0
 public TemplateInfo()
 {
     _id                  = 0;
     _siteId              = 0;
     _templateName        = string.Empty;
     _templateType        = TemplateType.ContentTemplate;
     _relatedFileName     = string.Empty;
     _createdFileFullName = string.Empty;
     _createdFileExtName  = string.Empty;
     _charset             = ECharset.utf_8;
     _isDefault           = false;
 }
Example #14
0
 public static bool Equals(ECharset type, string typeStr)
 {
     if (string.IsNullOrEmpty(typeStr))
     {
         return(false);
     }
     if (string.Equals(GetValue(type).ToLower(), typeStr.ToLower()))
     {
         return(true);
     }
     return(false);
 }
Example #15
0
        public static string UrlEncode(string urlString, ECharset charset)
        {
            if (urlString == null || urlString == "$4")
            {
                return(string.Empty);
            }

            var newValue = urlString.Replace("\"", "'");

            newValue = HttpUtility.UrlEncode(newValue, ECharsetUtils.GetEncoding(charset));
            newValue = newValue.Replace("%2f", "/");
            return(newValue);
        }
Example #16
0
 public static string ReadText(string filePath, ECharset charset)
 {
     if (IsFileExists(filePath))
     {
         StreamReader sr   = new StreamReader(filePath, ECharsetUtils.GetEncoding(charset));
         string       text = sr.ReadToEnd();
         sr.Close();
         return(text);
     }
     else
     {
         return(string.Empty);
     }
 }
Example #17
0
        /// <summary>
        /// 在操作系统中创建文件,如果文件存在,重新创建此文件
        /// </summary>
        public void GenerateFile(string filePath, ECharset charset, StringBuilder contentBuilder)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                return;
            }

            try
            {
                FileUtils.WriteText(filePath, charset, contentBuilder.ToString());
            }
            catch
            {
                FileUtils.RemoveReadOnlyAndHiddenIfExists(filePath);
                FileUtils.WriteText(filePath, charset, contentBuilder.ToString());
            }
        }
Example #18
0
        //private string CreateIncludeFile(string virtualUrl, bool isCreateIfExists)
        //{
        //    var templateInfo = new TemplateInfo(0, SiteId, string.Empty, TemplateType.FileTemplate, string.Empty, string.Empty, string.Empty, ECharsetUtils.GetEnumType(SiteInfo.Additional.Charset), false);
        //    var pageInfo = new PageInfo(SiteId, 0, SiteInfo, templateInfo, null);
        //    var contextInfo = new ContextInfo(pageInfo);

        //    var parsedVirtualUrl = virtualUrl.Substring(0, virtualUrl.LastIndexOf('.')) + "_parsed" + virtualUrl.Substring(virtualUrl.LastIndexOf('.'));
        //    var filePath = PathUtility.MapPath(SiteInfo, parsedVirtualUrl);
        //    if (!isCreateIfExists && FileUtils.IsFileExists(filePath)) return parsedVirtualUrl;

        //    var contentBuilder = new StringBuilder(StlCacheManager.FileContent.GetIncludeContent(SiteInfo, virtualUrl, pageInfo.TemplateInfo.Charset));
        //    StlParserManager.ParseTemplateContent(contentBuilder, pageInfo, contextInfo);
        //    var pageAfterBodyScripts = StlParserManager.GetPageInfoScript(pageInfo, true);
        //    var pageBeforeBodyScripts = StlParserManager.GetPageInfoScript(pageInfo, false);
        //    contentBuilder.Insert(0, pageBeforeBodyScripts);
        //    contentBuilder.Append(pageAfterBodyScripts);
        //    GenerateFile(filePath, pageInfo.TemplateInfo.Charset, contentBuilder);
        //    return parsedVirtualUrl;
        //}

        /// <summary>
        /// 在操作系统中创建文件,如果文件存在,重新创建此文件
        /// </summary>
        private static async Task GenerateFileAsync(string filePath, ECharset charset, StringBuilder contentBuilder)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                return;
            }

            try
            {
                await FileUtils.WriteTextAsync(filePath, ECharsetUtils.GetEncoding(charset), contentBuilder.ToString());
            }
            catch
            {
                FileUtils.RemoveReadOnlyAndHiddenIfExists(filePath);
                await FileUtils.WriteTextAsync(filePath, ECharsetUtils.GetEncoding(charset), contentBuilder.ToString());
            }
        }
Example #19
0
 public static bool GetRemoteHtml(string url, ECharset charset, string cookieString, out string content, out string errorMessage)
 {
     content      = string.Empty;
     errorMessage = string.Empty;
     for (var i = 0; i < 2; i++)
     {
         try
         {
             content = GetRemoteFileSource(url, charset, cookieString);
             return(true);
         }
         catch (Exception ex)
         {
             errorMessage = ex.Message;
         }
     }
     return(false);
 }
Example #20
0
        public static string GetContentByFilePath(string filePath, ECharset charset = ECharset.utf_8)
        {
            try
            {
                if (CacheUtils.Get(filePath) != null)
                {
                    return(CacheUtils.Get(filePath) as string);
                }

                var content = string.Empty;
                if (FileUtils.IsFileExists(filePath))
                {
                    content = FileUtils.ReadText(filePath, charset);
                }

                CacheUtils.Insert(filePath, content, TimeSpan.FromHours(12), filePath);
                return(content);
            }
            catch
            {
                return(string.Empty);
            }
        }
Example #21
0
        public static string GetContentByFilePath(string filePath, ECharset charset = ECharset.utf_8)
        {
            try
            {
                var content = DataCacheManager.Get <string>(filePath);
                if (content != null)
                {
                    return(content);
                }

                if (FileUtils.IsFileExists(filePath))
                {
                    content = FileUtils.ReadText(filePath, charset);
                }

                DataCacheManager.Insert(filePath, content, TimeSpan.FromHours(12), filePath);
                return(content);
            }
            catch
            {
                return(string.Empty);
            }
        }
Example #22
0
            public static string GetContentByFilePath(string filePath, ECharset charset = ECharset.utf_8)
            {
                try
                {
                    if (CacheUtils.Get(filePath) != null)
                    {
                        return(CacheUtils.Get(filePath) as string);
                    }

                    var content = string.Empty;
                    if (FileUtils.IsFileExists(filePath))
                    {
                        content = FileUtils.ReadText(filePath, charset);
                    }

                    CacheUtils.Insert(filePath, content, new CacheDependency(filePath), CacheUtils.HourFactor);
                    return(content);
                }
                catch
                {
                    return(string.Empty);
                }
            }
Example #23
0
 public GatherRuleInfo(string gatherRuleName, int publishmentSystemId, string cookieString, bool gatherUrlIsCollection, string gatherUrlCollection, bool gatherUrlIsSerialize, string gatherUrlSerialize, int serializeFrom, int serializeTo, int serializeInterval, bool serializeIsOrderByDesc, bool serializeIsAddZero, int nodeId, ECharset charset, string urlInclude, string titleInclude, string contentExclude, string contentHtmlClearCollection, string contentHtmlClearTagCollection, DateTime lastGatherDate, string listAreaStart, string listAreaEnd, string contentChannelStart, string contentChannelEnd, string contentTitleStart, string contentTitleEnd, string contentContentStart, string contentContentEnd, string contentNextPageStart, string contentNextPageEnd, string contentAttributes, string contentAttributesXml, string extendValues)
 {
     GatherRuleName         = gatherRuleName;
     PublishmentSystemId    = publishmentSystemId;
     CookieString           = cookieString;
     GatherUrlIsCollection  = gatherUrlIsCollection;
     GatherUrlCollection    = gatherUrlCollection;
     GatherUrlIsSerialize   = gatherUrlIsSerialize;
     GatherUrlSerialize     = gatherUrlSerialize;
     SerializeFrom          = serializeFrom;
     SerializeTo            = serializeTo;
     SerializeInterval      = serializeInterval;
     SerializeIsOrderByDesc = serializeIsOrderByDesc;
     SerializeIsAddZero     = serializeIsAddZero;
     NodeId                        = nodeId;
     Charset                       = charset;
     UrlInclude                    = urlInclude;
     TitleInclude                  = titleInclude;
     ContentExclude                = contentExclude;
     ContentHtmlClearCollection    = contentHtmlClearCollection;
     ContentHtmlClearTagCollection = contentHtmlClearTagCollection;
     LastGatherDate                = lastGatherDate;
     ListAreaStart                 = listAreaStart;
     ListAreaEnd                   = listAreaEnd;
     ContentChannelStart           = contentChannelStart;
     ContentChannelEnd             = contentChannelEnd;
     ContentTitleStart             = contentTitleStart;
     ContentTitleEnd               = contentTitleEnd;
     ContentContentStart           = contentContentStart;
     ContentContentEnd             = contentContentEnd;
     ContentNextPageStart          = contentNextPageStart;
     ContentNextPageEnd            = contentNextPageEnd;
     ContentAttributes             = contentAttributes;
     ContentAttributesXml          = contentAttributesXml;
     ExtendValues                  = extendValues;
 }
Example #24
0
            public static string GetCommentsTemplateContent(ECharset charset)
            {
                return
                    ($@"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">
<html xmlns=""http://www.w3.org/1999/xhtml"">
<head>
<meta http-equiv=""Content-Type"" content=""text/html; charset={ECharsetUtils.GetValue(charset)}"" />
<title>评论</title>
<style>
*{{font-size:12px}}
</style>
</head>

<body>

<stl:comments isPage=""true"" pageNum=""20"" isLinkToAll=""false""></stl:comments>

<br />

<stl:commentInput isDynamic=""true""></stl:commentInput>

</body>
</html>");
            }
Example #25
0
            public static string GetSearchTemplateContent(ECharset charset)
            {
                return
                    ($@"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">
<html xmlns=""http://www.w3.org/1999/xhtml"">
<head>
<meta http-equiv=""Content-Type"" content=""text/html; charset={ECharsetUtils.GetValue(charset)}"" />
<title>搜索</title>
<style>
*{{font-size:12px}}
</style>
</head>

<body>

<stl:searchInput openwin=""false"" isLoadValues=""true""></stl:searchInput>

<br />

<stl:searchOutput isHighlight=""true""></stl:searchOutput>

</body>
</html>");
            }
Example #26
0
            public static string GetIncludeContent(PublishmentSystemInfo publishmentSystemInfo, string file, ECharset charset)
            {
                var filePath = PathUtility.MapPath(publishmentSystemInfo, PathUtility.AddVirtualToPath(file));

                return(GetContentByFilePath(filePath, charset));
            }
Example #27
0
 public static string GetRemoteFileSource(string url, ECharset charset)
 {
     return(GetRemoteFileSource(url, charset, string.Empty));
 }
Example #28
0
 public static string UrlDecode(string urlString, ECharset charset)
 {
     return(HttpUtility.UrlDecode(urlString, ECharsetUtils.GetEncoding(charset)));
 }
Example #29
0
        // Reads a GEDCOM file into a hierarchy of data structures
        public void ParseFile()
        {
            LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note,  "ParseFile()" );

            CThreadError threaderror = new CThreadError( 1, "No error" ); // 2 = process was aborted, for signalling back to calling thread. 1= cancelled by user action
            m_nLineIndex = -1; // Used to indicate to exception handling that stage2 parsing hasn't started

            FileStream fileStream = null;
            StreamReader streamReader = null;

            ClearOutParser();
            LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "ParseFile() ClearOutParser" );
            string sParseLine="";

            try
            {
                m_progressWindow.Begin( 0, 100 );
                LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "Progress window begun" );

                // Discern file character set by reading first 2 bytes of file
                FileStream fsCharsetDetection = new FileStream( Filename, FileMode.Open, FileAccess.Read );
                StreamReader srCharsetDetection = null;
                try
                {
                    byte[] abFirstBytes = new byte[2];
                    fsCharsetDetection.Read( abFirstBytes, 0, 2 );
                    fsCharsetDetection.Seek( 0, SeekOrigin.Begin );

                    m_ecCharset = ECharset.Unknown8bit;
                    string sCharset = "ANSI";
                    if( (abFirstBytes[0] == 0xff && abFirstBytes[1] == 0xfe) || (abFirstBytes[0] == 0x30 && abFirstBytes[1] == 0x00) )
                    {
                        m_ecCharset = ECharset.Unicode;
                    }
                    else if( (abFirstBytes[0] == 0xfe && abFirstBytes[1] == 0xff) || (abFirstBytes[0] == 0x00 && abFirstBytes[1] == 0x30) )
                    {
                        m_ecCharset = ECharset.UnicodeReversed;
                    }

                    switch( m_ecCharset )
                    {
                        case ECharset.Unicode:
                            srCharsetDetection = new StreamReader( fsCharsetDetection, System.Text.Encoding.GetEncoding("UTF-16BE") );
                            break;
                        case ECharset.UnicodeReversed:
                            srCharsetDetection = new StreamReader( fsCharsetDetection, System.Text.Encoding.GetEncoding("UTF-16LE") );
                            break;
                        default:
                            srCharsetDetection = new StreamReader( fsCharsetDetection, System.Text.Encoding.GetEncoding("utf-8") );
                            break;
                    }
                    if( srCharsetDetection != null )
                    {
                        string sCharsetDetectionLine = "";
                        do
                        {
                            sCharsetDetectionLine = srCharsetDetection.ReadLine();
                            if( sCharsetDetectionLine != "" && sCharsetDetectionLine != null )
                            {
                                sCharsetDetectionLine = sCharsetDetectionLine.ToUpper();
                                sCharsetDetectionLine = sCharsetDetectionLine.Trim();
                            }
                        }
                        while( sCharsetDetectionLine != null && ( sCharsetDetectionLine.Length < 7 || sCharsetDetectionLine.Substring(0,7) != "1 CHAR " ) );
                        if( sCharsetDetectionLine != null )
                        {
                            sCharset = sCharsetDetectionLine.Substring(7);
                            if( m_ecCharset != ECharset.Unicode && m_ecCharset != ECharset.UnicodeReversed ) // If file is in unicode format, ignore charset string cos we already know format.
                            {
                                // Using substring here to ignore trailing spaces
                                if( sCharset.Length >= 5 && sCharset.Substring(0,5) == "ASCII" )
                                {
                                    m_ecCharset = ECharset.Ascii;
                                }
                                else if( sCharset.Length >= 4 && sCharset.Substring(0,4) == "ANSI" )
                                {
                                    m_ecCharset = ECharset.Ansi;
                                }
                                else if( sCharset.Length >= 5 && sCharset.Substring(0,5) == "ANSEL" )
                                {
                                    m_ecCharset = ECharset.Ansel;
                                }
                                else if( sCharset.Length >= 4 && sCharset.Substring(0,4) == "UTF8" )
                                {
                                    m_ecCharset = ECharset.UTF8;
                                }
                                else if( sCharset.Length >= 5 && sCharset.Substring(0,5) == "UTF-8" )
                                {
                                    m_ecCharset = ECharset.UTF8;
                                }
                                else if( sCharset.Length >= 7 && sCharset.Substring(0,7) == "UNICODE" )
                                {
                                    m_ecCharset = ECharset.Unicode;
                                }
                                else if( sCharset.Length >= 5 && sCharset.Substring(0,5) == "UTF16" )
                                {
                                    m_ecCharset = ECharset.Unicode;
                                }
                                else if( sCharset.Length >= 6 && sCharset.Substring(0,6) == "UTF-16" )
                                {
                                    m_ecCharset = ECharset.Unicode;
                                }
                            }
                        }
                    }

                }
                catch( Exception e )
                {
                    LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "Caught exception while trying to discern character set :" + e.ToString() );
                    m_ecCharset = ECharset.UTF8;
                }

                if( srCharsetDetection != null )
                {
                    srCharsetDetection.Close();
                }
                if( fsCharsetDetection != null )
                {
                    fsCharsetDetection.Close();
                }

                LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "Opening file with charset " + m_ecCharset.ToString() );
                fileStream = new FileStream( Filename, FileMode.Open, FileAccess.Read );

                System.Text.Encoding encoding = System.Text.Encoding.GetEncoding("iso-8859-1");
                switch( m_ecCharset )
                {
                    case ECharset.Ascii:
                        encoding = System.Text.Encoding.GetEncoding("ascii");
                        break;
                    case ECharset.Ansi:
                        encoding = System.Text.Encoding.GetEncoding("iso-8859-1");
                        break;
                    case ECharset.Ansel:
                        encoding = System.Text.Encoding.GetEncoding("iso-8859-1");
                        break;
                    case ECharset.UTF8:
                        encoding = System.Text.Encoding.GetEncoding("utf-8");
                        break;
                    case ECharset.Unicode:
                        encoding = System.Text.Encoding.GetEncoding("UTF-16BE");
                        break;
                    case ECharset.UnicodeReversed:
                        encoding = System.Text.Encoding.GetEncoding("UTF-16LE");
                        break;
                    default:
                        encoding = System.Text.Encoding.GetEncoding("utf-8");
                        break;
                }

                streamReader = new StreamReader( fileStream, encoding );

                LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "Stream created" );

                m_nBytesRead = 0;
                m_nBytesTotal = fileStream.Length;
                uint uLineInFile = 0;

                // Read all lines in file into memory
                int nPercentComplete, nPreviousPercentComplete = 0;
                for(;;)
                {
                    if( m_progressWindow.IsAborting )
                    {

                        LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "Progress window aborting  (1)" );

                        return;
                    }

                    sParseLine = streamReader.ReadLine();
                    if( m_ecCharset == ECharset.Ansel )
                    {
                        sParseLine = ConvertAnsel( sParseLine );
                    }

                    if(  sParseLine == null )
                    {
                        LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "No more lines, end of file" );
                        // No more lines, end of file
                        break;
                    }

                    uLineInFile++;

                    m_nBytesRead += sParseLine.Length + 1; // Interim fix. Should actually count bytes according to whether gedcomLine ends with CR or CRLF.

                    nPercentComplete = (int)(m_nBytesRead * 100 / m_nBytesTotal);
                    if( nPercentComplete != nPreviousPercentComplete )
                    {
                        nPreviousPercentComplete = nPercentComplete;
                        m_progressWindow.SetText( String.Format( "Bytes read: {0}", m_nBytesRead ) );
                        if( nPercentComplete > 100 )
                        {
                            LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "Percent set to 100 (1)" );

                            // Safety valve. Prevents control from throwing.
                            nPercentComplete = 100;
                        }
                        m_progressWindow.StepTo( nPercentComplete );
                    }

                    if( sParseLine.Length != 0 )
                    {
                        try
                        {
                            CGedcomLine gedcomLine = ParseLine( sParseLine, uLineInFile );
                            if( gedcomLine != null )
                            {
                                m_alLines.Add( gedcomLine );
                            }
                        }
                        catch( CParsingException )
                        {
                            LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Warning, String.Concat("Unable to parse line ", uLineInFile.ToString(), ":", sParseLine ) );
                        }
                    }
                    // Signal waiting app that parse has finished
                }
                if( m_progressWindow.IsAborting )
                {
                    LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "Progress window aborting  (2)" );
                    return;
                }

                // Parse lines of file
                m_nLineIndex = 0;
                sParseLine="";
                int nLines = m_alLines.Count;

                m_progressWindow.SetText( String.Format( "Parsing file line: {0} out of {1}", m_nLineIndex, nLines ) );

                nPercentComplete = (int)(m_nLineIndex * 100 / nLines);
                if( nPercentComplete > 100 )
                {
                    // Safety valve. Prevents control from throwing.
                    nPercentComplete = 100;
                }
                m_progressWindow.StepTo( nPercentComplete );
                if( m_progressWindow.IsAborting )
                {
                    LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "Progress window aborting  (3)" );
                    return;
                }

                if( !ParseHeader() )
                {
                    // Mandatory header missing/corrupt
                    throw new CParsingException( "Header missing or corrupt" );
                }
                m_progressWindow.SetText( String.Format( "Parsing file line: {0} out of {1}", m_nLineIndex, nLines ) );
                nPercentComplete = (int)(m_nLineIndex * 100 / nLines);
                if( nPercentComplete > 100 )
                {
                    // Safety valve. Prevents control from throwing.
                    nPercentComplete = 100;
                }
                m_progressWindow.StepTo( nPercentComplete );
                if( m_progressWindow.IsAborting )
                {
                    LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "Progress window aborting  (4)" );
                    return;
                }

                m_submissionRecord = CSubmissionRecord.Parse( this, 0 );
                m_progressWindow.SetText( String.Format( "Parsing file line: {0} out of {1}", m_nLineIndex, nLines ) );
                nPercentComplete = (int)(m_nLineIndex * 100 / nLines);
                if( nPercentComplete > 100 )
                {
                    // Safety valve. Prevents control from throwing.
                    LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "Percent set to 100 (2)" );
                    nPercentComplete = 100;
                }
                m_progressWindow.StepTo( nPercentComplete );
                if( m_progressWindow.IsAborting )
                {
                    LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "Progress window aborting  (5)" );

                    return;
                }

                int nRecords = 0;

                CFamilyRecord fr;
                CIndividualRecord ir;
                CMultimediaRecord mr;
                CNoteRecord nr;
                CRepositoryRecord rr;
                CSourceRecord sr;
                CSubmitterRecord smr;

                CGedcomLine gedcomLine2;

                bool bParsingSuccessful = false;
                bool bParsingFinished;
                do
                {
                    bParsingFinished = false;
                    m_progressWindow.SetText( String.Format( "Parsing file line: {0} out of {1}", m_nLineIndex, nLines ) );
                    nPercentComplete = (int)(m_nLineIndex * 100 / nLines);
                    if( nPercentComplete > 100 )
                    {
                        // Safety valve. Prevents control from throwing.
                        nPercentComplete = 100;
                    }
                    m_progressWindow.StepTo( nPercentComplete );
                    if( m_progressWindow.IsAborting )
                    {
                        LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "Progress window aborting  (6)" );
                        return;
                    }

                    if( (fr = CFamilyRecord.Parse( this, 0 )) != null )
                    {
                        m_alFamilyRecords.Add( fr );
                        m_htFamilyRecordsXref.Add( fr.m_xref, fr );
                        ++nRecords;
                        bParsingFinished = false;
                    }
                    else if( (ir = CIndividualRecord.Parse( this, 0)) != null )
                    {
                        m_alIndividualRecords.Add( ir );
                        m_htIndividualRecordsXref.Add( ir.m_xref, ir );
                        ++nRecords;
                        bParsingFinished = false;
                    }
                    else if( (mr = CMultimediaRecord.Parse( this, 0 )) != null )
                    {
                        m_alMultimediaRecords.Add( mr );
                        ++nRecords;
                        bParsingFinished = false;
                    }
                    else if( (nr = CNoteRecord.Parse( this, 0 )) != null )
                    {
                        m_alNoteRecords.Add( nr );
                        ++nRecords;
                        bParsingFinished = false;
                    }
                    else if( (rr = CRepositoryRecord.Parse( this, 0 )) != null )
                    {
                        m_alRepositoryRecords.Add( rr );
                        ++nRecords;
                        bParsingFinished = false;
                    }
                    else if( (sr = CSourceRecord.Parse( this, 0 )) != null )
                    {
                        m_alSourceRecords.Add( sr );
                        m_htSourceRecordsXref.Add( sr.m_xref, sr );
                        ++nRecords;
                        bParsingFinished = false;
                    }
                    else if( ( smr = CSubmitterRecord.Parse( this, 0 )) != null )
                    {
                        m_alSubmitterRecords.Add( smr );
                        ++nRecords;
                        bParsingFinished = false;
                    }
                    else if( ( gedcomLine2 = GetLine( 0, "TRLR" )) != null )
                    {
                        LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "TRLR found OK" );
                        bParsingSuccessful = true;
                    }
                    else
                    {
                        // Skip this unknown gedcomLine
                        LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Warning, "WARNING: Couldn't parse line:" );
                        LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Warning, GetLine().ToString() );
                        m_nLineIndex++;
                    }
                } // end do
                while( m_nLineIndex < nLines && !bParsingSuccessful && !bParsingFinished );
                LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "Parsing ended normally." );

                // Tie up adopted individuals with their associated fr
                LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "Linking adoptees." );
                foreach( CIndividualRecord adopIr in m_alAdoptedIndividuals )
                {
                    CEventDetail adopEvent = adopIr.GetEvent( "ADOP" );
                    if( adopEvent != null )
                    {
                        string adopFamXref = adopEvent.m_xrefFam;
                        bool adopHusband = adopEvent.m_bAdoptedByHusband;
                        bool adopWife = adopEvent.m_bAdoptedByWife;
                        CFamilyRecord adopFam = GetFamilyRecord( adopFamXref );
                        if( adopFam!=null && (adopHusband || adopWife) )
                        {
                            if( adopHusband )
                            {
                                CIndividualRecord irAdopHusband = GetIndividualRecord( adopFam.m_xrefHusband );
                                if( irAdopHusband != null )
                                {
                                    CIndividualEventStructure husbandAdopEvent = new CIndividualEventStructure( adopEvent );
                                    husbandAdopEvent.Type = "GEDMILL_ADOPTION_OF_CHILD"; // Special GEDmill only event
                                    husbandAdopEvent.m_eventDetail.m_xrefAdoptedChild = adopIr.m_xref;
                                    irAdopHusband.m_alIndividualEventStructures.Add( husbandAdopEvent );
                                }
                            }
                            if( adopWife )
                            {
                                CIndividualRecord irAdopWife = GetIndividualRecord( adopFam.m_xrefWife );
                                if( irAdopWife != null )
                                {
                                    CIndividualEventStructure wifeAdopEvent = new CIndividualEventStructure( adopEvent );
                                    wifeAdopEvent.Type = "GEDMILL_ADOPTION_OF_CHILD"; // Special GEDmill only event
                                    wifeAdopEvent.m_eventDetail.m_xrefAdoptedChild = adopIr.m_xref;
                                    irAdopWife.m_alIndividualEventStructures.Add( wifeAdopEvent );
                                }
                            }

                        }
                    }
                }

                LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "Linking indi backreferences." );
                foreach( CIndividualRecord brir in m_alIndividualRecords )
                {
                    foreach( CIndividualEventStructure ies in brir.m_alIndividualEventStructures )
                    {
                        if( ies.m_eventDetail != null )
                        {
                            foreach( CSourceCitation sc in ies.m_eventDetail.m_alSourceCitations )
                            {
                                sc.AddBackreference(new CBackReference(ERecordType.Individual, brir.m_xref, ies.Type));
                                sc.AddPicFromCitationToRecord();
                            }
                            foreach( CNoteStructure ns in ies.m_eventDetail.m_alNoteStructures )
                            {
                                if( ns != null && ns.m_alSourceCitations != null )
                                {
                                    foreach( CSourceCitation sc in ns.m_alSourceCitations )
                                    {
                                        sc.AddBackreference(new CBackReference(ERecordType.Individual, brir.m_xref, ies.Type));
                                        sc.AddPicFromCitationToRecord();
                                    }
                                }
                            }
                        }
                    }
                    foreach( CPersonalNameStructure pns in brir.m_alPersonalNameStructures )
                    {
                        if( pns.m_personalNamePieces != null )
                        {
                            foreach( CSourceCitation sc in pns.m_personalNamePieces.m_alSourceCitations )
                            {
                                sc.AddBackreference( new CBackReference( ERecordType.Individual, brir.m_xref, "NAME" ) );
                                sc.AddPicFromCitationToRecord();
                            }
                        }
                    }
                    foreach( CSourceCitation sc in brir.m_alSourceCitations )
                    {
                        sc.AddBackreference( new CBackReference( ERecordType.Individual, brir.m_xref, "" ) );
                        sc.AddPicFromCitationToRecord();
                    }
                }
                foreach( CFamilyRecord brfr in m_alFamilyRecords )
                {
                    foreach( CFamilyEventStructure fes in brfr.m_alFamilyEventStructures )
                    {
                        if( fes.m_eventDetail != null )
                        {
                            foreach( CSourceCitation sc in fes.m_eventDetail.m_alSourceCitations )
                            {
                                sc.AddBackreference(new CBackReference(ERecordType.Family, brfr.m_xref, fes.Type));
                                sc.AddPicFromCitationToRecord();
                            }
                            foreach( CNoteStructure ns in fes.m_eventDetail.m_alNoteStructures )
                            {
                                if( ns != null && ns.m_alSourceCitations != null )
                                {

                                    foreach( CSourceCitation sc in ns.m_alSourceCitations )
                                    {
                                        sc.AddBackreference(new CBackReference(ERecordType.Family, brfr.m_xref, fes.Type));
                                        sc.AddPicFromCitationToRecord();
                                    }
                                }
                            }

                        }
                    }
                    foreach( CSourceCitation sc in brfr.m_alSourceCitations )
                    {
                        sc.AddBackreference( new CBackReference( ERecordType.Family, brfr.m_xref, "" ) );
                        sc.AddPicFromCitationToRecord();
                    }

                }
                foreach( CNoteRecord brnr in m_alNoteRecords )
                {
                    foreach( CSourceCitation sc in brnr.m_alSourceCitations )
                    {
                        sc.AddBackreference( new CBackReference( ERecordType.Note, brnr.m_xref, "" ) );
                        sc.AddPicFromCitationToRecord();
                    }
                }

                // Join together fragmented multimedia files
                LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "Joining multimedia fragments." );
                // Go through all the MFRs in every link in every record.
                foreach( CSourceRecord isr in m_alSourceRecords )
                {
                    JoinMultimedia( isr.m_alMultimediaLinks );
                }
                foreach( CIndividualRecord iir in m_alIndividualRecords )
                {
                    JoinMultimedia( iir.m_alMultimediaLinks );
                }

                // Create a list of MFRs unique to the individual
                LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "Ordering individual's mfrs." );
                foreach( CIndividualRecord irMultimedia in m_alIndividualRecords )
                {
                    ConvertMultimediaLinks( irMultimedia.m_alMultimediaLinks, ref irMultimedia.m_alUniqueFileRefs );
                }
                // Create a list of MFRs unique to the source
                LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "Ordering source's mfrs." );
                foreach( CSourceRecord srMultimedia in m_alSourceRecords )
                {
                    ConvertMultimediaLinks( srMultimedia.m_alMultimediaLinks, ref srMultimedia.m_alUniqueFileRefs );
                }

                // Moved inside try block as any exception it threw would not otherwise be caught:
                AddChildrenToFamilies();

                // Ended normally
                threaderror.m_nError = 0;
            }
            catch( System.Threading.ThreadAbortException e )
            {
                // Abnormal abort
                threaderror.m_nError = 2;
                threaderror.m_sMessage = "";
                LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Error, String.Format("Caught thread exception : {0}", e.ToString() ) );
            }
            catch( System.Threading.ThreadInterruptedException e )
            {
                // Abnormal abort
                threaderror.m_nError = 2;
                threaderror.m_sMessage = "";
                LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Error, String.Format( "Caught thread exception : {0}", e.ToString() ) );
            }
            catch( CParsingException e )
            {
                // Abnormal abort
                threaderror.m_nError = 2;
                threaderror.m_sMessage = "";
                string sLine = sParseLine;
                if( m_nLineIndex>=0 )
                {
                    if( m_nLineIndex >= m_alLines.Count )
                    {
                        sLine = "EOF";
                    }
                    else
                    {
                        sLine = ((CGedcomLine)(m_alLines[m_nLineIndex])).ToString();
                    }
                }

                LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Error, String.Format("Caught parsing exception in file {0}, line {1} ({2}) : {3}", Filename, m_nLineIndex, sLine, e.ToString() ) );

                // And here, if we can
            }
            catch( System.IO.IOException e )
            {
                // Abnormal abort, offer retry, file already open.
                threaderror.m_nError = 3;
                threaderror.m_sMessage = "";
                LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Error, String.Format("Caught IO exception (line index={0}) : {1}", m_nLineIndex, e.ToString() ) );
            }
            catch( Exception e )
            {
                // Abnormal abort
                threaderror.m_nError = 2;
                threaderror.m_sMessage = "";
                LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Error, String.Format("Caught generic exception (line index={0}) : {1}", m_nLineIndex, e.ToString() ) );
            }
            finally
            {
                LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "Closing file" );

                if (streamReader != null)
                {
                    streamReader.Close();
                }

                if (fileStream != null)
                {
                    fileStream.Close();
                }

                if( m_progressWindow != null )
                {
                    LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "Closing progress window" );

                    m_progressWindow.End( threaderror );
                }

                // Don't need the memory any more:
                m_alLines.Clear();
            }
            LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Note, "All done." );
        }
Example #30
0
 public static void WriteText(string filePath, ECharset charset, string content)
 {
     WriteText(filePath, ECharsetUtils.GetEncoding(charset), content);
 }
Example #31
0
 public static KeyValuePair <string, string> GetListItem(ECharset type)
 {
     return(new KeyValuePair <string, string>(GetValue(type), GetText(type)));
 }
Example #32
0
        // Constructor, sets default values for the config
        public CConfig()
        {
            m_configFilename = "GEDmill Config";
            m_bRestrictConfidential = false;
            m_bRestrictPrivacy = false;
            m_sOutputFolder = "";
            m_sUnknownName = "<unknown>"; // "no name" implied we knew them and they had no name.
            m_nNameCapitalisation = 1;
            m_sVersion = "1.11.0";
            m_sHtmlExtension = "html";
            m_bCopyMultimedia = true;
            m_sImageFolder = "multimedia";
            m_bRelativiseMultimedia = false;
            m_sApplicationPath = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location );
            m_sBackgroundImage = m_sApplicationPath + "\\bg-gedmill.jpg";
            m_uMaxImageWidth = 160;
            m_uMaxImageHeight = 160;
            m_nMaxNumberMultimediaFiles = 32;
            m_nAgeForOccupation = 50;
            m_sOwnersName = Environment.UserName;
            m_sNoSurname = "No Surname";
            m_sIndexTitle = "Index Of Names";
            m_uMaxSourceImageWidth = 800;
            m_uMaxSourceImageHeight = 800;
            m_uMaxThumbnailImageWidth = 45;
            m_uMaxThumbnailImageHeight = 45;
            m_sFirstRecordXref = "";
            m_sTitle = "Family history";
            if( m_sOwnersName != null && m_sOwnersName != "" )
                m_sTitle += " of " + m_sOwnersName;
            m_sInputFilename = "";
            m_sFrontPageImageFilename = m_sApplicationPath + "\\gedmill.jpg";
            m_uTabSpaces = 8;
            m_sPlaceWord = "in";
            m_bCapitaliseEventDescriptions = true;
            m_bDataMayStartWithWhitespace = true;
            m_bRestrictAssociatedSources = true;
            m_bRenameMultimedia = true;
            m_bIndexLetterPerPage = false;
            m_bFrontPageStats = true;
            m_sCommentaryText = "";
            m_sFtpServer = "";
            m_sFtpUsername = "";
            m_sFtpPassword = "";
            m_sFtpUploadFolder = "/";
            m_ecHtmlCharset = ECharset.UTF8;

            // Reset those settings that can be modified by the user on the config screen.
            ResetUserSettings();
        }
Example #33
0
 // Initialise all data of gedcom parser
 private void ClearOutParser()
 {
     m_alLines = new ArrayList();
     m_nBytesRead = 0;
     m_nBytesTotal = 0;
     m_nLineIndex = 0;
     m_alFamilyRecords = new ArrayList();
     m_htFamilyRecordsXref = new Hashtable();
     m_alIndividualRecords = new ArrayList();
     m_htIndividualRecordsXref = new Hashtable();
     m_alMultimediaRecords = new ArrayList();
     m_alNoteRecords = new ArrayList();
     m_alRepositoryRecords = new ArrayList();
     m_alSourceRecords = new ArrayList();
     m_htSourceRecordsXref = new Hashtable();
     m_alSubmitterRecords = new ArrayList();
     m_header = null;
     m_submissionRecord = null;
     m_bDataMayStartWithWhitespace = true;
     m_ecCharset = ECharset.Unknown8bit;
 }
Example #34
0
        // Deserialise all the settings from isolated storage.
        public void RecoverSettings()
        {
            uint uVersionMajor=0, uVersionMinor=0, uVersionBuild=0;

            IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore( IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null );
            if( isoStore.GetFileNames( m_configFilename ).Length == 0 )
            {
                // File doesn't exist. Leave defaults in place.
                return;
            }
            // Read the stream from Isolated Storage.
            Stream stream = new IsolatedStorageFileStream(m_configFilename, FileMode.OpenOrCreate, isoStore );
            if ( stream == null )
            {
                return;
            }

            try
            {
                // DeSerialize the Hashtable from stream.
                IFormatter formatter = new BinaryFormatter();

                m_sVersion = ( string )formatter.Deserialize(stream);
                m_bRestrictConfidential = ( bool )formatter.Deserialize(stream);
                m_bRestrictPrivacy = ( bool )formatter.Deserialize(stream);
                m_sOutputFolder = ( string )formatter.Deserialize(stream);
                m_sUnknownName = ( string )formatter.Deserialize(stream);
                m_nNameCapitalisation = ( int )formatter.Deserialize(stream);
                m_sHtmlExtension = ( string )formatter.Deserialize(stream);
                m_bCopyMultimedia = ( bool )formatter.Deserialize(stream);
                m_sImageFolder = ( string )formatter.Deserialize(stream);
                m_bRelativiseMultimedia = ( bool )formatter.Deserialize(stream);
                m_sBackgroundImage = ( string )formatter.Deserialize(stream);
                m_uMaxImageWidth = ( uint )formatter.Deserialize(stream);
                m_uMaxImageHeight = ( uint )formatter.Deserialize(stream);
                int deprecated_m_nMaxNumberMultimediaFiles = ( int )formatter.Deserialize(stream);
                m_nAgeForOccupation = ( int )formatter.Deserialize(stream);
                m_sOwnersName = ( string )formatter.Deserialize(stream);
                m_sNoSurname = ( string )formatter.Deserialize(stream);
                m_sIndexTitle = ( string )formatter.Deserialize(stream);
                m_uMaxSourceImageWidth = ( uint )formatter.Deserialize(stream);
                m_uMaxSourceImageHeight = ( uint )formatter.Deserialize(stream);
                m_sFirstRecordXref = ( string )formatter.Deserialize(stream);
                m_sTitle = ( string )formatter.Deserialize(stream);
                m_sInputFilename = ( string )formatter.Deserialize(stream);
                m_sApplicationPath = ( string )formatter.Deserialize(stream);
                m_sFrontPageImageFilename = ( string )formatter.Deserialize(stream);
                m_uTabSpaces = ( uint )formatter.Deserialize(stream);
                m_sPlaceWord = (string)formatter.Deserialize(stream);
                m_bCapitaliseEventDescriptions = (bool)formatter.Deserialize(stream);
                m_bDataMayStartWithWhitespace = (bool)formatter.Deserialize(stream);
                m_bRestrictAssociatedSources = (bool)formatter.Deserialize(stream);
                m_bRenameMultimedia = (bool)formatter.Deserialize(stream);
                m_bIndexLetterPerPage = (bool)formatter.Deserialize(stream);
                m_sMiniTreeColourBranch = (string)formatter.Deserialize(stream);
                m_sMiniTreeColourIndiBorder = (string)formatter.Deserialize(stream);
                m_sMiniTreeColourIndiBackground = (string)formatter.Deserialize(stream);
                m_sMiniTreeColourIndiHighlight = (string)formatter.Deserialize(stream);
                m_sMiniTreeColourIndiShade = (string)formatter.Deserialize(stream);
                m_bFrontPageStats = (bool)formatter.Deserialize(stream);
                m_sCommentaryText = (string)formatter.Deserialize(stream);
                m_sFtpServer = (string)formatter.Deserialize(stream);
                m_sFtpUsername = (string)formatter.Deserialize(stream);
                m_sFtpPassword = (string)formatter.Deserialize(stream);
                m_sFtpUploadFolder = (string)formatter.Deserialize(stream);
                m_sTreeFontName = (string)formatter.Deserialize(stream);
                m_fTreeFontSize = (float)formatter.Deserialize(stream);
                m_nTargetTreeWidth = (int)formatter.Deserialize(stream);
                m_sMiniTreeImageFormat = (string)formatter.Deserialize(stream);
                m_sMiniTreeColourIndiText = (string)formatter.Deserialize(stream);
                m_sMiniTreeColourIndiLink = (string)formatter.Deserialize(stream);
                m_sMiniTreeColourBackground = (string)formatter.Deserialize(stream);
                m_bShowMiniTrees = (bool)formatter.Deserialize(stream);
                m_sUserEmailAddress = (string)formatter.Deserialize(stream);
                m_bFakeMiniTreeTransparency = (bool)formatter.Deserialize(stream);
                int nKeyIndividuals = (int)formatter.Deserialize(stream);
                m_alKeyIndividuals = new ArrayList();
                while( nKeyIndividuals-- > 0 )
                {
                    string keyXref = (string)formatter.Deserialize(stream);
                    m_alKeyIndividuals.Add( keyXref );
                }
                m_bMultiPageIndexes = (bool)formatter.Deserialize(stream);
                m_uIndividualsPerIndexPage = (uint)formatter.Deserialize(stream);
                m_bOpenWebsiteOnExit = (bool)formatter.Deserialize(stream);
                m_sFrontPageFilename = (string)formatter.Deserialize(stream);
                m_ecHtmlCharset = (ECharset)formatter.Deserialize(stream);
                m_bCreateCDROMFiles = (bool)formatter.Deserialize(stream);
                m_nMaxNumberMultimediaFiles = ( int )formatter.Deserialize(stream);
                m_bAllowMultipleImages = (bool)formatter.Deserialize(stream);
                m_bAllowNonPictures = (bool)formatter.Deserialize(stream);
                m_uMaxThumbnailImageWidth = ( uint )formatter.Deserialize(stream);
                m_uMaxThumbnailImageHeight = ( uint )formatter.Deserialize(stream);
                m_sMainWebsiteLink = (string)formatter.Deserialize(stream);
                m_bPreserveFrontPage = (bool)formatter.Deserialize(stream);
                m_bPreserveStylesheet = (bool)formatter.Deserialize(stream);
                m_sStylesheetFilename = (string)formatter.Deserialize(stream);
                m_sMiniTreeColourIndiBgConcealed = (string)formatter.Deserialize(stream);
                m_bOnlyConceal = (bool)formatter.Deserialize(stream);
                m_sConcealedName = (string)formatter.Deserialize(stream);
                m_sMiniTreeColourIndiFgConcealed = (string)formatter.Deserialize(stream);
                m_bLinkOriginalPicture = (bool)formatter.Deserialize(stream);
                m_bRenameOriginalPicture = (bool)formatter.Deserialize(stream);
                m_sExcludeFileDir = (string)formatter.Deserialize(stream);
                m_sExcludeFileName = (string)formatter.Deserialize(stream);
                m_sLastPictureAddedDir = (string)formatter.Deserialize(stream);
                m_bObfuscateEmails = (bool)formatter.Deserialize(stream);
                m_bAddHomePageCreateTime = (bool)formatter.Deserialize(stream);
                m_bIncludeValiditySticker = (bool)formatter.Deserialize(stream);
                m_bIncludeNickNamesInIndex = (bool)formatter.Deserialize(stream);
                m_sCustomFooter = (string)formatter.Deserialize(stream);
                m_bIncludeUserRefInIndex = (bool)formatter.Deserialize(stream);
                m_bOccupationHeadline = (bool)formatter.Deserialize(stream);
                m_bCommentaryIsHtml = (bool)formatter.Deserialize(stream);
                m_bFooterIsHtml = (bool)formatter.Deserialize(stream);
                m_bUserRecFilename = (bool)formatter.Deserialize( stream );
                m_bIncludeNavbar = (bool)formatter.Deserialize( stream );
                m_bUseWithheldNames = (bool)formatter.Deserialize( stream );
                uVersionMajor = (uint)formatter.Deserialize( stream );
                uVersionMinor = (uint)formatter.Deserialize( stream );
                uVersionBuild = (uint)formatter.Deserialize( stream );
                m_bConserveTreeWidth = (bool)formatter.Deserialize( stream );
                m_bAllowMultimedia = (bool)formatter.Deserialize( stream );
                m_bUseBom = (bool)formatter.Deserialize( stream );
                m_bSupressBackreferences = (bool)formatter.Deserialize( stream );
                m_bDataMayEndWithWhitespace = (bool)formatter.Deserialize(stream);
                m_bKeepSiblingOrder = (bool)formatter.Deserialize( stream );
                m_bIncludeHelppage = (bool)formatter.Deserialize( stream );
            }
            catch( Exception e )
            {
                LogFile.TheLogFile.WriteLine( LogFile.DT_CONFIG, LogFile.EDebugLevel.Error, "Exception caught while reading MainForm.s_config : " + e.ToString() );
            }
            finally
            {
                // We are done with it.
                stream.Close();
            }

            if( !(uVersionMajor > 1 || uVersionMinor > 9 || (uVersionMinor == 9 && uVersionBuild > 0) ) )
            {
                // This config came from a version less than 1.9.1
                // Need to mangle m_mainWebsiteLink, because it now must include the http:// prefix.
                if( m_sMainWebsiteLink.Length > 0 )
                {
                    m_sMainWebsiteLink = "http://" + m_sMainWebsiteLink;
                }
            }
        }