/// <summary> /// 获取uri地址 /// </summary> /// <param name="Item"></param> protected void GetItemUri(SpaceListViewItem Item) { try { if (Item.BookType == Common.BookType.File && Item.Self_File != null) { if (string.IsNullOrEmpty(Item.Uri)) { string parameters = SpaceHelper.GetParameters(this.SpaceType, SpaceCodeEnterEntity.DisplayItem, Item.Self_File.ID); ModelManage.Space_Service.Function_Invoke(SpaceCodeEnterEntity.DisplayItem, parameters, SpaceCodeEnterEntity.LoginUserName, SpaceCodeEnterEntity.WebLoginPassword, SpaceCodeEnterEntity.UserDomain, new Action <Dictionary <string, object> >((dicResult) => { SPItemEntity sPItemEntity = JsonManage.DictionaryToEntity <SPItemEntity>(dicResult, ','); string uri = SpaceCodeEnterEntity.SPSiteAddressFront + sPItemEntity.FileRef; //跨线程(异步委托) this.Dispatcher.BeginInvoke(new Action(() => { Item.Self_File.ServerRelativeUrl = uri; Item.Uri = uri; })); })); } } } catch (Exception ex) { LogManage.WriteLog(this.GetType(), ex); } finally { } }
/// <summary> /// 打开文件(包括文件夹) /// </summary> /// <param name="spaceListViewItem"></param> protected void book_OpenFileEvent(SpaceListViewItem spaceListViewItem, Action <string, int, string> compleateCallBack) { try { switch (spaceListViewItem.BookType) { case BookType.File: if (spaceListViewItem.Self_File != null) { if (string.IsNullOrEmpty(spaceListViewItem.Uri)) { string parameters = SpaceHelper.GetParameters(this.SpaceType, SpaceCodeEnterEntity.DisplayItem, spaceListViewItem.Self_File.ID); ModelManage.Space_Service.Function_Invoke(SpaceCodeEnterEntity.DisplayItem, parameters, SpaceCodeEnterEntity.LoginUserName, SpaceCodeEnterEntity.WebLoginPassword, SpaceCodeEnterEntity.UserDomain, new Action <Dictionary <string, object> >((dicResult) => { SPItemEntity sPItemEntity = JsonManage.DictionaryToEntity <SPItemEntity>(dicResult, ','); string uri = SpaceCodeEnterEntity.SPSiteAddressFront + sPItemEntity.FileRef; //跨线程(异步委托) this.Dispatcher.BeginInvoke(new Action(() => { spaceListViewItem.Self_File.ServerRelativeUrl = uri; spaceListViewItem.Uri = uri; //根据文件的类型使用相应的方式打开 SpaceCodeEnterEntity.fileOpenManage.FileOpenByExtension((fileType)spaceListViewItem.FileType, spaceListViewItem.Uri); })); })); } else { //根据文件的类型使用相应的方式打开 SpaceCodeEnterEntity.fileOpenManage.FileOpenByExtension((fileType)spaceListViewItem.FileType, spaceListViewItem.Uri); } } break; case BookType.Folder: //打开文件夹 this.FolderOpen(spaceListViewItem, compleateCallBack); break; default: break; } } catch (Exception ex) { LogManage.WriteLog(this.GetType(), ex); } }
/// <summary> /// 生成文件 /// </summary> private void DataLoad_File(SPItemEntity sPVirtualFile) { try { //等待提示 //this.ShowTip(); SPVirtualFile file = new SPVirtualFile() { ID = Convert.ToInt32(sPVirtualFile.ID), Name = sPVirtualFile.LinkFilename, }; long length; bool isSuccessed = long.TryParse(sPVirtualFile.FileSizeDisplay, out length); if (isSuccessed) { file.Length = length; } //文件类型 fileType file_Type = default(fileType); if (file.Name.Contains(".")) { //文件类型 string extention = IOPath.GetExtension(file.Name); //去掉点 extention = extention.Replace(".", string.Empty); //文件名称 string fileName = IOPath.GetFileNameWithoutExtension(file.Name); //转换为枚举 Enum.TryParse(extention, true, out file_Type); //图片 string imageUri = null; imageUri = SpaceCodeEnterEntity.extetionImageFolderName + extention + SpaceCodeEnterEntity.pictureExtension; string imageUri_Small = null; imageUri_Small = SpaceCodeEnterEntity.extetionImageFolderName_Small + extention + SpaceCodeEnterEntity.pictureExtension; SpaceListViewItem listViewItem = new SpaceListViewItem(imageUri, ViewType) { Title = fileName, SpaceType = this.SpaceType, BookType = BookType.File, FileType = file_Type, Self_File = file, ParentView = this.listView, }; listViewItem.SetSmallImg(imageUri_Small); listViewItem.SizeDisplay = FileManage.GetFileSize_MB_KB_Display(file.Length); DateTime dateTime; bool isSuccessed_1 = DateTime.TryParse(sPVirtualFile.Modified, out dateTime); if (isSuccessed_1) { listViewItem.UpdateTime = dateTime; } //添加书 this.ItemsAdd(listViewItem); } } catch (Exception ex) { LogManage.WriteLog(this.GetType(), ex); } finally { } }