示例#1
0
 // =========================================================================================================
 public psdxTools(ErrHandle objErr, XmlDocument pdxThis)
 {
     this.errHandle = objErr;
       oXmlTools = new xmlTools(objErr);
       oXmlTools.SetXmlDocument(pdxThis);
       pdxCurrentFile = pdxThis;
 }
示例#2
0
        private String sDirOut = ""; // Output base directory

        #endregion Fields

        #region Constructors

        // ================================ CLASS INITIALISATION ======================================
        public cmbConv(ErrHandle oErr)
        {
            this.errHandle = oErr;
              this.oTools = new xmlTools(oErr);
              // Start a new list to contain the harvesting results
              lstHarvest = new List<Harvest>();
              pdxCmdi = new XmlDocument();
              dicCmdi = new Dictionary<string, string>();
        }
示例#3
0
        private XmlWriterSettings setWr = null; // Writer settings

        #endregion Fields

        #region Constructors

        // ==================== CLASS INITIALISATION ==================================================
        public engConv(ErrHandle oErr)
        {
            this.errHandle = oErr;
              this.oTools = new opsub.util.xmlTools(oErr);
              pdxEN = new XmlDocument();
              pdxNL = new XmlDocument();
              lstEn = new List<subTrans>();
              lstNl = new List<subTrans>();
              // Create correct reader settings
              setThis = new XmlReaderSettings();
              setThis.DtdProcessing = DtdProcessing.Ignore;
              setThis.IgnoreComments = true;
              // Create good writer settings
              setWr = new XmlWriterSettings();
              setWr.Indent = true;
              setWr.CloseOutput = true;
              setWr.NamespaceHandling = NamespaceHandling.OmitDuplicates;
        }
示例#4
0
        // ------------------------------------------------------------------------------------
        // Name:   DoLike
        // Goal:   Perform the "Like" function using the pattern (or patterns) stored in [strPattern]
        //         There can be more than 1 pattern in [strPattern], which must be separated
        //         by a vertical bar: |
        // History:
        // 17-06-2010  ERK Created
        // ------------------------------------------------------------------------------------
        public static bool DoLike(string strText, string strPattern)
        {
            string[] arPattern = null;
            // Array of patterns
            int intI = 0;

            // Counter

            try {
                // Validate
                if ((strText == null))
                {
                    return(true);
                }
                // If the text to compare is empty, then we return false
                if ((string.IsNullOrEmpty(strText)))
                {
                    return(false);
                }
                // Reduce the [strPattern]
                strPattern = strPattern.Trim().ToLower();
                // Take lower case of the text
                strText = strText.ToLower();
                // SPlit the [strPattern] into different ones
                arPattern = strPattern.Split(new string[] { "|" }, StringSplitOptions.None);
                // Perform the "Like" operation for all needed patterns
                for (intI = 0; intI < arPattern.Length; intI++)
                {
                    // See if something positive comes out of this comparison
                    if (strText.IsLike(arPattern[intI]))
                    {
                        return(true);
                    }
                }
                // No match has happened, so return false
                return(false);
            } catch (Exception ex) {
                // Show error
                ErrHandle.HandleErr("General/DoLike", ex);
                // Return failure
                return(false);
            }
        }
示例#5
0
        private XmlReaderSettings setThis = null; // Settings to read the document

        #endregion Fields

        #region Constructors

        // ==================================== CLASS INITIALIZER =============================
        public ParReader(String sFileIn, ErrHandle oErr)
        {
            // Set error handler
              this.errHandle = oErr;
              // Set local file name
              this.loc_sFileIn = sFileIn;
              // Create correct reader settings
              setThis = new XmlReaderSettings();
              setThis.DtdProcessing = DtdProcessing.Ignore;
              setThis.IgnoreComments = true;
              // Validate
              if (!File.Exists(sFileIn)) return;
              // Try opening the file
              rdFileIn = new StreamReader(sFileIn);
              rdFileXml = XmlReader.Create(rdFileIn, setThis);
              // Create an xml document
              pdxThis = new XmlDocument();
              // Set init flag
              bInit = true;
        }
示例#6
0
        /// <summary>
        /// File-to-file buffered decompression
        /// </summary>
        /// <param name="sFileIn"></param>
        /// <param name="sFileOut"></param>
        /// <returns></returns>
        public static bool DecompressFile(String sFileIn, String sFileOut, FileMode fmDecomp = FileMode.Create)
        {
            const int size = 8192;

            byte[] buffer = new byte[size];

            try {
                using (FileStream fCompr = new FileStream(sFileIn, FileMode.Open, FileAccess.Read))
                    using (FileStream fDecom = new FileStream(sFileOut, fmDecomp, FileAccess.Write))
                        using (GZipStream alg = new GZipStream(fCompr, CompressionMode.Decompress)) {
                            int bytesRead = 0;
                            do
                            {
                                // Read buffer
                                bytesRead = alg.Read(buffer, 0, buffer.Length);
                                // Write buffer away
                                if (bytesRead > 0)
                                {
                                    fDecom.Write(buffer, 0, bytesRead);
                                }
                            } while (bytesRead > 0);
                            // finish writing
                            fDecom.Flush();
                            fDecom.Close(); fDecom.Dispose();
                            // Finish reading
                            alg.Close();
                            fCompr.Close(); fCompr.Dispose();
                        }
                // Return success
                return(true);
            } catch (Exception ex) {
                ErrHandle.HandleErr("DecompressFile", ex);
                // Return failure
                return(false);
            }
        }
示例#7
0
        /// <summary>
        /// Convert a string consisting of base64 encoded characters to a number
        /// </summary>
        /// <param name="sEncoded"></param>
        /// <returns></returns>
        public static int base64ToInt(String sEncoded)
        {
            int iBack = 0;

            try {
                // COnvert string into byte array
                char[] arEncoded = sEncoded.ToCharArray();
                // Treat the characters one-by-one from right-to-left
                for (int i = 0; i < arEncoded.Length; i++)
                {
                    // Conversion depends on the character values
                    char chThis = arEncoded[i];
                    int  iThis  = 0;
                    switch (chThis)
                    {
                    case 'A': iThis = 0; break;

                    case 'B': iThis = 1; break;

                    case 'C': iThis = 2; break;

                    case 'D': iThis = 3; break;

                    case 'E': iThis = 4; break;

                    case 'F': iThis = 5; break;

                    case 'G': iThis = 6; break;

                    case 'H': iThis = 7; break;

                    case 'I': iThis = 8; break;

                    case 'J': iThis = 9; break;

                    case 'K': iThis = 10; break;

                    case 'L': iThis = 11; break;

                    case 'M': iThis = 12; break;

                    case 'N': iThis = 13; break;

                    case 'O': iThis = 14; break;

                    case 'P': iThis = 15; break;

                    case 'Q': iThis = 16; break;

                    case 'R': iThis = 17; break;

                    case 'S': iThis = 18; break;

                    case 'T': iThis = 19; break;

                    case 'U': iThis = 20; break;

                    case 'V': iThis = 21; break;

                    case 'W': iThis = 22; break;

                    case 'X': iThis = 23; break;

                    case 'Y': iThis = 24; break;

                    case 'Z': iThis = 25; break;

                    case 'a': iThis = 26; break;

                    case 'b': iThis = 27; break;

                    case 'c': iThis = 28; break;

                    case 'd': iThis = 29; break;

                    case 'e': iThis = 30; break;

                    case 'f': iThis = 31; break;

                    case 'g': iThis = 32; break;

                    case 'h': iThis = 33; break;

                    case 'i': iThis = 34; break;

                    case 'j': iThis = 35; break;

                    case 'k': iThis = 36; break;

                    case 'l': iThis = 37; break;

                    case 'm': iThis = 38; break;

                    case 'n': iThis = 39; break;

                    case 'o': iThis = 40; break;

                    case 'p': iThis = 41; break;

                    case 'q': iThis = 42; break;

                    case 'r': iThis = 43; break;

                    case 's': iThis = 44; break;

                    case 't': iThis = 45; break;

                    case 'u': iThis = 46; break;

                    case 'v': iThis = 47; break;

                    case 'w': iThis = 48; break;

                    case 'x': iThis = 49; break;

                    case 'y': iThis = 50; break;

                    case 'z': iThis = 51; break;

                    case '0': iThis = 52; break;

                    case '1': iThis = 53; break;

                    case '2': iThis = 54; break;

                    case '3': iThis = 55; break;

                    case '4': iThis = 56; break;

                    case '5': iThis = 57; break;

                    case '6': iThis = 58; break;

                    case '7': iThis = 59; break;

                    case '8': iThis = 60; break;

                    case '9': iThis = 61; break;

                    case '+': iThis = 62; break;

                    case '/': iThis = 63; break;
                    }
                    // Add the new value to the existing ones
                    iBack = iBack * 64 + iThis;
                }
                return(iBack);
            } catch (Exception ex) {
                ErrHandle.HandleErr("base64ToInt", ex);
                // Return failure
                return(-1);
            }
        }
示例#8
0
 // =========================================================================================================
 public xmlTools(ErrHandle objErr)
 {
     this.errHandle = objErr;
 }
示例#9
0
 // =========================================================================================================
 public xmlTools(ErrHandle objErr)
 {
     this.errHandle = objErr;
 }