Beispiel #1
0
        public XenStoreSession(string name)
        {
            Base = WmiBase.Instance;
            Name = name;

            // call EndSession if this name already exists
            try
            {
                ObjectQuery obj = new ObjectQuery(String.Format("SELECT * FROM CitrixXenStoreSession WHERE Id=\"Citrix Xen Service: {0}\"", name));
                ManagementObjectSearcher mobs = new ManagementObjectSearcher(Base.Scope, obj);;
                Session = WmiBase.GetFirst(mobs.Get());
                Session.InvokeMethod("EndSession", null);
            }
            catch
            {
            }

            // create this session
            ManagementBaseObject input = Base.XenBase.GetMethodParameters("AddSession");

            input["ID"] = String.Format("Citrix Xen Service: {0}", name);
            ManagementBaseObject output      = Base.XenBase.InvokeMethod("AddSession", input, null);
            UInt32      sessionid            = (UInt32)output["SessionId"];
            ObjectQuery query                = new ObjectQuery("SELECT * from CitrixXenStoreSession WHERE SessionId=" + sessionid.ToString());
            ManagementObjectSearcher objects = new ManagementObjectSearcher(Base.Scope, query);

            Session = WmiBase.GetFirst(objects.Get());
        }
Beispiel #2
0
        public XenStoreSession(string name)
        {
            Base = WmiBase.Instance;
            Name = name;

            // call EndSession if this name already exists
            try
            {
                ObjectQuery obj = new ObjectQuery(String.Format("SELECT * FROM CitrixXenStireSession WHERE Id=\"Citrix Xen Service: {0}\"", name));
                ManagementObjectSearcher mobs = new ManagementObjectSearcher(Base.Scope, obj); ;
                Session = WmiBase.GetFirst(mobs.Get());
                Session.InvokeMethod("EndSession", null);
            }
            catch
            {
            }

            // create this session
            ManagementBaseObject input = Base.XenBase.GetMethodParameters("AddSession");
            input["ID"] = String.Format("Citrix Xen Service: {0}", name);
            ManagementBaseObject output = Base.XenBase.InvokeMethod("AddSession", input, null);
            UInt32 sessionid = (UInt32)output["SessionId"];
            ObjectQuery query = new ObjectQuery("SELECT * from CitrixXenStoreSession WHERE SessionId=" + sessionid.ToString());
            ManagementObjectSearcher objects = new ManagementObjectSearcher(Base.Scope, query);
            Session = WmiBase.GetFirst(objects.Get());
        }