void CreateChooseLevelOverlay() { chooseLevelOverlay = new MapOverlay(); levelItems = new Dictionary <MapOverlayImageItem, MapOverlayTextItem>(); levelSelectorItems = new Dictionary <MapOverlayTextItem, MapOverlayTextItem>(); foreach (string levelName in this.levelNames) { string levelIconName = levelName.ToLower().Replace(' ', '_'); MapOverlayImageItem iconItem = new MapOverlayImageItem() { Image = CommonExtension.GetResourceImage("FlagsGame", levelIconName + ".png"), JoiningOrientation = Orientation.Horizontal, Padding = new Padding(37, 20, 37, 20) }; MapOverlayTextItem nameItem = new MapOverlayTextItem() { Text = levelName.ToUpper(), Size = new Size(80, 0), Padding = new Padding(0, 20, 0, 20), TextAlignment = ContentAlignment.BottomCenter }; nameItem.TextStyle.Font = FontsCollection["level"]; nameItem.HotTrackedStyle.Fill = ChooseLevelBackgroundColor; MapOverlayTextItem selectorItem = new MapOverlayTextItem(); selectorItem.HotTrackedStyle.Fill = ChooseLevelBackgroundColor; this.levelItems.Add(iconItem, nameItem); this.levelSelectorItems.Add(nameItem, selectorItem); } chooseLevelOverlay.Items.AddRange(this.levelItems.Keys); chooseLevelOverlay.Items.AddRange(this.levelItems.Values); chooseLevelOverlay.Items.AddRange(this.levelSelectorItems.Values); }
static public string AutoGenKey(ref EntityRow row) { var table = row.Table; if (table == null) { return(null); } var pk = row.Table.PrimaryKey; var keyGen = pk.GetAttributesEntity().KeyGen; if (string.IsNullOrEmpty(keyGen)) { return(null); } var tableAttri = table.GetAttributesEntity(); long keyIndex = tableAttri.KeyCount + 1; var key = CommonExtension.StringFormat(keyGen, keyIndex); tableAttri.KeyCount = keyIndex; row.SetValue(table.PrimaryKey, key, true); return(key); //Table.GetAttributesEntity().KeyCount }
public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data) { LogEntity logEntity = data as LogEntity; string deccript = (logEntity == null) ?source : CommonExtension.StringFormat("{0}-{1}" , string.IsNullOrEmpty(logEntity.Category) ? source : logEntity.Category , (logEntity.MessageList.Count > 0) ? logEntity.MessageList[0].Content : "" ); if (logEntity == null) { base.TraceData(eventCache, deccript, eventType, id, data); } else { int size = logEntity.MessageList.Count; object[] msgs = new object[size + 1]; for (int i = 0; i < size; i++) { LogMessage msg = logEntity.MessageList[i]; string msgString = CommonExtension.StringFormat("[{0}] {1}", msg.TimestampXml, msg.Content); msgs.SetValue(msgString, i); } // this.TraceOutputOptions msgs.SetValue(logEntity.ExtInfo(), size); base.TraceData(eventCache, deccript, eventType, id, msgs); } }
public static void LoadShapefileDataAdapter(ShapefileDataAdapter ShapefileDataAdapter) { Stream shpStream = CommonExtension.GetResourceStream("Data", "Countries.shp"); Stream dbfStream = CommonExtension.GetResourceStream("Data", "Countries.dbf"); ShapefileDataAdapter.LoadFromStream(shpStream, dbfStream); }
private bool TryGetSettingValue(PropertyInfo propInfo, Type returnType, out object settingValue, bool isInBaseType = false) { if (!string.IsNullOrEmpty(ConnString)) { kvMap ??= Init(ConnString); var idxAttribute = propInfo.GetCustomAttribute <IndexingAttribute>(); var key = (idxAttribute == null) ? propInfo.Name : idxAttribute.Id; string value; if (kvMap.TryGetValue(key, out value)) { settingValue = (returnType.Equals(typeof(string))) ? value : CommonExtension.ToObject(value, returnType); return(true); } else if (!isInBaseType) { Func <Type, PropertyInfo> cond = type => (!propInfo.DeclaringType.IsInterface) ? null : type.GetProperty(propInfo.Name); propInfo = propInfo.DeclaringType.FindIncludBaseType <PropertyInfo>(cond); if (propInfo != null) { return(TryGetSettingValue(propInfo, returnType, out settingValue, true)); } } } settingValue = null; return(false); }
public override object Deserialize(Stream stream, Type type) { var list = (IList)Activator.CreateInstance(type); var typeArgument = type.GetGenericArguments()[0]; var indexingAttributes = TakeIndexingAttributesByIdx(typeArgument); bool isAllHeaderMatchPropertyName = false; var head = new List <string>(); using (var reader = new StreamReader(stream, TheEncoding)) { while (!reader.EndOfStream) { var line = reader.ReadLine(); if (string.IsNullOrEmpty(line)) { continue; } if (head.Count == 0) { if (!line.Contains(symbol)) { continue; } line.Split(str => { head.Add(str); return(true); }, symbol); isAllHeaderMatchPropertyName = head.TrueForAll(it => typeArgument.GetProperty(it) != null); if (!isAllHeaderMatchPropertyName && indexingAttributes == null) { throw new FieldAccessException("Deserialize: CSV Columns not match object propertys!"); } continue; } if (LineStrinCheckEvent != null && !LineStrinCheckEvent(line)) { continue; } if (LineStrinReplaceEvent != null) { line = LineStrinReplaceEvent(line); } var item = (CreateInstanceEvent != null) ? CreateInstanceEvent() : Activator.CreateInstance(typeArgument); var values = new List <object>(); line.Split(str => { values.Add(str); return(true); }, symbol); int colNum = (!isAllHeaderMatchPropertyName) ? indexingAttributes.Count : head.Count; for (int i = 0; i < colNum; i++) { var protertyInfo = (!isAllHeaderMatchPropertyName) ? indexingAttributes[i].OriginalPropertyInfo : typeArgument.GetProperty(head[i]); if (protertyInfo != null && i < values.Count) { protertyInfo.SetValue(item, CommonExtension.ToObject(values[i], protertyInfo.PropertyType)); } } list.Add(item); } return(list); } }
static private string GetFilePath(string file) { if (file.Contains("\\")) { return(file); } return(CommonExtension.StringFormat("{0}\\{1}", SystemSetting.Instance.StorageDirectory, file)); }
Image GetCountryFlag(string countryName) { string flagPath = countryName.Replace(' ', '_') + FlagExtension; if (!this.countriesFlags.ContainsKey(countryName)) { Image flagImage = CommonExtension.GetResourceImage("Flags.Big", flagPath); this.countriesFlags.Add(countryName, flagImage); } return(this.countriesFlags[countryName]); }
internal object DoGetProperty(System.Reflection.MethodInfo methodInfo, string propertyName) { TValue value; if (ValueMap.TryGetValue(propertyName, out value)) { return((methodInfo.ReturnType.Equals(typeof(string))) ?value:CommonExtension.ToObject(value, methodInfo.ReturnType)); } return(value); }
/// <summary> /// Reads the JSON representation of the object. /// </summary> /// <param name="reader">The <see cref="T:Newtonsoft.Json.JsonReader" /> to read from.</param> /// <param name="objectType">Type of the object.</param> /// <param name="existingValue">The existing value of object being read.</param> /// <param name="serializer">The calling serializer.</param> /// <returns> /// The object value. /// </returns> public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var unixTotalSeconds = reader.Value.SafeToString().ObjectToNullableInt64(); if (unixTotalSeconds.HasValue) { return(CommonExtension.UnixMillisecondsToDateTime(unixTotalSeconds * 1000, DateTimeKind.Utc)); } return(null); }
/// <summary> /// Reads the JSON representation of the object. /// </summary> /// <param name="reader">The <see cref="T:Newtonsoft.Json.JsonReader" /> to read from.</param> /// <param name="objectType">Type of the object.</param> /// <param name="existingValue">The existing value of object being read.</param> /// <param name="serializer">The calling serializer.</param> /// <returns> /// The object value. /// </returns> public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (objectType.IsNullable()) { var unixTotalSeconds = reader.Value.SafeToString().ObjectToNullableInt64(); return(unixTotalSeconds.HasValue ? CommonExtension.UnixMillisecondsToDateTime(unixTotalSeconds.Value * MagnificationByMillisecond, DateTimeKind.Utc) as DateTime? : null); } else { var unixTotalSeconds = reader.Value.SafeToString().ObjectToInt64(); return(CommonExtension.UnixMillisecondsToDateTime(unixTotalSeconds * MagnificationByMillisecond, DateTimeKind.Utc)); } }
protected void messageRepeater_ItemCreated(object sender, RepeaterItemEventArgs e) { DBViewTagAlert ev = e.Item.DataItem as DBViewTagAlert; if (ev != null) { SmartLabel isResolved = (SmartLabel)e.Item.FindControl("isResolved"); if (ev.AlertStatus != (byte)AlertStatusType.New) { isResolved.Text = "√"; } else { isResolved.Text = "<input type='checkbox' name='selection' value='" + ev.AlertId + "' />"; } Img icon = e.Item.FindControl("icon") as Img; HostTagGroupStatus hostTagGroupStatus = HostTagGroupStatus.SelectByHostId((int)ev.HostId); int groupId = hostTagGroupStatus.HostGroupId; icon.Src = CommonExtension.IdentityIconByGroupId(groupId); Anchor tagName = (Anchor)e.Item.FindControl("tagName"); tagName.Text = ev.HostName; tagName.Href = PathUtil.ResolveUrl(string.Format("/TagUsers/TagUser.aspx?id={0}&type={1}", ev.HostId, groupId)); SmartLabel facilityName = (SmartLabel)e.Item.FindControl("facilityName"); facilityName.Text = ev.FacilityName; SmartLabel coordinatesName = (SmartLabel)e.Item.FindControl("coordinatesName"); coordinatesName.Text = ev.CoordinatesName; SmartLabel eventType = (SmartLabel)e.Item.FindControl("eventType"); eventType.Text = CommonExtension.GetEventDescription((SupportEvent)ev.AlertType, ev.HostId.Value); SmartLabel alertStatus = (SmartLabel)e.Item.FindControl("alertStatus"); alertStatus.Text = Misc.GetAlertStatus((AlertStatusType)ev.AlertStatus); DateTimeLabel lastHappenTime = (DateTimeLabel)e.Item.FindControl("lastHappenTime"); lastHappenTime.DisplayValue = ev.WriteTime; Anchor alertDetail = (Anchor)e.Item.FindControl("alertDetail"); alertDetail.Text = "详情"; alertDetail.Href = PathUtil.ResolveUrl("/Monitor/TagAlertProcess.aspx?id=" + ev.AlertId); if (ev.AlertStatus == (byte)ResolveFlag.Processed) { HtmlTableRow tr = (HtmlTableRow)e.Item.FindControl("tr"); tr.Attributes["class"] = "t3"; tagName.CssClass = "t3"; } } }
public List <SelectListItem> GetSelectListAgeRange() { var lstAgeRangeEnum = CommonExtension.ToEnumSelectList <AgeRange>(); List <SelectListItem> lstAgeRange = new List <SelectListItem>(); foreach (var item in lstAgeRangeEnum) { SelectListItem ageRangeItem = new SelectListItem(); ageRangeItem.Value = item.Value; ageRangeItem.Text = item.Name; lstAgeRange.Add(ageRangeItem); } return(lstAgeRange); }
public string GetUrlForMethodOne(int orderId) { var url = @"weixin://wxpay/bizpayurl"; var packageParameter = new Hashtable(); packageParameter.Add("appid", _weiXinPaymentSettings.AppId); packageParameter.Add("mch_id", _weiXinPaymentSettings.MchId); packageParameter.Add("time_stamp", CommonExtension.GetCurrentTimeStamp().ToString()); packageParameter.Add("nonce_str", Guid.NewGuid().ToString("N")); packageParameter.Add("product_id", orderId.ToString()); var sign = CreateMd5Sign("key", _weiXinPaymentSettings.AppSecret, packageParameter, "utf-8"); packageParameter.Add("sign", sign); url += CreatUrlParameters(packageParameter); return(url); }
override public void Initializing() { if (string.IsNullOrEmpty(this.Content)) { return; } items.Clear(); Match match = priceRegex.Match(this.Content); if (match.Success) { foreach (Capture item in match.Groups[2].Captures) { items.Add(CommonExtension.ToObject <T>(item.Value)); } } }
static private object DoGetPropertyValue(MethodInfo methodInfo, object retValue) { if (methodInfo == null) { return(retValue); } var propertyType = methodInfo.ReturnType; if (retValue == null || retValue is DBNull) { retValue = (propertyType.IsValueType) ? Activator.CreateInstance(propertyType) : null; } if (retValue == null || propertyType.IsAssignableFrom(retValue.GetType())) { return(retValue); } return(CommonExtension.ToObject(retValue.ToString(), propertyType)); }
void list_ItemCreated(object sender, RepeaterItemEventArgs e) { DBViewTagAlert log = e.Item.DataItem as DBViewTagAlert; if (log != null) { SmartLabel description = e.Item.FindControl("description") as SmartLabel; description.Text = CommonExtension.GetEventDescription((SupportEvent)log.AlertType, log.HostId.Value); SmartLabel facilityName = e.Item.FindControl("facilityName") as SmartLabel; facilityName.Text = log.FacilityName; DateTimeLabel writeTime = e.Item.FindControl("writeTime") as DateTimeLabel; writeTime.DisplayValue = log.WriteTime; SmartLabel coordinatesName = e.Item.FindControl("coordinatesName") as SmartLabel; coordinatesName.Text = log.CoordinatesName; } }
private void NomalUpload(HttpContext context) { if (context.Request.HttpMethod.ToLower() != "post") { // var date = BsonValue.Create(DateTime.Parse("2015-07-29 09:49:29").ToUniversalTime()); // var list = // GridFsManager.Instance("db".Query("picture")) // .Find(Query.And(Query.GT("uploadDate", date), Query.EQ("", BsonValue.Create("")))); // context.Response.Write(CommonExtension.ToJson(list.Select(t => new // { // name = t.Name, // date = t.UploadDate.ToLocalTime().ToLongDateString() // }))); // Util.InitConfig(); return; } //查看原始数据 //var stream = context.Request.InputStream; //using (var sr = new StreamReader(stream)) //{ // System.IO.File.WriteAllText("d:\\form.txt", sr.ReadToEnd(), Encoding.UTF8); //} var type = "type".QueryOrForm(0); var helper = new UploadHelper(context, (FileType)type); var result = helper.Save(); if (!result.Status) { Util.ResponseJson(CommonExtension.ToJson(new { state = 0, msg = result.Message })); return; } Util.ResponseJson(CommonExtension.ToJson(new { state = 1, urls = result.Data.Values.ToArray(), keys = context.Request.Files.AllKeys })); }
/// <summary> /// Loading purchase statistics A and B data to DataTable /// </summary> /// <param name="filtering">EventCd and Type</param> /// <returns>IndexViewModel</returns> public IndexViewModel Load(IndexViewModel filtering) { var result = new IndexViewModel(); var purchaseStatistics = _context.PurchaseStatistics .Where(x => (filtering.EventCd == 0 || x.EventCd == filtering.EventCd) && x.Type == filtering.Type); result.TotalRowsAfterFiltering = purchaseStatistics.Count(); purchaseStatistics = Filtering(purchaseStatistics, filtering); result.PurchaseStatistics = purchaseStatistics .Select(x => new { x.Cd, x.InsertUser.FirstName, x.InsertUser.LastName, x.InsertDate, x.Event.StartDate, x.Event.EndDate, x.Event.Name }) .AsEnumerable() .Select(x => new PerchaseStatisticsRow { Cd = x.Cd, Time = x.StartDate.HasValue && x.EndDate.HasValue ? $"{x.StartDate.Value.Date.Year}年{CommonExtension.GetWeekOfMonth(x.StartDate.Value, x.EndDate.Value, false)}" : "", EventName = x.Name, OutputPerson = string.Concat(x.FirstName, x.LastName), InsertDate = x.InsertDate.Value.ToString(Constants.ExactDateTimeFormat) }).ToList(); if (result.PurchaseStatistics.Any()) { for (var i = 0; i < result.PurchaseStatistics.Count; i++) { result.PurchaseStatistics[i].No = filtering.Start + i + 1; } } return(result); }
public List <SelectListItem> GetSelectListCashVoucherValue(bool isNullItemFirst = false) { var vouchers = CommonExtension.ToEnumSelectList <CashVoucherValue>() .Select(d => new SelectListItem { Value = d.Value, Text = d.Name, }).ToList(); if (isNullItemFirst) { vouchers.Insert(0, new SelectListItem { Value = "", Text = "-- 未選択 --", }); } return(vouchers); }
public List <SelectListItem> GetSelectListVisitTime(bool isNullItemFirst = false) { var rs = CommonExtension.ToEnumSelectList <VisitTime>() .Select(t => new SelectListItem { Value = t.Value, Text = t.Name, }).ToList(); if (isNullItemFirst) { rs.Insert(0, new SelectListItem { Value = "", Text = "", }); } return(rs); }
public List <SelectListItem> GetSelectListMemberCard(bool isNullItemFirst = false) { var cards = CommonExtension.ToEnumSelectList <MemberCard>() .Select(c => new SelectListItem { Value = c.Value, Text = c.Name, }).ToList(); if (isNullItemFirst) { cards.Insert(0, new SelectListItem { Value = "", Text = "-- 未選択 --", }); } return(cards); }
public List <SelectListItem> GetSelectListSalesDepartment(bool isNullItemFirst = false) { var lstDepartment = CommonExtension.ToEnumSelectList <SalesDepartment>() .Select(d => new SelectListItem { Value = d.Value, Text = d.Name, }).ToList(); if (isNullItemFirst) { lstDepartment.Insert(0, new SelectListItem { Value = "", Text = "-- 未選択 --", }); } return(lstDepartment); }
public List <SelectListItem> GetSelectListIdentifyDoc(bool isNullItemFirst = false) { var docs = CommonExtension.ToEnumSelectList <IdentifyDocument>() .Select(d => new SelectListItem { Value = d.Value, Text = d.Name, }).ToList(); if (isNullItemFirst) { docs.Insert(0, new SelectListItem { Value = "", Text = "-- 未選択 --", }); } return(docs); }
public List <SelectListItem> GetSelectListClubRegStatus(bool isNullItemFirst = false) { var statuses = CommonExtension.ToEnumSelectList <ClubJoin>() .Select(s => new SelectListItem { Value = s.Value, Text = s.Name, }).ToList(); if (isNullItemFirst) { statuses.Insert(0, new SelectListItem { Value = "", Text = "", }); } return(statuses); }
public List <SelectListItem> GetSelectListPhoneBranch(bool isNullItemFirst = false) { var branches = CommonExtension.ToEnumSelectList <PhoneBranch>() .Select(b => new SelectListItem { Value = b.Value, Text = b.Name, }).ToList(); if (isNullItemFirst) { branches.Insert(0, new SelectListItem { Value = "", Text = "", }); } return(branches); }
public List <SelectListItem> GetSelectListGender(bool isNullItemFirst = false) { var genders = CommonExtension.ToEnumSelectList <Gender>() .Select(g => new SelectListItem { Value = g.Value, Text = g.Name, }).ToList(); if (isNullItemFirst) { genders.Insert(0, new SelectListItem { Value = "", Text = "-- 未選択 --", }); } return(genders); }
public List <SelectListItem> GetSelectListRemarks(bool isNullItemFirst = false) { var rs = CommonExtension.ToEnumSelectList <Remarks>() .Select(d => new SelectListItem { Value = d.Value, Text = d.Name, }).ToList(); if (isNullItemFirst) { rs.Insert(0, new SelectListItem { Value = "", Text = "", }); } return(rs); }
public List <SelectListItem> GetSelectListLeftPaymentMethod(bool isNullItemFirst = false) { var result = CommonExtension.ToEnumSelectList <LeftPaymentMethod>() .Select(d => new SelectListItem { Value = d.Value, Text = d.Name, }).ToList(); if (isNullItemFirst) { result.Insert(0, new SelectListItem { Value = "", Text = "-- 未選択 --", }); } return(result); }
public List <SelectListItem> GetSelectListDeliveryPlace(bool isNullItemFirst = false) { var result = CommonExtension.ToEnumSelectList <DeliveryPlace>() .Select(d => new SelectListItem { Value = d.Value, Text = d.Name, }).ToList(); if (isNullItemFirst) { result.Insert(0, new SelectListItem { Value = "", Text = "", }); } return(result); }