public ActionResult UploadFiles() { EntityNodeData nodeDatas = new EntityNodeData(); List <NodeData> nodes = new List <NodeData>(); List <NodeLink> linkNodes = new List <NodeLink>(); if (Request.Files.Count > 0) { HttpFileCollectionBase files = Request.Files; string filename = Path.GetFileName(Request.Files[0].FileName); HttpPostedFileBase file = files[0]; string fname; if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER") { string[] testfiles = file.FileName.Split(new char[] { '\\' }); fname = testfiles[testfiles.Length - 1]; } else { fname = file.FileName; } if ((file != null) && (file.ContentLength > 0) && !string.IsNullOrEmpty(file.FileName)) { string fileName = file.FileName; string fileContentType = file.ContentType; byte[] fileBytes = new byte[file.ContentLength]; var data = file.InputStream.Read(fileBytes, 0, Convert.ToInt32(file.ContentLength)); using (var package = new ExcelPackage(file.InputStream)) { var currentSheet = package.Workbook.Worksheets; string sheetName = Session["sheetName"].ToString(); ExcelWorksheet workSheet; if (sheetName == string.Empty) { workSheet = currentSheet.First(); } else { workSheet = currentSheet.Where(p => p.Name == sheetName).FirstOrDefault(); } var noOfCol = workSheet.Dimension.End.Column; var noOfRow = workSheet.Dimension.End.Row; string tableName; string columnName; string lookupTable; string LinkColumn; string LinkType; string pk; string toColumn; string datatype; string tableExp; string columnExp; string color; List <string> tables = new List <string>(); NodeData newNoteData = null; for (int rowIterator = 2; rowIterator <= noOfRow; rowIterator++) { tableExp = (workSheet.Cells[rowIterator, 1].Value == null) ? "" : workSheet.Cells[rowIterator, 1].Value.ToString(); tableName = ((workSheet.Cells[rowIterator, 2].Value == null) ? "" : workSheet.Cells[rowIterator, 2].Value.ToString()).ToUpper(); columnName = (workSheet.Cells[rowIterator, 3].Value == null) ? "" : workSheet.Cells[rowIterator, 3].Value.ToString(); columnExp = (workSheet.Cells[rowIterator, 4].Value == null) ? "" : workSheet.Cells[rowIterator, 4].Value.ToString(); datatype = (workSheet.Cells[rowIterator, 5].Value == null) ? "" : " (" + workSheet.Cells[rowIterator, 5].Value.ToString() + ") "; lookupTable = ((workSheet.Cells[rowIterator, 6].Value == null) ? "" : workSheet.Cells[rowIterator, 6].Value.ToString()).ToUpper(); LinkColumn = (workSheet.Cells[rowIterator, 7].Value == null) ? "" : workSheet.Cells[rowIterator, 7].Value.ToString(); toColumn = (workSheet.Cells[rowIterator, 8].Value == null) ? "" : workSheet.Cells[rowIterator, 8].Value.ToString(); LinkType = (workSheet.Cells[rowIterator, 9].Value == null) ? "" : workSheet.Cells[rowIterator, 9].Value.ToString(); pk = (workSheet.Cells[rowIterator, 10].Value == null) ? "" : workSheet.Cells[rowIterator, 10].Value.ToString(); //veriler excel'den alındı. İlgili tablolara atılması gerekiyor. if (tableName != string.Empty && !tables.Contains(tableName)) { newNoteData = new NodeData(); newNoteData.key = tableName; newNoteData.items = new List <NodeDataSubitems>(); tables.Add(tableName); nodes.Add(newNoteData); } if (tableName != string.Empty && tableExp != string.Empty) { NodeDataSubitems newNodeDataSubItem; newNodeDataSubItem = new NodeDataSubitems(tableExp, false, "Cube2", "Gray"); newNoteData.items.Add(newNodeDataSubItem); newNodeDataSubItem = new NodeDataSubitems(" ", false, "Cube2", "White"); newNoteData.items.Add(newNodeDataSubItem); } if (tableName != string.Empty) { if (pk == "true") { color = "yellow"; } else if (LinkColumn != string.Empty) { color = "blue"; } else { color = "white"; } NodeDataSubitems newNodeDataSubItem; newNodeDataSubItem = new NodeDataSubitems((pk == "true") ? columnName + datatype + " PK" + " " + columnExp : columnName + datatype + " " + columnExp, (pk == "true") ? true : false, (pk == "true" || color == "blue") ? "Cube1" : "Cylinder1", color); newNoteData.items.Add(newNodeDataSubItem); } if (lookupTable != string.Empty && LinkColumn != string.Empty) { string[] tmpType = null; if (LinkType != string.Empty) { tmpType = LinkType.Split('-'); } string toText = ""; string fromText = ""; if (tmpType != null && tmpType.Count() > 0) { toText = tmpType[1]; fromText = tmpType[0]; } NodeLink linkNode = new NodeLink(tableName, lookupTable, fromText + " " + columnName, toColumn + " " + toText); linkNodes.Add(linkNode); } } // for end } //using end nodeDatas.NodeDatas = nodes; nodeDatas.NodeLinks = linkNodes; }//if end } Session["UploadedEntity"] = nodeDatas; return(Content("")); }