public string ExportExcelTemplate() { var tenantId = ApplicationContext.Current.TenantId; var userId = ApplicationContext.Current.UserId; var path = string.Empty; try { //设置Excel表头 var templateData = AppAccountService.Instance.GetTemplateStream(tenantId, userId); if (templateData.Length == 0) { //error AppConnectLogHelper.Error("生成模板失败,文件数据流为null"); return(path); } var dfsItem = new DfsItem("AppConnectFile", "人员信息模板表.xls", templateData, tenantId); var dfsPath = Dfs.Store(dfsItem); path = Dfs.ToDownloadUrl(dfsPath.ToString(), UrlSignDomain.Tms, userId); ApplicationContext.Current.Put(Const.BeisenContextXHasException, ExceptionType.UrlRedirect); ApplicationContext.Current.Put(Const.BeisenContextXExResultModel, new ResultModel { code = "302", message = "url redirect", param = path }); } catch (Exception ex) { AppConnectLogHelper.Error("生成模板失败", ex); } return(path); }
public static byte[] GetDataFromDfsItem(DfsItem item) { byte[] bytes = null; if (item != null) { if (item.IsStream) { bytes = new byte[item.Length]; int index = 0; while (index < item.Length) { int read = item.FileDataStream.Read(bytes, index, (int)(item.Length - index)); index += read; } } else { bytes = item.FileDataBytes; } } return(bytes); }
private int DfsStack(Dictionary<string, DfsItem> graph, DfsItem currentDfsItem, Stack<string> order, int size, HashSet<string> visited) { Stack<DfsItem> stack = new Stack<DfsItem>(); string addToStack; DfsItem dfsItem; stack.Push(currentDfsItem); while (stack.Count > 0) { addToStack = null; dfsItem = null; currentDfsItem = stack.Pop(); visited.Add(currentDfsItem.Key); foreach (var edge in currentDfsItem.GetEdges()) { if(!visited.Contains(edge)) { addToStack = edge; break; } } if (!string.IsNullOrEmpty(addToStack)) { stack.Push(currentDfsItem); if (graph.TryGetValue(addToStack, out dfsItem)) { stack.Push(dfsItem); } else { visited.Add(addToStack); size++; order.Push(addToStack); } } else { size++; order.Push(currentDfsItem.Key); } } return size; }