public ShareFileItem findFile(ShareFileItem shareFileItem) { try { AHAItem foundItem = null; AHAClient ahaClient = new AHAClient(session); if (shareFileItem.FileInfo != null) { List <AHAItem> items = ahaClient.Search("&" + shareFileItem.FileInfo.Name); if (items.Count == 1) { foundItem = items[0]; } } if (foundItem == null) { if (shareFileItem.FileInfo != null) { if (!shareFileItem.FileInfo.Name.Equals(shareFileItem.Title)) { List <AHAItem> items = ahaClient.Search("&" + shareFileItem.Title); if (items.Count == 1) { foundItem = items[0]; } } } else { List <AHAItem> items = ahaClient.Search("&" + shareFileItem.Title); if (items.Count == 1) { foundItem = items[0]; } } } if (foundItem != null) { FileApi fileApi = new FileApi(session.GetApiClient()); ViewFileResult viewFileResult = fileApi.ViewFile(foundItem.Key); if (viewFileResult.Hdr.Rc == 0) { FileRecord fileRecord = viewFileResult.File; ShareFileItem newShareFileItem = new ShareFileItem(fileRecord.Name, fileRecord.Description); newShareFileItem.Key = fileRecord.Key; newShareFileItem.FileInfo = shareFileItem.FileInfo; newShareFileItem.SetIcon(shareFileItem.GetIcon()); newShareFileItem.Record = fileRecord; List <ShareSpace> itemSpaces = new List <ShareSpace>(); foreach (DisplayRecord spaceDisplayRecord in fileRecord.Destinations) { ShareSpace space = new ShareSpace(spaceDisplayRecord.Key, spaceDisplayRecord.DisplayName, null); itemSpaces.Add(space); } newShareFileItem.Spaces = itemSpaces; return(newShareFileItem); } else { return(null); } } else { return(null); } } catch (Exception ex) { throw new Exception("Error creating file", ex); } }
private void backgroundLoginWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Result is Exception) { Exception ex = e.Result as Exception; showStatus(ex.Message, STATUS_ERROR); Session = null; LoginForm loginForm = new LoginForm(); loginForm.Show(); } else { loggedUserDisplayName = e.Result as String; showStatus(String.Format(Properties.Resources.message_hi, loggedUserDisplayName), STATUS_INFO); textSearchAHA.Enabled = true; buttonSearch.Enabled = true; AhaClient = new AHAClient(Session); shareClient = new ShareClient(Session); contactClient = new ContactClient(Session); streamClient = new StreamClient(Session); notifMgr = new NotifierUIManager(Session); pushClient = new PushClient(Session); pushClient.OnReceiveMessage += OnPushReceiveMessage; pushClient.OnReceiveCount += OnPushReceiveCount; //toolStripStatusLabelPush.Text = "Connecting push..."; backgroundStartPushWorker.RunWorkerAsync(); //labelCross.Visible = true; //buttonMoreResults.Enabled = false; List <String> types = new List <String>(); if (checkBoxUsers.Checked) { types.Add(AHAClient.USER_TYPE); } if (checkBoxGroups.Checked) { types.Add(AHAClient.USERGROUP_TYPE); } if (checkBoxSpaces.Checked) { types.Add(AHAClient.HOTSPOT_TYPE); } if (checkBoxActivities.Checked) { types.Add(AHAClient.TASK_TYPE); types.Add(AHAClient.POST_TYPE); } //if (checkBoxContent.Checked) { // types.Add(AHAClient.FILE_TYPE); // types.Add(AHAClient.DOCUMENT_TYPE); //} //labelProgressAHA.Visible = true; //searchAhaWorkerInput = new SearchAHAWorkerInput(SearchAHAWorkerInput.CACHE, "", types); //backgroundAhaSearchWorker.RunWorkerAsync(searchAhaWorkerInput); //labelProgressStream.Visible = true; //searchStreamWorkerInput = new SearchStreamWorkerInput(SearchStreamWorkerInput.FIRST_PAGE, "", null); //backgroundStreamSearchWorker.RunWorkerAsync(searchStreamWorkerInput); //if (listViewShare.Items.Count == 0) { // List<ShareItem> shareItems = readFromShareCache(); // foreach (ShareItem item in shareItems) { // addShareItem(item); // } //} //if (listViewContacts.Items.Count == 0) { // List<ContactItem> contactItems = readFromContactsCache(); // foreach (ContactItem item in contactItems) { // addContactItem(item); // } //} } }