Example #1
0
        public void btnPreviewOsql_Click(Office.IRibbonControl control)
        {
            _isForceDisablePreviewOsql = false;
            Document doc = Wkl.MainCtrl.CommonCtrl.CommonProfile.ActiveDoc;

            try
            {
                //Validate document
                string mgrKey = string.Empty;
                Pdw.WKL.Profiler.Manager.ManagerProfile mgrPro = Wkl.MainCtrl.ManagerCtrl.CreateProfile(out mgrKey);
                mgrPro.WdColorIndex   = DefineColors.GetColor(selectedColor).Color;
                mgrPro.IsSaveDocument = false;

                ContextValidator validator = new ContextValidator(doc);
                validator.ValidateBeforeSave(mgrKey);

                //If document has invalid bookmarks
                if (!mgrPro.IsCorrect)
                {
                    //Ask user to remove invalid bookmarks
                    mgrPro.WDoc = doc;
                    Hcl.SaveMessageDialog saveNotify  = new Hcl.SaveMessageDialog(mgrKey);
                    DialogResult          userConfirm = saveNotify.ShowDialog();

                    if (userConfirm != DialogResult.OK || !HasSelectIBM())
                    {
                        return;
                    }
                }

                //Build and show osql
                PdwInfo pdwInfo = GetPdwInfo(doc);

                ChecksumInfo checkSum = ProntoDoc.Framework.Utils.ObjectSerializeHelper.Deserialize <ChecksumInfo>(pdwInfo.ChecksumString);
                OsqlXml      osqlXml = ProntoDoc.Framework.Utils.ObjectSerializeHelper.Deserialize <OsqlXml>(pdwInfo.OsqlString);
                string       renderArgument, jRenderArgument;
                GetRenderArguments(checkSum, out renderArgument, out jRenderArgument);

                Pdw.PreviewOsql.PreviewOsqlForm previewDialog = new Pdw.PreviewOsql.PreviewOsqlForm();
                previewDialog.Osql            = osqlXml.GetOsql("/*------------------------------------*/");
                previewDialog.JOsql           = osqlXml.GetJsql("/*------------------------------------*/");
                previewDialog.Xsl             = pdwInfo.XsltString;
                previewDialog.RenderArgument  = renderArgument;
                previewDialog.JRenderArgument = jRenderArgument;
                previewDialog.CheckSumInfo    = checkSum;
                previewDialog.OsqlXml         = osqlXml;
                previewDialog.ShowDialog();
            }
            catch { }
        }
Example #2
0
        public ValidationResult ValidateConfiguration(IGeneratorConfiguration configuration)
        {
            var result = new ValidationResult();

            _settings = GetSettings(configuration);
            if (_settings == null)
            {
                _settings = new Settings(configuration, _packageService);
            }
            _generator = GetGenerator(configuration);
            if (!string.IsNullOrEmpty(_settings.SourceModel))
            {
                var items = _moduleLoader.Load(_settings.SourceModel).ToList();
                if (!items.Any())
                {
                    result.Errors.Add(new ValidationFailure("SourceModel", "No module found in the source model."));
                }
                else if (items.Count() == 1)
                {
                    _module = items.First();
                }
                else
                {
                    result.Errors.Add(new ValidationFailure("SourceModel", "More than one module was found."));
                }
            }

            if (_module != null && string.IsNullOrEmpty(_settings.ModelName))
            {
                _model = ((Domain.Module)_module).Models.FirstOrDefault(m => m.Name.Value == configuration.ModelName);
            }

            var configValidator = new ContextValidator();
            var results         = configValidator.Validate(this);

            if (!results.IsValid)
            {
                return(result);
            }
            foreach (var item in results.Errors)
            {
                _logger.LogError("{Error}", item.ErrorMessage);
                result.Errors.Add(item);
            }

            return(result);
        }