示例#1
0
        private static VLogger _log = VLogger.GetVLogger(typeof(MTemplate).FullName);          //.class);

        /// <summary>
        ///     get Template by Name
        /// </summary>
        /// <param name="ctx">context</param>
        /// <param name="name">name</param>
        /// <param name="projectID">id</param>
        /// <param name="trxName">trx</param>
        /// <returns>Template</returns>
        public static MTemplate GetByName(Ctx ctx, String name, int projectID, Trx trxName)
        {
            String    sql         = "SELECT * FROM CM_Template WHERE Value LIKE @param1 AND CM_WebProject_ID=@param2";
            MTemplate thisElement = null;

            SqlParameter[] param = new SqlParameter[2];
            IDataReader    idr   = null;

            try
            {
                //pstmt = DataBase.prepareStatement (sql, trxName);

                //pstmt.setString (1, name);
                param[0] = new SqlParameter("@param1", Utility.Util.GetValueOfString(name));
                //pstmt.setInt (2, projectID);
                param[1] = new SqlParameter("@param2", projectID);
                idr      = DataBase.DB.ExecuteReader(sql, param, trxName);
                if (idr.Read())
                {
                    thisElement = new MTemplate(ctx, idr, trxName);
                }
                idr.Close();
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                _log.Log(Level.SEVERE, "getByName", e);
            }
            return(thisElement);
        }       //	getEntries
示例#2
0
 /// <summary>
 /// Get Template from Cache, or load it
 /// </summary>
 /// <returns>template</returns>
 public MTemplate GetTemplate()
 {
     if (GetCM_Template_ID() > 0 && _template == null)
     {
         _template = MTemplate.Get(GetCtx(), GetCM_Template_ID(), null);
     }
     return(_template);
 } // getTemplate
示例#3
0
        /// <summary>
        ///Get MTemplate from Cache
        /// </summary>
        /// <param name="ctx">context</param>
        /// <param name="CM_Template_ID">id</param>
        /// <param name="trxName">trx</param>
        /// <returns>MWEbproject</returns>
        public static MTemplate Get(Ctx ctx, int CM_Template_ID, Trx trxName)
        {
            MTemplate retValue = new MTemplate(ctx, CM_Template_ID, trxName);

            if (retValue != null)
            {
                return(retValue);
            }
            retValue = new MTemplate(ctx, CM_Template_ID, null);
            return(retValue);
        }       // get
示例#4
0
        }       //	validate

        /// <summary>
        /// Check whether all Elements exist
        /// </summary>
        /// <returns>true if updated</returns>
        public bool CheckElements()
        {
            MTemplate     thisTemplate    = new MTemplate(GetCtx(), this.GetCM_Template_ID(), Get_TrxName());
            StringBuilder thisElementList = new StringBuilder(thisTemplate.GetElements());

            while (thisElementList.ToString().IndexOf("\n") >= 0)
            {
                String thisElement = thisElementList.ToString().Substring(0, thisElementList.ToString().IndexOf("\n"));
                //thisElementList.delete(0,thisElementList.indexOf("\n")+1);
                thisElementList.Remove(0, thisElementList.ToString().IndexOf("\n") + 1);
                if (thisElement != null && !thisElement.Equals(""))
                {
                    CheckElement(thisElement);
                }
            }
            String thisElement1 = thisElementList.ToString();

            if (thisElement1 != null && !thisElement1.Equals(""))
            {
                CheckElement(thisElement1);
            }
            return(true);
        }
示例#5
0
 /// <summary>
 ///   * Prebuild Template, this also set's parameters of subtemplates
 // on the main template
 /// </summary>
 public void RebuildTemplate()
 {
     // We will build the prebuild code, so we check which subs are
     // needed and build it depending on them
     _preBuildTemplate = new StringBuilder(GetTemplateXST());
     // Let's see whether the template calls Subtemplates...
     if (_preBuildTemplate.ToString().IndexOf("<xsl:call-template") >= 0)
     {
         StringBuilder subTemplates     = new StringBuilder();
         int           pos              = 0;
         List <String> subTemplateNames = new List <String> ();
         while (_preBuildTemplate.ToString().IndexOf("<xsl:call-template", pos) >= 0)
         {
             String thisName = null;
             int    beginPos = _preBuildTemplate.ToString().IndexOf(
                 "<xsl:call-template", pos);
             int endPos = _preBuildTemplate.ToString().IndexOf("/>", beginPos);
             if (_preBuildTemplate.ToString().IndexOf(">", beginPos) < endPos)
             {
                 endPos = _preBuildTemplate.ToString().IndexOf(">", beginPos) + 1;
             }
             String tempTemplate = _preBuildTemplate.ToString().Substring(beginPos,
                                                                          endPos);
             pos = _preBuildTemplate.ToString().IndexOf("<xsl:call-template", pos)
                   + tempTemplate.Length;
             if (tempTemplate.ToString().IndexOf("name=") >= 0)
             {
                 thisName = tempTemplate.ToString().Substring(tempTemplate.ToString()
                                                              .IndexOf("name=\"") + 6, tempTemplate.ToString().IndexOf(
                                                                  "\"", tempTemplate.ToString().IndexOf("name=\"") + 7));
                 if (!subTemplateNames.Contains(thisName))
                 {
                     subTemplateNames.Add(thisName);
                 }
             }
         }
         // Build all the subtemplates and add them to the main template
         for (int i = 0; i < subTemplateNames.Count; i++)
         {
             MTemplate subTemplate = GetByName(GetCtx(), subTemplateNames[i], GetCM_WebProject_ID(), Get_TrxName());
             if (subTemplate != null)
             {
                 if (subTemplate.ContainsSubtemplates(true, subTemplateNames))
                 {
                     subTemplateNames = subTemplate.getSubTemplateList();
                 }
                 subTemplates.Append(subTemplate.GetTemplateXST());
                 if (subTemplate.IsUseAd())
                 {
                     _isUseAd = true;
                     _adTemplates.Append(subTemplate.Get_ID() + ",");
                 }
                 if (subTemplate.IsNews())
                 {
                     _isNews = true;
                 }
             }
         }
         _preBuildTemplate.Append(subTemplates);
         _preBuildTemplate = new StringBuilder(_preBuildTemplate.ToString()
                                               .Substring(0, _preBuildTemplate.ToString()
                                                          .IndexOf("</xsl:stylesheet>"))
                                               + subTemplates.ToString() + "\n</xsl:stylesheet>");
         // Check whether we need Request functionality for handling
         if (_preBuildTemplate.ToString().IndexOf("/webCM/requestTables/") >= 0)
         {
             _isRequest = true;
         }
     }
 }       //	getPreBuildTemplate