コード例 #1
0
        /// <summary>
        /// Lodas the column data into the dts objects from the datasource for columns
        /// </summary>
        private void LoadDataSourceInformation(IDTSOutput output, Dictionary <string, string> existingColumnData)
        {
            object sharepointUrl      = ComponentMetaData.CustomPropertyCollection[C_SHAREPOINTSITEURL].Value;
            object sharepointListName = ComponentMetaData.CustomPropertyCollection[C_SHAREPOINTLISTNAME].Value;

            // Reset the values
            if ((sharepointUrl != null) && (sharepointListName != null))
            {
                CreateExternalMetaDataColumns(output,
                                              (string)ComponentMetaData.CustomPropertyCollection[C_SHAREPOINTSITEURL].Value,
                                              (string)ComponentMetaData.CustomPropertyCollection[C_SHAREPOINTLISTNAME].Value,
                                              (string)ComponentMetaData.CustomPropertyCollection[C_SHAREPOINTLISTVIEWNAME].Value,
                                              existingColumnData);
            }
        }
コード例 #2
0
        /// <summary>
        /// Connects to SharePoint and gets any columns on the target
        /// </summary>
        /// <param name="output"></param>
        /// <param name="p"></param>
        private void CreateExternalMetaDataColumns(
            IDTSOutput output, string sharepointUrl, string listName, string viewName,
            Dictionary<string, string> existingColumnData)
        {
            // No need to load if the Url is bad.
            if ((sharepointUrl == null) || (sharepointUrl.Length == 0))
                return;

            // Need a list to continue
            if ((listName == null) || (listName.Length == 0))
                return;

            // If the list has changed, then we do not want any of the exisiting column data to
            // influence it (provides a way to actually reset the names if needed)
            if (output.Description != listName)
            {
                existingColumnData.Clear();
                output.Description = listName;
            }

            try
            {
                List<SharePointUtility.DataObject.ColumnData> accessibleColumns =
                    GetAccessibleSharePointColumns(sharepointUrl, listName, viewName);

                foreach (var column in accessibleColumns)
                {
                    // Setup the primary column details from the List
                    IDTSExternalMetadataColumn dtsColumnMeta = output.ExternalMetadataColumnCollection.New();
                    if (existingColumnData.ContainsKey(column.Name))
                        dtsColumnMeta.Name = existingColumnData[column.Name];
                    else
                        dtsColumnMeta.Name = column.FriendlyName;
                    dtsColumnMeta.Description = column.DisplayName;
                    dtsColumnMeta.Length = 0;
                    dtsColumnMeta.Precision = 0;
                    dtsColumnMeta.Scale = 0;
                    if ("Boolean|AllDayEvent|Attachments|CrossProjectLink|Recurrence".Contains(column.SharePointType))
                    {
                        dtsColumnMeta.DataType = DataType.DT_BOOL;
                    }
                    else if (column.SharePointType == "DateTime")
                    {
                        dtsColumnMeta.DataType = DataType.DT_DBTIMESTAMP;
                    }
                    else if ("Number|Currency".Contains(column.SharePointType))
                    {
                        // Max = 100,000,000,000.00000
                        dtsColumnMeta.DataType = DataType.DT_R8;
                    }
                    else if ("Counter|Integer".Contains(column.SharePointType))
                    {
                        dtsColumnMeta.DataType = DataType.DT_I4;
                    }
                    else if ("Guid".Contains(column.SharePointType))
                    {
                        dtsColumnMeta.DataType = DataType.DT_GUID;
                    }
                    else
                    {
                        if (column.MaxLength == -1)
                        {
                            dtsColumnMeta.DataType = DataType.DT_NTEXT;
                            dtsColumnMeta.Length = 0;
                        }
                        else
                        {
                            dtsColumnMeta.DataType = DataType.DT_WSTR;
                            dtsColumnMeta.Length = column.MaxLength;
                        }
                    }

                    IDTSCustomProperty fieldNameMeta = dtsColumnMeta.CustomPropertyCollection.New();
                    fieldNameMeta.Name = "Id";
                    fieldNameMeta.Description = "SharePoint ID";
                    fieldNameMeta.Value = column.Name;

                    // Create default output columns for all of the fields returned and link to the original columns
                    IDTSOutputColumn dtsColumn = output.OutputColumnCollection.New();
                    dtsColumn.Name = dtsColumnMeta.Name;
                    dtsColumn.Description = dtsColumnMeta.Description;
                    dtsColumn.ExternalMetadataColumnID = dtsColumnMeta.ID;

                    IDTSCustomProperty fieldName = dtsColumn.CustomPropertyCollection.New();
                    fieldName.Name = fieldNameMeta.Name;
                    fieldName.Description = fieldNameMeta.Description;
                    fieldName.Value = fieldNameMeta.Value;

                    dtsColumn.SetDataTypeProperties(
                        dtsColumnMeta.DataType, dtsColumnMeta.Length, dtsColumnMeta.Precision, dtsColumnMeta.Scale, 0);
                }
            }
            catch (ApplicationException)
            {
                // Exception happened, so clear the columns, which will invalidate this object.
                output.ExternalMetadataColumnCollection.RemoveAll();
            }

        }
コード例 #3
0
        /// <summary>
        /// Lodas the column data into the dts objects from the datasource for columns
        /// </summary>
        private void LoadDataSourceInformation(IDTSOutput output, Dictionary<string, string> existingColumnData)
        {
            object sharepointUrl = ComponentMetaData.CustomPropertyCollection[C_SHAREPOINTSITEURL].Value;
            object sharepointListName = ComponentMetaData.CustomPropertyCollection[C_SHAREPOINTLISTNAME].Value;

            // Reset the values
            if ((sharepointUrl != null) && (sharepointListName != null))
            {
                CreateExternalMetaDataColumns(output,
                    (string)ComponentMetaData.CustomPropertyCollection[C_SHAREPOINTSITEURL].Value,
                    (string)ComponentMetaData.CustomPropertyCollection[C_SHAREPOINTLISTNAME].Value,
                    (string)ComponentMetaData.CustomPropertyCollection[C_SHAREPOINTLISTVIEWNAME].Value,
                    existingColumnData);
            }
        }
コード例 #4
0
        /// <summary>
        /// Connects to SharePoint and gets any columns on the target
        /// </summary>
        /// <param name="output"></param>
        /// <param name="p"></param>
        private void CreateExternalMetaDataColumns(
            IDTSOutput output, string sharepointUrl, string listName, string viewName,
            Dictionary <string, string> existingColumnData)
        {
            // No need to load if the Url is bad.
            if ((sharepointUrl == null) || (sharepointUrl.Length == 0))
            {
                return;
            }

            // Need a list to continue
            if ((listName == null) || (listName.Length == 0))
            {
                return;
            }

            // If the list has changed, then we do not want any of the exisiting column data to
            // influence it (provides a way to actually reset the names if needed)
            if (output.Description != listName)
            {
                existingColumnData.Clear();
                output.Description = listName;
            }

            try
            {
                List <SharePointUtility.DataObject.ColumnData> accessibleColumns =
                    GetAccessibleSharePointColumns(sharepointUrl, listName, viewName);

                foreach (var column in accessibleColumns)
                {
                    // Setup the primary column details from the List
                    IDTSExternalMetadataColumn dtsColumnMeta = output.ExternalMetadataColumnCollection.New();
                    if (existingColumnData.ContainsKey(column.Name))
                    {
                        dtsColumnMeta.Name = existingColumnData[column.Name];
                    }
                    else
                    {
                        dtsColumnMeta.Name = column.FriendlyName;
                    }
                    dtsColumnMeta.Description = column.DisplayName;
                    dtsColumnMeta.Length      = 0;
                    dtsColumnMeta.Precision   = 0;
                    dtsColumnMeta.Scale       = 0;
                    if ("Boolean|AllDayEvent|Attachments|CrossProjectLink|Recurrence".Contains(column.SharePointType))
                    {
                        dtsColumnMeta.DataType = DataType.DT_BOOL;
                    }
                    else if (column.SharePointType == "DateTime")
                    {
                        dtsColumnMeta.DataType = DataType.DT_DBTIMESTAMP;
                    }
                    else if ("Number|Currency".Contains(column.SharePointType))
                    {
                        // Max = 100,000,000,000.00000
                        dtsColumnMeta.DataType = DataType.DT_R8;
                    }
                    else if ("Counter|Integer".Contains(column.SharePointType))
                    {
                        dtsColumnMeta.DataType = DataType.DT_I4;
                    }
                    else if ("Guid".Contains(column.SharePointType))
                    {
                        dtsColumnMeta.DataType = DataType.DT_GUID;
                    }
                    else
                    {
                        if (column.MaxLength == -1)
                        {
                            dtsColumnMeta.DataType = DataType.DT_NTEXT;
                            dtsColumnMeta.Length   = 0;
                        }
                        else
                        {
                            dtsColumnMeta.DataType = DataType.DT_WSTR;
                            dtsColumnMeta.Length   = column.MaxLength;
                        }
                    }

                    IDTSCustomProperty fieldNameMeta = dtsColumnMeta.CustomPropertyCollection.New();
                    fieldNameMeta.Name        = "Id";
                    fieldNameMeta.Description = "SharePoint ID";
                    fieldNameMeta.Value       = column.Name;

                    // Create default output columns for all of the fields returned and link to the original columns
                    IDTSOutputColumn dtsColumn = output.OutputColumnCollection.New();
                    dtsColumn.Name        = dtsColumnMeta.Name;
                    dtsColumn.Description = dtsColumnMeta.Description;
                    dtsColumn.ExternalMetadataColumnID = dtsColumnMeta.ID;

                    IDTSCustomProperty fieldName = dtsColumn.CustomPropertyCollection.New();
                    fieldName.Name        = fieldNameMeta.Name;
                    fieldName.Description = fieldNameMeta.Description;
                    fieldName.Value       = fieldNameMeta.Value;

                    dtsColumn.SetDataTypeProperties(
                        dtsColumnMeta.DataType, dtsColumnMeta.Length, dtsColumnMeta.Precision, dtsColumnMeta.Scale, 0);
                }
            }
            catch (ApplicationException)
            {
                // Exception happened, so clear the columns, which will invalidate this object.
                output.ExternalMetadataColumnCollection.RemoveAll();
            }
        }