예제 #1
0
        public ActionResult Edit(int?id)
        {
            ShiftChanged obj = ShiftChangedService.GetEdit((int)id);

            HelperMethod(obj);
            return(PartialView(obj));
        }
예제 #2
0
 public ActionResult Create(ShiftChanged obj)
 {
     if (obj.ChangedShiftDesc == null || obj.ChangedShiftDesc == "")
     {
         ModelState.AddModelError("ChangedShiftDesc", "Title cannot be empty");
     }
     if (ShiftChangedService.GetIndex().Where(aa => aa.ChangedShiftDesc == obj.ChangedShiftDesc).Count() > 0)
     {
         ModelState.AddModelError("ChangedShiftDesc", "Title must be unique");
     }
     if (obj.DateStart != null && obj.DateEnd != null)
     {
         if (obj.DateEnd == obj.DateStart)
         {
         }
         else
         {
             if (obj.DateEnd <= obj.DateStart)
             {
                 ModelState.AddModelError("DateStart", "Start Date can never be greater than end date.");
             }
         }
     }
     //if (ShiftChangedService.GetIndex().Where(aa => aa.DateStart == obj.DateStart && aa.PShiftChangedID != obj.PShiftChangedID).Count() > 0)
     //    ModelState.AddModelError("DateStart", "Already exists in same date");
     if (ModelState.IsValid)
     {
         ShiftChangedService.PostCreate(obj);
         return(Json("OK", JsonRequestBehavior.AllowGet));
     }
     HelperMethod(obj);
     return(PartialView("Create", obj));
 }
예제 #3
0
        private void HelperMethod(ShiftChanged obj)
        {
            VMLoggedUser LoggedInUser = Session["LoggedInUser"] as VMLoggedUser;

            ViewBag.LocationID = new SelectList(DDService.GetLocation(LoggedInUser).ToList().OrderBy(aa => aa.LocationName).ToList(), "PLocationID", "LocationName", obj.LocationID);
            ViewBag.ShiftID    = new SelectList(DDService.GetShift(LoggedInUser).ToList().OrderBy(aa => aa.ShiftName).ToList(), "PShiftID", "ShiftName", obj.ShiftID);
            ViewBag.DayOff1    = new SelectList(DDService.GetDaysName().ToList().OrderBy(aa => aa.DayName).ToList(), "DaysNameID", "DayName", obj.DayOff1);
            ViewBag.DayOff2    = new SelectList(DDService.GetDaysName().ToList().OrderBy(aa => aa.DayName).ToList(), "DaysNameID", "DayName", obj.DayOff2);
        }
예제 #4
0
 public ActionResult Edit(ShiftChanged obj)
 {
     if (ModelState.IsValid)
     {
         ShiftChangedService.PostEdit(obj);
         return(Json("OK", JsonRequestBehavior.AllowGet));
     }
     HelperMethod(obj);
     return(PartialView("Edit", obj));
 }
예제 #5
0
        public ActionResult Create()

        {
            ShiftChanged obj = new ShiftChanged();

            obj.BreakMin        = 0;
            obj.HalfDayBreakMin = 0;
            HelperMethod(obj);
            return(View(obj));
        }
예제 #6
0
        static void Main(string[] args)
        {
            string bootstrapServers  = "127.0.0.1:9092";
            string schemaRegistryUrl = "127.0.0.1:8081";
            string topicName         = "shift-changed";

            var producerConfig = new ProducerConfig
            {
                BootstrapServers = bootstrapServers
            };

            var schemaRegistryConfig = new SchemaRegistryConfig
            {
                Url = schemaRegistryUrl
            };

            var avroSerializerConfig = new AvroSerializerConfig
            {
                BufferBytes = 100
            };

            using (var schemaRegistry = new CachedSchemaRegistryClient(schemaRegistryConfig))
                using (var producer = new ProducerBuilder <string, ShiftChanged>(producerConfig)
                                      .SetKeySerializer(new AvroSerializer <string>(schemaRegistry, avroSerializerConfig))
                                      .SetValueSerializer(new AvroSerializer <ShiftChanged>(schemaRegistry, avroSerializerConfig))
                                      .Build())
                {
                    while (true)
                    {
                        var evt = new ShiftChanged();
                        evt.ShiftCode       = "B";
                        evt.CureEquipmentId = "001";

                        producer
                        .ProduceAsync(topicName, new Message <string, ShiftChanged> {
                            Key = evt.CureEquipmentId, Value = evt
                        })
                        .ContinueWith(task =>

                        {
                            if (!task.IsFaulted)
                            {
                                Console.WriteLine($"produced to: {task.Result.TopicPartitionOffset}");
                            }
                            Console.WriteLine($"error producing message: {task.Exception.InnerException}");
                        });

                        Thread.Sleep(10000);
                    }
                }
        }
예제 #7
0
 private void OnShiftChanged(ShiftState shift)
 {
     ShiftChanged?.Invoke(this, new ShiftChangedEventArgs {
         ShiftState = shift
     });
 }
예제 #8
0
 public ActionResult Delete(ShiftChanged obj)
 {
     ShiftChangedService.PostDelete(obj);
     return(Json("OK", JsonRequestBehavior.AllowGet));
 }