Ejemplo n.º 1
0
        public void Print(string fileOrPath, int printerId, string pages)
        {
            string prName = db.Printers.FirstOrDefault(p => p.Id == printerId).Prn_name;

            //if all pages
            if (String.IsNullOrEmpty(pages))
            {
                SpirePrAPI.PrintAll(fileOrPath, prName);
            }
            else  //if selectRange pages
            {
                SpirePrAPI.PrintSelectionPages(fileOrPath, prName, pages);
            }
        }
Ejemplo n.º 2
0
        public void InitializePrintersToDb()
        {
            #region DropCreateDB

            /*Database.SetInitializer(new ContexInitializer());
             * db.Database.Initialize(true); */
            #endregion

            //clear table
            var countPr = db.Printers.Count();
            if (countPr != 0)
            {
                db.Printers.RemoveRange(db.Printers);
            }

            // allPrinters.ForEach(p => db.Printers.Add(p));
            SpirePrAPI.GetAllPrinters().ForEach(p => db.Printers.Add(p));
            db.SaveChanges();

            //reset id
            db.Database.ExecuteSqlCommand(@"ALTER SEQUENCE dbo.""Printers_Id_seq"" RESTART");
            db.Database.ExecuteSqlCommand(@"UPDATE dbo.""Printers"" SET ""Id"" = DEFAULT");
        }