示例#1
0
 public HttpResponseMessage NewStory(StoryInfo story)
 {
     try
     {
         int storyId = DbController.Instance.InsertStory(story, System.Threading.Thread.CurrentThread.CurrentCulture.Name, ActiveModule.ModuleID, ActiveModule.TabID);
         return Request.CreateResponse(HttpStatusCode.OK, storyId);
     }
     catch (Exception ex)
     {
         return Request.CreateResponse(HttpStatusCode.InternalServerError, ex);
     }
 }
示例#2
0
 public HttpResponseMessage DeleteStory(StoryInfo delItem)
 {
     try
     {
         string imgType = "STORY";
         string imageDir = "Images/BBImageStory/" + delItem.StoryId.ToString();
         IFolderInfo folder = FolderManager.Instance.GetFolder(ActiveModule.PortalID, imageDir);
         if (folder != null)
         {
             IEnumerable<IFileInfo> files = FolderManager.Instance.GetFiles(folder);
             FileManager.Instance.DeleteFiles(files);
             FolderManager.Instance.DeleteFolder(folder);
         }
         DbController.Instance.DeleteStory(delItem.StoryId);
         DbController.Instance.DeleteForeignImages(delItem.StoryId,imgType);
         return Request.CreateResponse(HttpStatusCode.OK, true.ToString());
     }
     catch (Exception ex)
     {
         return Request.CreateResponse(HttpStatusCode.NotFound, ex);
     }
 }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ImportModule implements the IPortable ImportModule Interface
        /// </summary>
        /// <param name="ModuleID">The Id of the module to be imported</param>
        /// <param name="Content">The content to be imported</param>
        /// <param name="Version">The version of the module to be imported</param>
        /// <param name="UserId">The Id of the user performing the import</param>
        /// -----------------------------------------------------------------------------
        public void ImportModule(int ModuleID, string Content, string Version, int UserID)
        {
            int? partModuleId = null, partPortalId = null;
            
            ModuleInfo module = ModuleController.Instance.GetModule(ModuleID, PortalSettings.Current.ActiveTab.TabID, true);
            switch ((string)module.ModuleSettings["Partitioning"])
            {
                case "1":
                    partModuleId = ModuleID;
                    break;
                case "2":
                    partPortalId = PortalSettings.Current.PortalId;
                    break;

            }
            
            XmlNode xmlroot = Globals.GetContent(Content, "BBImageStories");

            // Save Templates
            string templateRoot = PortalSettings.Current.HomeDirectoryMapPath + "..\\..\\DesktopModules\\" + module.DesktopModule.FolderName + "\\";

            XmlNode xmlListTemplate = xmlroot.SelectSingleNode("ListTemplate");
            string contentListTemplate = xmlListTemplate.SelectSingleNode("Content").InnerText;
            string contentListName = xmlListTemplate.SelectSingleNode("Name").InnerText;
            string listTemplateFile = templateRoot + "js\\List\\" + contentListName;
            File.WriteAllText(listTemplateFile, contentListTemplate);
            ModuleController.Instance.UpdateModuleSetting(ModuleID, "List", contentListName.ToLower());

            XmlNode xmlViewTemplate = xmlroot.SelectSingleNode("ViewTemplate");
            string contentViewTemplate = xmlViewTemplate.SelectSingleNode("Content").InnerText;
            string contentViewName = xmlViewTemplate.SelectSingleNode("Name").InnerText;
            string viewTemplateFile = templateRoot + "js\\View\\" + contentViewName;
            File.WriteAllText(viewTemplateFile, contentViewTemplate);
            ModuleController.Instance.UpdateModuleSetting(ModuleID, "View", contentViewName.ToLower());

            XmlNode xmlImageWidth = xmlroot.SelectSingleNode("ImageWidth");
            if (xmlImageWidth != null)
                ModuleController.Instance.UpdateModuleSetting(ModuleID, "Width", xmlImageWidth.InnerText);

            //XmlNode xmlPartitioning = xmlroot.SelectSingleNode("Partitioning");
            //if (xmlPartitioning != null)
            //    ModuleController.Instance.UpdateModuleSetting(ModuleID, "Partitioning", xmlPartitioning.InnerText);

            foreach (XmlNode xmlStory in xmlroot.SelectNodes("Story"))
            {
                // Insert Story
                string strModuleId = xmlStory.SelectSingleNode("ModuleId").InnerText;
                string strPortalId = xmlStory.SelectSingleNode("PortalId").InnerText;
                string strStartDate = xmlStory.SelectSingleNode("StartDate").InnerText;
                string strEndDate = xmlStory.SelectSingleNode("EndDate").InnerText;
                StoryInfo story = new StoryInfo()
                                  {
                                      ModuleId = partModuleId,
                                      PortalId = partPortalId,
                                      StartDate = (strStartDate != "null") ? (DateTime?) Convert.ToDateTime(strStartDate, CultureInfo.InvariantCulture) : null,
                                      EndDate = (strEndDate != "null") ? (DateTime?) Convert.ToDateTime(strEndDate, CultureInfo.InvariantCulture) : null,
                                      LastPublishedDate = null,
                                      CreatedByUserID = UserID,
                                      CreatedOnDate = DateTime.Now,
                                      LastModifiedByUserID = UserID,
                                      LastModifiedOnDate = DateTime.Now
                                  };
                int storyId = DbController.Instance.InsertStory(story, ModuleID, PortalSettings.Current.ActiveTab.TabID);

                // Insert Story Language Info
                XmlNode xmlStoryLangs = xmlStory.SelectSingleNode("StoryLangs");
                foreach (XmlNode xmlStoryLang in xmlStoryLangs.SelectNodes("StoryLang"))
                {
                    string strLanguage = xmlStoryLang.SelectSingleNode("Language").InnerText;
                    string strTitle = xmlStoryLang.SelectSingleNode("Title").InnerText;
                    string strStory = xmlStoryLang.SelectSingleNode("Story").InnerText;
                    StoryLangInfo storyLang = new StoryLangInfo()
                                              {
                                                  StoryId = storyId,
                                                  Language = strLanguage,
                                                  Title = strTitle,
                                                  Story = strStory
                                              };
                    DbController.Instance.InsertStoryLang(storyLang, PortalSettings.Current.ActiveTab.TabID);
                }

                // Insert Images
                string imageDir = "Images/BBImageStory/" + storyId.ToString();

                IFolderInfo folder;
                if (!FolderManager.Instance.FolderExists(PortalSettings.Current.PortalId, imageDir))
                    folder = FolderManager.Instance.AddFolder(PortalSettings.Current.PortalId, imageDir);
                else
                    folder = FolderManager.Instance.GetFolder(PortalSettings.Current.PortalId, imageDir);

                XmlNode xmlImages = xmlStory.SelectSingleNode("Images");
                foreach (XmlNode xmlImage in xmlImages.SelectNodes("Image"))
                {
                    string strViewOrder = xmlImage.SelectSingleNode("ViewOrder").InnerText;
                    string strImageData = xmlImage.SelectSingleNode("ImageData").InnerText;
                    string strFileName = xmlImage.SelectSingleNode("FileName").InnerText;
                    MemoryStream imageStream = HexStringToStream(strImageData);
                    if (!FileManager.Instance.FileExists(folder, strFileName))
                    {
                        // Add File to directory
                        IFileInfo ifile = FileManager.Instance.AddFile(folder, strFileName, imageStream, true);

                        // Insert Image reference into Image Table
                        ImageInfo image = new ImageInfo() {FileId = ifile.FileId};
                        int imageId = DbController.Instance.InsertImage(image);

                        // Combine image and story in crosstable
                        ForeignImageInfo foreignImage = new ForeignImageInfo() {ForeignId = storyId, ForeignToken = "STORY", ImageId = imageId, ViewOrder = Convert.ToInt32(strViewOrder)};
                        DbController.Instance.InsertForeignImage(foreignImage);

                        XmlNode xmlImageLangs = xmlImage.SelectSingleNode("ImageLangs");
                        foreach (XmlNode xmlImageLang in xmlImageLangs.SelectNodes("ImageLang"))
                        {
                            string strLanguage = xmlImageLang.SelectSingleNode("Language").InnerText;
                            string strShortDescription = xmlImageLang.SelectSingleNode("ShortDescription").InnerText;
                            string strLongDescription = xmlImageLang.SelectSingleNode("LongDescription").InnerText;
                            ImageLangInfo imageLang = new ImageLangInfo()
                                                      {
                                                          ImageId = imageId,
                                                          Language = strLanguage,
                                                          ShortDescription = strShortDescription,
                                                          LongDescription = strLongDescription
                                                      };
                            DbController.Instance.InsertImageLang(imageLang);

                        }
                    }
                }
            }
        }
示例#4
0
 public void UpdateStory(StoryInfo story, string language, int tabId)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         
         var rep = ctx.GetRepository<StoryInfo>();
         rep.Update(story);
         DeleteStoryLang(story.StoryId, language);
         StoryLangInfo lang = new StoryLangInfo
         {
             StoryId = story.StoryId,
             Language = language,
             Story = story.Story,
             Title = story.Title
         };
         InsertStoryLang(lang, tabId);
     }
 }
示例#5
0
 public int InsertStory(StoryInfo story, string language, int moduleId, int tabId)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         var rep = ctx.GetRepository<StoryInfo>();
         rep.Insert(story);
         StoryLangInfo lang = new StoryLangInfo
                              {
                                  StoryId = story.StoryId,
                                  Language = language,
                                  Story = story.Story,
                                  Title = story.Title
                              };
         InsertStoryLang(lang, tabId);
         var contentItem = new ContentItem()
         {
             Content = GetStoryContent(story.StoryId),
             ContentTypeId = ContentTypeId,
             Indexed = false,
             ContentKey = "#view/" + story.StoryId.ToString(),
             ModuleID = moduleId,
             TabID = tabId
         };
         story.ContentItemID = Util.GetContentController().AddContentItem(contentItem);
         rep.Update(story);
         return story.StoryId;
     }
 }
示例#6
0
 public HttpResponseMessage UpdateStory(StoryInfo story)
 {
     try
     {
         story.LastModifiedByUserID = UserInfo.UserID;
         story.LastModifiedOnDate = DateTime.Now;
         DbController.Instance.UpdateStory(story, System.Threading.Thread.CurrentThread.CurrentCulture.Name, ActiveModule.TabID);
         return Request.CreateResponse(HttpStatusCode.OK, true.ToString());
     }
     catch (Exception ex)
     {
         return Request.CreateResponse(HttpStatusCode.InternalServerError, ex);
     }
 }