コード例 #1
0
        public string StopAll(string strUserName, string strPassword)
        {
            Hashtable  sessionList = (Hashtable)Application["m_sessionList"];
            DSResponse response    = new DSResponse();

            //Retrieve application constants
            string strConnStr = (string)Context.Cache["CONN_STR"];

            string  strErrMsg = "";
            BSLUser objUser   = GetUser(strUserName, strPassword, ref strErrMsg);

            if (objUser == null)
            {
                response.G2MgrResponse.AddG2MgrResponseRow("", strErrMsg, 1);
                return(response.GetXml());
            }

            if (!objUser.IsGensymAdmin)
            {
                response.G2MgrResponse.AddG2MgrResponseRow("",
                                                           "Method reserved for internal use.", 1);
                return(response.GetXml());
            }

            foreach (object o in sessionList.Keys)
            {
                G2Process p = (G2Process)sessionList[o];
                if ((p != null) && (!p.HasExited))
                {
                    try
                    {
                        p.Kill();
                    }
                    catch (Exception ex) {}
                }
            }

            sessionList.Clear();
            Application["m_sessionList"] = sessionList;

            response.G2MgrResponse.AddG2MgrResponseRow("Stopped all.", "", 0);
            return(response.GetXml());
        }
コード例 #2
0
        public string StopG2(string strUserName, string strPassword, int portNo)
        {
            Hashtable  sessionList = (Hashtable)Application["m_sessionList"];
            DSResponse response    = new DSResponse();

            //Retrieve application constants
            //string strConnStr = (string)Context.Cache["CONN_STR"];

            string  strErrMsg = "";
            BSLUser objUser   = GetUser(strUserName, strPassword, ref strErrMsg);

            if (objUser == null)
            {
                response.G2MgrResponse.AddG2MgrResponseRow("", strErrMsg, 1);
                return(response.GetXml());
            }

            if (!objUser.IsGensymAdmin)
            {
                response.G2MgrResponse.AddG2MgrResponseRow("",
                                                           "Method reserved for internal use.", 1);
                return(response.GetXml());
            }

            G2Process p = (G2Process)sessionList[portNo];

            if (p == null)
            {
                response.G2MgrResponse.AddG2MgrResponseRow("Stopped", "", 0);
                return(response.GetXml());
            }

            /*BSLCompany objCompany = objUser.GetCompany();
             * if (p.companyId != objCompany.TCompanies[0].coId)
             * {
             *      response.G2MgrResponse.AddG2MgrResponseRow("",
             *              "Process wasn't running under user's company Id.", 1);
             *      return response.GetXml();
             * }*/

            if (p.HasExited)
            {
                sessionList.Remove(portNo);
                Application["m_sessionList"] = sessionList;
                response.G2MgrResponse.AddG2MgrResponseRow("Stopped", "", 0);
                return(response.GetXml());
            }

            try
            {
                p.Kill();
                sessionList.Remove(portNo);
                Application["m_sessionList"] = sessionList;
                response.G2MgrResponse.AddG2MgrResponseRow("Stopped", "", 0);
            }
            catch (Exception ex)
            {
                response.G2MgrResponse.AddG2MgrResponseRow("", ex.Message, 1);
                LogMsg("StopG2 " + ex.Message);
            }

            return(response.GetXml());
        }