/// <summary> /// 用户登录 /// </summary> /// <param name="uname"></param> /// <param name="pwd"></param> private void LoginUser(string uname, string pwd, bool pwdEncrypted) { try { string sid = PortalService.AuthUser(uname, pwd, pwdEncrypted); if (!String.IsNullOrEmpty(sid)) { string url = FormsAuthentication.GetRedirectUrl(uname, true); if (asyncreq) { Response.Write(String.Format("success,{0}", url)); } else { Response.Redirect(url); } } else { Response.Write("登陆失败,用户名或密码不正确!"); } } catch (Exception ex) { Response.Write(ex.Message); Response.End(); } Response.End(); }
/// <summary> /// 获取identity id对应的成员信息 /// </summary> /// <param name="identity"></param> /// <returns></returns> private static ResultMo GetIdentityMemberInfo(MemberIdentity identity) { BaseMo memInfo = null; if (identity.AuthenticationType == (int)MemberAuthorizeType.Admin) { var memRes = service.GetAdminInfo(identity.Id).WaitResult(); if (!memRes.IsSuccess()) { return(new ResultMo(ResultTypes.UnAuthorize, "未发现授权用户信息")); } memInfo = memRes.data; } else { var memRes = service.GetUserInfo(identity.Id).WaitResult(); if (!memRes.IsSuccess()) { return(new ResultMo(ResultTypes.UnAuthorize, "未发现授权用户信息")); } memInfo = memRes.data; } identity.MemberInfo = memInfo; var checkRes = PortalService.CheckMemberStatus(memInfo.status); return(!checkRes.IsSuccess() ? checkRes : new ResultMo()); }
private void LoadData() { var portalProxy = new PortalProxy(txtUrl.Text, Guid.Parse(txtPracticeGuid.Text), txtUserName.Text, txtPassword.Text); _portalService = new PortalService(portalProxy); grdClients.SetDataBinding(_portalService.GetClients(), string.Empty); grdClients.RetrieveStructure(); }
protected void Page_Load(object sender, EventArgs e) { if (IsAsyncRequest) { ents = SysGroupRule.FindAll(SearchCriterion); this.PageState.Add("GrpList", ents); } SysGroup ent = null; switch (this.RequestAction) { case RequestActionEnum.Query: case RequestActionEnum.Default: ent = this.GetTargetData <SysGroup>(); this.SetFormData(ent); break; case RequestActionEnum.Update: ent = this.GetMergedData <SysGroup>(); ent.ParentID = String.IsNullOrEmpty(ent.ParentID) ? null : ent.ParentID; ent.DoUpdate(); this.SetMessage("更新成功!"); break; case RequestActionEnum.Create: ent = this.GetPostedData <SysGroup>(); if (String.IsNullOrEmpty(ent.ParentID)) { ent.CreateAsTop(); } else { ent.CreateAsSub(ent.ParentID); } this.SetMessage("添加模块成功!"); break; case RequestActionEnum.Delete: ent = this.GetTargetData <SysGroup>(); ent.DoDelete(); this.SetMessage("删除成功!"); break; case RequestActionEnum.Custom: if (RequestActionString == "refreshsys") { PortalService.RefreshSysModules(); SetMessage("操作成功!"); } break; } SysGroupType[] grpTypes = SysGroupTypeRule.FindAll(); this.PageState.Add("GrpTypeList", grpTypes); }
public async Task ComputeUsers(PerformContext performContext, int managedSupportId) { Logger.Info(performContext, "Getting the users from the Portal..."); var remoteUsers = PortalService.GetAllUsers().ToArray(); Logger.Info(performContext, "Getting the users from Active Directory..."); var adUsers = _activeDirectoryManager.GetAllUsers().ToList(); foreach (var adUser in adUsers) { performContext?.Cancel(); var remoteUser = remoteUsers.FirstOrDefault(ru => ru.Id == adUser.Id); if (remoteUser == null) { var newUser = LicenseUser.Create( adUser, managedSupportId, AuthService.GetAccount()); await PortalService.AddUserAsync(newUser); performContext?.WriteSuccessLine($"+ {newUser}"); Logger.Info($"Created: {newUser}"); Logger.Debug($"{JsonConvert.SerializeObject(newUser, Formatting.Indented)}"); continue; } remoteUser.UpdateValues(adUser); await PortalService.UpdateUserAsync(remoteUser); performContext?.WriteSuccessLine($"^ {remoteUser}"); Logger.Info($"Updated: {remoteUser}"); Logger.Debug($"{JsonConvert.SerializeObject(remoteUser, Formatting.Indented)}"); } var staleUsers = remoteUsers.Except(adUsers, _licenseUserEqualityComparer).ToArray(); foreach (var staleUser in staleUsers) { performContext?.Cancel(); if (staleUser.IsDeleted) { continue; } await PortalService.DeleteUserAsync(staleUser); performContext?.WriteWarnLine($"- {staleUser}"); Logger.Info($"Delete: {staleUser}"); Logger.Debug($"{JsonConvert.SerializeObject(staleUser, Formatting.Indented)}"); } }
public async Task ComputeGroups(PerformContext performContext) { Logger.Info(performContext, "Getting the groups from the Portal..."); var remoteGroups = PortalService.GetAllGroups().ToArray(); Logger.Info(performContext, "Getting the groups from Active Directory..."); var adGroups = _activeDirectoryManager.GetAllGroups().ToArray(); foreach (var adGroup in adGroups) { performContext?.Cancel(); var remoteGroup = remoteGroups.FirstOrDefault(rg => rg.Id == adGroup.Id); if (remoteGroup == null) { var newGroup = LicenseGroup.Create( adGroup, AuthService.GetAccount()); await PortalService.AddGroupAsync(newGroup); performContext?.WriteSuccessLine($"+ {newGroup}"); Logger.Info($"Created: {newGroup}"); Logger.Debug($"{JsonConvert.SerializeObject(newGroup, Formatting.Indented)}"); continue; } remoteGroup.UpdateValues(adGroup); await PortalService.UpdateGroupAsync(remoteGroup); performContext?.WriteSuccessLine($"^ {remoteGroup}"); Logger.Info($"Updated: {remoteGroup}"); Logger.Debug($"{JsonConvert.SerializeObject(remoteGroup, Formatting.Indented)}"); } var staleGroups = remoteGroups.Except(adGroups, _licenseGroupEqualityComparer).ToArray(); foreach (var staleGroup in staleGroups) { performContext?.Cancel(); if (staleGroup.IsDeleted) { continue; } await PortalService.DeleteGroupAsync(staleGroup); performContext?.WriteWarnLine($"- {staleGroup}"); Logger.Info($"Delete: {staleGroup}"); Logger.Debug($"{JsonConvert.SerializeObject(staleGroup, Formatting.Indented)}"); } }
private void InitApplication() { // 初始化PortalService PortalService.Initialize(new string[] { "Aim.Examining.Model", "Aim.WorkFlow" }, typeof(Aim.Examining.Model.ExamModelBase <>)); //日志 log4net.Config.XmlConfigurator.Configure(); //日志、异常 //LogAttribute.del += WriteLog; //ExceptionAttribute.del += WriteLog; //检验序列号是否有效 //CheckSystemValid(); }
public async Task ComputeGroupMembershipAsync(PerformContext performContext) { Logger.Info(performContext, "Getting the groups from Active Directory..."); var groups = _activeDirectoryManager.GetAllGroups().ToArray(); foreach (var group in groups) { performContext?.Cancel(); var groupMembers = _activeDirectoryManager.GetGroupMembers(group.Id); var userGroups = PortalService.GetAllGroupUsers(group.Id).ToArray(); var newMembers = groupMembers.Except(userGroups, _licenseUserGroupEqualityComparer).ToArray(); foreach (var newMember in newMembers) { performContext?.Cancel(); await PortalService.AddUserGroupAsync( LicenseUserGroup.Create(group.Id, newMember.UserId)); performContext?.WriteSuccessLine($"+ {group.Name} {newMember.UserId}"); Logger.Info($"User: {newMember.UserId} was added to Group: {group.Id} {group.Name}"); } var staleMembers = userGroups.Except(groupMembers, _licenseUserGroupEqualityComparer).ToArray(); foreach (var staleMember in staleMembers) { performContext?.Cancel(); await PortalService.DeleteUserGroupAsync( staleMember); performContext?.WriteWarnLine($"- {group.Name} {staleMember.UserId}"); Logger.Info($"User: {staleMember.UserId} was removed from Group: {group.Id} {group.Name}"); } if (!newMembers.Any() && !staleMembers.Any()) { Logger.Info($"Group: {group.Id} No changes have been made."); } else { Logger.Info($"Group: {group.Id} Added: {newMembers.Length} Removed: {staleMembers.Length}"); } } }
private void InitApplication() { // 初始化PortalService PortalService.Initialize(new string[] { "SP.Model", "Aim.WorkFlow" }, typeof(SP.Model.SPModelBase <>)); SearchCriterion search = new SearchCriterion(); search.DefaultPageSize = 30; //日志 log4net.Config.XmlConfigurator.Configure(); //日志、异常 LogAttribute.del += WriteLog; ExceptionAttribute.del += WriteLog; //检验序列号是否有效 //CheckSystemValid(); }
public void WhenGettingEntity_ThenReturnsCorrectEntity() { // Arrange var repositoryMock = new Mock<IPortalRepository>(); Portal newEntity = DefaultModelHelper.DummyPopulatedPortal(); repositoryMock.Setup(repo => repo.GetById(It.IsAny<int>())).Returns(newEntity); // Act var services = new PortalService(repositoryMock.Object, new Mock<IUnitOfWork>().Object); Portal returnedEntity = services.GetById(1); // Assert Assert.NotNull(returnedEntity); Assert.Equal("Title", returnedEntity.Title); }
/// <summary> /// 用户登录 /// </summary> /// <param name="uname"></param> /// <param name="pwd"></param> private void LoginUser(string uname, string pwd, bool pwdEncrypted) { try { string sql = "select count(UserId) from SysUser where LoginName='" + uname + "'"; if (DataHelper.QueryValue <int>(sql) > 0) { sql = "select password from SysUser where LoginName='" + uname + "'"; if (DataHelper.QueryValue(sql) + "" == "") { Response.Write("请先设置密码再登陆!"); } else { string sid = PortalService.AuthUser(uname, pwd, pwdEncrypted); if (!String.IsNullOrEmpty(sid)) { string url = FormsAuthentication.GetRedirectUrl(uname, true); if (asyncreq) { Response.Write(String.Format("success,{0}", url)); } else { Response.Redirect(url); } } else { Response.Write("登陆失败,用户名或密码不正确!"); } } } else { Response.Write("用户名不存在!"); } } catch (Exception ex) { Response.Write(ex.Message); Response.End(); } Response.End(); }
static void Main(string[] args) { ExportWebFilesApp app = new ExportWebFilesApp(); Logger logger = app.Logger; ExitCode exitCode = ExitCode.None; try { logger.Info("Application started."); CultureInfo.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB"); Options options = new Options(); Parser.Default.ParseArgumentsStrict(args, options, CommandLineOptions.ArgumentParsingFailed); Connection connection = null; if (string.IsNullOrWhiteSpace(options.ConnectionString)) { connection = new Connection(options.AuthorityUrl, options.OrganizationUrl, options.OrganizationUrlSuffix, options.TenantId, options.ServicePrincipalId, options.ServicePrincipalSecret, options.ConnectionRetries, options.ConnectionTimeout); } else { connection = new Connection(options.ConnectionString, options.ConnectionRetries, options.ConnectionTimeout); } using (CrmServiceContext organizationServiceContext = new CrmServiceContext(connection.OrganizationService)) using (CrmService crmService = new CrmService(organizationServiceContext, connection)) using (IPortalService portalService = new PortalService(organizationServiceContext, crmService)) { portalService.ExportWebFiles(options.OutputPath, options.WebsitePrimaryKey); exitCode = ExitCode.Success; } } catch (Exception ex) { exitCode = new ExceptionHandlingService(ex).GetExitCode(); } finally { logger.Info(CultureInfo.InvariantCulture, "Application exited with code: {0}", (int)exitCode); Environment.Exit((int)exitCode); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSubmit_Click(object sender, EventArgs e) { ZNode.Libraries.Shipping.FedEx fdx = new ZNode.Libraries.Shipping.FedEx(); ZNodeEncryption decrypt = new ZNodeEncryption (); fdx.ClientProductId = ZNodeConfigManager.SiteConfig.FedExClientProductId; fdx.ClientProductVersion = ZNodeConfigManager.SiteConfig.FedExClientProductVersion; fdx.CSPAccessKey = ZNodeConfigManager.SiteConfig.FedExCSPKey; fdx.CSPPassword = ZNodeConfigManager.SiteConfig.FedExCSPPassword; fdx.CurrencyCode = ZNode.Libraries.ECommerce.Catalog.ZNodeCurrencyManager.CurrencyCode(); fdx.FedExAccountNumber = decrypt.DecryptData(ZNodeConfigManager.SiteConfig.FedExAccountNumber); ZNode.Libraries.Shipping.FedExRegisterCspUserService.Address BillingAddress = new ZNode.Libraries.Shipping.FedExRegisterCspUserService.Address(); BillingAddress.StreetLines = new string[]{txtBillingStreet1.Text.Trim(),txtBillingStreet2.Text.Trim()}; BillingAddress.City = txtBillingCity.Text.Trim(); BillingAddress.StateOrProvinceCode = txtBillingState.Text.Trim(); BillingAddress.PostalCode = txtBillingPostalCode.Text.Trim(); BillingAddress.CountryCode = lstBillingCountryCode.SelectedValue; ZNode.Libraries.Shipping.FedExRegisterCspUserService.WebAuthenticationCredential userCredential = fdx.RegisterCPCUser(FirstName.Text.Trim(), LastName.Text.Trim(), PhoneNumber.Text.Trim(), "", "", EmailId.Text.Trim(), BillingAddress); if (fdx.ErrorCode == "0") { //User Credential string userKey = userCredential.Key; string password = userCredential.Password; PortalService portalService = new PortalService(); Portal _portal = portalService.GetByPortalID(ZNodeConfigManager.SiteConfig.PortalID); _portal.FedExProductionKey = decrypt.EncryptData(userKey); _portal.FedExSecurityCode = decrypt.EncryptData(password); portalService.Update(_portal); //remove the siteconfig from session ZNodeConfigManager.SiteConfig = null; Response.Redirect("~/admin/secure/settings/default.aspx?mode=fedex"); } else { lblErrorMsg.Text = fdx.ErrorDescription; } }
protected void Page_Load(object sender, EventArgs e) { if (this.IsAsyncRequest) { SearchCriterion.SetOrder("CreateDate"); SearchCriterion.SetOrder("SortIndex"); ents = SysRoleRule.FindAll(SearchCriterion); this.PageState.Add("RoleList", ents); } SysRole ent = null; switch (this.RequestAction) { case RequestActionEnum.Update: ent = this.GetMergedData <SysRole>(); ent.SaveAndFlush(); this.SetMessage("保存成功!"); break; case RequestActionEnum.Create: ent = this.GetPostedData <SysRole>(); ent.CreateAndFlush(); this.SetMessage("新建成功!"); break; case RequestActionEnum.Delete: ent = this.GetTargetData <SysRole>(); ent.DeleteAndFlush(); this.SetMessage("删除成功!"); break; case RequestActionEnum.Custom: if (RequestActionString == "refreshsys") { PortalService.RefreshSysModules(); SetMessage("操作成功!"); } break; } SysRoleType[] roleTypes = SysRoleTypeRule.FindAll(); this.PageState.Add("RoleTypeList", roleTypes); }
protected void btnSubmit_Click(object sender, EventArgs e) { ZNode.Libraries.Shipping.FedEx fdx = new ZNode.Libraries.Shipping.FedEx(); ZNodeEncryption decrypt = new ZNodeEncryption(); if (ZNodeConfigManager.SiteConfig.FedExProductionKey.Length == 0 || ZNodeConfigManager.SiteConfig.FedExSecurityCode.Length == 0) { lblErrorMsg.Text = "Please obtain user account first using RegisterCSPUSer."; return; } fdx.ClientProductId = ZNodeConfigManager.SiteConfig.FedExClientProductId; fdx.ClientProductVersion = ZNodeConfigManager.SiteConfig.FedExClientProductVersion; fdx.CSPAccessKey = ZNodeConfigManager.SiteConfig.FedExCSPKey; fdx.CSPPassword = ZNodeConfigManager.SiteConfig.FedExCSPPassword; fdx.FedExAccountNumber = decrypt.DecryptData(ZNodeConfigManager.SiteConfig.FedExAccountNumber); fdx.CurrencyCode = ZNode.Libraries.ECommerce.Catalog.ZNodeCurrencyManager.CurrencyCode(); fdx.FedExAccessKey = decrypt.DecryptData(ZNodeConfigManager.SiteConfig.FedExProductionKey); fdx.FedExSecurityCode = decrypt.DecryptData(ZNodeConfigManager.SiteConfig.FedExSecurityCode); ZNode.Libraries.Shipping.FedExSubscribeService.Address BillingAddress = new ZNode.Libraries.Shipping.FedExSubscribeService.Address(); BillingAddress.StreetLines = new string[] { txtBillingStreet1.Text.Trim(), txtBillingStreet2.Text.Trim() }; BillingAddress.PostalCode = txtBillingPostalCode.Text.Trim(); BillingAddress.City = txtBillingCity.Text.Trim(); BillingAddress.StateOrProvinceCode = txtBillingState.Text.Trim(); BillingAddress.CountryCode = lstBillingCountryCode.SelectedValue; string meterNumber = fdx.SubscribeUser(FirstName.Text.Trim() + " " + LastName.Text.Trim(), PhoneNumber.Text.Trim(), "", "", EmailID.Text, BillingAddress); if (fdx.ErrorCode == "0")//Check for success { PortalService portalService = new PortalService(); Portal _portal = portalService.GetByPortalID(ZNodeConfigManager.SiteConfig.PortalID); _portal.FedExMeterNumber = decrypt.EncryptData(meterNumber); portalService.Update(_portal); Response.Redirect("~/admin/secure/settings/default.aspx?mode=fedex"); } else { lblErrorMsg.Text = fdx.ErrorDescription; } }
private async Task Initialize() { try { _portalService = PortalService.CurrentPortalService as PortalService; InitializeCommandAndMessages(); if (_portalService.Portal != null) { var _ = await PopulateDataAsync(); } } catch (Exception ex) { var _ = App.ShowExceptionDialog(ex); } }
public override async Task StartAsync(PerformContext performContext) { await ExecuteAsync(performContext, async() => { if (!_veeamManager.IsOnline()) { performContext?.WriteErrorLine("The Veeam server does not appear to be online. Please make sure all Veeam services are started before retrying this operation again."); Logger.Error("Veeam server not online."); return; } Logger.Info(performContext, "Collecting information...this could take some time."); Veeam payload = _veeamManager.GetLicensingInformation(performContext); Logger.Info(performContext, "done"); Logger.Info(performContext, "Validating the payload..."); var remoteVeeam = PortalService.GetVeeamServerById(AuthService.GetDevice()); if (remoteVeeam.Count != 1) { payload.Validate(); Logger.Info(performContext, "Payload is valid!"); DumpPayload(payload); await PortalService.AddVeeamServerAsync(payload); Logger.Info(performContext, "Successfully checked in."); return; } remoteVeeam[0].UpdateValues(payload); remoteVeeam[0].Validate(); Logger.Info(performContext, "Payload is valid!"); DumpPayload(payload); await PortalService.UpdateVeeamServerAsync(remoteVeeam[0]); Logger.Info(performContext, "Successfully checked in."); }); }
protected void Page_Load(object sender, EventArgs e) { if (IsAsyncRequest) { switch (this.RequestAction) { case RequestActionEnum.Custom: if (RequestActionString == "querychildren") { SysModule[] mdls = null; if (RequestData.ContainsKey("ModuleID") && RequestData["ModuleID"] != null) { mdls = SysModule.FindAll("FROM SysModule as mdl WHERE mdl.ParentID = ?", RequestData["ModuleID"]); } else if (RequestData.ContainsKey("ApplicationID") && RequestData["ApplicationID"] != null) { mdls = SysModule.FindAll("FROM SysModule as mdl WHERE mdl.ApplicationID = ? AND mdl.ParentID is null", RequestData["ApplicationID"]); } mdls = mdls.OrderBy(ent => ent.SortIndex).ToArray(); this.PageState.Add("Mdls", mdls); } else if (RequestActionString == "refreshsys") { PortalService.RefreshSysModules(); SetMessage("操作成功!"); } break; } } else { SysApplication[] sysApps = SysApplicationRule.FindAll(); sysApps = sysApps.OrderBy(ent => ent.SortIndex).ToArray(); this.PageState.Add("Apps", sysApps); DataEnum de = SysModuleTypeRule.GetModuleTypeEnum(); this.PageState.Add("MdlTypeEnum", de); } }
protected void Page_Load(object sender, EventArgs e) { switch (this.RequestAction) { case RequestActionEnum.Custom: if (RequestActionString == "querychildren") { string id = (RequestData.ContainsKey("ID") ? RequestData["ID"].ToString() : String.Empty); string ttype = RequestData["Type"].ToString().ToLower(); if (RequestData.ContainsKey("Type")) { SysAuth[] ents = null; if (ttype == "atype") // 1为入口权限 { ents = SysAuth.FindAll("FROM SysAuth as ent WHERE ent.Type = ? AND ent.ParentID is null", id); } else { ents = SysAuth.FindAll("FROM SysAuth as ent WHERE ent.ParentID = ?", id); } this.PageState.Add("DtList", ents.OrderBy(v => v.SortIndex).ThenBy(v => v.CreateDate)); } } else if (RequestActionString == "refreshsys") { PortalService.RefreshSysModules(); SetMessage("操作成功!"); } break; } if (!IsAsyncRequest) { SysAuthType[] authTypeList = SysAuthTypeRule.FindAll(); this.PageState.Add("DtList", authTypeList); } }
public override void OnAuthorization(HttpActionContext actionContext) { _actionContext = actionContext; var currentUser = actionContext.RequestContext.Principal.Identity; if (currentUser.IsAuthenticated) { var queryString = actionContext.Request.RequestUri.Query; NameValueCollection parameters = System.Web.HttpUtility.ParseQueryString(queryString); var portalId = parameters["portalId"]; if (portalId == null) { ThrowResponseException(HttpStatusCode.NotFound, "ProjectAuthorizationAttribute: parameter portalId not found"); } PortalService _portalService = new PortalService(); if (!_portalService.IsPortalOwner(portalId)) { ThrowResponseException(HttpStatusCode.Unauthorized, "For removal, update and create portal projects, you must be the owner of the portal"); } var actionName = actionContext.ActionDescriptor.ActionName; if (actionName == "Update" || actionName == "Delete") { int projectId; if (!int.TryParse(actionContext.ControllerContext.RouteData.Values["id"].ToString(), out projectId)) { ThrowResponseException(HttpStatusCode.BadRequest, "ProjectAuthorizationAttribute: projectId is invalid"); } ProjectService _projectService = new ProjectService(); if (_projectService.GetProjectOwner(projectId).Email != currentUser.Name) { ThrowResponseException(HttpStatusCode.Unauthorized, "For removal, update and create project, you must be the owner of the project"); } } } else { ThrowResponseException(HttpStatusCode.Unauthorized, "Authentication required"); } base.OnAuthorization(actionContext); }
public async Task Run() { DebugHelper.LogInformation("Onboarding starting"); DebugHelper.LogInformation($"Device Provisioning State: {(SimulatedDevice.IsProvisioned ? "Provisioned" : "Not provisioned")}"); //Init Portal Api and turn on access point if (!InitializePortalAPI()) { return; } //Start Services _WifiService = new WifiService(); _ProvisioningService = new ProvisioningService(); _PortalService = new PortalService(); //Start AP App AccessPointHelper.StartAccessPoint(); //Start Stream Socker Service _DeviceApiServer = new WebDeviceApiServer(); _DeviceApiServer.CommandReceived += CommandReceived; _DeviceApiServer.Start(); DebugHelper.LogInformation("Onboarding started"); //Wait for AP Timeout _LastAccess = DateTime.UtcNow; while (true) { if (_APTimeoutEnabled && SimulatedDevice.IsProvisioned && DateTime.UtcNow.AddMinutes(-(APTimeoutMinutes)) > _LastAccess) { AccessPointHelper.StopAccessPoint(); } await Task.Delay(500); } }
/// <summary> /// 用户登录 /// </summary> /// <param name="uname"></param> /// <param name="pwd"></param> private void LoginUser(string uname, string pwd, bool pwdEncrypted) { try { SysUser userent = SysUser.FindAllByProperty(SysUser.Prop_LoginName, uname).FirstOrDefault(); if (userent == null) { ClientScript.RegisterClientScriptBlock(this.GetType(), "adsf", "window.parent.location.href='/Login.aspx'", true); return; } string CorpId = userent.Pk_corp; SysGroup group = SysGroup.TryFind(CorpId); Session["CompanyId"] = CorpId; if (group != null) { Session["CompanyName"] = group.Name; } else { Session["CompanyName"] = ""; } string sid = PortalService.AuthUser(uname, pwd, false); if (!String.IsNullOrEmpty(sid)) { string url = FormsAuthentication.GetRedirectUrl(uname, true); Response.Redirect(url); return; } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "adsf", "window.parent.location.href='/Login.aspx'", true); return; } } catch { } }
/// <summary> /// 通过授权token获取对应的成员Id等信息 /// </summary> /// <returns></returns> private static ResultMo <MemberIdentity> GetIndentityId() { var sysInfo = MemberShiper.AppAuthorize; if (string.IsNullOrEmpty(sysInfo.Token)) { return(new ResultMo <MemberIdentity>(ResultTypes.UnAuthorize, "用户未登录!")); } var tokenRes = PortalService.GetTokenDetail(sysInfo.AppSource, sysInfo.Token); if (!tokenRes.IsSuccess()) { return(tokenRes.ConvertToResultOnly <MemberIdentity>()); } var identity = new MemberIdentity { AuthenticationType = tokenRes.data.authType, Id = tokenRes.data.id }; return(new ResultMo <MemberIdentity>(identity)); }
public HomeController(PortalService portalService) { this.portalService = portalService; }
public override async Task StartAsync(PerformContext performContext) { await ExecuteAsync(performContext, async() => { Console.WriteLine(Environment.NewLine); Logger.Info(performContext, "Acquiring the upload details from the api."); var managedServer = PortalService.GetManagedServer(); if (managedServer == null) { Logger.Info(performContext, "It appears this device hasn't logged in before. Generating the upload details."); try { var upload = ManagedSupport.Create( SettingManagerHelper.ClientVersion, AuthService.GetDevice(), AuthService.GetAccount()); await PortalService.AddManagedServerAsync(upload); managedServer = PortalService.GetManagedServer(); if (managedServer == null) { throw new UserFriendlyException("There was a problem creating the upload, please try again. If the problem persists, please raise a bug report."); } } catch (Exception ex) when(!(ex is UserFriendlyException)) { throw new UserFriendlyException(ex.Message); } } else { managedServer.ClientVersion = SettingManagerHelper.ClientVersion; } Logger.Info(performContext, "Upload details acquired!"); Console.WriteLine(Environment.NewLine); Logger.Info(performContext, "---------- Uploading groups begin ----------"); await ComputeGroups(performContext); Logger.Info(performContext, "---------- Uploading groups end ----------"); Console.WriteLine(Environment.NewLine); Logger.Info(performContext, "---------- Uploading users begin ----------"); await ComputeUsers(performContext, managedServer.Id); Logger.Info(performContext, "---------- Uploading users end ----------"); Console.WriteLine(Environment.NewLine); Logger.Info(performContext, "Calculating group memberships. This could take some time..."); await ComputeGroupMembershipAsync(performContext); Logger.Info(performContext, "Group memberships are up to date."); Console.WriteLine(Environment.NewLine); Logger.Info(performContext, "Completing the upload."); await PortalService.UpdateManagedServerAsync(managedServer); }); }
/// <summary> /// 用户登录 /// </summary> /// <param name="uname"></param> /// <param name="pwd"></param> private void LoginUser(string uname, string pwd, bool pwdEncrypted, string loginstate) { try { string CorpId = RequestData.Get <string>("CorpId"); SysUser userent = SysUser.FindAllByProperty(SysUser.Prop_LoginName, uname).FirstOrDefault(); if (userent == null) { PageState.Add("error", "用户名错误!"); return; } if (string.IsNullOrEmpty(userent.Password)) { PageState.Add("error", "nullpwd"); return; } //判断登陆人有没有在这个公司 string sql = @"select count(1) from SysUserGroup where UserId='{0}' and GroupId not in (select RoleId from sysRole) and isnull(outdutydate,'')='' and pk_gw is not null and pk_corp='{1}'"; int corpcount = DataHelper.QueryValue <int>(string.Format(sql, userent.UserID, CorpId)); if (corpcount > 0 || uname == "admin") { string sid = PortalService.AuthUser(uname, pwd, false); if (!String.IsNullOrEmpty(sid)) { string url = FormsAuthentication.GetRedirectUrl(uname, true); string returnUrl = RequestData.Get <string>("ReturnUrl"); Session["CompanyId"] = CorpId; if (!string.IsNullOrEmpty(returnUrl)) { url = returnUrl; Session["CompanyId"] = CorpId; //公司 SysGroup group = SysGroup.TryFind(CorpId); if (group != null) { Session["CompanyName"] = group.Name; } else { Session["CompanyName"] = ""; } } PageState.Add("url", url); } else { PageState.Add("error", "登陆失败,用户名或密码不正确!"); } return; } else { //查询该人员有没有 DataTable dtrole = DataHelper.QueryDataTable("select CompanyIds from sysrole where roleid in ( select RoleID from SysUserRole where UserId='" + userent.UserID + "')"); bool hasQX = false; foreach (DataRow row in dtrole.Rows) { if ((row["CompanyIds"] + "").Contains(CorpId)) { hasQX = true; break; } } if (hasQX) { string sid = PortalService.AuthUser(uname, pwd, false); if (!String.IsNullOrEmpty(sid)) { string url = FormsAuthentication.GetRedirectUrl(uname, true); PageState.Add("url", url); Session["CompanyId"] = CorpId; } else { PageState.Add("error", "登陆失败,用户名或密码不正确!"); } } else { PageState.Add("error", "您没有该公司的权限,请重新选择公司!"); } return; } } catch (Exception ex) { PageState.Add("error", ex.Message); } }
private ServiceBase getService(string className) { ServiceBase service = null; if (className.Equals("com.liferay.portal.model.User")) { service = new UserService(_session); } else if (className.Equals("com.liferay.portal.model.Address")) { service = new AddressService(_session); } else if (className.Equals("com.liferay.portlet.asset.model.AssetCategory")) { service = new AssetCategoryService(_session); } else if (className.Equals("com.liferay.portlet.asset.model.AssetEntry")) { service = new AssetEntryService(_session); } else if (className.Equals("com.liferay.portlet.asset.model.AssetTag")) { service = new AssetTagService(_session); } else if (className.Equals("com.liferay.portlet.asset.model.AssetVocabulary")) { service = new AssetVocabularyService(_session); } else if (className.Equals("com.liferay.portlet.blogs.model.BlogsEntry")) { service = new BlogsEntryService(_session); } else if (className.Equals("com.liferay.portlet.bookmarks.model.BookmarksEntry")) { service = new BookmarksEntryService(_session); } else if (className.Equals("com.liferay.portlet.bookmarks.model.BookmarksFolder")) { service = new BookmarksFolderService(_session); } else if (className.Equals("com.liferay.portal.model.Company")) { service = new CompanyService(_session); } else if (className.Equals("com.liferay.portal.model.Contact")) { service = new ContactService(_session); } else if (className.Equals("com.liferay.portal.model.Country")) { service = new CountryService(_session); } else if (className.Equals("com.liferay.portlet.dynamicdatalists.model.DDLRecord")) { service = new DDLRecordService(_session); } else if (className.Equals("com.liferay.portlet.dynamicdatalists.model.DDLRecordSet")) { service = new DDLRecordSetService(_session); } else if (className.Equals("com.liferay.portlet.dynamicdatamapping.model.DDMStructure")) { service = new DDMStructureService(_session); } else if (className.Equals("com.liferay.portlet.dynamicdatamapping.model.DDMTemplate")) { service = new DDMTemplateService(_session); } else if (className.Equals("com.liferay.portlet.documentlibrary.model.DLFileEntry")) { service = new DLFileEntryService(_session); } else if (className.Equals("com.liferay.portlet.documentlibrary.model.DLFileEntryType")) { service = new DLFileEntryTypeService(_session); } else if (className.Equals("com.liferay.portlet.documentlibrary.model.DLFileVersion")) { service = new DLFileVersionService(_session); } else if (className.Equals("com.liferay.portlet.documentlibrary.model.DLFolder")) { service = new DLFolderService(_session); } else if (className.Equals("com.liferay.portal.model.EmailAddress")) { service = new EmailAddressService(_session); } else if (className.Equals("com.liferay.portlet.expando.model.ExpandoColumn")) { service = new ExpandoColumnService(_session); } else if (className.Equals("com.liferay.portlet.expando.model.ExpandoValue")) { service = new ExpandoValueService(_session); } else if (className.Equals("com.liferay.portal.model.Group")) { service = new GroupService(_session); } else if (className.Equals("com.liferay.portal.model.Image")) { service = new ImageService(_session); } else if (className.Equals("com.liferay.portlet.journal.model.JournalArticle")) { service = new JournalArticleService(_session); } else if (className.Equals("com.liferay.portlet.journal.model.JournalFeed")) { service = new JournalFeedService(_session); } else if (className.Equals("com.liferay.portlet.journal.model.JournalFolder")) { service = new JournalFolderService(_session); } else if (className.Equals("com.liferay.portal.model.Layout")) { service = new LayoutService(_session); } else if (className.Equals("com.liferay.portal.model.LayoutBranch")) { service = new LayoutBranchService(_session); } else if (className.Equals("com.liferay.portal.model.LayoutPrototype")) { service = new LayoutPrototypeService(_session); } else if (className.Equals("com.liferay.portal.model.LayoutRevision")) { service = new LayoutRevisionService(_session); } else if (className.Equals("com.liferay.portal.model.LayoutSet")) { service = new LayoutSetService(_session); } else if (className.Equals("com.liferay.portal.model.LayoutSetPrototype")) { service = new LayoutSetPrototypeService(_session); } else if (className.Equals("com.liferay.portal.model.ListType")) { service = new ListTypeService(_session); } else if (className.Equals("com.liferay.portlet.messageboards.model.MBBan")) { service = new MBBanService(_session); } else if (className.Equals("com.liferay.portlet.messageboards.model.MBCategory")) { service = new MBCategoryService(_session); } else if (className.Equals("com.liferay.portlet.messageboards.model.MBMessage")) { service = new MBMessageService(_session); } else if (className.Equals("com.liferay.portlet.messageboards.model.MBThread")) { service = new MBThreadService(_session); } else if (className.Equals("com.liferay.portlet.mobiledevicerules.model.MDRAction")) { service = new MDRActionService(_session); } else if (className.Equals("com.liferay.portlet.mobiledevicerules.model.MDRRule")) { service = new MDRRuleService(_session); } else if (className.Equals("com.liferay.portlet.mobiledevicerules.model.MDRRuleGroup")) { service = new MDRRuleGroupService(_session); } else if (className.Equals("com.liferay.portlet.mobiledevicerules.model.MDRRuleGroupInstance")) { service = new MDRRuleGroupInstanceService(_session); } else if (className.Equals("com.liferay.portal.model.MembershipRequest")) { service = new MembershipRequestService(_session); } else if (className.Equals("com.liferay.portal.model.Organization")) { service = new OrganizationService(_session); } else if (className.Equals("com.liferay.portal.model.OrgLabor")) { service = new OrgLaborService(_session); } else if (className.Equals("com.liferay.portal.model.PasswordPolicy")) { service = new PasswordPolicyService(_session); } else if (className.Equals("Permission")) { service = new PermissionService(_session); } else if (className.Equals("com.liferay.portal.model.Phone")) { service = new PhoneService(_session); } else if (className.Equals("Portal")) { service = new PortalService(_session); } else if (className.Equals("com.liferay.portal.model.Portlet")) { service = new PortletService(_session); } else if (className.Equals("com.liferay.portal.model.PortletPreferences")) { service = new PortletPreferencesService(_session); } else if (className.Equals("com.liferay.portal.model.Repository")) { service = new RepositoryService(_session); } else if (className.Equals("com.liferay.portal.model.ResourcePermission")) { service = new ResourcePermissionService(_session); } else if (className.Equals("com.liferay.portal.model.Role")) { service = new RoleService(_session); } else if (className.Equals("com.liferay.portal.model.Team")) { service = new TeamService(_session); } else if (className.Equals("com.liferay.portal.model.UserGroup")) { service = new UserGroupService(_session); } else if (className.Equals("com.liferay.portal.model.UserGroupGroupRole")) { service = new UserGroupGroupRoleService(_session); } else if (className.Equals("com.liferay.portal.model.UserGroupRole")) { service = new UserGroupRoleService(_session); } else if (className.Equals("com.liferay.portlet.wiki.model.WikiNode")) { service = new WikiNodeService(_session); } else if (className.Equals("com.liferay.portlet.wiki.model.WikiPage")) { service = new WikiPageService(_session); } return(service); }
protected void Page_Load(object sender, EventArgs e) { if (this.IsAsyncRequest) { SearchCriterion.SetOrder("CreateDate"); SearchCriterion.SetOrder("SortIndex"); ents = SysRoleRule.FindAll(SearchCriterion); this.PageState.Add("RoleList", ents); } SysRole ent = null; switch (this.RequestAction) { case RequestActionEnum.Update: ent = this.GetMergedData <SysRole>(); ent.SaveAndFlush(); this.SetMessage("保存成功!"); break; case RequestActionEnum.Create: ent = this.GetPostedData <SysRole>(); ent.CreateAndFlush(); this.SetMessage("新建成功!"); break; case RequestActionEnum.Delete: ent = this.GetTargetData <SysRole>(); ent.DeleteAndFlush(); this.SetMessage("删除成功!"); break; case RequestActionEnum.Custom: if (RequestActionString == "refreshsys") { PortalService.RefreshSysModules(); SetMessage("操作成功!"); } else if (RequestActionString == "getusers") { string uids = ""; string names = ""; using (new SessionScope()) { ent = SysRole.Find(this.RequestData.Get <string>("id")); if (ent.User.Count > 0) { SysUser[] usrs = ent.User.ToArray(); foreach (SysUser usr in usrs) { uids += usr.UserID + ","; names += usr.Name + ","; } } } uids = uids.TrimEnd(','); names = names.TrimEnd(','); this.PageState.Add("UserId", uids); this.PageState.Add("UserName", names); } else if (RequestActionString == "setusers") { string roleId = this.RequestData.Get <string>("id"); string userIds = this.RequestData.Get <string>("userids"); DataHelper.ExecSql("delete from SysUserRole where RoleId='" + roleId + "'"); string insertTpl = "insert into SysUserRole values ('{0}','" + roleId + "')"; string sql = ""; string[] users = userIds.Split(','); foreach (string user in users) { if (user != "") { sql += string.Format(insertTpl, user); } } if (sql.Trim() != "") { DataHelper.ExecSql(sql); } } break; } SysRoleType[] roleTypes = SysRoleTypeRule.FindAll(); this.PageState.Add("RoleTypeList", roleTypes); }
protected void Page_Load(object sender, EventArgs e) { // 登出页面 PortalService.Logout(); }