示例#1
0
    protected bool WhatifExists(string whatifName)
    {
        bool exists = false;

        ADODB.Recordset rec = new ADODB.Recordset();
        DbUse.OpenAdoRec(classE1_1.globaldb, rec, "SELECT WID, Name FROM tblWhatif;");
        try {
            int i = 0;
            while (!rec.EOF && !exists)
            {
                if (i == 0)
                {
                    rec.MoveFirst();
                }
                else
                {
                    rec.MoveNext();
                }
                exists = rec.Fields["Name"].Value.ToString().ToUpper().Equals(whatifName.ToUpper());
                i++;
            }
        } catch (Exception) { }
        DbUse.CloseAdoRec(rec);
        return(exists);
    }
示例#2
0
    public string GetResMessage()
    {
        ADODB.Recordset reccust    = null;
        string          resMessage = "";

        try {
            classE1_1.Open();
            DbUse.open_ado_rec(classE1_1.globaldb, ref reccust, "zstblresults");

            resMessage = "";
            if (!reccust.EOF)
            {
                resMessage = resMessage + (string)reccust.Fields["Results"].Value;
                reccust.MoveNext();
            }
            if (reccust != null)
            {
                reccust.Close();
                reccust = null;
            }
            classE1_1.Close();
        } catch (Exception ex) {
            logFiles.ErrorLog(ex);
        }
        resMessage = resMessage.Replace("\n", "<br/>");

        return(DbUse.reproduceRedColor(resMessage));
    }
示例#3
0
    public static byte[] xxReadGroupFile(int fileId)
    {
        using (MySqlConnection conn = new MySqlConnection(DbUse.GetConnectionString())) {
            using (MySqlCommand cmd = new MySqlCommand("SELECT File From Webmpx.group_files WHERE file_id = @fileId;", conn)) {
                try {
                    conn.Open();
                    cmd.Parameters.AddWithValue("@fileId", fileId);
                    MySqlDataReader reader = cmd.ExecuteReader();

                    if (reader.Read())
                    {
                        byte[] fileBytes = (byte[])reader["File"];
                        conn.Close();
                        return(fileBytes);
                    }
                    else
                    {
                        conn.Close();
                        throw new Exception("File not found in the database");
                    }
                } catch (Exception ex) {
                    throw new Exception("Error in reading group file, sql query: " + cmd.CommandText + ". " + ex.Message);
                }
            }
        }
    }
    public static bool SameOperNumDiffNameExists(string opName, int opNum, int prodId, int opId, string connectionString, LogFiles logFiles)
    {
        bool exists = false;

        ADODB.Connection conn = new ADODB.Connection();
        ADODB.Recordset  rec  = new ADODB.Recordset();

        opName = opName.ToUpper();

        bool   adoOpen     = DbUse.OpenAdo(conn, connectionString);
        string queryString = "SELECT OpID, OpNam, OpNum, Prodfore FROM tblOper WHERE Prodfore = " + prodId + " AND OpNam <> '" + opName + "' AND OpNum = " + opNum + " AND OpID <> " + opId;
        bool   recOpen     = DbUse.OpenAdoRec(conn, rec, queryString);

        try {
            if (adoOpen && recOpen)
            {
                exists = !rec.EOF;
            }
        } catch (Exception ex) {
            logFiles.ErrorLog(ex);
        } finally {
            DbUse.CloseAdoRec(rec);
            DbUse.CloseAdo(conn);
        }
        return(exists);
    }
示例#5
0
 public void DeleteBrowserGraphs()
 {
     if (userDir != null)
     {
         string graphsDirectoryPath = DbUse.GetMainDirectory() + DbPage.BROWSER_DIR + "\\" + userDir + "Graphs";
         if (Directory.Exists(graphsDirectoryPath))
         {
             string[] files = Directory.GetFiles(graphsDirectoryPath);
             try
             {
                 foreach (string file in files)
                 {
                     File.SetAttributes(file, FileAttributes.Normal);
                     File.Delete(file);
                 }
             }
             catch (Exception) { }
         }
         else
         {
             try
             {
                 // creates the graphs directory again
                 Directory.CreateDirectory(graphsDirectoryPath);
             }
             catch (Exception) { }
         }
     }
 }
    protected void ReadData()
    {
        bool   adoOpened     = DbUse.open_ado(ref conn, GetDirectory() + userDir + MAIN_USER_DATABASE);
        string commandString = "SELECT " + TBL_GENERAL + ".* FROM(" + TBL_GENERAL + ");";
        bool   adoRecOpened  = DbUse.open_ado_rec(conn, ref rec, commandString);

        try {
            if (!adoOpened || !adoRecOpened)
            {
                throw new Exception("Error in opening database/dataset. The data cannot be displayed.");
            }
            try {
                string title = (string)rec.Fields["Title"].Value;
                title1.Value  = title;
                comment.Value = rec.Fields["com"].Value.ToString();
                dtu.Text      = (string)rec.Fields["TUFor"].Value;
                mcttu.Text    = (string)rec.Fields["tult"].Value;
                optu.Text     = (string)rec.Fields["tuprod"].Value;

                cv1.Text = rec.Fields["RTU1b"].Value.ToString();
                cv2.Text = rec.Fields["RTU1c"].Value.ToString();

                utlimit.Text = rec.Fields["Utlimit"].Value.ToString();
                laborcv.Text = rec.Fields["coef_v_labor"].Value.ToString();
                equipcv.Text = rec.Fields["coef_v_equip"].Value.ToString();
                partcv.Text  = rec.Fields["coef_v_parts"].Value.ToString();
            } catch (Exception) {
                Master.ShowErrorMessage("An error has occured while reading the data from the database. Some data might not display correctly.");
            }
        } catch (Exception ex) {
            Master.ShowErrorMessage(ex.Message);
        }
        DbUse.CloseAdo(conn);
        DbUse.CloseAdoRec(rec);
    }
示例#7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Header.DataBind();
        if (!Page.IsPostBack)
        {
            string script = "<SCRIPT language='javascript' type='text/javascript'>function textChangedClick() {eval(\"document.getElementById('" + HiddenBtn.ClientID + "').click()\"); }</SCRIPT>";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "print_script", script);
        }
        else
        {
            try
            {
                HideLoadingPopup();
            }
            catch (Exception)
            {
            }
        }

        Page.MaintainScrollPositionOnPostBack = true;
        cookiesEnabled = DbUse.CookiesEnabled();
        SetModelLabel();
        //This is where timeout is initialized
        /*   firstTimer.Interval = 12 * 60 * 1000;*/ //!!! disabled temporarily the timer - testing javascript countdown instead
        //firstTimer.Enabled = true;
        SetMainLabels();

        // menutree.CollapseAll();
    }
示例#8
0
    protected void LogoutUser()
    {
        LogFiles logFiles = new LogFiles(this.username);

        logFiles.LogoutLog();
        DbUse.LogoutUser();
    }
    //get list of groups for user

    //  get list of models in group

    // int delete model from group
    /// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public int delete_model_from_group(int model_name_id, int groupid, string user_name)
    /// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    {
        int val = 0;

        string groupname = get_groupname_fileid(model_name_id);

        //  check user_name for authority
        if (has_group_leader(groupname, user_name) == 0)
        {
            // else check if owner
            if (is_file_owner(groupid, user_name, model_name_id) == 0)
            {
                return(0);
            }
        }

        // delete model from models list
        //xxquery

        string deleteQuery = "DELETE webmpx.group_files.* From Webmpx.group_files WHERE (Group_files.file_id=  @file_id);";

        //string deleteQuery = "DELETE  webmpx.group_files.File_owner, webmpx.group_files.[file_id], webmpx.group_files.* From Webmpx.group_files WHERE (((group_files.Groupname)= '"+ groupname +"' ) AND ((group_files.File_owner)= '" + user_name + "' ) AND ((group_files.file_id)= '"+ model_name_id +"' ));";


        DbUse.RunMySqlParams(deleteQuery, new string[] { "@file_id" }, new object[] { model_name_id });


        return(-1);
    }
    /// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public int find_group_id(string groupname)
    {
        /// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        string id1;

        id1 = "0";

        if (groupname == "")
        {
            return(0);
        }

        try {
            id1 = DbUse.GetMysqlDatabaseField("Group_id", "Group_name", groupname, "group_list");
        } catch (Exception ex) {
            if (ex.Message.IndexOf("not found") >= 0)
            {
                return(0);  //  not found
            }
        }
        int i_id;

        i_id = Convert.ToInt32(id1);
        return(i_id);
    }
    //  check file powner ...

    //delete user from group
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public int delete_user_from_group(int groupid, string username, string del_name)
    /// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    {
        int val = -1;

        string groupname = find_group_name(groupid);

        //  check if user has group leader authority
        if (has_group_leader(groupname, username) == 0)
        {
            return(0);
        }

        // check if del_name is in group
        if (unique_user_name(groupname, del_name) != 0)
        {
            return(0);
        }


        string deleteQuery = " DELETE webmpx.group_members.* FROM webmpx.group_members WHERE (((Group_members.Username)= '" + del_name + "' ) AND ((Group_members.Groupname)= '" + groupname + "'  )); ";

        if (!DbUse.RunMySqlParams(deleteQuery, new string[] {}, new object[] { }))
        {
            return(0);
        }



        return(val);
    }
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public int add_model_file(string filePath, string fileName, string fileOwner, int groupid)
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    {
        try
        {
            byte[] rawData  = File.ReadAllBytes(filePath + "\\" + fileName);
            int    fileSize = rawData.Length;

            // other way to get a file to byte array
            //FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
            //long fileSize2 = fs.Length;
            //rawData = new byte[fileSize];
            //fs.Read(rawData, 0, (int)fileSize2);
            //fs.Close();

            string groupname;
            groupname = find_group_name(groupid);
            DateTime DateC = DateTime.UtcNow;

            DbUse.RunMySqlParams("INSERT INTO webmpx.group_files (File_name, File_stuff, File_size, File_owner, Group_id, Groupname, Date_created) VALUES (@FileName, @File, @FileSize, @File_owner, @Group_id, @Groupname, @DateC);",
                                 new string[] { "@FileName", "@File", "@FileSize", "@File_owner", "@Group_id", "@Groupname", "@DateC" },
                                 new object[] { fileName, rawData, fileSize, fileOwner, groupid, groupname, DateC });
        }
        catch (Exception ex)
        {
            // show error message...
            LogFiles logFiles = new LogFiles();
            logFiles.ErrorLog(ex);
            return(0);
        }

        return(-1);
    }
    /// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



    /// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public int has_group_leader(string groupname, string username)
    /// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    {
        try {
            string           entry;
            ADODB.Connection conn = new ADODB.Connection();
            ADODB.Recordset  rec  = new ADODB.Recordset();

            bool adoOpened = DbUse.OpenAdoMysql(conn);



            string commandString = "SELECT `webmpx`.group_members.* FROM   `webmpx`.group_members  WHERE (((`webmpx`.group_members.Groupname)='" + groupname + "') AND ((`webmpx`.group_members.Username)='" + username + "')  and (`webmpx`.Group_members.Leader = 'yes')  ); ";

            bool adoRecOpened = DbUse.OpenAdoRec(conn, rec, commandString);
            if (!adoOpened || !adoRecOpened)
            {
                throw new Exception("Error in opening database/dataset.");
            }

            try {
                entry = rec.Fields["leader"].Value.ToString();
            } catch (Exception) {
                throw new Exception("Field  username  leader  not found in the table  group_members.");
            }  //  end try
            DbUse.CloseAdo(conn);
            DbUse.CloseAdoRec(rec);
        } catch (Exception ex) {
            if (ex.Message.IndexOf("not found") >= 0)
            {
                return(0);
            }
        } //  end try
        return(-1);  //  group leader set ='yes'
    }     //  end routine
    }  //  end routine

    /// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public int  flipLeader(string GroupName, string username, string leadername)
    {
        if (has_group_leader(GroupName, username) == 0)
        {
            return(0);
        }

        int curval = has_group_leader(GroupName, leadername);


        string newval;

        if (curval == 0)
        {
            newval = "yes";
        }
        else
        {
            newval = "no";
        }


        if (!DbUse.RunMySqlParams("update `webmpx`.group_members SET `webmpx`.group_members.`leader` = '" + newval + "'  WHERE  `webmpx`.group_members.`Username` = '" + leadername + "'  and  `webmpx`.group_members.`Groupname` = '" + GroupName + "'  ;",
                                  new string[] {  }, new object[] {  }))
        {
            return(0);
        }

        return(-1);
    }
    protected void RenameModel(object sender, EventArgs e)
    {
        if (DbUse.InRunProcess(userDir))
        {
            Master.ShowErrorMessage("Cannot rename the model because calculations are still running. Please wait.");
            return;
        }
        string currentModel = Master.GetCurrentModel();

        if ((currentModel != null) && !currentModel.Equals("") && !currentModel.Equals("none"))
        {
            if (IsWhatifMode())
            {
                Master.SetFocus2(btnGoToWhatif.ClientID);
                modalGoToWhatif.Show();
            }
            else
            {
                lblNewName.Text      = "Enter a new name for the current model: ";
                hdnNewNameMode.Value = SaveMode.RENAME_MODEL.ToString();
                TextBox txtNewName = pnlNewModelPopup.FindControl(InputPageControls.TXT_NEW_NAME) as TextBox;

                extenderNewModel.Show();
                Master.SetFocus(txtNewName.ClientID);
            }
        }
        else
        {
            Master.ShowErrorMessage("Cannot rename the current model because no model is loaded.");
        }
    }
示例#16
0
    public bool ChangeEmail(string cookieid, string email)
    {
        bool   updated   = false;
        string sqlString = "SELECT usercred.id, usercred.mail FROM usercred INNER JOIN userlist ON usercred.id = userlist.id WHERE userlist.sessionid = '" + cookieid + "';";

        conn = new ADODB.Connection();
        rec  = new ADODB.Recordset();
        bool openedCon = DbUse.OpenAdoMysql(conn);
        bool openedRec = DbUse.OpenAdoRec(conn, rec, sqlString);

        try {
            if (!openedCon || !openedRec)
            {
                throw new Exception("An error has occured. Please try again.");
            }
            else if (rec.EOF)
            {
                throw new Exception("An internal error has occured. Missing data.");
            }
            else
            {
                rec.Fields["mail"].Value = email;
                rec.Update();
                updated = true;
            }
        } catch (Exception ex) {
            logFiles.ErrorLog(ex);
            Master.ShowErrorMessage(ex.Message);
        } finally {
            DbUse.CloseAdoRec(rec);
            DbUse.CloseAdo(conn);
        }

        return(updated);
    }
    protected void SaveModelAs(object sender, EventArgs e)
    {
        if (DbUse.InRunProcess(userDir))
        {
            Master.ShowErrorMessage("Cannot save the model because calculations are still running. Please wait.");
            return;
        }
        hdnNewNameMode.Value = SaveMode.CURRENT_MODEL.ToString();

        string modelName = Master.GetCurrentModel();

        if (modelName == null || modelName.Equals("") || modelName.Equals("none"))
        {
            string message = "Cannot save the model because no model is loaded.";
            Master.ShowErrorMessage(message);
        }
        else if (IsWhatifMode())
        {
            Master.SetFocus2(btnGoToWhatif.ClientID);
            modalGoToWhatif.Show();
        }
        else
        {
            TextBox txtNewName = pnlNewModelPopup.FindControl(InputPageControls.TXT_NEW_NAME) as TextBox;
            txtNewName.Text = modelName;
            lblNewName.Text = "Save current model as: ";
            extenderNewModel.Show();
            Master.SetFocus(txtNewName.ClientID);
        }
    }
    protected void SaveModel(object sender, EventArgs e)
    {
        if (DbUse.InRunProcess(userDir))
        {
            Master.ShowErrorMessage("Cannot save the model because calculations are still running. Please wait.");
            return;
        }
        hdnNewNameMode.Value = SaveMode.CURRENT_MODEL.ToString();

        string modelName = Master.GetCurrentModel();

        if (modelName == null || modelName.Equals("") || modelName.Equals("none"))
        {
            string message = "Cannot save the model because no model is loaded.";
            Master.ShowErrorMessage(message);
        }
        else if (IsWhatifMode())
        {
            Master.SetFocus(btnGoToWhatif.ClientID);
            modalGoToWhatif.Show();
        }
        else
        {
            SaveModel(SaveMode.CURRENT_MODEL, modelName);
        }
    }
示例#19
0
    } // end function;

    public long Get_whatif_wid(string whatifname)
    {
        //on error GoTo Err_Get_whatif_name;

        ADODB.Recordset recset1 = null;
        long            retval;

        if (whatifname == "Base Case")
        {
            return(0);
        }

        else
        {
            DbUse.open_ado_rec(globaldb, ref recset1, "Select tblwhatif.* from tblwhatif where name = " + whatifname + ";");
            if (recset1.EOF)
            {
                retval = -1;
            }
            else
            {
                retval = (long)recset1.Fields["wid"].Value;
            }

            DbUse.CloseAdoRec(recset1);
            recset1 = null;
        };

        return(retval); //exit  Function;
    } // end function;
    public static void doSessionLogin(Sessionable.Session myNewSession)
    {
        var session = HttpContext.Current.Session;

        session["username"]       = myNewSession.USERNAME;
        session["user-directory"] = myNewSession.USERDIR;
        session["timeout"]        = myNewSession.TIMEOUT;
        session["basecase"]       = myNewSession.BASECASE;
        session["scenario"]       = myNewSession.SCENARIO;
        session["analysis"]       = myNewSession.ANALYSIS;
        session["isModified"]     = myNewSession.isMODIFIED;
        session["needsRecalc"]    = true;
        if (myNewSession.USERNAME.Equals("admingla"))
        {
            session["isAdmin"] = false;
        }
        else
        {
            session["isDemo"] = false;
        }



        try
        {
            DbUse.RunMysql("UPDATE userlist SET userlist.userid = '" + String.Empty + "', userlist.sessionid = '" + GetSessionID() + "' WHERE userlist.username = '******' ; ");
        }
        catch
        {
        }
    }
示例#21
0
    } // end function;

    public int testresetwid(int wid)
    {
        ADODB.Recordset recset1 = null;
        int             retval;

        if (wid == 0)
        {
            retval = -1;
            return(retval);
        }
        DbUse.open_ado_rec(globaldb, ref recset1, "Select tblwhatif.* from tblwhatif where wid = " + wid + ";");
        if (!recset1.EOF)
        {
            retval = -1;
        }
        else
        {
            retval  = 0;
            glngwid = 0;     //  !!!  reset to 0 basecase !!
            saveWid();
            saveRecalcNeeded(0, -1);
            model_modified = -1;
            saveModel_modified();
        }

        DbUse.CloseAdoRec(recset1);
        recset1 = null;

        return(retval);
    }
示例#22
0
    public string Get_whatif_name(int wid)
    {
        //on error GoTo Err_Get_whatif_name;

        ADODB.Recordset recset1 = null;
        string          retval;

        if (wid == 0)
        {
            retval = "Basecase";
        }
        else
        {
            DbUse.open_ado_rec(globaldb, ref recset1, "Select tblwhatif.* from tblwhatif where wid = " + wid + ";");
            if (recset1.EOF)
            {
                retval = "";
            }
            else
            {
                retval = (string)recset1.Fields["Name"].Value;
            }

            DbUse.CloseAdoRec(recset1);
            recset1 = null;
        };

        return(retval);  //exit  Function;

        //Err_Get_whatif_name:
        // msgbox(ErrorToString(), 0, appl_name);
        //RESUME NEXT
    } // end function;
示例#23
0
    } // end sub;

    float availtime()
    {
        //on error GoTo err_availtime;

        ADODB.Recordset reccust = null;
        float           X;

        DbUse.open_ado_rec(globaldb, ref reccust, "tblgeneral");

        X = ((float)reccust.Fields["RTU1b"].Value) * ((float)reccust.Fields["RTU1c"].Value);
        if ((X <= 0))
        {
            X = 1;
        }
        ;



        //exit_availtime:
        DbUse.CloseAdoRec(reccust);
        reccust = null;
        return(X); //exit  Function;

        //err_availtime:
        // msgbox(ErrorToString(), 0, appl_name);
        // resume  exit_availtime;
    } // end function;
示例#24
0
    } // end function;

    public string Get_whatif_comment(int wid)
    {
        //on error GoTo Err_Get_whatif_name;

        ADODB.Recordset recset1 = null;
        string          retval;

        if (wid == 0)
        {
            retval = "Base Case";
        }
        else
        {
            DbUse.open_ado_rec(globaldb, ref recset1, "tblwhatif");
            recset1.Filter = "[wid] =" + wid;
            retval         = (string)recset1.Fields["Comm"].Value;
            DbUse.CloseAdoRec(recset1);
            recset1 = null;
        };

        // return; //exit _Get_whatif_name:
        return(retval);  //exit  Function;

        //Err_Get_whatif_name:
        // msgbox(ErrorToString(), 0, appl_name);
        //RESUME NEXT
    } // end function;
示例#25
0
    public static string GetMysqlDatabaseField(string field, string key, int keyValue, string table)
    {
        string entry;

        ADODB.Connection conn = new ADODB.Connection();
        ADODB.Recordset  rec  = new ADODB.Recordset();

        bool   adoOpened     = DbUse.OpenAdoMysql(conn);
        string commandString = "SELECT " + key + ", " + field + " FROM " + table + " WHERE " + key + " = " + keyValue + ";";
        bool   adoRecOpened  = DbUse.OpenAdoRec(conn, rec, commandString);

        if (!adoOpened || !adoRecOpened)
        {
            throw new Exception("Error in opening database/dataset.");
        }

        try {
            entry = rec.Fields[field].Value.ToString();
        } catch (Exception) {
            throw new Exception("Field '" + field + "' not found in the table '" + table + "'.");
        }
        DbUse.CloseAdo(conn);
        DbUse.CloseAdoRec(rec);
        return(entry);
    }
示例#26
0
    public static void LogoutUser(string myUsername)
    {
        RunMySqlParams("SELECT * FROM tblGroups WHERE GroupID = ?", new string[] { "@GroupID" }, new object[] { 3 });

        //RunMysql("UPDATE userlist SET userlist.userid = '" + LOGOUT_USERID + "' WHERE userlist.username = '******' ; ");
        DbUse.RunMysql("UPDATE userlist SET userlist.userid = '" + DbUse.LOGOUT_USERID + "', userlist.sessionid = '" + null + "', userlist.sessionexpires = '" + 0 + "' WHERE userlist.username = '******' ; ");
    }
示例#27
0
    protected void btnLogout_Click(object sender, EventArgs e)
    {
        string logoutMessage = "Normal logout.";

        DbUse.WriteLogoutMessageToDb(logoutMessage);
        DbUse.LogoutUser();
        Response.Redirect(LOGOUT_PAGE);
    }
示例#28
0
    public static string Progress(string sessionID)
    {
        var returnable = "";


        ADODB.Connection conn = new ADODB.Connection();
        ADODB.Recordset  rec  = new ADODB.Recordset();

        int    timePerCalc = -1;
        int    total       = -1;
        int    calc        = -1;
        string myName      = "";



        bool   adoOpened     = DbUse.OpenAdoMysql(conn);
        string commandString = "SELECT usercalc.id, usercalc.total, usercalc.calc, usercalc.timePerCalc, userCalc.curName, userlist.sessionid FROM usercalc INNER JOIN userlist ON usercalc.id = userlist.id WHERE userlist.sessionid = '" + sessionID + "';";
        bool   adoRecOpened  = DbUse.OpenAdoRec(conn, rec, commandString);

        try
        {
            timePerCalc = int.Parse(rec.Fields["timePerCalc"].Value.ToString());
            total       = int.Parse(rec.Fields["total"].Value.ToString());
            calc        = int.Parse(rec.Fields["calc"].Value.ToString());
            myName      = Convert.ToString(rec.Fields["curName"].Value);


            if (!(calc == -1 && total == -1))
            {
                if (calc == -1 && total == 0)
                {
                    returnable = "Verifying data...";
                }
                if (calc > 0 && total > 0)
                {
                    returnable = "Calculating " + myName + " (" + calc + " of " + total + ")";
                    //report += "Calculating " + currentCalc + " out of " + totalCalc + " ...";
                }
            }
            else
            {
                returnable = "Verifying data...";
            }
        }
        catch (Exception)
        {
            returnable = "Error...";
        }
        finally
        {
            DbUse.CloseAdo(conn);
            DbUse.CloseAdoRec(rec);
        }



        return(returnable);
    }
示例#29
0
    public static bool isReCalcNecessary(string username, string path)
    {
        Boolean resultMessage;


        if (isCalculating(path))
        {
            resultMessage = false;
        }
        else
        {
            ClassF classE1_1 = new ClassF(path);
            classE1_1.Open();

            try
            {
                int totalCalc = 0;

                classE1_1.username = username;
                classE1_1.SetBasicModelInfo();
                classE1_1.calc_return = 0;     //0 - none, 1 labor, 2 eq over util, 4 warnings 8 errors
                ADODB.Recordset recNeedCalc = new ADODB.Recordset();
                //check if basecase needs recalc and add to totalCalc
                DbUse.open_ado_rec(classE1_1.globaldb, ref recNeedCalc, "SELECT * FROM zs0tblWhatIf WHERE zs0tblWhatIf.WID=0;");
                int basecaserecalc = Convert.ToInt32(recNeedCalc.Fields["recalc"].Value);
                if (basecaserecalc != 0)
                {
                    totalCalc++;
                }


                bool recOpened = DbUse.OpenAdoRec(classE1_1.globaldb, recNeedCalc, "SELECT * FROM tblWhatIf WHERE FamilyID = 0 AND recalc = true AND display = -1;");

                while (!recNeedCalc.EOF)
                {
                    totalCalc++;
                    recNeedCalc.MoveNext();
                }
                DbUse.CloseAdoRec(recNeedCalc);


                if (totalCalc > 0)
                {
                    resultMessage = true;
                }
                else
                {
                    resultMessage = false;
                }
            }
            catch (Exception)
            {
                resultMessage = false;
            }
            classE1_1.Close();
        }
        return(resultMessage);
    }
示例#30
0
    private void timeoutUser()
    {
        var mySession = HttpContext.Current.Session;

        DbUse.RunMySqlParams("SELECT * FROM tblGroups WHERE GroupID = ?", new string[] { "@GroupID" }, new object[] { 3 });
        DbUse.RunMysql("UPDATE userlist SET userlist.userid = '" + DbUse.LOGOUT_USERID + "', userlist.sessionid = '" + null + "', userlist.sessionexpires = '" + 0 + "' WHERE userlist.username = '******' ; ");
        mySession.Clear();
        mySession["timeout"] = "true";
    }