public Angel.Model.GridBinding GetGridBinding(string reportname) { Dictionary <string, Dimention> report = GetReport(); Dimention dimention = report[reportname]; return(dimention.GridBinding); }
/// <summary> /// 查询固定数据语句 /// </summary> /// <param name="tabID">tableid</param> /// <returns></returns> public DataTable GetDataSourceSqlId(string tabID, string where) { try { Dictionary <string, Dimention> report = GetReport(); Dimention dimention = report[tabID]; ArrayList al = new ArrayList(); string sql = ""; string citydatawherecondition = string.Empty; DataTable dt = new DataTable(); sql = dimention.SqlAll.Replace("%Where%", where); if (tabID.Equals("")) { dt = null; } else { al.Add(sql); dt = MySqlHelpers.Query(al).Tables[0]; } return(dt); } catch (Exception ex) { FileLog.WriteLog(ex.ToString()); return(null); } }
public static Dictionary <string, Dimention> GetReport() { string CacheKey = "report"; Dictionary <string, Dimention> TABList = new Dictionary <string, Dimention>(); object objModel = DataCache.GetCache(CacheKey); if (objModel == null || ((Dictionary <string, Dimention>)objModel).Count == 0) { DataCache.SetCache(CacheKey, TABList, DateTime.Now.AddMinutes(180), TimeSpan.Zero); string filepath = AppDomain.CurrentDomain.BaseDirectory + "xmldb\\";//获取基目录 DirectoryInfo di = new DirectoryInfo(filepath); FileInfo[] files = di.GetFiles(); foreach (FileInfo file in files) { Report tempreport = (Report)XmlSerializHelper.Deserialize <Report>(file.FullName); foreach (Dimention dimention in tempreport.TABList) { Dimention tempdimention = dimention; TABList.Add(tempdimention.TabId, tempdimention); } } DataCache.SetCache(CacheKey, TABList, DateTime.Now.AddMinutes(180), TimeSpan.Zero); } else { TABList = (Dictionary <string, Dimention>)DataCache.GetCache(CacheKey); } return(TABList); }
/// <summary> /// INSERT/UPDATE/DELETE公共方法 /// </summary> /// <param name="param">参数</param> /// <returns>影响记录数</returns> public int InsUpdDelDataTableToParam(Dictionary <string, List <Object> > param) { Dictionary <string, Dimention> report = GetReport(); string sql = string.Empty; int count = 0; List <string> repSql = new List <string>(); try { if (param != null) { foreach (var d in param) { Dimention dimention = report[d.Key]; sql = dimention.SqlAll; int i = 0; foreach (Object value in d.Value) { ////替换后的sql语句 sql = sql.Replace("{" + i + "}", value.ToString()); i = i + 1; } } } count = MySqlHelpers.ExecuteNonQuery(sql); } catch (Exception ex) { FileLog.WriteLog(ex.ToString()); } return(count); }
/// <summary> /// 配置文件名称返回tabid /// </summary> /// <returns></returns> public Dictionary <string, Dimention> GetBigTableId(string filename) { string CacheKey = filename; Dictionary <string, Dimention> TABList = new Dictionary <string, Dimention>(); object objModel = DataCache.GetCache(CacheKey); if (objModel == null) { DataCache.SetCache(CacheKey, TABList, DateTime.Now.AddMinutes(180), TimeSpan.Zero); string filepath = AppDomain.CurrentDomain.BaseDirectory + "xmldb\\";//获取基目录 FileInfo file = new FileInfo(filepath + filename + ".config"); Report tempreport = (Report)XmlSerializHelper.Deserialize <Report>(file.FullName); foreach (Dimention dimention in tempreport.TABList) { Dimention tempdimention = dimention; TABList.Add(tempdimention.TabId, tempdimention); } DataCache.SetCache(CacheKey, TABList, DateTime.Now.AddMinutes(180), TimeSpan.Zero); } else { TABList = (Dictionary <string, Dimention>)DataCache.GetCache(CacheKey); } return(TABList); }
/// <summary> /// 生成SQL语句 /// </summary> /// <param name="tabId">config文件中TAB Id值</param> /// <param name="values">传递的参数</param> /// <returns></returns> public string getSQL(string tabId, params object[] values) { Dictionary <string, Dimention> report = GetReport(); Dimention dimention = report[tabId]; string sql = String.Format(dimention.SqlAll, values); return(sql); }
public void CanFill_to_Bigger() { var maxSize = new Dimention(width: 1500, height: 1500); var resizeSettings = new ResizeOption(ResizeOperationType.Fill, ImageType.Preview_M, maxSize); var result = Resize(sourceFileName: "Lama.jpg", targetDimention: resizeSettings, dstFileName: "Lama fill Big.jpg"); Assert.True(result.Success); }
public void CanFill_BiggerHighBox() { var dFrom = new Dimention(width: 300, height: 400); var dTo = new Dimention(width: 500, height: 500); var result = dFrom.GetCenterRectangleToFill(dTo); Assert.True(result.X == 0 && result.Y == 50 && result.Width == 300 && result.Height == 300); }
public void CanFit_SmallerWideBox() { var dOriginal = new Dimention(width: 100, height: 50); var dBox = new Dimention(width: 50, height: 50); var scaled = dOriginal.GetSizeToFitInto(dBox); Assert.True(scaled.Width == 50 && scaled.Height == 25); }
public void CanFit_BiggerHighBox() { var dOriginal = new Dimention(width: 100, height: 100); var dBox = new Dimention(width: 200, height: 150); var scaled = dOriginal.GetSizeToFitInto(dBox); Assert.True(scaled.Width == 150 && scaled.Height == 150); }
public string GetTableSQLByParams(string TabId_Sel, string TabId_Ins, string tabName, string Indicatorid, string city, string date, string cdate, decimal IData, string sourceName, Dictionary <string, string> dicInsert, Dictionary <string, List <Object> > dicNewIData, string userid, string type) { //select语句 Dictionary <string, Dimention> report = GetReport(); Dimention dimention = report[TabId_Sel]; string sql = "", sql_insert, strkey; if (string.IsNullOrEmpty(type)) { sql = String.Format(dimention.SqlAll, Indicatorid, city, tabName, Indicatorid, city, date); } else { sql = String.Format(dimention.SqlAll, Indicatorid, city, tabName, Indicatorid, city, date, type); } //key值 strkey = Indicatorid + city; //insert语句 dimention = report[TabId_Ins]; if (string.IsNullOrEmpty(type)) { sql_insert = String.Format(dimention.SqlAll, tabName, Indicatorid, IData, sourceName, city, date, DateTime.Now, userid, cdate); } else { sql_insert = String.Format(dimention.SqlAll, tabName, Indicatorid, IData, sourceName, city, date, DateTime.Now, userid, cdate, type); } if (dicInsert.ContainsKey(strkey)) { dicInsert[strkey] = sql_insert; } else { dicInsert.Add(strkey, sql_insert); } // IData值 if (dicNewIData.ContainsKey(strkey)) { dicNewIData[strkey][0] = IData; dicNewIData[strkey][1] = sourceName; } else { List <Object> v = new List <object>(); v.Add(IData); v.Add(sourceName); dicNewIData.Add(strkey, v); } return(sql); }
public static Series AddSeries(int frame, ushort[][] image, Dimention dim, ProfileType type) { Series ser = new Series("Frame " + frame) { ChartType = SeriesChartType.Spline, BorderWidth = 5 }; ushort[][] newImage = null; switch (dim) { case Dimention.Y: newImage = image; break; case Dimention.X: newImage = new ushort[image[0].Length][]; for (int x = 0; x < image[0].Length; x++) { newImage[x] = new ushort[image.Length]; for (int y = 0; y < image.Length; y++) { newImage[x][y] = image[y][x]; } } break; } for (int i = 0; i < newImage.Length; i++) { switch (type) { case ProfileType.Avg: ser.Points.AddXY((double)i, (double)GetAverage(newImage[i])); break; case ProfileType.Max: ser.Points.AddXY((double)i, (double)newImage[i].Max()); break; case ProfileType.Min: ser.Points.AddXY((double)i, (double)newImage[i].Min()); break; } } return(ser); }
/// <summary> /// 新增方法传入json方式 /// </summary> /// <param name="param"></param> /// <returns>DataTable</returns> public DataTable GetDataTableToParamID(Dictionary <string, Newtonsoft.Json.Linq.JArray> param) { Dictionary <string, Dimention> report = GetReport(); string sql = string.Empty; DataTable dt = null; List <string> repSql = new List <string>(); string tableName = string.Empty; try { if (param != null) { foreach (var d in param) { Dimention dimention = report[d.Key]; tableName = dimention.TabName; sql = dimention.SqlAll; foreach (var arry in d.Value) { int i = 0; ////替换后的sql语句 foreach (var o in Newtonsoft.Json.Linq.JObject.FromObject(arry)) { sql = sql.Replace("[@c" + i + "]", o.Value.ToString()); i = i + 1; } } } } // if() dt = MySqlHelpers.GetDataTable(sql); dt.TableName = tableName; } catch (Exception ex) { FileLog.WriteLog(ex.ToString()); } if (dt != null) { return(dt); } else { return(null); } }
// 將 buffer 往 vector 移動一格. // camera 也會更著移動. public void MoveForward(Vector2D vector) { // remove line. Dimention dimention = Dimention.Null; int value = 0; switch (vector) { case Vector2D.Up: dimention = Dimention.Y; value = center.Y.value - extra; break; case Vector2D.Down: dimention = Dimention.Y; value = center.Y.value + extra; break; case Vector2D.Left: dimention = Dimention.X; value = center.X.value + extra; break; case Vector2D.Right: dimention = Dimention.X; value = center.X.value - extra; break; } RemoveLine(dimention, value); // move bufferCenter and camera. this.center.MoveFor(vector, 1); // GameObjectMove(camera, Convert(vector)); // add line. Point2D point = this.center.Copy(); point.MoveFor(vector, extra); vector = VectorConvert.Rotate(vector); point.MoveFor(vector, extra); vector = VectorConvert.Invert(vector); AddLine(point, vector, Width); }
// just remove grids private void RemoveLine(Dimention dimention, int value) { int index = 0; while (index != grids.Count) { if (IsOnLine(grids[index].binded, dimention, value)) { grids[index].Destroy(); grids.RemoveAt(index); } else { ++index; } } }
/// <summary> /// 返回DataSet /// </summary> /// <param name="param"></param> /// <returns></returns> public DataSet GetDataSetToParamID(Dictionary <string, Newtonsoft.Json.Linq.JArray> param) { Dictionary <string, Dimention> report = GetReport(); string sql = string.Empty; DataSet ds = null; List <string> repSql = new List <string>(); ArrayList al = new ArrayList(); try { if (param != null) { foreach (var d in param) { Dimention dimention = report[d.Key]; sql = dimention.SqlAll; foreach (var arry in d.Value) { int i = 0; ////替换后的sql语句 foreach (var o in Newtonsoft.Json.Linq.JObject.FromObject(arry)) { sql = sql.Replace("[@c" + i + "]", o.Value.ToString()); i = i + 1; } } } } al.Add(sql); ds = MySqlHelpers.Query(al); } catch (Exception ex) { FileLog.WriteLog(ex.ToString()); } if (ds != null) { return(ds); } else { return(null); } }
/// <summary> /// 直接返回datatable 此情况在执行单个语句,替换多个条件 /// </summary> /// <param name="TabId"></param> /// <param name="where1"></param> /// <param name="where2"></param> /// <returns></returns> public DataTable GetDataTableToIDWhere(string TabId, string where1, string where2) { Dictionary <string, Dimention> report = GetReport(); Dimention dimention = report[TabId]; string sql = ""; DataTable dt = null; sql = dimention.SqlAll.Replace("%Where1%", where1).Replace("%Where2%", where2).Trim(); dt = MySqlHelpers.GetDataTable(sql); if (dt != null) { return(dt); } else { return(null); } }
public Plain(Point3D point, Dimention dimention) { this.Dimention = dimention; switch (dimention) { case Dimention.X: this.Value = point.X.value; break; case Dimention.Y: this.Value = point.Y.value; break; case Dimention.Z: this.Value = point.Z.value; break; } }
/// <summary> /// 直接返回datatable 此情况在执行单个语句 /// </summary> /// <param name="TabId"></param> /// <returns></returns> public DataTable GetDataTableToID(string TabId) { Dictionary <string, Dimention> report = GetReport(); Dimention dimention = report[TabId]; string sql = ""; DataTable dt = null; sql = dimention.SqlAll.Replace("%Where%", ""); dt = SqlHelpers.GetDataTable(sql.Trim()); if (dt != null) { return(dt); } else { return(null); } }
// obj is on the line(dimention:value) ? private bool IsOnLine(GameObject obj, Dimention dimention, int value) { float dimen = 0; switch (dimention) { case Dimention.X: dimen = obj.transform.position.x; break; case Dimention.Y: dimen = obj.transform.position.y; break; case Dimention.Z: dimen = obj.transform.position.z; break; } return(Math.Round(dimen) == value); }
// 以 dimention 設定平面. public void ChangePlain(Dimention dimention) { this.Dimention = dimention; switch (dimention) { case Dimention.X: this.X = Binded.Y; this.Y = Binded.Z; break; case Dimention.Y: this.X = Binded.Z; this.Y = Binded.X; break; case Dimention.Z: this.X = Binded.X; this.Y = Binded.Y; break; } }
/// <summary> /// 安装ID编号查找 /// </summary> /// <param name="tabID"></param> /// <returns></returns> public DataTable GetGridDataSource(string tabID) { Dictionary <string, Dimention> report = GetReport(); Dimention dimention = report[tabID]; ArrayList al = new ArrayList(); string sql = ""; DataTable dt = null; sql = dimention.SqlAll.Replace("%Where%", " "); al.Add(sql); DataSet ds = new DataSet(); ds = MySqlHelpers.Query(al); for (int i = 0; i < ds.Tables.Count; i++) { if (dt != null) { if (ds.Tables[i].Rows.Count > 0) { dt.Merge(ds.Tables[i]); } } else { if (ds.Tables[i].Rows.Count > 0) { dt = ds.Tables[i].Copy(); } } } if (dt != null) { DataView dv = dt.DefaultView; // dv.Sort = "CITYNAME"; dt = dv.ToTable(); } return(dt); }
public SizedImageData(ImageType imgType, Dimention size, byte[] bytes) { ImgType = imgType; Size = size; Bytes = bytes; }
// 與 Point3D 綁定,以 dimention 設定平面. public void Bind(Point3D binded, Dimention dimention) { this.Binded = binded; this.ChangePlain(dimention); }
public Point2D(Point3D binded, Dimention dimention) { this.Bind(binded, dimention); }
private void HandleRobotCommand(char command, Map map) { switch (command) { case Commands.Left: case Commands.Right: Direction = directionsMap[new KeyValuePair<char, Direction>(command, Direction)]; dimention = dimention == Dimention.Horizontal ? Dimention.Vertical : Dimention.Horizontal; break; case Commands.Forward: RobotXCoord += Steps.StepForward; RobotYCoord += Steps.StepForward; CheckItemPresence(map); break; case Commands.Back: RobotXCoord += Steps.StepBack; RobotYCoord += Steps.StepBack; CheckItemPresence(map); break; } }
public Robot(ICommandProvider commandProvider) { this.commandProvider = commandProvider; dimention = Dimention.Vertical; }
private void ChangePlain(Dimention dimen) { this.posit.ChangePlain(dimen); }
internal SavedScaledPicInfo(Dimention dimention, string[] filePathParts, ImageType imgType) { Dimention = dimention; FilePathParts = filePathParts; ImgType = imgType; }
public Result <SizedImageData> GetScaledJpegBytes(byte[] data, ResizeOption resizeOption) { if (resizeOption.ImgType == ImageType.Unknown) { return(Result <SizedImageData> .NewFailure($"{nameof(resizeOption.ImgType)} {resizeOption.ImgType} is not supported.")); } if (resizeOption.OperationType == ResizeOperationType.Unknown) { return(Result <SizedImageData> .NewFailure($"{nameof(resizeOption.OperationType)} {resizeOption.OperationType} is not supported.")); } byte[] resizedBytes; Dimention newSize; try { using (var imageReadStream = new MemoryStream(data)) using (var sourceImg = Image.FromStream(imageReadStream)) { var sourceSize = new Dimention(height: sourceImg.Height, width: sourceImg.Width); switch (resizeOption.OperationType) { case ResizeOperationType.Raw: return(Result <SizedImageData> .NewSuccess(new SizedImageData(resizeOption.ImgType, sourceSize, data))); case ResizeOperationType.Fit: newSize = sourceSize.GetSizeToFitInto(resizeOption.Size); // Resize using (var outputMs = new MemoryStream()) { using (var canvas = new Bitmap(width: newSize.Width, height: newSize.Height)) using (var graphics = Graphics.FromImage(canvas)) { graphics.CompositingQuality = CompositingQuality.HighSpeed; graphics.InterpolationMode = InterpolationMode.HighQualityBilinear; graphics.CompositingMode = CompositingMode.SourceCopy; graphics.DrawImage(sourceImg, 0, 0, width: newSize.Width, height: newSize.Height); canvas.Save(outputMs, ImageFormat.Jpeg); } resizedBytes = outputMs.ToArray(); } break; case ResizeOperationType.Fill: newSize = resizeOption.Size; var rectDst = new Rectangle(0, 0, width: resizeOption.Size.Width, height: resizeOption.Size.Height); var souceSize = new Dimention(width: sourceImg.Width, height: sourceImg.Height); var rectSrc = sourceSize.GetCenterRectangleToFill(resizeOption.Size); // Resize using (var outputMs = new MemoryStream()) { using (var canvas = new Bitmap(width: resizeOption.Size.Width, height: resizeOption.Size.Height)) using (var graphics = Graphics.FromImage(canvas)) { graphics.CompositingQuality = CompositingQuality.HighSpeed; graphics.InterpolationMode = InterpolationMode.HighQualityBilinear; graphics.CompositingMode = CompositingMode.SourceCopy; graphics.DrawImage(image: sourceImg, destRect: rectDst, srcRect: rectSrc, srcUnit: GraphicsUnit.Pixel); canvas.Save(outputMs, ImageFormat.Jpeg); } resizedBytes = outputMs.ToArray(); } break; default: return(Result <SizedImageData> .NewFailure($"{nameof(resizeOption.OperationType)}: '{resizeOption.OperationType}' is not supported.")); } } var result = new SizedImageData(imgType: resizeOption.ImgType, size: newSize, bytes: resizedBytes); return(Result <SizedImageData> .NewSuccess(result)); } catch (Exception ex) { return(Result <SizedImageData> .NewFailure(ex.ToString())); } }