예제 #1
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                m_objUser = (BSLUser)Session["objUser"];
                if (m_objUser == null)
                {
                    throw new Exception("Your session has expired.");
                }

                if (m_objUser.TUsers[0].inactive)
                {
                    throw new Exception("Your account is inactive.");
                }

                if (!IsPostBack)
                {
                    BindFileDataToGrids("fileName");
                }
            }
            catch (Exception ex)
            {
                lblMsg.Visible = true;
                lblMsg.Text    = ex.Message;
            }
        }
예제 #2
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            TWOnlineHeader objHdr = (TWOnlineHeader)FindControl("main_header1");

            try
            {
                System.Security.Principal.WindowsIdentity wi =
                    System.Security.Principal.WindowsIdentity.GetCurrent();
                if (!wi.IsAuthenticated)
                {
                    throw new Exception("Current user is not authenticated.");
                }

                BSLUser objUser = new BSLUser((string)Cache["CONN_STR"]);

                string strUserName = System.IO.Path.GetFileName(wi.Name);

                objUser.Fill(strUserName);
                if (objUser.TUsers[0].inactive)
                {
                    throw new Exception("Current user account is inactive.");
                }

                Session["objUser"] = objUser;
            }
            catch (Exception ex)
            {
                string strScript = "<script for='window' event='onload' language='javascript'>alert('" + ex.Message + "');</script>";
                RegisterStartupScript("UserValidationError", strScript);
                objHdr.setError("javascript:alert('" + ex.Message + "');");
            }
        }
예제 #3
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                BSLUser objUser = (BSLUser)Session["objUser"];
                if (objUser == null)
                {
                    throw new Exception("Your session has expired.");
                }
                if (objUser.TUsers[0].inactive)
                {
                    throw new Exception("Your account is inactive.");
                }
                objUser = null;

                string m_coServerId = Request["sid"];
                if ((m_coServerId == null) || (m_coServerId.Length == 0))
                {
                    throw new Exception("Invalid server ID supplied.");
                }

                string strScript = "<script language='javascript'>function onBodyLoad(){document.all['frmcab'].src = 'twOCX.aspx?sid=" + m_coServerId + "';}</script>";
                RegisterStartupScript("populateIFrame", strScript);
            }
            catch (Exception ex)
            {
                Page.RegisterClientScriptBlock("errMsg", "<script for='window' event='onload' language='javascript'>alert(\"Error: " + ex.Message + " occurred.\");</script>");
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                m_objUser = (BSLUser)Session["objUser"];
                if (m_objUser == null)
                {
                    throw new Exception("Your session has expired.");
                }

                if (m_objUser.TUsers[0].inactive)
                {
                    throw new Exception("Your account is inactive.");
                }

                if (!IsPostBack)
                {
                    //Initialize server list
                    PopulateControls();
                }
            }
            catch (Exception ex)
            {
                Page.RegisterClientScriptBlock("errMsg", "<script for='window' event='onload' language='javascript'>alert(\"Error: " + ex.Message + " occurred.\");</script>");
            }
        }
예제 #5
0
        public string StartG2(string strUserName, string strPassword, int portNo)
        {
            LogMsg("StartG2: StartG2 called.");
            DSResponse response = new DSResponse();

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

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

            LogMsg("StartG2: Successfully retrieved user.");

            BSLCompany objCompany = objUser.GetCompany();

            LogMsg("StartG2: Successfully retrieved user's company.");

            LogMsg("StartG2: About to call ShellG2.");

            if (!ShellG2(portNo, objCompany, ref strErrMsg))
            {
                LogMsg("StartG2: " + strErrMsg + " occured in ShellG2.");
                response.G2MgrResponse.AddG2MgrResponseRow("", strErrMsg, 1);
                return(response.GetXml());
            }

            LogMsg("StartG2: Successfully Shelled G2.");

            response.G2MgrResponse.AddG2MgrResponseRow("Started", "", 0);
            return(response.GetXml());

            //			XmlDocument xDoc = new XmlDocument();
            //			xDoc.LoadXml(response.GetXml());
            //			NameTable nt = new NameTable();
            //			XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
            //			nsmgr.AddNamespace("dsresponse", "http://tempuri.org/DSResponse.xsd");
            //			XmlNode nodeErrCode = xDoc.DocumentElement.SelectSingleNode("//dsresponse:errorCode", nsmgr);
            //			if (nodeErrCode.InnerText.Equals("0"))
            //			{
            //				try
            //				{
            //					XmlNode nodeResults = xDoc.DocumentElement.SelectSingleNode("//dsresponse:results", nsmgr);
            //					if (nodeResults != null)
            //					{
            //						string s = nodeResults.InnerText;
            //						DSUser ds2 = new DSUser();
            //						System.Xml.XmlDataDocument xDataDoc = new XmlDataDocument(ds2);
            //						xDataDoc.LoadXml(s);
            //						if (ds2.TUsers.Count > 0)
            //							s = ds2.TUsers[0].firstName;
            //					}
            //				}
            //				catch(Exception ex)
            //				{
            //				}
            //			}
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            BSLUser objUser = (BSLUser)Session["objUser"];

            //Set link visibility
            link_Upload.Visible   = true;
            link_Download.Visible = true;
            separator2.Visible    = true;

            //Set Navigation URLs
            if (m_pageName.ToLower().Equals("upload.aspx"))
            {
                link_Upload.NavigateUrl = "";
            }

            if (m_pageName.ToLower().Equals("download.aspx"))
            {
                link_Download.NavigateUrl = "";
            }

            //Set welcome label
            label_Welcome.Visible = true;
            if (objUser != null)
            {
                label_Welcome.Text = "Welcome, " + objUser.TUsers[0].firstName + " " +
                                     objUser.TUsers[0].lastName;
            }
        }
예제 #7
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());
        }
예제 #8
0
        public string StartG2(string strUserName, string strPassword, int portNo, int companyId)
        {
            DSResponse response = new DSResponse();

            //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 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());
            }

            BSLCompany objCompany = new BSLCompany(strConnStr);

            try
            {
                objCompany.Fill(companyId);
            }
            catch (Exception ex)
            {
                response.G2MgrResponse.AddG2MgrResponseRow("", ex.Message, 1);
                LogMsg("StartG2: " + ex.Message);
                return(response.GetXml());
            }

            try
            {
                if (!ShellG2(portNo, objCompany, ref strErrMsg))
                {
                    response.G2MgrResponse.AddG2MgrResponseRow("", strErrMsg, 1);
                    return(response.GetXml());
                }
            }
            catch (Exception ex)
            {
                response.G2MgrResponse.AddG2MgrResponseRow("", ex.Message, 1);
                LogMsg("Start G2: " + ex.Message);
                return(response.GetXml());
            }

            response.G2MgrResponse.AddG2MgrResponseRow("Started", "", 0);
            return(response.GetXml());
        }
예제 #9
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            BSLUser objUser = (BSLUser)Session["objUser"];

            if (objUser == null)
            {
                return;
            }

            string strCoServerId = Request["sid"];

            if ((strCoServerId == null) || (strCoServerId.Length == 0))
            {
                return;
            }

            m_codeBase = (string)Cache["OCX_CODE_BASE"];
            m_classId  = (string)Cache["OCX_CLASS_ID"];

            try
            {
                int coServerId = int.Parse(strCoServerId);
                BSLCompanyServer objCoServer = new BSLCompanyServer((string)Cache["CONN_STR"]);
                objCoServer.Fill(coServerId);
                int serverId = objCoServer.TCompanyServers[0].serverId;
                m_serverName = objCoServer.TCompanyServers[0].serverName;
                int portNo = objCoServer.TCompanyServers[0].portNo;
                m_portNo   = portNo.ToString();
                m_userName = objUser.TUsers[0].userName;
                BSLSession objSession = objUser.GetCurrentSession();
                objSession.Refresh(serverId, portNo);
                objSession.Save();
                m_sessionId = objSession.TSessions[0].sessionGuid.ToString();
//				string strTempPwd = objUser.TUsers[0].password;
//				DateTime dt = objSession.TSessions[0].loginDate;
//				strTempPwd += dt.ToLongTimeString();
//				byte[] data = System.Text.Encoding.ASCII.GetBytes(strTempPwd.ToCharArray());
//				System.Security.Cryptography.SHA1CryptoServiceProvider sha =
//					new System.Security.Cryptography.SHA1CryptoServiceProvider();
//				byte[] result = sha.ComputeHash(data);
//				m_password = System.Text.Encoding.ASCII.GetString(result);
                m_password = objUser.TUsers[0].password;
                m_userMode = objUser.TUsers[0].userMode;
            }
            catch (Exception ex)
            {
                m_serverName = "";
                m_portNo     = "";
                m_userName   = "";
                m_password   = "";
                m_sessionId  = "";
                m_userMode   = "";
                RegisterStartupScript("LaunchErr", "<script language='javascript'>parent.displayError('" + ex.Message + "');</script>");
                Response.End();
                return;
            }
        }
예제 #10
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());
        }
예제 #11
0
        private BSLUser GetUser(string strUserName, string strPassword, ref string strErrMsg)
        {
            //Retrieve application constants
            string strConnStr = (string)Context.Cache["CONN_STR"];

            //Attempt to retrieve user from database
            BSLUser objUser = new BSLUser(strConnStr);

            try
            {
                objUser.Fill(strUserName, strPassword);
                return(objUser);
            }
            catch (Exception ex)
            {
                strErrMsg = ex.Message;
                LogMsg("GetUser: " + ex.Message);
                return(null);
            }
        }
예제 #12
0
        private void btn_Login_Click(object sender, System.EventArgs e)
        {
            BSLUser objUser = new BSLUser((string)Cache["CONN_STR"]);

            try
            {
                objUser.Fill(txt_UserName.Text, txt_Password.Text);
                if (objUser.TUsers[0].inactive)
                {
                    throw new Exception("User account is inactive.");
                }
                Session["objUser"] = objUser;
                Response.Redirect("selectSession.aspx", true);
                //Server.Transfer(...);
            }
            catch (Exception ex)
            {
                this.userNameValidator.ErrorMessage = ex.Message;
                this.userNameValidator.IsValid      = false;
            }
        }
예제 #13
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                m_objUser = (BSLUser)Session["objUser"];
                if (m_objUser == null)
                {
                    throw new Exception("Your session has expired.");
                }

                if (m_objUser.TUsers[0].inactive)
                {
                    throw new Exception("Your account is inactive.");
                }
            }
            catch (Exception ex)
            {
                lblMsg.Visible     = true;
                lblMsg.Text        = ex.Message;
                btn_Upload.Enabled = false;
            }
        }
예제 #14
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (m_pageName.ToLower().Equals("login.aspx"))
            {
                link_Login.NavigateUrl = "";
            }
            else
            {
                BSLUser objUser = (BSLUser)Session["objUser"];

                //Set link visibility
                link_StartSession.Visible = true;
                separator1.Visible        = true;

                if (objUser.TUsers[0].userRole >= 4)
                {
                    link_Admin.Visible = true;
                    separator2.Visible = true;
                }

                //Set Navigation URLs
                if (m_pageName.ToLower().Equals("selectsession.aspx"))
                {
                    link_StartSession.NavigateUrl = "";
                }

                if (m_pageName.ToLower().Equals("admin.aspx"))
                {
                    link_Admin.NavigateUrl = "";
                }

                //Set welcome label
                label_Welcome.Visible = true;
                label_Welcome.Text    = "Welcome, " + objUser.TUsers[0].firstName + " " +
                                        objUser.TUsers[0].lastName;
            }
        }
예제 #15
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            BSLUser objUser = (BSLUser)Session["objUser"];

            if ((objUser == null) || (objUser.TUsers[0].inactive))
            {
                return;
            }

            string strDir = Request["d"];

            if ((strDir == null) || (strDir.Length == 0))
            {
                return;
            }

            string strFilename = Request["f"];

            if ((strFilename == null) || (strFilename.Length == 0))
            {
                return;
            }

            BSLCompany objCompany     = objUser.GetCompany();
            string     strDataDirName = objCompany.TCompanies[0].rootDirName;
            string     strInputDir    = (string)Cache["G2_DATA_PATH"];

            strInputDir += (!strInputDir.EndsWith("\\") ? "\\" : "") +
                           strDataDirName;
            string strOutputDir = strInputDir;

            strInputDir += (!strInputDir.EndsWith("\\") ? "\\" : "") +
                           "Input";
            strOutputDir += (!strOutputDir.EndsWith("\\") ? "\\" : "") +
                            "Output";

            string strSourceDir = "";

            if (strDir.ToLower().Equals("i"))
            {
                strSourceDir = strInputDir;
            }
            else if (strDir.ToLower().Equals("o"))
            {
                strSourceDir = strOutputDir;
            }
            else
            {
                return;
            }

            Response.Clear();
            Response.AddHeader("content-disposition", "attachment; filename=" + strFilename);
            Response.ContentType = "application/download";             //"application/octet-stream"
            string filename = strSourceDir + "\\" + strFilename;

            System.IO.FileStream downloadFile = new System.IO.FileStream(filename,
                                                                         System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
            byte[] byteArray = new byte[(int)downloadFile.Length];
            downloadFile.Read(byteArray, 0, (int)downloadFile.Length);
            downloadFile.Close();
            Response.BinaryWrite(byteArray);
            Response.Flush();
            Response.End();
        }
예제 #16
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());
        }