public bool RefreshSharedFilesInClient() { string lastError = string.Empty; string encryptFileList = string.Empty; sharedFileList.Clear(); bool retVal = WebAPIServices.GetFileList(ref encryptFileList, ref lastError); if (!retVal) { MessageBoxHelper.PrepToCenterMessageBoxOnForm(this); MessageBox.Show(lastError, "GetFileList", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } else { if (encryptFileList.Length > 0) { List <DRPolicy> decrypFileList = DigitalRightControl.DecryptStrToObject <List <DRPolicy> >(encryptFileList); sharedFileList.Clear(); foreach (DRPolicy drPolicy in decrypFileList) { sharedFileList.Add(drPolicy.EncryptionIV, drPolicy); } } InitShareFileListView(); } return(true); }
public bool GetSharedFileList() { string lastError = string.Empty; string encryptFileList = string.Empty; Dictionary <string, DRPolicy> shareList = new Dictionary <string, DRPolicy>(); //bool retVal = WebFormServices.GetFileList(AccountForm.accountName, AccountForm.password, ref encryptFileList, ref lastError); //if (!retVal) //{ // MessageBoxHelper.PrepToCenterMessageBoxOnForm(this); // MessageBox.Show(lastError, "GetFileList", MessageBoxButtons.OK, MessageBoxIcon.Error); // return false; //} //else { if (encryptFileList.Length > 0) { List <string> decrypFileList = DigitalRightControl.DecryptStrToObject <List <string> >(encryptFileList); foreach (string name in decrypFileList) { if (name.Length > 0) { //the extension of the file is the creation time. string creationTimeStr = Path.GetExtension(name).Substring(1); string fileName = Path.GetFileNameWithoutExtension(name); DRPolicy drPolicy = new DRPolicy(); drPolicy.FileName = fileName; drPolicy.CreationTime = long.Parse(creationTimeStr); drPolicy.ExpireTime = 0; shareList.Add(creationTimeStr, drPolicy); } } } sharedFileList = shareList; InitListView(); } return(true); }
private void button_EditSharedFile_Click(object sender, EventArgs e) { if (listView_SharedFiles.SelectedItems.Count != 1) { MessageBoxHelper.PrepToCenterMessageBoxOnForm(this); MessageBox.Show("Please select a file.", "Edit", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string creationTimeStr = (string)listView_SharedFiles.SelectedItems[0].Tag; if (sharedFileList.ContainsKey(creationTimeStr)) { DRPolicy drPolicy = sharedFileList[creationTimeStr]; if (drPolicy.ExpireTime == 0) { string fileName = drPolicy.FileName; long creationTime = drPolicy.CreationTime; string lastError = string.Empty; string encryptedDRPolicy = string.Empty; //bool retVal = WebFormServices.GetFileDRInfo(AccountForm.accountName, AccountForm.password, fileName, creationTime, ref encryptedDRPolicy, ref lastError); //if (!retVal) //{ // MessageBoxHelper.PrepToCenterMessageBoxOnForm(this); // MessageBox.Show("Get digital right information for file " + fileName + " failed with error:" + lastError, "GetFileDRInfo", MessageBoxButtons.OK, MessageBoxIcon.Error); // return; //} drPolicy = DigitalRightControl.DecryptStrToObject <DRPolicy>(encryptedDRPolicy); drPolicy.CreationTime = creationTime; sharedFileList[creationTimeStr] = drPolicy; } ShareFileForm shareFileForm = new ShareFileForm(drPolicy); shareFileForm.ShowDialog(); } }