Esempio n. 1
0
        private static ICollection <SlotModel> CreateSlotModelCollection()
        {
            var slots = new List <SlotModel>();

            // setup slot
            var client = new NullClient {
                Settings = new ClientSettings {
                    Name = "Test2"
                }
            };
            var slot     = new SlotModel(client);
            var logLines = new List <Log.LogLine>
            {
                new Log.LogLine {
                    LineType = LogLineType.LogOpen, Index = 1, Raw = "Open"
                }
            };

            slot.CurrentLogLines = logLines;
            slot.WorkUnitModel.WorkUnit.LogLines = logLines;
            slots.Add(slot);

            // setup slot
            client = new NullClient {
                Settings = new ClientSettings {
                    Name = "Test1"
                }
            };
            slot = new SlotModel(client);
            slots.Add(slot);

            return(slots);
        }
Esempio n. 2
0
        private static ICollection <SlotModel> CreateSlotModelCollection()
        {
            // setup stubs
            var prefs = MockRepository.GenerateStub <IPreferenceSet>();

            var slots = new List <SlotModel>();

            // setup slot
            var slot = new SlotModel();

            slot.Prefs = prefs;
            // set concrete values
            slot.Settings = new ClientSettings {
                Name = "Test2"
            };
            slot.CurrentLogLines = new List <LogLine>();
            slots.Add(slot);

            // setup slot
            slot       = new SlotModel();
            slot.Prefs = prefs;
            // Test For - Issue 201 - Web Generation Fails when a Client with no CurrentLogLines is encountered.
            // Make sure we return null for CurrentLogLines in the second SlotModel.
            slot.Settings = new ClientSettings {
                Name = "Test1"
            };
            slot.CurrentLogLines = null;
            slots.Add(slot);

            return(slots);
        }
Esempio n. 3
0
        public AppointmentModel GetAllBookings(DateTime date)
        {
            AppointmentModel appointmentModel = new AppointmentModel();
            List <SlotModel> slots            = new List <SlotModel>();
            IEnumerable <UserAppointmentDto> userAppointmentDtos = _bookingRespository.GetAllAppointments(date);

            appointmentModel.Date = date;

            foreach (var userAppointmentDto in userAppointmentDtos)
            {
                SlotModel slot = new SlotModel
                {
                    User = new UserModel
                    {
                        Name    = userAppointmentDto.User.Name,
                        Contact = userAppointmentDto.User.Contact
                    },
                    Notes = userAppointmentDto.Notes,
                    Time  = userAppointmentDto.Appointment.Time
                };
                slots.Add(slot);
            }
            appointmentModel.AppointmentList = slots;
            return(appointmentModel);
        }
        public string GetSlotDetailsById(int Slotid)
        {
            SlotModel Slotmodel = new SlotModel();

            Slotmodel = _service.SlotRepository.GetSlotDetailsById(Slotid);
            return(JsonConvert.SerializeObject(Slotmodel));
        }
Esempio n. 5
0
    public void Scramble(int reelNum, SlotModel model)
    {
        switch (reelNum)
        {
        case 1:
            isScrambling1  = true;
            scrambleTime1  = Time.time;
            scrambleModel1 = model;
            break;

        case 2:
            isScrambling2  = true;
            scrambleTime2  = Time.time;
            scrambleModel2 = model;
            break;

        case 3:
            isScrambling3  = true;
            scrambleTime3  = Time.time;
            scrambleModel3 = model;
            break;

        case 4:
            isScrambling4  = true;
            scrambleTime4  = Time.time;
            scrambleModel4 = model;
            break;

        case 5:
            isScrambling5  = true;
            scrambleTime5  = Time.time;
            scrambleModel5 = model;
            break;
        }
    }
Esempio n. 6
0
        public void Update(SlotModel model)
        {
            var slots = _context.Slots.Find(model.SlotId);

            _context.Slots.Update(slots);
            _context.SaveChanges();
        }
Esempio n. 7
0
        private void InsertTestInternal(ClientSettings settings, int slotID, WorkUnit workUnit, Protein protein, Action <IList <WorkUnitRow> > verifyAction)
        {
            _repository.Initialize(_testScratchFile);

            var slotModel = new SlotModel(new NullClient {
                Settings = settings
            })
            {
                SlotID = slotID
            };
            var workUnitModel = new WorkUnitModel(slotModel, workUnit);

            workUnitModel.CurrentProtein = protein;

            _repository.Insert(workUnitModel);

            var rows = _repository.Fetch(WorkUnitQuery.SelectAll, BonusCalculation.None);

            verifyAction(rows);

            // test code to ensure this unit is NOT written again
            _repository.Insert(workUnitModel);
            // verify
            rows = _repository.Fetch(WorkUnitQuery.SelectAll, BonusCalculation.None);
            Assert.AreEqual(1, rows.Count);
        }
Esempio n. 8
0
        public void DuplicateTestMixed()
        {
            var instance1 = new SlotModel { UserId = "1" };
             var unitInfo1 = new UnitInfo { ProjectID = 1 };
             var logic1 = CreateUnitInfoLogic(unitInfo1);
             instance1.UnitInfoLogic = logic1;

             var instance2 = new SlotModel { UserId = "1" };
             var unitInfo2 = new UnitInfo { ProjectID = 2 };
             var logic2 = CreateUnitInfoLogic(unitInfo2);
             instance2.UnitInfoLogic = logic2;

             var instance3 = new SlotModel { UserId = "2" };
             var unitInfo3 = new UnitInfo { ProjectID = 1 };
             var logic3 = CreateUnitInfoLogic(unitInfo3);
             instance3.UnitInfoLogic = logic3;

             (new[] { instance1, instance2, instance3 }).FindDuplicates();

             Assert.IsTrue(instance1.UserIdIsDuplicate);
             Assert.IsTrue(instance1.ProjectIsDuplicate);
             Assert.IsTrue(instance2.UserIdIsDuplicate);
             Assert.IsFalse(instance2.ProjectIsDuplicate);
             Assert.IsFalse(instance3.UserIdIsDuplicate);
             Assert.IsTrue(instance3.ProjectIsDuplicate);
        }
Esempio n. 9
0
        public void DuplicateTestNoDuplicates()
        {
            var instance1 = new SlotModel {
                UserId = "1"
            };
            var unitInfo1 = new UnitInfo {
                ProjectID = 1
            };
            var logic1 = CreateUnitInfoLogic(unitInfo1);

            instance1.UnitInfoModel = logic1;

            var instance2 = new SlotModel {
                UserId = "2"
            };
            var unitInfo2 = new UnitInfo {
                ProjectID = 2
            };
            var logic2 = CreateUnitInfoLogic(unitInfo2);

            instance2.UnitInfoModel = logic2;

            (new[] { instance1, instance2 }).FindDuplicates();

            Assert.IsFalse(instance1.UserIdIsDuplicate);
            Assert.IsFalse(instance1.ProjectIsDuplicate);
            Assert.IsFalse(instance2.UserIdIsDuplicate);
            Assert.IsFalse(instance2.ProjectIsDuplicate);
        }
Esempio n. 10
0
        protected virtual int OnGetAutoSizeWidth(DataGridView grid, SlotModel slotModel, int rowIndex, int columnIndex)
        {
            var value    = grid.Rows[rowIndex].Cells[columnIndex].Value;
            var cellText = OnGetCellText(value, slotModel);

            return(TextRenderer.MeasureText(cellText, grid.DefaultCellStyle.Font).Width);
        }
Esempio n. 11
0
        public void BookSlot(SlotModel slot)
        {
            StudentController studentController = new StudentController();

            using (SqlConnection conn = new SqlConnection(Constants.ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = conn;
                    cmd.CommandType = CommandType.Text;

                    cmd.CommandText = @"UPDATE Slot SET BookedInStudentID = @BookedInStudentID WHERE RoomID = @RoomID AND StartTime = @StartTime;";

                    cmd.Parameters.AddWithValue("@RoomID", slot.room.RoomId);
                    cmd.Parameters.AddWithValue("@StartTime", slot.startTime);
                    cmd.Parameters.AddWithValue("@BookedInStudentID", slot.student.userId);

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    catch (SqlException e)
                    {
                        Console.WriteLine("SQL Exception: {0}", e.Message);
                    }
                }
            }
        }
Esempio n. 12
0
        public void XmlBuilder_CreateSlotDetail_PopulatesStringPropertiesThatAreNotNull()
        {
            // Arrange
            var client = new NullClient {
                Settings = new ClientSettings()
            };
            var slot       = new SlotModel(client);
            var xmlBuilder = new XmlBuilder(client.Preferences);
            // Act
            var slotDetail = xmlBuilder.CreateSlotDetail(slot, DateTime.Now);

            // Assert
            Assert.IsNotNull(slotDetail.HfmVersion);
            Assert.IsNotNull(slotDetail.NumberFormat);
            Assert.IsNotNull(slotDetail.LogFileName);
            var slotData = slotDetail.SlotData;

            Assert.IsNotNull(slotData.Core);
            Assert.IsNotNull(slotData.CoreId);
            var protein = slotData.Protein;

            Assert.IsNotNull(protein.ServerIP);
            Assert.IsNotNull(protein.WorkUnitName);
            Assert.IsNotNull(protein.Core);
            Assert.IsNotNull(protein.Description);
            Assert.IsNotNull(protein.Contact);
        }
Esempio n. 13
0
        public void CreateSlot(SlotModel slot)
        {
            using (SqlConnection conn = new SqlConnection(Constants.ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = conn;
                    cmd.CommandType = CommandType.Text;

                    cmd.CommandText = @"INSERT INTO Slot(RoomID,StartTime,StaffID) 
                            VALUES(@RoomID,@StartTime,@StaffID)";

                    cmd.Parameters.AddWithValue("@RoomID", slot.room.RoomId);
                    cmd.Parameters.AddWithValue("@StartTime", SqlDbType.DateTime2).Value = slot.startTime;
                    cmd.Parameters.AddWithValue("@StaffID", slot.staff.userId);

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    catch (SqlException e)
                    {
                        Console.WriteLine("SQL Exception: {0}", e.Message);
                    }
                }
            }
        }
Esempio n. 14
0
        public void CancelBooking(SlotModel slot)
        {
            using (SqlConnection conn = new SqlConnection(Constants.ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = conn;
                    cmd.CommandType = CommandType.Text;

                    //if (slot.student != null)
                    cmd.CommandText = @"UPDATE Slot SET BookedInStudentID = Null WHERE RoomID = @RoomID AND StartTime = @StartTime";

                    cmd.Parameters.AddWithValue("@RoomID", slot.room.RoomId);
                    cmd.Parameters.AddWithValue("@StartTime", slot.startTime);

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    catch (SqlException e)
                    {
                        Console.WriteLine("SQL Exception: {0}", e.Message);
                    }
                    finally
                    {
                        Console.WriteLine("Booking has been cancelled successfully!");
                    }
                }
            }
        }
Esempio n. 15
0
        public void DeleteSlot(SlotModel slot)
        {
            using (SqlConnection conn = new SqlConnection(Constants.ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = conn;
                    cmd.CommandType = CommandType.Text;

                    cmd.CommandText = @"DELETE FROM Slot WHERE RoomID = @RoomID AND StartTime = @StartTime";

                    cmd.Parameters.AddWithValue("@RoomID", slot.room.RoomId);
                    cmd.Parameters.AddWithValue("@StartTime", slot.startTime);

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    catch (SqlException e)
                    {
                        Console.WriteLine("SQL Exception: {0}", e.Message);
                    }
                }
            }
        }
Esempio n. 16
0
        protected override string OnGetCellText(object value, SlotModel slotModel)
        {
            var dateTime = (DateTime)value;

            if (dateTime.IsMinValue())
            {
                return(String.Empty);
            }

            var timeFormatting = slotModel.Prefs.Get <TimeFormatting>(Preference.TimeFormatting);

            if (timeFormatting == TimeFormatting.Format1)
            {
                var    timeSpan = dateTime.Subtract(DateTime.Now);
                string format   = "In {1:00}hr {2:00}min";
                if (timeSpan.Days > 0)
                {
                    format = "In {0}d {1:00}hr {2:00}min";
                }

                return(String.Format(format, timeSpan.Days, timeSpan.Hours, timeSpan.Minutes));
            }

            return(dateTime.ToShortStringOrEmpty());
        }
Esempio n. 17
0
        public Task <bool> Create(SlotModel model)
        {
            int?maxSlot = MaximumSlotPerDay(model.StaffId);

            if (maxSlot == null)
            {
                return(Task.FromResult(false));
            }

            if (maxSlot > 3)
            {
                return(Task.FromResult(false));
            }

            Slot slot = new Slot
            {
                RoomId    = model.RoomId,
                StartTime = model.StartTime,
                StaffId   = model.StaffId
            };

            _context.Slot.Add(slot);
            _context.SaveChangesAsync();
            return(Task.FromResult(true));
        }
Esempio n. 18
0
        protected override string OnGetCellText(object value, SlotModel slotModel)
        {
            if (!slotModel.Status.IsOnline())
            {
                return(String.Empty);
            }

            var timeFormatting = slotModel.Prefs.Get <TimeFormatting>(Preference.TimeFormatting);

            if (timeFormatting == TimeFormatting.Format1)
            {
                var    timeSpan = (TimeSpan)value;
                string format   = "{1:00}hr {2:00}min";
                if (timeSpan.Days > 0)
                {
                    format = "{0}d {1:00}hr {2:00}min";
                }

                return(String.Format(format, timeSpan.Days, timeSpan.Hours, timeSpan.Minutes));
            }

            var etaAsDate = slotModel.Prefs.Get <bool>(Preference.DisplayEtaAsDate);

            if (etaAsDate)
            {
                return(slotModel.ETADate.ToString(CultureInfo.CurrentCulture));
            }

            return(base.OnGetCellText(value, slotModel));
        }
Esempio n. 19
0
        protected override string OnGetCellText(object value, SlotModel slotModel)
        {
            if (!slotModel.Status.IsOnline())
            {
                return(String.Empty);
            }

            var timeSpan       = (TimeSpan)value;
            var timeFormatting = slotModel.Prefs.Get <TimeFormatting>(Preference.TimeFormatting);

            if (timeFormatting == TimeFormatting.Format1)
            {
                string format = "{1:00}min {2:00}sec";
                if (timeSpan.Hours > 0)
                {
                    format = "{0:00}hr {1:00}min {2:00}sec";
                }

                return(String.Format(format, timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds));
            }

            return(timeSpan.Hours > 0
                ? base.OnGetCellText(value, slotModel)
                : timeSpan.ToString(@"mm\:ss"));
        }
Esempio n. 20
0
        public ActionResult DeleteConfirmed(int id)
        {
            SlotModel slotModel = db.SlotModels.Find(id);

            db.SlotModels.Remove(slotModel);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 21
0
 protected override string OnGetCellText(object value, SlotModel slotModel)
 {
     if (!slotModel.Status.IsOnline())
     {
         return(String.Empty);
     }
     return(base.OnGetCellText(value, slotModel));
 }
Esempio n. 22
0
 public string GetMouseOverText(SlotModel slotModel)
 {
     if (slotModel is null)
     {
         return(null);
     }
     return(OnGetMouseOverText(slotModel));
 }
Esempio n. 23
0
        public ActionResult DeleteSlot(string param = "")
        {
            SlotModel Slotmodel = JsonConvert.DeserializeObject <SlotModel>(param);
            long      result    = 0;

            result = _service.SlotRepository.DeleteSlotsDetails(Slotmodel);
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 24
0
 private void LoadSelectedSlot(SlotModel selectedSlot, WorkUnitQueue workUnitQueue, SlotType slotType, IList <LogLine> logLines)
 {
     queueControl.SetWorkUnitQueue(workUnitQueue, slotType);
     txtLogFile.SetLogLines(selectedSlot, logLines);
     if (_presenter.Model.FollowLog)
     {
         txtLogFile.ScrollToBottom();
     }
 }
Esempio n. 25
0
        protected override string OnGetCellText(object value, SlotModel slotModel)
        {
            if (!slotModel.WorkUnitModel.WorkUnit.HasProject())
            {
                return(String.Empty);
            }

            return(base.OnGetCellText(value, slotModel));
        }
Esempio n. 26
0
        public SlotModel GetSlot(string roomId, DateTime dateTime)
        {
            SlotModel slot    = null;
            var       dateStr = dateTime.ToString("yyyy-MM-dd HH:mm:ss");

            SqlConnection conn  = new SqlConnection(Constants.ConnectionString);
            SqlCommand    query = new SqlCommand($"SELECT * from Slot WHERE RoomID = '{roomId}' AND StartTime = '{dateStr}';", conn);
            SqlDataReader read;

            try
            {
                conn.Open();

                read = query.ExecuteReader();

                while (read.Read())
                {
                    StaffController staffController;
                    UserModel       staffModel;

                    staffController = new StaffController();

                    staffModel = staffController.GetUser(read["StaffID"].ToString());

                    if (!String.IsNullOrWhiteSpace(read["BookedInStudentID"].ToString()))
                    {
                        UserModel         studentModel;
                        StudentController studentController = new StudentController();
                        studentModel = studentController.GetUser(read["BookedInStudentID"].ToString());

                        slot = new SlotModel(new RoomModel(read["RoomID"].ToString()[0]), Convert.ToDateTime(read["StartTime"]), staffModel, studentModel);
                    }
                    else
                    {
                        slot = new SlotModel(new RoomModel(read["RoomID"].ToString()[0]), Convert.ToDateTime(read["StartTime"]), staffModel);
                    }
                }
                read.Close();
            }
            catch (SqlException se)
            {
                Console.WriteLine("SQL Exception: {0}", se.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: {0}", e.Message);
            }
            finally
            {
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }

            return(slot);
        }
Esempio n. 27
0
        public static void Postfix(ref SGSaveGameSlotsPanel __instance, SlotModel slot)
        {
            if (Helper.IsIronManCampaign(slot))
            {
                return;
            }

            __instance.DisableLoadButton();
        }
Esempio n. 28
0
 public ActionResult Edit([Bind(Include = "Id,SlotModelName,SlotModelShortName,ThroughType")] SlotModel slotModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(slotModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(slotModel));
 }
Esempio n. 29
0
 public void SetSlotModelDecorations(int reelNum, SlotModel model, bool toggle)
 {
     foreach (SlotItemPreview slot in slots)
     {
         if (slot.model.slotId == model.slotId)
         {
             slot.ToggleSelected(reelNum, toggle);
             break;
         }
     }
 }
Esempio n. 30
0
        public ActionResult Create([Bind(Include = "Id,SlotModelName,SlotModelShortName,ThroughType")] SlotModel slotModel)
        {
            if (ModelState.IsValid)
            {
                db.SlotModels.Add(slotModel);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(slotModel));
        }
Esempio n. 31
0
        public static void Postfix(SGSaveGameListViewItem __instance, SlotModel slot)
        {
            if (Helper.IsIronManCampaign(slot))
            {
                return;
            }


            Traverse.Create(__instance).Field("deleteButton").GetValue <HBSButton>().
            SetState(ButtonState.Disabled);
        }
Esempio n. 32
0
        public void DuplicateTestWithDuplicates()
        {
            var instance1 = new SlotModel { UserId = "1" };
             var unitInfo1 = new UnitInfo { ProjectID = 1 };
             var logic1 = CreateUnitInfoLogic(unitInfo1);
             instance1.UnitInfoLogic = logic1;

             var instance2 = new SlotModel { UserId = "1" };
             var unitInfo2 = new UnitInfo { ProjectID = 1 };
             var logic2 = CreateUnitInfoLogic(unitInfo2);
             instance2.UnitInfoLogic = logic2;

             (new[] { instance1, instance2 }).FindDuplicates();

             Assert.IsTrue(instance1.UserIdIsDuplicate);
             Assert.IsTrue(instance1.ProjectIsDuplicate);
             Assert.IsTrue(instance2.UserIdIsDuplicate);
             Assert.IsTrue(instance2.ProjectIsDuplicate);
        }
Esempio n. 33
0
        private static IEnumerable<SlotModel> CreateSlotModelCollection()
        {
            // setup stubs
             var prefs = MockRepository.GenerateStub<IPreferenceSet>();
             var proteinCollection = MockRepository.GenerateStub<IProteinDictionary>();
             proteinCollection.Stub(x => x.GetProteinOrDownload(0)).IgnoreArguments().Return(new Protein());

             var slots = new List<SlotModel>();

             // setup slot
             var slot = new SlotModel();
             slot.Prefs = prefs;
             // set concrete values
             slot.Settings = new ClientSettings { Name = "Test2" };
             slot.CurrentLogLines = new List<LogLine>();
             slots.Add(slot);

             // setup slot
             slot = new SlotModel();
             slot.Prefs = prefs;
             // Test For - Issue 201 - Web Generation Fails when a Client with no CurrentLogLines is encountered.
             // Make sure we return null for CurrentLogLines in the second SlotModel.
             slot.Settings = new ClientSettings { Name = "Test1" };
             slot.CurrentLogLines = null;
             slots.Add(slot);

             return slots;
        }