public string UserRegister(string foaf_nick, string foaf_mbox, string paths_password) { var mTimer = new Stopwatch(); mTimer.Start(); try { euPaths clseuPaths = new euPaths(); string strQueryUserCheck = "select id from usr where email = '" + foaf_mbox + "';"; int rtnUserID = Utility.DBExecuteScalar(strQueryUserCheck); if (rtnUserID == 0) { string strQuery = "INSERT INTO usr (fk_cog_style_id,usr,foaf_nick,pwd,email) VALUES ('" + 1 + "','" + foaf_mbox + "','" + foaf_nick + "','" + paths_password + "','" + foaf_mbox + "');SELECT currval('usr_id_seq');"; int rtnID = Utility.DBExecuteScalar(strQuery); if (Convert.ToString(Context.Session.SessionID).Trim() != "") { strQuery = "select fk_usr_id from uaction where usession = '" + Convert.ToString(Context.Session.SessionID).Trim() + "';"; int rtnUID = Utility.DBExecuteScalar(strQuery); if (Context.Session["usr_id"] == null) { strQuery = "INSERT INTO workspace (fk_usr_id, isprimary) VALUES (" + rtnID + ", true);"; int workspaceID = Utility.DBExecuteScalar(strQuery); } else { strQuery = "update workspace set fk_usr_id = " + rtnID + " , isprimary = true where fk_usr_id=" + Context.Session["usr_id"] + ";"; int workspaceID = Utility.DBExecuteScalar(strQuery); } strQuery = "update uaction set fk_usr_id = " + rtnID + " where usession = '" + Convert.ToString(Context.Session.SessionID).Trim() + "';"; Utility.DBExecuteNonQuery(strQuery); strQuery = "update ubehaviour set fk_usr_id = " + rtnID + " where usession = '" + Convert.ToString(Context.Session.SessionID).Trim() + "';"; Utility.DBExecuteNonQuery(strQuery); } Context.Session["usr_id"] = rtnID; Context.Session["isAuthenticated"] = true; string strRV = clseuPaths.GetCurrentUserDetails(Convert.ToString(rtnID)); Utility.LogRequest(strRV, false, mTimer); return strRV; } else { var mMsg = Utility.GetMsg(Utility.msgStatusCodes.EmailAlreadyExists, "Email already exists"); Utility.LogRequest(mMsg,false, mTimer); return mMsg; } } catch (Exception ex) { var mMsg = Utility.GetMsg(Utility.msgStatusCodes.DatabaseSQLError, ex.Message); Utility.LogRequest(mMsg, true, mTimer); return mMsg; } }
public string UserLogin(string foaf_mbox, string paths_password) { var mTimer = new Stopwatch(); mTimer.Start(); euPaths clseuPaths = new euPaths(); try { int isAuthenticated = clseuPaths.authenticate(foaf_mbox, paths_password); string strQuery = string.Empty; string strRV = string.Empty; if (isAuthenticated > 0) { if (Context.Session["isTemporary"] != null && Utility.IsNumeric(Convert.ToString(Context.Session["usr_id"]))) { strQuery = "select id from workspace where isprimary = true and fk_usr_id =" + isAuthenticated + ";"; int rtnWSID = Utility.DBExecuteScalar(strQuery); strQuery = "select id from workspace WHERE fk_usr_id=" + Convert.ToString(Context.Session["usr_id"]) + ";"; DataTable dtRtnWSTID = Utility.DBExecuteDataTable(strQuery); //delete from workspace where id = 18 foreach (DataRow drow in dtRtnWSTID.Rows) { strQuery = "delete from workspace where id =" + drow["id"] + ";"; Utility.DBExecuteScalar(strQuery); } strQuery = "delete from usr where id =" + Convert.ToString(Context.Session["usr_id"]) + ";"; Utility.DBExecuteScalar(strQuery); foreach (DataRow drow in dtRtnWSTID.Rows) { strQuery = "UPDATE workspace_item SET fk_workspace_id=" + rtnWSID + " WHERE fk_workspace_id=" + drow["id"] + ";"; int rtnID = Utility.DBExecuteNonQuery(strQuery); } Context.Session["isTemporary"] = null; } Context.Session["usr_id"] = isAuthenticated; Context.Session["isAuthenticated"] = true; //Get user data after login strRV = clseuPaths.GetCurrentUserDetails(Convert.ToString(Context.Session["usr_id"])); Utility.LogRequest(strRV, false, mTimer); return strRV; } else { Context.Session["usr_id"] = null; Context.Session["isAuthenticated"] = null; var mMsg = Utility.GetMsg(Utility.msgStatusCodes.AuthenticationFailed); Utility.LogRequest(mMsg, false, mTimer); return mMsg; } } catch (Exception ex) { var mMsg = Utility.GetMsg(Utility.msgStatusCodes.OperationFailed, ex.Message); Utility.LogRequest(mMsg); return mMsg; } }
public string UserLogout() { var mTimer = new Stopwatch(); mTimer.Start(); euPaths clseuPaths = new euPaths(); Context.Session["isAuthenticated"] = null; Context.Session["usr_id"] = null; Context.Session.Clear(); Context.Session.Abandon(); string strQuery = string.Empty; string strRV = string.Empty; if (Context.Session["isAuthenticated"] == null) { clseuPaths.createTemporaryUser(Context); } //Get anonymous user data. strRV = clseuPaths.GetCurrentUserDetails(Convert.ToString(Context.Session["usr_id"])); Utility.LogRequest(strRV, false, mTimer); return strRV; }
public string Current() { var mTimer = new Stopwatch(); mTimer.Start(); string strRV = string.Empty; euPaths clseuPaths = new euPaths(); if (clseuPaths.requireUser(Context) == false) { // **** Updated on 12 September 2013 // commented below line and add new line. // return Utility.GetMsg(Utility.msgStatusCodes.OperationFailed, "Failed to create temporary user"); clseuPaths.requireUser(Context); // **** Updated on 12 September 2013 } try { strRV = clseuPaths.GetCurrentUserDetails(Convert.ToString(Context.Session["usr_id"])); Utility.LogRequest(strRV, false, mTimer); return strRV; } catch (Exception ex) { var mMsg = Utility.GetMsg(Utility.msgStatusCodes.DatabaseSQLError, ex.Message); Utility.LogRequest(mMsg, true, mTimer); return mMsg; } }