예제 #1
0
        private bool Initalize()
        {
            //try
            //{
            sqlService.TryConnectDb();

            sqlService.EnsureUserGroupDeltaRecordsExist();

            //Is user data set up?
            if (!sqlService.IsUserTablePopulated())
            {
                var seq      = 0;
                var userList = datowniaService.GetAllUsers(out seq);
                adservice.CreateUserList(ref userList);
                sqlService.InsertUserList(userList);
                sqlService.SetLatestLocalSeq(WaadConfig.UserApiFullName, seq);
                //removed auto email
                //emailservice.SendWelcomeEmail(userList);
            }

            //Is role data set up?
            if (!sqlService.IsGroupTablePopulated())
            {
                var seq       = 0;
                var groupList = datowniaService.GetAllGroups(out seq);
                sqlService.InsertGroupList(groupList);
                adservice.CreateGroupList(groupList);
                sqlService.SetLatestLocalSeq(WaadConfig.GroupApiFullName, seq);
            }

            //Is userrole data set up?
            if (!sqlService.IsUserGroupTablePopulated())
            {
                var seq           = 0;
                var usergroupList = datowniaService.GetAllUserGroups(out seq);
                sqlService.InsertUserGroupList(usergroupList);
                //need to update usergrouplist with the adUsername values
                sqlService.GetAdUsernames(ref usergroupList);
                adservice.AddUserGroupList(usergroupList);
                sqlService.SetLatestLocalSeq(WaadConfig.UserGroupApiFullName, seq);
            }
            //}
            //catch (Exception ex)
            //{
            //	//TODO: Log Exception
            //	return false;
            //}

            return(true);
        }