void proxy_GetSuppliersListItemsCompleted(object sender, GetListItemsCompletedEventArgs e) { XNamespace rowsetNamespace = "#RowsetSchema"; var query = from x in e.Result.Descendants() where x.Name == rowsetNamespace + "row" select x.Attribute("ows_SupplierLookup").Value; foreach (var supplierLookupValue in query) { Suppliers.Add(supplierLookupValue); } XElement rsData = e.Result.Descendants().First <XElement>(f => f.Name.LocalName == "data"); NumberOfSuppliersFound = rsData.Attributes("ItemCount").First().Value; }
private void ProxyGetListItemsCompleted(object sender, GetListItemsCompletedEventArgs e) { var tcs = (TaskCompletionSource <XmlNode>)e.UserState; if (e.Cancelled) { tcs.TrySetCanceled(); } else if (e.Error != null) { tcs.TrySetException(e.Error); } else { tcs.TrySetResult(e.Result); } }
void proxy_GetPartsListItemsCompleted(object sender, GetListItemsCompletedEventArgs e) { XNamespace rowsetNamespace = "#RowsetSchema"; var query = from x in e.Result.Descendants() where x.Name == rowsetNamespace + "row" select x.Attribute("ows_Title").Value; foreach (string partTitle in query) { Parts.Add(new Part { Title = partTitle }); } XElement rsData = e.Result.Descendants().First <XElement>(f => f.Name.LocalName == "data"); NumberOfPartsFound = rsData.Attributes("ItemCount").First().Value; }
void svc_GetListItemsCompleted(object sender, GetListItemsCompletedEventArgs e) { //TODO svc_GetListItemsCompleted code here IEnumerable <XElement> rows = e.Result.Descendants (XName.Get("row", "#RowsetSchema")); var myLinks = from element in rows select new Link( (int)element.Attribute("ows_ID"), (string)element.Attribute("ows_URL") ); Deployment.Current.Dispatcher.BeginInvoke(() => { if (MyLinks == null) { MyLinks = new ObservableCollection <Link>(); } MyLinks.Clear(); myLinks.ToList().ForEach(a => MyLinks.Add(a)); }); }
void ListsService_GetListItemsCompleted(object sender, GetListItemsCompletedEventArgs e) { var tasks = new List<Task>(); XNamespace ns = "#RowsetSchema"; IEnumerable<XElement> rows = e.Result.Descendants(ns + "row"); string currentId1 = _currentUpdateCheck[_currentIndex].Data[ID1].ToString(); // Get all the rows for that tasks that have an ID foreach (XElement row in rows) { var task = new Task { ID = GetXElementAtt(row, "ID"), ID1 = GetXElementAtt(row, ID1), RegionalOffset = Convert.ToInt32(GetXElementAtt(row, "RegionalOffset") == "" ? "0" : GetXElementAtt(row, "RegionalOffset")), Created = Constants.CreateUTCDateTime(GetXElementAtt(row, "Created")), Status = GetXElementAtt(row, "Status"), Checklist = GetXElementAtt(row, "Checklist") }; tasks.Add(task); } // Work out which one(s) were created today, using the same algorithm as the dashboard uses var todayTasks = tasks.Where(t => t.Created > _currentDateAnchor.Date.AddMinutes(t.RegionalOffset)); List<Task> foundTasks = todayTasks.ToList(); _mainPage.AddToLog(string.Format("{0}: {1} tasks found in the live system. {2} tasks for today", currentId1, tasks.Count(), foundTasks.Count())); var updateRow = new RowHandler(); AddUpdateValue(updateRow, "Title"); AddUpdateValue(updateRow, ID1); AddUpdateValue(updateRow, "High_x0020_Level_x0020_Descripti"); AddUpdateValue(updateRow, "Asset_x0020_Category"); AddUpdateValue(updateRow, "Business_x0020_Area"); AddUpdateValue(updateRow, "Due_x0020_Time"); AddUpdateValue(updateRow, "Alert_x0020_Time"); AddUpdateValue(updateRow, "Escalation_x0020_Level_x0020_1_x"); AddUpdateValue(updateRow, "Key_x0020_Control"); AddUpdateValue(updateRow, "KPI"); AddUpdateValue(updateRow, "Matrix_x0020_Definition"); AddUpdateValue(updateRow, "Locations"); AddUpdateValue(updateRow, "Assign_x0020_to"); AddUpdateValue(updateRow, "Manager"); AddUpdateValue(updateRow, "Link_x0020_to_x0020_Process"); AddUpdateValue(updateRow, "Managing_x0020_Director"); AddUpdateValue(updateRow, "Director"); AddUpdateValue(updateRow, "Asset_x0020_Sub_x0020_Category"); AddUpdateValue(updateRow, "BypassManagerApproval"); AddUpdateValue(updateRow, "ManagerSelfApproval"); updateRow.rowUpdate.UpdateValues.Add("Checklist", _mainPage.CurrentList.ListName); if (!foundTasks.Any()) { updateRow.Data.Add("ID", 0); // If its being created, also add the following fields AddUpdateValue(updateRow, "Functional"); AddUpdateValue(updateRow, "Frequency"); AddUpdateValue(updateRow, "Specific_x0020_Frequency"); AddUpdateValue(updateRow, "RandomFrequency"); AddUpdateValue(updateRow, "Comments"); AddUpdateValue(updateRow, "Holiday_x0020_Calendar"); _mainPage.AddToLog(currentId1 + " not found in live system. Set to 'Add'"); updateRow.rowUpdate.UpdateType = RowUpdate.UpdateTypes.New; _addCount++; } else if(foundTasks.Count() == 1) { if(foundTasks[0].Status == "Outstanding") { _mainPage.AddToLog(currentId1 + " found in live system and 'Outstanding'. Set to 'Update'"); updateRow.Data.Add("ID", foundTasks[0].ID); updateRow.rowUpdate.UpdateType = RowUpdate.UpdateTypes.Update; _updateCount++; } else { _mainPage.AddToLog(currentId1 + " found in live system but no longer 'Outstanding'. Will not be updated."); updateRow = null; _notOutstandingCount++; } } else { string dupChecklists = ""; foreach (Task foundTask in foundTasks) { if(dupChecklists != "") dupChecklists += ","; dupChecklists += foundTask.Checklist; } _mainPage.AddToLog(currentId1 + " found more than once for the following checklists: " + dupChecklists + ". These tasks will not be updated."); updateRow = null; _duplicateCount++; } if(updateRow != null) _currentUpdateData.Add(_currentIndex, updateRow); // Locate and process the next update _currentIndex++; if (_currentIndex < _currentUpdateCheck.Count) RetrieveNextUpdate(); else { string message = "You are about to perform the following on the live system:\n\n"; bool confirmMessage = true; if (_addCount == 0 && _updateCount == 0) { confirmMessage = false; message += "Nothing will be updated in the live system.\n"; } else { if (_addCount > 0) message += string.Format("Add {0} tasks.\n", _addCount); if (_updateCount > 0) message += string.Format("Update {0} tasks.\n", _updateCount); } message += "\n"; if (_notOutstandingCount > 0) message += _notOutstandingCount + " tasks will not be updated because they have already been completed.\n"; if (_duplicateCount > 0) message += _duplicateCount + " tasks will not be updated because duplicate ID1's have been found. See the log for more details.\n"; if (confirmMessage) message += "\nDo you want to continue?"; if (_updateCount > 0) message += "\n\nPlease note, for the update tasks, the following live fields will not be changed:\nFunctional, Freq, Spec Freq, Rand Freq, Comments, Holiday Calendar.\n"; _mainPage.AddToLog("User confirmation required:\n************************************\n" + message + "\n****************************************"); _mainPage.StatusHide(); if (confirmMessage) MessageDialog.ShowConfirmation(message, LiveUpdateConfirmation, null, false); else { MessageDialog.ShowMessage(message); Clear(); } } }
void svc_GetListItemsCompleted(object sender, GetListItemsCompletedEventArgs e) { //TODO svc_GetListItemsCompleted code here }
void Service_GetListItemsCompleted(object sender, GetListItemsCompletedEventArgs e) { if (e.Error != null) { _excelParams.AddToLog("Error retrieving list items:\n" + e.Error.Message); MessageBox.Show(Constants.ErrorMsg); } else ProcessListItems(e.Result, e.UserState); }
void ServiceParent_GetListItemCompleted(object sender, GetListItemsCompletedEventArgs e) { Dictionary<string, object> state = (Dictionary<string, object>)e.UserState; if (state["Source"].ToString() == Constants.Delete) { if (e.Error == null && GetErrorText(e.Result).Length == 0) { string rowId = GetAttributeValue(e.Result, "ID"); if (!string.IsNullOrEmpty(rowId)) UpdateListItem(state, state["ConfigList"].ToString(), rowId, RowUpdate.UpdateTypes.Delete, null); else { SPList list = (SPList)state["List"]; _service.DeleteListAsync(list.Id); } } else DeleteComplete(sender, e); } else if (state["Source"].ToString() == Constants.Update) { if (e.Error == null && GetErrorText(e.Result).Length == 0) { string rowId = GetAttributeValue(e.Result, "ID"); SPList list = (SPList)state["List"]; if (!string.IsNullOrEmpty(rowId)) { Dictionary<string, object> values = new Dictionary<string, object>(); values.Add("Title", list.Title); values.Add("bcheck_x0020_list_x0020_template", list.Title); UpdateListItem(state, state["ConfigList"].ToString(), rowId, RowUpdate.UpdateTypes.Update, values); } else UpdateList(list); } else UpdateListComplete(sender, e); } }