public EStoreConfiguration GetConfigurationSettings(string key) { using (var context = new CContext()) { return(context.EStoreConfigurations.SingleOrDefault(x => x.Key.Contains(key))); } }
public Order GetOrderById(int Id) { using (var _context = new CContext()) { return(_context.Orders.Where(x => x.ID == Id).Include(x => x.OrderItems).Include("OrderItems.Product").FirstOrDefault()); } }
private static void CloseFile(CContext c) { if (c.File != null) { if (!c.Uploading && c.HasError) { if (c.InitSize == -1) { c.File.Close(); try { System.IO.File.Delete(c.LocalFile); } catch { } } else { try { c.File.Flush(); c.File.SetLength(c.InitSize); } catch { } finally { c.File.Close(); } } } else { c.File.Close(); } c.File = null; } }
public List <Category> GetCategories() { using (var context = new CContext()) { return(context.Categories.ToList()); } }
public Product GetProduct(int id) { using (var context = new CContext()) { return(context.Products.Include(x => x.Category).SingleOrDefault(x => x.ID == id)); } }
public List <Product> GetProducts() { using (var context = new CContext()) { return(context.Products.Include(x => x.Category).ToList()); } }
public int GetMaxPrice() { using (var _context = new CContext()) { return((int)(_context.Products.Max(x => x.Price))); } }
public void DrawSurface(Point start, double width, double height, ISurface surface, ScaleMode mode, bool masked = false) { //FIXME: This still needs support for masked surfaces double scaleX, scaleY; Point offset; BaseImage <Pixbuf> .ScaleFactor((int)(surface.Width *surface.DeviceScaleFactor), (int)(surface.Height *surface.DeviceScaleFactor), (int)width, (int)height, mode, out scaleX, out scaleY, out offset); CContext.Save(); CContext.Translate(offset.X + start.X, offset.Y + start.Y); CContext.Scale(scaleX, scaleY); if (masked) { CContext.PushGroup(); } ImageSurface image = surface.Value as ImageSurface; CContext.SetSourceSurface(image, 0, 0); CContext.Rectangle(0, 0, image.Width, image.Height); CContext.Fill(); if (masked) { var src = CContext.PopGroup(); SetColor(FillColor); CContext.Mask(src); src.Dispose(); } CContext.Restore(); }
public List <Product> GetProducts(List <int> pId) { using (var context = new CContext()) { return(context.Products.Where(x => pId.Contains(x.ID)).ToList()); } }
protected override void OnPostProcessing(uint hint, ulong data) { CContext ctx = null; CClientSocket cs = AttachedClientSocket; lock (m_csFile) { if (m_vContext.Count > 0) { CContext context = m_vContext[0]; if (context.Uploading) { OpenLocalRead(context); } else { OpenLocalWrite(context); } DAsyncResultHandler rh = null; DOnExceptionFromServer se = null; if (context.HasError) { ctx = context; } else if (context.Uploading) { if (!SendRequest(idUpload, context.FilePath, context.Flags, context.FileSize, rh, context.Discarded, se)) { ctx = context; context.ErrCode = cs.ErrorCode; context.ErrMsg = cs.ErrorMsg; } } else { if (!SendRequest(idDownload, context.LocalFile, context.FilePath, context.Flags, context.InitSize, rh, context.Discarded, se)) { ctx = context; context.ErrCode = cs.ErrorCode; context.ErrMsg = cs.ErrorMsg; } } } } if (ctx == null) { return; } if (ctx.Download != null) { ctx.Download(this, ctx.ErrCode, ctx.ErrMsg); } lock (m_csFile) { CloseFile(m_vContext.RemoveFromFront()); if (m_vContext.Count > 0) { ClientCoreLoader.PostProcessing(AttachedClientSocket.Handle, 0, 0); AttachedClientSocket.DoEcho(); //make sure WaitAll works correctly } } }
public virtual bool Download(string localFile, string remoteFile, DDownload dl, DTransferring trans, DDiscarded discarded, uint flags, DOnExceptionFromServer se) { if (localFile == null || localFile.Length == 0) { throw new ArgumentException("localFile cannot be empty"); } if (remoteFile == null || remoteFile.Length == 0) { throw new ArgumentException("remoteFile cannot be empty"); } CContext context = new CContext(false, flags); context.Download = dl; context.Transferring = trans; context.Discarded = discarded; context.FilePath = remoteFile; context.LocalFile = localFile; context.Se = se; lock (m_csFile) { m_vContext.AddToBack(context); uint filesOpened = GetFilesOpened(); if (m_MaxDownloading > filesOpened) { ClientCoreLoader.PostProcessing(Socket.Handle, 0, 0); if (filesOpened == 0) { Socket.DoEcho(); //make sure WaitAll works correctly } } } return(true); }
public void DrawImage(Point start, double width, double height, Image image, bool scale, bool masked = false) { double scaleX, scaleY; Point offset; if (scale) { image.ScaleFactor((int)width, (int)height, out scaleX, out scaleY, out offset); } else { offset = new Point(0, 0); scaleX = width / image.Width; scaleY = height / image.Height; } CContext.Save(); CContext.Translate(start.X + offset.X, start.Y + offset.Y); CContext.Scale(scaleX, scaleY); if (masked) { CContext.PushGroup(); Gdk.CairoHelper.SetSourcePixbuf(CContext, image.Value, 0, 0); CContext.Paint(); var src = CContext.PopGroup(); SetColor(FillColor); CContext.Mask(src); src.Dispose(); } else { Gdk.CairoHelper.SetSourcePixbuf(CContext, image.Value, 0, 0); CContext.Paint(); } CContext.Restore(); }
public void DrawLine(Point start, Point stop) { CContext.LineWidth = LineWidth; CContext.MoveTo(start.X, start.Y); CContext.LineTo(stop.X, stop.Y); StrokeAndFill(); }
public void DrawRoundedRectangle(Point start, double width, double height, double radius, bool strokeAndFill) { double x, y; x = start.X + LineWidth / 2; y = start.Y + LineWidth / 2; height -= LineWidth; width -= LineWidth; if ((radius > height / 2) || (radius > width / 2)) { radius = Math.Min(height / 2, width / 2); } CContext.MoveTo(x, y + radius); CContext.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2); CContext.LineTo(x + width - radius, y); CContext.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0); CContext.LineTo(x + width, y + height - radius); CContext.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2); CContext.LineTo(x + radius, y + height); CContext.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI); CContext.ClosePath(); if (strokeAndFill) { StrokeAndFill(); } }
public void DrawTriangle(Point corner, double width, double height, SelectionPosition position) { double x1, y1, x2, y2, x3, y3; x1 = corner.X; y1 = corner.Y; switch (position) { case SelectionPosition.Top: x2 = x1 + width / 2; y2 = y1 + height; x3 = x1 - width / 2; y3 = y1 + height; break; case SelectionPosition.Bottom: default: x2 = x1 + width / 2; y2 = y1 - height; x3 = x1 - width / 2; y3 = y1 - height; break; } SetColor(StrokeColor); CContext.MoveTo(x1, y1); CContext.LineTo(x2, y2); CContext.LineTo(x3, y3); CContext.ClosePath(); StrokeAndFill(); }
public void Clear(Color color) { SetColor(color); CContext.Operator = Operator.Source; CContext.Paint(); CContext.Operator = Operator.Over; }
//设置文件上传路径 static public void SetUploadPath() { CContext ctx = GetCtx(); string sPath = HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["VirtualDir"]); //设置默认文件上传路径 ctx.UploadPath = sPath + "\\UploadPath\\"; if (!Directory.Exists(ctx.UploadPath)) { Directory.CreateDirectory(ctx.UploadPath); } //设置产品图片上传路径 string sUploadPath = sPath + "\\Store\\ProductImg\\"; if (!Directory.Exists(sUploadPath)) { Directory.CreateDirectory(sUploadPath); } CTable table = ctx.TableMgr.FindByCode("SP_ProductImg"); if (table != null) { CColumn col = (CColumn)table.ColumnMgr.FindByCode("Url"); if (col != null) { col.UploadPath = sUploadPath; } } }
public void DrawImage(Point start, double width, double height, Image image, ScaleMode mode, bool masked = false, float alpha = 1) { double scaleX, scaleY; Point offset; BaseImage <Pixbuf> .ScaleFactor((int)(image.Width *image.DeviceScaleFactor), (int)(image.Height *image.DeviceScaleFactor), (int)width, (int)height, mode, out scaleX, out scaleY, out offset); CContext.Save(); CContext.Translate(start.X + offset.X, start.Y + offset.Y); CContext.Scale(scaleX, scaleY); if (masked) { CContext.PushGroup(); Gdk.CairoHelper.SetSourcePixbuf(CContext, image.Value, 0, 0); CContext.PaintWithAlpha(alpha); var src = CContext.PopGroup(); SetColor(FillColor); CContext.Mask(src); src.Dispose(); } else { Gdk.CairoHelper.SetSourcePixbuf(CContext, image.Value, 0, 0); CContext.PaintWithAlpha(alpha); } CContext.Restore(); }
public virtual bool Download(string localFile, string remoteFile, DDownload dl, DTransferring trans, DDiscarded discarded, uint flags) { if (localFile == null || localFile.Length == 0) { return(false); } if (remoteFile == null || remoteFile.Length == 0) { return(false); } CContext context = new CContext(false, flags); context.Download = dl; context.Transferring = trans; context.Discarded = discarded; context.FilePath = remoteFile; context.LocalFile = localFile; lock (m_csFile) { m_vContext.AddToBack(context); if (m_vContext.Count == 1) { ClientCoreLoader.PostProcessing(AttachedClientSocket.Handle, 0, 0); AttachedClientSocket.DoEcho(); //make sure WaitAll works correctly } } return(true); }
public Category Edit(int ID) { using (var context = new CContext()) { return(context.Categories.ToList().SingleOrDefault(x => x.ID == ID)); } }
public void InsertPerson() { using (CContext c_ocContext = new CContext()) { CPerson c_peSomeone = new CPerson("Иванов", "Петр", "Сергеевич", new CDateTime(2010, 1, 2)); c_ocContext.Persons.Add(c_peSomeone); Assert.IsTrue(c_ocContext.SaveChanges() > 0); } }
public int GetTotalItem() { using (var _context = new CContext()) { return(_context.Categories.Count() ); } }
public void DrawRectangle(Point start, double width, double height) { CContext.Rectangle(new global::Cairo.Rectangle(start.X + LineWidth / 2, start.Y + LineWidth / 2, width - LineWidth, height - LineWidth)); StrokeAndFill(false); }
public void TranslateAndScale(Point translation, Point scale) { if (!disableScalling) { CContext.Translate(translation.X, translation.Y); CContext.Scale(scale.X, scale.Y); } }
public void UpdateProducts(Product product) { using (var context = new CContext()) { context.Entry(product).State = EntityState.Modified; context.SaveChanges(); } }
public int SaveOrders(Order order) { using (var _context = new CContext()) { _context.Orders.Add(order); return(_context.SaveChanges()); } }
public void SaveCategory(Category category) { using (var context = new CContext()) { context.Categories.Add(category); context.SaveChanges(); } }
public void updateCategory(Category category) { using (var context = new CContext()) { context.Entry(category).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void Delete(int id) { using (var context = new CContext()) { var catId = context.Categories.Single(x => x.ID == id); context.Categories.Remove(catId); context.SaveChanges(); } }
public List <Category> GetFeaturedCategories() { using (var context = new CContext()) { return(context.Categories .Where(x => x.isFeatured == true && x.ImageURL != null) .Take(4).ToList()); } }