Ejemplo n.º 1
0
        public MainWindow()
        {
            _library_service = new LibraryServiceClient();

            this.Initialized += MainWindow_Initialized;
            InitializeComponent();
        }
Ejemplo n.º 2
0
        public ActionResult Books()
        {
            Book[] books = null;
            try
            {
                string endpointName = GlobalCache.GetResolvedString("LibraryServiceEndpoint");
                if (endpointName == null)
                {
                    throw new ApplicationException("Could not find 'LibraryServiceEndpoint' in configuration settings.");
                }
                Debug.WriteLine(string.Format("LibraryServiceEndpoint='{0}'", endpointName));

                // ---------------------------------------------------------
                //
                // ---------------------------------------------------------
                using (LibraryServiceClient proxy = new LibraryServiceClient(endpointName))
                {
                    proxy.List(null, out books);
                }
            }
            catch (Exception exp)
            {
                Request.PostError(exp, false);
            }

            return(PartialView(new List <Book>(books)));
        }
Ejemplo n.º 3
0
 static void AddSomeBooks(LibraryServiceClient client)
 {
     foreach (var book in Books)
     {
         client.AddBook(book);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Guzik usuwający z bazy zaznaczone książki.
        /// </summary>
        protected void btnUsunZaznaczone_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem lvi in ListView1.Items)
            {
                CheckBox chbox = lvi.FindControl("CheckBoxItem") as CheckBox;

                if (chbox.Checked)
                {
                    try
                    {
                        HiddenField hf = lvi.FindControl("ID_KSIAZKA") as HiddenField;
                        string      id = hf.Value;

                        LibraryServiceClient lib = new LibraryServiceClient();
                        lib.deleteBook(Int32.Parse(id));
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            ListView1.DataBind();
            showInfo("Pomyślnie usunięto zaznaczone elementy");
        }
Ejemplo n.º 5
0
        private static void Main(string[] args)
        {
            var client1 = new LibraryServiceClient();

            client1.Present("Петр", "Петров");
            Console.WriteLine($"ID-сессии: {client1.InnerChannel.SessionId}");
            client1.EscapeLibrary();

            var client2 = new LibraryServiceClient();

            client2.Present("Иван", "Иванов");
            Console.WriteLine($"ID-сессии: {client1.InnerChannel.SessionId}");

            var newBook = new Book
            {
                Id       = 6,
                Author   = "Пушкин А.С.",
                BookType = BookType.Tale,
                Name     = "Сказка о рыбаке и рыбке"
            };

            client2.Add(newBook);

            for (var i = 1; i < 7; i++)
            {
                var book = client2.Get(i);
                client1.Take(book);
            }
            client2.ApplyСhanges();

            Console.ReadLine();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Po kliknięciu "Usuń" usunięcie z bazy danej książki i przekierowanie na stronę główną.
        /// </summary>
        protected void lbtnUsun_Click(object sender, EventArgs e)
        {
            LibraryServiceClient lib = new LibraryServiceClient();

            lib.deleteBook(Int32.Parse(id));
            Response.Redirect("~/Default.aspx");
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            var client = new LibraryServiceClient();
            var book   = new Book
            {
                Name           = "name",
                Author         = "author",
                PublishingYear = 2017,
                BookType       = BookType.FictionBook
            };
            var book1 = new Book
            {
                Name           = "name2",
                Author         = "author2",
                PublishingYear = 2017,
                BookType       = BookType.Magazine
            };

            client.AddBook(book);
            client.AddBook(book1);
            PrintBook(client.GetBook(0));
            client.TakeBook(book);
            PrintBook(client.GetBook(1));
            client.ReturnBook(book);
            var books = client.GetAllBooks("author");

            foreach (var e in books)
            {
                PrintBook(e);
            }
        }
Ejemplo n.º 8
0
        private void btnSimpleSearch_Click(object sender, EventArgs e)
        {
            LibraryServiceClient lib = new LibraryServiceClient();

            gvBooksList.Rows.Clear();
            foreach (BookForListShort b in lib.searchBooksSimple(txtSearchSimple.Text.ToString()))
            {
                gvBooksList.Rows.Add(b.Id.ToString(), b.tytul.ToString());
            }
        }
Ejemplo n.º 9
0
        public List <BookDTO> GetAllBooks()
        {
            List <BookDTO> booksList = new List <BookDTO>();

            using (LibraryServiceClient client = new LibraryServiceClient())
            {
                booksList = client.GetAllBooks();
            }
            return(booksList);
        }
Ejemplo n.º 10
0
        private void getBooks()
        {
            gvBooksList.Rows.Clear();
            LibraryServiceClient lib = new LibraryServiceClient();

            foreach (BookForListShort b in lib.getBooksListShort())
            {
                gvBooksList.Rows.Add(b.Id.ToString(), b.tytul.ToString());
            }
        }
Ejemplo n.º 11
0
        public ActionResult Checkout(Library.Model.Checkout Checkout)
        {
            object response = null;

            try
            {
                string endpointName = GlobalCache.GetResolvedString("LibraryServiceEndpoint");
                if (endpointName == null)
                {
                    throw new ApplicationException("Could not find 'LibraryServiceEndpoint' in configuration settings.");
                }
                Debug.WriteLine(string.Format("LibraryServiceEndpoint='{0}'", endpointName));

                DateTime?checkedout = null;

                using (LibraryServiceClient proxy = new LibraryServiceClient(endpointName))
                {
                    if (proxy.Checkout(Checkout, true, out checkedout))
                    {
                        Checkout.DateOut = checkedout.Value;

                        var parameters = new KeyedDataStore(Request.Form);
                        parameters["DateOut"] = checkedout.Value;
                        sendEmailConfirmation(parameters);

                        response = new
                        {
                            code    = 200,
                            message = string.Format("{0: MM/dd/yyyy HH:mm:ss} - A confirmation email has been sent.",
                                                    checkedout),
                            ISBN = Checkout.ISBN
                        };
                    }
                    else
                    {
                        response = new
                        {
                            code    = 409,
                            message = string.Format("{0: MM/dd/yyyy HH:mm:ss} - As of this date, your selection was already checked out.",
                                                    checkedout),
                            ISBN = ""
                        };
                        Response.StatusCode = 409;
                    }
                }
            }
            catch (Exception exp)
            {
                Trace.WriteLine(string.Format("Exception CheckoutBook::ProcessRequest\n{0}", exp.Message));
                Request.PostError(exp);
            }

            Response.ContentType = "application/json";
            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Ustawienie tytułu strony.
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object senderr, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return(true); };
            LibraryServiceClient lib = new LibraryServiceClient();
            String url         = lib.Endpoint.Address.Uri.ToString();
            String serviceName = "LibraryService.svc";

            url           = url.Remove(url.Length - serviceName.Length, serviceName.Length);
            url           = url + "covers/";
            webServiceUrl = url;
            Page.Title    = "Biblioteka";
        }
Ejemplo n.º 13
0
        private void bookToForm(int id)
        {
            LibraryServiceClient lib = new LibraryServiceClient();
            Book   b           = lib.getBookInfo(id);
            String url         = lib.Endpoint.Address.Uri.ToString();
            String serviceName = "LibraryService.svc";

            url = url.Remove(url.Length - serviceName.Length, serviceName.Length);
            url = url + "covers/";
            try
            {
                txtDescription.Text = b.opis.Replace("<br> ", "\r\n");
            }
            catch (Exception)
            {
            }
            txtTitle.Text     = b.tytul;
            txtPublisher.Text = Form1.getData(b.wydawnictwo);
            txtAuthors.Text   = b.autorzy;
            if (!string.IsNullOrWhiteSpace(b.oprawa))
            {
                if (b.oprawa == "miękka")
                {
                    cbBinding.SelectedIndex = 0;
                }
                else if (b.oprawa == "twarda")
                {
                    cbBinding.SelectedIndex = 1;
                }
                else
                {
                    cbBinding.SelectedIndex = -1;
                }
            }
            txtISBN.Text             = Form1.getData(b.isbn);
            txtDimensions.Text       = Form1.getData(b.wymiary);
            numericPagesNumber.Value = b.iloscStron;


            string fileName = b.okladka;

            if (!String.IsNullOrWhiteSpace(fileName))
            {
                pictureBox1.ImageLocation = string.Format(url + fileName);
                pictureBox1.Tag           = b.okladka;
            }
            else
            {
                pictureBox1.ImageLocation = string.Format(url + "brak-okladki.jpg");
                pictureBox1.Tag           = null;
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Metoda ładująca dane książki do odpowiednich kontrolek.
        /// </summary>
        /// <param name="id">ID książki</param>
        /// <returns>True jeśli odczytwaliśmy dane z bazy, false przy braku danych.</returns>
        private bool loadData(string id)
        {
            LibraryServiceClient lib = new LibraryServiceClient();
            Book book = lib.getBookInfo(Int32.Parse(id));

            if (book != null)
            {
                String url         = lib.Endpoint.Address.Uri.ToString();
                String serviceName = "LibraryService.svc";
                url                 = url.Remove(url.Length - serviceName.Length, serviceName.Length);
                url                 = url + "covers/";
                txtTytul.Text       = book.tytul;
                txtOpis.Text        = book.opis;
                txtAutorzy.Text     = book.autorzy;
                txtWydawnictwo.Text = book.wydawnictwo;
                string oprawa = book.oprawa;
                if (oprawa.Equals("miękka"))
                {
                    ddOprawa.SelectedIndex = 0;
                }
                else if (oprawa.Equals("twarda"))
                {
                    ddOprawa.SelectedIndex = 1;
                }
                string[] dimentions = readDimentions(book.wymiary);
                txtWymiaryX.Text = dimentions[0];
                txtWymiaryY.Text = dimentions[1];
                if (book.iloscStron == 0)
                {
                    txtIloscStron.Text = "";
                }
                else
                {
                    txtIloscStron.Text = book.iloscStron.ToString();
                }
                txtISBN.Text = book.isbn;
                string fileName = book.okladka;
                if (!String.IsNullOrWhiteSpace(fileName))
                {
                    imgOkldka.ImageUrl = string.Format(url + fileName);
                }
                else
                {
                    imgOkldka.ImageUrl = string.Format(url + "brak-okladki.jpg");
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 15
0
        public LibraryClient(string endpoint)
        {
            NetTcpBinding myBinding = new NetTcpBinding();
            myBinding.Security.Mode = SecurityMode.None;
            if (endpoint == "")
            {
                //Todo: read this from a file.
                endpoint = defaultendpoint;
            }
            EndpointAddress myEndpoint = new EndpointAddress(endpoint);

            ls = new LibraryServiceClient(myBinding, myEndpoint);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Ustawienie nazwy strony. Jeśli użytkownik jest zalogowany, włącznie guzików edycji i usunięcia wyświetlanej książki.
        /// Jeśli został podany parapetr "id" wyświetlenie informacji o książce, jeśli nie przekierowanie na stronę główną.
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = "Biblioteka - Szczegóły książki";

            if (Session["LOGIN"] != null)
            {
                edit.Visible = true;
            }

            id = Request.QueryString["id"];

            if (id != null)
            {
                LibraryServiceClient lib = new LibraryServiceClient();
                String url         = lib.Endpoint.Address.Uri.ToString();
                String serviceName = "LibraryService.svc";
                url = url.Remove(url.Length - serviceName.Length, serviceName.Length);
                url = url + "covers/";
                LibraryService.Book b = lib.getBookInfo(Int32.Parse(id));
                LabelTytul.Text       = b.tytul;
                Page.Title            = string.Format("Biblioteka - {0}", LabelTytul.Text);
                LabelOpis.Text        = b.opis;
                LabelAutorzy.Text     = b.autorzy;
                LabelWydawnictwo.Text = getData(b.wydawnictwo);
                LabelOprawa.Text      = b.oprawa;
                LabelWymiary.Text     = getData(b.wymiary);
                if (b.iloscStron == 0)
                {
                    LabelLiczbaStron.Text = "Brak danych";
                }
                else
                {
                    LabelLiczbaStron.Text = b.iloscStron.ToString();
                }
                LabelISBN.Text = getData(b.isbn);
                string fileName = b.okladka;
                if (!String.IsNullOrWhiteSpace(fileName))
                {
                    ImageOkladka.ImageUrl = string.Format(url + fileName);
                }
                else
                {
                    ImageOkladka.ImageUrl = string.Format(url + "brak-okladki.jpg");
                }
            }
            else
            {
                Response.Redirect("~/Default.aspx");
            }
        }
Ejemplo n.º 17
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            LibraryServiceClient lib = new LibraryServiceClient();
            Boolean check            = lib.checkCredentials(txtLogin.Text.ToString(), txtPassword.Text.ToString());

            if (check)
            {
                form.logged = true;
                form.changeLogonState(true);
                this.Close();
            }
            else
            {
                MessageBox.Show("Podano błędne dane.", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            }
        }
Ejemplo n.º 18
0
        static void Main(string[] args)
        {
            var cb = new LibraryServiceCallback();
            var instanceContext = new InstanceContext(cb);
            var client          = new LibraryServiceClient(instanceContext);

            cb.Client = client;

            client.LogIn("user1");
            AddSomeBooks(client);
            var books = new List <Book>();

            try
            {
                for (int i = 0; i < 6; i++)
                {
                    books.Add(client.TakeBook(client.GetBook(i)));
                    PrintBook(books[i]);
                }
            }
            catch (FaultException <LibraryFaultModel> ex)
            {
                Console.WriteLine(ex.Detail.Text);
            }
            Console.WriteLine(client.ConfirmChoice());
            for (int i = 0; i < 5; i++)
            {
                client.ReturnBook(books[i]);
                books.Add(client.TakeBook(client.GetBook(i)));
                PrintBook(books[i]);
                client.ReturnBook(books[i]);
            }
            try
            {
                var authorBooks = client.GetAllBooks("author2");
                foreach (var e in authorBooks)
                {
                    PrintBook(e);
                }
            }
            catch (FaultException <LibraryFaultModel> ex)
            {
                Console.WriteLine(ex.Detail.Text);
            }
            client.LeaveLibrary();
        }
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            LibraryServiceClient LSC = new LibraryServiceClient();
            int permission           = LSC.VerifyLogin(txtUsername.Text, txtPassword.Password);

            if (permission == 999)
            {
                MainWindow mainWindow = new MainWindow();
                mainWindow.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("Username or password is incorrect.");
            }
            LSC.Close();
        }
Ejemplo n.º 20
0
        private void gvBooksList_SelectionChanged(object sender, EventArgs e)
        {
            if (gvBooksList.Rows.Count > 0)
            {
                LibraryServiceClient lib = new LibraryServiceClient();
                String url         = lib.Endpoint.Address.Uri.ToString();
                String serviceName = "LibraryService.svc";
                url = url.Remove(url.Length - serviceName.Length, serviceName.Length);
                url = url + "covers/";
                Book b = lib.getBookInfo(Int32.Parse(gvBooksList.CurrentRow.Cells["Id"].Value.ToString()));
                try
                {
                    txtDescription.Text = b.opis.Replace("<br> ", "\r\n");
                }
                catch (Exception)
                {
                }
                txtPublisher.Text  = getData(b.wydawnictwo);
                txtAuthors.Text    = b.autorzy;
                txtBinding.Text    = b.oprawa;
                txtISBN.Text       = getData(b.isbn);
                txtDimensions.Text = getData(b.wymiary);
                if (b.iloscStron == 0)
                {
                    txtPagesNumber.Text = "Brak danych";
                }
                else
                {
                    txtPagesNumber.Text = b.iloscStron.ToString();
                }


                string fileName = b.okladka;
                if (!String.IsNullOrWhiteSpace(fileName))
                {
                    pictureBox1.ImageLocation = string.Format(url + fileName);
                    pictureBox1.Tag           = b.okladka;
                }
                else
                {
                    pictureBox1.ImageLocation = string.Format(url + "brak-okladki.jpg");
                    pictureBox1.Tag           = null;
                }
            }
        }
Ejemplo n.º 21
0
        private void btnDeleteBook_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Czy na pewno chcesz usunąć tą książkę?", "Potwierdzenie", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                LibraryServiceClient lib = new LibraryServiceClient();
                int selection            = Convert.ToUInt16(gvBooksList.CurrentRow.Cells["Id"].Value.ToString());
                int index = gvBooksList.CurrentCell.RowIndex;
                if (index == 0)
                {
                    index++;
                }
                lib.deleteBook(selection);
                getBooks();
                gvBooksList.CurrentCell = gvBooksList.Rows[index - 1].Cells[1];
            }
        }
Ejemplo n.º 22
0
        private static void Main(string[] args)
        {
            var instanceContext1 = new InstanceContext(new ClientCallback());
            var client1          = new LibraryServiceClient(instanceContext1);

            client1.Present("Иван", "Иванов");
            client1.EscapeLibrary();

            var instanceContext2 = new InstanceContext(new ClientCallback());
            var client2          = new LibraryServiceClient(instanceContext2);

            client2.Present("Петр", "Петров");
            Console.WriteLine($"ID-сессии: {client2.InnerChannel.SessionId}");

            var journal = client2.Get(2);

            try
            {
                client2.Get(45);
            }
            catch (FaultException ex)
            {
                Console.WriteLine(ex.Reason);
            }

            client2.Take(journal);

            try
            {
                var book = new Book()
                {
                    Id = 45
                };
                client2.Take(book);
            }
            catch (FaultException ex)
            {
                Console.WriteLine(ex.Reason);
            }

            client2.ApplyСhanges();

            Console.ReadLine();
        }
Ejemplo n.º 23
0
        public ActionResult Export()
        {
            Book[] books = null;
            try
            {
                string endpointName = GlobalCache.GetResolvedString("LibraryServiceEndpoint");
                if (endpointName == null)
                {
                    throw new ApplicationException("Could not find 'LibraryServiceEndpoint' in configuration settings.");
                }
                Debug.WriteLine(string.Format("LibraryServiceEndpoint='{0}'", endpointName));

                // ---------------------------------------------------------
                //
                // ---------------------------------------------------------
                using (LibraryServiceClient proxy = new LibraryServiceClient(endpointName))
                {
                    proxy.List(null, out books);
                }
            }
            catch (Exception exp)
            {
                Request.PostError(exp, false);
            }

            Response.ContentType     = "text/csv";
            Response.ContentEncoding = System.Text.ASCIIEncoding.ASCII;
            StringBuilder content = new StringBuilder();
            StringWriter  writer  = new StringWriter(content);

            foreach (var book in books)
            {
                if (content.Length == 0)
                {
                    writer.WriteLine(book.ToPropertyNameList("ISBN Author Title Publisher Synopsis"));
                }
                writer.WriteLine(book.ToCSVString("ISBN Author Title Publisher Synopsis"));
            }

            return(File(new System.Text.UTF8Encoding().GetBytes(content.ToString()), "text/csv", "Library.csv"));
        }
Ejemplo n.º 24
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (!isBookDataValid())
            {
                return;
            }

            if (id > 0)
            {
                LibraryServiceClient lib = new LibraryServiceClient();

                if (lib.updateBook(bookFromForm()))
                {
                    MessageBox.Show("Książka edytowana poprawnie.", "Powiadomienie", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Książka nie została zaktualizowana", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                LibraryServiceClient lib = new LibraryServiceClient();

                if (lib.addBook(bookFromForm()))
                {
                    MessageBox.Show("Książka dodana poprawnie.", "Powiadomienie", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Książka nie została dodana", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Guzik odpowiadający za wyszukiwanie zaawansowane.
 /// </summary>
 protected void btnSzukanieZaawansowane_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         query             = txtSzukanyTekst.Text.ToString();
         ListView1.Visible = true;
         LibraryServiceClient lib = new LibraryServiceClient();
         Boolean titleDesc        = chbxSzukajWOpisie.Checked;
         String  authors          = txtAutor.Text.ToString();
         String  publisher        = txtWydawnictwo.Text.ToString();
         int     binding          = ddOprawa.SelectedIndex;
         int     pages            = -1;
         if (!String.IsNullOrWhiteSpace(txtIloscStron.Text.ToString()))
         {
             pages = Int32.Parse(txtIloscStron.Text.ToString());
         }
         int    pagesSearchType = ddIloscStron.SelectedIndex;
         String isbn            = txtISBN.Text.ToString();
         ListView1.DataSource = lib.searchBooksAdvanced(query, titleDesc, authors, publisher, binding, pages, pagesSearchType, isbn);
         ListView1.DataBind();
     }
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Guzik odpowiadający za logowanie użytkownika. Po walidacji danych przechowuje w sesji login użytkownika.
 /// Udane logowanie przekierowuje do panelu administracyjnego.
 /// </summary>
 protected void ButtonZaloguj_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(TextBoxLogin.Text) || string.IsNullOrWhiteSpace(TextBoxHaslo.Text))
     {
         LabelError.Text = "Wpisz login i hasło.";
         error.Visible   = true;
     }
     else
     {
         LibraryServiceClient lib   = new LibraryServiceClient();
         Boolean credentialsCorrect = lib.checkCredentials(TextBoxLogin.Text.ToString(), TextBoxHaslo.Text.ToString());
         if (credentialsCorrect)
         {
             Session["LOGIN"] = TextBoxLogin.Text;
             Response.Redirect("~/ACP.aspx");
         }
         else
         {
             LabelError.Text = "Błędne dane.";
             error.Visible   = true;
         }
     }
 }
Ejemplo n.º 27
0
        private static void Main(string[] args)
        {
            var client = new LibraryServiceClient();

            var journal = client.Get(3);

            PrintBookInfo(journal);

            var newBook = new Book
            {
                Id       = 4,
                Author   = "Пушкин А.С.",
                BookType = BookType.Tale,
                Name     = "Сказка о рыбаке и рыбке"
            };

            client.Add(newBook);

            var books = client.GetBooks("Пушкин А.С.");

            foreach (var book in books)
            {
                PrintBookInfo(book);
            }

            Console.WriteLine($"Количество книг в библиотеке: {client.GetBooksCount()}");

            Console.WriteLine("Клиент забрал журнал");
            client.Take(journal);
            Console.WriteLine($"Количество книг в библиотеке: {client.GetBooksCount()}");

            Console.WriteLine("Клиент вернул журнал");
            client.Return(journal);
            Console.WriteLine($"Количество книг в библиотеке: {client.GetBooksCount()}");

            Console.ReadLine();
        }
Ejemplo n.º 28
0
        private void btnAdvancedSearch_Click(object sender, EventArgs e)
        {
            LibraryServiceClient lib = new LibraryServiceClient();

            gvBooksList.Rows.Clear();
            String  query     = txtSearchQuery.Text.ToString();
            Boolean titleDesc = cbSearchBoth.Checked;
            String  authors   = txtSearchAuthor.Text.ToString();
            String  publisher = txtSearchPublisher.Text.ToString();
            int     binding   = cbSearchBinding.SelectedIndex;
            int     pages     = -1;

            if (nudSearchPages.Value > 0)
            {
                pages = (int)nudSearchPages.Value;
            }
            int    pagesSearchType = cbSearchPagesType.SelectedIndex;
            String isbn            = txtSearchISBN.Text.ToString();

            foreach (BookForListShort b in lib.searchBooksAdvanced(query, titleDesc, authors, publisher, binding, pages, pagesSearchType, isbn))
            {
                gvBooksList.Rows.Add(b.Id.ToString(), b.tytul.ToString());
            }
        }
Ejemplo n.º 29
0
 public static void Main()
 {
     LibraryServiceClient client = new LibraryServiceClient();
     int timesContain = client.Contains("asasas", "as");
     Console.WriteLine(timesContain);
 }
Ejemplo n.º 30
0
        public void Run()
        {
            try
            {
                using (EchoServiceClient proxy = new EchoServiceClient(_echoServiceEndpointName))
                {
                    string result = "";

                    result = proxy.Ping();
                    Console.WriteLine(string.Format("EchoService : {0}", result));
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                Trace.WriteLine(string.Format("!Note! : No endpoint listening at [{0}]", _echoServiceEndpointName));
            }

            using (LibraryServiceClient proxy = new LibraryServiceClient(_libraryServiceEndpointName))
            {
                Book book = null;

                Action prompt = new Action(() =>
                {
                    Console.WriteLine("LIST - Return a list of Books using the Search Pattern.");
                    Console.WriteLine("READ - Return a Book using the Key value.");
                    Console.WriteLine("Press ENTER to terminate.");
                });

                prompt();

                string        input = "";
                StringBuilder sb    = new StringBuilder();
                while ((input = Console.ReadLine().ToUpper()).Length > 0)
                {
                    try
                    {
                        string[] tokens = input.Split(' ');
                        switch ((tokens.Length) > 0 ? tokens[0] : "")
                        {
                        case "LIST":
                            Console.Write("Search Pattern : ");
                            string searchPattern = Console.ReadLine();
                            proxy.List(searchPattern, out books);

                            Stream stream = new MemoryStream();
                            EntitySerializationHelpers.SerializeBooks(books.ToList(), stream);
                            Console.WriteLine(stream.ContentsToString());

                            break;

                        case "LOAD":
                            Stream xstream = StreamFactory.Create(@"res://AppData.Books.xml");
                            Console.WriteLine(string.Format("Load = {0}", proxy.Load(xstream)));
                            break;

                        case "READ":
                            Console.Write("Key : ");
                            string key = Console.ReadLine();
                            if (proxy.Read(key, out book))
                            {
                                stream = new MemoryStream();
                                EntitySerializationHelpers.SerializeBook(book, stream);
                                Console.WriteLine(stream.ContentsToString());
                            }
                            else
                            {
                                Console.WriteLine(" *Not Found*");
                            }
                            break;

                        default:
                            prompt();
                            break;
                        }
                    }
                    catch (Exception exp)
                    {
                        Trace.WriteLine(string.Format("Error {0} : {1}", input, exp.Message));
                    }
                }
            }
        }
Ejemplo n.º 31
0
        public BookForListShort[] searchSimple(String text)
        {
            LibraryServiceClient lib = new LibraryServiceClient();

            return(lib.searchBooksSimple(text));
        }
Ejemplo n.º 32
0
        public BookForListLong[] getBooksList()
        {
            LibraryServiceClient lib = new LibraryServiceClient();

            return(lib.getBooksListLong());
        }