Ejemplo n.º 1
0
        // Stores the uploaded file in the Files directory. Displays the URL to the file's location.
        protected void UploadButton_Click(object sender, EventArgs e)
        {
            try
            {
                // Sets the archived name of the file.
                string fileName     = Path.GetFileName(FileUpload1.FileName);
                int    index        = fileName.LastIndexOf(".");
                string date         = DateTime.Now.ToString("yyyy-M-dd");
                string time         = DateTime.Now.ToString("HH-mm-ss");
                string dateTime     = "_" + date + "_" + time;
                string archivedName = fileName.Insert(index, dateTime);

                // Provides access to the uploaded file.
                HttpPostedFile postedFile = FileUpload1.PostedFile;
                int            fileLen    = postedFile.ContentLength;
                byte[]         array      = new byte[fileLen];
                // Initialize stream
                Stream myStream = postedFile.InputStream;
                // Read file into byte array
                myStream.Read(array, 0, fileLen);
                ServiceReference1.myInterfaceClient myPxy = new ServiceReference1.myInterfaceClient();
                fServerPath.Text = myPxy.Storage(archivedName, array);
                myPxy.Close();
            }
            catch (Exception s)
            {
                fServerPath.Text = s.Message;
            }
        }
 // Checks if the account exists in Accounts.xml.
 protected void accountExists(object sender, EventArgs e)
 {
     ServiceReference1.myInterfaceClient myPxy = new ServiceReference1.myInterfaceClient();
     if (myPxy.AccountExists(AccountOwner.Text))
     {
         myPxy.Close();
         Status.Text = "Account exists";
         return;
     }
     myPxy.Close();
     Status.Text = "Account does not exist";
 }
Ejemplo n.º 3
0
 protected void getFile(object sender, EventArgs e)
 {
     try
     {
         string archivedName = FileName.Text;
         ServiceReference1.myInterfaceClient myPxy = new ServiceReference1.myInterfaceClient();
         Status.Text = myPxy.GetFile(archivedName);
         myPxy.Close();
     }
     catch (Exception ex)
     {
         Status.Text = ex.Message;
     }
 }
Ejemplo n.º 4
0
 // Deletes the account information from Accounts.xml.
 protected void deleteAccount(object sender, EventArgs e)
 {
     ServiceReference1.myInterfaceClient myPxy = new ServiceReference1.myInterfaceClient();
     if (myPxy.AccountExists(AccountOwner.Text))
     {
         if (myPxy.DeleteAccount(AccountOwner.Text))
         {
             myPxy.Close();
             Status.Text = "Account deletion: Successful";
             return;
         }
     }
     myPxy.Close();
     Status.Text = "Account deletion: Unsuccessful";
 }
 // Updates the password in the Members.xml file & the Service's Accounts.xml file.
 protected void update(object sender, EventArgs e)
 {
     if (password1.Text != password2.Text)
     {
         Status.Text = "New password fields must match";
         return;
     }
     ServiceReference1.myInterfaceClient myPxy = new ServiceReference1.myInterfaceClient();
     if (!myPxy.UpdatePassword(Owner.Text, password.Text, password1.Text, password2.Text))
     {
         myPxy.Close();
         Status.Text = "Password update: Unsuccessful";
         return;
     }
     myPxy.Close();
     Status.Text = " Password update: Successful";
 }
Ejemplo n.º 6
0
        // Given the account nickname & the amount, it deposits the amount into the account & returns the new balance.
        protected void deposit(object sender, EventArgs e)
        {
            ServiceReference1.myInterfaceClient myPxy = new ServiceReference1.myInterfaceClient();
            string owner = myPxy.GetOwner(Nickname.Text);

            string[] info = myPxy.GetAccountInfo(owner).Split(' ');
            if (info.Length > 2)
            {
                OldBalance.Text = info[2];
                Balance.Text    = myPxy.Deposit(Nickname.Text, Amount.Text);
            }
            else
            {
                OldBalance.Text = "Invalid input";
            }
            myPxy.Close();
        }
 // Gets the account number, nickname, & balance.
 protected void getInfo(object sender, EventArgs e)
 {
     ServiceReference1.myInterfaceClient myPxy = new ServiceReference1.myInterfaceClient();
     result.Text = myPxy.GetAccountInfo(Owner.Text);
     myPxy.Close();
 }
Ejemplo n.º 8
0
 protected void createAccount(object sender, EventArgs e)
 {
     ServiceReference1.myInterfaceClient myPxy = new ServiceReference1.myInterfaceClient();
     Nickname.Text = myPxy.CreateAccount(AccountNumber.Text, AccountOwner.Text, AccountBalance.Text, Password.Text);
     myPxy.Close();
 }
 protected void getOwner(object sender, EventArgs e)
 {
     ServiceReference1.myInterfaceClient myPxy = new ServiceReference1.myInterfaceClient();
     result.Text = myPxy.GetOwner(Nickname.Text);
     myPxy.Close();
 }