public HomeViewModel() { StartCommand = new Command(Start); StatusList = new ObservableCollection <Status>(); m_folders = new List <IFolder>(); var appCmd = new SitecoreInterface(); m_folders = appCmd.SitecoreItems(); CacheRefresherWarmup(); }
async public void Start(object Obj) { _startBtn = false; NotifyPropertyChanged("StartBtn"); canStartExecute(); var sitecoreItemsList = new List <string>(); if (SelectedNode != null) { sitecoreItemsList.Add(SelectedNode.ContentPath); } if (SelectedProgram != null) { var appCmd = new SitecoreInterface(); sitecoreItemsList.AddRange(appCmd.LanguageItems(SelectedProgram, IncludeDestinations, IncludeCourses)); } StatusList.Clear(); foreach (var item in sitecoreItemsList) { var url = "http://" + SelectedMarket.localDomain + "/" + item + "/"; var noCacheUrl = "http://" + SelectedMarket.localDomain + "/" + item + "/?staticignore=true"; var request = WebRequest.Create(url); ((HttpWebRequest)request).UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36"; var secondRequest = WebRequest.Create(noCacheUrl); ((HttpWebRequest)secondRequest).UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36"; if (GenerateScreenshot) { var itemName = item.Replace('/', '.'); GenerateBitmapMobile(noCacheUrl, itemName); GenerateBitmapDesktop(noCacheUrl, itemName); } try { var response = await request.GetResponseAsync(); var status = ((HttpWebResponse)response).StatusCode; response.Close(); var noCacheResponse = await secondRequest.GetResponseAsync(); var staticIgnoreStatus = ((HttpWebResponse)noCacheResponse).StatusCode; noCacheResponse.Close(); var result = new Status(); result.Url = url; result.StatusInt = (int)status; result.StaticIgnoreStatus = (int)staticIgnoreStatus; StatusList.Add(result); } catch (WebException ex) { var status = ((HttpWebResponse)ex.Response).StatusCode; } catch (Exception ex) { } } _startBtn = true; NotifyPropertyChanged("StartBtn"); canStartExecute(); }