Пример #1
0
        public static ADConfig ADSettings()
        {
            ADConfig cfg = new ADConfig();

            GetConfig().Bind("AppSettings:ActiveDirectory", cfg);
            return(cfg);
        }
Пример #2
0
 public AppPropertyService(IRepositoryFactory repositoryFactory, IOptions <ADConfig> adOptions,
                           IOptions <BitrixConfig> bitrixOptions,
                           IOptions <OnlyOfficeConfig> onlyOfficeOptions, IOptions <TimesheetConfig> timesheetOptions) : base(repositoryFactory)
 {
     _timesheetConfig  = timesheetOptions.Value ?? throw new ArgumentNullException(nameof(timesheetOptions));
     _adConfig         = adOptions.Value ?? throw new ArgumentNullException(nameof(adOptions));
     _bitrixConfig     = bitrixOptions.Value ?? throw new ArgumentNullException(nameof(bitrixOptions));
     _onlyOfficeConfig = onlyOfficeOptions.Value ?? throw new ArgumentNullException(nameof(onlyOfficeOptions));
 }
Пример #3
0
 public ADSyncJob(IOptions <ADConfig> adConfigOptions, IHttpContextAccessor httpContextAccessor, DbContextOptions <RPCSContext> dbContextOptions, IMemoryCache memoryCache, ILogger <ADSyncJob> logger)
 {
     _adConfig            = adConfigOptions.Value;
     _adConfigOptions     = adConfigOptions;
     _httpContextAccessor = httpContextAccessor;
     _dbContextOptions    = dbContextOptions;
     _memoryCache         = memoryCache;
     _logger = logger;
 }
Пример #4
0
 public QuartzHostedService(
     ISchedulerFactory schedulerFactory,
     IJobFactory jobFactory, IOptions <ADConfig> adOptions, IOptions <BitrixConfig> bitrixOptions, IOptions <TimesheetConfig> timesheetOptions)
 {
     _schedulerFactory = schedulerFactory;
     _jobFactory       = jobFactory;
     _timesheetConfig  = timesheetOptions.Value ?? throw new ArgumentNullException(nameof(timesheetOptions));
     _adConfig         = adOptions.Value ?? throw new ArgumentNullException(nameof(adOptions));
     _bitrixConfig     = bitrixOptions.Value ?? throw new ArgumentNullException(nameof(bitrixOptions));
 }
Пример #5
0
        public void ConfigureAzureAD()
        {
            var azureOptions = new ADConfig();

            configuration.Bind("AzureAD", azureOptions);
            clientId         = azureOptions.ClientId;
            clientSecret     = azureOptions.ClientSecret;
            tenantId         = azureOptions.TenantId;
            aadInstance      = azureOptions.Instance;
            graphResource    = azureOptions.GraphResource;
            graphAPIEndpoint = $"{azureOptions.GraphResource}{azureOptions.GraphResourceEndPoint}";
            authority        = $"{aadInstance}{tenantId}";
        }
Пример #6
0
 public HomeController(IADManager aDManager, IOptions <ADConfig> adConfig)
 {
     _manager = aDManager;
     _options = adConfig.Value;
 }
Пример #7
0
 public SyncWithADTask(IEmployeeService employeeService, IOptions <ADConfig> adOptions)
     : base()
 {
     _employeeService = employeeService;
     _adConfig        = adOptions.Value;
 }
Пример #8
0
        public ActionResult Save(SaveADConfig savemodel)
        {
            var gamelist = _mobilGameTask.GetAll(null, "").ToSelectList(c => c.ID.ToString(), c => c.GameName);

            gamelist.Insert(1, new SelectListItem
            {
                Selected = false,
                Text     = "不属于任何游戏",
                Value    = "0"
            });
            gamelist.Insert(0, new SelectListItem
            {
                Selected = true,
                Text     = "请选择",
                Value    = string.Empty
            });
            ViewData["gamelist"] = gamelist;
            ViewData["AdType"]   = AdTypeEnum.Flash.ToSelectList();
            var placelist = ADConfigPlaceEnum.HomeLunBo.ToSelectList();

            placelist.Insert(0, new SelectListItem
            {
                Selected = true,
                Text     = "请选择",
                Value    = string.Empty,
            });
            ViewData["placelist"] = placelist;
            if (ModelState.IsValid)
            {
                string errMsg, savePath = string.Empty;

                if (savemodel.ID == null)
                {
                    if (Request.Files.Count != 0 && Request.Files[0].ContentLength != 0)
                    {
                        if (!UploadService.UploadFile(Request.Files[0], out savePath, out errMsg))
                        {
                            return(AlertMsg(errMsg, Request.UrlReferrer.PathAndQuery));
                        }
                    }

                    var model = new ADConfig
                    {
                        Title        = savemodel.Title,
                        CreateDate   = DateTime.Now,
                        AdPath       = savePath,
                        Link         = savemodel.Link,
                        AdType       = savemodel.AdType,
                        Sort         = savemodel.Sort,
                        Place        = savemodel.Place,
                        CreatePeople = LogOnUserName,
                    };
                    _lunBoAdTask.Add(model);
                }
                else
                {
                    var model = _lunBoAdTask.GetById((int)savemodel.ID);
                    if (Request.Files.Count != 0 && Request.Files[0].ContentLength != 0)
                    {
                        if (!UploadService.UploadFile(Request.Files[0], out savePath, out errMsg))
                        {
                            return(AlertMsg(errMsg, Request.UrlReferrer.PathAndQuery));
                        }

                        model.AdPath = savePath;
                    }


                    if (model == null)
                    {
                        return(AlertMsg("参数错误", HttpContext.Request.UrlReferrer.PathAndQuery));
                    }


                    model.Link   = savemodel.Link;
                    model.Title  = savemodel.Title;
                    model.AdType = savemodel.AdType;
                    model.Place  = savemodel.Place;
                    model.Sort   = savemodel.Sort;
                    _lunBoAdTask.Update(model);
                }
                return(AlertMsg("保存成功", HttpContext.Request.UrlReferrer.PathAndQuery));
            }
            return(View(savemodel));
        }
Пример #9
0
    private void PhaseConfig(string config)
    {
        isLoad = true;
        string[]        ary      = config.Split('\n');
        List <ADConfig> selfList = new List <ADConfig>();

        foreach (string str in ary)
        {
            string[] ary2 = str.Split('\t');
            if (ary2[0] == platform.ToString() && ary2.Length == 5)
            {
                ADConfig ad = new ADConfig();
                ad.platfrom   = platform;
                ad.image      = ary2[1];
                ad.url        = ary2[2];
                ad.start_show = int.Parse(ary2[3]);
                ad.admob_show = int.Parse(ary2[4]);
                if (ad.url.IndexOf("http") >= 0)
                {
                    if (ad.start_show == 1)//内置广告
                    {
                        selfList.Add(ad);
                    }
                }
                else
                {
                    admob_show = ad.admob_show == 1;
                }
            }
        }
        if (selfList.Count > 0)
        {
            selfAD = selfList[Random.Range(0, selfList.Count)];
            if (selfAD.image.IndexOf("http") >= 0)//网络资源
            {
                StartCoroutine(LoadImage(selfAD.image));
            }
            else
            {
                Sprite img = Resources.Load("image/ad/" + selfAD.image.Split('.')[0], typeof(Sprite)) as Sprite;
                if (img)
                {
                    transform.GetChild(0).gameObject.SetActive(true);
                    transform.GetChild(0).GetComponent <Image>().sprite = img;
                }
                else
                {
                    Debug.Log("image/ad/" + selfAD.image.Split('.')[0] + "load Error");
                }
            }
        }
        else
        {
            Quit();
        }


#if UNITY_IOS && !UNITY_EDITOR
        if (UnityEngine.iOS.ADBannerView.IsAvailable(UnityEngine.iOS.ADBannerView.Type.Banner))
        {
            bannerInventor = ADInventor.iad;
        }
        else
        {
            bannerInventor = ADInventor.admob;
        }
        if (UnityEngine.iOS.ADInterstitialAd.isAvailable)
        {
            interstitialInventor = ADInventor.iad;
        }
        else
        {
            interstitialInventor = ADInventor.admob;
        }
#else
        bannerInventor       = ADInventor.admob;
        interstitialInventor = ADInventor.admob;
#endif
    }
Пример #10
0
 public void Update(ADConfig model)
 {
     _dao.Update(model);
 }
Пример #11
0
 public void Add(ADConfig model)
 {
     _dao.Add(model);
 }
Пример #12
0
    private void PhaseConfig(string config)
    {
        isLoad = true;
        string[] ary = config.Split('\n');
        List<ADConfig> selfList = new List<ADConfig>();
        foreach (string str in ary)
        {
            string[] ary2 = str.Split('\t');
            if (ary2[0] == platform.ToString() && ary2.Length == 5)
            {
                ADConfig ad = new ADConfig();
                ad.platfrom = platform;
                ad.image = ary2[1];
                ad.url = ary2[2];
                ad.start_show = int.Parse(ary2[3]);
                ad.admob_show = int.Parse(ary2[4]);
                if (ad.url.IndexOf("http") >= 0)
                {
                    if (ad.start_show == 1)//内置广告
                        selfList.Add(ad);
                }
                else
                    admob_show = ad.admob_show == 1;
            }
        }
        if (selfList.Count > 0)
        {
            selfAD = selfList[Random.Range(0, selfList.Count)];
            if (selfAD.image.IndexOf("http") >= 0)//网络资源
            {
                StartCoroutine(LoadImage(selfAD.image));
            }
            else
            {
                Sprite img = Resources.Load("image/ad/" + selfAD.image.Split('.')[0], typeof(Sprite)) as Sprite;
                if (img)
                {
                    transform.GetChild(0).gameObject.SetActive(true);
                    transform.GetChild(0).GetComponent<Image>().sprite = img;
                }
                else
                    Debug.Log("image/ad/" + selfAD.image.Split('.')[0] + "load Error");
            }
        }
        else
            Quit();

        #if UNITY_IOS && !UNITY_EDITOR
        if(UnityEngine.iOS.ADBannerView.IsAvailable(UnityEngine.iOS.ADBannerView.Type.Banner))
            bannerInventor = ADInventor.iad;
        else
            bannerInventor = ADInventor.admob;
        if(UnityEngine.iOS.ADInterstitialAd.isAvailable)
            interstitialInventor = ADInventor.iad;
        else
            interstitialInventor = ADInventor.admob;
        #else
        bannerInventor = ADInventor.admob;
        interstitialInventor = ADInventor.admob;
        #endif
    }
Пример #13
0
        public string Authenticate(AuthenticateModel authData)
        {
            string ret = "";

            if (string.IsNullOrEmpty(authData.username) || string.IsNullOrEmpty(authData.password))
            {
                return(string.Format("The {0} can not be empty", string.IsNullOrEmpty(authData.username)?"user name":"password"));
            }

            Tenant tn = null;

            if (!string.IsNullOrEmpty(authData.tenant))
            {
                tn = dbCtx.Tenants.SingleOrDefault(t => t.Name.ToLower().Equals(authData.tenant.ToLower()));
                if (tn == null) // nonexisting tenant name provided
                {
                    return(string.Format("Tenant {0} not found", authData.tenant));
                }
            }

            // in this example application, we do not use the full ActiveDirectory identity features.
            // That, plus synchronizing the users in Izenda configuration DB and in the
            // authorization application DB, allows just to validate the user against the Active Directory.
            // In case you dont want to synchronize the users and/or not using the authorization DB
            // while still want to use the Active Directory - you need to implement
            // the full - featured identity mechanizm with ActiveDirectory support.
            //
            // So, here we just validate the active directory user if we set to use the active directory.
            ADUser   adUser = null;
            ADConfig adCfg  = Utilities.ADSettings();

            if (adCfg.UseActiveDirectory)
            {
                adUser = ADUtilities.ValidateADUser(authData.username, authData.password, adCfg);
            }

            if (adCfg.UseActiveDirectory && !adUser.IsValid)
            {
                return(string.Format("The user {0} is invalid or not found in the Active Directory.\nError:{1}", authData.username, adUser.Reserved));
            }

            // Check if the user exists in the authentication database.
            // For the Active Directory, we still will verify this too, even in case the user is valid on A.D.
            int?tnId = null;

            if (tn != null)
            {
                tnId = tn.Id;
            }
            AspNetUser user = dbCtx.AspNetUsers.SingleOrDefault(
                u => u.UserName.ToLower().Equals(authData.username.ToLower()) &&
                u.TenantId == tnId);

            // Tip.
            // At this point, if the AD user exists/valid (adUser.IsValid == true), it is possible to automatically
            // create the AD user in Izenda DB, if you'd like to. You can implement something like the following:
            // if ((adCfg.UseActiveDirectory && adUser.IsValid) && user == null) {
            //     user = (cast/retrieve to the AspNetUser)CreateUser(new CreateUserBindingModel { FirstName = "", LastName = "", Tenant = authData.tenant, Password = authData.password, IsAdmin = false });
            // }
            // See the article "Few aspects of Active Directory authentication" at Izenda Confluence board for details
            // as of now, we expect the A.D. user to exist in the database.
            if (user == null)
            {
                return(string.Format("User {0} not found {1}", authData.username, tn == null ? "":"for the tenant " + tn.Name));
            }

            if (!VerifyPassword(authData.password, user))
            {
                return("The password is incorrect");
            }

            // our sample (custom authenticacion) database does not have the user status flag.
            // we will use Izenda to find out if the user is active or not.
            string adminToken = IzendaTokenAuthorization.GetIzendaAdminToken();
            Task <IzendaBoundary.Models.UserDetail> getUser = IzendaUtilities.GetIzendaUserByTenantAndName(user.UserName, tn == null?null:tn.Name, adminToken);

            IzendaBoundary.Models.UserDetail userDetails = getUser.Result;
            if (userDetails == null)
            {
                return(string.Format("The user {0} not found in [Izenda database]. Contact your administrator please", user.UserName));
            }
            else if (!userDetails.Active)
            {
                return(string.Format("The user {0} was found but it is not active. Contact your administrator please", user.UserName));
            }
            return(ret);
        }