Exemple #1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                var props = Properties.Settings.Default;
                _connector = new ExchangeConnector.ExchangeConnector(props.email);

                string currentSite = props.currentSite;
                _locations = new LocationResolver();
                _locations.Load("locationMap.csv");
                _connector.LocationFilter = _locations.OfSite(currentSite).ToArray();                 // filter locations by site
                _connector.Connect();

                _myLocation = new Location
                {
                    Site     = props.currentSite,
                    Building = props.currentBuilding,
                    Floor    = props.currentFloor
                };
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Application.Exit();
            }
        }
Exemple #2
0
        public string Login(string username, string password, string email, string site, string serviceUrl)
        {
            Debug.WriteLine($"Request on thread {Thread.CurrentThread.ManagedThreadId}");
            if (string.IsNullOrEmpty(username))
            {
                throw new WebFaultException <string>($"{nameof(username)} is a mandatory parameter", HttpStatusCode.BadRequest);
            }
            if (string.IsNullOrEmpty(password))
            {
                throw new WebFaultException <string>($"{nameof(password)} is a mandatory parameter", HttpStatusCode.BadRequest);
            }
            if (string.IsNullOrEmpty(email))
            {
                throw new WebFaultException <string>($"{nameof(email)} is a mandatory parameter", HttpStatusCode.BadRequest);
            }
            if (string.IsNullOrEmpty(site))
            {
                throw new WebFaultException <string>($"{nameof(site)} is a mandatory parameter", HttpStatusCode.BadRequest);
            }

            try
            {
                var connector = new ExchangeConnector(username, password, serviceUrl, email);
                connector.LocationFilter = LocationResolver.OfSite(site).ToArray();                 // filter locations by site
                connector.Connect();
                string ticket = Guid.NewGuid().ToString("N");
                if (!SessionManager.TryAdd(ticket, connector))
                {
                    throw new WebFaultException <string>("GUID conflict", HttpStatusCode.InternalServerError);
                }
                return(ticket);
            }
            catch (Exception ex)
            {
                throw new WebFaultException <string>(ex.Message, HttpStatusCode.Unauthorized);
            }
        }