Exemplo n.º 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();
            }
        }
Exemplo n.º 2
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();
			}
		}
Exemplo n.º 3
0
		private static void Dowork()
		{
			var props = Properties.Settings.Default;
			var connector = new ExchangeConnector(props.username, props.password, props.serverUrl, props.serviceEmail);

			connector.Connect();
			
			var roomLists = ParseRooms(connector.GetAllRoomLists()).ToArray();
			DumpToCsv(roomLists);
			DumpToJson(roomLists);
		}
Exemplo n.º 4
0
		public static bool TryGetValue(string ticket, out ExchangeConnector connector)
		{
			Session tmp;
			if (AllSessions.TryGetValue(ticket, out tmp))
			{
				tmp.Touch();
				connector = tmp.Connector;
				return true;
			}
			connector = null;
			return false;
		}
Exemplo n.º 5
0
		public static bool TryAdd(string ticket, ExchangeConnector connector)
		{
			ServiceHost.Log?.AddMessage($"New session created ({ticket.Substring(0, 5)}...)");
			return AllSessions.TryAdd(ticket, new Session(connector, SessionTimeout));
		}
Exemplo n.º 6
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);
			}
		}
Exemplo n.º 7
0
		public Session(ExchangeConnector connector, TimeSpan timeout)
		{
			Connector = connector;
			_timeout = timeout;
			ExpirationDate = DateTime.Now + timeout;
		}