예제 #1
0
 /// <summary>
 /// deploys style and palette provider
 /// </summary>
 /// <param name="__style">The style.</param>
 /// \ingroup_disabled renderapi_service
 public void setContext(IRenderExecutionContext __context)
 {
     context = __context;
     if (context.theme != null)
     {
         _zone = context.theme.zoneMain;
         _c    = context.theme.cMain;
     }
     else
     {
         context.log(String.Format("- context.style is null - {0} will use its own cursor and zone definitions", this.GetType().Name));
     }
 }
        public virtual void prepareOperation(IRenderExecutionContext context)
        {
            string        src = sourcepath.toPath(includeSourceFolder, context.data);
            DirectoryInfo dir = context.directoryScope;

            if (location == deliveryUnitItemLocationBase.globalDeliveryResource)
            {
                dir = context.directoryRoot;
            }

            if (flags.HasFlag(deliveryUnitItemFlags.useTemplate))
            {
                template = openBase.openFileToString(src, true, false);
            }

            if (flags.HasFlag(deliveryUnitItemFlags.useCopy))
            {
                string trg = outputpath.toPath(context.directoryRoot.FullName, context.data);

                output_fileinfo = trg.getWritableFile(getWritableFileMode.overwrite);
                if (sourceFileInfo == null)
                {
                }
                else
                {
                    if (File.Exists(sourceFileInfo.FullName))
                    {
                        File.Copy(sourceFileInfo.FullName, output_fileinfo.FullName, true);

                        context.regFileOutput(output_fileinfo.FullName, output_fileinfo.Extension, description);
                    }
                    else
                    {
                        context.log("File [" + sourceFileInfo.FullName + "] not found.");
                    }

                    //context.saveFileOutput(output, output_fileinfo.FullName, "css", description);
                }
            }
        }
        /// <summary>
        /// Adds the specified ins.
        /// </summary>
        /// <param name="ins">The ins.</param>
        /// <returns></returns>
        public docScriptInstructionCompiled compile(docScriptInstruction ins, IRenderExecutionContext log, PropertyCollectionDictionary __indata, PropertyCollection __extraData, docScriptFlags flags)
        {
            docScriptInstructionCompiled instructionCompiled = new docScriptInstructionCompiled(ins, flags);

            try
            {
                PropertyCollectionDictionary indata    = __indata;
                PropertyCollection           extraData = __extraData;

                if (ins.type == appendType.x_scopeIn)
                {
                    currentDataPath = ins.getProperString(d.dsa_path);
                }
                else if (ins.type == appendType.x_scopeOut)
                {
                    currentDataPath = currentDataPath.getPathVersion(1, "\\", true);
                }

                PropertyCollection dataItem = null;
                if (indata != null)
                {
                    var tmp = indata[currentDataPath];
#pragma warning disable CS0184 // The given expression is never of the provided ('DictionaryEntry') type
                    if (tmp is DictionaryEntry)
#pragma warning restore CS0184 // The given expression is never of the provided ('DictionaryEntry') type
                    {
                        //DictionaryEntry entry = (DictionaryEntry)tmp;
                        //dataItem = entry.Value as PropertyCollection;
                    }
                    else
                    {
                        dataItem = tmp as PropertyCollection;
                    }
                }

                /// Compiling data into template
                instructionCompiled.compileTemplate(dataItem, extraData);

                if (instructionCompiled.isCompileFailed)
                {
                    string msg = scriptInstructions.Count().ToString("D4") + " " + ins.type.ToString() + " failed on: " + instructionCompiled.missingData.toCsvInLine();
                    if (flags.HasFlag(docScriptFlags.ignoreCompilationFails))
                    {
                        log.log(msg);
                    }
                    else
                    {
                        log.compileError(msg, instructionCompiled);
                    }

                    if (flags.HasFlag(docScriptFlags.allowFailedInstructions))
                    {
                        scriptInstructions.Add(instructionCompiled);
                    }
                    scriptInstructionsFailed.Add(instructionCompiled);
                }
                else
                {
                    scriptInstructions.Add(instructionCompiled);

                    if (instructionCompiled.isCompilable)
                    {
                        // log.log("--- compiled Strings(" + instructionCompiled.keyListForStrings.Count + ") and StringCollections(" + instructionCompiled.keyListForStringCollections.Count + ")");
                    }
                }

                missingData.AddRange(instructionCompiled.missingData);
            }
            catch (Exception ex)
            {
            }
            return(instructionCompiled);
        }
        /// <summary>
        /// Prepares the operation.
        /// </summary>
        /// <param name="context">The context.</param>
        public override void prepareOperation(IRenderExecutionContext context)
        {
            base.prepareOperation(context);

            context.data.add(templateFieldBasic.root_relpath, "");

            if (isDataFieldMode)
            {
                context.data.add(output_datafield, "");
            }

            if (!isDataFieldMode)
            {
                PropertyCollection pc = new PropertyCollection();
                pc.AppendData(context.data, existingDataMode.overwriteExisting);

                //  pc.add(templateFieldBasic.root_relpath,
                //pc.AppendData(dict[composer.path], existingDataMode.overwriteExisting);

                pc.add(templateFieldBasic.page_title, name);
                pc.add(templateFieldBasic.page_desc, description);

                pc.add(reportOutputDomainEnum.includes, "");
                pc.add(reportOutputDomainEnum.localdirectory, "");
                pc.add(reportOutputDomainEnum.logs, "");

                string        filepath = outputpath.toPath(context.directoryRoot.FullName, context.data);
                string        dirpath  = Path.GetDirectoryName(filepath);
                DirectoryInfo dirinfo  = new DirectoryInfo(dirpath);

                string rootrel = dirinfo.getRelativePathToParent(context.directoryRoot).getWebPathBackslashFormat();
                if (rootrel == "/")
                {
                    rootrel = "";
                }

                pc.add(templateFieldBasic.root_relpath, rootrel);

                string output = template.applyToContent(false, pc);

                if (templateOutput == null)
                {
                    context.saveFileOutput(output, filepath, context.scope.path, description, name);
                }
                else
                {
                    pc.add(templateFieldSubcontent.main, output);

                    output = templateOutput.template.applyToContent(false, pc);

                    filepath = outputpath.toPathWithExtension(context.directoryRoot.FullName, templateOutput.format.getDefaultExtension());
                    context.saveFileOutput(output, filepath, context.scope.path, description, name);

                    //FileInfo fi = templateOutput.saveOutput(output, context.data, filepath);
                    //context.regFileOutput(fi.FullName, context.scope.path, description, name);
                }
            }
            else
            {
                context.log(name + " :: data field application the item: " + GetType().Name);
            }
        }