Exemple #1
0
        public MultiplexingConverter()
        {
            lock (_worker)
            {
                // XXX: We need to keep a converter instance alive during the whole application
                //		lifetime due to some underliying's library bug by which re-initializing
                //		the API after having deinitiaized it, causes all newlly rendered pdf
                //		file to be corrupted. So we will keep this convertr alive to avoid
                //		de-initialization until app's shutdown. (pruiz)
                // See: http://code.google.com/p/wkhtmltopdf/issues/detail?id=511
                if (_initiWorkAround == null)
                {
                    _Log.InfoFormat("Initializing converter infraestructure..");
                    _worker.Invoke((Action)(() => _initiWorkAround = new WkHtmlToPdfConverter()));
                    _Log.InfoFormat("Initialized converter infraestructure..");

                    AppDomain.CurrentDomain.ProcessExit += (o, e) =>
                                                           _worker.Invoke((Action)(() => {
                        _Log.InfoFormat("Disposing converter infraestructure..");
                        _initiWorkAround.Dispose();
                        _initiWorkAround = null;
                        _Log.InfoFormat("Disposed converter infraestructure..");
                    }));
                }
            }

            _worker.Invoke((Action)(() => _converter = new WkHtmlToPdfConverter()));
        }
        protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
        {
            _Log.InfoFormat("Resolving controller of type: {0}", controllerType.IfNotNull(x => x.Name));

            if (controllerType == null)
            {
                throw new HttpException(404, string.Format("The controller for path '{0}' could not be found.", requestContext.HttpContext.Request.Path));
            }
            return((IController)_container.Resolve(controllerType));
        }
Exemple #3
0
        private MultiplexingConverter _GetConverter()
        {
            var obj = new MultiplexingConverter();

            obj.Begin           += (s, e) => _Log.DebugFormat("Conversion begin, phase count: {0}", e.Value);
            obj.Error           += (s, e) => _Log.Error(e.Value);
            obj.Warning         += (s, e) => _Log.Warn(e.Value);
            obj.PhaseChanged    += (s, e) => _Log.InfoFormat("PhaseChanged: {0} - {1}", e.Value, e.Value2);
            obj.ProgressChanged += (s, e) => _Log.InfoFormat("ProgressChanged: {0} - {1}", e.Value, e.Value2);
            obj.Finished        += (s, e) => _Log.InfoFormat("Finished: {0}", e.Value ? "success" : "failed!");
            return(obj);
        }
Exemple #4
0
        public void DeployLibrary(Stream stream, string fileName, DateTime timestamp)
        {
            var compressed = fileName.EndsWith(".gz", StringComparison.InvariantCultureIgnoreCase);

            fileName = compressed ? Path.GetFileNameWithoutExtension(fileName) : fileName;
            fileName = Path.Combine(_OutputPath, fileName);

            if (File.Exists(fileName))
            {
                if (File.GetLastWriteTime(fileName) > timestamp)
                {
                    return;
                }

                if (IsFileLocked(fileName))
                {
                    _Log.WarnFormat("Unable to update {0}: file in use!", fileName);
                    return;
                }
            }

            _Log.InfoFormat("Deploying embedded {0} to {1}..", Path.GetFileName(fileName), _OutputPath);

            byte[] hash = null;

            using (var input = compressed ? new GZipStream(stream, CompressionMode.Decompress, false) : stream)
                using (var output = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    hash = CopyStream(input, output);
                }

            _Log.InfoFormat("Deployed {0} with md5sum: {1}.", fileName, string.Concat(hash.Select(b => b.ToString("X2")).ToArray()));

            if (Environment.OSVersion.Platform == PlatformID.Unix)
            {
                // Set as executable (only applies to mono)..
                var attrs = File.GetAttributes(fileName);
                File.SetAttributes(fileName, (FileAttributes)((uint)attrs | 0x80000000));
            }
        }
        private bool ScriptTask1Execute(ProcessExecutingContext context)
        {
            UserConnection userConnection              = Get <UserConnection>("UserConnection");
            string         useOldProcessFeatureCode    = "UseOldOpportunityManagementProcess";
            bool           useOldVersion               = Get <bool>("UseOldOpportunityManagement");
            bool           forceUpdateUsageState       = Get <bool>("ForceUpdateUsageState");
            bool           useOldVersionFeatureEnabled = userConnection.GetIsFeatureEnabled(useOldProcessFeatureCode);

            if (forceUpdateUsageState && useOldVersionFeatureEnabled != useOldVersion)
            {
                var newState = useOldVersion ? FeatureState.Enabled : FeatureState.Disabled;
                userConnection.SetFeatureState(useOldProcessFeatureCode, (int)newState);
            }
            global::Common.Logging.ILog _logger         = global::Common.Logging.LogManager.GetLogger("Process");
            StoredProcedure             storedProcedure = new StoredProcedure(userConnection,
                                                                              "tsp_ActualizeOpportunityManagementProcess");

            storedProcedure.WithParameter("fetchProcessesInfo", true);
            Dictionary <Guid, bool> processSchemasInfos = new Dictionary <Guid, bool>();

            using (var executor = userConnection.EnsureDBConnection()) {
                using (var reader = storedProcedure.ExecuteReader(executor)) {
                    while (reader.Read())
                    {
                        var schemaName  = reader.GetValue <string>("SchemaName");
                        var schemaId    = reader.GetValue <Guid>("SchemaId");
                        var toBeEnabled = reader.GetValue <bool>("ToBeEnabled");
                        _logger.InfoFormat("Process {0}({1}) will be set to enabled state = {2}", schemaName,
                                           schemaId, toBeEnabled);
                        processSchemasInfos[schemaId] = toBeEnabled;
                    }
                }
            }
            var processSchemaManager = userConnection.ProcessSchemaManager;

            foreach (var processSchemaInfo in processSchemasInfos)
            {
                if (processSchemaInfo.Value)
                {
                    processSchemaManager.EnableProcess(userConnection, processSchemaInfo.Key);
                }
                else
                {
                    processSchemaManager.DisableProcess(userConnection, processSchemaInfo.Key);
                }
            }
            return(true);
        }
Exemple #6
0
        private static void DeployLibrary(string resource)
        {
            var resourcePath = GetResourcePath();
            var fileName     = resource.Substring(resourcePath.Length + 1);
            var compressed   = fileName.EndsWith(".gz", StringComparison.InvariantCultureIgnoreCase);

            fileName = compressed ? Path.GetFileNameWithoutExtension(fileName) : fileName;
            fileName = Path.Combine(_OutputPath, fileName);

            if (File.Exists(fileName))
            {
                if (File.GetLastWriteTime(fileName) > File.GetLastWriteTime(Assembly.Location))
                {
                    return;
                }

                if (IsFileLocked(fileName))
                {
                    _Log.WarnFormat("Unable to update {0}: file in use!", fileName);
                    return;
                }
            }

            _Log.InfoFormat("Deploying embedded {0} to {1}..", Path.GetFileName(fileName), _OutputPath);

            var res = Assembly.GetManifestResourceStream(resource);

            using (var input = compressed ? new GZipStream(res, CompressionMode.Decompress, false) : res)
                using (var output = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    CopyStream(input, output);
                }

            if (Environment.OSVersion.Platform == PlatformID.Unix)
            {
                // Set as executable (only applies to mono)..
                var attrs = File.GetAttributes(fileName);
                File.SetAttributes(fileName, (FileAttributes)((uint)attrs | 0x80000000));
            }
        }
        public FileSourceReader(string filePath, Encoding encoding,
                                ulong position = 0, ulong inode    = 0,
                                byte[] head    = null, byte[] tail = null)
        {
            _filePath        = filePath;
            _defaultEncoding = encoding ?? DEFAULT_ENCODING;
            _initialPosition = position;

            if (_initialPosition > 0)
            {
                _fileInode = inode;
                if (head != null)
                {
                    head.ForEach(x => _headBytes.Enqueue(x));
                }
                if (tail != null)
                {
                    tail.ForEach(x => _tailBytes.Enqueue(x));
                }
                _checkFileRotation = true;
            }

            _Log.InfoFormat("New reader for file: {0}. (encoding {1}; offset: {2}; inode: {3})", filePath, encoding.IfNotNull(x => x.EncodingName), position, inode);
        }
Exemple #8
0
 public void InfoFormat(IFormatProvider provider, String format, params Object[] args)
 {
     _log.InfoFormat(provider, format, args);
 }