Exemplo n.º 1
0
        public static void isLoggedIn()
        {
            byte[] bs;
            string schema;
            string sessionID = Server.SessionID.ToString();

            rt = mid.DataSetListZIP(out schema, out bs, sessionID, "P_CHANGE_PASSWORD.1", 1, null);

            //if ((Server.rt.ErrorInfo.ErrorReference == "ML001047") ||
            //    (Server.rt.ErrorInfo.ErrorReference == "ML001048"))
            while ((Server.rt.ErrorInfo.ErrorReference == "ML001047") ||
                   (Server.rt.ErrorInfo.ErrorReference == "ML001048") ||
                   (Server.rt.ErrorInfo.ErrorReference == "ML001051"))
            {
                //MessageBox.Show("Please change the Password for user" + UserName);
                using (ReLogin renewSession = new ReLogin())
                {
                    //Server.RetrieveBrowserInformation();

                    //IntPtr handle = mainForm.Handle;
                    renewSession.Activate();

                    renewSession.ShowDialog();
                    renewSession.Dispose();
                }
            }
        }
Exemplo n.º 2
0
 public static void Logout()
 {
     //Console.WriteLine();
     try
     {
         rt = mid.Logout(SessionID); // call logout
         if (rt.HasError)            // lets see what server thinks about that // lets see what server thinks about that
         {
             LogDetails.writeLog(Server.logfile, String.Format("Logout error: {0}\r\n{1}", rt.ErrorInfo.ErrorReference, rt.ErrorInfo.ErrorText));
         }
         else
         {
             SessionID = null; // termination accepted - no point to keep old value
             LogDetails.writeLog(Server.logfile, String.Format("Logout successful."));
         }
     }
     catch (Exception ex) //catch unexpected stuff that is not able to set "rt" (like network failure)
     {
         LogDetails.writeLog(Server.logfile, String.Format("Logout exception:\r\n{0}", ex.Message));
     }
     finally
     {
         //always close once done.
         if (mid != null)
         {
             mid.Close();
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Login. Create the connection and get session
        /// </summary>
        public static string Login(string UserName, string Password, string Participant)
        {
            string sessionID = String.Empty;

            //Console.WriteLine();
            try
            {
                GetServerVersionInfo();


                /* Call actual login. password is sent in MD5 */
                rt = mid.DependLogin(out sessionID, UserName, Utils.MD5(Password), Assembly.GetExecutingAssembly().GetName().Name + " Ver: " + Assembly.GetExecutingAssembly().GetName().Version.ToString(), Participant);
                Server.SessionID = sessionID;
                if (rt.HasError) // lets see what server thinks about that
                {
                    LogDetails.writeLog(Server.logfile, String.Format("Login error: {0}\r\n{1}", rt.ErrorInfo.ErrorReference, rt.ErrorInfo.ErrorText));
                }

                else if (rt.IDInfo[6].IDType == "USER_WARN_REMAIN") //warning is returned if password needs to be changed
                {
                    MessageBox.Show("Please change the Password for user" + UserName);
                    using (ChangePassword changePassword = new ChangePassword())
                    {
                        //Server.RetrieveBrowserInformation();

                        //IntPtr handle = mainForm.Handle;
                        changePassword.Activate();

                        changePassword.ShowDialog();
                        changePassword.Dispose();
                    }
                }
                else
                {
                    LogDetails.writeLog(Server.logfile, String.Format("Login successful.\r\nSessionID:{0}", sessionID));
                }
            }
            catch (Exception ex) //catch unexpected stuff that is not able to set "rt" (like network failure)
            {
                LogDetails.writeLog(Server.logfile, String.Format("Login exception:\r\n{0}", ex.Message));
            }
            finally
            {
                //always close once done.
                //if (mid != null)
                //    mid.Close();
            }
            return(sessionID);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Retrieving browser information (use LIST_HOLDER as an example)
        /// </summary>
        public static DataTable getTable(string operation, string param, int noRecords, string version)
        {
            byte[]    bs;
            string    schema;
            string    function;
            string    parameter;
            DataTable configTable = new DataTable();

            //function = "LIST_BATCH.1";
            //parameter = "BATCHCONTROL_ID = " + batchID;
            //function = operation + version;
            function  = operation;
            parameter = param;

            //File.AppendAllText(Server.logfile,"\r\nBrowsing: ");
            try
            {
                isLoggedIn();
                /* call operation and fill dataset. output stream is ziped! */
                Server.rt = Server.mid.DataSetListZIP(out schema, out bs, Server.SessionID, function, noRecords, parameter);
                //Server.rt = Server.mid.DataSetListZIP(out schema, out bs, Server.SessionID, function, -1, "BATCHCONTROL_ID = 31");
                if (Server.rt.HasError) // lets see what server thinks about that
                {
                    LogDetails.writeLog(Server.logfile, String.Format("Browser error: {0}\r\n{1}", Server.rt.ErrorInfo.ErrorReference, Server.rt.ErrorInfo.ErrorText));
                }
                else
                {
                    /* unzip output from server */
                    DataSet browserDS = Utils.unZipDS(bs, schema);
                    /* print out all tables in dataset */

                    configTable = browserDS.Tables[operation];
                }
            }
            catch (Exception ex) //catch unexpected stuff that is not able to set "rt" (like network failure)
            {
                LogDetails.writeLog(Server.logfile, String.Format("Account Status list exception:\r\n{0}", ex.Message));
            }
            finally
            {
                //always close once done.
                //if (mid != null)
                //    mid.Close();
            }
            return(configTable);
        }
Exemplo n.º 5
0
        //private static bool ChangePass(string uniqueReference, string oldpass, string newpass, string sessionID)
        public static bool ChangePass(string uniqueReference, string oldpass, string newpass, string sessionID)
        {
            //string sessionID = sessionID;

            byte[]  bs;
            DataRow password;
            DataSet passwordDS = new DataSet("Password");

            LogDetails.writeLog(Server.logfile, "\r\nEnter Password: "******"P_CHANGE_PASSWORD.1", 0, null);
                if (rt.HasError) // lets see what server thinks about that
                {
                    LogDetails.writeLog(Server.logfile, String.Format("Password schema retrieve error: {0}\r\n{1}", rt.ErrorInfo.ErrorReference, rt.ErrorInfo.ErrorText));
                    return(false);
                }
                else
                {
                    passwordDS.ReadXmlSchema(new StringReader(schema));
                    LogDetails.writeLog(Server.logfile, String.Format("Password schema retrieved."));
                }
            }
            catch (Exception ex) //catch unexpected stuff that is not able to set "rt" (like network failure)
            {
                LogDetails.writeLog(Server.logfile, String.Format("Account Status list exception:\r\n{0}", ex.Message));
                return(false);
            }
            finally
            {
                //always close once done.
                //if (mid != null)
                //    mid.Close();
            }
            password = passwordDS.Tables["P_CHANGE_PASSWORD"].NewRow();
            password["USER_OLD_PASSWORD"] = Utils.MD5(oldpass); // "P@ssw0rd";
            password["USER_PASSWORD"]     = Utils.MD5(newpass); // "dr0wss@P1";

            passwordDS.Tables["P_CHANGE_PASSWORD"].Rows.Add(password);
            // insert password
            int changedRows = 0;
            int auditID     = 0;

            /* check if there is changed rows */
            if (passwordDS.Tables[0].GetChanges() != null)
            {
                changedRows = passwordDS.Tables[0].GetChanges().Rows.Count;
            }
            if (changedRows > 0)
            {
                LogDetails.writeLog(Server.logfile, String.Format("\r\nPosting {0} changed row(s) of password back to server... ", changedRows));
            }
            else
            {
                LogDetails.writeLog(Server.logfile, "\r\nNothing to write to server");
                return(false);
            }
            try
            {
                /* call actual update with user reference GenerateUniqueReference().
                 * server reference will be in auditID. Send changes only to reduce the load and optimize performance */
                rt = mid.DataSetUpdate(ref auditID, sessionID, "P_CHANGE_PASSWORD.1", 0, Utils.DataSetToXMLStr(passwordDS), uniqueReference);
                if (rt.HasError) // lets see what server thinks about that
                {
                    LogDetails.writeLog(Server.logfile, String.Format("Password post error: {0}\r\n{1} (audit ref:{2})", rt.ErrorInfo.ErrorReference, rt.ErrorInfo.ErrorText, uniqueReference));
                    return(false);
                }
                else
                {
                    LogDetails.writeLog(Server.logfile, String.Format("Password posted with auditID: {0} (audit ref:{1})", auditID, uniqueReference));
                }
            }
            catch (Exception ex)  //catch unexpected stuff that is not able to set "rt" (like network failure)
            {
                LogDetails.writeLog(Server.logfile, String.Format("Password table edit exception:\r\n{0}\r\n(audit ref:{1})", ex.Message, uniqueReference));
                return(false);
            }
            finally
            {
                //always close once done.
                //if (mid != null)
                //    mid.Close();
            }
            return(true);
        }