Example #1
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);
        }
Example #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);
            }
        }