Esempio n. 1
0
        public OperationResult UpdatePlanTimeJob(PlanTimeJob planTimeJob)
        {
            Console.WriteLine("PlanScheduleService-UpdatePlanTimeJob({0}): {1}", planTimeJob.ToString(), DateTime.Now);
            try
            {
                planTimeJob.ObjectState = Pattern.Infrastructure.ObjectState.Modified;
                //var _OldJobItem = _planJobItemService.FindBy(x => x.EQID == planTimeJob.EQID && x.IsCreated == false);
                //foreach (var jobitem in _OldJobItem)
                //{
                //    jobitem.ObjectState = Pattern.Infrastructure.ObjectState.Deleted;
                //    _planJobItemService.Delete(jobitem);
                //}
                //foreach (var jobitem in planTimeJob.PlanTimeJob_Items)
                //{
                //    jobitem.ObjectState = Pattern.Infrastructure.ObjectState.Added;
                //    _planJobItemService.Add(jobitem);
                //}

                _planJobService.Update(planTimeJob);
                _unitOfWorkAsync.SaveChanges();
                operationResult.Success = true;
                operationResult.Message = "Update Successed!";
                operationResult.Caption = "Successed!";
            }
            catch (Exception ex)
            {
                operationResult.Success = false;
                operationResult.Message = "There are some things wrong: " + ex.ToString();
                operationResult.Caption = "Error!";
                Loger.Error(ex);
            }
            return(operationResult);
        }
Esempio n. 2
0
 public void LogsSource(PlanTimeJob plan)
 {
     gridControl1.DataSource = report.GetQCReport("QP01_QueryGetScheduleLog", new string[] { "ID", "ScheduleUID" }, new object[] { plan.JobID, plan.ScheduleUID }).Tables[0];
     gridView1.Columns["Stamp"].DisplayFormat.FormatType   = DevExpress.Utils.FormatType.DateTime;
     gridView1.Columns["Stamp"].DisplayFormat.FormatString = "dd-MM-yyyy HH:mm:ss";
     gridView1.BestFitColumns();
 }
        void gridView1_Click(object sender, EventArgs e)
        {
            Dictionary <string, object> paramenters = new Dictionary <string, object>();

            int rowCount = gridView1.SelectedRowsCount;

            if (rowCount != 1)
            {
                return;
            }

            DataRow row = gridView1.GetDataRow(gridView1.GetSelectedRows()[0]);

            foreach (DataColumn c in row.Table.Columns)
            {
                paramenters.Add(c.ColumnName, row[c.ColumnName]);
            }

            PlanTimeJob _planjob = new PlanTimeJob
            {
                JobID        = new Guid(paramenters["JobID"].ToString()),
                ScheduleUID  = new Guid(paramenters["ScheduleUID"].ToString()),
                ScheduleName = paramenters["ScheduleName"].ToString(),
                Enabled      = (bool)paramenters["Enabled"]
            };

            planTemp = _planjob;
            if (eventgridView1_Click != null)
            {
                eventgridView1_Click(_planjob.Enabled, EventArgs.Empty);
            }
        }
 void cmbLine_SelectedIndexChanged(object sender, EventArgs e)
 {
     GetSetPlanTimeJob = new PlanTimeJob()
     {
         SampleName = SampleName,
         LOT_NO     = Material,
         LINE       = Line
     };
 }
        private string CreateRemark(PlanTimeJob plan)
        {
            try
            {
                var dt = acQC.DbHelper.ExecuteStoredProcedure("WF_JobSchedule_GetDescription",
                                                              new string[] { "Type", "Interval", "DayUnit", "DayInterval", "RelativeInterval", "RecurrenceFactor", "StartDate", "EndDate", "StartTime", "EndTime" },
                                                              new object[] { plan.Type, plan.Interval, plan.DayUnit, plan.DayInterval, plan.RelativeInterval, plan.RecurrenceFactor, plan.StartDate, plan.EndDate, plan.StartTime, plan.EndTime }).Tables[0];

                return(dt.Rows.Count > 0 ? dt.Rows[0][0].ToString() : "");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Can not create Schedule Description:" + ex.Message);
                log.Error(ex);
                return("");
            }
        }
        public bool Update(PlanTimeJob plan, List <string> propertylist)
        {
            Console.WriteLine("DOCPlanTimeJobDAL-Update():" + DateTime.Now);

            try
            {
                if (CheckPlanJob(plan))
                {
                    throw new Exception(string.Format("Plan already Exist! {0} - {1} - {2}", plan.SampleName, plan.LOT_NO, plan.LINE));
                }

                return(db.Update(plan));
            }
            catch (Exception e)
            {
                log.Error(e);

                throw new Exception(e.Message);
            }
        }
        public bool CheckPlanJob(PlanTimeJob plan)
        {
            Console.WriteLine("DOCPlanTimeJobDAL-CheckPlanJob():" + DateTime.Now);

            try
            {
                int count = acQC.SelectScalar <int>(@"SELECT COUNT(*) FROM PlanTimeJob 
                                              WHERE SampleName = @SampleName 
                                              AND LINE = @LINE
                                              AND LOT_NO = @LOTNO ",
                                                    new object[] { plan.SampleName, plan.LINE, plan.LOT_NO });
                return(count <= 0);
            }
            catch (Exception e)
            {
                log.Error(e);

                throw new Exception(e.Message);
            }
        }
        private void AddSchedule()
        {
            _QP01Dialog.Init_Load();
            if (_QP01Dialog.ShowDialog() == DialogResult.Yes)
            {
                PlanTimeJob planadd = _QP01Dialog.GetSetPlanTimeJob;

                if (Infrastructure.ConfirmBox.Show("Confirm", "Do you want to Create Plan: "))
                {
                    if (biz.Create(planadd, _QP01Dialog.GetAttributeList))
                    {
                        WriteTips(5, "Save Success!", true);
                        Query();
                    }
                    else
                    {
                        WriteTips(5, "Save Fail!", false);
                    }
                }
            }
        }
        public bool StartStopSchedule(PlanTimeJob plan)
        {
            Console.WriteLine("DOCPlanTimeJobDAL-Start/StopSchedule():" + DateTime.Now);
            Console.WriteLine("{0}................Schedule + {1} " + DateTime.Now, plan.Enabled ? "Stop" : "Start", plan.ScheduleName);
            try
            {
                string UserID = Shawoo.GenuineChannels.GenuineUtility.CurrentSession["UID"].ToString();
                acQC.DbHelper.ExecuteNonQuery("UPDATE PlanTimeJob SET Enabled = @Enabled WHERE JobID = @JobID AND ScheduleUID = @ScheduleUID", new object[] { !plan.Enabled, plan.JobID, plan.ScheduleUID });

                acQC.DbHelper.ExecuteStoredProcedureNonQuery("WF_JobSchedule_SaveLog",
                                                             new string[] { "UserID", "JobID", "ScheduleUID", "IsSuccess", "Message" },
                                                             new object[] { UserID, plan.JobID, plan.ScheduleUID, true, string.Format("{0} {1} schedule at: {2:dd-MM-yyyy HH:mm:ss}", UserID, plan.Enabled ? "Stop" : "Start", DateTime.Now) });
                return(true);
            }
            catch (Exception e)
            {
                log.Error(e);

                throw new Exception(e.Message);
            }
        }
        public bool Create(PlanTimeJob plan, List <string> propertylist)
        {
            Console.WriteLine("DOCPlanTimeJobDAL-Create():" + DateTime.Now);
            var trans = acQC.BeginTransaction();

            try
            {
                plan.UserID = Shawoo.GenuineChannels.GenuineUtility.CurrentSession["UID"].ToString();
                //1.Create JobID
                if (CheckPlanJob(plan))
                {
                    plan.JobID = Guid.NewGuid();
                }
                else
                {
                    DataTable dt = acQC.DbHelper.Select(@"SELECT JobID FROM PlanTimeJob 
                                                        WHERE SampleName = @SampleName 
                                                        AND LINE = @LINE
                                                        AND LOT_NO = @LOTNO", new object[] { plan.SampleName, plan.LINE, plan.LOT_NO }).Tables[0];
                    if (dt.Rows.Count <= 0)
                    {
                        throw new Exception("Error when get JobID");
                    }
                    plan.JobID = new Guid(dt.Rows[0]["JobID"].ToString());
                }

                //2.Create ScheduleUID and ScheduleName
                CreateSchedule(plan, propertylist);

                trans.Commit();
                return(true);
            }
            catch (Exception e)
            {
                trans.Rollback();
                log.Error(e);

                throw new Exception(e.Message);
            }
        }
Esempio n. 11
0
        public OperationResult UpdatePlanTimeJob(PlanTimeJob planTimeJob)
        {
            Console.WriteLine("PlanScheduleService-UpdatePlanTimeJob({0}): {1}", planTimeJob.ToString(), DateTime.Now);
            try
            {
                planTimeJob.ObjectState = Pattern.Infrastructure.ObjectState.Modified;

                _planJobService.Update(planTimeJob);
                _unitOfWorkAsync.SaveChanges();
                operationResult.Success = true;
                operationResult.Message = "Update Successed!";
                operationResult.Caption = "Successed!";
            }
            catch (Exception ex)
            {
                operationResult.Success = false;
                operationResult.Message = "There are some things wrong: " + ex.ToString();
                operationResult.Caption = "Error!";
                Loger.Error(ex);
            }
            return(operationResult);
        }
        public bool CreateSchedule(PlanTimeJob plan, List <string> propertylist)
        {
            Console.WriteLine("DOCPlanTimeJobDAL-CreateSchedule():" + DateTime.Now);
            var trans = acQC.BeginTransaction();

            try
            {
                plan.ScheduleName = string.Format("Schedule_{0:yyyyMMdd_HHmmss}", DateTime.Now);
                plan.ScheduleUID  = Guid.NewGuid();
                plan.UserID       = Shawoo.GenuineChannels.GenuineUtility.CurrentSession["UID"].ToString();
                plan.Remark       = CreateRemark(plan);
                //1.Create Schedule
                db.Insert(plan, trans);

                //2.Save To PlanTimeJob_Items
                for (int i = 0; i < propertylist.Count; i++)
                {
                    var planitem = new PlanTimeJob_Items
                    {
                        JobID        = plan.JobID,
                        ScheduleUID  = plan.ScheduleUID,
                        ItemOrder    = i + 1,
                        SampleName   = plan.SampleName,
                        PropertyName = propertylist[i]
                    };
                    db.Insert(planitem, trans);
                }
                trans.Commit();
                return(true);
            }
            catch (Exception e)
            {
                trans.Rollback();
                log.Error(e);

                throw new Exception(e.Message);
            }
        }
        public bool Delete(PlanTimeJob plan)
        {
            Console.WriteLine("DOCPlanTimeJobDAL-Delete():" + DateTime.Now);
            var trans = acQC.BeginTransaction();

            try
            {
                //Delete Logs
                acQC.DbHelper.ExecuteNonQuery("DELETE PlanTimeJob_Logs WHERE JobID=@JobID AND ScheduleUID=@ScheduleUID", new object[] { plan.JobID, plan.ScheduleUID });
                //Delete All Properties
                acQC.DbHelper.ExecuteNonQuery("DELETE PlanTimeJob_Items WHERE JobID = @JobID AND ScheduleUID=@ScheduleUID", new object[] { plan.JobID, plan.ScheduleUID });
                //Delete Schedule
                db.Delete(plan);
                trans.Commit();
                return(true);
            }
            catch (Exception e)
            {
                trans.Rollback();
                log.Error(e);
                throw new Exception(e.Message);
            }
        }
Esempio n. 14
0
 public bool CheckPlanJob(PlanTimeJob plan)
 {
     return(proxy.CheckPlanJob(plan));
 }
Esempio n. 15
0
 public bool StartStopSchedule(PlanTimeJob plan)
 {
     return(proxy.StartStopSchedule(plan));
 }
Esempio n. 16
0
 public bool Delete(PlanTimeJob plan)
 {
     return(proxy.Delete(plan));
 }
Esempio n. 17
0
 public bool Update(PlanTimeJob plan, List <string> propertylist)
 {
     return(proxy.Update(plan, propertylist));
 }
Esempio n. 18
0
 public IHttpActionResult UpdatePlanTimeJob(PlanTimeJob item) => Ok(_planScheduleService.UpdatePlanTimeJob(item));
Esempio n. 19
0
 public bool CreateSchedule(PlanTimeJob plan, List <string> propertylist)
 {
     return(proxy.CreateSchedule(plan, propertylist));
 }