Exemplo n.º 1
0
        protected void CallbackPanelCurrent_Callback(object sender, CallbackEventArgsBase e)
        {
            DateTime date = DateTime.Now;


            DateTime dateCustom;

            dateCustom = ProductionRepository.GetAndonOverideDate();
            var dayCode = 1;

            if (DateTime.Today == dateCustom)
            {
                dayCode = 3;//custom
            }
            else
            {
                dayCode = date.DayOfWeek == DayOfWeek.Friday ? 2 : 1; //1 normal day, 2 jumuah
            }



            List <TimeSchedule> sched = ProductionRepository.GetAndonDailySchedules(dayCode);


            System.Web.Script.Serialization.JavaScriptSerializer oSerializer2 = new System.Web.Script.Serialization.JavaScriptSerializer();
            Scheduless = oSerializer2.Serialize(sched);



            ETimeOfDayType timeType = GetTimeType(date, sched);

            int target   = ProductionRepository.GetAndonProductionTarget(lineId, assySectionId, date, stationAct);
            int tactTime = GetTactTimeInSeconds(target, sched);
            //if (tactTime == 0) tactTime = 1;

            int elapsedTime = GetElapsedTimeInSeconds(date, sched);

            int plan = 0;

            if (tactTime > 0)
            {
                plan = elapsedTime / tactTime;
            }
            lblPlanning.Text = plan.ToString();

            int actual = ProductionRepository.GetAndonProductionActual(lineId, date, stationAct);

            lblActual.Text = actual.ToString();

            int countdown = 0;



            if (timeType == ETimeOfDayType.OffTime || timeType == ETimeOfDayType.ReadyTime)
            {
                Session["AndonTactTime"]    = tactTime;
                Session["AndonAchievement"] = actual;
                //dont countdown
                fields["cp_action"] = "stop";
                countdown           = tactTime;
            }
            else if (timeType == ETimeOfDayType.BreakTime)
            {
                //Session["AndonTactTime"] = tactTime;
                //Session["AndonAchievement"] = actual;
                ////pause counting
                fields["cp_action"] = "pause";
                //if (fields.Contains("cp_countdown"))
                //{
                //    countdown = fields["cp_countdown"].ToInt32(0);
                //}

                Session["AndonTactTime"]    = tactTime;
                Session["AndonAchievement"] = actual;
                //start counting
                if (tactTime == 0)
                {
                    countdown = 0;
                }
                else
                {
                    countdown = elapsedTime % tactTime;
                    countdown = tactTime - countdown;
                }
                //fields["cp_action"] = "reset";
                fields["cp_countdown"] = countdown;
                fields["cp_seed"]      = tactTime;
                fields["cp_planned"]   = plan;


                lblCountdown.Text = FormatDate(countdown);
            }
            else
            {
                if (e.Parameter == "start")
                {
                    Session["AndonTactTime"]    = tactTime;
                    Session["AndonAchievement"] = actual;
                    //start counting
                    if (tactTime == 0)
                    {
                        countdown = 0;
                    }
                    else
                    {
                        countdown = elapsedTime % tactTime;
                        countdown = tactTime - countdown;
                    }
                    fields["cp_action"]    = "reset";
                    fields["cp_countdown"] = countdown;
                    fields["cp_seed"]      = tactTime;
                    fields["cp_planned"]   = plan;
                }
                else if (e.Parameter == "check")
                {
                    int prevTact = Session["AndonTactTime"].ToInt32(0);
                    if (tactTime == prevTact)
                    {
                        Session["AndonAchievement"] = actual;
                        //keep counting
                        if (fields.Contains("cp_action") && fields["cp_action"].ToString() == "pause")
                        {
                            fields["cp_action"] = "resume";
                        }
                        else
                        {
                            fields["cp_action"] = "count";
                        }
                        if (fields.Contains("cp_countdown"))
                        {
                            countdown = fields["cp_countdown"].ToInt32(0);
                        }
                    }
                    else
                    {
                        Session["AndonTactTime"]    = tactTime;
                        Session["AndonAchievement"] = actual;
                        //reset counting
                        countdown              = elapsedTime % tactTime;
                        fields["cp_action"]    = "reset";
                        fields["cp_countdown"] = countdown;
                        fields["cp_seed"]      = tactTime;
                        fields["cp_planned"]   = plan;
                    }
                }
                else //e.Parameter = "finish"
                {
                    //TODO

                    //keep counting down
                    fields["cp_action"] = "count";
                    if (fields.Contains("cp_countdown"))
                    {
                        countdown = fields["cp_countdown"].ToInt32(0);
                    }
                }
            }
            // lblCountdown.Text = FormatDate(countdown);

            //if (e.Parameter == "start")
            //{
            //    //store current fault id in session
            //    Session["AndonAchievement"] = null;
            //}

            //int achievement = -1;
            //if (Session["AndonAchievement"] != null)
            //    achievement = Session["AndonAchievement"].ToInt32(0);

            //int countdown = 0;
            //if (actual == achievement && fields.Contains("cp_countdown"))
            //{
            //    countdown = fields["cp_countdown"].ToInt32(0);
            //}
            //else
            //{
            //    countdown = GetCountDownTimeInSeconds(lineId, assySectionId, date, target, sched);
            //    //countdown = GetCountDownTimeV2InSeconds(lineId, assySectionId, date, (target - actual), sched);
            //    fields["cp_countdown"] = countdown;
            //    //fields["cp_seed"] = countdown;
            //}
            //lblCountdown.Text = FormatDate(countdown);

            //if (e.Parameter == "finish")
            //{
            //    //TODO: sound alarm?

            //    //keep counting down
            //    fields["cp_action"] = "count";
            //}
            //else //if (e.Parameter == "check")
            //{
            //    if (timeType == ETimeOfDayType.OffTime || timeType == ETimeOfDayType.ReadyTime)
            //    {
            //        //start of day
            //        Session["AndonAchievement"] = 0;

            //        //dont countdown
            //        fields["cp_action"] = "stop";
            //    }
            //    else if (timeType == ETimeOfDayType.BreakTime)
            //    {
            //        fields["cp_action"] = "pause";
            //    }
            //    else  //ETimeOfDayType.WorkingTime
            //    {
            //        if (actual == achievement)
            //        {
            //            if (fields.Contains("cp_action") && fields["cp_action"].ToString() == "pause")
            //                fields["cp_action"] = "resume";
            //            else
            //                fields["cp_action"] = "count";
            //        }
            //        else
            //        {
            //            //new actual -> reset
            //            fields["cp_action"] = "reset";
            //            fields["cp_seed"] = actual;

            //            Session["AndonAchievement"] = actual;
            //        }
            //    }
            //}   //if (e.Parameter == "finish")
        }
Exemplo n.º 2
0
        protected void CallbackPanelFault_Callback(object sender, DevExpress.Web.CallbackEventArgsBase e)
        {
            DateTime date = DateTime.Now;

            DateTime dateCustom;

            dateCustom = ProductionRepository.GetAndonOverideDate();
            var dayCode = 1;

            if (DateTime.Today == dateCustom)
            {
                dayCode = 3;//custom
            }
            else
            {
                dayCode = date.DayOfWeek == DayOfWeek.Friday ? 2 : 1; //1 normal day, 2 jumuah
            }
            List <TimeSchedule> sched = ProductionRepository.GetAndonDailySchedules(dayCode);

            string text = "";

            ETimeOfDayType timeType = GetTimeType(date, sched);

            if (timeType == ETimeOfDayType.BreakTime)
            {
                text = AppConfiguration.ANDON_MSG_BREAKTIME;
                //store current fault id in session
                Session["AndonFaultId"] = -1;
            }
            else if (timeType == ETimeOfDayType.ReadyTime)
            {
                text = AppConfiguration.ANDON_MSG_READYTIME;
                //store current fault id in session
                Session["AndonFaultId"] = -1;
            }
            else if (timeType == ETimeOfDayType.OffTime)
            {
                text = AppConfiguration.ANDON_MSG_OFFTIME;
                //store current fault id in session
                Session["AndonFaultId"] = -1;
            }
            else
            {
                //text
                var textlist = ProductionRepository.GetAndonProductionProblem(lineId, DateTime.Now, stationAct, 0);

                foreach (var item in textlist)
                {
                    text += string.Format(" {0} : {1} ", item.StationName, item.ProblemName);
                }

                if (textlist.Count() > 0)
                {
                    CallbackPanelFault.JSProperties["cp_test"] = "havePro";
                }
                else
                {
                    CallbackPanelFault.JSProperties["cp_test"] = "noPro";
                }
                //set to empty string to avoid flicker
                runningText.InnerText = "";

                //pass text to client
                CallbackPanelFault.JSProperties["cp_runningtext"] = text;



                //working time



                var faults = ProductionRepository.GetAndonProductionFaults(lineId, assySectionId, DateTime.Now);

                if (faults.Count() == 0)
                {
                    runningText.InnerText = "";
                    //store current fault id in session
                    Session["AndonFaultId"] = -1;
                    return;
                }

                int faultId = 0;
                if (Session["AndonFaultId"] != null)
                {
                    faultId = Session["AndonFaultId"].ToInt32(0);
                }

                //get index of current running fault
                int faultIdx = 0;
                if (faultId > 0)
                {
                    for (int i = 0; i < faults.Count(); i++)
                    {
                        if (faults[i].Id == faultId)
                        {
                            faultIdx = i;
                            break;
                        }
                    }

                    //get the next fault to show
                    if (faultIdx >= 0 && faultIdx < faults.Count - 1)
                    {
                        faultIdx++;
                    }
                    else
                    {
                        faultIdx = 0;
                    }
                }

                ProductionFault fau = faults[faultIdx];
                // text = string.Format("{0} {1} : {2}", fau.StationName, fau.Classification, fau.PartDescription);



                //store current fault id in session
                Session["AndonFaultId"] = fau.Id;
            }

            //set to empty string to avoid flicker
            runningText.InnerText = "";

            //pass text to client
            CallbackPanelFault.JSProperties["cp_runningtext"] = text;
        }