Ejemplo n.º 1
0
        public void GetListData(SPList list)
        {
            _currentList = list;
            _dataReady = false;
            _schemaReady = false;
            _isListDataRetrieved = false;

            ExcelColumns = new Dictionary<string, ExcelColumn>();

            Rows = new List<Dictionary<string, object>>();

            InitilizeColumns();

            ChecklistAdminServiceAgent checklistagent = new ChecklistAdminServiceAgent();
            checklistagent.GetChecklistTaskDefinitions("5", items =>
            {
                taskDefinitions = items;
                items.ForEach(item =>
                {
                    Dictionary<string, object> row = new Dictionary<string, object>();

                    foreach (string key in ExcelColumns.Keys)
                    {
                        var property = item.GetType().GetProperty(key);
                        if (property != null)
                        {
                            String PropertyColumnType = ((ColumnTypeAttribute)Attribute.GetCustomAttribute(property, typeof(ColumnTypeAttribute))).ColumnType.ToString();
                            var value = item.GetType().GetProperty(key).GetValue(item, null);
                            if (PropertyColumnType == "Choice" && value != null)
                            {
                                String choiceGroup = ((ColumnTypeAttribute)Attribute.GetCustomAttribute(property, typeof(ColumnTypeAttribute))).ChoiceGroupName.ToString();
                                row.Add(ExcelColumns[key].PropertyBind, StaticData[choiceGroup][int.Parse(value.ToString())]);
                            }
                            else
                            {
                                row.Add(ExcelColumns[key].PropertyBind, value);
                            }
                        }
                    }
                    Rows.Add(row);
                });

                ListDataRetrieved(this, new EventArgs());

            });


             }
Ejemplo n.º 2
0
        public void BatchUpdate(Dictionary<int, RowHandler> updates, SPList list)
        {
            List<bCheckV2.Helpers.Definitions.TaskItem> tasks = new List<bCheckV2.Helpers.Definitions.TaskItem>();
 
            updates.ToList().ForEach(row => {
                var rowData = row.Value.Data;
                bCheckV2.Helpers.Definitions.TaskItem task = new bCheckV2.Helpers.Definitions.TaskItem();

                task.ID1 = rowData["ID1"].ToString();
                task.AlertTime = rowData["AlertTime"].ToString();
                task.DueTime = rowData["DueTime"].ToString();
                task.EscalationLevel1Time = rowData["EscalationLevel1Time"].ToString();
                task.AssetCategoryID = (DataHandler.Current.StaticData["AssetCategories"]).Where(ac => ac.Value == rowData["AssetCategoryID"].ToString()).First().Key;
                task.BusinessAreaID = (DataHandler.Current.StaticData["BusinessAreas"]).Where(ba => ba.Value == rowData["BusinessAreaID"].ToString()).First().Key;
                task.Comments = (String)rowData["Comments"];
                task.Description = (String)rowData["Description"];
                task.FrequencyID = (DataHandler.Current.StaticData["Frequencies"]).Where(freq => freq.Value == rowData["FrequencyID"].ToString()).First().Key;
                task.FunctionalID = (DataHandler.Current.StaticData["Functionals"]).Where(func => func.Value == rowData["FunctionalID"].ToString()).First().Key;
                task.HolidayCalendar = Boolean.Parse(rowData["HolidayCalendar"].ToString());
                task.KeyControl = Boolean.Parse(rowData["KeyControl"].ToString());
                task.LinkToProcess = rowData["LinkToProcess"] == null ? null : rowData["LinkToProcess"].ToString();
                task.LocationID = (DataHandler.Current.StaticData["Locations"]).Where(ac => ac.Value == rowData["LocationID"].ToString()).First().Key;
                task.ManagerSelfApproval = Boolean.Parse(rowData["ManagerSelfApproval"].ToString());
                task.BypassManagerApproval = Boolean.Parse(rowData["BypassManagerApproval"].ToString());
                task.RandomFrequencyID = (DataHandler.Current.StaticData["RandomFrequencies"]).Where(ac => ac.Value == rowData["RandomFrequencyID"].ToString()).First().Key;
                task.SpecificFrequencyID = (DataHandler.Current.StaticData["SpecificFrequencies"]).Where(ac => ac.Value == rowData["SpecificFrequencyID"].ToString()).First().Key;
                task.TaskName = rowData["TaskName"].ToString();
                task.MandatoryLink = Boolean.Parse(rowData["MandatoryLink"].ToString());
                task.Assignees = (List<bCheckV2.Helpers.Definitions.User>)rowData["Assignees"];
                task.Managers = (List<bCheckV2.Helpers.Definitions.User>)rowData["Managers"];
                tasks.Add(task);
            });

            ChecklistAdminAgent = new ChecklistAdminServiceAgent();
            ChecklistAdminAgent.UpdateTaskDefintions(tasks, reply => { });
            //XElement batchNode = BuildBatchStringWebService(list, updates);
            //_service.UpdateListItemsAsync(list.ListName, batchNode);
        }