/// <summary> /// Authorizes the mobile phone number. /// </summary> /// <param name="mobilePhoneNumber">The mobile phone number.</param> /// <param name="countryName">Name of the country.</param> /// <returns></returns> public InfoAccumulator AuthorizeMobilePhoneNumber(string mobilePhoneNumber, CountryName countryName = CountryName.UK) { InfoAccumulator errors = new InfoAccumulator(); //validate debug mode if (IsInDebugMode(mobilePhoneNumber)) { return(errors); } CountInfo countInfo = MobilePhoneQueries.GetCurrentMobileCodeCountInfo(mobilePhoneNumber); //check whether can continue or not if (!CanGenerateCodeAndSendSms(countInfo, mobilePhoneNumber, errors)) { return(errors); } //generate code string code = GenerateAuthorizationCode(); //save phone number and generated code //we do not care whether this operation is succeeded or not (only put logs) and continue SaveGeneratedCodeAndPhoneNumber(mobilePhoneNumber, code, errors); string message = string.Format("Your authentication code is: {0}", code); //send sms and save it in DB //we do not care whether this operation is succeeded or not and continue SendSmsAndSave(mobilePhoneNumber, message, countryName, errors); return(errors); }
private static float ThingCountOnMap(ThingDef d) { if (!ThingCountOnMapCached.TryGetValue(d, out var countInfo)) { countInfo = new CountInfo(); ThingCountOnMapCached[d] = countInfo; } var ticks = Find.TickManager.TicksGame; if (Math.Abs(ticks - countInfo.TickUpdated) > UpdateDelayThingsCount) { float count = 0; var list = Find.CurrentMap.listerThings.ThingsInGroup(ThingRequestGroup.HaulableAlways); foreach (var thing in list) { if (!thing.Position.Fogged(thing.Map) && d == thing.def && (Settings.CountForbiddenItems || !thing.IsForbidden(Faction.OfPlayer))) { count += thing.stackCount; } } countInfo.Count = count; countInfo.TickUpdated = ticks; } return(countInfo.Count); }
public CountInfo PrepareToUpdate(SecurityInfo securityInfo, DateTimeOffset lastUpdateBrands, DateTimeOffset lastUpdateCatalogs, DateTimeOffset lastUpdateDirectories, DateTimeOffset lastUpdateProductDirections, DateTimeOffset lastUpdatePhotos, bool needLoadPhotos, long[] ids) { CountInfo result = null; if (ValidatePassword(securityInfo)) { IShapingBrands shapingBrands = new ShapingBrands(dataService, optionService); IShapingCatalogs shapingCatalogs = new ShapingCatalogs(dataService, optionService, priceService); IShapingDirectories shapingDirectories = new ShapingDirectories(dataService, optionService); IShapingProductDirections shapingProductDirections = new ShapingProductDirections(dataService, optionService); IShapingPhotos shapingPhotos = new ShapingPhotos(dataService, optionService); result = new CountInfo { CountBrands = shapingBrands.PrepareToUpdate(securityInfo.Login, lastUpdateBrands), CountCatalogs = shapingCatalogs.PrepareToUpdate(securityInfo.Login, lastUpdateCatalogs), CountDirectories = shapingDirectories.PrepareToUpdate(securityInfo.Login, lastUpdateDirectories), CountProductDirections = shapingProductDirections.PrepareToUpdate(securityInfo.Login, lastUpdateProductDirections), CountPhotos = needLoadPhotos ? shapingPhotos.PrepareToUpdate(securityInfo.Login, lastUpdatePhotos, ids) : 0, IsAuthorized = true }; } return(result); }
//1Cellだけの陸と海を除去 static private WorldDataConst.EachTerrainData[] fillGap(Vector2Int size, WorldDataConst.EachTerrainData[] tileMap) { for (int y = 0; y < size.y; y++) { for (int x = 0; x < size.x; x++) { // 隣接タイルが同じだったら浸食 int treatCount = 4; CountInfo countInfo = countSameCell(treatCount, size, tileMap, x, y); if ((y == 0) || (y == size.y - 1)) { countInfo.currentTile.type = WorldDataConst.TileType.SEA; } else if (countInfo.count == treatCount) { countInfo.currentTile.type = countInfo.diffType; } else if ((countInfo.currentTile.type == WorldDataConst.TileType.FIELD) && (countInfo.count == 2)) { countInfo.currentTile.type = WorldDataConst.TileType.SEA; } } } return(tileMap); }
public Tuple<ListSortInfo, CountInfo, object> CreatePageInfo(IInputData input, int pageNumber, int pageSize) { ListSortInfo list = new ListSortInfo(input); CountInfo pageInfo = new CountInfo(Count, 0, Count == 0 ? 1 : Count); return Tuple.Create<ListSortInfo, CountInfo, object>(list, pageInfo, null); }
//地形をランダマイズ static private WorldDataConst.EachTerrainData[] deformationTileMap(System.Random rnd, Vector2Int size, WorldDataConst.EachTerrainData[] tileMap) { for (int y = 0; y < size.y; y++) { for (int x = 0; x < size.x; x++) { // 隣接タイルが同じだったら浸食 int treatCount = WorldDataConst.DIRECTIONS.Length; CountInfo countInfo = countSameCell(treatCount, size, tileMap, x, y); if ((y == 0) || (y == size.y - 1)) { countInfo.currentTile.type = WorldDataConst.TileType.SEA; } else if (countInfo.count == treatCount) { countInfo.currentTile.type = countInfo.diffType; } else if ((countInfo.count > 0) && (rnd.Next(0, treatCount) < countInfo.count)) { countInfo.currentTile.type = countInfo.diffType; } } } return(tileMap); }
public Tuple <ListSortInfo, CountInfo, object> CreatePageInfo(IInputData input, int pageNumber, int pageSize) { ListSortInfo list = new ListSortInfo(input); CountInfo pageInfo = new CountInfo(Count, 0, Count == 0 ? 1 : Count); return(Tuple.Create <ListSortInfo, CountInfo, object>(list, pageInfo, null)); }
private MarshallingInfo GetMarshallingInfo( ITypeSymbol type, Dictionary <int, AttributeData> useSiteAttributes, int indirectionLevel, ImmutableHashSet <string> inspectedElements, ref int maxIndirectionLevelUsed) { maxIndirectionLevelUsed = Math.Max(indirectionLevel, maxIndirectionLevelUsed); CountInfo parsedCountInfo = NoCountInfo.Instance; if (useSiteAttributes.TryGetValue(indirectionLevel, out AttributeData useSiteAttribute)) { INamedTypeSymbol attributeClass = useSiteAttribute.AttributeClass !; if (indirectionLevel == 0 && SymbolEqualityComparer.Default.Equals(_compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_MarshalAsAttribute), attributeClass)) { // https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute return(CreateInfoFromMarshalAs(type, useSiteAttribute, inspectedElements, ref maxIndirectionLevelUsed)); } else if (SymbolEqualityComparer.Default.Equals(_compilation.GetTypeByMetadataName(TypeNames.MarshalUsingAttribute), attributeClass)) { if (parsedCountInfo != NoCountInfo.Instance) { _diagnostics.ReportInvalidMarshallingAttributeInfo(useSiteAttribute, nameof(Resources.DuplicateCountInfo)); return(NoMarshallingInfo.Instance); } parsedCountInfo = CreateCountInfo(useSiteAttribute, inspectedElements); if (useSiteAttribute.ConstructorArguments.Length != 0) { return(CreateNativeMarshallingInfo( type, useSiteAttribute, isMarshalUsingAttribute: true, indirectionLevel, parsedCountInfo, useSiteAttributes, inspectedElements, ref maxIndirectionLevelUsed)); } } } // If we aren't overriding the marshalling at usage time, // then fall back to the information on the element type itself. foreach (AttributeData typeAttribute in type.GetAttributes()) { INamedTypeSymbol attributeClass = typeAttribute.AttributeClass !; if (SymbolEqualityComparer.Default.Equals(_compilation.GetTypeByMetadataName(TypeNames.BlittableTypeAttribute), attributeClass)) { // If type is generic, then we need to re-evaluate that it is blittable at usage time. if (type is INamedTypeSymbol { IsGenericType: false } || type.HasOnlyBlittableFields())
public List <CountInfo> PullForCountInfoForCenter() { var model = new CountInfo { Value = GetRandomForInt(58850, 58900) }; return(new List <CountInfo> { model }); }
void GenerateDetailsDictionary() { int formatIndex = Format == null ? -1 : CountInfo.FormatIndex(Format.Value); FormatDetailsDictionary = new Dictionary <string, int>(); FormatDetailsDictionary.Add(MovieItemStatus.Rented.ToString(), Format == null ? CountInfo.WithStatus[CountInfo.StatusIndex(MovieItemStatus.Rented)] : CountInfo.WithFormatAndStatus[formatIndex, CountInfo.StatusIndex(MovieItemStatus.Rented)]); FormatDetailsDictionary.Add(MovieItemStatus.Active.ToString(), Format == null ? CountInfo.WithStatus[CountInfo.StatusIndex(MovieItemStatus.Active)] : CountInfo.WithFormatAndStatus[formatIndex, CountInfo.StatusIndex(MovieItemStatus.Active)]); FormatDetailsDictionary.Add("For Sell", Format == null ? CountInfo.ForSell : CountInfo.WithFormatForSell[formatIndex]); FormatDetailsDictionary.Add(MovieItemStatus.Lost.ToString(), Format == null ? CountInfo.WithStatus[CountInfo.StatusIndex(MovieItemStatus.Lost)] : CountInfo.WithFormatAndStatus[formatIndex, CountInfo.StatusIndex(MovieItemStatus.Lost)]); FormatDetailsDictionary.Add(MovieItemStatus.Damaged.ToString(), Format == null ? CountInfo.WithStatus[CountInfo.StatusIndex(MovieItemStatus.Damaged)] : CountInfo.WithFormatAndStatus[formatIndex, CountInfo.StatusIndex(MovieItemStatus.Damaged)]); FormatDetailsDictionary.Add(MovieItemStatus.Sold.ToString(), Format == null ? CountInfo.WithStatus[CountInfo.StatusIndex(MovieItemStatus.Sold)] : CountInfo.WithFormatAndStatus[formatIndex, CountInfo.StatusIndex(MovieItemStatus.Sold)]); }
protected override SqlCommandDescription GenerateCount(SqlCommandGenerateContext context) { string tableName = context.TableName; CountInfo deleteInfo = (CountInfo)context.CommandInfo; StringBuilder sqlBuilder = new StringBuilder(); SqlCommandDescription description = new SqlCommandDescription(); GenerateContext generateContext = new GenerateContext(description, sqlBuilder); sqlBuilder.Append($"SELECT COUNT(*) AS [{Constant.RESULT_FIELD_NAME_COUNT}] FROM [{tableName}]"); GenerateByConditions(ref generateContext, deleteInfo.ConditionInfos); description.SqlCommand = sqlBuilder.ToString(); return(description); }
private void DoSynchronize(object obj) { canDoSynchronize = false; SynchronizeCommand.RiseCanExecute(); lastUpdateBrands = DataService.DataBaseContext.BrandItemEntities.Any() ? DataService.DataBaseContext.BrandItemEntities.Select(x => x.LastUpdated).Max() : DateTimeOffset.MinValue; lastUpdateCatalogs = DataService.DataBaseContext.CatalogItemEntities.Any() ? DataService.DataBaseContext.CatalogItemEntities.Select(x => x.LastUpdated).Max() : DateTimeOffset.MinValue; lastUpdateDirectories = DataService.DataBaseContext.DirectoryEntities.Any() ? DataService.DataBaseContext.DirectoryEntities.Select(x => x.LastUpdated).Max() : DateTimeOffset.MinValue; lastUpdateProductDirections = DataService.DataBaseContext.ProductDirectionEntities.Any() ? DataService.DataBaseContext.ProductDirectionEntities.Select(x => x.LastUpdated).Max() : DateTimeOffset.MinValue; lastUpdatePhotos = DataService.DataBaseContext.PhotoItemEntities.Any() ? DataService.DataBaseContext.PhotoItemEntities.Select(x => x.LastUpdated).Max() : DateTimeOffset.MinValue; ids = DataService.DataBaseContext.PhotoItemEntities .Where(x => !x.IsLoad) .Select(x => x.Id) .ToList(); CountInfo countInfo = webService.PrepareToUpdate(lastUpdateBrands, lastUpdateCatalogs, lastUpdateDirectories, lastUpdateProductDirections, lastUpdatePhotos, NeedPhopos, ids); ValueBrands = 0; ValueDirectories = 0; ValueProductDirection = 0; ValueCatalogs = 0; ValuePhotos = 0; MaxBrands = countInfo.CountBrands; MaxDirectories = countInfo.CountDirectories; MaxProductDirections = countInfo.CountProductDirections; MaxCatalogs = countInfo.CountCatalogs; MaxPhotos = countInfo.CountPhotos; SetBrandsLabel(); SetDirectoriesLabel(); SetProductDirectionLabel(); SetCatalogsLabel(); SetPhotosLabel(); Updates(); }
public CountInfo GetQueueCount(TicketInfo ti, string seatType) { try { HttpClient client = new HttpClient(Cookies); if (StaticValues.Proxy != "") { client.Proxy = new WebProxy(StaticValues.Proxy); } string trainDate = ti.LeftTicketInfo.train_date + " 00:00:00";; trainDate = Convert.ToDateTime(trainDate).ToString("ddd MMM dd yyyy HH:mm:ss 'GMT'zzz ", System.Globalization.CultureInfo.GetCultureInfo("en-US")); trainDate = trainDate.Replace("08:00", "0800") + "(中国标准时间)"; string trainNo = ti.LeftTicketInfo.train_no; string trainCode = ti.LeftTicketInfo.station_train_code; string leftTicket = ti.LeftTicketInfo.ypInfoDetail; string fromStationTelecode = ti.LeftTicketInfo.from_station; string toStationTelecode = ti.LeftTicketInfo.to_station; string purpose_codes = "00"; string token = ti.Token; string data = "train_date={0}&train_no={1}&stationTrainCode={2}&seatType={3}&fromStationTelecode={4}&toStationTelecode={5}&leftTicket={6}&purpose_codes={7}&_json_att=&REPEAT_SUBMIT_TOKEN={8}"; object[] objs = new object[] { HttpUtility.UrlEncode(trainDate), trainNo, trainCode, seatType, fromStationTelecode, toStationTelecode, leftTicket, purpose_codes, token }; data = string.Format(data, objs); string url = "https://kyfw.12306.cn/otn/confirmPassenger/getQueueCount"; string result = client.Post(url, data, "kyfw.12306.cn", "https://kyfw.12306.cn", "https://kyfw.12306.cn/otn/confirmPassenger/initDc"); result = result.Replace("\"", ""); string count = HtmlHelper.GetContent(result, "count:", ","); string ticket = HtmlHelper.GetContent(result, "ticket:", ","); string op_2 = HtmlHelper.GetContent(result, "op_2:", ","); string countT = HtmlHelper.GetContent(result, "countT:", ","); string op_1 = HtmlHelper.GetContent(result, "op_1:", "}"); string ticketCnt = JsFuncitonHelper.GetCnt(ticket, seatType); CountInfo ci = new CountInfo(); ci.count = count; ci.countT = countT; ci.op_1 = op_1; ci.op_2 = op_2; ci.ticket = ticket; ci.ticketCnt = ticketCnt; return(ci); } catch { return(null); } }
public List <CountInfo> GetCountInfoList(int publishmentSystemID) { var countInfoList = new List <CountInfo>(); string SQL_WHERE = $"WHERE {CountAttribute.PublishmentSystemID} = {publishmentSystemID}"; var SQL_SELECT = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TABLE_NAME, 0, SqlUtils.Asterisk, SQL_WHERE, null); using (var rdr = ExecuteReader(SQL_SELECT)) { while (rdr.Read()) { var countInfo = new CountInfo(rdr.GetInt32(0), rdr.GetInt32(1), rdr.GetInt32(2), rdr.GetInt32(3), rdr.GetInt32(4), ECountTypeUtils.GetEnumType(rdr.GetValue(5).ToString()), rdr.GetInt32(6)); countInfoList.Add(countInfo); } rdr.Close(); } return(countInfoList); }
/// <summary> /// Determines whether we can generate code and send SMS by examining count information. /// </summary> /// <param name="countInfo">The count information.</param> /// <param name="mobilePhoneNumber">The mobile phone number.</param> /// <param name="errors">The errors.</param> /// <returns></returns> private bool CanGenerateCodeAndSendSms(CountInfo countInfo, string mobilePhoneNumber, InfoAccumulator errors) { if (Config.MaxPerDay <= countInfo.SentToday) { string errorMsg = string.Format("Reached max number of daily SMS messages ({0}). SMS not sent", Config.MaxPerDay); errors.AddError(errorMsg); Log.Error(errorMsg); return(false); } if (Config.MaxPerNumber <= countInfo.SentToNumber) { string errorMsg = string.Format("Reached max number of SMS messages ({0}) to number:{1}. SMS not sent", Config.MaxPerNumber, mobilePhoneNumber); errors.AddError(errorMsg); Log.Error(errorMsg); return(false); } return(true); }
public List <CountInfo> GetCountInfoList(int publishmentSystemId) { var countInfoList = new List <CountInfo>(); string sqlWhere = $"WHERE {CountAttribute.PublishmentSystemId} = {publishmentSystemId}"; var sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TableName, 0, SqlUtils.Asterisk, sqlWhere, null); using (var rdr = ExecuteReader(sqlSelect)) { while (rdr.Read()) { var countInfo = new CountInfo(rdr.GetInt32(0), rdr.GetInt32(1), rdr.GetInt32(2), rdr.GetInt32(3), rdr.GetInt32(4), ECountTypeUtils.GetEnumType(rdr.GetValue(5).ToString()), rdr.GetInt32(6)); countInfoList.Add(countInfo); } rdr.Close(); } return(countInfoList); }
void UpdateFields() { if (CategoryPrice == null) { DetailControlsVisible = false; } else { DetailControlsVisible = true;; DefaultRentalDays = CategoryPrice.DefaultRentDays.ToString(); DefaultLateFee = CategoryPrice.DefaultPrice.ToString(); } if (Format == null) { TotalCount = string.Format(ConstStrings.Get("ItemsCountCaptionFlowDocument"), CountInfo.Total); } else { int formatIndex = CountInfo.FormatIndex(Format.Value); TotalCount = string.Format(ConstStrings.Get("ItemsCountCaptionFlowDocument"), CountInfo.WithFormat[formatIndex]); } DetailCounts = GetTextDetailsForFormat(); }
public int Insert(CountInfo countInfo) { var countID = 0; var sqlString = @"INSERT INTO wx_Count (PublishmentSystemID, CountYear, CountMonth, CountDay, CountType, Count) VALUES (@PublishmentSystemID, @CountYear, @CountMonth, @CountDay, @CountType, @Count)"; var parms = new IDataParameter[] { GetParameter("@PublishmentSystemID", EDataType.Integer, countInfo.PublishmentSystemID), GetParameter("@CountYear", EDataType.Integer, countInfo.CountYear), GetParameter("@CountMonth", EDataType.Integer, 255, countInfo.CountMonth), GetParameter("@CountDay", EDataType.Integer, 200, countInfo.CountDay), GetParameter("@CountType", EDataType.VarChar, 50, ECountTypeUtils.GetValue(countInfo.CountType)), GetParameter("@Count", EDataType.Integer, countInfo.Count), }; using (var conn = GetConnection()) { conn.Open(); using (var trans = conn.BeginTransaction()) { try { ExecuteNonQuery(trans, sqlString, parms); countID = BaiRongDataProvider.DatabaseDao.GetSequence(trans, "wx_Count"); trans.Commit(); } catch { trans.Rollback(); throw; } } } return(countID); }
public CountInfo GetQueueCount(TicketInfo ti,string seatType) { try { HttpClient client = new HttpClient(Cookies); if (StaticValues.Proxy != "") { client.Proxy = new WebProxy(StaticValues.Proxy); } string trainDate = ti.LeftTicketInfo.train_date + " 00:00:00"; ; trainDate = Convert.ToDateTime(trainDate).ToString("ddd MMM dd yyyy HH:mm:ss 'GMT'zzz ", System.Globalization.CultureInfo.GetCultureInfo("en-US")); trainDate = trainDate.Replace("08:00", "0800") + "(中国标准时间)"; string trainNo = ti.LeftTicketInfo.train_no; string trainCode = ti.LeftTicketInfo.station_train_code; string leftTicket = ti.LeftTicketInfo.ypInfoDetail; string fromStationTelecode = ti.LeftTicketInfo.from_station; string toStationTelecode = ti.LeftTicketInfo.to_station; string purpose_codes = "00"; string token = ti.Token; string data = "train_date={0}&train_no={1}&stationTrainCode={2}&seatType={3}&fromStationTelecode={4}&toStationTelecode={5}&leftTicket={6}&purpose_codes={7}&_json_att=&REPEAT_SUBMIT_TOKEN={8}"; object[] objs = new object[] { HttpUtility.UrlEncode(trainDate), trainNo, trainCode, seatType, fromStationTelecode, toStationTelecode, leftTicket, purpose_codes, token }; data = string.Format(data, objs); string url = "https://kyfw.12306.cn/otn/confirmPassenger/getQueueCount"; string result = client.Post(url, data, "kyfw.12306.cn", "https://kyfw.12306.cn", "https://kyfw.12306.cn/otn/confirmPassenger/initDc"); result = result.Replace("\"", ""); string count = HtmlHelper.GetContent(result, "count:", ","); string ticket = HtmlHelper.GetContent(result, "ticket:", ","); string op_2 = HtmlHelper.GetContent(result, "op_2:", ","); string countT = HtmlHelper.GetContent(result, "countT:", ","); string op_1 = HtmlHelper.GetContent(result, "op_1:", "}"); string ticketCnt = JsFuncitonHelper.GetCnt(ticket, seatType); CountInfo ci = new CountInfo(); ci.count = count; ci.countT = countT; ci.op_1 = op_1; ci.op_2 = op_2; ci.ticket = ticket; ci.ticketCnt = ticketCnt; return ci; } catch { return null; } }
private MarshallingInfo GetMarshallingInfo( ITypeSymbol type, Dictionary <int, AttributeData> useSiteAttributes, int indirectionLevel, ImmutableHashSet <string> inspectedElements, ref int maxIndirectionDepthUsed) { maxIndirectionDepthUsed = Math.Max(indirectionLevel, maxIndirectionDepthUsed); CountInfo parsedCountInfo = NoCountInfo.Instance; if (useSiteAttributes.TryGetValue(indirectionLevel, out AttributeData useSiteAttribute)) { INamedTypeSymbol attributeClass = useSiteAttribute.AttributeClass !; if (indirectionLevel == 0 && SymbolEqualityComparer.Default.Equals(_compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_MarshalAsAttribute), attributeClass)) { // https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshalasattribute return(CreateInfoFromMarshalAs(type, useSiteAttribute, inspectedElements, ref maxIndirectionDepthUsed)); } else if (SymbolEqualityComparer.Default.Equals(_compilation.GetTypeByMetadataName(TypeNames.MarshalUsingAttribute), attributeClass)) { if (parsedCountInfo != NoCountInfo.Instance) { _diagnostics.ReportInvalidMarshallingAttributeInfo(useSiteAttribute, nameof(SR.DuplicateCountInfo)); return(NoMarshallingInfo.Instance); } parsedCountInfo = CreateCountInfo(useSiteAttribute, inspectedElements); if (useSiteAttribute.ConstructorArguments.Length != 0) { return(CreateNativeMarshallingInfo( type, (INamedTypeSymbol)useSiteAttribute.ConstructorArguments[0].Value !, useSiteAttribute, isMarshalUsingAttribute: true, indirectionLevel, parsedCountInfo, useSiteAttributes, inspectedElements, ref maxIndirectionDepthUsed)); } } } // If we aren't overriding the marshalling at usage time, // then fall back to the information on the element type itself. foreach (AttributeData typeAttribute in type.GetAttributes()) { INamedTypeSymbol attributeClass = typeAttribute.AttributeClass !; if (attributeClass.ToDisplayString() == TypeNames.NativeMarshallingAttribute) { return(CreateNativeMarshallingInfo( type, (INamedTypeSymbol)typeAttribute.ConstructorArguments[0].Value !, typeAttribute, isMarshalUsingAttribute: false, indirectionLevel, parsedCountInfo, useSiteAttributes, inspectedElements, ref maxIndirectionDepthUsed)); } } // If the type doesn't have custom attributes that dictate marshalling, // then consider the type itself. if (TryCreateTypeBasedMarshallingInfo( type, parsedCountInfo, indirectionLevel, useSiteAttributes, inspectedElements, ref maxIndirectionDepthUsed, out MarshallingInfo infoMaybe)) { return(infoMaybe); } return(NoMarshallingInfo.Instance); }
private CountInfo UpdateCountInfo(int chunkNum, CountInfo countInfo) { Interlocked.Increment(ref countInfo.CurrentCount); return(countInfo); }
public override void Execute() { ObjectListModel model = (ObjectListModel)Model; CountInfo countRow = model.Count; ListSortInfo sortRow = model.Sort; int sortField = sortRow.SortField; string tableName = ViewBag.MetaData.Table.TableName; IEnumerable <ObjectContainer> dataTable = model.List; UrlInfo urlInfo = model.CallerInfo.URL; string url = urlInfo.DSelfUrl; PageInfo pageInfo = model.CallerInfo.Info; string condition = sortRow.SqlCon; IEnumerable <IFieldInfoEx> fields = ViewBag.MetaData.Table.TableList; NormalListData pageData = (NormalListData)ViewBag.PageData; WriteLiteral("\r\n"); DefineSection("DefaultListHeader", () => { WriteLiteral("\r\n <tr>\r\n"); if (pageData.OperatorPosition == OperatorPosition.Left) { WriteLiteral(" <th"); WriteLiteral(" class=\"text-center text-nowrap\""); WriteLiteral(">\r\n <div>"); Write(pageData.OperationCaption); WriteLiteral("</div>\r\n </th>\r\n"); } WriteLiteral(" "); int index = 0; WriteLiteral("\r\n"); foreach (IFieldInfoEx field in fields) { WriteLiteral(" <th "); Write(CreateHeadAttrs(field, index++, sortField, sortRow)); WriteLiteral(">\r\n <div>"); Write(field.DisplayName); WriteLiteral("</div>\r\n </th>\r\n"); } WriteLiteral(" "); if (pageData.OperatorPosition == OperatorPosition.Right) { WriteLiteral(" <th"); WriteLiteral(" class=\"text-center text-nowrap\""); WriteLiteral(">\r\n <div>"); Write(pageData.OperationCaption); WriteLiteral("</div>\r\n </th>\r\n"); } WriteLiteral(" </tr>\r\n"); }); DefineSection("DefaultListWidth", () => { WriteLiteral("\r\n"); if (pageData.OperatorPosition == OperatorPosition.Left) { WriteLiteral(" <col "); Write(OperatorWidth(pageData.OperatorWidth)); WriteLiteral(" />\r\n"); } WriteLiteral(" "); int index = 0; WriteLiteral("\r\n"); foreach (IFieldInfoEx field in fields) { WriteLiteral(" <col "); Write(CreateColAttrs(field, index++, sortField)); WriteLiteral(" />\r\n"); } WriteLiteral(" "); if (pageData.OperatorPosition == OperatorPosition.Right) { WriteLiteral(" <col "); Write(OperatorWidth(pageData.OperatorWidth)); WriteLiteral(" />\r\n"); } }); DefineSection("DefaultTabSheet", () => { WriteLiteral("\r\n "); WriteLiteral("\r\n"); }); Write(RenderSectionOrDefault("TabSheet", "DefaultTabSheet")); WriteLiteral("\r\n<table"); WriteAttribute("class", Tuple.Create(" class=\"", 4099), Tuple.Create("\"", 4185) , Tuple.Create(Tuple.Create("", 4107), Tuple.Create <System.Object, System.Int32>(HtmlUtil.MergeClass("list-table table", pageData.Display.TableDisplayClass()) , 4107), false) ); WriteLiteral(">\r\n <colgroup>\r\n"); WriteLiteral(" "); Write(RenderSectionOrDefault("ListWidth", "DefaultListWidth")); WriteLiteral("\r\n </colgroup>\r\n"); if (pageData.ShowListHeader) { WriteLiteral(" <thead>\r\n"); WriteLiteral(" "); Write(RenderSectionOrDefault("ListHeader", "DefaultListHeader")); WriteLiteral("\r\n </thead>\r\n"); } WriteLiteral(" <tbody"); WriteLiteral(" id=\"pageList\""); WriteLiteral(" data-totalcount=\""); Write(countRow.TotalCount); WriteLiteral("\""); WriteLiteral(" data-totalpage=\""); Write(countRow.TotalPage); WriteLiteral("\""); WriteLiteral(" data-sort=\""); Write(sortField); WriteLiteral("\""); WriteLiteral(" data-order=\""); Write(sortRow.Order); WriteLiteral("\""); WriteLiteral(" data-page=\""); Write(countRow.CurrentPage); WriteLiteral("\""); WriteLiteral(" data-url=\""); Write(url); WriteLiteral("\""); WriteLiteral(" data-condition=\""); Write(condition); WriteLiteral("\""); WriteLiteral(" data-source=\""); Write(pageInfo.Source); WriteLiteral("\""); WriteLiteral(" "); WriteLiteral(">\r\n"); if (dataTable != null) { foreach (ObjectContainer row in dataTable) { string rowString = @RenderRow(row); if (rowString != null) { Write(rowString); } else { WriteLiteral(" <tr>\r\n"); if (pageData.OperatorPosition == OperatorPosition.Left) { WriteLiteral(" <td"); WriteLiteral(" class=\"text-nowrap text-center\""); WriteLiteral(">"); Write(BootcssUtil.CreateRowOperators(model.RowOperators, row)); WriteLiteral("</td>\r\n"); } WriteLiteral("\r\n"); foreach (IFieldInfoEx field in fields) { Tk5FieldInfoEx fieldInfo = field.Convert <Tk5FieldInfoEx>(); string fieldString = @RenderFieldItem(row, fieldInfo); if (fieldString == null) { WriteLiteral(" <td>"); Write(fieldInfo.DisplayValue(row)); WriteLiteral("</td>\r\n"); } else { Write(fieldString); } } WriteLiteral("\r\n"); if (pageData.OperatorPosition == OperatorPosition.Right) { WriteLiteral(" <td"); WriteLiteral(" class=\"text-nowrap text-center\""); WriteLiteral(">"); Write(BootcssUtil.CreateRowOperators(model.RowOperators, row)); WriteLiteral("</td>\r\n"); } WriteLiteral("\r\n </tr>\r\n"); } } } WriteLiteral(" </tbody>\r\n</table>\r\n"); if (countRow.TotalCount == 0) { WriteLiteral(" <div"); WriteLiteral(" class=\"p30\""); WriteLiteral(">"); Write(pageData.NoDataCaption); WriteLiteral("</div>\r\n"); } else { if (@pageData.ShowPage) { } } }
private object drawList(string name, object val, object info) { Type type; if (typeof(PropertyInfo).IsAssignableFrom(info.GetType())) { PropertyInfo pinfo = (PropertyInfo)info; type = pinfo.PropertyType; } else { FieldInfo finfo = (FieldInfo)info; type = finfo.FieldType; } if (val == null) { val = type.GetConstructor(new Type[] { }).Invoke(new object[] { }); } int hashcode = val.GetHashCode(); try { activeFlags[hashcode] = EditorGUILayout.Foldout(activeFlags[hashcode], name); } catch (KeyNotFoundException e) { activeFlags.Add(hashcode, false); activeFlags[hashcode] = EditorGUILayout.Foldout(activeFlags[hashcode], name); } if (activeFlags[hashcode]) { EditorGUI.indentLevel++; Type eleType; MethodInfo getInfo; MethodInfo addInfo; PropertyInfo capacityInfo; PropertyInfo CountInfo; eleType = type.GetGenericArguments()[0]; addInfo = type.GetMethod("Add"); getInfo = type.GetMethod("get_Item"); capacityInfo = type.GetProperty("Capacity"); CountInfo = type.GetProperty("Count"); int count = (int)CountInfo.GetGetMethod().Invoke(val, null); int capacity = EditorGUILayout.DelayedIntField("size", (int)capacityInfo.GetGetMethod().Invoke(val, null)); //if (count > capacity) //{ // val=type.GetMethod("CopyTo",new Type[] { Int32,}) //} capacityInfo.GetSetMethod().Invoke(val, new object[] { capacity }); for (int i = 0; i < capacity; i++) { object element; if (count < capacity) { element = Activator.CreateInstance(eleType, new object[] { }); addInfo.Invoke(val, new object[] { element }); count++; } else { element = getInfo.Invoke(val, new object[] { i }); } //var finfos = element.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance); //foreach (var finfo in finfos) // drawIns(finfo.FieldType, finfo, element); try { element = dict[eleType].Invoke(eleType.Name + " " + i + " :", element, null); Debug.Log(getInfo.Invoke(val, new object[] { i })); } catch (KeyNotFoundException e) { EditorGUILayout.HelpBox(eleType + "在表中没有匹配", MessageType.Error); } } EditorGUI.indentLevel--; } return(val); }
private static ExpressionSyntax GetNumElementsExpressionFromMarshallingInfo(TypePositionInfo info, CountInfo count, StubCodeContext context) { return(count switch { SizeAndParamIndexInfo(int size, SizeAndParamIndexInfo.UnspecifiedParam) => GetConstSizeExpression(size), ConstSizeCountInfo(int size) => GetConstSizeExpression(size), SizeAndParamIndexInfo(SizeAndParamIndexInfo.UnspecifiedConstSize, TypePositionInfo param) => CheckedExpression(SyntaxKind.CheckedExpression, GetExpressionForParam(param)), SizeAndParamIndexInfo(int size, TypePositionInfo param) => CheckedExpression(SyntaxKind.CheckedExpression, BinaryExpression(SyntaxKind.AddExpression, GetConstSizeExpression(size), GetExpressionForParam(param))), CountElementCountInfo(TypePositionInfo elementInfo) => CheckedExpression(SyntaxKind.CheckedExpression, GetExpressionForParam(elementInfo)), _ => throw new MarshallingNotSupportedException(info, context) { NotSupportedDetails = SR.ArraySizeMustBeSpecified }, });
public IEnumerable<CheckinTimeEx> FetchTimes() { if (_times != null) return _times; // filter if (dateEnd != null) dateEnd = dateEnd.Value.AddHours(24); var q = from t in DbUtil.Db.CheckInTimes where t.Location == location where t.CheckInTimeX >= dateStart || dateStart == null where t.CheckInTimeX < dateEnd || dateEnd == null //where peopleid == 0 || t.PeopleId == peopleid || t.Guests.Any(g => g.PeopleId == peopleid) where accesstype == 0 || t.AccessTypeID == accesstype || t.Guests.Any(g => g.AccessTypeID == accesstype) where t.GuestOfId == null select t; // count var q2 = from t in DbUtil.Db.CheckInTimes where t.Location == location where t.CheckInTimeX >= dateStart || dateStart == null where t.CheckInTimeX < dateEnd || dateEnd == null //where peopleid == 0 || t.PeopleId == peopleid || t.Guests.Any(g => g.PeopleId == peopleid) where accesstype == 0 || t.AccessTypeID == accesstype || t.Guests.Any(g => g.AccessTypeID == accesstype) select t; if (namesearch != null && namesearch.Length > 0) { q = ApplyNameSearch(q, namesearch); q2 = ApplyNameSearch(q2, namesearch); } if (activity != null && !activity.Equals(ALL_ACTIVITIES)) { q = from t in q where t.CheckInActivities.Any(z => z.Activity == activity) select t; q2 = from t in q2 where t.CheckInActivities.Any(z => z.Activity == activity) select t; } CountInfo ci = new CountInfo(); ci.members = (from c in q2 where c.AccessTypeID == 1 select c).Count(); ci.guests = (from c in q2 where c.AccessTypeID != 1 select c).Count(); _counts = ci; // sort q = SortItems(q); // transform to view model _times = from t in q.Skip(Pager.StartRow).Take(Pager.PageSize) select new CheckinTimeEx { ctime = t, activities = string.Join(",", t.CheckInActivities.Select(a => a.Activity)), name = t.Person.Name, guestcount = t.Guests.Count(), guests = t.Guests, accesstype = t.AccessTypeID ?? 0, }; return _times; }
private ExpressionSyntax GetNumElementsExpressionFromMarshallingInfo(TypePositionInfo info, CountInfo count, StubCodeContext context) { switch (count) { case SizeAndParamIndexInfo(int size, SizeAndParamIndexInfo.UnspecifiedParam): return(GetConstSizeExpression(size)); case ConstSizeCountInfo(int size): return(GetConstSizeExpression(size)); case SizeAndParamIndexInfo(SizeAndParamIndexInfo.UnspecifiedConstSize, TypePositionInfo param): { ExpressionSyntax expr = GetExpressionForParam(param, out bool isIntType); return(isIntType ? expr : CheckedExpression(SyntaxKind.CheckedExpression, expr)); } case SizeAndParamIndexInfo(int size, TypePositionInfo param): return(CheckedExpression(SyntaxKind.CheckedExpression, BinaryExpression(SyntaxKind.AddExpression, GetConstSizeExpression(size), GetExpressionForParam(param, out _)))); case CountElementCountInfo(TypePositionInfo elementInfo): { ExpressionSyntax expr = GetExpressionForParam(elementInfo, out bool isIntType); return(isIntType ? expr : CheckedExpression(SyntaxKind.CheckedExpression, expr)); } default: throw new MarshallingNotSupportedException(info, context) { NotSupportedDetails = SR.ArraySizeMustBeSpecified }; }
private CountInfo UpdateCountInfo(int chunkNum, CountInfo countInfo) { Interlocked.Increment(ref countInfo.CurrentCount); return countInfo; }
public IEnumerable <CheckinTimeEx> FetchTimes() { if (_times != null) { return(_times); } // filter if (dateEnd != null) { dateEnd = dateEnd.Value.AddHours(24); } var q = from t in DbUtil.Db.CheckInTimes where t.Location == location where t.CheckInTimeX >= dateStart || dateStart == null where t.CheckInTimeX < dateEnd || dateEnd == null //where peopleid == 0 || t.PeopleId == peopleid || t.Guests.Any(g => g.PeopleId == peopleid) where accesstype == 0 || t.AccessTypeID == accesstype || t.Guests.Any(g => g.AccessTypeID == accesstype) where t.GuestOfId == null select t; // count var q2 = from t in DbUtil.Db.CheckInTimes where t.Location == location where t.CheckInTimeX >= dateStart || dateStart == null where t.CheckInTimeX < dateEnd || dateEnd == null //where peopleid == 0 || t.PeopleId == peopleid || t.Guests.Any(g => g.PeopleId == peopleid) where accesstype == 0 || t.AccessTypeID == accesstype || t.Guests.Any(g => g.AccessTypeID == accesstype) select t; if (namesearch != null && namesearch.Length > 0) { q = ApplyNameSearch(q, namesearch); q2 = ApplyNameSearch(q2, namesearch); } if (activity != null && !activity.Equals(ALL_ACTIVITIES)) { q = from t in q where t.CheckInActivities.Any(z => z.Activity == activity) select t; q2 = from t in q2 where t.CheckInActivities.Any(z => z.Activity == activity) select t; } CountInfo ci = new CountInfo(); ci.members = (from c in q2 where c.AccessTypeID == 1 select c).Count(); ci.guests = (from c in q2 where c.AccessTypeID != 1 select c).Count(); _counts = ci; // sort q = SortItems(q); // transform to view model _times = from t in q.Skip(Pager.StartRow).Take(Pager.PageSize) select new CheckinTimeEx { ctime = t, activities = string.Join(",", t.CheckInActivities.Select(a => a.Activity)), name = t.Person.Name, guestcount = t.Guests.Count(), guests = t.Guests, accesstype = t.AccessTypeID ?? 0, }; return(_times); }