示例#1
0
        /// <summary>
        /// Suck in some more changes from an XmlNode.  Handy for config file parenting.
        /// </summary>
        /// <param name="node">The node to read from</param>
        public void AddSettings(XmlNode node)
        {
            if (node == null)
                return;

            if (node.Attributes != null)
            {
                var preferredAlgorithm = node.Attributes["preferredAlgorithm"];
                if (preferredAlgorithm != null)
                {
                    try
                    {
                        _preferredAlgorithm = (Algorithms)Enum.Parse(typeof(Algorithms), preferredAlgorithm.Value, true);
                    }
                    catch (ArgumentException) { }
                }
            }

            if (node.Attributes != null)
            {
                var compressionLevel = node.Attributes["compressionLevel"];
                if (compressionLevel != null)
                {
                    try
                    {
                        _compressionLevel = (CompressionLevels)Enum.Parse(typeof(CompressionLevels), compressionLevel.Value, true);
                    }
                    catch (ArgumentException) { }
                }
            }

            ParseExcludedTypes(node.SelectSingleNode("excludedMimeTypes"));
            ParseExcludedPaths(node.SelectSingleNode("excludedPaths"));

        }
示例#2
0
 private Settings()
 {
     _preferredAlgorithm = Algorithms.Default;
     _compressionLevel   = CompressionLevels.Default;
     _excludedTypes      = new StringCollection();
     _excludedPaths      = new StringCollection();
 }
示例#3
0
        /// <summary>
        /// Suck in some more changes from an XmlNode.  Handy for config file parenting.
        /// </summary>
        /// <param name="node">The node to read from</param>
        public void AddSettings(XmlNode node)
        {
            if (node == null)
            {
                return;
            }

            var preferredAlgorithm = node.Attributes?["preferredAlgorithm"];

            if (preferredAlgorithm != null)
            {
                try
                {
                    _preferredAlgorithm = (Algorithms)Enum.Parse(typeof(Algorithms), preferredAlgorithm.Value, true);
                }
                catch (ArgumentException) { }
            }

            var compressionLevel = node.Attributes?["compressionLevel"];

            if (compressionLevel != null)
            {
                try
                {
                    _compressionLevel = (CompressionLevels)Enum.Parse(typeof(CompressionLevels), compressionLevel.Value, true);
                }
                catch (ArgumentException) { }
            }

            ParseExcludedTypes(node.SelectSingleNode("excludedMimeTypes"));
            ParseExcludedPaths(node.SelectSingleNode("excludedPaths"));
        }
示例#4
0
 private Settings()
 {
     _preferredAlgorithm = Algorithms.None;
     _compressionLevel = CompressionLevels.None;
     _excludedTypes = new StringCollection();
     _excludedPaths = new StringCollection();
     _whitespace = false;
 }
示例#5
0
 private Settings()
 {
     _preferredAlgorithm = Algorithms.Default;
     _compressionLevel = CompressionLevels.Default;
     _excludedTypes = new StringCollection();
     _excludedPaths = new StringCollection();
     InitTypes();
 }
示例#6
0
 private Settings()
 {
     _preferredAlgorithm = Algorithms.None;
     _compressionLevel   = CompressionLevels.None;
     _excludedTypes      = new StringCollection();
     _excludedPaths      = new StringCollection();
     _whitespace         = false;
 }
        public SyndicationCompressionSettings(XmlNode node) : this()
        {
            if (node == null)
            {
                return;
            }

            _type  = (Algorithms)RetrieveEnumFromAttribute(node.Attributes["type"], typeof(Algorithms));
            _level = (CompressionLevels)RetrieveEnumFromAttribute(node.Attributes["level"], typeof(CompressionLevels));
        }
        public SyndicationCompressionSettings(XmlNode node)
            : this()
        {
            if(node == null)
            {
                return;
            }

            _type = (Algorithms)RetrieveEnumFromAttribute(node.Attributes["type"], typeof(Algorithms));
            _level = (CompressionLevels)RetrieveEnumFromAttribute(node.Attributes["level"], typeof(CompressionLevels));
        }
示例#9
0
        /// <summary>
        /// Returns a decompressed float.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="readIndex"></param>
        /// <returns></returns>
        public static float ReturnDecompressedFloat(byte[] data, ref int readIndex)
        {
            float             result;
            CompressionLevels cl = (CompressionLevels)data[readIndex];

            readIndex += 1;

            //Decompressed from a byte.
            if (cl == CompressionLevels.Level1Positive)
            {
                result     = (float)(data[readIndex] / 100f);
                readIndex += 1;
            }
            else if (cl == CompressionLevels.Level1Negative)
            {
                result     = (float)(data[readIndex] / -100f);
                readIndex += 1;
            }
            //Decompressed from a short.
            else if (cl == CompressionLevels.Level2Positive)
            {
                result     = (float)BitConverter.ToUInt16(data, readIndex) / 100f;
                readIndex += 2;
            }
            //Decompressed from a short.
            else if (cl == CompressionLevels.Level2Positive)
            {
                result     = (float)BitConverter.ToUInt16(data, readIndex) / -100f;
                readIndex += 2;
            }
            //Not compressed.
            else
            {
                result     = BitConverter.ToSingle(data, readIndex);
                readIndex += 4;
            }

            return(result);
        }
示例#10
0
        /// <summary>
        /// Returns a decompressed float.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="readIndex"></param>
        /// <returns></returns>
        public static int ReturnDecompressedInteger(byte[] data, ref int readIndex)
        {
            int result;
            CompressionLevels cl = (CompressionLevels)data[readIndex];

            readIndex += 1;

            //Decompressed from a byte.
            if (cl == CompressionLevels.Level1Positive)
            {
                result     = (int)data[readIndex];
                readIndex += 1;
            }
            else if (cl == CompressionLevels.Level1Negative)
            {
                result     = (int)-data[readIndex];
                readIndex += 1;
            }
            //Decompressed from a short.
            else if (cl == CompressionLevels.Level2Positive)
            {
                result     = (int)BitConverter.ToUInt16(data, readIndex);
                readIndex += 2;
            }
            //Decompressed from a short.
            else if (cl == CompressionLevels.Level2Positive)
            {
                result     = (int)-BitConverter.ToUInt16(data, readIndex);
                readIndex += 2;
            }
            //Not compressed.
            else
            {
                result     = BitConverter.ToInt32(data, readIndex);
                readIndex += 4;
            }

            return(result);
        }
示例#11
0
		/// <summary>
		/// Full constructor that allows you to set the wrapped stream and the level of compression
		/// </summary>
		/// <param name="baseStream">The stream to wrap up with the deflate algorithm</param>
		/// <param name="compressionLevel">The level of compression to use</param>
		public DeflateFilter(Stream baseStream, CompressionLevels compressionLevel) : base(baseStream, compressionLevel) 
		{
			_deflater = GetDeflater();
			m_stream = new DeflaterOutputStream(baseStream, _deflater);
		}
示例#12
0
 /// <summary>
 /// Full constructor that allows you to set the wrapped stream and the level of compression
 /// </summary>
 /// <param name="baseStream">The stream to wrap up with the deflate algorithm</param>
 /// <param name="compressionLevel">The level of compression to use</param>
 public DeflateFilter(Stream baseStream, CompressionLevels compressionLevel) : base(baseStream, compressionLevel) { }
示例#13
0
 /// <summary>
 /// Full constructor that allows you to set the wrapped stream and the level of compression
 /// </summary>
 /// <param name="baseStream">The stream to wrap up with the deflate algorithm</param>
 /// <param name="compressionLevel">The level of compression to use</param>
 public DeflateFilter(Stream baseStream, CompressionLevels compressionLevel) : base(baseStream, compressionLevel)
 {
 }
示例#14
0
 private void setDefaultValues()
 {
     CompressionLevel = CompressionLevels.Recommended;
 }
 private SyndicationCompressionSettings()
 {
     _type  = Algorithms.Deflate;
     _level = CompressionLevels.Normal;
 }
示例#16
0
        internal byte[] WriteSwf(object data, bool debug, CompressionLevels compressionLevel, string url, bool allowDomain)
        {
            // Create the SWF
            byte headerType = compressionLevel != CompressionLevels.None ? SwxAssembler.CompressedSwf : SwxAssembler.UncompressedSwf;
            _swf.Put(headerType);
            _swf.Put(SwxAssembler.SwfHeader);

            //DoAction
            _swf.Put(SwxAssembler.ActionDoAction);
            int doActionBlockSizeIndex = (int)_swf.Position;
            _swf.Skip(4);
            int doActionBlockStartIndex = (int)_swf.Position;

            if (debug)
                _swf.Put(SwxAssembler.DebugStart);

            _swf.Put(SwxAssembler.ActionPushData);
            _swf.Mark();//start marking for length check
            _swf.Skip(2);//Skip ActionRecord length

            // Add the 'result' variable name -- either
            // using the constant table if in debug mode
            // or as a regular string otherwise
            if (debug)
            {
                _swf.Put(SwxAssembler.DataTypeConstantPool1);
                _swf.Put((byte)0);
            }
            else
            {
                PushString("result");
            }
            DataToBytecode(data);
            //Put ActionRecord length
            EndPush();
            
            _swf.Put(SwxAssembler.ActionSetVariable);
            if (allowDomain)
            {
                GenerateAllowDomainBytecode(url);
            }
            if (debug)
                _swf.Put(SwxAssembler.DebugEnd);

            //Fix DoAction size
            long doActionBlockEndIndex = _swf.Position;
            UInt32 doActionBlockSizeInBytes = (UInt32)(doActionBlockEndIndex - doActionBlockStartIndex);
            _swf.Put(doActionBlockSizeIndex, doActionBlockSizeInBytes);
            
            //Swf End
            _swf.Put(SwxAssembler.ActionShowFrame);
            _swf.Put(SwxAssembler.ActionEndSwf);
            
            //Fix Swf size
            UInt32 swfSizeInBytes = (UInt32)_swf.Length;
            _swf.Put(4, swfSizeInBytes);

            _swf.Flip();
            byte[] buffer = _swf.ToArray();

            if (compressionLevel != CompressionLevels.None)
            {
                MemoryStream msCompressed = new MemoryStream();
#if (NET_1_1)
                ICSharpCode.SharpZipLib.Zip.Compression.Streams.DeflaterOutputStream deflaterOutputStream = new ICSharpCode.SharpZipLib.Zip.Compression.Streams.DeflaterOutputStream(msCompressed, new ICSharpCode.SharpZipLib.Zip.Compression.Deflater((int)compressionLevel, false));
                deflaterOutputStream.Write(buffer, 8, buffer.Length - 8);
                deflaterOutputStream.Close();
#else
                DeflateStream deflateStream = new DeflateStream(msCompressed, CompressionMode.Compress, false);
                deflateStream.Write(buffer, 8, buffer.Length - 8);
                deflateStream.Close();
#endif
                byte[] msBuffer = msCompressed.ToArray();
                byte[] compressedBuffer = new byte[msBuffer.Length + 8];
                Buffer.BlockCopy(buffer, 0, compressedBuffer, 0, 8);
                Buffer.BlockCopy(msBuffer, 0, compressedBuffer, 8, msBuffer.Length);
                buffer = compressedBuffer;
            }
            //ByteBuffer dumpBuffer = ByteBuffer.Wrap(buffer);
            //dumpBuffer.Dump("test.swf");
            return buffer;
        }
示例#17
0
文件: Zip.cs 项目: NickHola/Backupper
        /// <param name="oggDaCompr">può essere: string (file o cartella), List(Of String) (file o cartella), oggDaComprimere (file o cartella), List(Of oggDaComprimere) (file o cartella)</param>
        /// <param name="timeOutMs">0  ==  Non attende la compressione ma ritorna subito  |  -1 ==  Attesa infinita  |  XX ==  Attesa massima fino a XX ms</param>
        public static bool Comprimi(object oggDaCompr, string percNomeFileCompr, out Thread thrZip, TipiArchivio formatoArchivio = TipiArchivio.sevenZip, CompressionLevels livelloCompr = CompressionLevels.Ultra,
                                    string password = null, int timeOutMs = -1, Progressione progressione = null, Mess logMess = null)
        {
            thrZip = null;

            try
            {
                if (logMess == null)
                {
                    logMess = new Mess(LogType.Warn, Log.main.warnUserText);
                }

                if ((Zip.inizializzato == false) && inizializza(logMess) == false)
                {
                    return(false);
                }

                Dictionary <string, string> dizionario; bool esito;

                if (FS.ValidaPercorsoFile(percNomeFileCompr, true, percFileFormattato: out percNomeFileCompr, verEsistenza: CheckExistenceOf.PathFolderOnly, logMess: logMess) == false)
                {
                    return(false);
                }

                if (PreparazioneDizionario(oggDaCompr, out dizionario, logMess) == false)
                {
                    return(false);
                }

                if (dizionario.Count == 0)
                {
                    Log.main.Add(new Mess(LogType.info, "Non ci sono file da comprimere"));
                    return(true);
                }

                esito  = false;
                thrZip = Thr.AvviaNuovo(() => esito = ThrComprimi(dizionario, percNomeFileCompr, formatoArchivio, livelloCompr, password, progressione));

                if (timeOutMs != 0)
                { //Non attendo il completamento del thr se = 0
                    if (Thr.AttesaCompletamento(ref thrZip, timeOutMs) == false || esito == false)
                    {
                        return(false);
                    }
                }

                if (thrZip.ThreadState == ThreadState.Aborted)
                {
                    return(false);
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
示例#18
0
 /// <summary>
 /// Full constructor that allows you to set the wrapped stream and the level of compression
 /// </summary>
 /// <param name="baseStream">The stream to wrap up with the deflate algorithm</param>
 /// <param name="compressionLevel">The level of compression to use</param>
 public DeflateFilter(Stream baseStream, CompressionLevels compressionLevel) : base(baseStream, compressionLevel)
 {
     _deflater = GetDeflater();
     m_stream  = new DeflaterOutputStream(baseStream, _deflater);
 }
示例#19
0
 protected CompressingFilter(Stream baseStream, CompressionLevels compressionLevel) : base(baseStream)
 {
     this.hasWrittenHeaders = false;
     this._compressionLevel = compressionLevel;
 }
示例#20
0
 /// <summary>
 /// Protected constructor that sets up the underlying stream we're compressing into
 /// </summary>
 /// <param name="baseStream">The stream we're wrapping up</param>
 /// <param name="compressionLevel">The level of compression to use when compressing the content</param>
 protected CompressingFilter(Stream baseStream, CompressionLevels compressionLevel)
     : base(baseStream)
 {
     _compressionLevel = compressionLevel;
 }
示例#21
0
 /// <summary>
 /// Full constructor that allows you to set the wrapped stream and the level of compression
 /// </summary>
 /// <param name="baseStream">The stream to wrap up with the deflate algorithm</param>
 /// <param name="compressionLevel">The level of compression to use</param>
 public DeflateFilter(Stream baseStream, CompressionLevels compressionLevel)
     : base(baseStream, compressionLevel)
 {
     _mStream = new DeflateStream(baseStream, CompressionMode.Compress);
 }
示例#22
0
        public void Handle(HttpApplication httpApplication)
        {
            object            data = null;
            string            str  = null;
            Hashtable         hashtable;
            bool              debug = false;
            CompressionLevels none  = CompressionLevels.None;

            if ((FluorineConfiguration.Instance.HttpCompressSettings.HandleRequest == HandleRequest.Swx) || (FluorineConfiguration.Instance.HttpCompressSettings.HandleRequest == HandleRequest.All))
            {
                none = FluorineConfiguration.Instance.HttpCompressSettings.CompressionLevel;
            }
            bool allowDomain = FluorineConfiguration.Instance.SwxSettings.AllowDomain;

            try
            {
                NameValueCollection queryString;
                string str5;
                if (httpApplication.Request.RequestType == "GET")
                {
                    queryString = httpApplication.Request.QueryString;
                }
                else
                {
                    queryString = httpApplication.Request.Form;
                }
                string typeName   = queryString["serviceClass"];
                string methodName = queryString["method"];
                string str4       = queryString["args"];
                str   = queryString["url"];
                debug = (queryString["debug"] != null) ? Convert.ToBoolean(queryString["debug"]) : false;
                if (str != null)
                {
                    str = HttpUtility.UrlDecode(str);
                    str = str.Replace("///", "//");
                    try
                    {
                        UriBuilder builder = new UriBuilder(str);
                    }
                    catch (UriFormatException)
                    {
                        if (log.get_IsWarnEnabled())
                        {
                            str5 = __Res.GetString("Swx_InvalidCrossDomainUrl", new object[] { str });
                            log.Warn(str5);
                        }
                        str = null;
                    }
                }
                else if (allowDomain && log.get_IsWarnEnabled())
                {
                    str5 = "No referring URL received from Flash. Cross-domain will not be supported on this call regardless of allowDomain setting";
                    log.Warn(str5);
                }
                switch (str4)
                {
                case "undefined":
                case string.Empty:
                    str4 = "[]";
                    break;
                }
                object[]        arguments  = (JavaScriptConvert.DeserializeObject(str4.Replace(@"\t", "\t").Replace(@"\n", "\n").Replace(@"\'", "'")) as JavaScriptArray).ToArray();
                object          obj3       = ObjectFactory.CreateInstance(typeName);
                MethodInfo      methodInfo = MethodHandler.GetMethod(obj3.GetType(), methodName, arguments);
                ParameterInfo[] parameters = methodInfo.GetParameters();
                TypeHelper.NarrowValues(arguments, parameters);
                data = new InvocationHandler(methodInfo).Invoke(obj3, arguments);
            }
            catch (TargetInvocationException exception)
            {
                hashtable            = new Hashtable();
                hashtable["error"]   = true;
                hashtable["code"]    = "SERVER.PROCESSING";
                hashtable["message"] = exception.InnerException.Message;
                data = hashtable;
            }
            catch (Exception exception2)
            {
                hashtable            = new Hashtable();
                hashtable["error"]   = true;
                hashtable["code"]    = "SERVER.PROCESSING";
                hashtable["message"] = exception2.Message;
                data = hashtable;
            }
            byte[] buffer = new SwxAssembler().WriteSwf(data, debug, none, str, allowDomain);
            httpApplication.Response.Clear();
            httpApplication.Response.ClearHeaders();
            httpApplication.Response.Buffer      = true;
            httpApplication.Response.ContentType = "application/swf";
            int length = buffer.Length;

            httpApplication.Response.AppendHeader("Content-Length", length.ToString());
            httpApplication.Response.AppendHeader("Content-Disposition", "attachment; filename=data.swf");
            if (buffer.Length > 0)
            {
                httpApplication.Response.OutputStream.Write(buffer, 0, buffer.Length);
            }
            try
            {
                httpApplication.Response.Flush();
            }
            catch (SecurityException)
            {
            }
        }
示例#23
0
文件: Zip.cs 项目: NickHola/Backupper
        private static bool ThrComprimi(Dictionary <string, string> dizionarioDaCompr, string percNomeFileCompr, TipiArchivio formatoArchivio, CompressionLevels livelloCompr, string passsword, Progressione Progressione)
        {
            Thr.SbloccaThrPadre();
            SevenZipCompressor zipCompressor;

            try {
                zipCompressor = new SevenZipCompressor();

                if (Progressione != null)
                {
                    progressioniAttuali.Add(zipCompressor.UniqueID, Progressione);
                }

                zipCompressor.CompressionMode   = CompressionMode.Create;
                zipCompressor.TempFolderPath    = Path.GetTempPath();
                zipCompressor.ArchiveFormat     = (OutArchiveFormat)(int)formatoArchivio;
                zipCompressor.CompressionMethod = CompressionMethod.Lzma; //ATTENZIONE: la libreria 16.04 con Lzma2 in alcuni casi va in errore
                if (passsword != null)
                {
                    zipCompressor.EncryptHeaders      = true;
                    zipCompressor.ZipEncryptionMethod = ZipEncryptionMethod.Aes256;
                }

                //il formato 7zip se la dll viene eseguita a 32bit non accetta un livello di compressione superiore a Normal
                if (formatoArchivio == TipiArchivio.sevenZip && livelloCompr > CompressionLevels.Normal && Environment.Is64BitProcess == false)
                {
                    livelloCompr = CompressionLevels.Normal;
                }
                zipCompressor.CompressionLevel = (SevenZip.CompressionLevel)(int) livelloCompr;

                zipCompressor.Compressing         += PercentualeCompressa;
                zipCompressor.CompressionFinished += CompressioneTerminata;

                zipCompressor.CompressFileDictionary(dizionarioDaCompr, percNomeFileCompr, passsword);

                return(true);
            } catch (Exception ex) {
                if (Progressione != null)
                {
                    Progressione.ScatenaEventoTerminataConErrori(ex.Message);
                }
                //If progressioniAttuali.ContainsKey(zipCompressor.UniqueID) Then progressioniAttuali(zipCompressor.UniqueID).ScatenaEventoTerminataConErrori(ex.Message)
                return(false);
            }
        }
示例#24
0
        internal byte[] WriteSwf(object data, bool debug, CompressionLevels compressionLevel, string url, bool allowDomain)
        {
            // Create the SWF
            byte headerType = compressionLevel != CompressionLevels.None ? SwxAssembler.CompressedSwf : SwxAssembler.UncompressedSwf;

            _swf.Put(headerType);
            _swf.Put(SwxAssembler.SwfHeader);

            //DoAction
            _swf.Put(SwxAssembler.ActionDoAction);
            int doActionBlockSizeIndex = (int)_swf.Position;

            _swf.Skip(4);
            int doActionBlockStartIndex = (int)_swf.Position;

            if (debug)
            {
                _swf.Put(SwxAssembler.DebugStart);
            }

            _swf.Put(SwxAssembler.ActionPushData);
            _swf.Mark();  //start marking for length check
            _swf.Skip(2); //Skip ActionRecord length

            // Add the 'result' variable name -- either
            // using the constant table if in debug mode
            // or as a regular string otherwise
            if (debug)
            {
                _swf.Put(SwxAssembler.DataTypeConstantPool1);
                _swf.Put((byte)0);
            }
            else
            {
                PushString("result");
            }
            DataToBytecode(data);
            //Put ActionRecord length
            EndPush();

            _swf.Put(SwxAssembler.ActionSetVariable);
            if (allowDomain)
            {
                GenerateAllowDomainBytecode(url);
            }
            if (debug)
            {
                _swf.Put(SwxAssembler.DebugEnd);
            }

            //Fix DoAction size
            long   doActionBlockEndIndex    = _swf.Position;
            UInt32 doActionBlockSizeInBytes = (UInt32)(doActionBlockEndIndex - doActionBlockStartIndex);

            _swf.Put(doActionBlockSizeIndex, doActionBlockSizeInBytes);

            //Swf End
            _swf.Put(SwxAssembler.ActionShowFrame);
            _swf.Put(SwxAssembler.ActionEndSwf);

            //Fix Swf size
            UInt32 swfSizeInBytes = (UInt32)_swf.Length;

            _swf.Put(4, swfSizeInBytes);

            _swf.Flip();
            byte[] buffer = _swf.ToArray();

            if (compressionLevel != CompressionLevels.None)
            {
                MemoryStream msCompressed = new MemoryStream();
#if (NET_1_1)
                ICSharpCode.SharpZipLib.Zip.Compression.Streams.DeflaterOutputStream deflaterOutputStream = new ICSharpCode.SharpZipLib.Zip.Compression.Streams.DeflaterOutputStream(msCompressed, new ICSharpCode.SharpZipLib.Zip.Compression.Deflater((int)compressionLevel, false));
                deflaterOutputStream.Write(buffer, 8, buffer.Length - 8);
                deflaterOutputStream.Close();
#else
                DeflateStream deflateStream = new DeflateStream(msCompressed, CompressionMode.Compress, false);
                deflateStream.Write(buffer, 8, buffer.Length - 8);
                deflateStream.Close();
#endif
                byte[] msBuffer         = msCompressed.ToArray();
                byte[] compressedBuffer = new byte[msBuffer.Length + 8];
                Buffer.BlockCopy(buffer, 0, compressedBuffer, 0, 8);
                Buffer.BlockCopy(msBuffer, 0, compressedBuffer, 8, msBuffer.Length);
                buffer = compressedBuffer;
            }
            //ByteBuffer dumpBuffer = ByteBuffer.Wrap(buffer);
            //dumpBuffer.Dump("test.swf");
            return(buffer);
        }
示例#25
0
        public void Handle(HttpApplication httpApplication)
        {
            object            result           = null;
            string            url              = null;
            bool              debug            = false;
            CompressionLevels compressionLevel = CompressionLevels.None;

            if (FluorineConfiguration.Instance.HttpCompressSettings.HandleRequest == HandleRequest.Swx ||
                FluorineConfiguration.Instance.HttpCompressSettings.HandleRequest == HandleRequest.All)
            {
                compressionLevel = FluorineConfiguration.Instance.HttpCompressSettings.CompressionLevel;
            }
            bool allowDomain = FluorineConfiguration.Instance.SwxSettings.AllowDomain;

            try
            {
                NameValueCollection parameters;
                if (httpApplication.Request.RequestType == "GET")
                {
                    parameters = httpApplication.Request.QueryString;
                }
                else
                {
                    parameters = httpApplication.Request.Form;
                }

                string serviceClass = parameters["serviceClass"];
                string operation    = parameters["method"];
                string args         = parameters["args"];
                url   = parameters["url"];
                debug = parameters["debug"] != null?FluorineFx.Util.Convert.ToBoolean(parameters["debug"]) : false;

                if (url != null)
                {
                    url = HttpUtility.UrlDecode(url);
                    // Firefox/Flash (at least, and tested only on a Mac), sends
                    // file:/// (three slashses) in the URI and that fails the validation
                    // so replacing that with two slashes instead.
                    url = url.Replace("///", "//");

                    try
                    {
                        UriBuilder uriBuilder = new UriBuilder(url);
                    }
                    catch (UriFormatException)
                    {
                        if (log.IsWarnEnabled)
                        {
                            string msg = __Res.GetString(__Res.Swx_InvalidCrossDomainUrl, url);
                            log.Warn(msg);
                        }
                        url = null;
                    }
                }
                else
                {
                    if (allowDomain && log.IsWarnEnabled)
                    {
                        string msg = "No referring URL received from Flash. Cross-domain will not be supported on this call regardless of allowDomain setting";
                        log.Warn(msg);
                    }
                }
                // If the user did not pass an args array, treat it as
                // an empty args array. (Although this may be an error
                // on the client side, it may also be the user calling
                // a method that doesn't take arguments and we shouldn't
                // force the user to create an args parameter with an empty
                // array.)
                if (args == "undefined" || args == string.Empty)
                {
                    args = "[]";
                }
                // Massage special characters back
                args = args.Replace("\\t", "\t");
                args = args.Replace("\\n", "\n");
                args = args.Replace("\\'", "'");

                FluorineFx.Json.JavaScriptArray argsArray = FluorineFx.Json.JavaScriptConvert.DeserializeObject(args) as FluorineFx.Json.JavaScriptArray;
                object[] arguments = argsArray.ToArray();

                object          instance       = ObjectFactory.CreateInstance(serviceClass);
                MethodInfo      mi             = MethodHandler.GetMethod(instance.GetType(), operation, arguments);
                ParameterInfo[] parameterInfos = mi.GetParameters();
                TypeHelper.NarrowValues(arguments, parameterInfos);
                InvocationHandler invocationHandler = new InvocationHandler(mi);
                result = invocationHandler.Invoke(instance, arguments);
            }
            catch (TargetInvocationException exception)
            {
                Hashtable resultObj = new Hashtable();
                resultObj["error"]   = true;
                resultObj["code"]    = "SERVER.PROCESSING";
                resultObj["message"] = exception.InnerException.Message;
                result = resultObj;
            }
            catch (Exception exception)
            {
                Hashtable resultObj = new Hashtable();
                resultObj["error"]   = true;
                resultObj["code"]    = "SERVER.PROCESSING";
                resultObj["message"] = exception.Message;
                result = resultObj;
            }

            SwxAssembler assembler = new SwxAssembler();

            byte[] buffer = assembler.WriteSwf(result, debug, compressionLevel, url, allowDomain);
            httpApplication.Response.Clear();
            httpApplication.Response.ClearHeaders();
            httpApplication.Response.Buffer      = true;
            httpApplication.Response.ContentType = "application/swf";
            httpApplication.Response.AppendHeader("Content-Length", buffer.Length.ToString());
            httpApplication.Response.AppendHeader("Content-Disposition", "attachment; filename=data.swf");
            if (buffer.Length > 0)
            {
                httpApplication.Response.OutputStream.Write(buffer, 0, buffer.Length);
            }
            try
            {
                httpApplication.Response.Flush();
            }
            catch (SecurityException)
            {
            }
        }
示例#26
0
文件: Zip.cs 项目: NickHola/Backupper
        public static bool Comprimi(object oggDaCompr, string percNomeFileCompr, TipiArchivio formatoArchivio = TipiArchivio.sevenZip, CompressionLevels livelloCompr = CompressionLevels.Ultra,
                                    string password = null, int timeOutMs = -1, Progressione progressione = null, Mess logMess = null)
        {
            Thread thrZip = null;

            return(Comprimi(oggDaCompr, percNomeFileCompr, out thrZip, formatoArchivio: formatoArchivio, livelloCompr: livelloCompr, password: password, timeOutMs: timeOutMs, progressione: progressione
                            , logMess: logMess));
        }
示例#27
0
 /// <summary>
 /// Protected constructor that sets up the underlying stream we're compressing into
 /// </summary>
 /// <param name="baseStream">The stream we're wrapping up</param>
 /// <param name="compressionLevel">The level of compression to use when compressing the content</param>
 protected CompressingFilter(Stream baseStream, CompressionLevels compressionLevel) : base(baseStream)
 {
     _compressionLevel = compressionLevel;
 }
 private SyndicationCompressionSettings()
 {
     _type = Algorithms.Deflate;
     _level = CompressionLevels.Normal;
 }
示例#29
0
 /// <summary>
 /// Full constructor that allows you to set the wrapped stream and the level of compression
 /// </summary>
 /// <param name="baseStream">The stream to wrap up with the deflate algorithm</param>
 /// <param name="compressionLevel">The level of compression to use</param>
 public DeflateFilter(Stream baseStream, CompressionLevels compressionLevel) : base(baseStream, compressionLevel)
 {
     m_stream = new DeflateStream(baseStream, CompressionMode.Compress);
 }
示例#30
0
        internal byte[] WriteSwf(object data, bool debug, CompressionLevels compressionLevel, string url, bool allowDomain)
        {
            byte num = (compressionLevel != CompressionLevels.None) ? CompressedSwf : UncompressedSwf;

            this._swf.Put(num);
            this._swf.Put(SwfHeader);
            this._swf.Put(ActionDoAction);
            int position = (int)this._swf.Position;

            this._swf.Skip(4);
            int num3 = (int)this._swf.Position;

            if (debug)
            {
                this._swf.Put(DebugStart);
            }
            this._swf.Put(ActionPushData);
            this._swf.SetBookmark();
            this._swf.Skip(2);
            if (debug)
            {
                this._swf.Put(DataTypeConstantPool1);
                this._swf.Put((byte)0);
            }
            else
            {
                this.PushString("result");
            }
            this.DataToBytecode(data);
            this.EndPush();
            this._swf.Put(ActionSetVariable);
            if (allowDomain)
            {
                this.GenerateAllowDomainBytecode(url);
            }
            if (debug)
            {
                this._swf.Put(DebugEnd);
            }
            uint num5 = (uint)(this._swf.Position - num3);

            this._swf.Put(position, num5);
            this._swf.Put(ActionShowFrame);
            this._swf.Put(ActionEndSwf);
            uint length = (uint)this._swf.Length;

            this._swf.Put(4, length);
            this._swf.Flip();
            byte[] buffer = this._swf.ToArray();
            if (compressionLevel != CompressionLevels.None)
            {
                MemoryStream  stream  = new MemoryStream();
                DeflateStream stream2 = new DeflateStream(stream, CompressionMode.Compress, false);
                stream2.Write(buffer, 8, buffer.Length - 8);
                stream2.Close();
                byte[] src = stream.ToArray();
                byte[] dst = new byte[src.Length + 8];
                Buffer.BlockCopy(buffer, 0, dst, 0, 8);
                Buffer.BlockCopy(src, 0, dst, 8, src.Length);
                buffer = dst;
            }
            return(buffer);
        }