Example #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);
         }
     }
 }
Example #2
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);
                    }
                }
            }
        }