Exemplo n.º 1
0
        void housekeep()
        {
            DateTime lastRun           = DateTime.UtcNow;
            DateTime lastExportCleanup = DateTime.UtcNow;

            while (!shuttingDown)
            {
                Thread.Sleep(saveFunCycleMsec);
                var sinceLast = DateTime.UtcNow.Subtract(lastRun);
                if (sinceLast.TotalSeconds < saveFunLoopSec)
                {
                    continue;
                }
                lastRun = DateTime.UtcNow;
                try
                {
                    housekeepDocuments();
                    housekeepSessions();
                    var sinceLastExportCleanup = DateTime.UtcNow.Subtract(lastExportCleanup);
                    if (sinceLastExportCleanup.TotalSeconds > exportCleanupLoopSec)
                    {
                        lastExportCleanup = DateTime.UtcNow;
                        DocxExporter.Housekeep(options.ExportsFolder);
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "Error in housekeeping thread");
                }
            }
        }
Exemplo n.º 2
0
        public async Task <string> ExportDocx(string docId)
        {
            XieChar[] text = null;
            lock (lockObject)
            {
                ensureDocLoaded(docId);
                var doc = docs.Find(x => x.DocId == docId);
                if (doc == null)
                {
                    return(null);
                }
                text = new XieChar[doc.HeadText.Length];
                for (int i = 0; i < text.Length; ++i)
                {
                    text[i] = doc.HeadText[i];
                }
            }
            var exportFileName = docId + "-" + ShortIdGenerator.Next() + ".docx";
            var exportFilePath = Path.Combine(options.ExportsFolder, exportFileName);
            var exporter       = new DocxExporter(composer, text, exportFilePath);
            await exporter.Export();

            return(exportFileName);
        }