public static string ExecuteNecessary()
    {
        string myUsername  = Sessionable.GetSessionUserName();
        string myDirectory = Sessionable.GetSessionUserDirectoryPath();
        string myCookie    = Sessionable.GetSessionID();

        return(Calculate.RunNecessary(myUsername, myDirectory, myCookie));
    }
    public static bool NeedsReCalc()
    {
        //var session = HttpContext.Current.Session;
        //string username = session["username"] as string;
        string myUsername  = Sessionable.GetSessionUserName();
        string myDirectory = Sessionable.GetSessionUserDirectoryPath();

        return(Calculate.isReCalcNecessary(myUsername, myDirectory));
    }
 public static void refreshSession()
 {
     Sessionable.refreshUserSession();
 }
    public static bool CancelRun()
    {
        string myCookie = Sessionable.GetSessionID();

        return(Calculate.Cancel(myCookie));
    }
    public static string GetCalcProgress()
    {
        string myCookie = Sessionable.GetSessionID();

        return(Calculate.Progress(myCookie));
    }
Beispiel #6
0
    public static List <string[]> databaseQueryArray(string query, int[] queryArray)
    {
        OleDbConnection  connec  = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Sessionable.GetSessionUserModelDirectoryPath() + ";");
        OleDbCommand     cmd     = new OleDbCommand(query, connec);
        OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);

        DataTable       dt        = new DataTable();
        List <string[]> myResults = new List <string[]>();

        try
        {
            connec.Open();

            adapter.Fill(dt);

            if (dt.Rows.Count == 0)
            {
                throw new Exception();
            }
            else
            {
                foreach (DataRow dtrow in dt.Rows)
                {
                    string[] myResult = new string[queryArray.Length];

                    for (int i = 0; i < queryArray.Length; i++)
                    {
                        myResult[i] = dtrow[queryArray[i]].ToString().ToUpper();
                    }

                    myResults.Add(myResult);
                }
            }


            connec.Close();
        }
        catch
        {
            try
            {
                connec.Close();
                connec = null;
            }
            catch { }
        }

        return(myResults);
    }
Beispiel #7
0
    public static string GetMaxUtil()
    {
        string           maxUtilQuery = "SELECT tblgeneral.utlimit FROM tblgeneral";
        OleDbConnection  connec       = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Sessionable.GetSessionUserModelDirectoryPath() + ";");
        OleDbCommand     cmd          = new OleDbCommand(maxUtilQuery, connec);
        OleDbDataAdapter adapter      = new OleDbDataAdapter(cmd);

        DataTable dt     = new DataTable();
        String    myUtil = null;

        try
        {
            connec.Open();

            adapter.Fill(dt);

            if (dt.Rows.Count == 0)
            {
                throw new Exception();
            }
            else
            {
                foreach (DataRow dtrow in dt.Rows)
                {
                    myUtil = dtrow[0].ToString().ToUpper();
                }
            }


            connec.Close();
        }
        catch
        {
            try
            {
                connec.Close();
                connec = null;
            }
            catch { }
        }

        return(myUtil);
    }
    protected void RunLogin()
    {
        string strUsername = Request.Form["txtUsername"];//should use Server.Htmlencode?

        strUsername = MyUtilities.clean(strUsername);
        string strPassword = Request.Form["txtPassword"];//should use Server.Htmlencode?



        try
        {
            if (!DbUse.CookiesEnabled())
            {
                throw new Exception(ERROR_COOKIES);
            }

            if (strUsername == "" | strPassword == "")
            {
                throw new Exception("Please Enter a Username or Password");
            }

            if (!IsValidCaptcha())
            {
                throw new Exception("Captcha Rejected!");
            }

            RecognizeUser(strUsername, strPassword);
            //IF IT DOES NOT THROW ERROR THEN USERNAME AND PASSWORD PAIR IS VALID

            bool   adoOpened     = DbUse.OpenAdoMysql(conn);
            string commandString = "SELECT * FROM userlist WHERE username = '******';";
            bool   adoRecOpened  = DbUse.OpenAdoRec(conn, rec, commandString);


            string dbUserDir      = rec.Fields["usersub"].Value.ToString();
            string dbCurrentModel = rec.Fields["currentModel"].Value.ToString();

            DbUse.CloseAdo(conn);
            DbUse.CloseAdoRec(rec);

            //Session["timeout"] = "false";
            //Session["username"] = strUsername;
            //Session["user-directory"] = dbUserDir;
            //Session["Basecase-model"] = dbCurrentModel;
            //this.Master.passCurrentModelName(currentModel);
            //IDEALLY SOFTWARE WILL SAVE MODEL ON TIMEOUT/LOGOUT, AND SET MODEL TO NONE

            bool modelModified = GetModelModified();

            if (currentModel.Equals("none"))
            {
                if (modelModified)
                {
                    modelModified = false;
                    SetModelModified(modelModified);
                }
            }

            //Session["isModified"] = modelModified;
            //this.Master.PassModelModified(modelModified);

            bool isWhatif = IsWhatifMode();
            //Session["isScenario"] = isWhatif;

            if (isWhatif)
            {
                //this.Master.PassCurrentWhatifName(GetCurrentWhatif());
                //Session["Scenario-model"] = GetCurrentWhatif();
            }

            bool isAnalysis = IsAnalysisMode();
            //Session["isAnalysis"] = isAnalysis;

            if (isAnalysis)
            {
                //this.Master.PassCurrentAnalysisName(GetCurrentAnalysis());
                //Session["Analysis-model"] = GetCurrentAnalysis();
            }

            Sessionable.Session myNewSession = new Sessionable.Session
            {
                USERNAME    = strUsername,
                TIMEOUT     = "false",
                USERDIR     = dbUserDir,
                BASECASE    = dbCurrentModel,
                isMODIFIED  = modelModified,
                SCENARIO    = GetCurrentWhatif(),
                ANALYSIS    = GetCurrentAnalysis(),
                needsRECALC = true
            };



            Sessionable.doSessionLogin(myNewSession);
            if (myNewSession.USERNAME != "admingla")
            {
                Response.Redirect("/models.aspx", true);
            }
            else
            {
                Response.Redirect("/mpx_admin.aspx", true);
            }
        }
        catch (Exception ex)
        {
            //loginCount++;
            //hidden1.Value = loginCount + "";

            if (ex.Message.ToLower().IndexOf("object reference") == 0)
            {
                txtError += " " + ex.StackTrace;
            }
            else
            {
                txtError = ex.Message;
            }
        }
        lblError.Text     = txtError;
        lblError.CssClass = "lblErrorVis";
    }