Пример #1
0
        private async Task <uint?> GetNextIdAsync(CommandContext context, string userInput, CancellationToken cancellationToken = default)
        {
            if (string.IsNullOrWhiteSpace(userInput))
            {
                GroupConfig groupConfig = await _groupConfigStore.GetGroupConfigAsync(context.Message.RecipientID, cancellationToken).ConfigureAwait(false);

                if (groupConfig == null || groupConfig.CurrentGuesswhatGameID == null)
                {
                    await context.ReplyTextAsync("(n) I do not know the next GW game ID for this group.\r\n" +
                                                 $"Use `{context.Options.Prefix}next <ID>` to set it, or `{context.Options.Prefix}next continue` to take it from AP", cancellationToken).ConfigureAwait(false);

                    return(null);
                }
                else
                {
                    return(GetNextExistingID(groupConfig.CurrentGuesswhatGameID.Value));
                }
            }
            if (!uint.TryParse(userInput, out uint nextID))
            {
                await context.ReplyTextAsync($"(n) `{userInput}` is not a correct game ID!", cancellationToken).ConfigureAwait(false);

                return(null);
            }
            else
            {
                return(nextID);
            }
        }
Пример #2
0
        private T _CloneOneObject(int i, List <T> list, Action <int, T> CallBack, GroupConfig config)
        {
            T t = null;

            if (i < list.Count)
            {
                t = list[i];
            }
            else
            {
                if (config.tempT == null)
                {
                    t = (T)((Component)FEngineManager.PoolObject(config.resName, config.parent.gameObject));
                }
                else
                {
                    t = FEngineManager.CloneObject <T>(config.tempT.gameObject, null);
                }
                list.Add(t);
            }

            t.gameObject.SetActive(true);

            if (config.toolData != null)
            {
                config.toolData.HandTool(i, t);
            }

            if (CallBack != null)
            {
                CallBack(i, t);
            }
            return(t);
        }
Пример #3
0
        private ICredentials InitCredentials(ClientSecurityConfig securityConfig, GroupConfig groupConfig)
        {
            var credentials = securityConfig.GetCredentials();

            if (credentials == null)
            {
                var credentialsClassname = securityConfig.GetCredentialsClassName();
                if (credentialsClassname != null)
                {
                    try
                    {
                        var type = Type.GetType(credentialsClassname, true, false);
                        if (type != null)
                        {
                            credentials = Activator.CreateInstance(type) as ICredentials;
                        }
                    }
                    catch (Exception e)
                    {
                        throw ExceptionUtil.Rethrow(e);
                    }
                }
            }
            if (credentials == null)
            {
                credentials = new UsernamePasswordCredentials(groupConfig.GetName(), groupConfig.GetPassword());
            }
            return(credentials);
        }
Пример #4
0
        public async Task <GroupConfig> GetGroupConfigAsync(uint groupID, CancellationToken cancellationToken = default)
        {
            await _lock.WaitAsync(cancellationToken).ConfigureAwait(false);

            try
            {
                // check cache first
                GroupConfig result = _cache.Get(groupID);
                if (result != null)
                {
                    _log.LogTrace("Group config for group {GroupID} found in cache", groupID);
                    return(result);
                }

                // get from DB
                _log.LogTrace("Retrieving group config for group {GroupID} from database", groupID);
                result = await _groupConfigsCollection.Find(dbConfig => dbConfig.ID == groupID).FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false);

                // if not found, return default data
                if (result == null)
                {
                    _log.LogTrace("Group config for group {GroupID} not found, creating new with defaults", groupID);
                    result = new GroupConfig(groupID);
                }

                _cache.AddOrReplace(result);
                return(result);
            }
            finally
            {
                _lock.Release();
            }
        }
Пример #5
0
        public static bool IsEditable(this GroupConfig value)
        {
            var fi = value.GetType().GetField(value.ToString());
            var dA = fi.GetCustomAttribute(typeof(EditableAttribute)) as EditableAttribute;

            return(dA?.AllowEdit ?? false);
        }
Пример #6
0
 public static GroupConfig ReadGroup()
 {
     Logs.LogOut("[Config]读取群设置");
     try
     {
         GroupConfig config = JsonConvert.DeserializeObject <GroupConfig>
                                  (File.ReadAllText(ConfigFile.GroupConfig.FullName));
         if (config.Groups == null)
         {
             IMinecraft_QQ.ShowMessageCall?.Invoke("Group.json配置文件读取发送错误,已经重写");
             config.Groups = new();
             ConfigWrite.Group();
         }
         foreach (var item in config.Groups)
         {
             if (item.Value.IsMain == true)
             {
                 IMinecraft_QQ.Main.GroupSetMain = item.Key;
                 break;
             }
         }
         return(config);
     }
     catch (Exception e)
     {
         IMinecraft_QQ.ShowMessageCall?.Invoke("快去检查你的Group.json文件语法,用的是json就要遵守语法!");
         Logs.LogError(e);
         return(new GroupConfig());
     }
 }
Пример #7
0
    public void Set(FriendInfo fi)
    {
        CurFI = fi;

        Name.text = CurFI.Name;

        int        RoleID = Math.Max(fi.RoleID, 1);
        RoleConfig rc     = null;

        if (CsvConfigTables.Instance.RoleCsvDic.TryGetValue(RoleID, out rc))
        {
            HeadPortrait.spriteName = rc.Portrait;
        }

        StageConfig sc = null;

        CsvConfigTables.Instance.StageCsvDic.TryGetValue(CurFI.StageProgress, out sc);
        if (sc != null)
        {
            ChapterConfig cc = null;
            CsvConfigTables.Instance.ChapterCsvDic.TryGetValue(sc.ChapterID, out cc);

            GroupConfig gc = null;
            CsvConfigTables.Instance.GroupCsvDic.TryGetValue(sc.GroupID, out gc);
            if (cc != null && gc != null)
            {
                Stage.text = StringBuilderTool.ToInfoString(cc.Name, "-", gc.Name, "-", sc.Name);
            }
        }
    }
Пример #8
0
        public GroupList()
        {
            InitializeComponent();

            GroupConfig.Load();
            m_list.Items.AddRange(GroupInfoManager.GetGroupArray());
        }
Пример #9
0
            public List <GroupConfig> GetAllModels()
            {
                if (Doc == null)
                {
                    return(null);
                }

                List <GroupConfig> groupConfigs = new List <GroupConfig>();

                var parts = Doc.GetElementbyId("nav-groupIllustration-table").SelectNodes("tbody/tr");

                foreach (var part in parts)
                {
                    var         cell           = part.SelectNodes("td");
                    GroupConfig newGroupConfig = new GroupConfig
                    {
                        GLGR          = cell[0].InnerText,
                        Ilustration   = cell[1].InnerText,
                        IlustrationId = Regex.Match(part.Attributes["url"].Value, @"illustrationId=(.*?)&").Groups[1].Value,
                        Name          = cell[2].InnerText,
                        Notice        = cell[3].InnerText == "&nbsp;" ? null : cell[3].InnerText,
                        Inputs        = cell[4].InnerText == "&nbsp;" ? null : cell[4].InnerText,
                    };
                    groupConfigs.Add(newGroupConfig);
                }
                return(groupConfigs);
            }
Пример #10
0
    /// <summary> 获取解锁条件文字描述 </summary>
    public string GetUnLockConditionDes()
    {
        switch (UnLockType)
        {
        default:
        case 0:
            return("");

        case 1:
            string[] TempSplit = UnLockCondition.Split('_');
            if (TempSplit.Length == 3)
            {
                ChapterConfig cc = null;
                if (CsvConfigTables.Instance.ChapterCsvDic.TryGetValue(int.Parse(TempSplit[0]), out cc))
                {
                    GroupConfig gc = null;
                    if (CsvConfigTables.Instance.GroupCsvDic.TryGetValue(int.Parse(TempSplit[1]), out gc))
                    {
                        StageConfig sc = null;
                        if (CsvConfigTables.Instance.StageCsvDic.TryGetValue(int.Parse(TempSplit[2]), out sc))
                        {
                            return(StringBuilderTool.ToInfoString("通关 " + cc.Name, "-", gc.Name, "-" + sc.Name));
                        }
                    }
                }
            }
            return("解锁条件数据格式错误!");

        case 2:
            return("充值" + float.Parse(UnLockCondition) + "元");
        }
    }
Пример #11
0
        /// <summary>
        /// 动态处理程序
        /// </summary>
        /// <param name="groupMember"></param>
        /// <param name="eventArgs"></param>
        private void GroupMemberActivityModule_After(GroupMember groupMember, CommonEventArgs eventArgs)
        {
            ActivityService activityService = new ActivityService();

            if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                //生成动态
                if (groupMember == null)
                {
                    return;
                }
                var group = new GroupService().Get(groupMember.GroupId);
                if (group == null)
                {
                    return;
                }
                //生成Owner为群组的动态
                Activity actvityOfGroup = Activity.New();
                actvityOfGroup.ActivityItemKey       = ActivityItemKeys.Instance().CreateGroupMember();
                actvityOfGroup.ApplicationId         = GroupConfig.Instance().ApplicationId;
                actvityOfGroup.IsOriginalThread      = true;
                actvityOfGroup.IsPrivate             = !group.IsPublic;
                actvityOfGroup.UserId                = groupMember.UserId;
                actvityOfGroup.ReferenceId           = group.GroupId;
                actvityOfGroup.ReferenceTenantTypeId = TenantTypeIds.Instance().Group();
                actvityOfGroup.SourceId              = groupMember.UserId;
                actvityOfGroup.TenantTypeId          = TenantTypeIds.Instance().User();
                actvityOfGroup.OwnerId               = group.GroupId;
                actvityOfGroup.OwnerName             = group.GroupName;
                actvityOfGroup.OwnerType             = ActivityOwnerTypes.Instance().Group();

                activityService.Generate(actvityOfGroup, false);

                //生成Owner为用户的动态
                Activity actvityOfUser = Activity.New();
                actvityOfUser.ActivityItemKey        = ActivityItemKeys.Instance().JoinGroup();
                actvityOfUser.ApplicationId          = actvityOfGroup.ApplicationId;
                actvityOfUser.HasImage               = actvityOfGroup.HasImage;
                actvityOfUser.HasMusic               = actvityOfGroup.HasMusic;
                actvityOfUser.HasVideo               = actvityOfGroup.HasVideo;
                actvityOfUser.IsOriginalThread       = actvityOfGroup.IsOriginalThread;
                actvityOfUser.IsPrivate              = actvityOfGroup.IsPrivate;
                actvityOfUser.UserId                 = actvityOfGroup.UserId;
                actvityOfUser.ReferenceId            = actvityOfGroup.ReferenceId;
                actvityOfGroup.ReferenceTenantTypeId = actvityOfGroup.ReferenceTenantTypeId;
                actvityOfUser.SourceId               = actvityOfGroup.SourceId;

                actvityOfUser.TenantTypeId = actvityOfGroup.TenantTypeId;
                actvityOfUser.OwnerId      = groupMember.UserId;
                actvityOfUser.OwnerName    = groupMember.User.DisplayName;
                actvityOfUser.OwnerType    = ActivityOwnerTypes.Instance().User();
                activityService.Generate(actvityOfUser, false);
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Delete()) //删除动态
            {
                activityService.DeleteSource(TenantTypeIds.Instance().User(), groupMember.UserId);
            }
        }
Пример #12
0
    public void Set(GroupConfig gc)
    {
        ThemeID = gc.GroupID;

        Name.text        = gc.Name;
        Icon.mainTexture = Resources.Load(StringBuilderTool.ToInfoString("MagicCardTheme/", gc.ThemePic)) as Texture;

        StatisHoldCnt();
    }
Пример #13
0
        /// <summary>
        /// Renders an Mvc Core Bootstrap button group.
        /// </summary>
        /// <param name="htmlHelper">Html helper instance.</param>
        /// <param name="configAction">Action that implements button group configuration.</param>
        /// <returns>Button group html markup.</returns>
        public static IHtmlContent MvcCoreBootstrapButtonGroup(this IHtmlHelper htmlHelper,
                                                               Action <MvcCoreBootstrapButtonGroupBuilder> configAction)
        {
            GroupConfig config = new GroupConfig();

            configAction(new MvcCoreBootstrapButtonGroupBuilder(config));

            return(new GroupRenderer().Render(config));
        }
Пример #14
0
        public List <GroupConfig> GetParts(GroupConfig config)
        {
            string action      = "/group.action?";
            string constParams = "catalogMarket=RDW&episType=152&lang=ru&localMarketOnly=true&ordinalNumber=2&partDetailsMarket=RDW&startup=false&mode=K00U0RUXX&upds=1381";
            string partsUrl    = string.Format(path + action + constParams + "&familyKey={0}&modelYear={1}&maingroup={2}&restriction1={3}",
                                               config.ModelConfig.FamilyKey, config.ModelConfig.Year, config.MainGroup, config.ModelConfig.RestrictKey);
            ParsingPart newParsingGroups = new ParsingPart(partsUrl);

            return(newParsingGroups.GetAllModels());
        }
Пример #15
0
        public bool HasFlag(GroupConfig flag)
        {
            if (Flags == null)
            {
                Flags = 0;
            }
            var f = (GroupConfig)Flags;

            return(f.HasFlag(flag));
        }
Пример #16
0
        public ActionResult GetDetails(GroupConfig config)
        {
            var responce = _vehicleService.GetDetails(config);

            if (responce.Count == 0)
            {
                return(NotFound());
            }
            return(Ok(responce));
        }
Пример #17
0
        public List <DetailConfing> GetDetails(GroupConfig config)
        {
            string action      = "/image-board.action?";
            string constParams = "catalogMarket=RDW&episType=152&lang=ru&localMarketOnly=true&ordinalNumber=2&partDetailsMarket=RDW&startup=false&mode=K00U0DEXX&upds=1381";
            string detailUrl   = string.Format(path + action + constParams + "&familyKey={0}&modelYear={1}&maingroup={2}&restriction1={3}&illustrationId={4}",
                                               config.ModelConfig.FamilyKey, config.ModelConfig.Year, config.MainGroup, config.ModelConfig.RestrictKey, config.IlustrationId);
            ParsingDetail newParsingGroups = new ParsingDetail(detailUrl);

            return(newParsingGroups.GetAllModels());
        }
Пример #18
0
        public void RemoveFlag(GroupConfig flag)
        {
            if (Flags == null)
            {
                Flags = 0;
            }
            var f = (GroupConfig)Flags;

            f    &= ~flag;
            Flags = (long)f;
        }
Пример #19
0
 public void Configure(GroupConfig groupConfig, IDictionary <string, string> properties)
 {
     if (!properties.TryGetValue("username", out _username))
     {
         _username = groupConfig.GetName();
     }
     if (!properties.TryGetValue("password", out _password))
     {
         _password = groupConfig.GetPassword();
     }
 }
Пример #20
0
        public void AddFlag(GroupConfig flag)
        {
            if (Flags == null)
            {
                Flags = 0;
            }
            var f = (GroupConfig)Flags;

            f     = f | flag;
            Flags = (long)f;
        }
        /// <summary>
        /// Configures a group in the toolbar.
        /// </summary>
        /// <param name="configAction">Configuration action</param>
        /// <returns>The toolbar builder instance.</returns>
        public MvcCoreBootstrapButtonToolbarBuilder Group(Action <MvcCoreBootstrapButtonGroupBuilder> configAction)
        {
            GroupConfig group = new GroupConfig();
            MvcCoreBootstrapButtonGroupBuilder builder = new MvcCoreBootstrapButtonGroupBuilder(group);

            this.CheckNullPar(configAction, () => nameof(configAction));
            configAction(builder);
            _config.Groups.Add(group);

            return(this);
        }
Пример #22
0
        public static bool GetDefaultValue(this GroupConfig value)
        {
            var fi = value.GetType().GetField(value.ToString());
            var dA = fi.GetCustomAttribute(typeof(DefaultValueAttribute)) as DefaultValueAttribute;

            if (dA?.Value == null)
            {
                return(false);
            }
            return((bool)dA.Value);
        }
Пример #23
0
        public static QuestionAttribute GetInfo(this GroupConfig value)
        {
            var fieldInfo = value.GetType().GetField(value.ToString());

            var qA = fieldInfo.GetCustomAttributes(
                typeof(QuestionAttribute), false) as QuestionAttribute[];

            if (qA == null)
            {
                return(null);
            }
            return((qA.Length > 0) ? qA[0] : null);
        }
Пример #24
0
        public static GroupConfig LoadDefaults()
        {
            GroupConfig result = GroupConfig.Update;

            foreach (GroupConfig flag in Enum.GetValues(typeof(GroupConfig)))
            {
                if (flag.GetDefaultValue())
                {
                    result |= flag;
                }
            }
            return(result);
        }
        public GroupConfig GetGroupConfig(tblGroupDetail objGroupDetails)
        {
            GroupConfig objGroupConfig = new GroupConfig();

            using (var context = new CommonDBContext())
            {
                objGroupConfig.CityName           = context.tblCities.Where(x => x.CityId == objGroupDetails.City).Select(y => y.CityName).FirstOrDefault();
                objGroupConfig.CategoryName       = context.tblCategories.Where(x => x.CategoryId == objGroupDetails.RetailCategory).Select(y => y.CategoryName).FirstOrDefault();
                objGroupConfig.BillingPartnerName = context.tblBillingPartners.Where(x => x.BillingPartnerId == objGroupDetails.BillingPartner).Select(y => y.BillingPartnerName).FirstOrDefault();
                objGroupConfig.BillingSystemName  = context.BOTS_TblBillingPartnerProduct.Where(x => x.BillingPartnerProductId == objGroupDetails.BillingProduct).Select(y => y.BillingPartnerProductName).FirstOrDefault();
                objGroupConfig.SourceByName       = context.tblSourcedBies.Where(x => x.SourcedbyId == objGroupDetails.SourcedBy).Select(y => y.SourcedbyName).FirstOrDefault();
                objGroupConfig.CSAssignedName     = context.tblRMAssigneds.Where(x => x.RMAssignedId == objGroupDetails.RMAssigned).Select(y => y.RMAssignedName).FirstOrDefault();
            }
            return(objGroupConfig);
        }
        private IHtmlContent Toolbar(GroupConfig config)
        {
            TagBuilder    toolbar       = new TagBuilder("div");
            GroupRenderer groupRenderer = new GroupRenderer();

            toolbar.AddCssClass("btn-toolbar");
            toolbar.Attributes.Add("role", "toolbar");
            foreach (GroupConfig group in config.Groups)
            {
                group.ButtonSize = config.ButtonSize;
                group.State      = config.State;
                toolbar.InnerHtml.AppendHtml(groupRenderer.Render(group));
            }

            return(toolbar);
        }
Пример #27
0
        /// <summary>
        /// 设置/取消管理员通知处理程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void SetManagerNoticeEventModule_After(GroupMember sender, CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType != EventOperationType.Instance().SetGroupManager() && eventArgs.EventOperationType != EventOperationType.Instance().CancelGroupManager())
            {
                return;
            }

            GroupService groupService = new GroupService();
            GroupEntity  entity       = groupService.Get(sender.GroupId);

            if (entity == null)
            {
                return;
            }

            User senderUser = DIContainer.Resolve <IUserService>().GetFullUser(sender.UserId);

            if (senderUser == null)
            {
                return;
            }

            NoticeService noticeService = DIContainer.Resolve <NoticeService>();

            Notice notice = Notice.New();

            notice.UserId             = sender.UserId;
            notice.ApplicationId      = GroupConfig.Instance().ApplicationId;
            notice.TypeId             = NoticeTypeIds.Instance().Hint();
            notice.LeadingActorUserId = 0;
            notice.LeadingActor       = string.Empty;
            notice.LeadingActorUrl    = string.Empty;
            notice.RelativeObjectId   = sender.GroupId;
            notice.RelativeObjectName = StringUtility.Trim(entity.GroupName, 64);
            notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().GroupHome(entity.GroupKey));

            if (eventArgs.EventOperationType == EventOperationType.Instance().SetGroupManager())
            {
                notice.TemplateName = NoticeTemplateNames.Instance().SetGroupManager();
            }
            else
            {
                notice.TemplateName = NoticeTemplateNames.Instance().CannelGroupManager();
            }
            noticeService.Create(notice);
        }
Пример #28
0
        private async Task <bool> SaveGroupConfigAsync(IWolfClient client, uint groupID, uint currentID, CancellationToken cancellationToken = default)
        {
            try
            {
                GroupConfig groupConfig = await _groupConfigStore.GetGroupConfigAsync(groupID, cancellationToken).ConfigureAwait(false);

                groupConfig.CurrentGuesswhatGameID = currentID;
                await _groupConfigStore.SetGroupConfigAsync(groupConfig, false, cancellationToken).ConfigureAwait(false);

                return(true);
            }
            catch (Exception ex) when(ex.LogAsError(_log, "Failed saving group config for group {GroupID} in the database", groupID))
            {
                await client.SendGroupTextMessageAsync(groupID, "/alert Failed saving group config in the database.", cancellationToken).ConfigureAwait(false);

                return(false);
            }
        }
Пример #29
0
 public static void AddCustomIdentityConfigs(this ModelBuilder modelBuilder, SiteSettings siteSettings)
 {
     GroupConfig.Build(modelBuilder);
     GroupRoleConfig.Build(modelBuilder);
     GroupChangeLogConfig.Build(modelBuilder);
     RoleClaimConfig.Build(modelBuilder);
     RoleConfig.Build(modelBuilder);
     UserChangeLogConfig.Build(modelBuilder);
     UserClaimConfig.Build(modelBuilder);
     UserLoginConfig.Build(modelBuilder);
     UserConfig.Build(modelBuilder);
     UserRoleConfig.Build(modelBuilder);
     UserTokenConfig.Build(modelBuilder);
     UserTokenStorageConfig.Build(modelBuilder);
     UserUsedPasswordConfig.Build(modelBuilder);
     UserGeolocationConfig.Build(modelBuilder);
     GeographicalDistanceConfig.Build(modelBuilder);
 }
Пример #30
0
        public static void ExitForm()
        {
            s_singleton.Invoke(new DoAction(delegate
            {
                GroupConfig.Save();

                Timer quitTimer    = new Timer();
                quitTimer.Interval = 500;
                quitTimer.Tick    += new EventHandler(quitTimer_Tick);
                quitTimer.Start();

                UserInfo[] users = UserInfoManager.GetUserArray();
                foreach (UserInfo user in users)
                {
                    OutgoingPackagePool.AddFirst(NetPackageGenerater.UserOffline(user.RemoteIP));
                }
            }));
        }