예제 #1
0
파일: frmLogin.cs 프로젝트: uon-coehm/IQVL
        private bool loginEMR(string username, string password, string facilityname)
        {
            DataRow dr;
            Entity  en         = new Entity();
            string  connstring = Entity.GetConnString().ToString();

            ClsUtility.Init_Hashtable();
            string sPassword = ClsUtility.Encrypt(password);
            string sSQL      = "SELECT top 1 a.userID, a.UserName, a.Password, a.UserFirstName, a.UserLastName, c.GroupName, f.FacilityID, f.SatelliteID MFLCode FROM " +
                               "(Select FacilityID, SatelliteID FROM mst_Facility WHERE FacilityName = '" + facilityname + "') f, " +
                               "mst_user a " +
                               "INNER JOIN dbo.lnk_UserGroup b ON a.UserID = b.UserID " +
                               "INNER JOIN dbo.mst_Groups c ON b.GroupID = c.GroupID " +
                               "WHERE a.DeleteFlag = 0 AND a.UserName = '******' AND Password = '******'";

            try {
                dr = (DataRow)en.ReturnObject(connstring, ClsUtility.theParams, sSQL, ClsUtility.ObjectEnum.DataRow, serverType);
            }
            catch (Exception ex) {
                if (ex.Message.Contains("There is no row at position 0"))
                {
                    MessageBox.Show(Assets.Messages.InvalidUser, Assets.Messages.ErrorHeader, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
                else
                {
                    MessageBox.Show(ex.Message, Assets.Messages.ErrorHeader);
                    return(false);
                }
            }
            if (dr.Table.Rows.Count >= 1)
            {
                clsGbl.loggedInUser.UserID       = Convert.ToInt16(dr["userID"]);
                clsGbl.loggedInUser.UserName     = dr["UserName"].ToString();
                clsGbl.loggedInUser.Password     = dr["Password"].ToString();
                clsGbl.loggedInUser.FirstName    = dr["UserFirstName"].ToString();
                clsGbl.loggedInUser.LastName     = dr["UserLastName"].ToString();
                clsGbl.loggedInUser.Group        = dr["GroupName"].ToString();
                clsGbl.loggedInUser.FacilityID   = Convert.ToInt16(dr["FacilityID"]);
                clsGbl.loggedInUser.FacilityName = facilityname;
                clsGbl.loggedInUser.MFLCode      = dr["MFLCode"].ToString();
                return(true);
            }
            else
            {
                MessageBox.Show(Assets.Messages.InvalidUser, Assets.Messages.ErrorHeader);
                return(false);
            }
        }
        private void btnSaveUser_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text != "" && txtEmail.Text != "")
            {
                if (passwordsMatch(txtPass1.Text, txtPass2.Text))
                {
                    Entity             en = new Entity();
                    localhost.Service1 sn = new localhost.Service1( );
                    ClsUtility.Init_Hashtable();
                    string sqlString = "INSERT INTO aa_users (FirstName, LastName, UserName, GID, Password, CreateDate, DeleteFlag, Email) VALUES (" +
                                       "'" + txtFirstName.Text + "' " +
                                       ",'" + txtLastName.Text + "' " +
                                       ",'" + txtUserName.Text + "' " +
                                       ",'" + cbUserGroups.SelectedValue.ToString() + "' " +
                                       ",'" + ClsUtility.Encrypt(txtPass1.Text) + "' " +
                                       ",getdate()" +
                                       //",null " +
                                       ",0,'" + txtEmail.Text + "')";

                    /*+
                     * ",1 "
                     *
                     +
                     + ",'" + txtEmail.Text + "') ";*/

                    try
                    {
                        int i = (int)en.ReturnObject(clsGbl.cnnstr + ";Initial Catalog = " + clsGbl.iqtoolsDB, ClsUtility.theParams, sqlString, ClsUtility.ObjectEnum.ExecuteNonQuery, "mssql");
                    }
                    catch (Exception ex) {
                        string err = clsGbl.cnnstr + ";Initial Catalog = " + clsGbl.iqtoolsDB + ",<<ucUserManagement.cs: btnSaveUser_Click>>:" + ex.Message;
                        //sn.ErrorLogging(err, clsGbl.applicationName, 0);
                        MessageBox.Show(ex.Message);
                    }
                    finally { btnUsers_Click(sender, e); }
                }
                else
                {
                    MessageBox.Show("Password mismatch", "Error");
                }
            }
            else
            {
                MessageBox.Show("Missing Data", "Error");
            }
        }
예제 #3
0
        private string GetIQCareURL(String FacilityID, String ptnpk)
        {
            String url        = "";
            String encryptURL = "";
            String cryptURL   = "";

            // Prompt for Connect config if missing
            try
            {
                DataRow theDr = (DataRow)theObject.ReturnObject(Entity.getconnString(clsGbl.xmlPath), ClsUtility.theParams, "SELECT top 1 [IQServer],[IQPort],[IQUserName], u.UserID, [IQPassword],[IQTechnicalArea], [IQProtocol] FROM aa_IQCareConnect i inner join mst_user u on i.IQUserName = u.UserName WHERE i.DeleteFlag is Null And i.Active = 1", ClsUtility.ObjectEnum.DataRow, serverType);


                String IQCareUserName = theDr["IQUserName"].ToString().Trim();
                String UserID         = theDr["UserID"].ToString().Trim();
                String IQCarePassword = ClsUtility.Decrypt(theDr["IQPassword"].ToString().Trim());
                String TechnicalArea  = theDr["IQTechnicalArea"].ToString().Trim();
                String server         = theDr["IQServer"].ToString().Trim();
                String protocol       = theDr["IQProtocol"].ToString().Trim();
                String port           = theDr["IQPort"].ToString().Trim();


                cryptURL   = "Ptn_pk=" + ptnpk + "&UserName="******"&Password="******"&technicalArea=" + TechnicalArea + "&UserID=" + UserID + "&FacilityID=" + FacilityID + "";
                encryptURL = ClsUtility.Encrypt(cryptURL);

                //Format the URL
                url = protocol + "://" + server + ":" + port + "/iqcare/frmConnect.aspx?enc=" + encryptURL;
                return(url);
            }
            catch (Exception ex)
            {
                if (ex.Message.ToLower() == "there is no row at position 0.")
                {
                    //MessageBox.Show ( "Connection to IQCare Has Not Been Configured. Please Enter Your Connection Details Under The Administration Page", "IQTools", MessageBoxButtons.OK, MessageBoxIcon.Question );
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
                return(null);
            }
        }
예제 #4
0
        private string GetIQCareURL()
        {
            //Entity en = new Entity();
            //ClsUtility.Init_Hashtable();

            //String url = "";
            //String encryptURL = "";
            //String cryptURL = "";
            //try
            //{
            //    string IQCareUserName = clsGbl.loggedInUser.UserName;
            //    string UserID = clsGbl.loggedInUser.UserID.ToString();
            //    string IQCarePassword = ClsUtility.Decrypt(clsGbl.loggedInUser.Password);
            //    string TechnicalArea = "1";//theDr["IQTechnicalArea"].ToString().Trim(); Not used
            //    string server = "localhost";//theDr["IQServer"].ToString().Trim();
            //    string protocol = "http";//theDr["IQProtocol"].ToString().Trim();
            //    string port = "58789";//theDr["IQPort"].ToString().Trim();
            //    string FacilityID = clsGbl.loggedInUser.FacilityID.ToString();//"755";

            //    cryptURL = String.Format("Ptn_Pk={0}&UserName={1}&Password={2}&technicalArea={3}&UserID={4}&FacilityID={5}"
            //        , clsGbl.EMRPatientPK, IQCareUserName, IQCarePassword, TechnicalArea, UserID, FacilityID);
            //    encryptURL = ClsUtility.Encrypt(cryptURL);

            //    //Format the URL
            //    //url = protocol + "://" + server + ":" + port + "/iqcare/frmConnect.aspx?enc=" + encryptURL;
            //    url = String.Format("{0}://{1}:{2}/frmConnect.aspx?enc={3}"
            //        ,protocol,server,port,encryptURL);
            //    return url;
            //}
            //catch (Exception ex)
            //{
            //    if (ex.Message.ToLower() == "there is no row at position 0.")
            //    {
            //        //MessageBox.Show ( "Connection to IQCare Has Not Been Configured. Please Enter Your Connection Details Under The Administration Page", "IQTools", MessageBoxButtons.OK, MessageBoxIcon.Question );
            //    }
            //    else
            //    {
            //        MessageBox.Show(ex.Message);
            //    }
            //    return null;
            //}

            string url        = string.Empty;
            string encryptURL = string.Empty;
            string cryptURL   = string.Empty;
            string page       = string.Empty;

            //if (Convert.ToDouble(clsGbl.EmrVersion) < Convert.ToDouble(3.6))
            //{
            //page = "frmConnect.aspx";
            //}
            //else
            page = "frmConnect36.aspx";
            try
            {
                string IQCareUserName = clsGbl.loggedInUser.UserName;
                string UserID         = clsGbl.loggedInUser.UserID.ToString();
                string IQCarePassword = ClsUtility.Decrypt(clsGbl.loggedInUser.Password);
                string TechnicalArea  = "1"; //Not used
                //string server = clsGbl.EMRIPAddress;
                string server     = "localhost";
                string protocol   = "http";
                string port       = "80";
                string FacilityID = clsGbl.loggedInUser.FacilityID.ToString();

                cryptURL = String.Format("Ptn_Pk={0}&UserName={1}&Password={2}&technicalArea={3}&UserID={4}&FacilityID={5}"
                                         , clsGbl.EMRPatientPK, IQCareUserName, IQCarePassword, TechnicalArea, UserID, FacilityID);
                encryptURL = ClsUtility.Encrypt(cryptURL);

                //Format the URL
                //url = protocol + "://" + server + ":" + port + "/iqcare/frmConnect.aspx?enc=" + encryptURL;
                url = String.Format("{0}://{1}:{2}/iqcare/{3}?enc={4}"
                                    , protocol, server, port, page, encryptURL);
                return(url);
            }
            catch (Exception ex)
            {
                if (ex.Message.ToLower() == "there is no row at position 0.")
                {
                    //MessageBox.Show ( "Connection to IQCare Has Not Been Configured. Please Enter Your Connection Details Under The Administration Page", "IQTools", MessageBoxButtons.OK, MessageBoxIcon.Question );
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
                return(null);
            }
        }
예제 #5
0
파일: frmLogin.cs 프로젝트: moshonk/IQTools
        private bool loginEMR(string emr, string userName, string password, string facilityName)
        {
            string emrConnString = "";

            ClsUtility.Init_Hashtable();
            Entity en = new Entity();

            try
            {
                if (emr.ToLower() == "iqcare")
                {
                    DataRow dr = (DataRow)en.ReturnObject(Entity.GetConnString(), ClsUtility.theParams
                                                          , "Select ConnString,DBase,DBName From aa_Database", ClsUtility.ObjectEnum.DataRow, serverType);
                    emrConnString = ClsUtility.Decrypt(dr["ConnString"].ToString());
                    string sPassword = ClsUtility.Encrypt(password);
                    string sSQL      = "SELECT top 1 a.userID, a.UserName, a.Password, a.UserFirstName, a.UserLastName, c.GroupName, f.FacilityID, f.PosID MFLCode FROM " +
                                       "(Select FacilityID, PosID FROM mst_Facility WHERE FacilityName = '" + facilityName + "') f, " +
                                       "mst_user a " +
                                       "INNER JOIN dbo.lnk_UserGroup b ON a.UserID = b.UserID " +
                                       "INNER JOIN dbo.mst_Groups c ON b.GroupID = c.GroupID " +
                                       "WHERE a.DeleteFlag = 0 AND a.UserName = '******' AND Password = '******'";
                    try
                    {
                        dr = (DataRow)en.ReturnObject(emrConnString, ClsUtility.theParams, sSQL, ClsUtility.ObjectEnum.DataRow, serverType);
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message.Contains("There is no row at position 0"))
                        {
                            MessageBox.Show(Assets.Messages.InvalidUser, Assets.Messages.ErrorHeader, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return(false);
                        }
                        else
                        {
                            MessageBox.Show(ex.Message, Assets.Messages.ErrorHeader);
                            return(false);
                        }
                    }
                    if (dr.Table.Rows.Count >= 1)
                    {
                        clsGbl.loggedInUser.UserID       = Convert.ToInt16(dr["userID"]);
                        clsGbl.loggedInUser.UserName     = dr["UserName"].ToString();
                        clsGbl.loggedInUser.Password     = dr["Password"].ToString();
                        clsGbl.loggedInUser.FirstName    = dr["UserFirstName"].ToString();
                        clsGbl.loggedInUser.LastName     = dr["UserLastName"].ToString();
                        clsGbl.loggedInUser.Group        = dr["GroupName"].ToString();
                        clsGbl.loggedInUser.FacilityID   = Convert.ToInt16(dr["FacilityID"]);
                        clsGbl.loggedInUser.FacilityName = facilityName;
                        clsGbl.loggedInUser.MFLCode      = dr["MFLCode"].ToString();
                        return(true);
                    }
                    else
                    {
                        MessageBox.Show(Assets.Messages.InvalidUser, Assets.Messages.ErrorHeader);
                        return(false);
                    }
                }
                else if (emr.ToLower() == "cpad")
                {
                    DataRow dr        = null;
                    string  sPassword = ClsUtility.Encrypt(password);
                    string  sSQL      = "SELECT a.userID, a.UserName, a.Password, a.firstname, a.lastname, b.facilityname, a.salt FROM cpad.mst_user a" +
                                        ",(select a.facilityname from cpad.mst_facility a where configured = true limit 1)b " +
                                        "WHERE a.DeleteFlag = false AND a.username = '******' limit 1";
                    try
                    {
                        dr = (DataRow)en.ReturnObject(Entity.getconnString(clsGbl.xmlPath), ClsUtility.theParams
                                                      , sSQL, ClsUtility.ObjectEnum.DataRow, serverType);
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message.Contains("There is no row at position 0"))
                        {
                            MessageBox.Show(Assets.Messages.InvalidUser, Assets.Messages.ErrorHeader, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return(false);
                        }
                        else
                        {
                            MessageBox.Show(ex.Message, Assets.Messages.ErrorHeader);
                            return(false);
                        }
                    }
                    if (dr.Table.Rows.Count >= 1)
                    {
                        string salt = dr["salt"].ToString();
                        string p    = password + salt;
                        string s    = ClsUtility.GetSHA1Hash(p);
                        if (s == dr["password"].ToString())
                        {
                            clsGbl.loggedInUser.UserID       = Convert.ToInt16(dr["userID"]);
                            clsGbl.loggedInUser.UserName     = dr["UserName"].ToString();
                            clsGbl.loggedInUser.Password     = dr["Password"].ToString();
                            clsGbl.loggedInUser.FirstName    = dr["FirstName"].ToString();
                            clsGbl.loggedInUser.LastName     = dr["LastName"].ToString();
                            clsGbl.loggedInUser.FacilityName = dr["facilityname"].ToString();
                            return(true);
                        }
                        else
                        {
                            MessageBox.Show(Assets.Messages.InvalidUser, Assets.Messages.ErrorHeader, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return(false);
                        }
                    }
                    else
                    {
                        MessageBox.Show(Assets.Messages.InvalidUser, Assets.Messages.ErrorHeader);
                        return(false);
                    }
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Assets.Messages.ErrorHeader);
                return(false);
            }
        }