示例#1
0
 /// <summary>
 /// Update Elements in Container from Stage
 /// </summary>
 /// <param name="project">proejct</param>
 /// <param name="stage">stage</param>
 /// <param name="trxName">trx</param>
 protected void UpdateTTables(MWebProject project, MCStage stage,
                              Trx trxName)
 {
     int[] tableKeys = X_CM_CStageTTable.GetAllIDs("CM_CStageTTable",
                                                   "CM_CStage_ID=" + stage.Get_ID(), trxName);
     if (tableKeys != null && tableKeys.Length > 0)
     {
         for (int i = 0; i < tableKeys.Length; i++)
         {
             X_CM_CStageTTable thisStageTTable = new X_CM_CStageTTable(
                 project.GetCtx(), tableKeys[i], trxName);
             int[] thisContainerTTableKeys = X_CM_ContainerTTable.GetAllIDs(
                 "CM_ContainerTTable", "CM_Container_ID=" + stage.Get_ID()
                 + " AND CM_TemplateTable_ID="
                 + thisStageTTable.GetCM_TemplateTable_ID(), trxName);
             X_CM_ContainerTTable thisContainerTTable;
             if (thisContainerTTableKeys != null &&
                 thisContainerTTableKeys.Length > 0)
             {
                 thisContainerTTable = new X_CM_ContainerTTable(project
                                                                .GetCtx(), thisContainerTTableKeys[0], trxName);
             }
             else
             {
                 thisContainerTTable = new X_CM_ContainerTTable(project
                                                                .GetCtx(), 0, trxName);
             }
             thisContainerTTable.SetCM_Container_ID(stage.Get_ID());
             PO.CopyValues(new X_CM_CStageTTable(project.GetCtx(),
                                                 tableKeys[i], trxName), thisContainerTTable);
             thisContainerTTable.Save(trxName);
         }
     }
 }
示例#2
0
        /// <summary>
        ///	Get Stages
        /// </summary>
        /// <param name="project">project</param>
        /// <returns>stages</returns>
        public static MCStage[] GetStages(MWebProject project)
        {
            List <MCStage> list = new List <MCStage>();

            SqlParameter[] param = new SqlParameter[1];
            IDataReader    idr   = null;
            String         sql   = "SELECT * FROM CM_CStage WHERE CM_WebProject_ID=@param ORDER BY CM_CStage_ID";

            try
            {
                //pstmt = DataBase.prepareStatement (sql, project.get_TrxName());
                //pstmt.setInt (1, project.getCM_WebProject_ID());
                param[0] = new SqlParameter("@param", project.GetCM_WebProject_ID());
                idr      = DataBase.DB.ExecuteReader(sql, param, project.Get_TrxName());

                while (idr.Read())
                {
                    list.Add(new MCStage(project.GetCtx(), idr, project.Get_TrxName()));
                }
                idr.Close();
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                _log.Log(Level.SEVERE, sql, e);
            }

            MCStage[] retValue = new MCStage[list.Count];
            retValue = list.ToArray();
            return(retValue);
        }       //	getStages
示例#3
0
        } // getAD_Tree_ID;

        /// <summary>
        /// Set/Copy Stage
        /// </summary>
        /// <param name="project">parent</param>
        /// <param name="stage">stage</param>
        /// <param name="path">path</param>
        protected void SetStage(MWebProject project, MCStage stage, String path)
        {
            _stage = stage;
            PO.CopyValues(stage, this);
            SetAD_Client_ID(project.GetAD_Client_ID());
            SetAD_Org_ID(project.GetAD_Org_ID());
            SetIsActive(stage.IsActive());
            SetCM_ContainerLink_ID(stage.GetCM_CStageLink_ID());
            //
            SetRelativeURL(path + stage.GetRelativeURL());
            //
            if (GetMeta_Author() == null || GetMeta_Author().Length == 0)
            {
                SetMeta_Author(project.GetMeta_Author());
            }
            if (GetMeta_Content() == null || GetMeta_Content().Length == 0)
            {
                SetMeta_Content(project.GetMeta_Content());
            }
            if (GetMeta_Copyright() == null || GetMeta_Copyright().Length == 0)
            {
                SetMeta_Copyright(project.GetMeta_Copyright());
            }
            if (GetMeta_Publisher() == null || GetMeta_Publisher().Length == 0)
            {
                SetMeta_Publisher(project.GetMeta_Publisher());
            }
            if (GetMeta_RobotsTag() == null || GetMeta_RobotsTag().Length == 0)
            {
                SetMeta_RobotsTag(project.GetMeta_RobotsTag());
            }
        } // setStage
示例#4
0
        }       //	setRelativeURL

        /// <summary>
        /// Get Web Project
        /// </summary>
        /// <returns>webproject</returns>
        public MWebProject GetWebProject()
        {
            if (_project == null)
            {
                _project = MWebProject.Get(GetCtx(), GetCM_WebProject_ID());
            }
            return(_project);
        }       //	getWebProject
示例#5
0
 /// <summary>
 /// getWebProject
 /// </summary>
 /// <returns>web project</returns>
 public MWebProject GetWebProject()
 {
     if (_project == null)
     {
         _project = new MWebProject(GetCtx(), GetCM_WebProject_ID(), Get_TrxName());
     }
     return(_project);
 }
示例#6
0
        private static VLogger _log = VLogger.GetVLogger(typeof(MMedia).FullName);//.class);

        /// <summary>
        /// getByMediaAndProject Get All deployers by Media ID and WebProject
        /// </summary>
        /// <param name="ctx">Context</param>
        /// <param name="CM_Media_ID">id</param>
        /// <param name="thisProject">web project</param>
        /// <param name="createIfMissing">createIfMissing Whether we create or not</param>
        /// <param name="trxName">trx</param>
        /// <returns> Array of MediaDeploy</returns>
        public static MMediaDeploy[] GetByMediaAndProject(Ctx ctx, int CM_Media_ID, MWebProject thisProject, bool createIfMissing, Trx trxName)
        {
            List <MMediaDeploy> list = new List <MMediaDeploy>();

            MMediaServer[] theseServers = MMediaServer.GetMediaServer(thisProject);
            if (theseServers != null && theseServers.Length > 0)
            {
                for (int i = 0; i < theseServers.Length; i++)
                {
                    list.Add(GetByMedia(ctx, CM_Media_ID, theseServers[i].Get_ID(), createIfMissing, trxName));
                }
            }
            MMediaDeploy[] retValue = new MMediaDeploy[list.Count];// .size ()];
            retValue = list.ToArray();
            return(retValue);
        }
示例#7
0
        /// <summary>
        /// Get MWebProject from Cache
        /// </summary>
        /// <param name="ctx">context</param>
        /// <param name="CM_WebProject_ID">id</param>
        /// <returns>MWebproject</returns>
        public static MWebProject Get(Ctx ctx, int CM_WebProject_ID)
        {
            int         key      = Utility.Util.GetValueOfInt(CM_WebProject_ID);
            MWebProject retValue = (MWebProject)_cache[key];

            if (retValue != null)
            {
                return(retValue);
            }
            retValue = new MWebProject(ctx, CM_WebProject_ID, null);
            if (retValue.Get_ID() == CM_WebProject_ID)
            {
                _cache.Add(key, retValue);
            }
            return(retValue);
        } //	get
示例#8
0
        /// <summary>
        ///Deploy Stage into Container
        /// </summary>
        /// <param name="project">webproject</param>
        /// <param name="stage">Deploy Stage into Container</param>
        /// <param name="path">url to it</param>
        /// <returns>Container</returns>
        public static MContainer Deploy(MWebProject project, MCStage stage,
                                        String path)
        {
            MContainer cc = GetDirect(stage.GetCtx(), stage.GetCM_CStage_ID(),
                                      stage.Get_TrxName());

            if (cc == null)     // new
            {
                cc = new MContainer(stage.GetCtx(), 0, stage.Get_TrxName());
            }
            cc.SetStage(project, stage, path);
            cc.Save();
            if (!stage.IsSummary())
            {
                cc.UpdateElements(project, stage, stage.Get_TrxName());
                cc.UpdateTTables(project, stage, stage.Get_TrxName());
            }
            return(cc);
        }       // copy
示例#9
0
        }       //	getStages

        /// <summary>
        /// Get Stage by Name
        /// </summary>
        /// <param name="project">project</param>
        /// <param name="RelativeURL">relurl</param>
        /// <param name="parent_ID">id</param>
        /// <returns>stages</returns>
        public static MCStage GetByName(MWebProject project, String RelativeURL, int parent_ID)
        {
            MCStage     retValue = null;
            IDataReader idr      = null;

            SqlParameter[] param = new SqlParameter[4];
            String         sql   = "SELECT * FROM CM_CStage WHERE CM_WebProject_ID=@param1 AND RelativeURL LIKE @param2 " + //1,2
                                   "AND CM_CStage_ID IN (SELECT Node_ID FROM AD_TreeNodeCMS WHERE " +
                                   " AD_Tree_ID=@param3 AND Parent_ID=@param4)" +                                           // 3, 4
                                   "ORDER BY CM_CStage_ID";

            try
            {
                //pstmt = DataBase.prepareStatement (sql, project.get_TrxName());
                //pstmt.setInt (1, project.getCM_WebProject_ID());
                param[0] = new SqlParameter("@param1", project.GetCM_WebProject_ID());
                //pstmt.setString (2, RelativeURL);
                param[1] = new SqlParameter("@param2", RelativeURL);
                //pstmt.setInt (3, project.getAD_TreeCMS_ID ());
                param[2] = new SqlParameter("@param3", project.GetAD_TreeCMS_ID());
                //pstmt.setInt (4, parent_ID);
                param[3] = new SqlParameter("@param4", parent_ID);
                idr      = DataBase.DB.ExecuteReader(sql, param, project.Get_TrxName());
                if (idr.Read())
                {
                    retValue = new MCStage(project.GetCtx(), idr, project.Get_TrxName());
                }
                idr.Close();
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }

                _log.Log(Level.SEVERE, sql, e);
            }

            return(retValue);
        }       //	getStages
示例#10
0
        } // setStage

        /// <summary>
        /// Update Elements in Container from Stage
        /// </summary>
        /// <param name="project">project</param>
        /// <param name="stage">stage</param>
        /// <param name="trxName">trx</param>
        protected void UpdateElements(MWebProject project, MCStage stage,
                                      Trx trxName)
        {
            vcon = new VConnection();
            VAdvantage.CM.CacheHandler thisHandler = new VAdvantage.CM.CacheHandler(
                VAdvantage.CM.CacheHandler.ConvertJNPURLToCacheURL(vcon.Apps_host), log, GetCtx(),
                Get_Trx());
            // First update the new ones...
            int[] tableKeys = X_CM_CStage_Element.GetAllIDs("CM_CStage_Element",
                                                            "CM_CStage_ID=" + stage.Get_ID(), trxName);
            if (tableKeys != null && tableKeys.Length > 0)
            {
                for (int i = 0; i < tableKeys.Length; i++)
                {
                    X_CM_CStage_Element thisStageElement = new X_CM_CStage_Element(
                        project.GetCtx(), tableKeys[i], trxName);
                    int[] thisContainerElementKeys = X_CM_Container_Element
                                                     .GetAllIDs("CM_Container_Element", "CM_Container_ID="
                                                                + stage.Get_ID() + " AND Name LIKE '"
                                                                + thisStageElement.GetName() + "'", trxName);
                    X_CM_Container_Element thisContainerElement;
                    if (thisContainerElementKeys != null &&
                        thisContainerElementKeys.Length > 0)
                    {
                        thisContainerElement = new X_CM_Container_Element(project
                                                                          .GetCtx(), thisContainerElementKeys[0], trxName);
                    }
                    else
                    {
                        thisContainerElement = new X_CM_Container_Element(project
                                                                          .GetCtx(), 0, trxName);
                    }
                    thisContainerElement.SetCM_Container_ID(stage.Get_ID());
                    X_CM_CStage_Element stageElement = new X_CM_CStage_Element(
                        project.GetCtx(), tableKeys[i], trxName);
                    thisContainerElement.SetName(stageElement.GetName());
                    thisContainerElement.SetDescription(stageElement.GetDescription());
                    thisContainerElement.SetHelp(stageElement.GetHelp());
                    thisContainerElement.SetIsActive(stageElement.IsActive());
                    thisContainerElement.SetIsValid(stageElement.IsValid());
                    String contentHTML = thisStageElement.GetContentHTML();
                    thisContainerElement.SetContentHTML(contentHTML);
                    // PO.copyValues(new
                    // X_CM_CStage_Element(project.getCtx(),tableKeys[i],trxName),
                    // thisContainerElement);
                    thisContainerElement.Save(trxName);
                    // Remove Container from cache
                    thisHandler.CleanContainerElement(thisContainerElement
                                                      .Get_ID());
                }
            }
            // Now we are checking the existing ones to delete the unneeded ones...
            tableKeys = X_CM_Container_Element.GetAllIDs("CM_Container_Element",
                                                         "CM_Container_ID=" + stage.Get_ID(), trxName);
            if (tableKeys != null && tableKeys.Length > 0)
            {
                for (int i = 0; i < tableKeys.Length; i++)
                {
                    X_CM_Container_Element thisContainerElement = new X_CM_Container_Element(
                        project.GetCtx(), tableKeys[i], trxName);
                    int[] thisCStageElementKeys = X_CM_CStage_Element
                                                  .GetAllIDs("CM_CStage_Element", "CM_CStage_ID="
                                                             + stage.Get_ID() + " AND Name LIKE '"
                                                             + thisContainerElement.GetName() + "'", trxName);
                    // If we cannot find a representative in the Stage we will delete from production
                    if (thisCStageElementKeys == null ||
                        thisCStageElementKeys.Length < 1)
                    {
                        // First delete it from cache, then delete the record itself
                        thisHandler.CleanContainerElement(thisContainerElement
                                                          .Get_ID());
                        thisContainerElement.Delete(true);
                    }
                }
            }
        }