private void HostControl_Loaded(object sender, RoutedEventArgs e) { if (SyncTask == null) { SyncTask = SyncTask.NewSyncTask(); } else { SourceQueryGeneratorControl.Initialize(SyncTask.SourceQueryResultMapping); DestinationSiteSetting = SyncTask.DestinationSiteSetting; QueryResult sourceQueryResult = SyncTask.SourceQueryResultMapping.Mappings[0].QueryResult; //SourceSiteSetting = sourceQueryResult.SiteSetting; DestinationFolder = ApplicationContext.Current.GetFolder(SyncTask.DestinationSiteSetting, new BasicFolderDefinition() { FolderUrl = DestinationSiteSetting.Url + "/" + SyncTask.DestinationFolderPath, SiteSettingID = DestinationSiteSetting.ID, Title = SyncTask.DestinationListName }); DestinationSelectButton.Content = DestinationFolder.GetPath(); PopulateDestinationDetails(); SkipUpdateEventsCheckBox.IsChecked = SyncTask.ShouldSkipUpdates; if (SyncTask.ScheduleInterval == 0) { RunOnceRadioButtonNo.IsChecked = false; RunOnceRadioButtonYes.IsChecked = true; FrequencyTextBox.Text = "0"; } else { RunOnceRadioButtonNo.IsChecked = true; RunOnceRadioButtonYes.IsChecked = false; FrequencyTextBox.Text = SyncTask.ScheduleIntervalAsMinute.ToString(); } /* * SourceFolder = ApplicationContext.Current.GetFolder(SourceSiteSetting, new BasicFolderDefinition() * { * FolderUrl = SourceSiteSetting.Url + "/" + sourceQueryResult.ListName, * SiteSettingID = SourceSiteSetting.ID, * Title = SyncTask.DestinationListName * }); * * SourceSelectButton.Content = SourceFolder.GetPath(); * DestinationSelectButton.Content = DestinationFolder.GetPath(); */ } }
private void GenerateExcelImportTask() { ISiteSetting siteSetting = ApplicationContext.Current.GetSiteSetting(_MainObject.SiteSettingID); List <string> excelHeaders = new List <string>(); List <string> sharePointFieldNames = new List <string>(); Dictionary <string, string> fieldMappings = new Dictionary <string, string>(); foreach (UIElement element in DynamicGrid.Children) { if (element is ComboBox) { string excelHeader = ((ComboBox)element).Tag.ToString(); string sharePointFieldName = ((ComboBoxItem)((ComboBox)element).SelectedItem).Tag.ToString(); if (string.IsNullOrEmpty(sharePointFieldName) == true) { continue; } excelHeaders.Add(excelHeader); sharePointFieldNames.Add(sharePointFieldName); fieldMappings.Add(excelHeader, sharePointFieldName); } } excelHeaders.Insert(0, "ID"); sharePointFieldNames.Insert(0, "SourceItemID"); //List<SyncTask> syncTasks = new List<SyncTask>(); SyncTask syncTask = SyncTask.NewSyncTask(); syncTask.ID = Guid.NewGuid(); syncTask.ScheduleInterval = 240; string folderPath = ConfigurationManager.GetInstance().GetSyncTaskFolder(syncTask); System.IO.File.Copy(_SelectedFileFullPath, folderPath + "\\ProcessedExport.xlsx"); QueryResult test1QueryResult = new QueryResult(); test1QueryResult.Fields = excelHeaders.ToArray(); test1QueryResult.ListName = "Test1"; test1QueryResult.Name = "Test1"; test1QueryResult.SiteSetting = null; test1QueryResult.Filters = new CamlFilters(); /* * test1QueryResult.ReferenceFields.Add(new QueryResultReferenceField() * { * SiteSetting = GetTestSiteSetting(), * ReferenceFilterFieldName = "FilterValue", * ReferenceListName = "TestLookup", * ReferenceValueFieldName = "DataValue", * SourceFieldName = "RefField", * OutputName = "RefField1" * }); */ QueryResultMapping test1QueryResultMapping = new QueryResultMapping(); test1QueryResultMapping.QueryResult = test1QueryResult; List <QueryResultMappingSelectField> queryResultMappingSelectFields = new List <QueryResultMappingSelectField>(); foreach (string excelHeader in excelHeaders) { queryResultMappingSelectFields.Add(new QueryResultMappingSelectField(excelHeader, excelHeader)); } test1QueryResultMapping.SelectFields = queryResultMappingSelectFields.ToArray(); syncTask.SourceQueryResultMapping.Mappings.Add(test1QueryResultMapping); syncTask.DestinationListName = _MainObject.GetListName(); syncTask.DestinationRootFolderPath = _MainObject.GetListName(); syncTask.Name = _MainObject.GetListName(); syncTask.SourceUniqueFieldHeaderNames = new string[] { "ID" }; syncTask.DestinationUniqueFieldNames = new string[] { "SourceItemID" }; syncTask.DestinationIDFieldHeaderName = "ID"; syncTask.SourceFieldHeaderMappings = excelHeaders.ToArray(); //syncTask.DestinationFieldMappings = sharePointFieldNames.ToArray(); syncTask.IsDestinationDocumentLibrary = false; syncTask.DestinationTermStoreName = "Taxonomy_BrjLUNqY3/3gqp8FAbbKiQ=="; syncTask.DestinationSiteSetting = (SiteSetting)siteSetting; //syncTasks.Add(syncTask); //SyncTasksManager.GetInstance().SyncTasks.Clear(); //SyncTasksManager.GetInstance().SyncTasks.Add(syncTask); //SyncTasksManager.GetInstance().SaveSyncTasks(); SyncBackgroundWorker.RunWorkerAsync(new object[] { syncTask }); }