Example #1
0
 static void SeedOperatingSystemTable()
 {
     using (var context = new MachineContext()) {
         var os = new OperatingSys {
             Name = "Windows XP", StillSupported = false
         };
         context.OperatingSys.Add(os);
         os = new OperatingSys {
             Name = "Windows 7", StillSupported = true
         };
         context.OperatingSys.Add(os);
         os = new OperatingSys {
             Name = "Windows 8", StillSupported = false
         };
         context.OperatingSys.Add(os);
         os = new OperatingSys {
             Name = "Windows 8.1", StillSupported = true
         };
         context.OperatingSys.Add(os);
         os = new OperatingSys {
             Name = "Windows 10", StillSupported = true
         };
         context.OperatingSys.Add(os);
         os = new OperatingSys {
             Name = "Windows Server 2000", StillSupported = false
         };
         context.OperatingSys.Add(os);
         //os = new OperatingSys { Name = "Windows Server 2003 R2", StillSupported = false };
         //context.OperatingSys.Add(os);
         os = new OperatingSys {
             Name = "Windows Server 2008", StillSupported = true
         };
         context.OperatingSys.Add(os);
         os = new OperatingSys {
             Name = "Windows Server 2008 R2", StillSupported = true
         };
         context.OperatingSys.Add(os);
         os = new OperatingSys {
             Name = "Windows Server 2012", StillSupported = true
         };
         context.OperatingSys.Add(os);
         os = new OperatingSys {
             Name = "Windows Server 2012 R2", StillSupported = true
         };
         context.OperatingSys.Add(os);
         os = new OperatingSys {
             Name = "Windows Server 2016", StillSupported = true
         };
         context.OperatingSys.Add(os);
         os = new OperatingSys {
             Name = "Ubuntu Server 16.14.2 LTS", StillSupported = true
         };
         context.OperatingSys.Add(os);
         os = new OperatingSys {
             Name = "Ubuntu Server 17.04", StillSupported = true
         };
         context.OperatingSys.Add(os);
         context.SaveChanges();
     }
 }
Example #2
0
 private MachineContext CreateContext()
 {
     return(MachineContext.Create(b => b
                                  .RegisterIdentities(typeof(PacketSerialization_Id))
                                  .RegisterMessages(typeof(PacketSerialization_Event), typeof(PacketSerialization_Child_Event))
                                  ));
 }
Example #3
0
 public NewsWaitingState(MachineContext context, double time)
     : base(context)
 {
     this.timer = new Util.StaticTimer(context.RetryTimeout);
     this.queueTime = new Util.StaticTimer(TimeSpan.FromMilliseconds(time));
     this.retriesUsed = 0;
 }
Example #4
0
 public NewsTransferState(MachineContext context, IState prev)
     : base(context)
 {
     this.prev = prev;
     this._timer = new Util.StaticTimer(TimeSpan.FromSeconds(8));
     this.queueMsg = new Queue<NewsMessage>();
 }
Example #5
0
        public ActionResult MachineDetail(int id)
        {
            using (var machineContext = new MachineContext())
            {
                var machine = machineContext.Machines.SingleOrDefault(m => m.MachineId == id);
                if (machine != null)
                {
                    var machineViewModel = new MachineViewModel
                    {
                        MachineId    = machine.MachineId,
                        MachineNum   = machine.MachineNum,
                        MachineMake  = machine.MachineMake,
                        MachineModel = machine.MachineModel,
                        TypeId       = machine.TypeId,
                        Hours        = machine.Hours,
                        Notes        = machine.Notes,
                        Status       = machine.Status,
                        Photo        = machine.Photo
                    };
                    return(View(machineViewModel));
                }
            }

            return(new HttpNotFoundResult());
        }
Example #6
0
        public void message_should_work()
        {
            var context = MachineContext.Create(b => b
                                                .RegisterIdentities(typeof(UserId) /*, typeof(SuperUserId)*/)
                                                );

            var metadata = new MessageMetadata();

            metadata.Receivers = new List <IIdentity>()
            {
                new UserId()
                {
                    Value = "hello"
                },
                new UserId()
                {
                    Value = "hello232"
                },
                new UserId()
                {
                    Value = "hello232dfhdghdgh"
                },
            };

            var bytes = ProtobufSerializer.SerializeProtocalBuffer(metadata, context.Serializer.Model);
            var back  = ProtobufSerializer.DeserializeProtocalBuffer <MessageMetadata>(bytes, context.Serializer.Model);
        }
Example #7
0
 public NewsCrawlerState(MachineContext context, IState prev)
     : base(context)
 {
     this.prev = prev;
     this._timer = new Util.StaticTimer(TimeSpan.FromMinutes(3));
     InitRssFeed();
 }
 static void DisplayOperatingSystems()
 {
     Console.Clear();
     Console.WriteLine("Operating Systems");
     Console.ForegroundColor = ConsoleColor.White;
     using (var context = new MachineContext())
     {
         foreach (var os in context.OperatingSys.ToList())
         {
             Console.Write($"Name: {os.Name,-39}\tStill Supported = ");
             Console.ForegroundColor = ConsoleColor.White;
             if (os.StillSupported == true)
             {
                 Console.ForegroundColor = ConsoleColor.Green;
             }
             else
             {
                 Console.ForegroundColor = ConsoleColor.Red;
             }
             Console.WriteLine(os.StillSupported);
             Console.ForegroundColor = ConsoleColor.White;
             Console.ForegroundColor = ConsoleColor.Black;
         }
     }
     Console.WriteLine("\r\nAny key to continue...");
     Console.ForegroundColor = ConsoleColor.White;
     Console.ReadKey();
 }
Example #9
0
        public ActionResult EditMachine(MachineViewModel machineViewModel)
        {
            using (var machineContext = new MachineContext())
            {
                var machine = machineContext.Machines.SingleOrDefault(m => m.MachineId == machineViewModel.MachineId);

                if (machine != null)
                {
                    machine.MachineNum   = machineViewModel.MachineNum.Value;
                    machine.MachineMake  = machineViewModel.MachineMake;
                    machine.MachineModel = machineViewModel.MachineModel;
                    machine.TypeId       = machineViewModel.TypeId;
                    machine.Hours        = machineViewModel.Hours.Value;
                    machine.Notes        = machineViewModel.Notes;
                    machine.Status       = machineViewModel.Status;
                    machine.Photo        = machineViewModel.Photo;
                    machineContext.SaveChanges();


                    return(RedirectToAction("Index"));
                }

                return(new HttpNotFoundResult());
            }
        }
        static OperatingSys GetOperatingSystemById(int id)
        {
            var          context = new MachineContext();
            OperatingSys os      = context.OperatingSys.FirstOrDefault(i => i.OperatingSysId == id);

            return(os);
        }
 public MachineController(MachineContext context, UserManager <MachineUser> userManager, IMapper mapper,
                          LinkGenerator linkGenerator)
 {
     _context       = context;
     _userManager   = userManager;
     _mapper        = mapper;
     _linkGenerator = linkGenerator;
 }
Example #12
0
 public RouterNode(MachineContext context, String routerRepAddress, String routerPubAddress, String domainReqAddress, IJournalStorage storage)
 {
     _context          = context;
     _routerRepAddress = routerRepAddress;
     _routerPubAddress = routerPubAddress;
     _domainReqAddress = domainReqAddress;
     _storage          = storage;
 }
Example #13
0
        public bool SupportTicketIdExists(int supportTicketId)
        {
            bool exists = false;

            using (MachineContext context = new MachineContext()) {
                exists = context.SupportTicket.Any(x => x.SupportTicketId.Equals(supportTicketId));
            }
            return(exists);
        }
Example #14
0
        public MainViewModel()
        {
            db = new MachineContext();

            //Creates database if non created and perform migrations
            db.Database.Migrate();
            Machines = new ObservableCollection <Machine>();
            ResetFields();
        }
        public void simple_pum_para_pum()
        {
            var journalStorage = new InMemoryJournalStorage();

            var context = MachineContext.Create(b => b
                                                .RegisterMessages(typeof(EnvelopeSerializer_Event), typeof(EnvelopeSerializer_Child_Event))
                                                .RegisterIdentities(typeof(EnvelopeSerializer_Id))
                                                .AddRouter("process", new ProcessRouter())
                                                );

            var message = new EnvelopeSerializer_Event()
            {
                Rate = 0.7, Title = "Muahaha!"
            };
            var messageMetadata = new EventMetadata()
            {
                Receivers = new[] { new EnvelopeSerializer_Id()
                                    {
                                        Value = "hello"
                                    } }
            };

            context.RunHost(h => h
                            .AddNode(new RouterNode(context, "inproc://rep", "inproc://pub", "inproc://domain", journalStorage))
                            .AddNode(new ProcessesNode(context, "inproc://domain", "inproc://rep"))
                            .SetTimeout(700)
                            .Execute(token =>
            {
                using (var input = context.CreateSocket(SocketType.PUSH))
                {
                    input.Connect("inproc://rep", token);

                    input.SendPacket(context.CreatePacket(message, messageMetadata));
                    input.SendPacket(context.CreatePacket(message, messageMetadata));
                    input.SendPacket(context.CreatePacket(message, messageMetadata));
                    input.SendPacket(context.CreatePacket(message, messageMetadata));
                    input.SendPacket(context.CreatePacket(message, messageMetadata));
                }
            })
                            );

            var seq     = journalStorage.GetPrivateFieldValue <Int64>("_sequance");
            var storage = journalStorage.GetPrivateFieldValue <SortedList <Int64, IPacketMessageEnvelope> >("_storage");

            Assert.That(seq, Is.EqualTo(5));
            var firstMessage = (EnvelopeSerializer_Event)storage[1].Message;

            Assert.That(firstMessage == message, Is.False);
            Assert.That(firstMessage.Rate, Is.EqualTo(message.Rate));
            Assert.That(firstMessage.Title, Is.EqualTo(message.Title));

            var result = journalStorage.Load(3, 100);

            var queue = new Queue(1);
        }
Example #16
0
 public void SetupViewBag()
 {
     using (var machineContext = new MachineContext())
     {
         ViewBag.MachineTypes = new SelectList(
             machineContext.MachineTypes.ToList(),
             "TypeId",
             "TypeName"
             );
     }
 }
        public List <SupportLog> RetreiveLogEntries(int ticketId)
        {
            List <SupportLog> logEntries = new List <SupportLog>();

            using (MachineContext context = new MachineContext()) {
                logEntries = context.SupportLog
                             .Where(x => x.SupportTicketId == ticketId)
                             .OrderBy(x => x.SupportTicket).ToList();
            }
            return(logEntries);
        }
        public List <SupportTicket> RetreiveOpenTickets()
        {
            List <SupportTicket> openTickets = new List <SupportTicket>();

            using (MachineContext context = new MachineContext()) {
                openTickets = context.SupportTicket
                              .Include(m => m.Machine)
                              .Where(x => x.DateResolved == null).ToList();
            }
            return(openTickets);
        }
 private void CloseTicket(int ticketId)
 {
     Console.WriteLine("Closing ticket...");
     using (MachineContext context = new MachineContext()) {
         SupportTicket sTicket = context.SupportTicket.Where(x => x.SupportTicketId == ticketId).FirstOrDefault();
         sTicket.DateResolved = DateTime.Now;
         context.Update(sTicket);
         context.SaveChanges();
         Console.WriteLine("Ticket is closed");
     }
 }
Example #20
0
 static void DeleteAllUnsupportedOperatingSystems()
 {
     using (var context = new MachineContext()) {
         var os = (from o in context.OperatingSys where o.StillSupported == false select o);
         Console.WriteLine("\r\nDeleting all Unsupported Operating Systems...");
         context.OperatingSys.RemoveRange(os);
         int i = context.SaveChanges();
         Console.WriteLine($"We have deleted {i} records");
         Console.WriteLine("Hit any key to continue...");
         Console.ReadKey();
     }
 }
        /// <summary>
        /// The contructor requires an open DataContext to work with
        /// </summary>
        /// <param name="context">An open DataContext</param>

        public RepositoryMachineMk2(MachineContext context)
        {
            this.Context = context;
            try
            {
                this.Entities = context.Set <TEntity>();
            }
            catch
            {
                this.Queries = context.Query <TEntity>();
            }
        }
Example #22
0
        static bool CheckForExistingOS(string osName)
        {
            bool exists = false;

            using (var context = new MachineContext()) {
                var os = context.OperatingSys.Where(o => o.Name.Trim() == osName.Trim());
                if (os.Count() > 0)
                {
                    exists = true;
                }
            }
            return(exists);
        }
Example #23
0
        public AccountController(ILogger <AccountController> logger,
                                 SignInManager <MachineUser> signInManager,
                                 UserManager <MachineUser> userManager,
                                 MachineContext context,

                                 IConfiguration config)
        {
            _logger        = logger;
            _signInManager = signInManager;
            _userManager   = userManager;
            _context       = context;
            _config        = config;
        }
Example #24
0
        public void Retreive_Support_Ticket_By_ID()
        {
            // Arrange
            int           ticketId = 1;
            SupportTicket sTicket;

            // Act
            using (MachineContext context = new MachineContext()) {
                sTicket = context.SupportTicket.Where(x => x.SupportTicketId == ticketId).FirstOrDefault();
            }

            //Assert
            Assert.AreEqual(1, sTicket.SupportTicketId, message: "TicketId test");
            Assert.AreEqual(5, sTicket.MachineId, message: "MachineId test");
        }
Example #25
0
 public MainViewModel()
 {
     _machineContext     = new MachineContext();
     ClickCommand        = new ParameterCommand <string>(OnClick);
     SelectItemCommand   = new ParameterCommand <string>(OnItemSelected);
     MenuCommand         = new ParameterCommand <string>(OnMenuItemSelected);
     OnDropCommand       = new ParameterCommand <DragEventArgs>(OnDrop);
     _imageService       = new ImageService();
     _OCRService         = new OCRService();
     _windowsManager     = new WindowsManager();
     WindowHeight        = SystemParameters.PrimaryScreenHeight * 0.6;
     WindowWidth         = SystemParameters.PrimaryScreenWidth * 0.6;
     SelectedOCRLanguage = "eng";
     WindowVisibility    = Visibility.Visible;
     OCRResult           = new List <string>();
 }
Example #26
0
        public void test()
        {
            var context = MachineContext.Create(b => b
                                                .RegisterIdentities(typeof(UserId) /*, typeof(SuperUserId)*/)
                                                );

            var metadata = new StateMetadata();

            metadata.ProcessId = new UserId()
            {
                Value = "hello"
            };

            var bytes = ProtobufSerializer.SerializeProtocalBuffer(metadata, context.Serializer.Model);
            var back  = ProtobufSerializer.DeserializeProtocalBuffer <StateMetadata>(bytes, context.Serializer.Model);
        }
 static void DisplayOperatingSystems()
 {
     Clear();
     WriteLine("Operating Systems");
     using (var context = new MachineContext())
     {
         foreach (var os in context.OperatingSys.ToList())
         {
             Write($"Name: {os.Name,-39}\tStill Supported = ");
             ForegroundColor = os.StillSupported == true ? ConsoleColor.Green : ConsoleColor.Red;
             WriteLine(os.StillSupported);
             ForegroundColor = ConsoleColor.Yellow;
         }
     }
     WriteLine("\r\nAny key to continue...");
     ReadKey();
 }
        public ActionResult DeleteMachine(MachineViewModel machineViewModel)
        {
            using (var machineContext = new MachineContext())
            {
                var machine = machineContext.Machines.SingleOrDefault(p => p.Id == machineViewModel.Id);

                if (machine != null)
                {
                    machineContext.Machines.Remove(machine);
                    machineContext.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }

            return(new HttpNotFoundResult());
        }
        static void DeleteOperatingSystem(int id)
        {
            OperatingSys os = GetOperatingSystemById(id);

            if (os != null)
            {
                Console.WriteLine($"\r\nAre you sure you want to delete {os.Name}? [y or n]");
                Console.ForegroundColor = ConsoleColor.White;
                ConsoleKeyInfo cki;
                string         result;
                bool           cont;
                do
                {
                    cki    = Console.ReadKey(true);
                    result = cki.KeyChar.ToString();
                    cont   = ValidateYorN(result);
                } while (!cont);
                if ("y" == result.ToLower())
                {
                    Console.WriteLine("\r\nDeleting record");
                    Console.ForegroundColor = ConsoleColor.White;
                    using (var context = new MachineContext())
                    {
                        context.Remove(os);
                        context.SaveChanges();
                    }
                    Console.WriteLine("Record Deleted");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.ReadKey();
                }
                else
                {
                    Console.WriteLine("Delete Aborted\r\nHit any key to continue...");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.ReadKey();
                }
            }
            else
            {
                Console.WriteLine("\r\nOperating System Not Found!");
                Console.ForegroundColor = ConsoleColor.White;
                Console.ReadKey();
                SelectOperatingSystem("Delete");
            }
        }
        public ActionResult AddMachine(MachineViewModel machineViewModel)
        {
            using (var machineContext = new MachineContext())
            {
                var machine = new Machine
                {
                    Num   = machineViewModel.Num,
                    Make  = machineViewModel.Make,
                    Model = machineViewModel.Model,
                    Hours = machineViewModel.Hours
                };

                machineContext.Machines.Add(machine);
                machineContext.SaveChanges();
            }


            return(RedirectToAction("Index"));
        }
        public ActionResult EditMachine(MachineViewModel machineViewModel)
        {
            using (var machineContext = new MachineContext())
            {
                var machine = machineContext.Machines.SingleOrDefault(p => p.Id == machineViewModel.Id);

                if (machine != null)
                {
                    machine.Num   = machineViewModel.Num;
                    machine.Make  = machineViewModel.Make;
                    machine.Model = machineViewModel.Model;
                    machine.Hours = machineViewModel.Hours;

                    return(RedirectToAction("Index"));
                }
            }


            return(new HttpNotFoundResult());
        }
Example #32
0
        public ActionResult AddMachine(MachineViewModel machineViewModel)
        {
            using (var machineContext = new MachineContext())
            {
                var machine = new Mach
                {
                    MachineNum   = machineViewModel.MachineNum.Value,
                    MachineMake  = machineViewModel.MachineMake,
                    MachineModel = machineViewModel.MachineModel,
                    TypeId       = machineViewModel.TypeId,
                    Hours        = machineViewModel.Hours.Value,
                    Notes        = machineViewModel.Notes,
                    Status       = machineViewModel.Status,
                    Photo        = machineViewModel.Photo
                };

                machineContext.Machines.Add(machine);
                machineContext.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
        public ActionResult MachineEdit(int id)
        {
            using (var machineContext = new MachineContext())
            {
                var machine = machineContext.Machines.SingleOrDefault(p => p.Id == id);
                if (machine != null)
                {
                    var machineViewModel = new MachineViewModel
                    {
                        Num   = machine.Num,
                        Make  = machine.Make,
                        Model = machine.Model,
                        Hours = machine.Hours,
                    };

                    return(View("AddEditMachine", machineViewModel));
                }
            }

            return(new HttpNotFoundResult());
        }
Example #34
0
 public NewsEndState(MachineContext context)
     : base(context)
 {
     _timer = new Util.StaticTimer(TimeSpan.FromSeconds(1));
 }
Example #35
0
 public NewsIdleState(MachineContext context)
     : base(context)
 {
 }
Example #36
0
 public NewsBeginState(MachineContext context)
     : base(context)
 {
     waitingForOverlayAnimationCompleted = new Util.StaticTimer(TimeSpan.FromSeconds(1));
 }
Example #37
0
 public LoggingState(IState decoratee, MachineContext context)
 {
     this.decoratee = decoratee;
     this.context = context;
 }