private void okButton_Click(object sender, RoutedEventArgs e) { string newText = descriptionTextBox.Text; if (oldDescription.Text != newText) //Если данные менялись, регистрируем изменения на сервисе { using (LibraryClient libClient = new LibraryClient("BasicHttpBinding_ILibrary")) { Description description = new Description(); description.Id = oldDescription.Id; description.Text = newText; string result = libClient.EditDescription(description); if (result == "OK") { this.Close(); } else { MessageBox.Show(result, "Ошибка!"); } } } else { this.Close(); } }
public async Task <Tuple <bool, string> > Download(DownloadItem item) { Logger.Log("Adding item for downloading: ID: " + item.Id); var downloadItem = await LibraryClient.GetDownload(item.Id); Logger.Log("Item download requested from server"); if (downloadItem != null) { Logger.Log("Checking available storage"); var canStore = await canStoreOnDevice(downloadItem); Logger.Log("Available storage checked"); if (!canStore) { return(Tuple.Create(false, downloadItem.Url)); } item.Url = downloadItem.Url; item.Headers = downloadItem.Headers; downloadItem.FileName = item.FileName; await DownloadDb(downloadItem); return(Tuple.Create(true, item.Url)); } Logger.Log("ERROR: Failed to start downloading of item: ID: " + item.Id + ". FileName: " + item.FileName); return(Tuple.Create(true, string.Empty)); }
static void Main(string[] args) { LibraryClient cl = new LibraryClient(); Console.WriteLine(cl.GetStringData("100")); Console.WriteLine(cl.GetIntData(100)); Console.ReadKey(); }
// GET: Authors/Create public ActionResult Create() { LibraryClient lc = new LibraryClient(); ViewBag.listEmploymentStatus = lc.GetEmplyeeStatusIdNameMVCModel().Select(x => new SelectListItem { Value = x.NAME, Text = x.NAME }); return(View("Create")); }
static void Main(string[] args) { ILibraryCallback CallBackObject = new CallBackHost(); InstanceContext objContext = new InstanceContext(CallBackObject); LibraryClient cl = new LibraryClient(objContext); cl.UpdateData("Hi,Hello"); Console.WriteLine("Message Sent to Client"); Console.ReadKey(); }
public ActionResult Edit(int id) { LibraryClient lc = new LibraryClient(); Author author = new Author(); ViewBag.listEmploymentStatus = lc.GetEmplyeeStatusIdNameMVCModel().Select(x => new SelectListItem { Value = x.NAME, Text = x.NAME }); author = lc.GetAuthor(id); return(View("Edit", author)); }
public ActionResult Edit(int id) { LibraryClient lc = new LibraryClient(); Book book = new Book(); book = lc.GetBook(id); ViewBag.listAuthors = lc.GetAuthorsIdName().Select(x => new SelectListItem { Value = x.ID.ToString(), Text = x.NAME }); ViewBag.listEditions = lc.GetEditionIdNameMVCModel().Select(x => new SelectListItem { Value = x.NAME, Text = x.NAME }); return(View("Edit", book)); }
/// <summary> /// 根据检查套餐代码产生行 /// </summary> /// <param name="parentCrfSection">列表所在的CRF表</param> /// <param name="tableField">检查子项目列表字段</param> /// <param name="inspectionPackageCode">检查套餐代码</param> /// <returns></returns> public async Task <IEnumerable <CrfSection> > GenerateInspectionRows(CrfSection parentCrfSection, CrfField tableField, string inspectionPackageCode) { LibraryClient libClient = this.Account.CreateLibraryClient(); InspectionPackage package = await libClient.GetInspectionPackageByCode(inspectionPackageCode); if (package == null || string.IsNullOrEmpty(package.PackageCode)) { throw new ArgumentException("无效的检查套餐代码"); } var result = parentCrfSection.AddInpectionDetailRows(tableField, package); return(result); }
public DescriptionBlank(AddressClient adrClient) { InitializeComponent(); addressTextBox.Text = adrClient.Country + "\n" + adrClient.Region + "\n" + adrClient.City + "\n" + adrClient.Street + "\n" + adrClient.House; using (LibraryClient libClient = new LibraryClient("BasicHttpBinding_ILibrary")) //Получаем описание этого адреса { oldDescription.Text = libClient.ReadDescription(adrClient.Id); } oldDescription.Id = adrClient.Id; descriptionTextBox.Text = oldDescription.Text; }
public override int GetHashCode() { int hash = 1; if (LibraryClient.Length != 0) { hash ^= LibraryClient.GetHashCode(); } hash ^= Rpcs.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
static void Main(string[] args) { LibraryClient cl = new LibraryClient(); Patient p = new Patient(); p.ID = 1; p.Name = "Rameshkartik"; Console.WriteLine("Sending input to Service.."); Patient pOut = cl.PatientDetails(p); Console.WriteLine("Output Data"); Console.WriteLine("ID : " + pOut.ID.ToString()); Console.WriteLine("Name : " + pOut.Name); Console.ReadLine(); }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { this.InitializeComponent(); this.Suspending += OnSuspending; try { HockeyClient.Current.Configure("87334d12c9e34259817be32a66c6a767"); Assist = new Assistant(); LibraryClient = new LibraryClient(); SeatClient = new SeatClient(); GatewayClient = new GatewayClient(); AVClient.Initialize("vXdeiDEvPWNif2dvtCVc7Q1N-9Nh9j0Va", "CVlURpsG9thauLU2xUwnbuFi"); SavePC(); } catch { } }
static void Main(string[] args) { try { LibraryClient cl = new LibraryClient(); bool bValidate = cl.Validate("Ramesh", "RameshKartik"); if (bValidate) { Console.WriteLine("Key and Value are validate and approved"); } } catch (FaultException <ValidateKeyValue> fault) { Console.WriteLine(fault.Detail.Message); } Console.ReadKey(); }
static void Main(string[] args) { LibraryClient client = new LibraryClient(); for (int i = 0; i < 10; i++) { var book = new Book() { Idk__BackingField = i + 1, Authork__BackingField = "bee", Titlek__BackingField = "buu", Pricek__BackingField = (i + 1) * 10, Yeark__BackingField = 2010 }; client.AddBook(book); Console.WriteLine(client.AllBooks().Length); } Console.ReadLine(); }
private void UploadData() { List <AddressClient> addresses = new List <AddressClient>(); //Переписываем полученный List с сервиса в собственный класс клиента, так как напрямую полученный List не привязать, потому что полученный класс сериализован using (LibraryClient libClient = new LibraryClient("BasicHttpBinding_ILibrary")) //новый клиент сервиса foreach (Address adr in libClient.ReadAllLibrary()) //считываем данные об адресах из сервиса { AddressClient adrClient = new AddressClient(adr.Id, adr.Country, adr.Region, adr.City, adr.Street, adr.House); addresses.Add(adrClient); } if (addresses.Count > 0) { libraryDataGrid.ItemsSource = addresses; } else { MessageBox.Show("Данных в библиотеке нет"); } }
static void Main(string[] args) { var client = new LibraryClient(); client.AddBook(new Book { Id = 10, Title = "Harry Potter10", Author = "J.Rouling", Year = 2000, Type = BookType.Fiction }); Book book = client.GetBookById(0); Book[] books = client.GetBooksByAuthor("J.Rouling"); Book takenBook = client.GiveBook(0, 0); client.ReturnBook(0, 0); Console.Write("I'am client of Library"); Console.ReadLine(); }
// GET: Books/Create public ActionResult Create() { LibraryClient lc = new LibraryClient(); // NonStrongly Type //------------------------------------------ //Method 1 //ViewBag.listAuthors = new SelectList(lc.GetAuthorsIdName(), "ID", "NAME"); //Method 2 ViewBag.listAuthors = lc.GetAuthorsIdName().Select(x => new SelectListItem { Value = x.ID.ToString(), Text = x.NAME }); //------------------------------------------ // Strongly Type //------------------------------------------ /* * Book model = new Book * { * //Method 1 * Authors = new SelectList(lc.GetAuthorsIdName(), "ID", "NAME"); * //Method 2 * Authors = lc.GetAuthorsIdName().Select(x => new SelectListItem { Value = x.ID.ToString(), Text = x.NAME }) * }; * * return View(model); * //------------------------------------------ */ ViewBag.listEditions = lc.GetEditionIdNameMVCModel().Select(x => new SelectListItem { Value = x.NAME, Text = x.NAME }); return(View()); }
private void loginButton_Click(object sender, RoutedEventArgs e) { loginButton.IsEnabled = false; using (LibraryClient libClient = new LibraryClient("BasicHttpBinding_ILibrary")) //новый клиент сервиса { try { if (!string.Equals(libClient.TestConnection(), "OK", StringComparison.InvariantCultureIgnoreCase)) { throw new Exception("Попытка соединения не удалась"); } labelConnectionStatus.Content = "Соединение успешно\nПроверка данных"; if (libClient.UserNameValidator(loginBox.Text, MD5Hash(passwordBox.Password))) { labelConnectionStatus.Content = "УСПЕШНО!\nДобро пожаловать, " + loginBox.Text; Library lib = new Library(); lib.Show(); this.Close(); } else { throw new Exception("Проверьте правильность введенных данных!"); } } catch (Exception ex) { // выводим информацию об ошибке labelConnectionStatus.Content = "Ошибка: " + ex.Message; loginBox.Text = MD5Hash(passwordBox.Password); } } loginButton.IsEnabled = true; }
public BooksService(LibraryClient libraryClient) { this.libraryClient = libraryClient; }
private async Task getItems(bool cloudItemsOnly = false) { if (!cloudItemsOnly) { await getLocalItems(); } else { await updateLocalItems(); } var collection = await LibraryClient.Get(); if (collection?.Entries != null) { if (CloudItems == null) { CloudItems = new ObservableCollection <LibraryItem>(); } var entries = new ObservableCollection <LibraryItem>(collection.Entries); switch (librarySort) { case LibrarySort.Alphabetical: await entries.SortByTitle(); break; case LibrarySort.Recent: await entries.SortByDate(); break; } var newItems = await CloudItems.UpdateItems(entries); if (Account != null && Account.SignedIn && Account.UserInfo != null && !string.IsNullOrEmpty(Account.UserInfo.Email)) { var cloud = CloudItems.ToList(); var email = Account.UserInfo.Email.ToLower(); if (!SharedSettingsService.Instance.GetBoolValue("AutoDownloadDBCreated" + email)) { SharedSettingsService.Instance.SetBoolValue("AutoDownloadDBCreated" + email, true); foreach (var cloudItem in cloud) { LocalLibraryService.Instance.CreateCloudItemId(cloudItem.ID, Account.UserInfo.Email); } } else { foreach (var cloudItem in newItems) { if ( !LocalLibraryService.Instance.IsItemAddedForDownload(cloudItem.ID, Account.UserInfo.Email)) { LocalLibraryService.Instance.CreateCloudItemId(cloudItem.ID, Account.UserInfo.Email); if (AutoDownload) { LoggerService.Instance.Log("Library.getItems: Found new item for download: ID: " + cloudItem.ID); await DownloadItem(cloudItem, false); } } } } } } if (LocalItems != null && CloudItems != null) { var local = LocalItems.ToList(); var cloud = CloudItems.ToList(); foreach (var localItem in local) { var cloudItemForLocalItem = cloud.FirstOrDefault( item => item.ID == localItem.ID && localItem.Storage == LibraryItemStorage.AppLocal); if (cloudItemForLocalItem != null) { cloudItemForLocalItem.LocalItem = localItem; if (cloudItemForLocalItem.DownloadStatus != DownloadStatus.Downloading) { cloudItemForLocalItem.DownloadStatus = DownloadStatus.Completed; } } } } await sort(librarySort); OnPropertyChanged(nameof(CloudItemsCount)); }
private async Task <bool> delete(LibraryItem item) { if (item == null || item.Storage == LibraryItemStorage.iTunes) { return(false); } LoggerService.Instance.Log("INFO: Library.delete: ID: " + item.ID); if (item.IsLocal) { if (item.Storage == LibraryItemStorage.AppLocal) { var deleted = LocalLibraryService.Instance.DeleteMediaItem(item, true); if (deleted) { if (CloudItems != null) { var deletedItem = CloudItems.FirstOrDefault(cloudItem => item.ID == cloudItem.ID); if (deletedItem != null) { deletedItem.DownloadStatus = DownloadStatus.Unknown; deletedItem.LocalItem = null; } } if (LocalItems != null) { LocalItems.Remove(item); OnPropertyChanged(nameof(LocalItemsCount)); } if (item.Equals(SelectedItem)) { SelectedItem = null; } if (item.Equals(SelectedLibraryItem)) { SelectedLibraryItem = null; } return(true); } } } else { var response = await LibraryClient.Delete(item.ID); if (response != null && response.Success) { if (Account != null && Account.SignedIn && Account.UserInfo != null && !string.IsNullOrEmpty(Account.UserInfo.Email)) { LocalLibraryService.Instance.DeleteCloudItemId(item.ID, Account.UserInfo.Email); } CloudItems.Remove(item); OnPropertyChanged(nameof(CloudItemsCount)); if (item.Equals(SelectedItem)) { SelectedItem = null; } if (item.Equals(SelectedCloudItem)) { SelectedCloudItem = null; } return(true); } } return(false); }
/// <summary> /// 创建知识库管理客户端 /// </summary> /// <returns></returns> public LibraryClient CreateLibraryClient() { LibraryClient client = new LibraryClient(this); return(client); }
public async Task <Tuple <bool, string> > Download(DownloadItem item) { Logger.Log("Adding item for downloading: ID: " + item.Id); var downloadItem = await LibraryClient.GetDownload(item.Id); Logger.Log("Item download requested from server"); if (downloadItem != null) { Logger.Log("Checking available storage"); var canStore = await canStoreOnDevice(downloadItem); Logger.Log("Available storage checked"); if (!canStore) { return(Tuple.Create(false, downloadItem.Url)); } item.Url = downloadItem.Url; item.Headers = downloadItem.Headers; using (var url = NSUrl.FromString(item.Url)) using (var request = new NSMutableUrlRequest(url)) { List <NSHttpCookie> cookies = new List <NSHttpCookie>(); foreach (var header in item.Headers) { cookies.Add(new NSHttpCookie(header.Key, header.Value)); } request.Headers = NSHttpCookie.RequestHeaderFieldsWithCookies(cookies.ToArray()); DownloadSessionMetadata.SaveDownloadItem(item); if ((RestService.Instance.User != null) && !string.IsNullOrEmpty(RestService.Instance.User.Email)) { LocalLibraryService.Instance.CreateCloudItemId(item.Id, RestService.Instance.User.Email); } CreateSession(sessionID); lock (syncRoot) { if (session != null) { var task = session.CreateDownloadTask(request); task.Resume(); } else { Logger.Log("ERROR: Failed to start downloading because session is NULL"); } } Logger.Log("Item added to the download queue: ID: " + item.Id + " FileName: " + item.FileName + " URL:" + item.Url); return(Tuple.Create(true, item.Url)); } } else { Logger.Log("ERROR: Failed to start downloading of item: ID: " + item.Id + ". FileName: " + item.FileName); } return(Tuple.Create(true, string.Empty)); }
public LibraryTest() { Client = new LibraryClient(); }