Example #1
0
        public string GetG2CompanyId(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());
            }

            G2Process p = (G2Process)sessionList[portNo];

            if ((p == null) || (p.HasExited))
            {
                response.G2MgrResponse.AddG2MgrResponseRow("", "G2 is not running on specified port.", 1);
            }
            else
            {
                response.G2MgrResponse.AddG2MgrResponseRow(p.companyId.ToString(), "", 0);
            }

            return(response.GetXml());
        }
Example #2
0
        private void p_Exited(object sender, EventArgs e)
        {
            Hashtable sessionList = (Hashtable)Application["m_sessionList"];
            G2Process p           = (G2Process)sender;
            int       portNo      = p.portNo;

            if (sessionList.Contains(portNo))
            {
                sessionList.Remove(portNo);
                Application["m_sessionList"] = sessionList;
            }
        }
Example #3
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());
        }
Example #4
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());
        }
Example #5
0
        private bool ShellG2(int portNo, BSLCompany objCompany, ref string strErrMsg)
        {
            LogMsg("ShellG2: ShellG2 called.");
            Hashtable sessionList = (Hashtable)Application["m_sessionList"];

            //Retrieve application constants
            string strG2Path     = (string)Context.Cache["G2_PATH"];
            string strOKPath     = (string)Context.Cache["OK_PATH"];
            string strLogPath    = (string)Context.Cache["LOG_PATH"];
            string strG2DataPath = (string)Context.Cache["G2_DATA_PATH"];
            string strG2KB       = (string)Context.Cache["G2_KB"];

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

            LogMsg("ShellG2: Retrieved application constants.");

            //Retrieve company-specific data from database.
            string strOKFileName  = objCompany.TCompanies[0].okFileName;
            string strLogFileName = objCompany.TCompanies[0].logFileName;
            string strDataDirName = objCompany.TCompanies[0].rootDirName;

            string strRootDir = strG2DataPath + (!strG2DataPath.EndsWith("\\") ? "\\" : "") +
                                strDataDirName;

            LogMsg("ShellG2: Read company-specific data.");

            //Build G2 command line arguments
            string strArgs = "-tcpport " + portNo + " -tcpipexact";

            //strArgs += " -ok \"" + strOKPath + (!strOKPath.EndsWith("\\") ? "\\" : "") + strOKFileName + "\"";
            strArgs += " -log \"" + strLogPath + (!strLogPath.EndsWith("\\") ? "\\" : "") + strLogFileName + "\"";
            strArgs += " -root-dir \"" + strRootDir + "\"";
            strArgs += " -kb \"" + strG2KB + "\"";
            strArgs += " -nowindow";

            try
            {
                ProcessStartInfo si = new ProcessStartInfo();
                si.FileName         = "\"" + strG2Path + (!strG2Path.EndsWith("\\") ? "\\" : "") + "g2.exe\"";         // "g2.exe\""; // "start-g2.bat\""
                si.WorkingDirectory = strG2Path;
                si.Arguments        = strArgs;

                LogMsg("ShellG2: Process command line: " + si.FileName);

                LogMsg("ShellG2: Process command line args: " + strArgs);

                LogMsg("ShellG2: Process Working Dir: " + si.WorkingDirectory);

                si.WindowStyle     = ProcessWindowStyle.Normal;
                si.UseShellExecute = false;
                si.EnvironmentVariables.Add("G2_OK", strOKPath + (!strOKPath.EndsWith("\\") ? "\\" : "") + strOKFileName);

                /*
                 * si.EnvironmentVariables.Add("G2_MODULE_SEARCH_PATH",
                 *      " '%SITE_%' '%G2IHOME_%\sites\Optegrity\kbs'
                 * '%G2IHOME_%\sites\e-SCOR\kbs' '%G2IHOME_%\sites\ReThink\kbs'
                 * '%G2IHOME_%\sites\DevSite\kbs' '%G2IHOME_%\kbs' '%G2HOME_%\g2\kbs\utils'
                 * '%G2HOME_%\activexlink' '%G2HOME_%\odbc' '%G2HOME_%\pi'
                 * '%G2HOME_%\opclink\kbs' '%G2HOME_%\protools\kbs' '%G2HOME_%\gw'
                 * '%G2HOME_%\corbalink\kbs' '%G2HOME_%\javalink\kbs' '%G2HOME_%\tw2\kbs' "
                 * set G2_MODULE_SEARCH_PATH=" '%G2IHOME_%\sites\Optegrity\kbs'
                 * '%G2IHOME_%\sites\e-SCOR\kbs' '%G2IHOME_%\sites\ReThink\kbs'
                 * '%G2IHOME_%\sites\DevSite\kbs' '%G2IHOME_%\kbs' 'C:\bt\kbs'
                 * '%G2HOME_%\activexlink\kbs' '%G2HOME_%\odbc\kbs' '%G2HOME_%\pi'
                 * '%G2HOME_%\opclink\kbs' '%G2HOME_%\jmail\kbs' '%G2HOME_%\jms\kbs'
                 * '%G2HOME_%\protools\kbs' '%G2HOME_%\gw' '%G2HOME_%\corbalink\kbs'
                 * '%G2HOME_%\javalink\kbs' '%G2HOME_%\tw2\kbs' '%G2HOME_%\g2\kbs\utils'
                 * '%G2HOME_%\g2\kbs\demos' " />
                 */

                G2Process p = new G2Process(objCompany.TCompanies[0].coId, portNo);
                p.StartInfo           = si;
                p.Exited             += new EventHandler(p_Exited);
                p.EnableRaisingEvents = true;
                //p.SynchronizingObject = this.Contain;

                LogMsg("ShellG2: Calling Start.");
                if (!p.Start())
                {
                    LogMsg("ShellG2: Process failed to start.");
                    strErrMsg = "Process failed to start.";
                    return(false);
                }

                LogMsg("ShellG2: Calling WaitForInputIdle.");
                p.WaitForInputIdle(20000);
                LogMsg("ShellG2: Adding process to list.");
                sessionList.Add(portNo, p);
                LogMsg("ShellG2: Saving list.");
                Application["m_sessionList"] = sessionList;
                LogMsg("ShellG2: Returning 'true'.");
                return(true);
            }
            catch (Exception ex)
            {
                strErrMsg = ex.Message;
                LogMsg("ShellG2: " + ex.Message);
                return(false);
            }
        }