EaseFilter Demo Project
AccountForm.cs
Go to the documentation of this file.
1 //
3 // (C) Copyright 2012 EaseFilter Technologies Inc.
4 // All Rights Reserved
5 //
6 // This software is part of a licensed software product and may
7 // only be used or copied in accordance with the terms of that license.
8 //
10 
11 using System;
12 using System.Collections.Generic;
13 using System.ComponentModel;
14 using System.Data;
15 using System.Drawing;
16 using System.Linq;
17 using System.Text;
18 using System.Windows.Forms;
19 
21 
22 namespace SecureAgent
23 {
24  public partial class AccountForm : Form
25  {
26  public static string accountName = string.Empty;
27  public static string password = string.Empty;
28  public static bool isAuthorized = false;
29  public static bool isGuest = true;
30 
31  public AccountForm()
32  {
33  InitializeComponent();
34  textBox_EmailAddress.Text = GlobalConfig.AccountName;
35 
36  this.StartPosition = FormStartPosition.CenterScreen;
37  }
38 
39  private void button_SignIn_Click(object sender, EventArgs e)
40  {
41  GlobalConfig.AccountName = textBox_EmailAddress.Text;
43 
44  button_SignIn.Enabled = false;
45 
46  try
47  {
48  if (string.IsNullOrEmpty(textBox_EmailAddress.Text))
49  {
50  MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
51  MessageBox.Show("The account name can't be empty.", "account", MessageBoxButtons.OK, MessageBoxIcon.Error);
52 
53  return;
54 
55  }
56 
57  accountName = textBox_EmailAddress.Text.ToLower().Trim();
58  password = textBox_Password.Text.Trim();
59 
60  if (string.Compare(accountName, "guest") == 0)
61  {
62  isAuthorized = true;
63  isGuest = true;
64  return;
65  }
66  else
67  {
68  if (string.IsNullOrEmpty(password))
69  {
70  MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
71  MessageBox.Show("The password can't be empty.", "password", MessageBoxButtons.OK, MessageBoxIcon.Error);
72 
73  return;
74 
75  }
76  }
77 
78  string lastError = string.Empty;
79 
80  //verify user account in remove server.
81  isAuthorized = true;
82 
83  if (!isAuthorized)
84  {
85  MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
86  MessageBox.Show(lastError, "SignIn", MessageBoxButtons.OK, MessageBoxIcon.Error);
87 
88  return;
89  }
90 
91  isGuest = false;
92  }
93  catch (Exception ex)
94  {
95  MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
96  MessageBox.Show("Sign in account failed with error" + ex.Message, "SignIn", MessageBoxButtons.OK, MessageBoxIcon.Error);
97  }
98  finally
99  {
100  button_SignIn.Enabled = true;
101 
102  if (isAuthorized)
103  {
104  this.Close();
105  }
106  }
107  }
108 
109 
110  private void textBox_Password_KeyDown(object sender, KeyEventArgs e)
111  {
112  if (e.KeyCode == Keys.Enter)
113  {
114  button_SignIn_Click(null, null);
115  }
116 
117  }
118 
119  private void button_SignUp_Click(object sender, EventArgs e)
120  {
121  GlobalConfig.AccountName = textBox_EmailAddress.Text;
123 
124  button_SignUp.Enabled = false;
125 
126  try
127  {
128  if (string.IsNullOrEmpty(textBox_EmailAddress.Text))
129  {
130  MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
131  MessageBox.Show("The account name can't be empty.", "account", MessageBoxButtons.OK, MessageBoxIcon.Error);
132 
133  return;
134 
135  }
136 
137  accountName = textBox_EmailAddress.Text.ToLower().Trim();
138  if (string.Compare(accountName, "guest") == 0)
139  {
140  MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
141  MessageBox.Show("The guest account name can't be signed up to the server.", "account", MessageBoxButtons.OK, MessageBoxIcon.Error);
142 
143  return;
144  }
145 
146  string lastError = string.Empty;
147 
148  //sign up the account in remote server.
149  bool retVal = true;// SignUpAccount(accountName, ref lastError);
150  MessageBoxIcon icon = MessageBoxIcon.Information;
151  if (!retVal)
152  {
153  icon = MessageBoxIcon.Error;
154  }
155 
156  MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
157  MessageBox.Show(lastError, "SignUp", MessageBoxButtons.OK, icon);
158 
159  return;
160  }
161  catch (Exception ex)
162  {
163  MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
164  MessageBox.Show("Sign up account failed with error" + ex.Message, "SignUp", MessageBoxButtons.OK, MessageBoxIcon.Error);
165  }
166  finally
167  {
168  button_SignUp.Enabled = true;
169  this.Close();
170  }
171  }
172 
173 
174  }
175 }
static bool isAuthorized
Definition: AccountForm.cs:28
static string accountName
Definition: AccountForm.cs:26
static string password
Definition: AccountForm.cs:27

Social Network


Services Overview

Architect, implement and test file system filter drivers for a wide range of functionality. We can offer several levels of assistance to meet your specific.

Contact Us

You are welcome to contact us for salse or partnership.

Sales: sales@easefilter.com
Support: support@easefilter.com
Info: info@easefilter.com