public bool DoesWebPanelExist(string name, string windowName, out WebPanelEntity webPanel) { using (var listAgent = new SuperOffice.CRM.Services.ListAgent()) { // gets both your webpanels and those created by others. var webPanels = listAgent.GetWebPanelList(); //var englName = SuperOffice.CRM.Globalization.CultureDataFormatter.ParseMultiLanguageString(name, "EN"); webPanel = webPanels.FirstOrDefault(wp => wp.Name.StartsWith(name, StringComparison.InvariantCultureIgnoreCase) || wp.WindowName.StartsWith(windowName, StringComparison.InvariantCultureIgnoreCase)); return(webPanel != null); } }
/// <summary> /// Create a web panel in the logged in users' installation of SuperOffice. /// </summary> /// <param name="name">The string that uniquely identifies the web panel. This name will be stripped of spacing and special characters, and appended with "Panel", so it becomes namePanel.</param> /// <param name="appearLocation">Where in SuperOffice the panel will be shown</param> /// <param name="url">The url to show in the web panel</param> /// <param name="windowName">Window Name </param> /// <param name="urlEncoding"></param> public WebPanelEntity CreateWebPanel( string name, string url, Navigation appearLocation, string windowName = null, UrlEncoding urlEncoding = UrlEncoding.None, bool showInAddressBar = false, bool showInMenuBar = false, bool showInStatusBar = false, bool showInToolBar = false) { WebPanelEntity webPanel; string locWindowName = ParseSafeName(windowName ?? name, _windowPrefixFormat); if (DoesWebPanelExist(name, locWindowName, out webPanel)) { if (webPanel.Deleted) { // this will happen when the user reinstalls a webpanel WebPanelEntity webPanelEntity = UpdateWebPanel(webPanel.WebPanelId, name, locWindowName, url, _webPanelDescription, appearLocation , urlEncoding , showInAddressBar, showInMenuBar, showInStatusBar, showInToolBar , false); // NB! return(webPanelEntity); } else { throw new WebPanelNameNotUniqueException( "WebPanelHelper: The name isn't unique, and it isn't marked as deleted. Did you already install this? You could try again with a different name..."); } } else { WebPanelEntity webPanelEntity = CreateBasicWebPanel(name, locWindowName, url, appearLocation, urlEncoding, showInAddressBar, showInMenuBar, showInStatusBar, showInToolBar); return(webPanelEntity); } }