示例#1
0
        public bool LoginUser(string email, string unencrytedPass)
        {
            bool successfulLogin = false;

            if (email != null && email.Length > 0 && unencrytedPass != null && unencrytedPass.Length > 0)
            {
                //encrypt passowrd
                String pass = Security.EncryptString(unencrytedPass);
                ServiceReference.ServiceUser user = null;
                //connect to webservice
                using (ServiceReference.Service1Client proxy = new ServiceReference.Service1Client())
                {
                    //get the user id - -1 if no user exists
                    user = proxy.GetUserByEmailAndPass(email, pass);
                }
                if (user != null) //login successful
                {
                    //User logged in
                    session.UserID         = user.id;
                    session.Email          = email;
                    session.RootFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\sliceofpie\\" + email;
                    Directory.CreateDirectory(session.RootFolderPath);

                    System.Windows.MessageBox.Show("Logged in successfully", "Login");
                    successfulLogin = true;
                    UpdateExplorerView();
                }
                else
                {
                    MessageBox.Show("Wrong email or password", "Unable to login");
                }
            }
            else
            {
                MessageBox.Show("Enter email and password", "Login error");
            }
            return(successfulLogin);
        }
示例#2
0
 /// <summary>
 /// Method to share the currently opened document with another user
 /// </summary>
 /// <param name="email">The email of the sue rwhich you want to share the doument</param>
 public void ShareDocument(string email)
 {
     if (email != null && email.Length > 0 && session.CurrentDocumentPath.Length > 0 && session.CurrentDocumentID != -1)
     {
         ServiceReference.ServiceUser shareUser = null;
         using (ServiceReference.Service1Client proxy = new ServiceReference.Service1Client())
         {
             shareUser = proxy.GetUserByEmail(email);
         }
         if (shareUser != null)
         {
             using (ServiceReference.Service1Client proxy = new ServiceReference.Service1Client())
             {
                 proxy.AddUserDocumentInRoot(shareUser.id, session.CurrentDocumentID);
             }
             MessageBox.Show("Document shared with " + shareUser.email, "Share success");
         }
         else
         {
             MessageBox.Show("User does not exist", "Email error");
         }
     }
 }