Exemple #1
0
 protected void Delete()
 {
     long folderId = Convert.ToInt64(Request.QueryString["folderId"]);
     try
     {
         //if this is a master layout, check if it's used anywhere. if not then go ahead and delete, but otherwise, don't.
         if (m_EkContent.GetContentSubType(this.ContentId, this.LanguageId) == EkEnumeration.CMSContentSubtype.PageBuilderMasterData)
         {
             TemplateModel tm = new TemplateModel();
             TemplateData template = tm.FindByMasterLayoutID(this.ContentId);
             if(template != null){
                 long[] folders = m_EkContent.GetTemplateDefaultFolderUsage(template.Id);
                 Microsoft.VisualBasic.Collection contentblocks = m_EkContent.GetTemplateContentBlockUsage(template.Id);
                 if (folders.Length == 0 && contentblocks.Count == 0)
                 {
                     m_EkContent.SubmitForDeletev2_0(this.ContentId, folderId);
                 }
                 else
                 {
                     StringBuilder sb = new StringBuilder();
                     sb.Append("Cannot delete this master layout.\r\n");
                     if (folders.Length > 0)
                     {
                         sb.Append("The following folders are associated with it:\r\n");
                         for (int i = 0; i < folders.Length; i++)
                         {
                             sb.Append(m_EkContent.GetFolderPath(folders[i]).Replace('\\', '/') + '/');
                             if (i != folders.Length - 1) sb.Append(",");
                             sb.Append("\r\n");
                         }
                     }
                     if (contentblocks.Count > 0)
                     {
                         sb.Append("The following content is associated with it:\r\n");
                         for (int i = 1; i <= contentblocks.Count; i++)
                         {
                             Microsoft.VisualBasic.Collection inner = (Microsoft.VisualBasic.Collection)contentblocks[i];
                             ContentData cd = m_EkContent.GetContentById((long)inner["content_id"], EkContent.ContentResultType.Published);
                             sb.Append("/" + cd.Path + cd.Title + "   (id: " + cd.Id + ", lang: " + cd.LanguageId + ")");
                             if (i != contentblocks.Count) sb.Append(",\r\n");
                         }
                     }
                     DmsMenuActionsRepsonse.Text = "message:" + sb.ToString();
                 }
             }
         }
         else
         {
             m_EkContent.SubmitForDeletev2_0(this.ContentId, folderId);
         }
     }
     catch (Exception ex)
     {
         if (ex.Message.ToLower().Contains("delete master layout"))
         {
             DmsMenuActionsRepsonse.Text = "message:" + ex.Message;
         }
         else
         {
             throw ex;
         }
     }
 }