Пример #1
0
        private void FillNewFromResource(SPWeb oWeb)
        {
            var dtResources = APITeam.GetResourcePool(
                string.Format("<Get><Columns>{0}</Columns></Get>", ExternalColumn),
                oWeb);

            var arrNewTemp = new ArrayList();

            foreach (var parameter in NewUsers)
            {
                var row = dtResources.Select(string.Format("{0} ='{1}'", ExternalColumn, parameter));
                if (row.Length > 0)
                {
                    arrNewTemp.Add(row[0]["SPID"].ToString());
                }
            }

            NewUsers = arrNewTemp;
        }
Пример #2
0
        /// <summary>
        ///     Maps the resource pool id to SP user id.
        /// </summary>
        /// <param name="resourcePoolIds">The resource pool ids.</param>
        /// <param name="badResourcePoolIds">The bad resource pool ids.</param>
        /// <param name="returnAll">if set to <c>true</c> [return all].</param>
        /// <returns></returns>
        private Dictionary <int, string> MapResourcePoolIdToSPUser(IEnumerable <int> resourcePoolIds,
                                                                   ref IList <string> badResourcePoolIds, bool returnAll)
        {
            var resourceIdDictionary = new Dictionary <int, string>();

            DataTable resourcePool = APITeam.GetResourcePool(@"<GetResources><Columns></Columns></GetResources>", Web);

            if (!returnAll)
            {
                foreach (int resourcePoolId in resourcePoolIds)
                {
                    DataRow dataRow = resourcePool.Select(string.Format("ID = '{0}'", resourcePoolId)).FirstOrDefault();

                    if (dataRow == null)
                    {
                        badResourcePoolIds.Add(resourcePoolId.ToString(CultureInfo.InvariantCulture));
                        continue;
                    }

                    if (!resourceIdDictionary.ContainsKey(resourcePoolId))
                    {
                        resourceIdDictionary.Add(resourcePoolId, (string)dataRow["SPAccountInfo"]);
                    }
                }
            }
            else
            {
                foreach (DataRow dataRow in resourcePool.Rows)
                {
                    int resourcePoolId = int.Parse(dataRow["ID"].ToString());

                    if (!resourceIdDictionary.ContainsKey(resourcePoolId))
                    {
                        resourceIdDictionary.Add(resourcePoolId, (string)dataRow["SPAccountInfo"]);
                    }
                }
            }

            return(resourceIdDictionary);
        }