/// <summary> /// select *from MACH_CAMDrawing where DrawingName='{0}' and lock=1 /// </summary> /// <param name="DrawName"></param> /// <returns></returns> public CAMDrawing GetCAMDrawing(string DrawName) { DrawName = DrawName.Replace("+", "%2B"); string _url = "/Task/GetCAMDrawing?DrawName=" + DrawName; string _result = _server.ReceiveStream(_url); CAMDrawing _camDrawing = JsonConvert.DeserializeObject <CAMDrawing>(_result); return(_camDrawing); }
public CAMDrawing QueryByName(string DrawingName) { //CAMDrawing _camDrawing = _context.CAMDrawings.Where(d => d.DrawingName == DrawingName).FirstOrDefault(); CAMDrawing _camDrawing = (from c in _context.CAMDrawings where c.DrawingName == DrawingName select c).FirstOrDefault(); return(_camDrawing); }
public int Save(CAMDrawing CAMDrawing) { CAMDrawing _dbEntry = null; bool _isNew = false; if (CAMDrawing.CAMDrawingID == 0) { _dbEntry = QueryByName(CAMDrawing.DrawingName); if (_dbEntry == null) { _isNew = true; CAMDrawing.ReleaseBy = ""; CAMDrawing.ReleaseDate = new DateTime(1900, 1, 1); _context.CAMDrawings.Add(CAMDrawing); } else { _dbEntry.DrawingName = CAMDrawing.DrawingName; _dbEntry.MoldName = CAMDrawing.MoldName; _dbEntry.Lock = CAMDrawing.Lock; _dbEntry.CreateDate = CAMDrawing.CreateDate; _dbEntry.CreateBy = CAMDrawing.CreateBy; _dbEntry.ReleaseDate = CAMDrawing.ReleaseDate; _dbEntry.ReleaseBy = CAMDrawing.ReleaseBy; _dbEntry.active = CAMDrawing.active; } } else { _dbEntry = _context.CAMDrawings.Find(CAMDrawing.CAMDrawingID); _dbEntry.DrawingName = CAMDrawing.DrawingName; _dbEntry.MoldName = CAMDrawing.MoldName; _dbEntry.Lock = CAMDrawing.Lock; _dbEntry.CreateDate = CAMDrawing.CreateDate; _dbEntry.CreateBy = CAMDrawing.CreateBy; _dbEntry.ReleaseDate = CAMDrawing.ReleaseDate; _dbEntry.ReleaseBy = CAMDrawing.ReleaseBy; _dbEntry.active = CAMDrawing.active; } _context.SaveChanges(); if (_isNew) { return(CAMDrawing.CAMDrawingID); } else { return(_dbEntry.CAMDrawingID); } }
/// <summary> /// 获取最大版本图纸 /// </summary> /// <param name="TaskName">任务名</param> /// <returns></returns> public string GetMaxVerDrawFile(string TaskName) { List <CAMDrawing> _draws = _context.CAMDrawings.Where(d => d.DrawingName.Contains(TaskName) && d.active == true && d.Lock == false).ToList(); #region 排序,找到最高版本对应DrawID Dictionary <int, int> _dics = new Dictionary <int, int>(); foreach (var d in _draws) { int _ver = Convert.ToInt32(d.DrawingName.Substring(d.DrawingName.LastIndexOf('_') + 2, 2)); _dics.Add(d.CAMDrawingID, _ver); } Dictionary <int, int> _dics_SortByKey = _dics.OrderByDescending(d => d.Value).ToDictionary(d => d.Key, v => v.Value); #endregion if (_dics_SortByKey.Count > 0) { int _fkey = _dics_SortByKey.FirstOrDefault().Key; CAMDrawing _draw = _context.CAMDrawings.Where(d => d.CAMDrawingID == _fkey).FirstOrDefault(); return(_draw.DrawingName ?? ""); } return(""); }