internal RequestSettings Serialize()
        {
            if (String.IsNullOrEmpty(SurveyTitle) || String.IsNullOrEmpty(SurveyNickname))
            {
                throw new ArgumentException("SurveyTitle and SurveyNickname must both be populated.");
            }

            if ((TemplateId == 0 && FromSurveyId == 0) || (TemplateId > 0 && FromSurveyId > 0))
            {
                throw new ArgumentException("You must populate either TemplateId or FromSurveyId, and not both.");
            }

            var parameters = new RequestSettings();

            if (TemplateId != 0)
            {
                parameters.Add("template_id", TemplateId.ToString());
            }
            if (FromSurveyId != 0)
            {
                parameters.Add("from_survey_id", FromSurveyId.ToString());
            }

            parameters.Add("survey_title", SurveyTitle);
            parameters.Add("survey_nickname", SurveyNickname);

            if (LanguageId != Language.NotSet)
            {
                parameters.Add("language_id", (int)LanguageId);
            }

            return(parameters);
        }
    public void FromIDataReader(IDataReader pobjIDataReader)
    {
        if (pobjIDataReader == null)
        {
            return;
        }

        if ((!object.ReferenceEquals(pobjIDataReader["templateId"], DBNull.Value)))
        {
            this.TemplateId = Convert.ToInt32(pobjIDataReader["templateId"]);
        }

        if ((!object.ReferenceEquals(pobjIDataReader["Nome"], DBNull.Value)))
        {
            this.Nome = pobjIDataReader["Nome"].ToString();
        }

        if ((!object.ReferenceEquals(pobjIDataReader["Arquivo"], DBNull.Value)))
        {
            this.Arquivo = pobjIDataReader["Arquivo"].ToString();
        }

        if ((!object.ReferenceEquals(pobjIDataReader["QuantidadeAba"], DBNull.Value)))
        {
            this.QuantidadeAba = Convert.ToInt32(pobjIDataReader["QuantidadeAba"]);
        }

        IdArquivo = string.Concat(TemplateId.ToString(), "|", Arquivo);
    }
示例#3
0
        /// <summary>
        /// Replaces previous extracted references to Tridion items in the template.
        /// </summary>
        /// <param name="newReferences"></param>
        public override void PerformSubstituteReferences(string[] newReferences)
        {
            RazorHandler handler = new RazorHandler(TemplateId.ToString(), WebDavUrl, Content);

            handler.Initialize();
            List <string> references = handler.GetImportReferences();

            List <string> dwReferences = new List <string>();
            int           count        = newReferences.Length - references.Count;

            for (int i = 0; i < count; i++)
            {
                dwReferences.Add(newReferences[i]);
            }

            _dwHandler.PerformSubstituteReferences(dwReferences.ToArray());

            if (handler.Config.ImportSettings.ReplaceRelativePaths)
            {
                foreach (string path in references)
                {
                    if (!path.StartsWith("tcm:") && !path.StartsWith("/webdav/"))
                    {
                        Content = Content.Replace(path, GetRelativeImportPath(path));
                    }
                }
            }
        }
示例#4
0
        /// <summary>
        /// Compiles the template. If there are any compilation errors, an error will be thrown at save time.
        /// </summary>
        private void ValidateCompilation()
        {
            RazorHandler handler = new RazorHandler(TemplateId.ToString(), WebDavUrl, Content);

            handler.Initialize();
            handler.CompileOnly(DateTime.Now);
        }
示例#5
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return((Id.ToString("x")) + ('~') +
            (TemplateId.ToString("x")) + ('~') +
            (Quantity.ToString("x")) + ('~') +
            ((SlotId != (int)ItemSlotEnum.SLOT_INVENTORY ? SlotId.ToString("x") : "")) + ('~') +
            (StringEffects) + (';'));
 }
示例#6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="message"></param>
 public void SerializeAs_BagContent(StringBuilder message)
 {
     message
     .Append(Id.ToString("x")).Append('~')
     .Append(TemplateId.ToString("x")).Append('~')
     .Append(Quantity.ToString("x")).Append('~')
     .Append((SlotId != (int)ItemSlotEnum.SLOT_INVENTORY ? SlotId.ToString("x") : "")).Append('~')
     .Append(StringEffects).Append(';');
 }
示例#7
0
        public override IDictionary <string, object> GetSerializedValue()
        {
            var val = new Dictionary <string, object>();

            // (APN) Note that the model's TemplateId property has been changed to HiveId? because currently the modelmetadata
            // is considering a non-nullable value type to be implicitly required, making it impossible to save content without a template assigned (Sep 11)
            // (MB) Removed the HiveId.Empty check to allow for "No Template" selections. Please note that there is now a difference between null (no value selected)
            // and HiveId.Empty ("No Template" value selected) (2012/01/18)
            if (TemplateId != null)
            {
                val.Add("TemplateId", TemplateId.ToString());
            }
            return(val);
        }
示例#8
0
        /// <summary>
        /// Extarcts the references to Tridion items from the template content. It is allowed to have values in the result that are not valid Tridion references.
        /// </summary>
        /// <returns></returns>
        public override string[] PerformExtractReferences()
        {
            TemplatingLogger log = TemplatingLogger.GetLogger(this.GetType());

            string[] dwReferences = _dwHandler.PerformExtractReferences();

            RazorHandler handler = new RazorHandler(TemplateId.ToString(), WebDavUrl, Content);

            handler.Initialize();

            List <string> imports    = handler.GetImportReferences();
            List <string> references = dwReferences.ToList();

            foreach (string path in imports)
            {
                if (!path.ToLower().StartsWith("tcm:") && !path.ToLower().StartsWith("/webdav/"))
                {
                    references.Add(GetRelativeImportPath(path));
                }
                else
                {
                    if (path.StartsWith("/webdav/"))
                    {
                        string[] pathParts   = path.Split('/');
                        string[] webDavParts = WebDavUrl.Split('/');

                        if (pathParts[2] != webDavParts[2])
                        {
                            pathParts[2] = webDavParts[2];
                        }

                        references.Add(String.Join("/", pathParts));
                    }
                    else if (TcmUri.IsValid(path))
                    {
                        TcmUri uri = new TcmUri(path);
                        if (uri.PublicationId != TemplateId.PublicationId)
                        {
                            uri = new TcmUri(uri.ItemId, uri.ItemType, TemplateId.PublicationId);
                        }
                        references.Add(uri.ToString());
                    }
                }
            }

            return(references.ToArray());
        }
示例#9
0
        public virtual void WriteYaml(YamlWriter writer)
        {
            writer.WriteMap("ID", Id.ToString("D"));
            writer.WriteMap("Parent", ParentId.ToString("D"));
            writer.WriteMap("Template", TemplateId.ToString("D"));
            writer.WriteMap("Path", Path);
            writer.WriteMap("DB", DatabaseName);

            if (BranchId != default(Guid))
            {
                writer.WriteMap("BranchID", BranchId.ToString());
            }

            if (SharedFields.Any())
            {
                writer.WriteMap("SharedFields");
                writer.IncreaseIndent();

                foreach (var field in SharedFields)
                {
                    field.WriteYaml(writer);
                }

                writer.DecreaseIndent();
            }

            if (Languages.Any())
            {
                writer.WriteMap("Languages");
                writer.IncreaseIndent();

                foreach (var language in Languages)
                {
                    language.WriteYaml(writer);
                }

                writer.DecreaseIndent();
            }
        }
 public override void GetObjectData(SerializationInfo info, StreamingContext context)
 {
     base.GetObjectData(info, context);
     info.AddValue($"{nameof(TemplateNotFoundException)}.{nameof(TemplateId)}", TemplateId.ToString());
     info.AddValue($"{nameof(TemplateNotFoundException)}.{nameof(TemplateKindKey)}", TemplateKindKey);
 }
 public override void GetObjectData(SerializationInfo info, StreamingContext context)
 {
     base.GetObjectData(info, context);
     info.AddValue($"{nameof(TemplateVersionUpdateFailedException)}.{nameof(TemplateId)}", TemplateId.ToString());
     info.AddValue($"{nameof(TemplateVersionUpdateFailedException)}.{nameof(TemplateVersionId)}", TemplateVersionId.ToString());
 }
示例#12
0
        private XElement FindNameElement(XDocument d)
        {
            XElement xe = d.Descendants().Where(x => x.Name == "String").Where(x => x.Attribute("id").Value == TemplateId.ToString()).FirstOrDefault();

            return(xe);
        }
示例#13
0
    public void FromIDataReader(IDataReader pobjIDataReader)
    {
        if (pobjIDataReader == null)
        {
            return;
        }

        if ((!object.ReferenceEquals(pobjIDataReader["paginaId"], DBNull.Value)))
        {
            this.PaginaId = Convert.ToInt32(pobjIDataReader["paginaId"]);
        }

        if ((!object.ReferenceEquals(pobjIDataReader["categoriaId"], DBNull.Value)))
        {
            this.CategoriaId = Convert.ToInt32(pobjIDataReader["categoriaId"]);
        }

        if ((!object.ReferenceEquals(pobjIDataReader["templateId"], DBNull.Value)))
        {
            this.TemplateId = Convert.ToInt32(pobjIDataReader["templateId"]);
        }

        if ((!object.ReferenceEquals(pobjIDataReader["alias"], DBNull.Value)))
        {
            this.Alias = pobjIDataReader["alias"].ToString();
        }

        if ((!object.ReferenceEquals(pobjIDataReader["titulo"], DBNull.Value)))
        {
            this.Titulo = pobjIDataReader["titulo"].ToString();
        }

        if ((!object.ReferenceEquals(pobjIDataReader["descricao"], DBNull.Value)))
        {
            this.Descricao = pobjIDataReader["descricao"].ToString();
        }

        if ((!object.ReferenceEquals(pobjIDataReader["status"], DBNull.Value)))
        {
            this.Status = Convert.ToInt32(pobjIDataReader["status"]);
        }

        if ((!object.ReferenceEquals(pobjIDataReader["MetatagsKeywords"], DBNull.Value)))
        {
            this.MetatagsKeywords = pobjIDataReader["MetatagsKeywords"].ToString();
        }

        if ((!object.ReferenceEquals(pobjIDataReader["MetatagsDescription"], DBNull.Value)))
        {
            this.MetatagsDescription = pobjIDataReader["MetatagsDescription"].ToString();
        }

        if ((!object.ReferenceEquals(pobjIDataReader["corMenu"], DBNull.Value)))
        {
            this.CorMenu = pobjIDataReader["corMenu"].ToString();
        }

        if ((!object.ReferenceEquals(pobjIDataReader["dataCriacao"], DBNull.Value)))
        {
            this.DataCriacao = Convert.ToDateTime(pobjIDataReader["dataCriacao"]);
        }

        if ((!object.ReferenceEquals(pobjIDataReader["dataPublicacao"], DBNull.Value)))
        {
            this.DataPublicacao = Convert.ToDateTime(pobjIDataReader["dataPublicacao"]);
        }

        if ((!object.ReferenceEquals(pobjIDataReader["usuarioId"], DBNull.Value)))
        {
            this.Usuario = new Usuario()
            {
                Id = Convert.ToInt32(pobjIDataReader["usuarioId"])
            };
        }

        if ((!object.ReferenceEquals(pobjIDataReader["Categoria"], DBNull.Value)))
        {
            this.Categoria = pobjIDataReader["Categoria"].ToString();
        }

        if ((!object.ReferenceEquals(pobjIDataReader["CriadoPor"], DBNull.Value)))
        {
            this.CriadoPor = pobjIDataReader["CriadoPor"].ToString();
        }

        if ((!object.ReferenceEquals(pobjIDataReader["StatusDescricao"], DBNull.Value)))
        {
            this.StatusDescricao = pobjIDataReader["StatusDescricao"].ToString();
        }

        if ((!object.ReferenceEquals(pobjIDataReader["PublicadoPor"], DBNull.Value)))
        {
            this.PublicadoPor = pobjIDataReader["PublicadoPor"].ToString();
        }

        if (DataPublicacao > DateTime.MinValue)
        {
            DataPublicacaoString = DataPublicacao.ToString();
        }

        if ((!object.ReferenceEquals(pobjIDataReader["ArquivoTemplate"], DBNull.Value)))
        {
            this.ArquivoTemplate = pobjIDataReader["ArquivoTemplate"].ToString();
        }

        IdTemplateArquivo = string.Concat(TemplateId.ToString(), "|", ArquivoTemplate);

        if ((!object.ReferenceEquals(pobjIDataReader["ConfiguracaoAbas"], DBNull.Value)))
        {
            this.ConfiguracaoAbas = pobjIDataReader["ConfiguracaoAbas"].ToString();
        }

        if ((!object.ReferenceEquals(pobjIDataReader["QuantidadeAba"], DBNull.Value)))
        {
            this.QuantidadeAbas = Convert.ToInt32(pobjIDataReader["QuantidadeAba"]);
        }
    }