public List <ComputationType> SearchLike(ComputationType computationType) { List <ComputationType> listComputationType = new List <ComputationType>(); SqlParameter[] parametersComputationType = new SqlParameter[] { new SqlParameter("@ComputationTypeID", computationType.ComputationTypeID), new SqlParameter("@Title", computationType.Title), }; using (DataTable table = SqlDBHelper.ExecuteParamerizedSelectCommand("ComputationType_SearchLike", CommandType.StoredProcedure, parametersComputationType)) { if (table.Rows.Count > 0) { foreach (DataRow row in table.Rows) { ComputationType tmpComputationType = new ComputationType(); tmpComputationType.ComputationTypeID = (row["ComputationTypeID"] != DBNull.Value) ? Convert.ToInt32(row["ComputationTypeID"]) : 0; tmpComputationType.Title = row["Title"].ToString(); listComputationType.Add(tmpComputationType); } } } return(listComputationType); }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { Label lblComputationTypeID = GridView1.Rows[e.RowIndex].FindControl("lblComputationTypeID") as Label; TextBox txtTitle = GridView1.Rows[e.RowIndex].FindControl("txtTitle") as TextBox; if (lblComputationTypeID != null && txtTitle != null) { ComputationType computationType = new ComputationType(); computationType.ComputationTypeID = Convert.ToInt32(lblComputationTypeID.Text.Trim()); computationType.Title = txtTitle.Text; //Let us now update the database if (computationTypeHandler.Update(computationType) == true) { lblResult.Text = "Record Updated Successfully"; } else { lblResult.Text = "Failed to Update record"; } //end the editing and bind with updated records. GridView1.EditIndex = -1; BindData(); } }
public bool Exists(ComputationType computationType) { SqlParameter[] parametersComputationType = new SqlParameter[] { new SqlParameter("@ComputationTypeID", computationType.ComputationTypeID) }; return(SqlDBHelper.ExecuteScalar("ComputationType_Exists", CommandType.StoredProcedure, parametersComputationType) > 0); }
public Int64 Insert(ComputationType computationType) { SqlParameter[] parametersComputationType = new SqlParameter[] { new SqlParameter("@Title", computationType.Title) }; computationType.ComputationTypeID = Convert.ToInt32(SqlDBHelper.ExecuteScalar("ComputationType_Insert", CommandType.StoredProcedure, parametersComputationType)); return(computationType.ComputationTypeID); }
public decimal CalculateImage(ComputationType computationType) { if (computationType == ComputationType.ComplexComputation) { return(new Random().Next(500, 600)); } return(new Random().Next(200, 700)); }
public bool Update(ComputationType computationType) { SqlParameter[] parametersComputationType = new SqlParameter[] { new SqlParameter("@ComputationTypeID", computationType.ComputationTypeID), new SqlParameter("@Title", computationType.Title) }; return(SqlDBHelper.ExecuteNonQuery("ComputationType_Update", CommandType.StoredProcedure, parametersComputationType)); }
private PointGrid( ViewPort viewPort, ComputationType computationType, Stream pointStream) { ViewPort = viewPort; ComputationType = computationType; _pointStream = pointStream; _pointsPosition = pointStream.Position; }
private EdgeSpanStream( ViewPort viewPort, ComputationType computationType, int count, Stream spanStream) { ViewPort = viewPort; ComputationType = computationType; Count = count; _spanStream = spanStream; _spansPosition = spanStream.Position; }
protected void btnYES_Click(object sender, EventArgs e) { ComputationType computationType = new ComputationType(); computationType.Title = txtTitle.Text; ComputationTypeHandler computationTypeHandler = new ComputationTypeHandler(); if (computationTypeHandler.Insert(computationType) > 0) { Response.Redirect("Z_ComputationTypeDefault.aspx"); } }
public void PointGrid_Compute( [ArgDescription("The resolution (it will be squared)."), ArgRequired] int resolution, [ArgDescription("Computation type."), ArgDefaultValue(ComputationType.ScalarDouble)] ComputationType computationType, [ArgDescription("The directory for the resulting grid file."), ArgExistingDirectory, ArgDefaultValue(".")] string outputPath) { var viewPort = new ViewPort( Constant.RenderingArea.GetPositiveImagArea(), new Size(resolution, resolution / 2)); PointGrid.Compute( Path.Combine(outputPath, $"pointGrid_{resolution}_{computationType}"), viewPort, computationType, _token); }
public static void Write( string filePath, ViewPort viewPort, ComputationType computationType, IEnumerable <bool> pointsInSet) { using var stream = new FileStream(filePath, FileMode.Create); using var writer = new BinaryWriter(stream, Encoding.ASCII); writer.Write(HeaderText); writer.WriteViewPort(viewPort); writer.Write((int)computationType); int rowsWritten = 0; foreach (var row in pointsInSet.Batch(viewPort.Resolution.Width)) { bool inSet = false; int length = 0; foreach (var point in row) { if (length == 0) { inSet = point; length = 1; } else if (point == inSet) { length++; } else { writer.Write(inSet ? length : -length); inSet = point; length = 1; } } writer.Write(inSet ? length : -length); rowsWritten++; } if (rowsWritten != viewPort.Resolution.Height) { throw new ArgumentException($"Expected {viewPort.Resolution.Height} rows but only got {rowsWritten}."); } }
public ComputationRequest(Complex min, Complex max, int width, int height, int partialWidth, int partialHeight, uint limit, int col, int row, ComputationType type) { Id = Guid.NewGuid(); Type = type; RMin = min.RValue; IMin = min.IValue; RMax = max.RValue; IMax = max.IValue; Width = width; Height = height; PartialWidth = partialWidth; PartialHeight = partialHeight; Limit = limit; Row = row; Col = col; }
public ComputationType GetDetails(int computationTypeID) { ComputationType computationType = new ComputationType(); SqlParameter[] parametersComputationType = new SqlParameter[] { new SqlParameter("@ComputationTypeID", computationTypeID) }; using (DataTable table = SqlDBHelper.ExecuteParamerizedSelectCommand("ComputationType_GetDetails", CommandType.StoredProcedure, parametersComputationType)) { if (table.Rows.Count == 1) { DataRow row = table.Rows[0]; computationType.ComputationTypeID = (row["ComputationTypeID"] != DBNull.Value) ? Convert.ToInt32(row["ComputationTypeID"]) : 0; computationType.Title = row["Title"].ToString(); } } return(computationType); }
public List <ComputationType> GetListAll() { List <ComputationType> listComputationType = null; using (DataTable table = SqlDBHelper.ExecuteSelectCommand("ComputationType_GetListAll", CommandType.StoredProcedure)) { if (table.Rows.Count > 0) { listComputationType = new List <ComputationType>(); foreach (DataRow row in table.Rows) { ComputationType computationType = new ComputationType(); computationType.ComputationTypeID = (row["ComputationTypeID"] != DBNull.Value) ? Convert.ToInt32(row["ComputationTypeID"]) : 0; computationType.Title = row["Title"].ToString(); listComputationType.Add(computationType); } } } return(listComputationType); }
public static void Write( string filePath, ViewPort viewPort, ComputationType computationType, IEnumerable <LogicalEdgeSpan> spans) { if (viewPort.Resolution.Height > (1 << DirectionOffset)) { throw new ArgumentOutOfRangeException(nameof(viewPort.Resolution), "That resolution is too damn big."); } using var stream = new FileStream(filePath, FileMode.Create); using var writer = new BinaryWriter(stream, Encoding.ASCII); writer.Write(HeaderText); writer.WriteViewPort(viewPort); writer.Write((int)computationType); long countPosition = stream.Position; stream.Position += sizeof(int); int count = 0; foreach (var span in spans) { count++; writer.Write(span.Location.X); writer.Write(span.Location.Y | ((int)span.ToOutside << DirectionOffset)); } Log.Info($"Wrote {count:N0} edge spans."); stream.Position = countPosition; writer.Write(count); }
protected void Page_Load(object sender, EventArgs e) { string computationTypeID = Request.QueryString["computationTypeID"] as string; if (computationTypeID == null) { Response.Redirect("Z_ComputationTypeDefault.aspx"); } try { computationTypeComputationTypeID = Convert.ToInt32(computationTypeID.Trim()); computationTypeHandler = new ComputationTypeHandler(); ComputationType computationType = computationTypeHandler.GetDetails(computationTypeComputationTypeID); lblComputationTypeID.Text = computationType.ComputationTypeID.ToString(); lblTitle.Text = computationType.Title.ToString(); } catch (Exception) { Response.Redirect("Z_ComputationTypeDefault.aspx"); } }
public static IScalarKernel BuildScalarKernel(ComputationType type) => type switch {
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM V2.1 SCHEMA ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes a new instance of the <see cref="ComputationCore"/> class. /// </summary> /// <param name="parent"> /// The parent. /// </param> /// <param name="xmlType"> /// The xml type. /// </param> /// <exception cref="SdmxSemmanticException"> /// Throws Validate exception. /// </exception> public ComputationCore(IIdentifiableObject parent, ComputationType xmlType) : base(xmlType, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Computation), parent) { this.description = new List<ITextTypeWrapper>(); this.localId = xmlType.localID; this.softwareLanguage = xmlType.softwareLanguage; this.softwarePackage = xmlType.softwarePackage; this.softwareVersion = xmlType.softwareVersion; this.description = TextTypeUtil.WrapTextTypeV21(xmlType.Description, this); try { this.Validate(); } catch (SdmxSemmanticException ex) { throw new SdmxSemmanticException(ex, ExceptionCode.ObjectStructureConstructionError, this); } catch (Exception th) { throw new SdmxException(th, ExceptionCode.ObjectStructureConstructionError, this); } }
public static void Compute( string filePath, ViewPort viewPort, ComputationType computationType, CancellationToken token) { Log.Info($"Outputting to: {filePath}"); Log.Info($"Resolution: {viewPort.Resolution.Width:N0}x{viewPort.Resolution.Height:N0}"); Log.Info($"Area: {viewPort.Area}"); Log.Info($"Computation type: {computationType}"); IEnumerable <bool> GetPointsInSetScalar() { var kernel = KernelBuilder.BuildScalarKernel(computationType); var rowPointsInSet = new bool[viewPort.Resolution.Width]; using var progress = TimedOperation.Start("points", totalWork: viewPort.Resolution.Area()); for (int row = 0; row < viewPort.Resolution.Height; row++) { Parallel.For( 0, viewPort.Resolution.Width, col => rowPointsInSet[col] = kernel.FindEscapeTime(viewPort.GetComplex(col, row), Constant.IterationRange.Max).IsInfinite); for (int x = 0; x < viewPort.Resolution.Width; x++) { yield return(rowPointsInSet[x]); } progress.AddWorkDone(viewPort.Resolution.Width); } } IEnumerable <bool> GetPointsInSetVectorDoubles() { using var progress = TimedOperation.Start("points", totalWork: viewPort.Resolution.Area()); var vWidth = VectorDoubleKernel.Capacity; var vectorBatches = viewPort.Resolution.Width / vWidth; var remainder = viewPort.Resolution.Width % vWidth; if (remainder != 0) { vectorBatches++; } var lastIndex = vectorBatches - 1; var rowPointsInSet = new bool[viewPort.Resolution.Width]; // TODO: Why is the Parallel.For inside a loop? for (int row = 0; row < viewPort.Resolution.Height; row++) { Parallel.For( 0, vectorBatches, batchIndex => { var realBatch = new double[vWidth]; var imagBatch = new double[vWidth]; var times = new EscapeTime[vWidth]; var batchSize = (batchIndex == lastIndex) ? remainder : vWidth; for (int i = 0; i < batchSize; i++) { var c = viewPort.GetComplex(batchIndex * vWidth + i, row); realBatch[i] = c.Real; imagBatch[i] = c.Imaginary; } VectorDoubleKernel.FindEscapeTimes( realBatch, imagBatch, Constant.IterationRange.Max, times); for (int i = 0; i < batchSize; i++) { rowPointsInSet[batchIndex * vWidth + i] = times[i].Iterations == Constant.IterationRange.Max; } }); for (int x = 0; x < viewPort.Resolution.Width; x++) { yield return(rowPointsInSet[x]); } progress.AddWorkDone(viewPort.Resolution.Width); } } IEnumerable <bool> ChooseEnumerator() => computationType switch { ComputationType.ScalarDouble => GetPointsInSetScalar(), ComputationType.ScalarFloat => GetPointsInSetScalar(), ComputationType.VectorDouble => GetPointsInSetVectorDoubles(), _ => throw new ArgumentException("Unsupported computation type: " + computationType) }; Write(filePath, viewPort, computationType, ChooseEnumerator()); } }