/// <summary> /// Gets the signup details for the given community. /// </summary> /// <param name="communityId">Community for which signup xml to be fetched</param> /// <returns>Signup object with details.</returns> public SignUp GetSignUpDetail(string communityId) { SignUp signup = null; try { string communityDirectory = Path.Combine(this.CommunityLocation, communityId); DirectoryInfo communityDirectoryInfo = new DirectoryInfo(communityDirectory); // Get thumbnail relative file path, if any image file with name Thumbnail exists. string thumbnailFile = communityDirectoryInfo.GetThumbnailFilePath(this.CommunityLocation); signup = new SignUp(communityDirectoryInfo.Name, thumbnailFile); } catch (DirectoryNotFoundException ex) { ErrorHandler.LogException(ex); throw new FaultException(ex.Message); } catch (SecurityException ex) { ErrorHandler.LogException(ex); throw new FaultException(ex.Message); } catch (UnauthorizedAccessException ex) { ErrorHandler.LogException(ex); throw new FaultException(ex.Message); } catch (ArgumentException ex) { ErrorHandler.LogException(ex); throw new FaultException(ex.Message); } catch (IOException ex) { ErrorHandler.LogException(ex); throw new FaultException(ex.Message); } return signup; }
public Folder GetPayloadDetails(string communityId) { Folder rootFolder = null; try { string communityFolder = Path.Combine(this.CommunityLocation, communityId); string payloadFilePath = string.Format(CultureInfo.CurrentCulture, "{0}\\{1}_payload.xml", communityFolder, communityId); DirectoryInfo dirInfo = new DirectoryInfo(communityFolder); // Delete if any payload files are pending to be deleted, because cache dependency could not delete last time. for (int i = communityFolderCacheDependency.FilesToBeDeleted.Count - 1; i >= 0; i--) { try { string filePath = communityFolderCacheDependency.FilesToBeDeleted[i]; File.Delete(filePath); communityFolderCacheDependency.FilesToBeDeleted.Remove(filePath); } catch (IOException ex) { ErrorHandler.LogException(ex); } } if (File.Exists(payloadFilePath)) { try { using (Stream stream = File.OpenRead(payloadFilePath)) { // IsLocal property of the Place object needs to be serialized so that while // De-serialized and processed for URL rewriting, IsLocal property can be used. XmlAttributeOverrides overrides = new XmlAttributeOverrides(); XmlAttributes attributes = new XmlAttributes(); attributes.XmlIgnore = false; overrides.Add(typeof(Place), "IsLocal", attributes); XmlSerializer serializer = new XmlSerializer(typeof(Folder), overrides); XmlReader reader = new XmlTextReader(stream); rootFolder = (Folder)serializer.Deserialize(reader); } } catch (IOException ex) { ErrorHandler.LogException(ex); } } else { // Get thumbnail relative file path, if any image file with name Thumbnail exists. string thumbnailFile = dirInfo.GetThumbnailFilePath(this.CommunityLocation); // Creating the root community folder object. rootFolder = new Folder(dirInfo.Name, null); rootFolder.Thumbnail = thumbnailFile; // By default, two folder with name "All Tours" and "Latest" will be added to all communities. // "All Tours" will be having all the tours which are present in the community anywhere in the folder structure. // "Latest" will be having all the tours, WTMLs and Places/Links which are modified in last n days and present // in the community anywhere in the folder structure. Folder allToursFolder = new Folder(Constants.AllToursFolder, rootFolder); Folder latestFolder = new Folder(Constants.LatestFolder, rootFolder); // Loop through all the folder contents recursively. ProcessFolderItems(dirInfo, rootFolder); // This will make sure that there are not events fired while creating/overwriting the payload XML file. communityFolderCacheDependency.CommunityFolderWatcher.EnableRaisingEvents = false; SavePayloadToCache(payloadFilePath, rootFolder); } } catch (DirectoryNotFoundException ex) { ErrorHandler.LogException(ex); throw new FaultException(ex.Message); } catch (SecurityException ex) { ErrorHandler.LogException(ex); throw new FaultException(ex.Message); } catch (UnauthorizedAccessException ex) { ErrorHandler.LogException(ex); throw new FaultException(ex.Message); } catch (ArgumentException ex) { ErrorHandler.LogException(ex); throw new FaultException(ex.Message); } catch (IOException ex) { ErrorHandler.LogException(ex); throw new FaultException(ex.Message); } finally { // If the community folder watcher is not enabled for events, enable them. if (!communityFolderCacheDependency.CommunityFolderWatcher.EnableRaisingEvents) { communityFolderCacheDependency.CommunityFolderWatcher.EnableRaisingEvents = true; } } return rootFolder; }