/// <summary> /// Creates list of offices and shows it. /// </summary> private void FillOfficesList() { try { Office[] offices = Office.GetOffices(); if (offices == null) return; // Create object for work with proxy. WebProxy proxy = null; if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["ProxyURL"])) { proxy = new WebProxy(ConfigurationManager.AppSettings["ProxyURL"]); string proxyDomain = ConfigurationManager.AppSettings["ProxyUserDomain"]; string proxyUser = ConfigurationManager.AppSettings["ProxyUserLogin"]; string proxyPassword = ConfigurationManager.AppSettings["ProxyUserPassword"]; if (!string.IsNullOrEmpty(proxyUser)) { NetworkCredential netCred = new NetworkCredential(); netCred.UserName = proxyUser; if (!string.IsNullOrEmpty(proxyDomain)) netCred.Domain = proxyDomain; if (!string.IsNullOrEmpty(proxyPassword)) netCred.Password = proxyPassword; proxy.Credentials = netCred; } } List<OfficeDescription> coll = new List<OfficeDescription>(); foreach (Office office in Office.GetOffices()) { //if (!string.IsNullOrEmpty(office.StatusesServiceURL)) { try { OfficeDescription officeDescr = new OfficeDescription(); if (!string.IsNullOrEmpty(office.StatusesServiceURL)) { UsersStatusesService service = new UsersStatusesService(office.StatusesServiceURL); if (proxy != null) { service.Proxy = proxy; } service.Timeout = 180000; officeDescr.OfficeName = service.GetOfficeName(); } if (string.IsNullOrEmpty(officeDescr.OfficeName)) officeDescr.OfficeName = office.OfficeName; officeDescr.OfficeID = office.ID.Value; officeDescr.ServiceURL = office.StatusesServiceURL; officeDescr.ServiceUserName = office.StatusesServiceUserName; officeDescr.ServicePassword = office.StatusesServicePassword; officeDescr.SelectedDate = Calendar.SelectedDate; coll.Add(officeDescr); } catch (Exception ex) { Logger.Log.Error(ex.Message, ex); } } } repOffices.DataSource = coll; repOffices.DataBind(); } catch (Exception ex) { Logger.Log.Error(ex.Message, ex); } }
/// <summary> /// Creates list of offices and shows it. /// </summary> private void FillOfficesList() { try { Office[] offices = Office.GetOffices(); if (offices == null) return; //// Create object for work with proxy. //WebProxy proxy = null; //if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["ProxyURL"])) //{ // proxy = new WebProxy(ConfigurationManager.AppSettings["ProxyURL"]); // string proxyDomain = ConfigurationManager.AppSettings["ProxyUserDomain"]; // string proxyUser = ConfigurationManager.AppSettings["ProxyUserLogin"]; // string proxyPassword = ConfigurationManager.AppSettings["ProxyUserPassword"]; // if (!string.IsNullOrEmpty(proxyUser)) // { // NetworkCredential netCred = new NetworkCredential(); // netCred.UserName = proxyUser; // if (!string.IsNullOrEmpty(proxyDomain)) // netCred.Domain = proxyDomain; // if (!string.IsNullOrEmpty(proxyPassword)) // netCred.Password = proxyPassword; // proxy.Credentials = netCred; // } //} List<OfficeDescription> coll = new List<OfficeDescription>(); foreach (Office office in offices) { OfficeDescription officeDescr = new OfficeDescription(); try { if (!String.IsNullOrEmpty(office.StatusesServiceURL)) { PortalServiceProxy wcfClient = new PortalServiceProxy( office.StatusesServiceURL, office.StatusesServiceUserName, office.StatusesServicePassword); officeDescr.OfficeName = wcfClient.GetOfficeName(); wcfClient.Close(); } } catch (Exception ex) { Logger.Log.Error(ex.Message, ex); } if (String.IsNullOrEmpty(officeDescr.OfficeName)) officeDescr.OfficeName = office.OfficeName; officeDescr.ServiceURL = office.StatusesServiceURL; officeDescr.ServiceUserName = office.StatusesServiceUserName; officeDescr.ServicePassword = office.StatusesServicePassword; officeDescr.MeteoInformer = office.MeteoInformer; officeDescr.ClockInformer = office.ClockInformer; officeDescr.DigitalClockInformer = office.DigitalClockInformer; coll.Add(officeDescr); } repOffices.DataSource = coll; repOffices.DataBind(); } catch (Exception ex) { Logger.Log.Error(ex.Message, ex); } }