Exemplo n.º 1
0
        public List <Library.Library> ReadFile(List <Library.Library> libraries)
        {
            List <Library.Library> libs = libraries;

            try
            {
                this.reader = new StreamReader(@"C:\Users\Samantha\source\repos\Assignment_01_PRO670\Assignment_01_PRO670\" + this.fileName);
            } catch (Exception e)
            {
                Console.WriteLine(e);
            }

            using (reader)
            {
                while (!reader.EndOfStream)
                {
                    Library.Library tempLib = new Library.Library();

                    var line   = reader.ReadLine();
                    var values = line.Split(',');

                    tempLib.LibraryId = Int16.Parse(values[0]);
                    tempLib.Address   = values[1];

                    libs.Add(tempLib);
                }
            }
            return(libs);
        }
        public bool AddProject(string title, string description, string projectFolder, Library.User projectAdministratorUser)
        {
            User adminUser = dbUser.FindUserById(projectAdministratorUser.Id);
            if (adminUser == null)
            {
                return false;
            }

            Project project = new Project(title, description, projectFolder, adminUser);
            try
            {
                var option = new TransactionOptions();
                option.IsolationLevel = IsolationLevel.ReadCommitted;

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, option))
                {
                    dbContext.Projects.InsertOnSubmit(project);
                    dbContext.ProjectUsers.InsertOnSubmit(new ProjectUsers { Project = project, User = project.ProjectAdministrators.FirstOrDefault(), UserType = UserType.Administrator });
                    dbContext.SubmitChanges();
                    if (true) //TODO check if the data added to db were sucessfull / valid.
                        scope.Complete();
                }
                return true;
            }
            catch (Exception e)
            {
                throw new Exception("Project not added to db " + e);
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Test Program for Library Application");
            Console.WriteLine();

            Library myLib = new Library();

            // check-out one book
            myLib.book1.issue(myLib.user1);

            // try to check-out the same book by another user
            myLib.book1.issue(myLib.user2);

            // return the book
            myLib.book1.returnIt();

            // hold a book
            myLib.ebook1.holdIt(myLib.user2);

            // try to check-out the same book by another user
            myLib.ebook1.issue(myLib.user1);

            // remove hold
            myLib.ebook1.removeHolds();
            Console.WriteLine();

            // print authors
            Console.WriteLine(myLib.book1.printAuthors);
            Console.WriteLine(myLib.ebook1.printAuthors);

            Console.Read();
        }
Exemplo n.º 4
0
 private void InitializeBindings(Library.CustomerEdit model)
 {
     this.Model = model;
     this.Model.BeginEdit();
     this.Bindings.RemoveAll();
     Bindings.Add(((MainView)View).txtId, "Text", this.Model, "Id", BindingDirection.OneWay);
     Bindings.Add(((MainView)View).txtName, "Text", this.Model, "Name", BindingDirection.TwoWay);
     Bindings.Add(((MainView)View).txtStatus, "Text", this.Model, "Status", BindingDirection.OneWay);
 }
Exemplo n.º 5
0
 public CommsDecoder(string BaudRate, string COMport, Library.PacketStates.PacketState SendPacketState)
 {
     //Set Communication Properties
     _BaudRate = BaudRate;
     _COMport = COMport;
     //Set Current Communication States
     CurrentState = SendPacketState;
     //Initialise timers
     timerClock = new System.Timers.Timer();
 }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            //We are given a library of books. Define classes for the library and the books.
            //The library should have name and a list of books.
            //The books have title, author, publisher, year of publishing and ISBN. Keep the books in List<Book>
            //(first find how to use the class System.Collections.Generic.List<T>).

            //Implement methods for adding, searching by title and author, displaying and deleting books.\

            //Write a test class that creates a library, adds few books to it and displays them.
            //Find all books by Nakov, delete them and print again the library.

            Book book1 = new Book("Encarta Encyclopedia", "Tom Jones", "Izdanie Trud", "1989", "sfrsdfr9342343");
            Book book2 = new Book("Raznovidnosti na ruskiq ribolov", "James Brown", "Prosveta", "1983", "sfrsf2342343");
            Book book3 = new Book("Introduction Programming with C#", "Svetlin Nakov", "Prosveta", "2011", "sfrsf2342343");
            Book book4 = new Book("Introduction Programming with Java", "Svetlin Nakov", "Prosveta", "1985", "sfrsf2342343");

            List<Book> books = new List<Book> { book1, book2, book3, book4 };

            Library library = new Library(books);
            library.Name = "My cool new library";
            //view books in newly created library
            library.ViewAllBooks();

            List<Book> NakovBooks = library.GetBooksByAuthor("Svetlin Nakov");

            //see how many Nakov books are there now
            Console.WriteLine();
            Console.WriteLine("There are {0} Nakov's books in the library", NakovBooks.Count);
            Console.WriteLine();
            foreach (Book NakovBook in NakovBooks)
            {
                library.DeleteBook(NakovBook);
            }
            //view library after deleting Nakov's Books
            library.ViewAllBooks();
            //see how many Nakov books are there now
            NakovBooks = library.GetBooksByAuthor("Svetlin Nakov");
            Console.WriteLine("Now there are {0} Nakov's books in the library", NakovBooks.Count);
        }
Exemplo n.º 7
0
 public void DeleteTitle(Library.MovieItem item)
 {
     foreach (Disk d in item.TitleObject.Disks)
     {
         string status = deleteDisk(d);
         if (!string.IsNullOrEmpty(status))
         {
             this.MediaCenterEnvironment.Dialog(
                 string.Format("Unable to delete this movie: {0}", status),
                 "Failed", DialogButtons.Ok, 5, false);
             return;
         }
         else
         {
             TitleCollectionManager.DeleteTitle(item.TitleObject);
         }
     }
 }
Exemplo n.º 8
0
 void mouseActiveHooker_MouseActive(Library.Code.V3.IsMouseActiveHooker m, Library.Code.V3.MouseActiveEventArgs e)
 {
     this.IsMouseActive = e.MouseActive;
 }
Exemplo n.º 9
0
 public void RegisterSource(string stScheme, Library.Code.V3.IResourceProvider source)
 {
     this.m_dictSources[stScheme] = source;
 }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            Library l = new Library();

            l.menu();
        }
Exemplo n.º 11
0
Arquivo: Native.cs Projeto: ifzz/FDK
        static void Construct()
        {
            LrpClient = CreateLocalClient(Signature.Value, "SoftFX.LlApi.");
            LrpLlCommonClient = CreateLocalClient(Financial.Generated.Signature.Value, "SoftFX.LlCommon.");

            Serializer = new Financial.Generated.Serializer(LrpLlCommonClient);

            Handle = new Handle(LrpClient);
            Params = new Params(LrpClient);
            Client = new ClientServer(LrpClient);
            ClientCache = new ClientCache(LrpClient);
            FeedServer = new FeedServer(LrpClient);
            FeedCache = new FeedCache(LrpClient);
            TradeServer = new TradeServer(LrpClient);
            TradeCache = new TradeCache(LrpClient);
            Converter = new Converter(LrpClient);
            Iterator = new Iterator(LrpClient);
            Library = new Library(LrpClient);
        }
 public bool UpdateUser(int id, string username, string password, string salt, Library.UserType usertype, string email)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            Console.WriteLine("Test Program for Library Application");
            Console.WriteLine();

            Library myLib = new Library();

            // check-out one book
            myLib.book1.issue(myLib.user1);

            // try to check-out the same book by another user
            myLib.book1.issue(myLib.user2);

            // return the book
            myLib.book1.returnIt();

            // hold a book
            myLib.ebook1.holdIt(myLib.user2);

            // try to check-out the same book by another user
            myLib.ebook1.issue(myLib.user1);

            // remove hold
            myLib.ebook1.removeHolds();
            Console.WriteLine();

            // check-out one music
            myLib.music1.issue(myLib.user1);

            // try to check-out the same music by another user
            myLib.music1.issue(myLib.user2);

            //check in one music
            myLib.music1.returnIt();

            // check-out one movie
            myLib.movie1.issue(myLib.user1);

            // try to check-out the same movie by another user
            myLib.movie1.issue(myLib.user2);

            //check in one movie
            myLib.movie1.returnIt();

            // check-out one Audiobook
            myLib.audioBook1.issue(myLib.user1);

            // try to check-out the same Audiobook by another user
            myLib.audioBook1.issue(myLib.user2);

            //check in one audiobook
            myLib.audioBook1.returnIt();

            // print authors
            Console.WriteLine(myLib.book1.printAuthors);
            Console.WriteLine(myLib.ebook1.printAuthors);

            // print music duration
            Console.WriteLine(myLib.music1.getHMS());
            Console.WriteLine(myLib.music2.getHMS());

            //print movie duration
            Console.WriteLine(myLib.movie1.getHMS());
            Console.WriteLine(myLib.movie2.getHMS());

            //print Audiobook duration
            Console.WriteLine(myLib.audioBook1.getHMS());
            Console.WriteLine(myLib.audioBook2.getHMS());

            // Print all (unsorted) elements of List<Item> using Iterator
            Console.WriteLine("\nPrint all (unsorted) elements of List<Item> using Iterator");
            foreach(Item i in Item.GetItems())
            {
                Console.WriteLine(i.ToString());
            }

            // Sort elements of List<Item> based on ‘year’
            ItemComparer itemComparer = new ItemComparer();
            Item.GetItems().Sort(itemComparer);

            // Print all (sorted) elements of List<Item> using Iterator
            Console.WriteLine("\nPrint all (sorted) elements of List<Item> using Iterator");
            foreach (Item i in Item.GetItems())
            {
                Console.WriteLine(i.ToString());
            }

            // Print all elements in dictionary collection using Indexer.
            Console.WriteLine("\nPrint all elements in dictionary collection using Indexer");
            ItemCollection myItems = new ItemCollection();
            myItems[myLib.book1.Year] = myLib.book1;
            myItems[myLib.book2.Year] = myLib.book2;
            myItems[myLib.movie1.Year] = myLib.movie1;
            myItems[myLib.movie2.Year] = myLib.movie2;
            myItems[myLib.music1.Year] = myLib.music1;
            myItems[myLib.music2.Year] = myLib.music2;

            Console.WriteLine(myItems[myLib.book1.Year]);
            Console.WriteLine(myItems[myLib.book2.Year]);
            Console.WriteLine(myItems[myLib.movie1.Year]);
            Console.WriteLine(myItems[myLib.movie2.Year]);
            Console.WriteLine(myItems[myLib.music1.Year]);
            Console.WriteLine(myItems[myLib.music2.Year]);

            // Get entries parsed from Text file.
            List<Item> parsedItems = myLib.ParseFileContents();

            // Add the parsed items to dictionary.
            // The items are also added to the List when they were initialized.
            foreach(Item i in parsedItems)
            {
                myItems[i.Year] = i;
            }

            // Call method to write the LibraryCatalog.txt
            Console.WriteLine("\nPrinted LibraryCatalog.txt in current directory");
            myLib.PrintLibraryCatalog(Item.GetItems());

            // Print Items from year 2005 using LINQ query
            Console.WriteLine("\nPrint Items from year 2005 using LINQ query");
            List<Item> result = myLib.GetItemsByYear(Item.GetItems(), 2005);
            foreach(Item i in result)
            {
                Console.WriteLine(i.ToString());
            }

            Console.Read();
        }
 public void PlayMovie(Library.Code.V3.MovieItem item)
 {
     if (this.Enabled)
     {
         string itemRating = item.TitleObject.ParentalRating.ToUpperInvariant().Replace("-", "");
         if (!string.IsNullOrEmpty(itemRating) && itemRating!="UNRATED")
         {
             if (MCMovieRatings.ContainsKey(itemRating) && MCMovieRatings[itemRating] > this.MaxAllowed)
             {
                 controls.PromptForPin(delegate(bool goodPin)
                 {
                     if (goodPin)
                         item.PlayMovie();
                 });
             }
             else
                 item.PlayMovie();
         }
         else
         {
             if (this.BlockUnrated)
             {
                 controls.PromptForPin(delegate(bool goodPin)
                 {
                     if (goodPin)
                         item.PlayMovie();
                 });
             }
             else
                 item.PlayMovie();
         }
     }
     else
         item.PlayMovie();
 }
 public bool ItemIsAllowed(Library.Code.V3.MovieItem item)
 {
     if (this.Enabled)
     {
         string itemRating = item.TitleObject.ParentalRating.ToUpperInvariant();
         if (string.IsNullOrEmpty(itemRating))
         {
             if (MCMovieRatings[itemRating] <= this.MaxAllowed)
                 return true;
         }
         else
         {
             if (this.BlockUnrated)
                 return false;
         }
     }
     return true;
 }