コード例 #1
0
        private static bool UpdateProfileProperties(string userAccount, string userName, string subDepartment
                                                    , string Anniversarydate, string birthday, DateTime lastUpdated)
        {
            try
            {
                var SubDepartmentAttribute = ConfigurationManager.AppSettings["SubDepartmentAttribute"];
                var AnniversaryAttribute   = ConfigurationManager.AppSettings["AnniversaryAttribute"];
                var BirthdayAttribute      = ConfigurationManager.AppSettings["BirthdayAttribute"];

                var userAccountName = "i:0#.f|membership|" + AuthHelper.userName;

                var tenantCtx     = AuthHelper.GetTenantContext();
                var peopleManager = new PeopleManager(tenantCtx);

                peopleManager.SetSingleValueProfileProperty(userAccountName, SubDepartmentAttribute, subDepartment);
                peopleManager.SetSingleValueProfileProperty(userAccountName, AnniversaryAttribute, Anniversarydate);
                peopleManager.SetSingleValueProfileProperty(userAccountName, BirthdayAttribute, birthday);

                tenantCtx.ExecuteQuery();
                LogManager.WriteToFile("INFO : " + DateTime.Now + " --> " + userName + " --> " + userAccount + " --> " + lastUpdated + " --> Updated.");

                Console.WriteLine();
                return(true);
            }
            catch (Exception ex)
            {
                LogManager.WriteToFile("ERROR : " + DateTime.Now + " --> " + userName + " --> " + ex.Message);
                return(false);
            }
        }
コード例 #2
0
        public static void ProvisionSiteCollection()
        {
            try
            {
                //Check if Site Collection is exist
                var  siteCtx     = AuthHelper.GetClientContext();
                bool isSiteExist = false;

                // This will not check if Site Collection is deleted and available in Recycle bin
                if (siteCtx.WebExistsFullUrl(AuthHelper.siteUrl))
                {
                    isSiteExist = true;
                }

                //Create Context of SPO Admin
                var          tenantCtx = AuthHelper.GetTenantContext();
                var          tenant    = new Tenant(tenantCtx);
                SpoOperation spo       = null;

                if (isSiteExist)
                {
                    DeleteSiteCollectionAndRecycled(spo, tenantCtx, tenant);
                    RemoveSiteFromRecycleBin(spo, tenantCtx, tenant);
                }
                else
                {
                    CreateSiteCollection(spo, tenantCtx, tenant);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }