Example #1
0
        /// <summary>
        /// Login. Create the connection and get session
        /// </summary>

        private static string Login(string UserName, string Password, string Participant)
        {
            string sessionID = String.Empty;

            Console.WriteLine();
            try
            {
                /* Call actual login. password is sent in MD5 */
                rt = mid.DependLogin(out sessionID, UserName, ComputeMD5Hash(Password), Assembly.GetExecutingAssembly().GetName().Name + " Ver: " + Assembly.GetExecutingAssembly().GetName().Version.ToString(), Participant);
                if (rt.HasError) // lets see what server thinks about that
                {
                    Console.WriteLine(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
                {
                    string passReference = GenerateUniqueReference(); // reference for operation used for auditing

                    Console.WriteLine(String.Format("Please Change Your Password. You have:{0} trie(s)", rt.IDInfo[6].IDValue));
                    string response;
                    Console.WriteLine("To change password press 1");
                    response = Console.ReadLine();
                    if (response == "1")
                    {
                        Console.WriteLine("Please enter old password");
                        var oldpass = Console.ReadLine();
                        Console.WriteLine("Please enter new password");
                        var newpass = Console.ReadLine();
                        Console.WriteLine("Please verifiy new password");
                        var verifypass = Console.ReadLine();
                        if (newpass != verifypass)
                        {
                            Console.WriteLine("Please verifiy new password");
                            verifypass = Console.ReadLine();
                        }
                        else
                        {
                            ChangePass(passReference, oldpass, newpass, sessionID);
                        }
                    }
                }
                else
                {
                    Console.WriteLine(String.Format("Login successful.\r\nSessionID:{0}", sessionID));
                }
            }
            catch (Exception ex) //catch unexpected stuff that is not able to set "rt" (like network failure)
            {
                Console.WriteLine(String.Format("Login exception:\r\n{0}", ex.Message));
            }
            finally
            {
                //always close once done.
                //if (mid != null)
                //    mid.Close();
            }
            return(sessionID);
        }
Example #2
0
        private static void GetListOperations()
        {
            byte[] data;
            string schema;
            string function;
            //string function2;
            string parameter;

            function = "CFUNCTION_BROKER_POSITIONS"; // Function Names
            //function2 = "LIST_HOLDER.2";
            //function = "CFUNCTION_BROKER_NON_TRADE_TRANS";

            //parameter = "null,USD"; //Function Parameters
            //parameter = "2012-04-02,2012-04-04";
            parameter = "2017-11-30";

            Console.WriteLine("\r\n Processing operation " + function);

            try
            {
                //Console.ReadLine();

                /* call operation and fill dataset. output stream is ziped! */
                rt = mid.DataSetListZIP(out schema, out data, SessionID, function, 100, parameter);

                Console.ReadLine();

                if (rt.HasError) // lets see what server thinks about that
                {
                    Console.WriteLine(String.Format(function + " error: {0}\r\n{1}", rt.ErrorInfo.ErrorReference, rt.ErrorInfo.ErrorText));
                    Console.ReadLine();
                }

                else
                {
                    string reader = MyunZipDS(data, schema);

                    Console.Write(reader);
                    Console.WriteLine("...");
                    Console.ReadLine();
                }
            }

            catch (Exception ex) //catch unexpected stuff that is not able to set "rt" (like network failure)
            {
                Console.WriteLine(String.Format(function + " exception:\r\n{0}", ex.Message));
            }
            finally
            {
                //always close once done.
                if (mid != null)
                {
                    mid.Close();
                }
            }
        }
Example #3
0
        private static bool ChangePass(string uniqueReference, string oldpass, string newpass, string sessionID)
        {
            //string sessionID = sessionID;

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

            Console.WriteLine("\r\nEnter Password: "******"P_CHANGE_PASSWORD.1", 0, null);
                if (rt.HasError) // lets see what server thinks about that
                {
                    Console.WriteLine(String.Format("Password schema retrieve error: {0}\r\n{1}", rt.ErrorInfo.ErrorReference, rt.ErrorInfo.ErrorText));
                    return(false);
                }
                else
                {
                    passwordDS.ReadXmlSchema(new StringReader(schema));
                    Console.WriteLine(String.Format("Password schema retrieved."));
                }
            }
            catch (Exception ex) //catch unexpected stuff that is not able to set "rt" (like network failure)
            {
                Console.WriteLine(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"] = ComputeMD5Hash(oldpass);  // "P@ssw0rd";
            password["USER_PASSWORD"]     = ComputeMD5Hash(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)
            {
                Console.WriteLine(String.Format("\r\nPosting {0} changed row(s) of password back to server... ", changedRows));
            }
            else
            {
                Console.WriteLine("\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, DataSetToXMLStr(passwordDS), uniqueReference);
                if (rt.HasError) // lets see what server thinks about that
                {
                    Console.WriteLine(String.Format("Password post error: {0}\r\n{1} (audit ref:{2})", rt.ErrorInfo.ErrorReference, rt.ErrorInfo.ErrorText, uniqueReference));
                    return(false);
                }
                else
                {
                    Console.WriteLine(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)
            {
                Console.WriteLine(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);
        }