protected override void OnInit(EventArgs e) { base.OnInit(e); string pid = Request.QueryString["pid"]; if (!string.IsNullOrEmpty(pid)) { NetRadio.Assistant.Web.Controls.TabViewItem item; System.Collections.Generic.IEnumerable <NetRadio.Model.Menu> menus = Business.BusSystemMenu.GetSystemMenuFromCache(NetRadio.Common.LocatingMonitor.ContextUser.Current, pid, true); ObjectView.Items.Clear(); string _url = ""; for (int i = 0; i < menus.Count(); i++) { item = new NetRadio.Assistant.Web.Controls.TabViewItem(); _url = menus.ElementAt(i).MenuUrl; if (_url.IndexOf("pid=") == -1) { _url = _url.IndexOf("?") == -1 ? (_url + "?pid=" + pid) : (_url + "&pid=" + pid); } item.Href = "/" + _url; item.Label = menus.ElementAt(i).MenuText; ObjectView.Items.Add(item); } } }
public static int PriorityToLeave(IOrderedEnumerable <int> patientOrderDesc, System.Collections.Generic.IEnumerable <double> patientPriorityOrder, double randomPriority) { if (randomPriority > (Math.Round(1 - patientPriorityOrder.ElementAt(0), 1))) { return(ChangePriority(new int[] { patientOrderDesc.ElementAt(0) }, 1).First()); } else if (randomPriority > (Math.Round(1 - patientPriorityOrder.ElementAt(0) - patientPriorityOrder.ElementAt(1), 1))) { return(ChangePriority(new int[] { patientOrderDesc.ElementAt(1) }, 1).First()); } else if (randomPriority > (Math.Round(1 - patientPriorityOrder.ElementAt(0) - patientPriorityOrder.ElementAt(1) - patientPriorityOrder.ElementAt(2), 1))) { return(ChangePriority(new int[] { patientOrderDesc.ElementAt(2) }, 1).First()); } else { try { return(ChangePriority(new int[] { patientOrderDesc.ElementAt(3) }, 1).First()); } catch (ArgumentOutOfRangeException expection) { return(ChangePriority(new int[] { patientOrderDesc.ElementAt(2) }, 1).First()); } } }
public static string GetXsrfCookieValue(HttpResponseMessage response) { System.Collections.Generic.IEnumerable <string> setCookieHeaders = response.Headers.GetValues("Set-Cookie"); for (int i = 0; i < setCookieHeaders.Count(); i++) { if (setCookieHeaders.ElementAt(i).StartsWith("XSRF-TOKEN")) { return(setCookieHeaders.ElementAt(i).Substring(11).Split(";")[0]); } } return(null); }
protected override void OnInit(EventArgs e) { base.OnInit(e); string pid = Request.QueryString["pid"]; string userType = Request.QueryString["userType"]; if (!string.IsNullOrEmpty(pid)) { NetRadio.Assistant.Web.Controls.TabViewItem item; System.Collections.Generic.IEnumerable <NetRadio.Model.Menu> menus = Business.BusSystemMenu.GetSystemMenuFromCache(NetRadio.Common.LocatingMonitor.ContextUser.Current, pid, true); tabView.Items.Clear(); string _url = ""; for (int i = 0; i < menus.Count(); i++) { item = new NetRadio.Assistant.Web.Controls.TabViewItem(); _url = menus.ElementAt(i).MenuUrl; if (_url.IndexOf("pid=") == -1) { _url = _url.IndexOf("?") == -1 ? (_url + "?pid=" + pid) : (_url + "&pid=" + pid); } if (_url.IndexOf("userType=") == -1) { _url = _url.IndexOf("?") == -1 ? (_url + "?userType=" + userType) : (_url + "&userType=" + userType); } item.Href = "/" + _url; item.Label = menus.ElementAt(i).MenuText; tabView.Items.Add(item); } } string masterFile = Request.QueryString["masterFile"]; if (!string.IsNullOrEmpty(masterFile)) { NetRadio.Assistant.Web.Controls.TabViewItem _ctl = null; foreach (NetRadio.Assistant.Web.Controls.TabViewItem ctl in tabView.Items) { if (ctl.GetType() == typeof(NetRadio.Assistant.Web.Controls.TabViewItem)) { _ctl = (NetRadio.Assistant.Web.Controls.TabViewItem)ctl; _ctl.Href = _ctl.Href + (_ctl.Href.IndexOf("?") == -1 ? "?masterFile=" + masterFile : "&masterFile=" + masterFile); } } } }
public static int PriorityToLeaveInDoubleQuery(int priorityMin, int priorityMax, System.Collections.Generic.IEnumerable <double> patientPriorityOrder, double randomPriority) { if (randomPriority <= patientPriorityOrder.ElementAt(1)) { return(priorityMin); } else { return(priorityMax); } }
public virtual System.Collections.Generic.IEnumerable <TEntity> PopulateEntitiesByEntityIds <T>(System.Collections.Generic.IEnumerable <T> entityIds) { TEntity[] array = new TEntity[entityIds.Count <T>()]; System.Collections.Generic.Dictionary <object, int> dictionary = new System.Collections.Generic.Dictionary <object, int>(); for (int i = 0; i < entityIds.Count <T>(); i++) { TEntity tEntity = this.cacheService.Get <TEntity>(Repository <TEntity> .RealTimeCacheHelper.GetCacheKeyOfEntity(entityIds.ElementAt(i))); if (tEntity != null) { array[i] = tEntity; } else { array[i] = default(TEntity); dictionary[entityIds.ElementAt(i)] = i; } } if (dictionary.Count > 0) { System.Collections.Generic.IEnumerable <TEntity> enumerable = this.CreateDAO().FetchByPrimaryKeys <TEntity>(dictionary.Keys); foreach (TEntity current in enumerable) { array[dictionary[current.EntityId]] = current; if (Repository <TEntity> .RealTimeCacheHelper.EnableCache && current != null) { if (Repository <TEntity> .RealTimeCacheHelper.PropertyNameOfBody != null && Repository <TEntity> .RealTimeCacheHelper.PropertyNameOfBody != null) { Repository <TEntity> .RealTimeCacheHelper.PropertyNameOfBody.SetValue(current, null, null); } this.cacheService.Set(Repository <TEntity> .RealTimeCacheHelper.GetCacheKeyOfEntity(current.EntityId), current, Repository <TEntity> .RealTimeCacheHelper.CachingExpirationType); } } } System.Collections.Generic.List <TEntity> list = new System.Collections.Generic.List <TEntity>(); TEntity[] array2 = array; for (int j = 0; j < array2.Length; j++) { TEntity tEntity2 = array2[j]; if (tEntity2 != null && !tEntity2.IsDeletedInDatabase) { list.Add(tEntity2); } } return(list); }
/// <summary> /// 转换为列表 /// </summary> /// <param name="datas"></param> /// <returns></returns> public static System.Collections.IList ConvertToList(System.Collections.Generic.IEnumerable <DataCollection> datas, string format = "yyyy-MM-dd HH:mm:ss") { string dtoTypeFullName; var addSupportProperties = false; if (addSupportProperties) { dtoTypeFullName = GetTypeId(datas) + "1"; } else { dtoTypeFullName = GetTypeId(datas) + "0"; } Type dtoType = null; if (_cachedTypes.ContainsKey(dtoTypeFullName)) { // Get type from cache dtoType = _cachedTypes[dtoTypeFullName]; } else { // Cache new type dtoType = CreateType(datas.ElementAt <DataCollection>(0), addSupportProperties, dtoTypeFullName); _cachedTypes.Add(dtoTypeFullName, dtoType); } var dtoCollection = new System.Collections.ObjectModel.ObservableCollection <BindableObject>(); foreach (var d in datas) { dtoCollection.Add(GetBindableData(d, dtoType)); } return(dtoCollection); }
/// <summary> /// Is this a base of the fetched type? Must do some data mining to find out. /// </summary> /// <param name="candle">Collection of OHLC parameters each with date and volume</param> /// <returns></returns> public BaseData FindBase(System.Collections.Generic.IEnumerable <Candle> candle) { Decimal CupLeftSide = 0; Decimal CupRightSide = 0; Decimal CupDeepest = 0; Decimal CupHandleBottom = 0; Decimal PivotPoint = 0; Decimal decBasePercentDeep = 0; Decimal decBaseMidValue = 0; Decimal decBaseHandlePercentDeep = 0; DateTime dtBaseStart = candle.ElementAt(0).Date; DateTime dtBaseEnds = candle.ElementAt(0).Date; DateTime dtStartDate = candle.ElementAt(0).Date; DateTime dtCurrentDate = dtStartDate; DateTime dtPivotPoint = dtStartDate; TimeSpan tsDates; Double dCurrentNumberofDays = 0; Boolean isBaseDuration = false; Boolean isBaseDeepEnough = false; Boolean isBaseHandleDeepEnough = false; Boolean isCalculatingHandle = false; Boolean isHandleRising = false; for (int i = candle.Count(); i > 0; i--) { //find the right most peak going down... // find the middle peak // find the left peak. } for (int i = 0; i < candle.Count(); i++) { //Calculate the left side of the cup (highest point) // The base starts at the left side of the cup. if (CupLeftSide < candle.ElementAt(i).High) { dtStartDate = candle.ElementAt(i).Date; CupLeftSide = candle.ElementAt(i).High; CupDeepest = CupLeftSide; CupRightSide = 0; CupHandleBottom = 0; PivotPoint = 0; } //Calculate the deepest part of the cup // its dropped percentage // and the mid value (50% of depth) // we are not interested in dates a low point of the cup, only when rising. if (CupDeepest > candle.ElementAt(i).Low) { dtCurrentDate = dtStartDate; dtBaseStart = dtCurrentDate; CupDeepest = candle.ElementAt(i).Low; CupRightSide = CupDeepest; CupHandleBottom = CupDeepest; PivotPoint = CupDeepest; decBasePercentDeep = (1 - CupDeepest / CupLeftSide) * 100; decBaseMidValue = CupDeepest + (CupLeftSide - CupDeepest) / 2; if (decBasePercentDeep > BASE_DEPTH_MINIMUM) { isBaseDeepEnough = true; } } //The right side of the cup. Calculate this by looking at the deepest // and if bigger than deepest then cup is rising, but see if the base // is deep enough first. if (CupDeepest < candle.ElementAt(i).High) { if (isBaseDeepEnough && !isCalculatingHandle) { CupRightSide = candle.ElementAt(i).High; if (decBaseMidValue < candle.ElementAt(i).Close) { dtCurrentDate = candle.ElementAt(i).Date; dtBaseEnds = dtCurrentDate; } } } //private Decimal BASE_HANDLE_DEPTH_MINIMUM = 0; //private Decimal BASE_HANDLE_RISING_COUNT = 0; // Handle can form on the upper part of the cup to be effective // to calculate the base, at a minimum we want to rise 50% of depth. if (CupRightSide > decBaseMidValue) { //Check if the closing is lower for 4 consecutive days and calculate // the depth of the handle by looking at the lowest point of the handle. //Trace back and see when is the highest point from those 4 consecutive days. if ((i + 5) < candle.Count()) { if ((candle.ElementAt(i + 0).Close >= candle.ElementAt(i + 1).Close) && (candle.ElementAt(i + 1).Close >= candle.ElementAt(i + 2).Close) && (candle.ElementAt(i + 2).Close >= candle.ElementAt(i + 3).Close) && (candle.ElementAt(i + 3).Close >= candle.ElementAt(i + 4).Close)) { //we are now in the handle part area isCalculatingHandle = true; } } } //Calculate time of base tsDates = dtCurrentDate - dtStartDate; dCurrentNumberofDays = tsDates.TotalDays; if (dCurrentNumberofDays > 49) //7 weeks { isBaseDuration = true; } } // Denote base formation if (isBaseDuration && isBaseDeepEnough) { m_IsFormingBase = true; } if (isBaseHandleDeepEnough) { m_HasFormedBase = true; } m_Data.DateBaseStarts = dtBaseStart; m_Data.DateBaseEnds = dtBaseEnds; m_Data.HeightBaseStarts = CupLeftSide; m_Data.HeightBaseEnds = CupRightSide; m_Data.HeightMidpointBase = decBaseMidValue; m_Data.DepthBasePercent = decBasePercentDeep; m_Data.PivotPoint = PivotPoint; m_Data.DateHandleStarts = dtPivotPoint; m_Data.DepthHandlePercent = decBaseHandlePercentDeep; return(m_Data); }
/// <summary> /// 初始化项 /// </summary> /// <param name="el"></param> /// <param name="item"></param> /// <param name="rotatestep"></param> /// <param name="circleIndex"></param> /// <param name="radiacenter"></param> /// <param name="center"></param> /// <param name="maxbottom"></param> /// <param name="circlesize"></param> /// <param name="tocentername"></param> private void InitPoint(EllipseGeometry el, Model.DataPoint item, double rotatestep, int circleIndex, double radiacenter, Point center, double maxbottom, double circlesize, string tocentername, int circlecount, System.Collections.Generic.IEnumerable <Model.ItemMapping> links, object data) { var position = new Point(); var rotate = rotatestep * circleIndex + 2.95; var rsin = Math.Sin(rotate); var rcos = Math.Cos(rotate); //二圆偏移量 var ystep = rsin * radiacenter; var xstep = rcos * radiacenter; position.X = center.X + xstep; position.Y = center.Y - ystep; if (position.Y >= maxbottom) { position.Y = maxbottom; } item.Position = position; el.RadiusX = el.RadiusY = circlesize; item.Width = item.Height = circlesize * 2; var arrow = new Controls.CLMArrow(Canvas); arrow.Fill = this.Fill; arrow.Stroke = this.Stroke; arrow.Rotate = rotate; arrow.ToName = tocentername; arrow.FromName = item.StringValue; arrow.RotateSin = rsin; arrow.RotateCos = rcos; var startystep = (circlesize) * arrow.RotateSin; var startxstep = (circlesize) * arrow.RotateCos; arrow.StartPoint = new Point(item.Position.X - startxstep, item.Position.Y + startystep); var endystep = centerSize * arrow.RotateSin; var endxstep = centerSize * arrow.RotateCos; arrow.EndPoint = new Point(center.X + endxstep, center.Y - endystep); if (links != null) { var count = links.Count <Model.ItemMapping>(); if (count > 0) { var lnk = links.ElementAt <Model.ItemMapping>(0); var tmp = Common.Helper.GetPropertyName(data, lnk.MemberName); if (!string.IsNullOrWhiteSpace(lnk.MarkName)) { arrow.FromMarkName = lnk.MarkName; } arrow.FromValue = tmp == null ? "" : tmp.ToString(); } if (count > 1) { var lnk = links.ElementAt <Model.ItemMapping>(1); var tmp = Common.Helper.GetPropertyName(data, lnk.MemberName); if (!string.IsNullOrWhiteSpace(lnk.MarkName)) { arrow.ToMarkName = lnk.MarkName; } arrow.ToValue = tmp == null ? "" : tmp.ToString(); } } //设置箭头提示事件 if (ArrowTooltipClick != null) { arrow.SetClickEvent(ArrowTooltipClick); } arrow.Draw(); item.TargetControl = arrow; var label = item.CreateLabel(); Canvas.AddChild(label); if (ItemClick != null) { label.Cursor = Cursors.Hand; label.MouseLeftButtonUp += (sender, e) => { var arg = new Model.ItemClickEventArg() { Data = data, Item = item }; ItemClick(sender, arg); }; } if (Canvas.IsAnimate) { label.Visibility = Visibility.Collapsed; var anima = new PointAnimation(); anima.To = position; anima.Duration = TimeSpan.FromMilliseconds(AnimateDurtion); Storyboard.SetTarget(anima, el); el.Center = center; Storyboard.SetTargetProperty(anima, new PropertyPath("Center")); var sizeanimax = new DoubleAnimation(); sizeanimax.From = 0; sizeanimax.To = circlesize; Storyboard.SetTarget(sizeanimax, el); Storyboard.SetTargetProperty(sizeanimax, new PropertyPath("RadiusX")); var sizeanimay = new DoubleAnimation(); sizeanimay.From = 0; sizeanimay.To = circlesize; Storyboard.SetTarget(sizeanimay, el); Storyboard.SetTargetProperty(sizeanimay, new PropertyPath("RadiusY")); anima.Completed += new EventHandler((sender, e) => { label.Visibility = Visibility.Visible; InitMouseEvent(label, arrow); if (circleIndex == circlecount / 2 - 1) { arrow.Show(); currentShowedArrow = arrow; } }); this.storyboard.Children.Add(anima); this.storyboard.Children.Add(sizeanimax); this.storyboard.Children.Add(sizeanimay); } else { el.Center = position; //加入标签 //var label = item.CreateLabel(); //Canvas.AddChild(label); InitMouseEvent(label, arrow); if (circleIndex == circlecount / 2 - 1) { arrow.Show(); currentShowedArrow = arrow; } } }
private WoopsaValue Calibrate(System.Collections.Generic.IEnumerable <IWoopsaValue> arguments) { _minLevel = arguments.ElementAt(0).ToDouble(); _maxLevel = arguments.ElementAt(1).ToDouble(); return(WoopsaValue.Null); }
SharedSettings( System.Collections.Generic.IEnumerable <Bam.Core.Module> objectFiles, System.Type convertExtensionClassType, System.Type conversionInterfaceType, Bam.Core.TypeArray convertParameterTypes) { var sharedInterfaces = SharedInterfaces(objectFiles); var implementedInterfaces = new Bam.Core.TypeArray(sharedInterfaces); implementedInterfaces.Add(conversionInterfaceType); // define a new type, that contains just the shared interfaces between all object files // (any interface not shared, must be cloned later) var typeSignature = "IDESharedSettings"; var assemblyName = new System.Reflection.AssemblyName(typeSignature); var assemblyBuilder = System.AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, System.Reflection.Emit.AssemblyBuilderAccess.Run); var moduleBuilder = assemblyBuilder.DefineDynamicModule("MainModule", true); var sharedSettingsTypeDefn = moduleBuilder.DefineType(typeSignature, System.Reflection.TypeAttributes.Public | System.Reflection.TypeAttributes.Class | System.Reflection.TypeAttributes.AutoClass | System.Reflection.TypeAttributes.AnsiClass | System.Reflection.TypeAttributes.BeforeFieldInit | System.Reflection.TypeAttributes.AutoLayout, typeof(C.SettingsBase), implementedInterfaces.ToArray()); // TODO: is this necessary? #if false sharedSettingsTypeDefn.DefineDefaultConstructor( System.Reflection.MethodAttributes.Public | System.Reflection.MethodAttributes.SpecialName | System.Reflection.MethodAttributes.RTSpecialName); #endif // implement 'automatic property' setter and getters for each property in each interface foreach (var i in sharedInterfaces) { var properties = i.GetProperties(); foreach (var prop in properties) { var dynamicProperty = sharedSettingsTypeDefn.DefineProperty(prop.Name, System.Reflection.PropertyAttributes.None, prop.PropertyType, System.Type.EmptyTypes); var field = sharedSettingsTypeDefn.DefineField("m" + prop.Name, prop.PropertyType, System.Reflection.FieldAttributes.Private); var methodAttrs = System.Reflection.MethodAttributes.Public | System.Reflection.MethodAttributes.HideBySig | System.Reflection.MethodAttributes.Virtual; if (prop.IsSpecialName) { methodAttrs |= System.Reflection.MethodAttributes.SpecialName; } var getter = sharedSettingsTypeDefn.DefineMethod("get_" + prop.Name, methodAttrs, prop.PropertyType, System.Type.EmptyTypes); var setter = sharedSettingsTypeDefn.DefineMethod("set_" + prop.Name, methodAttrs, null, new[] { prop.PropertyType }); var getIL = getter.GetILGenerator(); getIL.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); getIL.Emit(System.Reflection.Emit.OpCodes.Ldfld, field); getIL.Emit(System.Reflection.Emit.OpCodes.Ret); dynamicProperty.SetGetMethod(getter); var setIL = setter.GetILGenerator(); setIL.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); setIL.Emit(System.Reflection.Emit.OpCodes.Ldarg_1); setIL.Emit(System.Reflection.Emit.OpCodes.Stfld, field); setIL.Emit(System.Reflection.Emit.OpCodes.Ret); dynamicProperty.SetSetMethod(setter); } } var projectSettingsConvertMethod = sharedSettingsTypeDefn.DefineMethod("Convert", System.Reflection.MethodAttributes.Public | System.Reflection.MethodAttributes.Final | System.Reflection.MethodAttributes.HideBySig | System.Reflection.MethodAttributes.NewSlot | System.Reflection.MethodAttributes.Virtual, null, convertParameterTypes.ToArray()); var convertIL = projectSettingsConvertMethod.GetILGenerator(); foreach (var i in sharedInterfaces) { var extConvertParameterTypes = new Bam.Core.TypeArray(i); extConvertParameterTypes.AddRange(convertParameterTypes); var methInfo = convertExtensionClassType.GetMethod("Convert", extConvertParameterTypes.ToArray()); if (null == methInfo) { throw new Bam.Core.Exception("Unable to locate the function {0}.{1}(this {2})", convertExtensionClassType.FullName, "Convert", i.Name); } // TODO: can this be simplified, using the ldarg opcode? a simple loop would suffice convertIL.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); if (extConvertParameterTypes.Count > 1) { convertIL.Emit(System.Reflection.Emit.OpCodes.Ldarg_1); } if (extConvertParameterTypes.Count > 2) { convertIL.Emit(System.Reflection.Emit.OpCodes.Ldarg_2); } if (extConvertParameterTypes.Count > 3) { convertIL.Emit(System.Reflection.Emit.OpCodes.Ldarg_3); } convertIL.Emit(System.Reflection.Emit.OpCodes.Call, methInfo); } convertIL.Emit(System.Reflection.Emit.OpCodes.Ret); var sharedSettingsType = sharedSettingsTypeDefn.CreateType(); var attributeType = typeof(Bam.Core.SettingsExtensionsAttribute); // now that we have an instance of the shared settings type, calculate the values of the individual settings across all object files // for all shared interfaces var commonSettings = System.Activator.CreateInstance(sharedSettingsType) as SettingsBase; commonSettings.InitializeAllInterfaces(objectFiles.First(), true, false); foreach (var i in sharedInterfaces) { var attributeArray = i.GetCustomAttributes(attributeType, false); if (0 == attributeArray.Length) { throw new Bam.Core.Exception("Settings interface {0} is missing attribute {1}", i.ToString(), attributeType.ToString()); } var attribute = attributeArray[0] as Bam.Core.SettingsExtensionsAttribute; var cloneSettingsMethod = attribute.GetMethod("Clone", new[] { i, i }); if (null == cloneSettingsMethod) { throw new Bam.Core.Exception("Unable to find extension method {0}.Clone(this {1}, {1}, {1}, {1})", attribute.ExtensionsClassName, i.ToString()); } var intersectSettingsMethod = attribute.GetMethod("Intersect", new[] { i, i }); if (null == intersectSettingsMethod) { throw new Bam.Core.Exception("Unable to find extension method {0}.Intersect(this {1}, {1})", attribute.ExtensionsClassName, i.ToString()); } var objectFileCount = objectFiles.Count(); cloneSettingsMethod.Invoke(null, new[] { commonSettings, objectFiles.First().Settings }); for (int objIndex = 1; objIndex < objectFileCount; ++objIndex) { intersectSettingsMethod.Invoke(null, new[] { commonSettings, objectFiles.ElementAt(objIndex).Settings }); } } return(commonSettings); }