/// <summary>
        /// Add a single application node.  If the application is global then will add
        /// for all session, else will add only for the active session passed in.
        /// </summary>
        /// <param name="session">The current active session</param>
        /// <param name="app">The application to add</param>
        public void AddApplicationNode(Session session, IHostedApplication app)
        {
            foreach (TreeNode sessionNode in sessionsTree.Nodes)
            {
                // If app is global then add for all sessions
                if (session.AppHost.IsGlobalApplication(app))
                {
                    // If this node is the current active session
                    if (session.Name.ToString() == sessionNode.Text.ToString())
                    {
                        sessionNode.Nodes.Add(CreateApplicationNode(app, session));
                    }
                    else
                    {
                        sessionNode.Nodes.Add(CreateApplicationNode(app, null));
                    }
                }
                // Not global so only add for correct session
                else if (session.Name.ToString() == sessionNode.Text.ToString())
                {
                    sessionNode.Nodes.Add(CreateApplicationNode(app, session));

                    return;
                }
            }
        }
 protected void CloseAppClickHandler(IHostedApplication app)
 {
     if (this.CloseApplicationClickEvent != null)
     {
         this.CloseApplicationClickEvent(app);
     }
 }
        public void SetActiveApplication(IHostedApplication app)
        {
            IHostedApplication tabApp;

            foreach (C1USDDockTabItem item in Items)
            {
                tabApp = item.Tag as IHostedApplication;
                if ((tabApp != null) && (tabApp.ApplicationID == app.ApplicationID))
                {
                    SelectedItem = item;
                    try
                    {
                        CRMGlobalManager.SetAppWithFocus((this.SelectedItem as C1USDDockTabItem).Tag as IHostedApplication, this, this._panelName);
                    }
                    catch
                    {
                    }
                    WpfDesktopApplicationUI.ActivePanel = this.Parent as WpfPanel;
                    if (this.SelectedAppChangedEvent != null)
                    {
                        this.SelectedAppChangedEvent(null, null);
                    }
                    return;
                }
            }
        }
        /// <summary>
        /// Remove the applications for a session from the SessionExplorerControl
        /// </summary>
        /// <param name="session"></param>
        public void RemoveWorkflowApplicationNodes(Session session)
        {
            IHostedApplication app;

            foreach (TreeNode sessionNode in sessionsTree.Nodes)
            {
                // Remove of workflow application nodes for the correct session
                if (session.Name.ToString() == sessionNode.Text.ToString())
                {       // Collect all workflow tagged applications
                    ArrayList al = new ArrayList();
                    foreach (TreeNode applicationNode in sessionNode.Nodes)
                    {
                        IHostedApplication adapter = applicationNode.Tag as IHostedApplication;
                        app = adapter;

                        // Remove only the tagged globabl and tagged non-global apps
                        if (session.AppHost.IsTaggedApplication(app))
                        {
                            al.Add(applicationNode);
                        }
                    }

                    foreach (object o in al)
                    {
                        TreeNode tn = (TreeNode)o;
                        sessionNode.Nodes.Remove(tn);
                    }
                    sessionsTree.ExpandAll();
                }
            }
        }
        public void SendApplicationsToUnknownPanel()
        {
            try
            {
                List <IHostedApplication> tabApps = new List <IHostedApplication>();

                while (Items.Count > 0)
                {
                    C1USDDockTabItem   item   = (C1USDDockTabItem)Items[0];
                    IHostedApplication tabApp = item.Tag as IHostedApplication;
                    if (tabApp != null)
                    {
                        IDesktopFeatureAccess desktop = AifServiceContainer.Instance.GetService <IDesktopFeatureAccess>();
                        if (desktop != null)
                        {
                            desktop.SendApplicationToUnknownPanel(this, tabApp);
                        }
                    }
                    if (Items.Count > 0)
                    {
                        Items.RemoveAt(0);
                    }
                }
            }
            catch
            {
            }
        }
        /// <summary>
        /// Create and return an application node
        /// </summary>
        /// <param name="app"></param>
        /// <param name="session"></param>
        /// <returns></returns>
        private TreeNode CreateApplicationNode(IHostedApplication app, Microsoft.Ccf.Csr.Session session)
        {
            // Add the app's icon to the tabControl's list
            ImageList imageList = app.GetIconList();

            if (imageList != null && imageList.Images.Count > 0)
            {
                System.Drawing.Image image = imageList.Images[0];
                sessionsTree.ImageList.Images.Add(image);
            }

            TreeNode node = new TreeNode(app.ApplicationName);

            node.Tag = app;

            // if there was no image for this application, then the image for
            // the previous application will be used.
            node.ImageIndex         = sessionsTree.ImageList.Images.Count - 1;
            node.SelectedImageIndex = node.ImageIndex;

            if (session != null)
            {
                // If this app has the current selection, select it in the tree
                if (app == session.FocusedApplication)
                {
                    sessionsTree.SelectedNode = node;
                }
            }

            return(node);
        }
        private C1USDDockTabItem ShowApplication(object child, string applicationName)
        {
            if (child is IHostedApplication5)
            {
                if (((IHostedApplication5)child).TopLevelWpfWindow.Parent != null)
                {
                    return(null);
                }
                return((C1USDDockTabItem)ShowApplicationOnUI(child, ((IHostedApplication5)child).TopLevelWpfWindow, applicationName));
            }
            else if (child is IHostedApplication)
            {
                IHostedApplication application3 = child as IHostedApplication;
                if (application3.TopLevelWindow != null)
                {
                    AifWindowsFormsHost uiElement = new AifWindowsFormsHost(application3.TopLevelWindow);
                    application3.TopLevelWindow.Tag = uiElement;
                    return((C1USDDockTabItem)ShowApplicationOnUI(child, uiElement, applicationName));
                }
            }
            else if (child is System.Windows.Forms.Control)
            {
                System.Windows.Forms.Control c     = child as System.Windows.Forms.Control;
                AifWindowsFormsHost          host2 = new AifWindowsFormsHost(c);
                c.Tag = host2;
                return((C1USDDockTabItem)ShowApplicationOnUI(child, host2, applicationName));
            }

            return(null);
        }
        /// <summary>
        /// Complete redraw of the session explorer UI.
        /// </summary>
        public void RefreshView()
        {
            IHostedApplication app = null;

            try
            {
                if (sessionsTree.SelectedNode != null &&
                    sessionsTree.SelectedNode.Tag != null)
                {
                    app = sessionsTree.SelectedNode.Tag as IHostedApplication;
                }

                // so the node select code doesn't run until we're done.
                sessionsTree.AfterSelect -= new System.Windows.Forms.TreeViewEventHandler(this.sessionsTree_AfterSelect);

                sessionsTree.SuspendLayout();

                // Erase the current tree
                sessionsTree.Nodes.Clear();

                if (sessionsTree.ImageList != null)
                {
                    sessionsTree.ImageList.Dispose();
                }
                sessionsTree.ImageList = new ImageList();
                LoadDefaultIcon();

                if (sessionManager != null)
                {
                    foreach (Session session in sessionManager)
                    {
                        AddSession(session, false);
                    }
                }

                sessionsTree.ExpandAll();
            }
            finally
            {
                sessionsTree.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.sessionsTree_AfterSelect);
                sessionsTree.ResumeLayout(true);

                updateFields();  // updates some fields to current state

                if (app != null)
                {
                    this.FocusOnApplication(app);
                }
                //if the session node is selected instead of application node, app will be null
                //hence set the selection to the appropriate node.
                //validate thoroughly for null before calling FocusOnApplication
                else if (sessionManager != null &&
                         sessionManager.ActiveSession != null &&
                         sessionManager.ActiveSession.FocusedApplication != null)
                {
                    this.FocusOnApplication(sessionManager.ActiveSession.FocusedApplication);
                }
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// Called whenever the user click to close an application.
 /// </summary>
 /// <param name="app"></param>
 protected void closeAppClick(IHostedApplication app)
 {
     if (closeApplicationClick != null)
     {
         // Notify the UI code about this change
         closeApplicationClick(app);
     }
 }
Exemplo n.º 10
0
        public static Form CreateInstance()
        {
            ApplicationRecord appRec = new ApplicationRecord();

            appRec.ApplicationID    = 5;
            appRec.Name             = "WinForm Hello World";
            appRec.Type             = 0;
            appRec.Initialization   = @"
<initstring>
  <assemblyInfo>
    <URL>Microsoft.Ccf.Samples.Citrix.WinFormHelloWorld.dll</URL>
    <type>Microsoft.Ccf.Samples.Citrix.WinFormHelloWorld</type>
  </assemblyInfo>
  <displayGroup>MainPanel</displayGroup>
  <optimumSize x=""470"" y=""380"" />
  <minimumSize x=""340"" y=""180"" />
</initstring>";
            appRec.EnableAutoSignOn = false;
            appRec.LoginFields      = null;

            BindingList <ActionRecord> list = new BindingList <ActionRecord>();

            ActionRecord ar1 = new ActionRecord();

            ar1.ActionID       = 1;
            ar1.Name           = "Default";
            ar1.Initialization = @"<ActionInit/>";
            list.Add(ar1);

            appRec.Actions = list;

#pragma warning disable 0618
            IHostedApplication stub = HostedAppFactory.CreateApplication(appRec);
#pragma warning restore 0618

            HostingForm hostingForm = new HostingForm();
            hostingForm.Name            = "StandAloneTestAppStub";
            hostingForm.Text            = stub.ApplicationName;
            hostingForm.ControlBox      = false;
            hostingForm.MaximizeBox     = false;
            hostingForm.MinimizeBox     = false;
            hostingForm.ShowInTaskbar   = false;
            hostingForm.FormBorderStyle = FormBorderStyle.None;
            hostingForm.StartPosition   = FormStartPosition.Manual;
            hostingForm.ClientSize      = stub.OptimumSize;
            hostingForm.MinimumSize     = stub.MinimumSize;

            hostingForm.Closed += delegate { stub.Close(); };

            stub.TopLevelWindow.Parent = hostingForm;
            stub.TopLevelWindow.Dock   = DockStyle.Fill;

            stub.Initialize();

            return(hostingForm);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ApplicationRolesEventArgs"/> class, containing the details of the Hosted Application.
        /// </summary>
        /// <param name="context">The <see cref="DbContext"/> instance associated to the Hosted Application.</param>
        /// <param name="hostedApplication">An instance of the <see cref="IHostedApplication"/>.</param>
        /// <exception cref="ArgumentNullException">thrown if the <paramref name="hostedApplication"/> is <c>Null</c>.</exception>
        public ApplicationRolesInitializationEventArgs(DbContext context, IHostedApplication hostedApplication)
            : base(context)
        {
            if (hostedApplication == null)
                throw new ArgumentNullException("hostedApplication");

            this.roles = hostedApplication.Roles.ToArray();
            this.Identifier = hostedApplication.Identifier;
            this.ApplicationName = hostedApplication.ApplicationName;
        }
 public AreaRegistrationCreator(IHostedApplication hostedApplication)
     : base()
 {
     this.classSource = new System.StringBuilder(AreaRegistrationCreator.GetTemplate("AreaRegistration"));
     this.dbSets = new Dictionary<Type, string>();
     this.namespaces = new List<string>();
     this.hostedApplication = hostedApplication;
     this.referencedAssemblies = new List<string>();
     this.AddAssemblyReference(typeof(AreaRegistrationCreator).Assembly);
 }
Exemplo n.º 13
0
        public bool Remove(object app)
        {
            IHostedApplication application = ContentContainer.Tag as IHostedApplication;

            if (app == application)
            {
                ContentContainer = null;
                IsOpen           = false;
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MvcHostedApplicationRegistration"/> class.
        /// </summary>
        /// <param name="identifier">The name used to identify the Hosted Module.</param>
        /// <param name="mvcModuleAssembly">The <see cref="Assembly"/> associated to the Hosted Module.</param>
        public MvcHostedApplicationRegistration(IHostedApplication hostedApplication, RouteCollection routeCollection)
            : base()
        {
            if (hostedApplication.IsInvalid())
                throw new InvalidOperationException("The Hosted Application is not correctly configured.");

            this.HostedApplication = hostedApplication;
            this.ModuleAssembly = hostedApplication.ApplicationContextType.Assembly;
            this.PathProvider = new EmbeddedViewVirtualPathProvider(this.Identifier, this.ModuleAssembly);
            HostingEnvironment.RegisterVirtualPathProvider(this.PathProvider);
            this.ModuleAssembly.RegisterControllers(routeCollection, hostedApplication.Identifier);
            ApplicationHostConfiguration.Instance.AddHostedApplication(this.HostedApplication);
        }
Exemplo n.º 15
0
 public bool IsApplicationOnPanel(Guid id)
 {
     if (ContentContainer != null)
     {
         IHostedApplication application = ContentContainer.Tag as IHostedApplication;
         if ((application != null) && (application.ApplicationID == id))
         {
             IsOpen = true;
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 16
0
        /// <summary>
        /// Add the application to the TabControl
        /// </summary>
        /// <param name="child">The application to add</param>
        /// <param name="bar">The CcfPanelToolbar to add to the control.</param>
        /// <param name="closeButton"></param>
        /// <returns>The tab page</returns>
        private TabPage addApplicationToTabControl(object child, CcfPanelToolbar bar, bool closeButton)
        {
            TabPage tabPage = null;
            Image   icon    = null;  // Icon for the tab
            string  text;            // Text for the tab

            // Get the application name and icon to be displayed on the tab
            if (child is IHostedApplication)
            {
                IHostedApplication app = child as IHostedApplication;

                // Get the app's name
                text = app.ApplicationName;

                // Get the app's icon
                ImageList imageList = app.GetIconList();
                if (imageList != null && imageList.Images.Count > 0)
                {
                    icon = imageList.Images[0];
                }

                tabPage = tabControl.ShowApplication(child, text, icon, closeButton);

                if (app == CCFAppsUI.AppWithFocus)
                {
                    tabControl.SelectedTab = tabPage;
                }
            }
            else if (child is Control)
            {
                text    = (child as Control).Text;
                tabPage = tabControl.ShowApplication(child, text, null, closeButton);
            }

            if (bar != null)
            {
                // if a toolbar already exists don't add additional ones
                foreach (Control toolbar in tabPage.Controls)
                {
                    if (toolbar is CcfPanelToolbar)
                    {
                        tabPage.Controls.Remove(toolbar);
                        break;
                    }
                }
                tabPage.Controls.Add(bar);
            }

            return(tabPage);
        }
        public void NotifyContextChange(Context context)
        {
            if (!VerifyGlobalManagerConnection())
            {
                return;
            }

            Dispatcher.BeginInvoke(new System.Action(() =>
            {
                foreach (C1USDDockTabItem item in this.Items)
                {
                    IHostedApplication tag = item.Tag as IHostedApplication;
                    if (tag != null)
                    {
                        string applicationName = tag.ApplicationName;
                        Entity thisApplication = CRMWindowRouter.LoadApplicationEntity(applicationName);
                        try
                        {
                            if (thisApplication != null && thisApplication.Contains("mcs_displayname"))
                            {
                                string appNameTemp = CRMWindowRouter.ReplaceParametersInCurrentSession((string)thisApplication["mcs_displayname"]);
                                if (!String.IsNullOrEmpty(appNameTemp) && Utility.IsAllReplacementValuesReplaced(appNameTemp))
                                {
                                    applicationName = appNameTemp;
                                }
                            }
                        }
                        catch { }
                        if (item.Header is Grid)
                        {
                            foreach (UIElement c in ((Grid)item.Header).Children)
                            {
                                if (c is System.Windows.Controls.Label)
                                {
                                    ((System.Windows.Controls.Label)c).Content = applicationName;
                                }
                            }
                        }
                        else if (item.Header is string)
                        {
                            item.Header = applicationName;
                        }
                        else if (item.Header is System.Windows.Controls.Label)
                        {
                            ((System.Windows.Controls.Label)item.Header).Content = applicationName;
                        }
                    }
                }
            }));
        }
Exemplo n.º 18
0
        public void SetActiveApplication(IHostedApplication app)
        {
            IHostedApplication tabApp;

            foreach (Window item in floatingWindows)
            {
                tabApp = item.Tag as IHostedApplication;
                if ((tabApp != null) && (tabApp.ApplicationID == app.ApplicationID))
                {
                    item.Activate();
                    return;
                }
            }
        }
Exemplo n.º 19
0
 public bool IsApplicationOnPanel(Guid id)
 {
     foreach (Window appwindow in this.floatingWindows)
     {
         if (appwindow.Content is IHostedApplication)
         {
             IHostedApplication application = appwindow.Content as IHostedApplication;
             if ((application != null) && (application.ApplicationID == id))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
        public object Add(object child, string initializationXml, bool useToolbar, bool closeButton)
        {
            if (!string.IsNullOrEmpty(initializationXml))
            {
                XmlDocument document = new XmlDocument();
                document.LoadXml(initializationXml);
                if (document.DocumentElement.SelectSingleNode("descendant::toolbar") != null)
                {
                    useToolbar = true;
                }
            }
            IHostedApplication app = child as IHostedApplication;

            return(this.ShowTabControl(child));
        }
Exemplo n.º 21
0
 public void CloseApplications()
 {
     if (this.Child != null)
     {
         ContentPresenter   item        = ContentContainer as ContentPresenter;
         IHostedApplication application = item.Tag as IHostedApplication;
         if (application != null)
         {
             IDesktopUserActions desktop = AifServiceContainer.Instance.GetService <IDesktopUserActions>();
             if (desktop != null)
             {
                 desktop.CloseDynamicApplication(application.ApplicationName);
             }
         }
         ContentContainer = null;
     }
 }
Exemplo n.º 22
0
        public void SendApplicationsToUnknownPanel()
        {
            List <IHostedApplication> tabApps = new List <IHostedApplication>();

            if (this.Child != null)
            {
                ContentPresenter   item        = ContentContainer as ContentPresenter;
                IHostedApplication application = item.Tag as IHostedApplication;
                if (application != null)
                {
                    IDesktopFeatureAccess desktop = AifServiceContainer.Instance.GetService <IDesktopFeatureAccess>();
                    if (desktop != null)
                    {
                        desktop.SendApplicationToUnknownPanel(this, application);
                    }
                }
                ContentContainer = null;
            }
        }
Exemplo n.º 23
0
        public object Add(object child, string initializationXml, bool useToolbar, bool closeButton)
        {
            if (!string.IsNullOrEmpty(initializationXml))
            {
                XmlDocument document = new XmlDocument();
                document.LoadXml(initializationXml);
                if (document.DocumentElement.SelectSingleNode("descendant::toolbar") != null)
                {
                    useToolbar = true;
                }
            }
            if (!(child is IHostedApplication5))
            {
                throw new Exception("Floating Panel does not support legacy hosted controls");
            }
            IHostedApplication app = child as IHostedApplication;

            return(this.ShowControl(child));
        }
Exemplo n.º 24
0
        public void NotifyContextChange(Context context)
        {
            if (!VerifyGlobalManagerConnection())
            {
                return;
            }

            Dispatcher.BeginInvoke(new System.Action(() =>
            {
                foreach (Window item in this.floatingWindows)
                {
                    IHostedApplication tag = item.Tag as IHostedApplication;
                    if (tag != null)
                    {
                        string applicationName = Utility.GetApplicationDisplayName(tag);
                        item.Title             = applicationName;
                    }
                }
            }));
        }
Exemplo n.º 25
0
        private Window AddApplicationToControl(object app)
        {
            Window             appwindow   = null;
            IHostedApplication application = app as IHostedApplication;

            if (application != null)
            {
                string applicationName = Utility.GetApplicationDisplayName(application);
                appwindow = ShowApplication(app, applicationName);
                if (application == DesktopApplicationUIBase.AppWithFocus)
                {
                    appwindow.Focus();
                }
            }
            else if (app is System.Windows.Forms.Control)
            {
                appwindow = ShowApplication(app, "");
            }
            return(appwindow);
        }
Exemplo n.º 26
0
        public void CloseApplications()
        {
            List <IHostedApplication> tabApps = new List <IHostedApplication>();

            if (floatingWindows.Count > 0)
            {
                foreach (Window item in floatingWindows)
                {
                    IHostedApplication tabApp = item.Tag as IHostedApplication;
                    if (tabApp != null)
                    {
                        IDesktopUserActions desktop = AifServiceContainer.Instance.GetService <IDesktopUserActions>();
                        if (desktop != null)
                        {
                            desktop.CloseDynamicApplication(tabApp.ApplicationName);
                        }
                    }
                }
                floatingWindows.Clear();
            }
        }
Exemplo n.º 27
0
        public void SendApplicationsToUnknownPanel()
        {
            List <IHostedApplication> tabApps = new List <IHostedApplication>();

            if (floatingWindows.Count > 0)
            {
                foreach (Window item in floatingWindows)
                {
                    IHostedApplication tabApp = item.Tag as IHostedApplication;
                    if (tabApp != null)
                    {
                        IDesktopFeatureAccess desktop = AifServiceContainer.Instance.GetService <IDesktopFeatureAccess>();
                        if (desktop != null)
                        {
                            desktop.SendApplicationToUnknownPanel(this, tabApp);
                        }
                    }
                }
                floatingWindows.Clear();
            }
        }
        private C1USDDockTabItem AddApplicationToTabControl(object app)
        {
            //TabItem element = null;

            C1USDDockTabItem   element     = null;
            Image              icon        = new Image();
            IHostedApplication application = app as IHostedApplication;

            if (application != null)
            {
                string applicationName = application.ApplicationName;
                if (VerifyGlobalManagerConnection())
                {
                    Entity thisApplication = CRMWindowRouter.LoadApplicationEntity(applicationName);
                    try
                    {
                        if (thisApplication != null && thisApplication.Contains("mcs_displayname"))
                        {
                            string appNameTemp = CRMWindowRouter.ReplaceParametersInCurrentSession((string)thisApplication["mcs_displayname"]);
                            if (!String.IsNullOrEmpty(appNameTemp) && Utility.IsAllReplacementValuesReplaced(appNameTemp))
                            {
                                applicationName = appNameTemp;
                            }
                        }
                    }
                    catch { }
                }
                element = ShowApplication(app, applicationName);
                if (application == DesktopApplicationUIBase.AppWithFocus)
                {
                    this.SelectedItem = element;
                }
            }
            else if (app is System.Windows.Forms.Control)
            {
                element = ShowApplication(app, "");
                AutomationProperties.SetName(element, app.ToString() + " Tab Page");
            }
            return(element);
        }
Exemplo n.º 29
0
        private Window ShowApplication(object child, string applicationName)
        {
            if (child is IHostedApplication5)
            {
                if (((IHostedApplication5)child).TopLevelWpfWindow.Parent != null)
                {
                    Window w = ((IHostedApplication5)child).TopLevelWpfWindow.Parent as Window;
                    if (w != null)
                    {
                        w.Show();
                    }
                    floatingWindows.Add(w);
                    return(w);
                }
                return((Window)ShowApplicationOnUI(child, ((IHostedApplication5)child).TopLevelWpfWindow, applicationName));
            }
            else if (child is IHostedApplication)
            {
                IHostedApplication application3 = child as IHostedApplication;
                if (application3.TopLevelWindow != null)
                {
                    AifWindowsFormsHost uiElement = new AifWindowsFormsHost(application3.TopLevelWindow);
                    application3.TopLevelWindow.Tag = uiElement;
                    return((Window)ShowApplicationOnUI(child, uiElement, applicationName));
                }
            }
            else if (child is System.Windows.Forms.Control)
            {
                System.Windows.Forms.Control c     = child as System.Windows.Forms.Control;
                AifWindowsFormsHost          host2 = new AifWindowsFormsHost(c);
                c.Tag = host2;
                return((Window)ShowApplicationOnUI(child, host2, applicationName));
            }

            return(null);
        }
        /// <summary>
        /// Remove a single application node from the session explorer.  If the application is
        /// global then will remove for all session, else will remove only for the active session
        /// passed in.
        /// </summary>
        /// <param name="session">The current active session</param>
        /// <param name="app">The application to remove</param>
        public void RemoveApplicationNode(Session session, IHostedApplication app)
        {
            if (app != null)
            {
                // If the application is global
                if (session.AppHost.IsGlobalApplication(app))
                {
                    foreach (TreeNode sessionNode in sessionsTree.Nodes)
                    {
                        // Remove of nodes for the all session
                        ArrayList al = new ArrayList();
                        foreach (TreeNode applicationNode in sessionNode.Nodes)
                        {
                            IHostedApplication adapter = applicationNode.Tag as IHostedApplication;

                            // Remove only
                            if (adapter.ApplicationName == app.ApplicationName)
                            {
                                al.Add(applicationNode);
                            }
                        }

                        foreach (object o in al)
                        {
                            TreeNode tn = (TreeNode)o;
                            sessionNode.Nodes.Remove(tn);
                        }
                        sessionsTree.ExpandAll();
                    }
                }
                // The application is non-global
                else
                {
                    foreach (TreeNode sessionNode in sessionsTree.Nodes)
                    {
                        // Remove of application nodes only for the correct session
                        if (session.Name.ToString() == sessionNode.Text.ToString())
                        {
                            ArrayList al = new ArrayList();
                            foreach (TreeNode applicationNode in sessionNode.Nodes)
                            {
                                IHostedApplication adapter = applicationNode.Tag as IHostedApplication;

                                // Remove only
                                if (adapter.ApplicationName == app.ApplicationName)
                                {
                                    al.Add(applicationNode);
                                }
                            }

                            foreach (object o in al)
                            {
                                TreeNode tn = (TreeNode)o;
                                sessionNode.Nodes.Remove(tn);
                            }
                            sessionsTree.ExpandAll();
                        }
                    }
                }
            }
        }
Exemplo n.º 31
0
        /// <summary>
        /// Restores the state of a session from the passed XML.
        /// </summary>
        /// <param name="sessionInfoXml"></param>
        /// <returns>true if this is an active session, false if not</returns>
        public override bool Restore(string sessionInfoXml)
        {
            XmlDocument doc = new XmlDocument();
            XmlNode     node;
            bool        active = false;

            // Right now we only permit a single transfer record
            doc.LoadXml(sessionInfoXml);

            // Get the name and presence state of the saved session
            node = doc.SelectSingleNode("Session");
            XmlAttribute attr = node.Attributes["name"];

            if (attr != null)
            {
                this.Name = attr.Value;
            }
            attr = node.Attributes["presence"];
            if (attr != null)
            {
                this.PresenceState = Convert.ToInt32(attr.Value);
            }

            // Return true if this was an active session
            attr = node.Attributes["active"];
            if (attr != null)
            {
                active = Convert.ToBoolean(attr.Value);
            }

            CustomerProviderCustomerRecord c = null;

            node = doc.SelectSingleNode("descendant::Customer");
            if (node != null &&
                (this.customer == null || this.customer.CustomerID == String.Empty))
            {
                c = ReadCustomer(node.InnerXml) as CustomerProviderCustomerRecord;
                if (c != null && c.CustomerID != String.Empty)
                {
                    customer = c;
                }
            }

            // Get workflow information, if any
            node = doc.SelectSingleNode("descendant::WorkflowData");
            if (node != null)
            {
                //Workflow = node.InnerXml.Trim();

                // Workflow Driven Implementation:
                // Add the <restoredWorkflow/> tag to the workflow data so that
                // Workflow control recognise this pending workflow as restored one.
                XmlDocument xdoc = new XmlDocument();
                xdoc.LoadXml(node.InnerXml.Trim());
                XmlElement restoredWrkflNode = xdoc.CreateElement("restoredWorkflow");
                xdoc.DocumentElement.AppendChild(restoredWrkflNode);

                Workflow = xdoc.OuterXml;
            }

            // Get the saved application state and pass it to the current apps
            XmlNodeList nodeList = doc.SelectNodes("descendant::Application");

            if (nodeList != null)
            {
                foreach (XmlNode appNode in nodeList)
                {
                    XmlNode stateNode = appNode.SelectSingleNode("State");
                    if (stateNode != null)
                    {
                        XmlAttribute       id  = appNode.Attributes["id"];
                        IHostedApplication app = GetApplication(Convert.ToInt32(id.Value));
                        if (app != null)
                        {
                            app.SetStateData(stateNode.InnerXml);
                        }
                    }
                }
            }

            // Get the context information, if any
            // This context wraps the Ccf Conext, hence the "Context"
            // tag name and not "CcfContext"
            node = doc.SelectSingleNode("descendant::Context");
            if (node != null)
            {
                Context context = new Context();
                context.SetContext(node.InnerXml.Trim());
                this.AppHost.SetContext(context);
            }

            //added to ensure that when actions are executed
            //after the correct context is set.
            if (customer.CustomerID != String.Empty)
            {
                this.AppHost.ExecuteApplicationState();
            }

            // Select the app the transferring agent was looking at
            node = doc.SelectSingleNode("descendant::CurrentApplication");
            if (node != null)
            {
                int appID = Convert.ToInt32(node.InnerText);
                this.FocusedApplication = GetApplication(appID);
            }
            //AUDIT TRAIL
            if (null == customer)
            {
                LogData.CustomerID = String.Empty;
            }
            else
            {
                LogData.CustomerID = customer.CustomerID;
            }
            if (this.FocusedApplication != null)
            {
                LogData.ApplicationID = this.FocusedApplication.ApplicationID;
            }
            //AUDIT TRAIL END

            return(active);
        }
 public static dynamic Create(IHostedApplication hostedApplication)
 {
     var creator = new AreaRegistrationCreator(hostedApplication);
     return creator.CreateInstance();
 }
 /// <summary>
 /// Remove a single application node from the session explorer.  If the application is
 /// global then will remove for all session, else will remove only for the active session
 /// passed in.
 /// </summary>
 /// <param name="session">The current active session</param>
 /// <param name="app">The application to remove</param>
 public virtual void RemoveApplicationNode(Session session, IHostedApplication app)
 {
     // Handled in WpfApplicationExplorer control.
 }
Exemplo n.º 34
0
        /// <summary>
        /// Adds a CCF hosted application or a user WinForms control to the
        /// CCFPanel.  If there are currenlty no app on this panel, then add
        /// to CcfDeckControl.  Else if there are more than one app on this
        /// panel, then add to CcfTabControl.
        /// </summary>
        /// <param name="child">The control or hosted app to add to the panel</param>
        /// <param name="initializationXml">An XML string for the application being added.
        /// This is used when determining how the app will appear in the panel, for
        /// instance, is there a toolbar.
        /// </param>
        /// <param name="useToolbar">True if a toolbar is used no mater what, false
        /// if the xml string should be parsed to see if one is used.
        /// </param>
        /// <param name="closeButton">True if a close button is provided for closing
        /// dynamic hosted application, false otherwise</param>
        /// <returns>The tabpage from the CcfTabControl if one is used or the CcfDeckControl</returns>
        virtual public Control Add(object child, string initializationXml, bool useToolbar, bool closeButton)
        {
            CcfPanelToolbar bar = null;

            if (initializationXml != null && initializationXml != String.Empty)
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(initializationXml);

                XmlNode node = doc.DocumentElement.SelectSingleNode("descendant::toolbar");
                if (node != null)
                {
                    useToolbar = true;
                }
            }

            IHostedApplication hostapp = child as IHostedApplication;

            // If you want all web apps to have the toolbar without adding them to
            // the database, just enable this code.
            //if ( hostapp != null && hostapp.HostedApp is HostedWebApplication )
            //{
            //	useToolbar = true;
            //}

            // Create and add the toolbar to the hosted app's deckControl
            if (useToolbar && hostapp != null)
            {
                foreach (Control toolbar in deckControl.Controls)
                {
                    if (toolbar is CcfPanelToolbar)
                    {
                        deckControl.Controls.Remove(toolbar);
                        break;
                    }
                }

                bar      = new CcfPanelToolbar(hostapp);
                bar.Dock = DockStyle.Top;
            }

            // If there are no apps yet, then show app on a deckControl
            // Else we show the controls in a tabControl
            if (deckControl.Count == 0 && tabControl.Count == 0)
            {
                deckControl.Visible = true;
                tabControl.Visible  = false;

                // Begin Dynamic
                if (closeButton)
                {
                    // Add the close button toolbar to the deckControl
                    CcfButtonToolbar closeButtonToolBar = new CcfButtonToolbar(child);
                    closeButtonToolBar.CloseButtonClick += new CcfButtonToolbar.CloseButtonClickHandler(closeButtonClick);
                    deckControl.Controls.Add(closeButtonToolBar);
                    closeButtonToolBar.Dock = DockStyle.Top;
                }

                //deckControl.CloseAppClick += new CcfDeckControl.CloseAppClickHandler(closeAppClick);

                // End Dynamic

                if (bar != null)
                {
                    // Add the CcfPanelToolbar to the deckControl
                    deckControl.Controls.Add(bar);
                }

                return(deckControl.ShowApplication(child, closeButton));
            }
            else
            {
                // Add the previosly added app from the deckControl to the tabControl
                if (deckControl.Count > 0)
                {
                    tabControl.Visible  = true;
                    deckControl.Visible = false;

                    tabControl.SelectedIndexChanged += new EventHandler(tabControl_SelectedIndexChanged);

                    // Begin Dynamic
                    tabControl.CloseAppClick += new CcfTabControl.CloseAppClickHandler(closeAppClick);
                    // End Dynamic

                    CcfPanelToolbar tempBar = null;

                    // If there are any CcfPanelToolbar on panel for this control remove from panel and add
                    // to TabPage for this app
                    foreach (Control toolbar in deckControl.Controls)
                    {
                        if (toolbar is CcfPanelToolbar)
                        {
                            tempBar = toolbar as CcfPanelToolbar;
                            deckControl.Controls.Remove(toolbar);
                            break;
                        }
                        else if (toolbar is CcfButtonToolbar)
                        {
                            CcfButtonToolbar tempbar = toolbar as CcfButtonToolbar;
                            tempbar.CloseButtonClick -= new CcfButtonToolbar.CloseButtonClickHandler(closeButtonClick);
                            deckControl.Controls.Remove(tempbar);
                        }
                    }

                    // Only 1 app on the deck control
                    bool closable = deckControl.IsClosableApplication(deckControl.HostedApplications[0] as IHostedApplication);
                    addApplicationToTabControl(deckControl.HostedApplications[0], tempBar, closable);
                    deckControl.RemoveApplication(deckControl.HostedApplications[0]);
                }

                return(addApplicationToTabControl(child, bar, closeButton));
            }
        }