private void btnUpload_Click(object sender, EventArgs e) { FileTreeNode file = null; //针对直接上传图片,却选择的是微博类型的情况做的特殊处理。 do { if (strUploadPath.Substring(strUploadPath.LastIndexOf('.') + 1).ToLower() == "jpg") { if (cbFileKind.Text == "Weibo") { file = BLLControl.UploadFile(strUploadPath, fileID, txtFileInfo.Text, ContentKind.Picture, "VssDisk"); break; } } //正常情况 file = BLLControl.UploadFile(strUploadPath, fileID, txtFileInfo.Text, (ContentKind)(cbFileKind.SelectedIndex + 1), "VssDisk"); break; }while (true); //如果是上传不是替换 if (fileID == "") { UIController.AddNode(file); } else { UIController.ReplaceNodeByFileID(fileID, null, file); } //如果上传的是一张图片 if (strUploadPath.Substring(strUploadPath.LastIndexOf('.') + 1).ToLower() == "jpg") { if (cbFileKind.Text == "Weibo") { BlogMsg blog = new BlogMsg(); blog.strUin = BLLControl.GetValidator().VssID; blog.strFromClient = BLLControl.GetValidator().AppID; blog.strObjPicUrl = file.FileID; blog.strMsgID = ""; blog.strNickName = ""; blog.strContent = ""; DateTime dt = DateTime.Now; blog.strWriteDate = dt.Year + "年" + dt.Month + "月" + dt.Day + "日 " + dt.Hour + ":" + dt.Minute + ":" + dt.Second; blog.strObjKind = "None"; blog.imgHeadSrc = ""; file = BLLControl.UploadTextFile(JsonConvert.SerializeObject(blog), strUploadPath.Substring(strUploadPath.LastIndexOf("\\") + 1), "", txtFileInfo.Text, (ContentKind)(cbFileKind.SelectedIndex + 1), "VssDisk"); blog.strMsgID = file.FileID; file = BLLControl.UploadTextFile(JsonConvert.SerializeObject(blog), strUploadPath.Substring(strUploadPath.LastIndexOf("\\") + 1), file.FileID, txtFileInfo.Text, (ContentKind)(cbFileKind.SelectedIndex + 1), "VssDisk"); UIController.AddNode(file); } } this.Close(); }
/// <summary> /// 增加新朋友 /// </summary> public static void AddFriend() { string friID = Interaction.InputBox("Input his/her VSSID please:"); if (friID == "" || friID == BLLControl.GetValidator().VssID) { return; } List <string> friList = new List <string>(); friList.Add(friID); BLLControl.AddFocus(friList); }
/// <summary> /// 初始化所有UI组件 /// </summary> /// <param name="treeNode"></param> /// <param name="listView"></param> /// <param name="listTextbox"></param> /// <param name="richTextBox"></param> public static void InitUIController(ref TreeView treeView, ref ListView listView, ref List <TextBox> listTextbox, ref RichTextBox richTextBox, Main frmMain) { MainLink = frmMain; uiTreeNode = treeView; uiListView = listView; uiListTextBox = listTextbox; uiRichTextBox = richTextBox; uiStackFileTreeNode = new Stack <FileTreeNode>(); uiGoForwardFileTreeNode = new Stack <FileTreeNode>(); //设置几个UI相关的数据 frmMain.tslUser.Text = BLLControl.GetValidator().VssID; }
/// <summary> /// 填充信息 /// </summary> /// <param name="listFriPub"></param> /// <param name="listFriPro"></param> /// <param name="listMyPub"></param> public static void FillProvideMessage(ref ListBox listFriPub, ref ListBox listFriPro, ref ListBox listMyPub) { //先填充自己的公布 List <TMessages> list = BLLControl.GetPublishMessage(new List <string>() { BLLControl.GetValidator().VssID }, 500); listMyPub.Items.Clear(); foreach (TMessages msg in list) { DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddSeconds(msg.ProvideTime); string sItem = dtStart.ToShortDateString() + " " + dtStart.ToShortTimeString() + " From App : " + msg.FromApp; sItem += " Publish A File : [ " + msg.FileOject.FileId + " ]"; sItem += " Size : " + msg.FileOject.FileSize + " Kind : " + msg.FileOject.FileKind.ToString(); listMyPub.Items.Add(sItem); } //找自己关注的人列表,然后拉取他们的公开发布。 List <string> listFriend = BLLControl.GetFocusList(); if (listFriend.Count != 0) { list = BLLControl.GetPublishMessage(listFriend, 500); listFriPub.Items.Clear(); foreach (TMessages msg in list) { DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddSeconds(msg.ProvideTime); string sItem = dtStart.ToShortDateString() + " " + dtStart.ToShortTimeString() + " From App : " + msg.FromApp; sItem += " Publish A File : [ " + msg.FileOject.FileId + " ]"; sItem += " Size : " + msg.FileOject.FileSize + " Kind : " + msg.FileOject.FileKind.ToString(); listFriPub.Items.Add(sItem); } } //找别人单独授权我的列表 list = BLLControl.GetProvideMessage(500); listFriPro.Items.Clear(); foreach (TMessages msg in list) { DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddSeconds(msg.ProvideTime); string sItem = dtStart.ToShortDateString() + " " + dtStart.ToShortTimeString() + " From App : " + msg.FromApp; sItem += " Publish A File : [ " + msg.FileOject.FileId + " ]"; sItem += " Size : " + msg.FileOject.FileSize + " Kind : " + msg.FileOject.FileKind.ToString(); listFriPro.Items.Add(sItem); } }
private void replaceToolStripMenuItem_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count == 0) { return; } FileTreeNode file = (FileTreeNode)listView1.SelectedItems[0].Tag; if (file.FileOwner != BLLControl.GetValidator().VssID) { MessageBox.Show("This File is not belong to you ! So you can not Destory it !"); return; } DialogResult dialogResult = MessageBox.Show("If you replace the FILE by what you upload later. All the functions which rely on the File will change. Do you stil want to Replace it?", "Replace Alarm", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { UIController.Upload(file.FileID); } }
private void Destory() { if (listView1.SelectedItems.Count == 0) { return; } FileTreeNode file = (FileTreeNode)listView1.SelectedItems[0].Tag; if (file.FileOwner != BLLControl.GetValidator().VssID) { MessageBox.Show("This File is not belong to you ! You have no permission to dispose it !"); return; } DialogResult dialogResult = MessageBox.Show("If you dispose the file, all links to this file will lost! Continue ?", "Alarm", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { UIController.DestroyNode(file); UIController.DeleteNodeByFileID(file.FileID); } }
public static void FillFileTreeByTimerLoadingMessage(ref TreeView treeView) { //先填充自己的公布 List <TMessages> list = BLLControl.GetPublishMessage(new List <string>() { BLLControl.GetValidator().VssID }, 500); List <TMessages> provideItems = BLLControl.GetProvideItems(500); list.AddRange(provideItems); TreeNode theTreeNode = treeView.Nodes[1]; PublishFolder.SubNodes.Clear(); foreach (TMessages msg in list) { PublishFolder.SubNodes.Add(CreateTreeNodeByMessage(msg)); } //验证数据是否变化,再确定是否替换。 bool needRefresh = true; if (tempPublishFolder != null) { if (CompareFileTreeNode(tempPublishFolder, PublishFolder)) { needRefresh = false; } } if (needRefresh) { theTreeNode.Nodes.Clear(); SetTreeNodeByObject(ref theTreeNode, PublishFolder); tempPublishFolder = (FileTreeNode)PublishFolder.Clone(); } //填充收听表 Dictionary <string, List <TMessages> > dictMsg; List <string> friList = BLLControl.GetFocusList(); if (friList.Count != 0) { list = BLLControl.GetPublishMessage(friList, 500); dictMsg = new Dictionary <string, List <TMessages> >(); foreach (TMessages msg in list) { if (!dictMsg.ContainsKey(msg.FromVssId)) { dictMsg.Add(msg.FromVssId, new List <TMessages>()); } dictMsg[msg.FromVssId].Add(msg); } theTreeNode = treeView.Nodes[2]; FocusFolder.SubNodes.Clear(); foreach (string key in dictMsg.Keys) { FileTreeNode folder = new FileTreeNode(); folder.SubNodes = new List <FileTreeNode>(); folder.FileID = "0"; folder.FileKind = ContentKind.Folder; folder.FileInfo = key + "'s Folder"; folder.FileSize = 0; folder.FromApp = "Vss"; folder.NodeName = key; folder.SubNodes = new List <FileTreeNode>(); foreach (TMessages msg in dictMsg[key]) { folder.SubNodes.Add(CreateTreeNodeByMessage(msg)); } FocusFolder.SubNodes.Add(folder); } //验证数据是否变化,再确定是否替换。 needRefresh = true; if (tempFocusFolder != null) { if (CompareFileTreeNode(tempFocusFolder, FocusFolder)) { needRefresh = false; } } if (needRefresh) { theTreeNode.Nodes.Clear(); SetTreeNodeByObject(ref theTreeNode, FocusFolder); tempFocusFolder = (FileTreeNode)FocusFolder.Clone(); } } //下面填充我Receive的列表 list = BLLControl.GetProvideMessage(500); dictMsg = new Dictionary <string, List <TMessages> >(); foreach (TMessages msg in list) { if (!dictMsg.ContainsKey(msg.FromVssId)) { dictMsg.Add(msg.FromVssId, new List <TMessages>()); } dictMsg[msg.FromVssId].Add(msg); } theTreeNode = treeView.Nodes[3]; ReceiveFolder.SubNodes.Clear(); foreach (string key in dictMsg.Keys) { FileTreeNode folder = new FileTreeNode(); folder.SubNodes = new List <FileTreeNode>(); folder.FileID = "0"; folder.FileKind = ContentKind.Folder; folder.FileInfo = key + "'s Folder"; folder.FileSize = 0; folder.FromApp = "Vss"; folder.NodeName = key; folder.SubNodes = new List <FileTreeNode>(); foreach (TMessages msg in dictMsg[key]) { folder.SubNodes.Add(CreateTreeNodeByMessage(msg)); } ReceiveFolder.SubNodes.Add(folder); } //验证数据是否变化,再确定是否替换。 needRefresh = true; if (tempReceiveFolder != null) { if (CompareFileTreeNode(tempReceiveFolder, ReceiveFolder)) { needRefresh = false; } } if (needRefresh) { theTreeNode.Nodes.Clear(); SetTreeNodeByObject(ref theTreeNode, ReceiveFolder); tempReceiveFolder = (FileTreeNode)ReceiveFolder.Clone(); } }