private static SqlString GetProjectionArgument(ICriteriaQuery criteriaQuery, ICriteria criteria, IProjection projection, int loc, IDictionary<string, IFilter> enabledFilters) { SqlString sql = projection.ToSqlString(criteria, loc, criteriaQuery, enabledFilters); return sql.Substring(0, sql.LastIndexOfCaseInsensitive(" as ")); }
/// <summary> /// Initializes a new instance of the ProjectedCoordinateSystem class. /// </summary> /// <param name="horizontalDatum">The horizontal datum to use.</param> /// <param name="axisInfoArray">An array of IAxisInfo representing the axis information.</param> /// <param name="geographicCoordSystem">The geographic coordinate system.</param> /// <param name="linearUnit">The linear units to use.</param> /// <param name="projection">The projection to use.</param> /// <param name="remarks">Remarks about this object.</param> /// <param name="authority">The name of the authority.</param> /// <param name="authorityCode">The code the authority uses to identidy this object.</param> /// <param name="name">The name of the object.</param> /// <param name="alias">The alias of the object.</param> /// <param name="abbreviation">The abbreviated name of this object.</param> internal ProjectedCoordinateSystem( IHorizontalDatum horizontalDatum, IAxisInfo[] axisInfoArray, IGeographicCoordinateSystem geographicCoordSystem, ILinearUnit linearUnit, IProjection projection, string remarks, string authority, string authorityCode, string name, string alias, string abbreviation) : base(remarks, authority, authorityCode, name, alias, abbreviation) { if (axisInfoArray==null) { throw new ArgumentNullException("axisInfoArray"); } if (geographicCoordSystem==null) { throw new ArgumentNullException("geographicCoordSystem"); } if (projection==null) { throw new ArgumentNullException("projection"); } if (linearUnit==null) { throw new ArgumentNullException("linearUnit"); } _horizontalDatum=horizontalDatum; _axisInfoArray= axisInfoArray; _geographicCoordSystem = geographicCoordSystem; _projection= projection; _linearUnit = linearUnit; }
/// <summary> /// Creates a new OSM data layer. /// </summary> /// <param name="projection"></param> public LayerGpx(IProjection projection) { _projection = projection; this.Scene = new Scene2DSimple(); this.Scene.BackColor = SimpleColor.FromKnownColor(KnownColor.Transparent).Value; }
public ProjectionWrapper(IProjection projection, ILogger log) { this.projection = projection; this.buferredProjection = projection as IBuferredProjection; this.log = log; Init(); }
/// <summary> /// Gets the filter modifier criterion. /// </summary> /// <param name="projection">The projection.</param> /// <param name="filerModifier">The filer modifier.</param> /// <param name="value">The value.</param> /// <returns>A <see cref="NHibernate.Criterion.ICriterion"/></returns> public static ICriterion GetFilterModifierCriterion( IProjection projection, string filerModifier, object value ) { ICriterion ret = null; if ( filerModifier == FilterModifier.EqualTo ) { ret = Restrictions.Eq ( projection, value ); } else if ( filerModifier == FilterModifier.GreaterThan ) { ret = ( Restrictions.Gt ( projection, value ) ); } else if ( filerModifier == FilterModifier.GreaterThanOrEqualTo ) { ret = ( Restrictions.Ge ( projection, value ) ); } else if ( filerModifier == FilterModifier.LessThen ) { ret = ( Restrictions.Lt ( projection, value ) ); } else if ( filerModifier == FilterModifier.LessThenOrEqualTo ) { ret = ( Restrictions.Le ( projection, value ) ); } else { throw new ArgumentException ( "Invalid Filter Modifier" ); } return ret; }
public static IMathTransform CreateCoordinateOperation(IProjection projection, IEllipsoid ellipsoid) { ParameterList parameterList = new ParameterList(); for(int i=0; i< projection.NumParameters; i++) { ProjectionParameter param = projection.GetParameter(i); parameterList.Add(param.Name,param.Value); } parameterList.Add("semi_major",ellipsoid.SemiMajorAxis); parameterList.Add("semi_minor",ellipsoid.SemiMinorAxis); IMathTransform transform = null; switch(projection.Name.ToLower()) { case "mercator": //1SP transform = new MercatorProjection(parameterList); break; case "transverse_mercator": transform = new TransverseMercatorProjection(parameterList); break; case "albers": transform = new AlbersProjection(parameterList); break; case "lambert": transform = new LambertConformalConic2SPProjection(parameterList); break; default: throw new NotSupportedException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Projection {0} is not supported.",projection.AuthorityCode)); } return transform; }
public IsDescendantOfExpression(string propertyName, string value) { _propertyName = propertyName; _projection = NHibernate.Criterion.Projections.Property(_propertyName); _value = value; _typedValue = new TypedValue(NHibernateUtil.String, _value, EntityMode.Poco); }
public LikeExpression(string propertyName, string value, char? escapeChar, bool ignoreCase) { this.projection = Projections.Property(propertyName); this.value = value; this.escapeChar = escapeChar; this.ignoreCase = ignoreCase; }
public OrderBy(IProjection projection, OrderByDirection direction) { Require.NotNull(projection, "projection"); Direction = direction; Projection = projection; }
public bool IsVersionExist(IProjection projection) { using (var con = db.OpenDbConnection()) { return con.Count<ProjectionVersionDto>(x => x.ProjectionName == GetName(projection)) > 0; } }
public Projection(ISpatialReference pSpatialReference, IWorkspace pWorkSpace) { IProjectedCoordinateSystem pProjectedCoordinateSys = pSpatialReference as IProjectedCoordinateSystem; m_pSpatialReference = pSpatialReference; m_pIProjection = pProjectedCoordinateSys.Projection; m_pWorkspace = pWorkSpace; }
/** * Adds the given projection. * * @param projection the projection to add * @return this */ public IExitOperationsCollector AddProjection(IProjection projection) { if (projection.GetType().IsAssignableFrom(distinct.GetType())) { this.distinct = (Distinct) projection; //TODO: Distinct doesn't work yet log.Error("Distinct is not ready yet"); throw new NotSupportedException(); } if (projection.GetType().IsAssignableFrom(rowCountProjection.GetType())) { rowCountProjection = (RowCountProjection) projection; } if (projection.GetType().IsAssignableFrom(aggregateProjection.GetType())) { if (projection.ToString().ToLower().StartsWith("avg")) { this.avgProjection = (AggregateProjection)projection; } else { this.aggregateProjection = (AggregateProjection)projection; } } else { log.Error("Adding an unsupported Projection: " + projection.GetType().Name); throw new NotSupportedException(); } return this; }
private static IMathTransform CreateCoordinateOperation(IProjection projection, IEllipsoid ellipsoid) { List<ProjectionParameter> parameterList = new List<ProjectionParameter>(projection.NumParameters); for (int i = 0; i < projection.NumParameters; i++) parameterList.Add(projection.GetParameter(i)); parameterList.Add(new ProjectionParameter("semi_major", ellipsoid.SemiMajorAxis)); parameterList.Add(new ProjectionParameter("semi_minor", ellipsoid.SemiMinorAxis)); IMathTransform transform = null; switch (projection.ClassName.ToLower()) { case "mercator_1sp": case "mercator_2sp": //1SP transform = new Mercator(parameterList); break; case "transverse_mercator": transform = new TransverseMercator(parameterList); break; case "albers": transform = new AlbersProjection(parameterList); break; case "lambert_conformal_conic": case "lambert_conformal_conic_2sp": transform = new LambertConformalConic2SP(parameterList); break; default: throw new NotSupportedException(String.Format("Projection {0} is not supported.", projection.ClassName)); } return transform; }
private static SqlString GetProjectionArgument(ICriteriaQuery criteriaQuery, ICriteria criteria, IProjection projection, int loc, IDictionary<string, IFilter> enabledFilters) { SqlString sql = projection.ToSqlString(criteria, loc, criteriaQuery, enabledFilters); return StringHelper.RemoveAsAliasesFromSql(sql); }
public string GetModifiedReason(IProjection projection) { if (projection == null || projection is ICheckpointStore) { return string.Empty; } try { var dto = collection.AsQueryable().FirstOrDefault(x => x.ProjectionName == GetName(projection)); if (dto == null) { return "Version is absent"; } if (dto.Version != projection.Version) { return "Version is different"; } if (dto.Hash != StructureHash.CalculateMD5(projection)) { return "Hash is different"; } return string.Empty; } catch (Exception ex) { if (ex is SqlException || ex.Message.Contains("Invalid column name")) { return "Invalid column name"; } throw; } }
/// <summary> /// Creates a new MapCSS scene target. /// </summary> /// <param name="mapCSSInterpreter"></param> /// <param name="scene"></param> /// <param name="projection"></param> public StyleOsmStreamSceneTarget(StyleInterpreter mapCSSInterpreter, Scene2D scene, IProjection projection) { _projection = projection; _scene = scene; _mapCSSInterpreter = mapCSSInterpreter; }
public static Rectangle QuadKeyToRect(IProjection projection, QuadKey quadKey) { var boundingBox = QuadKeyToBoundingBox(quadKey); var minPoint = projection.Project(boundingBox.MinPoint, 0); var maxPoint = projection.Project(boundingBox.MaxPoint, 0); return new Rectangle(minPoint.x, minPoint.z, maxPoint.x - minPoint.x, maxPoint.z - minPoint.z); }
/// <summary> /// Creates a new MapCSS scene target. /// </summary> /// <param name="styleInterpreter"></param> /// <param name="scene"></param> /// <param name="projection"></param> /// <param name="stream"></param> public StyleOsmStreamSceneStreamTarget(StyleInterpreter styleInterpreter, Scene2D scene, IProjection projection, Stream stream) { _projection = projection; _scene = scene; _styleInterpreter = styleInterpreter; _stream = stream; }
/// <summary> /// Initializes a new instance of the ProjectedCoordinateSystem class. /// </summary> /// <param name="horizontalDatum">The horizontal datum to use.</param> /// <param name="axisInfoArray">An array of IAxisInfo representing the axis information.</param> /// <param name="geographicCoordSystem">The geographic coordinate system.</param> /// <param name="linearUnit">The linear units to use.</param> /// <param name="projection">The projection to use.</param> internal ProjectedCoordinateSystem( IHorizontalDatum horizontalDatum, IAxisInfo[] axisInfoArray, IGeographicCoordinateSystem geographicCoordSystem, ILinearUnit linearUnit, IProjection projection) : this(horizontalDatum, axisInfoArray, geographicCoordSystem, linearUnit, projection, "", "", "", "", "", "") { }
public LikeExpression(string propertyName, string value, char? escapeChar, bool ignoreCase) { this.projection = Projections.Property(propertyName); this.value = value; typedValue = new TypedValue(NHibernateUtil.String, this.value, EntityMode.Poco); this.escapeChar = escapeChar; this.ignoreCase = ignoreCase; }
public void Setup() { _compositionRoot = TestHelper.GetCompositionRoot(TestHelper.WorldZeroPoint, (container, _) => container.Register(Component.For<IElevationProvider>().Use<FlatElevationProvider>())); _elementEditor = _compositionRoot.GetService<IElementEditor>(); _dataLoader = _compositionRoot.GetService<IMapDataLoader>(); _stylesheet = _compositionRoot.GetService<Stylesheet>(); _projection = _compositionRoot.GetService<IProjection>(); }
/// <summary> Creates <see cref="Tile"/>. </summary> /// <param name="quadKey"></param> /// <param name="stylesheet"></param> /// <param name="projection"> Projection. </param> internal Tile(QuadKey quadKey, Stylesheet stylesheet, IProjection projection) { QuadKey = quadKey; Stylesheet = stylesheet; Projection = projection; BoundingBox = GeoUtils.QuadKeyToBoundingBox(quadKey); Rectangle = GeoUtils.QuadKeyToRect(projection, quadKey); }
public InsensitiveLikeIncludeNullExpression(IProjection projection, string value, MatchMode matchMode) { _projection = projection; if(value != null) _criterion = Restrictions.Disjunction() .Add(Restrictions.InsensitiveLike(projection, value, matchMode)) .Add(Restrictions.IsNull(projection)); else _criterion = Restrictions.IsNull(projection); }
/// <summary> /// Initializes a new instance of a projected coordinate system /// </summary> /// <param name="datum">Horizontal datum</param> /// <param name="geographicCoordinateSystem">Geographic coordinate system</param> /// <param name="linearUnit">Linear unit</param> /// <param name="projection">Projection</param> /// <param name="axisInfo">Axis info</param> /// <param name="name">Name</param> /// <param name="authority">Authority name</param> /// <param name="code">Authority-specific identification code.</param> /// <param name="alias">Alias</param> /// <param name="abbreviation">Abbreviation</param> /// <param name="remarks">Provider-supplied remarks</param> internal ProjectedCoordinateSystem(IHorizontalDatum datum, IGeographicCoordinateSystem geographicCoordinateSystem, ILinearUnit linearUnit, IProjection projection, List<AxisInfo> axisInfo, string name, string authority, long code, string alias, string remarks, string abbreviation) : base(datum, axisInfo, name, authority, code, alias, abbreviation, remarks) { _GeographicCoordinateSystem = geographicCoordinateSystem; _LinearUnit = linearUnit; _Projection = projection; }
public AggregateExitOperation(IProjection projection) { string projectionAsString = projection.ToString(); int start = projectionAsString.IndexOf("("); string aggregateName = projectionAsString.Substring(0, start); start++; int stop = projectionAsString.IndexOf(")"); _fieldName = projectionAsString.Substring(start, stop - start); _aggregate = (SupportedAggregations) Enum.Parse(_aggregate.GetType(), aggregateName.ToUpper()); }
/// <summary> /// 생성자 /// </summary> /// <param name="projection"></param> /// <param name="value"></param> public EqIncludeNullExpression(IProjection projection, object value) { _projection = projection; if(value != null) _criterion = Restrictions.Disjunction() .Add(Restrictions.Eq(projection, value)) .Add(Restrictions.IsNull(projection)); else _criterion = Restrictions.IsNull(projection); }
public static SqlString[] GetColumnNames( string propertyName, IProjection projection, ICriteriaQuery criteriaQuery, ICriteria criteria, IDictionary<string, IFilter> enabledFilters) { if (projection == null) return GetColumnNamesUsingPropertyName(criteriaQuery, criteria, propertyName); else return GetColumnNamesUsingProjection(projection, criteriaQuery, criteria, enabledFilters); }
internal static SqlString[] GetColumnNamesUsingProjection(IProjection projection, ICriteriaQuery criteriaQuery, ICriteria criteria, IDictionary<string, IFilter> enabledFilters) { SqlString sqlString = projection.ToSqlString(criteria, criteriaQuery.GetIndexForAlias(), criteriaQuery, enabledFilters); return new SqlString[] { StringHelper.RemoveAsAliasesFromSql(sqlString) }; }
public IProjectionExitOperation GetProjectionExitOperation(IProjection projection, ISessionFactoryImplementor sessionFactoryImplementor) { if (projection.GetType().IsAssignableFrom(typeof(RowCountExitOperation))) { return new RowCountExitOperation(projection); } if (projection.GetType().IsAssignableFrom(typeof(AggregateProjection))) { return new AggregateExitOperation(projection); } throw new NotSupportedException("This project is not supported: " + projection.GetType()); }
/// <summary> /// Creates a new OSM data layer. /// </summary> /// <param name="dataSource"></param> /// <param name="styleInterpreter"></param> /// <param name="projection"></param> public LayerOsm(IDataSourceReadOnly dataSource, StyleInterpreter styleInterpreter, IProjection projection) { // build the zoom-level cutoffs. List<float> zoomFactors = new List<float>(); zoomFactors.Add(16); zoomFactors.Add(14); zoomFactors.Add(12); zoomFactors.Add(10); _dataSource = dataSource; _styleSceneManager = new StyleSceneManager(styleInterpreter, projection, zoomFactors); }
/// <summary> /// Apply a "less than or equal" constraint to two properties /// </summary> /// <param name="lhsProjection">The LHS projection.</param> /// <param name="rhsProjection">The RHS projection.</param> /// <returns>A <see cref="LePropertyExpression"/> .</returns> public static AbstractCriterion LeProperty(IProjection lhsProjection, IProjection rhsProjection) { return(new LePropertyExpression(lhsProjection, rhsProjection)); }
/// <summary> /// Creates a <see cref="ProjectedCoordinateSystem"/> using a projection object. /// </summary> /// <param name="name">Name of projected coordinate system</param> /// <param name="gcs">Geographic coordinate system</param> /// <param name="projection">Projection</param> /// <param name="linearUnit">Linear unit</param> /// <param name="axis0">Primary axis</param> /// <param name="axis1">Secondary axis</param> /// <returns>Projected coordinate system</returns> public IProjectedCoordinateSystem CreateProjectedCoordinateSystem(string name, IGeographicCoordinateSystem gcs, IProjection projection, ILinearUnit linearUnit, AxisInfo axis0, AxisInfo axis1) { if (String.IsNullOrEmpty(name)) { throw new ArgumentException("Invalid name"); } if (gcs == null) { throw new ArgumentException("Geographic coordinate system was null"); } if (projection == null) { throw new ArgumentException("Projection was null"); } if (linearUnit == null) { throw new ArgumentException("Linear unit was null"); } List <AxisInfo> info = new List <AxisInfo>(2); info.Add(axis0); info.Add(axis1); return(new ProjectedCoordinateSystem(null, gcs, linearUnit, projection, info, name, String.Empty, -1, String.Empty, String.Empty, String.Empty)); }
public static AbstractCriterion InsensitiveLike(IProjection projection, string value, MatchMode matchMode) { return(new InsensitiveLikeExpression(projection, value, matchMode)); }
/// <summary> /// Apply a "between" constraint to the projection /// </summary> /// <param name="projection">The projection.</param> /// <param name="lo">The low value for the Property.</param> /// <param name="hi">The high value for the Property.</param> /// <returns>A <see cref="BetweenExpression"/>.</returns> public static AbstractCriterion Between(IProjection projection, object lo, object hi) { return(new BetweenExpression(projection, lo, hi)); }
public Sql_cssql(IProjection model, IProjection result) : base(model, result) { }
/// <summary> /// Returns true if this layer is visible for the given project and relative zoom factor. /// </summary> /// <param name="projection"></param> /// <param name="zoomFactor"></param> /// <returns></returns> public bool IsLayerVisibleFor(IProjection projection, float zoomFactor) { return(this.IsLayerVisibleFor((float)projection.ToZoomLevel(zoomFactor))); }
/// <summary> /// Apply an "not equal" constraint to the projections /// </summary> /// <param name="propertyName">Name of the property.</param> /// <param name="rhsProjection">The RHS projection.</param> /// <returns>A <see cref="EqPropertyExpression"/> .</returns> public static AbstractCriterion NotEqProperty(string propertyName, IProjection rhsProjection) { return(new NotExpression(new EqPropertyExpression(propertyName, rhsProjection))); }
public ProjectionList Add(IProjection proj) { elements.Add(proj); return(this); }
private static string[] GetColumnAliases(string alias, int position, ICriteria criteria, ICriteriaQuery criteriaQuery, IProjection projection) { return(projection is IEnhancedProjection ? ((IEnhancedProjection)projection).GetColumnAliases(alias, position, criteria, criteriaQuery) : projection.GetColumnAliases(alias, position)); }
public SqlFunctionProjection(string functionName, IProjection returnTypeProjection, params IProjection[] args) { this.functionName = functionName; this.returnTypeProjection = returnTypeProjection; this.args = args; }
private static SqlString GetProjectionArgument(ICriteriaQuery criteriaQuery, ICriteria criteria, IProjection projection, int loc) { SqlString sql = projection.ToSqlString(criteria, loc, criteriaQuery); return(SqlStringHelper.RemoveAsAliasesFromSql(sql)); }
/// <summary> /// Creates a new primitives layer. /// </summary> public LayerPrimitives(IProjection projection) { _projection = projection; _scene = new Scene2DSimple(); }
public BatchedCommand_cssql(IProjection model, IProjection result) : base(model, result) { }
/// <summary> /// Apply a "less than or equal" constraint to two properties /// </summary> /// <param name="propertyName">The lhs Property Name</param> /// <param name="projection">The projection.</param> /// <returns>A <see cref="LePropertyExpression"/> .</returns> public static AbstractCriterion LeProperty(string propertyName, IProjection projection) { return(new LePropertyExpression(propertyName, projection)); }
/// <summary> /// Apply a "less than or equal" constraint to two properties /// </summary> /// <param name="projection">The projection.</param> /// <param name="otherPropertyName">The rhs Property Name</param> /// <returns>A <see cref="LePropertyExpression"/> .</returns> public static AbstractCriterion LeProperty(IProjection projection, string otherPropertyName) { return(new LePropertyExpression(projection, otherPropertyName)); }
private void PushProjection(IProjection projection) { AddLastProjection(); lastProjection = projection; }
/// <summary> /// Apply an "equal" constraint from the projection to the identifier property /// </summary> /// <param name="projection">The projection.</param> /// <returns>ICriterion</returns> public static AbstractCriterion IdEq(IProjection projection) { return(new IdentifierEqExpression(projection)); }
/// <summary> /// Create an alias for the previous projection /// </summary> public QueryOverProjectionBuilder <T> WithAlias(string alias) { lastProjection = Projections.Alias(lastProjection, alias); return(this); }
public ProjectionList Add(IProjection projection, String alias) { return(Add(Projections.Alias(projection, alias))); }
public TemplateQuery1_cssql(IProjection model, IProjection result) : base(model, result) { }
/// <summary> /// Apply an "equal" constraint to lshProjection and rshProjection /// </summary> /// <param name="lshProjection">The LHS projection.</param> /// <param name="rshProjection">The RSH projection.</param> /// <returns>A <see cref="EqPropertyExpression"/> .</returns> public static AbstractCriterion EqProperty(IProjection lshProjection, IProjection rshProjection) { return(new EqPropertyExpression(lshProjection, rshProjection)); }
public Distinct(IProjection proj) { this.projection = proj; }
/// <summary> /// Apply an "in" constraint to the projection /// </summary> /// <param name="projection">The projection.</param> /// <param name="values">An ICollection of values.</param> /// <returns>An <see cref="InExpression"/>.</returns> public static AbstractCriterion In(IProjection projection, ICollection values) { object[] ary = new object[values.Count]; values.CopyTo(ary, 0); return(new InExpression(projection, ary)); }
/// <summary> /// Apply a "like" constraint to the project /// </summary> /// <param name="projection">The projection.</param> /// <param name="value">The value for the Property.</param> /// <param name="matchMode">The match mode.</param> /// <returns>A <see cref="LikeExpression"/>.</returns> public static SimpleExpression Like(IProjection projection, string value, MatchMode matchMode) { return(new SimpleExpression(projection, matchMode.ToMatchString(value), " like ")); }
/// <summary> /// Apply an "in" constraint to the projection /// </summary> /// <param name="projection">The projection.</param> /// <param name="values">An array of values.</param> /// <returns>An <see cref="InExpression"/>.</returns> public static AbstractCriterion In(IProjection projection, object[] values) { return(new InExpression(projection, values)); }
/// <summary> /// Apply a "like" constraint to the project /// </summary> /// <param name="projection">The projection.</param> /// <param name="value">The value for the Property.</param> /// <returns>A <see cref="LikeExpression"/>.</returns> public static SimpleExpression Like(IProjection projection, object value) { return(new SimpleExpression(projection, value, " like ")); }
/// <summary> /// A case-insensitive "like", similar to Postgres "ilike" operator /// </summary> /// <param name="projection">The projection.</param> /// <param name="value">The value for the Property.</param> /// <returns> /// An <see cref="InsensitiveLikeExpression"/>. /// </returns> public static AbstractCriterion InsensitiveLike(IProjection projection, object value) { return(new InsensitiveLikeExpression(projection, value)); }
/// <summary> /// Apply an "is not null" constraint to the named property /// </summary> /// <param name="projection">The projection.</param> /// <returns>A <see cref="NotNullExpression"/>.</returns> public static AbstractCriterion IsNotNull(IProjection projection) { return(new NotNullExpression(projection)); }
/// <summary> /// Select an arbitrary projection /// </summary> public QueryOverProjectionBuilder <T> Select(IProjection projection) { PushProjection(projection); return(this); }
public async Task <JsonResult> Data() { string staff_id = Convert.ToString(Session["staff_id"]); string _month = Request["month"]; string _year = CommonHelper.GetValue(Request["year"], "0"); if (string.IsNullOrEmpty(_month)) { _month = Request["month[]"]; } if (string.IsNullOrEmpty(_month)) { _month = "0"; } string title = "Overtime"; string yaxis = "Duration (hours)"; double[] b = new double[12]; string[] categories = new string[12]; double[] c = new double[12]; for (int i = 1; i < 13; i++) { categories[i - 1] = CommonHelper.GetAbbreviatedMonthName(i); } ISession se = NHibernateHelper.CurrentSession; ICriteria cr = se.CreateCriteria <Attendance>(); if (!string.IsNullOrEmpty(staff_id)) { cr.Add(Restrictions.Eq("Staffid", staff_id)); } if (_year != "0") { int year = Convert.ToInt32(_year); IProjection yearProjection = Projections.SqlFunction("year", NHibernateUtil.Int32, Projections.Property("Workdate")); cr.Add(Restrictions.Eq(yearProjection, year)); title = string.Format("Overtime for Year {0}", year); } if (_month != "0") { string[] monthlist = _month.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); IProjection monthProjection = Projections.SqlFunction("month", NHibernateUtil.Int32, Projections.Property("Workdate")); cr.Add(Restrictions.In(monthProjection, monthlist)); } IList <Attendance> list = await Task.Run(() => { return(cr.List <Attendance>()); }); await Task.Run(() => { foreach (Attendance o in list) { DateTime to = o.Timeout.GetValueOrDefault(); DateTime v = new DateTime(to.Year, to.Month, to.Day, 18, 0, 0, DateTimeKind.Utc); double x = (to - v).TotalSeconds / 3600.0; int m = o.Workdate.GetValueOrDefault().Month; if (x > 0) { b[m - 1] += x; } } }); for (int i = 0; i < b.Length; i++) { c[i] = Math.Round(b[i], 2); } return(Json(new Dictionary <string, object> { { "data", c }, { "categories", categories }, { "title", title }, { "yaxis", yaxis } }, JsonRequestBehavior.AllowGet)); }