Example #1
0
        public bool update(PrintItem printJob, DbTransaction transaction)
        {
            IFPObjectDAO objDAO = DAOFactory.getInstance().createFPObjectDAO();
            objDAO.update(printJob, transaction);

            SqlTransaction trans = (SqlTransaction)transaction;
            String sql = "update Print_Item set " +
                "pid = @pid, notes = @notes, mac = @mac, pc = @pc, newjob = @newjob, em = @em, ftp = @ftp, cddvd = @cddvd, " +
                "job_type = @job_type, handled_by = @handled_by, test_job = @test_job, register_date = @register_date, " +
                "job_deadline = @job_deadline, print_job = @print_job, Fpaper = @Fpaper, Fcolor = @Fcolor, Fdelivery_date = @Fdelivery_date, "+
                "Fdelivery_address = @Fdelivery_address, job_status = @job_status, file_name = @file_name, hold_job = @hold_job, "+
                "Gpage = @Gpage, Gcolor = @Gcolor, qty=@qty, size=@size, unit=@unit where jobid = @jobid";
            SqlConnection conn = trans.Connection;
            SqlCommand cmd = conn.CreateCommand();
            cmd.Connection = conn;
            cmd.Transaction = trans;
            cmd.CommandText = sql;

            cmd.Parameters.Add(genSqlParameter("jobid", SqlDbType.NVarChar, 50, printJob.jobid));
            cmd.Parameters.Add(genSqlParameter("pid", SqlDbType.NVarChar, 50, printJob.pid));
            cmd.Parameters.Add(genSqlParameter("notes", SqlDbType.NVarChar, 2000, printJob.notes));
            cmd.Parameters.Add(genSqlParameter("mac", SqlDbType.Int, 10, printJob.mac ? 1 : 0));
            cmd.Parameters.Add(genSqlParameter("pc", SqlDbType.Int, 10, printJob.pc ? 1 : 0));
            cmd.Parameters.Add(genSqlParameter("newjob", SqlDbType.Int, 10, printJob.newjob ? 1 : 0));
            cmd.Parameters.Add(genSqlParameter("em", SqlDbType.Int, 10, printJob.em ? 1 : 0));
            cmd.Parameters.Add(genSqlParameter("cddvd", SqlDbType.Int, 10, printJob.cddvd ? 1 : 0));
            cmd.Parameters.Add(genSqlParameter("job_type", SqlDbType.NVarChar, 50, printJob.job_type == null ? "" : printJob.job_type.id));

            if (printJob.handled_by == null)
                cmd.Parameters.Add(genSqlParameter("handled_by", SqlDbType.Int, 10, null));
            else
                cmd.Parameters.Add(genSqlParameter("handled_by", SqlDbType.Int, 10, printJob.handled_by.objectId));

            cmd.Parameters.Add(genSqlParameter("test_job", SqlDbType.Int, 10, printJob.test_job ? 1 : 0));
            cmd.Parameters.Add(genSqlParameter("register_date", SqlDbType.NVarChar, 50, printJob.register_date));
            cmd.Parameters.Add(genSqlParameter("job_deadline", SqlDbType.NVarChar, 50, printJob.job_deadline));

            cmd.Parameters.Add(genSqlParameter("Fpaper", SqlDbType.NVarChar, 50, printJob.Fpaper));
            cmd.Parameters.Add(genSqlParameter("Fcolor", SqlDbType.NVarChar, 50, printJob.Fcolor));
            cmd.Parameters.Add(genSqlParameter("Fdelivery_date", SqlDbType.NVarChar, 50, printJob.Fdelivery_date));
            cmd.Parameters.Add(genSqlParameter("Fdelivery_address", SqlDbType.NVarChar, 50, printJob.Fdelivery_address));
            cmd.Parameters.Add(genSqlParameter("job_status", SqlDbType.NVarChar, 50, printJob.job_status));
            cmd.Parameters.Add(genSqlParameter("file_name", SqlDbType.NVarChar, 50, printJob.file_name));

            cmd.Parameters.Add(genSqlParameter("print_job", SqlDbType.NVarChar, 255, printJob.item_detail));

            cmd.Parameters.Add(genSqlParameter("hold_job", SqlDbType.Int, 10, printJob.hold_job ? 1 : 0));
            cmd.Parameters.Add(genSqlParameter("Gpage", SqlDbType.NVarChar, 50, printJob.Gpage));
            cmd.Parameters.Add(genSqlParameter("Gcolor", SqlDbType.NVarChar, 50, printJob.Gcolor));
            cmd.Parameters.Add(genSqlParameter("ftp", SqlDbType.Int, 10, printJob.ftp ? 1 : 0));

            cmd.Parameters.Add(genSqlParameter("qty", SqlDbType.NVarChar, 500, printJob.qty));
            cmd.Parameters.Add(genSqlParameter("size", SqlDbType.NVarChar, 500, printJob.size));
            cmd.Parameters.Add(genSqlParameter("unit", SqlDbType.NVarChar, 500, printJob.unit));


            cmd.ExecuteNonQuery();
            cmd.Dispose();
            return true;
        }
Example #2
0
        public bool add(PrintItem printItem, DbTransaction transaction)
        {
            IFPObjectDAO objDAO = DAOFactory.getInstance().createFPObjectDAO();
            objDAO.add(printItem, transaction);

            SqlTransaction trans = (SqlTransaction)transaction;
            String sql = "insert into Print_Item(ObjectId, jobid, pid, notes, mac, pc, newjob, em, ftp, cddvd, job_type, handled_by, test_job, register_date, job_deadline, print_job, Fpaper, Fcolor, Fdelivery_date, Fdelivery_address, job_status, file_name, hold_job, Gpage, Gcolor,qty,size,unit) values" +
                "(@ObjectId, @jobid, @pid, @notes, @mac, @pc, @newjob, @em, @ftp, @cddvd, @job_type, @handled_by, @test_job, @register_date, @job_deadline, @print_job, @Fpaper, @Fcolor, @Fdelivery_date, @Fdelivery_address, @job_status, @file_name, @hold_job, @Gpage, @Gcolor, @qty, @size, @unit)";
            SqlConnection conn = trans.Connection;
            SqlCommand cmd = conn.CreateCommand();
            cmd.Connection = conn;
            cmd.Transaction = trans;
            cmd.CommandText = sql;

            cmd.Parameters.Add(genSqlParameter("ObjectId", SqlDbType.Int, 10, printItem.objectId));
            cmd.Parameters.Add(genSqlParameter("jobid", SqlDbType.NVarChar, 50, printItem.jobid));
            cmd.Parameters.Add(genSqlParameter("pid", SqlDbType.NVarChar, 50, printItem.pid));
            cmd.Parameters.Add(genSqlParameter("notes", SqlDbType.NVarChar, 2000, printItem.notes));
            cmd.Parameters.Add(genSqlParameter("mac", SqlDbType.Int, 10, printItem.mac ? 1 : 0));
            cmd.Parameters.Add(genSqlParameter("pc", SqlDbType.Int, 10, printItem.pc ? 1 : 0));
            cmd.Parameters.Add(genSqlParameter("newjob", SqlDbType.Int, 10, printItem.newjob ? 1 : 0));
            cmd.Parameters.Add(genSqlParameter("em", SqlDbType.Int, 10, printItem.em ? 1 : 0));
            cmd.Parameters.Add(genSqlParameter("cddvd", SqlDbType.Int, 10, printItem.cddvd ? 1 : 0));
            cmd.Parameters.Add(genSqlParameter("job_type", SqlDbType.NVarChar, 50, printItem.job_type == null ? "" : printItem.job_type.id));

            if (printItem.handled_by == null)
                cmd.Parameters.Add(genSqlParameter("handled_by", SqlDbType.Int, 10, null));
            else
                cmd.Parameters.Add(genSqlParameter("handled_by", SqlDbType.Int, 10, printItem.handled_by.objectId));

            cmd.Parameters.Add(genSqlParameter("test_job", SqlDbType.Int, 10, printItem.test_job ? 1 : 0));
            cmd.Parameters.Add(genSqlParameter("register_date", SqlDbType.NVarChar, 50, printItem.register_date));
            cmd.Parameters.Add(genSqlParameter("job_deadline", SqlDbType.NVarChar, 50, printItem.job_deadline));
            cmd.Parameters.Add(genSqlParameter("Fpaper", SqlDbType.NVarChar, 50, printItem.Fpaper));
            cmd.Parameters.Add(genSqlParameter("Fcolor", SqlDbType.NVarChar, 50, printItem.Fcolor));
            cmd.Parameters.Add(genSqlParameter("Fdelivery_date", SqlDbType.NVarChar, 50, printItem.Fdelivery_date));
            cmd.Parameters.Add(genSqlParameter("Fdelivery_address", SqlDbType.NVarChar, 50, printItem.Fdelivery_address));
            cmd.Parameters.Add(genSqlParameter("job_status", SqlDbType.NVarChar, 50, printItem.job_status));
            cmd.Parameters.Add(genSqlParameter("file_name", SqlDbType.NVarChar, 50, printItem.file_name));

            cmd.Parameters.Add(genSqlParameter("print_job", SqlDbType.NVarChar, 255, printItem.item_detail));


            cmd.Parameters.Add(genSqlParameter("hold_job", SqlDbType.Int, 10, printItem.hold_job ? 1 : 0));
            cmd.Parameters.Add(genSqlParameter("Gpage", SqlDbType.NVarChar, 50, printItem.Gpage));
            cmd.Parameters.Add(genSqlParameter("Gcolor", SqlDbType.NVarChar, 50, printItem.Gcolor));
            cmd.Parameters.Add(genSqlParameter("ftp", SqlDbType.Int, 10, printItem.ftp ? 1 : 0));

            cmd.Parameters.Add(genSqlParameter("qty", SqlDbType.NVarChar, 500, printItem.qty));
            cmd.Parameters.Add(genSqlParameter("size", SqlDbType.NVarChar,500, printItem.size));
            cmd.Parameters.Add(genSqlParameter("unit", SqlDbType.NVarChar, 500, printItem.unit));


            cmd.ExecuteNonQuery();
            cmd.Dispose();
            return true;
        }
Example #3
0
 public static String getJobJson(PrintItem job, PrintOrder order)
 {
     String customername = "";
     if (order != null)
     {
         if (order.customer_contact != null)
         {
             if (order.customer_contact.company_name != null)
             {
                 customername = order.customer_contact.company_name;
             }
         }
     }
     StringBuilder jobJson = new StringBuilder();
     jobJson.Append("{").Append("jobid:'").Append(job.jobid).Append("',")
         .Append("job_type:'").Append(job.job_type == null ? "" : job.job_type.category_name).Append("',")
         .Append("handled_by:'").Append(job.handled_by == null ? "" : job.handled_by.eng_name).Append("',")
         .Append("customer_name:'").Append(filter(customername)).Append("',")
         .Append("job_deadline:'").Append(job.job_deadline).Append("',")
         .Append("notes:'").Append(filter(job.notes)).Append("',")
         .Append("job_status:'").Append(job.job_status).Append("'}");
     return jobJson.ToString();
 }
Example #4
0
        public ActionResult cloneJob()
        {
            UserAC user = (UserAC)Session["user"];
            IFPService service = (IFPService)FPServiceHolder.getInstance().getService("fpService");
            IFPObjectService objectService = (IFPObjectService)FPServiceHolder.getInstance().getService("fpObjectService");


            String jobid = Request.Params["jobid"];
            PrintItem job = objectService.getPrintJobByID(jobid, user);
            if (job == null)
            {
                PrintOrder order = (PrintOrder)Session["newOrder"];
                if (order.print_job_list == null)
                    order.print_job_list = new List<PrintItem>();

                for (int i = 0; i < order.print_job_list.Count; i++)
                {
                    if (order.print_job_list[i].jobid == jobid)
                    {
                        job = order.print_job_list[i];
                        break;
                    }
                }
            }

            if (job != null)
            {
                PrintItem cloneJob = new PrintItem();
                cloneJob.cddvd = job.cddvd;
                cloneJob.createDate = job.createDate;
                cloneJob.em = job.em;
                cloneJob.Fcolor = job.Fcolor;
                cloneJob.Fdelivery_address = job.Fdelivery_address;
                cloneJob.Fdelivery_date = job.Fdelivery_date;
                cloneJob.file_name = job.file_name;
                cloneJob.Fpaper = job.Fpaper;
                cloneJob.ftp = job.ftp;
                cloneJob.Gcolor = job.Gcolor;
                cloneJob.Gpage = job.Gpage;
                cloneJob.handled_by = job.handled_by;
                cloneJob.hold_job = job.hold_job;
                cloneJob.isDeleted = job.isDeleted;
                cloneJob.item_detail = job.item_detail;
                cloneJob.job_deadline = job.job_deadline;
                cloneJob.job_status = job.job_status;
                cloneJob.job_type = job.job_type;
                cloneJob.jobid = "";
                cloneJob.mac = job.mac;
                cloneJob.newjob = job.newjob;
                cloneJob.notes = job.notes;
                cloneJob.objectId = -1;
                cloneJob.pc = job.pc;
                cloneJob.pid = job.pid;
                cloneJob.print_job_detail = job.print_job_detail;
                cloneJob.print_job_items = job.print_job_items;
                cloneJob.qty = job.qty;
                cloneJob.register_date = job.register_date;
                cloneJob.size = job.size;
                cloneJob.test_job = job.test_job;
                cloneJob.unit = job.unit;
                cloneJob.updateBy = job.updateBy;
                cloneJob.updateDate = job.updateDate;

                String pid = Request.Params["pid"];
                PrintOrder oldOrder = objectService.getPrintOrderByID(pid, user);
                if (oldOrder != null)
                {
                    service.addNewJob(oldOrder, cloneJob, user);
                }
                else
                {
                    PrintOrder order = (PrintOrder)Session["newOrder"];

                    cloneJob.jobid = order.print_job_list.Count + "";
                    order.print_job_list.Add(cloneJob);
                }

                return Content("{success:true, result:\"" + cloneJob.jobid + "\"}");
            }
            else
            {
                return Content("{success:false, result:\"Clone item failed\"}");
            }
        }
Example #5
0
        public ActionResult addNewJob()
        {
            UserAC user = (UserAC)Session["user"];
            IFPService service = (IFPService)FPServiceHolder.getInstance().getService("fpService");
            IFPObjectService objectService = (IFPObjectService)FPServiceHolder.getInstance().getService("fpObjectService");

            try
            {
                PrintJobCategory job_type = objectService.getPrintJobCategoryByID(Request.Params["newjob-jobtype"], user);
                if (job_type == null)
                    return Content("{success:false, result:\"" + "Unknow job type\"}");

                String sCheckItemIds = "";
                for (int i = 0; i < Request.Params.Count; i++)
                {
                    if (Request.Params.Keys[i].StartsWith("item"))
                    {
                        if (Request.Params[Request.Params.Keys[i]] == "on")
                        {
                            if (sCheckItemIds != "")
                                sCheckItemIds += "/";
                            sCheckItemIds = sCheckItemIds + Request.Params.Keys[i].Replace("item", "");
                        }
                    }
                }

                PrintOrder order = (PrintOrder)Session["newOrder"];

                if (order.print_job_list == null)
                    order.print_job_list = new List<PrintItem>();

                PrintItem job = new PrintItem();
                job.cddvd = Request.Params["newjob-cddvd"] == "on";
                job.em = Request.Params["newjob-em"] == "on";

                job.file_name = Request.Params["newjob-filename"];

                job.ftp = Request.Params["newjob-ftp"] == "on";

                job.Fpaper = "" + Request.Params["Fpaper"];
                job.Fcolor = Request.Params["Fcolor"];
                job.Fdelivery_address = Request.Params["Fdelivery_address"];
                job.Fdelivery_date = Request.Params["Fdelivery_date"];
                job.Gcolor = "" + Request.Params["Gcolor"];
                job.Gpage = "" + Request.Params["Gpage"];

                job.handled_by = null;
                job.hold_job = false;
                job.job_deadline = ""; 
                job.job_status = PrintItem.STATUS_NEWG;
                job.job_type = job_type;
                job.jobid = order.print_job_list.Count + "";
                job.mac = Request.Params["newjob-mac"] == "on";
                job.newjob = Request.Params["newjob-newjob"] == "on";
                job.notes = Request.Params["newjob-notes"];
                job.pc = Request.Params["newjob-pc"] == "on";
                job.pid = ""; 
                job.item_detail = sCheckItemIds;
                job.print_job_detail = null; //to do
                job.register_date = DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss");
                job.test_job = Request.Params["newjob-testjob"] == "on";
                //job.qty = Request.Params["newjob-quantity"];
                //job.size = Request.Params["newjob-size"];
                //job.unit = Request.Params["unit"];

                job.qty = "";
                job.size = "";
                job.unit = "";
                String[] qty_size = Regex.Split(("" + Request.Params["neworder-hidden-quantityvalue"]), "\r\n");
                for (int i = 0; i < qty_size.Length; i++)
                {
                    if (qty_size[i].Trim() != "")
                    {
                        if (i > 0)
                        {
                            job.qty += " ";
                            job.size += " ";
                            job.unit += " ";
                        }
                        job.qty += qty_size[i].Split(' ')[0];
                        job.size += qty_size[i].Split(' ')[1];
                        job.unit += qty_size[i].Split(' ')[2];
                    }
                }

                if (order == null)
                {
                    return Content("{success:false, result:\"" + "Create job failed. order is not found." + "\"}");
                }

                String pid = Request.Params["newjob-pid"];
                PrintOrder oldOrder = objectService.getPrintOrderByID(pid, user);
                if (oldOrder != null)
                {
                    service.addNewJob(oldOrder, job, user);
                }
                else
                {
                    order.print_job_list.Add(job);
                }


            }
            catch(Exception e)
            {
                return Content("{success:false, result:\"" + "Create job failed. ex=" + e.Message + "\"}");
            }

            return Content("{success:true, result:\"" + "Create job successfully." + "\"}");
        }
Example #6
0
 public bool deleteJob(PrintItem job, UserAC user)
 {
     IDatabase db = DAOFactory.getInstance().getDatabase();
     DbConnection conn = db.getConnection();
     DbTransaction transaction = db.beginTransaction(conn);
     try
     {
         IPrintItemDAO jobDAO = DAOFactory.getInstance().createPrintJobDAO();
         job.updateBy = user.eng_name;
         jobDAO.delete(job, transaction);
         transaction.Commit();
         return true;
     }
     catch (Exception e)
     {
         transaction.Rollback();
         throw e;
     }
     finally
     {
         conn.Close();
     }
 }
Example #7
0
        public bool addNewJob(PrintOrder order, PrintItem job, UserAC user)
        {
            IDatabase db = DAOFactory.getInstance().getDatabase();
            DbConnection conn = db.getConnection();
            DbTransaction transaction = db.beginTransaction(conn);
            try
            {
                IPrintItemDAO printJobDAO = DAOFactory.getInstance().createPrintJobDAO();
                ISequenceDAO seqDAO = DAOFactory.getInstance().createSequenceDAO();
                int seqNo = 0;

                String jobid = "";
                //do
                //{
                //    seqNo++;
                //    seqNo = 1000 + seqNo;
                //    jobid = order.pid + job.job_type.category_code + ("" + seqNo).Substring(1);
                //} while (printJobDAO.get(jobid, transaction) != null);

                int c = 1;
                jobid = order.pid + "-" + job.job_type.category_code + c;
                while (printJobDAO.get(jobid, transaction) != null)
                {
                    c++;
                    jobid = order.pid + "-" + job.job_type.category_code + c;
                }

                job.jobid = jobid;
                job.job_deadline = order.order_deadline;
                job.pid = order.pid;
                job.objectId = seqDAO.getNextObjectId(transaction);
                job.updateBy = user.eng_name;

                printJobDAO.add(job, transaction);

                transaction.Commit();
                return true;
            }
            catch (Exception e)
            {
                transaction.Rollback();
                throw e;
            }
            finally
            {
                conn.Close();
            }
        }
Example #8
0
        public bool updateJob(PrintItem job, UserAC user)
        {
            if (job == null)
                return false;

            IDatabase db = DAOFactory.getInstance().getDatabase();
            DbConnection conn = db.getConnection();
            DbTransaction transaction = db.beginTransaction(conn);
            try
            {
                IPrintItemDAO printJobDAO = DAOFactory.getInstance().createPrintJobDAO();
                IPrintOrderDAO orderDAO = DAOFactory.getInstance().createPrintOrderDAO();
                job.updateBy = user.eng_name;

                bool success = printJobDAO.update(job, transaction);

                
                PrintOrder order = orderDAO.get(job.pid, transaction);
                
                bool isOrderFinished = true;
                for(int i = 0 ; i < order.print_job_list.Count; i++)
                {
                    if (order.print_job_list[i].job_status != PrintItem.STATUS_FINISH)
                    {
                        isOrderFinished = false;
                        break;
                    }
                }

                order.status = isOrderFinished ?  PrintOrder.STATUS_FINISH : PrintOrder.STATUS_PENDING;
                order.updateDate = DateTime.Now;
                order.updateBy = user.eng_name;
                orderDAO.update(order, transaction);


                transaction.Commit();
                return success;
            }
            catch (Exception e)
            {
                transaction.Rollback();
                throw e;
            }
            finally
            {
                conn.Close();
            }
        }
Example #9
0
        private List<PrintItem> getQueryResult(SqlCommand cmd)
        {
            DbDataReader reader = cmd.ExecuteReader();
            DataTable dt = new DataTable();

            IAssetConsumptionDAO printJobDetailDAO = DAOFactory.getInstance().createPrintJobDetailDAO();
            IUserDAO userDAO = DAOFactory.getInstance().createUserDAO();
            IPrintJobCategoryDAO categoryDAO = DAOFactory.getInstance().createPrintJobCategoryDAO();
            IPrintItemDetailDAO printJobLookupDAO = DAOFactory.getInstance().createPrintJobLookupDAO();

            List<PrintItem> printItems = new List<PrintItem>();
            PrintItem printItem = null;
            String[] itemKeys;
            PrintItemDetail item = null;

            dt.Load(reader);
            reader.Close();

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    printItem = new PrintItem();
                    printItem.objectId = getInt(dt.Rows[i]["ObjectId"]);
                    printItem.createDate = getDateTime(dt.Rows[i]["CreateDate"]);
                    printItem.updateDate = getDateTime(dt.Rows[i]["UpdateDate"]);
                    printItem.updateBy = getString(dt.Rows[i]["UpdateBy"]);
                    printItem.isDeleted = (getInt(dt.Rows[i]["IsDeleted"]) == 1);
                    printItem.cddvd = getInt(dt.Rows[i]["cddvd"]) == 1 ? true : false;
                    printItem.em = getInt(dt.Rows[i]["em"]) == 1 ? true : false;
                    printItem.Fcolor = getString(dt.Rows[i]["Fcolor"]);
                    printItem.Fdelivery_address = getString(dt.Rows[i]["Fdelivery_address"]);
                    printItem.Fdelivery_date = getString(dt.Rows[i]["Fdelivery_date"]);
                    printItem.file_name = getString(dt.Rows[i]["file_name"]);
                    printItem.Fpaper = getString(dt.Rows[i]["Fpaper"]);
                    printItem.ftp = getInt(dt.Rows[i]["ftp"]) == 1 ? true : false;
                    printItem.Gcolor = getString(dt.Rows[i]["Gcolor"]);
                    printItem.Gpage = getString(dt.Rows[i]["Gpage"]);
                    printItem.handled_by = userDAO.get(getInt(dt.Rows[i]["handled_by"]), cmd.Transaction);
                    printItem.hold_job = getInt(dt.Rows[i]["hold_job"]) == 1 ? true : false;
                    printItem.job_deadline = getString(dt.Rows[i]["job_deadline"]);
                    printItem.job_status = getString(dt.Rows[i]["job_status"]);
                    printItem.job_type = categoryDAO.get(getString(dt.Rows[i]["job_type"]), cmd.Transaction);
                    printItem.jobid = getString(dt.Rows[i]["jobid"]);
                    printItem.mac = getInt(dt.Rows[i]["mac"]) == 1 ? true : false;
                    printItem.newjob = getInt(dt.Rows[i]["newjob"]) == 1 ? true : false;
                    printItem.notes = getString(dt.Rows[i]["notes"]);
                    printItem.pc = getInt(dt.Rows[i]["pc"]) == 1 ? true : false;
                    printItem.pid = getString(dt.Rows[i]["pid"]);
                    printItem.item_detail = getString(dt.Rows[i]["print_job"]);
                    printItem.register_date = getString(dt.Rows[i]["register_date"]);
                    printItem.test_job = getInt(dt.Rows[i]["test_job"]) == 1 ? true : false;
                    printItem.qty = getString(dt.Rows[i]["qty"]);
                    printItem.size = getString(dt.Rows[i]["size"]);
                    printItem.unit = getString(dt.Rows[i]["unit"]);

                    printItem.print_job_detail = printJobDetailDAO.search(" where jobid = '" + printItem.jobid + "' and IsDeleted = 0 ", cmd.Transaction);

                    printItem.print_job_items = new List<PrintItemDetail>();
                    if (printItem.item_detail != null)
                    {
                        itemKeys = printItem.item_detail.Split('/');
                        for (int j = 0; j < itemKeys.Length; j++)
                        {
                            item = printJobLookupDAO.get(itemKeys[j],cmd.Transaction);
                            if (item != null)
                                printItem.print_job_items.Add(item);
                        }
                    }

                    printItems.Add(printItem);
                }
            }
            return printItems;
        }
Example #10
0
 public bool delete(PrintItem printJob, DbTransaction transaction)
 {
     IFPObjectDAO objDAO = DAOFactory.getInstance().createFPObjectDAO();
     return objDAO.delete(printJob, transaction);
 }
Example #11
0
        public static String getJobDetailJson(PrintItem job)
        {
            StringBuilder jobJson = new StringBuilder();
            jobJson.Append("{").Append("jobid:'").Append(job.jobid).Append("',")
                .Append("job_type:'").Append(job.job_type == null ? "" : job.job_type.id).Append("',")
                .Append("job_deadline:'").Append(job.job_deadline).Append("',")
                .Append("notes:'").Append(filter(job.notes)).Append("',")
                .Append("file_name:'").Append(job.file_name).Append("',")
                .Append("mac:").Append(job.mac ? "true" : "false").Append(",")
                .Append("pc:").Append(job.pc ? "true" : "false").Append(",")
                .Append("newjob:").Append(job.newjob ? "true" : "false").Append(",")
                .Append("em:").Append(job.em ? "true" : "false").Append(",")
                .Append("ftp:").Append(job.ftp ? "true" : "false").Append(",")
                .Append("cddvd:").Append(job.cddvd ? "true" : "false").Append(",")
                .Append("handled_by:'").Append(job.handled_by == null ? "" : job.handled_by.eng_name).Append("',")
                .Append("testjob:").Append(job.test_job ? "true" : "false").Append(",")
                .Append("register_date:'").Append(job.register_date).Append("',")
                .Append("print_job:'").Append(job.item_detail).Append("',")
                .Append("Fpaper:'").Append(job.Fpaper).Append("',")
                .Append("Fcolor:'").Append(job.Fcolor).Append("',")
                .Append("Fdelivery_date:'").Append(job.Fdelivery_date).Append("',")
                .Append("Fdelivery_address:'").Append(job.Fdelivery_address).Append("',")
                .Append("hold_job:").Append(job.hold_job ? "true" : "false").Append(",")
                .Append("Gpage:'").Append(job.Gpage).Append("',")
                .Append("Gcolor:'").Append(job.Gcolor).Append("',")
                .Append("qty:'").Append((job.qty + "").Replace("Quantity:", "")).Append("',")
                .Append("size:'").Append((job.size + "").Replace("Size:", "")).Append("',")
                .Append("unit:'").Append((job.unit + "").Replace("Unit:", "")).Append("',");
                jobJson.Append("item_details:'");
                String itemType = "";
                for (int i = 0; i < job.print_job_items.Count; i++)
                {
                    if (itemType != job.print_job_items[i].category_name)
                    {
                        jobJson.Append("\\n").Append(job.print_job_items[i].category_name).Append(" : ");
                        itemType = job.print_job_items[i].category_name;
                    }
                    jobJson.Append(job.print_job_items[i].code_desc).Append(" ");
                }

                if ((job.qty + "").Trim() != "")
                {
                    String[] qtys = job.qty.Split(' ');
                    String[] sizes = job.size.Split(' ');
                    String[] units = job.unit.Split(' ');

                    if (qtys.Length == sizes.Length && qtys.Length == units.Length)
                    {
                        for (int i = 0; i < qtys.Length; i++)
                        {
                            jobJson.Append("\\n").Append("Quantity:").Append((qtys[i] + "").Replace("Quantity:", "")).Append(" Size:").Append(sizes[i].Replace("Size:", ""));
                            if (units[i].Replace("Unit:", "") != "")
                                jobJson.Append(" Unit:").Append(units[i].Replace("Unit:", ""));
                        }
                    }
                }

                //if((job.qty + "").Trim() != "")
                //    jobJson.Append("\\n").Append("Quantity : ").Append((job.qty + "").Replace("Q:", ""));
                //if ((job.size + "").Trim() != "")
                //    jobJson.Append("\\n").Append("Size : ").Append((job.size + "").Replace("Size:", ""));
                //if ((job.unit + "").Trim() != "")
                //    jobJson.Append("\\n").Append("Unit : ").Append((job.unit + "").Replace("Unit:", ""));

                jobJson.Append("',job_status:'").Append(job.job_status).Append("'}");
            return jobJson.ToString();
        }
Example #12
0
        public static String getJobOfOrderJson(PrintOrder order, PrintItem job)
        {
            StringBuilder jobJson = new StringBuilder();
            jobJson.Append("{").Append("pid:'").Append(job.pid).Append("',")
                .Append("received_date:'").Append(order.received_date == null ? "" : order.received_date.Value.ToString("yyyy-MM-dd")).Append("',")
                .Append("received_by:'").Append(order.received_by == null ? "" : order.received_by.eng_name).Append("',")
                .Append("order_deadline:'").Append(order.order_deadline).Append("',")
                .Append("customer_name:'").Append(filter(order.customer_contact.company_name)).Append("',")
                .Append("customer_tel:'").Append(order.customer_contact.tel).Append("',")

                .Append("customer_contact_person:'").Append(order.customer_contact.contact_person).Append("',")
                .Append("remarks:'").Append(filter(order.remarks)).Append("',")
                .Append("section:'").Append(job.job_type == null ? "" : job.job_type.category_name).Append("',")
                .Append("jobid:'").Append(job.jobid).Append("',")
                .Append("filename:'").Append(job.file_name).Append("',")
                .Append("request:'");

            bool addRequest = false;
            if (job.newjob)
            {
                addRequest = true;
                jobJson.Append("New Job");
            }
            if (job.em)
            {
                if (addRequest)
                    jobJson.Append(",EM");
                else
                    jobJson.Append("EM");

                addRequest = true;
            }
            if (job.ftp)
            {
                if (addRequest)
                    jobJson.Append(",FTP");
                else
                    jobJson.Append("FTP");

                addRequest = true;
            }
            if (job.cddvd)
            {
                if (addRequest)
                    jobJson.Append(",CD/DVD");
                else
                    jobJson.Append("CD/DVD");

                addRequest = true;
            }
            if (job.mac)
            {
                if (addRequest)
                    jobJson.Append(",MAC");
                else
                    jobJson.Append("MAC");

                addRequest = true;
            }
            if (job.pc)
            {
                if (addRequest)
                    jobJson.Append(",PC");
                else
                    jobJson.Append("PC");

                addRequest = true;
            }
            if (job.test_job)
            {
                if (addRequest)
                    jobJson.Append(",Test");
                else
                    jobJson.Append("Test");

                addRequest = true;
            }
            jobJson.Append("',item_details:'");
            String itemType = "";
            for (int i = 0; i < job.print_job_items.Count; i++)
            {
                if (itemType != job.print_job_items[i].category_name)
                {
                    jobJson.Append("\\n").Append(job.print_job_items[i].category_name).Append(" : ");
                    itemType = job.print_job_items[i].category_name;
                }
                jobJson.Append(job.print_job_items[i].code_desc).Append(" ");
            }
            if((job.qty + "").Trim() != "")
            {
                String[] qtys = job.qty.Split(' ');
                String[] sizes = job.size.Split(' ');
                String[] units = job.unit.Split(' ');

                if (qtys.Length == sizes.Length && qtys.Length == units.Length)
                {
                    for (int i = 0; i < qtys.Length; i++)
                    {
                        jobJson.Append("\\n").Append("Quantity:").Append((qtys[i] + "").Replace("Quantity:", "")).Append(" Size:").Append(sizes[i].Replace("Size:", ""));
                        if (units[i].Replace("Unit:", "") != "")
                            jobJson.Append(" Unit:").Append(units[i].Replace("Unit:", ""));
                    }
                }
            }
            
            //if((job.qty + "").Trim() != "")
            //    jobJson.Append("\\n").Append("Quantity : ").Append((job.qty + "").Replace("Q:", ""));
            //if ((job.size + "").Trim() != "")
            //    jobJson.Append("\\n").Append("Size : ").Append((job.size + "").Replace("Size:", ""));
            //if ((job.unit + "").Trim() != "")
            //    jobJson.Append("\\n").Append("Unit : ").Append((job.unit + "").Replace("Unit:", ""));


            jobJson.Append("',").Append("notes:'").Append(job.notes).Append("',")
                .Append("handledby:'").Append(job.handled_by == null ? "" : (job.handled_by.objectId == 0 ? "" : job.handled_by.objectId.ToString())).Append("',")
                .Append("job_details:[").Append(""/*TODO*/).Append("],")
                .Append("job_status:'").Append(job.job_status).Append("',")
                .Append("purpose:'").Append(""/*TODO*/).Append("',")
                .Append("size:'").Append(""/**/).Append("'}");
            return jobJson.ToString();
        }