public ActionResult ShowSearchMenu() { LoginUsers UserData = LI.GetLoginUserInfo(""); MyLastAction myla = LI.GetUserCurrentAction(""); string sTableName = UserData.CompanyName.ToString().Trim().ToUpper().Replace(" ", "_") + "_LevelInfos"; if (myla.Oper == "LV") { sTableName = UserData.CompanyName.ToString().Trim().ToUpper().Replace(" ", "_") + "_LegalInfos"; } int Version = Convert.ToInt32(myla.Version); var UFH = (from ufh in db.UploadFilesHeaders where ufh.VersionNo == Version select ufh).FirstOrDefault(); DataTable ShowTable = null; if (UFH != null) { Common ComClass = new Common(); ShowTable = ComClass.SQLReturnDataTable("SELECT LEVEL_ID," + UFH.ExcelDownLoadFields + " FROM " + "[" + sTableName + "]"); } if (ShowTable == null) { ShowTable = new DataTable(); ShowTable.Columns.Add("Dummy", typeof(string)); DataRow dr = ShowTable.NewRow(); dr["Dummy"] = "None"; ShowTable.Rows.Add(dr); } return(PartialView("ShowSearchMenu", ShowTable));; }
private MyLastAction GetUserCurrentAction() { var UCA = (from uca in db.UserLastActions where uca.UserId == UserData.UserName select uca).FirstOrDefault(); MyLastAction viewModel = new MyLastAction(); if (UCA == null) { UserLastActions uca = new UserLastActions(); uca.Company = UserData.CompanyName; uca.KeyDate = "2018/07/11"; uca.UserId = UserData.UserName; uca.Version = "1"; uca.UsedView = "Normal"; uca.Oper = "OV"; uca.Levels = "One"; uca.ShowLevel = "101212"; uca.Country = ""; uca.Role = "User"; db.UserLastActions.Add(uca); db.SaveChanges(); viewModel.ShowLevel = "101212"; viewModel.KeyDate = "2018/07/11"; viewModel.Levels = "One"; viewModel.Version = "1"; viewModel.Oper = "OV"; viewModel.View = "Normal"; viewModel.Country = ""; viewModel.Role = "User"; } else { viewModel.KeyDate = UCA.KeyDate; viewModel.ShowLevel = UCA.ShowLevel; viewModel.Levels = UCA.Levels; viewModel.Version = UCA.Version; viewModel.Oper = UCA.Oper; viewModel.View = UCA.UsedView; viewModel.Country = UCA.Country; viewModel.Role = UCA.Role; } return(viewModel); }
public ActionResult Index() { MyLastAction myla = GetUserCurrentAction(); var viewModel = new MyModel { UseDate = DateTime.Now, KeyDate = myla.KeyDate, ShowLevel = myla.ShowLevel, Levels = myla.Levels, Version = myla.Version, Oper = myla.Oper, View = myla.View, Country = myla.Country, ChartData = GetOrgChartData(myla.Role, myla.Country, myla.ShowLevel, myla.Levels, myla.Oper, myla.Version), Role = myla.Role }; return(View(viewModel)); }
public ActionResult UpdateTable() { int iShowCount = 0, iNullCount = 0, iKey = 0; List <string> lstParentName = new List <string>(); List <dynamic> lstDynamic = new List <dynamic>(); var UploadExcelFile = (from uef in db.UploadFiles where uef.CompanyName == UserData.CompanyName select uef).OrderByDescending(x => x.CreatedDate).FirstOrDefault(); string ServerMapPath = System.Web.HttpContext.Current.Server.MapPath("~/App_Data/Uploads/" + UploadExcelFile.JSONFileName); using (StreamReader reader = new StreamReader(ServerMapPath)) { string SUP_DISPLAY_NAME = UploadExcelFile.ParentField; string RNUM = UploadExcelFile.FirstPositionField; string SNUM = ""; string jsonData = reader.ReadToEnd(); dynamic array = JsonConvert.DeserializeObject(jsonData); foreach (var item in array.data) { if (item[SUP_DISPLAY_NAME] != null) { iShowCount++; } if (item[SUP_DISPLAY_NAME] == null) { iNullCount++; } if (UploadExcelFile.SerialNoFlag == "Y") { SNUM = (100000 + Convert.ToInt32(item[RNUM])).ToString(); } else { SNUM = (100000 + iKey++).ToString(); } if (item[SUP_DISPLAY_NAME] != null) { if (lstParentName.Count() >= 1) { var match = lstParentName.FirstOrDefault(stringToCheck => stringToCheck.Contains(item[SUP_DISPLAY_NAME].ToString().Trim())); if (match == null) { lstParentName.Add(item[SUP_DISPLAY_NAME].ToString().Trim()); } } else { lstParentName.Add(item[SUP_DISPLAY_NAME].ToString().Trim()); } } // Employee Details if (UploadExcelFile.UseFields != "") { string FULL_NAME = ""; if (UploadExcelFile.FullNameFields != "") { string[] FN = UploadExcelFile.FullNameFields.Split(','); foreach (string strFN in FN) { FULL_NAME += " " + item[strFN]; } } dynamic DyObj = new ExpandoObject(); string[] UF = UploadExcelFile.UseFields.Split(','); foreach (string strUF in UF) { string strField = strUF.Trim().ToUpper().Replace(" ", "_"); if (strField == "LEVEL_ID") { AddProperty(DyObj, strField, SNUM); } else if (strField == "PARENT_LEVEL_ID") { AddProperty(DyObj, strField, "999999"); } else if (strField == "VERSION") { AddProperty(DyObj, strField, "1"); } else if (strField == "FULL_NAME") { AddProperty(DyObj, strField, (FULL_NAME == "") ? "" : FULL_NAME.Substring(1)); } else if (strField == "DATE_UPDATED") { AddProperty(DyObj, strField, DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss")); } else if (strField == "USER_ID") { AddProperty(DyObj, strField, UserData.CompanyName); } else { AddProperty(DyObj, strField, ((item[strUF] == null)?"":item[strUF])); } } lstDynamic.Add(DyObj); } } // Gets the Parent name int Index = 0; foreach (string pn in lstParentName) { ExpandoObject ObjId = lstDynamic.Where(Obj => Obj.FULL_NAME == pn).FirstOrDefault(); if (ObjId != null) { var expandoLEVEL_ID = (IDictionary <string, object>)ObjId; Index++; var Objects = lstDynamic.Where(Obj => Obj.SUP_DISPLAY_NAME == pn).ToList(); foreach (ExpandoObject md in Objects) { var expandoPARENT_ID = (IDictionary <string, object>)md; expandoPARENT_ID["PARENT_LEVEL_ID"] = expandoLEVEL_ID["LEVEL_ID"].ToString(); } } } } // Insert the data into SQL table InsertDynamicDataToDB(lstDynamic); MyLastAction myla = GetUserCurrentAction(); var viewModel = new MyModel { UseDate = DateTime.Now, ShowLevel = myla.ShowLevel, Levels = myla.Levels, Version = myla.Version, Oper = myla.Oper, View = myla.View, Country = myla.Country, ChartData = GetOrgChartData(myla.Role, myla.Country, myla.ShowLevel, myla.Levels, myla.Oper, myla.Version), Role = myla.Role }; return(View("Index", viewModel)); }
public ActionResult VersionControl(string VersionControl, string Oper, string Version, string ChartData) { if (VersionControl == "DownloadVersion") { var UploadExcelFile = (from uef in db.UploadFiles where uef.CompanyName == UserData.CompanyName && uef.UserId == UserData.UserName select uef).OrderByDescending(x => x.CreatedDate).FirstOrDefault(); string ServerMapPath = System.Web.HttpContext.Current.Server.MapPath("~/App_Data/Upload/" + UploadExcelFile.JSONFileName); var filePath = new FileInfo(ServerMapPath); using (ExcelPackage workbook = new ExcelPackage(filePath)) { // Generate a new unique identifier against which the file can be stored string handle = Guid.NewGuid().ToString(); using (MemoryStream memoryStream = new MemoryStream()) { workbook.SaveAs(memoryStream); memoryStream.Position = 0; TempData[handle] = memoryStream.ToArray(); } // Note we are returning a filename as well as the handle return(new JsonResult() { Data = new { FileGuid = handle, FileName = "TestReportOutput.xlsx" } }); } } else if (VersionControl == "SaveVersion") { var UploadExcelFile = (from uef in db.UploadFiles where uef.CompanyName == UserData.CompanyName select uef).OrderByDescending(x => x.CreatedDate).FirstOrDefault(); string ServerMapPath = System.Web.HttpContext.Current.Server.MapPath("~/App_Data/Download/" + UploadExcelFile.JSONFileName); using (StreamReader reader = new StreamReader(ServerMapPath)) { string jsonData = reader.ReadToEnd(); dynamic lstDynamic = JsonConvert.DeserializeObject(jsonData); foreach (var item in lstDynamic.data) { } } } MyLastAction myla = GetUserCurrentAction(); var viewModel = new MyModel { UseDate = DateTime.Now, ShowLevel = myla.ShowLevel, Levels = myla.Levels, Version = myla.Version, Oper = myla.Oper, View = myla.View, Country = myla.Country, ChartData = GetOrgChartData(myla.Role, myla.Country, myla.ShowLevel, myla.Levels, myla.Oper, myla.Version), Role = myla.Role }; return(View("Index", viewModel)); }
public ActionResult Index(string Search) { string Security = "No", Refresh = "No"; string[] AssignedView = LI.GetUserRoles().Split(','); if (AssignedView[0] == "NoUser") { return(RedirectToAction("NotAuthorizedPage", "Version")); } if (Array.IndexOf(AssignedView, "User") != -1) { Security = "Yes"; } if (Search == "Refresh") { Refresh = "Yes"; Search = null; } MyLastAction myla = LI.GetUserCurrentAction("User", Search); int VersionNumber = myla.Version == "" ? 0 : Convert.ToInt32(myla.Version); DataTable ShowGridTable = new DataTable(); ShowGridTable.Columns.Add("Upload", typeof(string)); DataRow dr = ShowGridTable.NewRow(); dr["Upload"] = "No data uploaded"; ShowGridTable.Rows.Add(dr); Session["SourceTable"] = ShowGridTable; LoginUsers UserData = LI.GetLoginUserInfo("User"); if (Refresh == "Yes") { Session.Contents[UserData.UserName + "_MyModel"] = null; } if (AssignedView[0] == "Player") { return(RedirectToAction("UploadVersion", "Version", new { area = "" })); } else if (AssignedView[0] == "Finalyzer") { return(RedirectToAction("UploadData", "Version", new { area = "" })); } if (UserData.ValidUser == "No") { return(RedirectToAction("NotAuthorizedPage", "Version")); } if (Session.Contents[UserData.UserName + "_MyModel"] == null || Refresh == "Yes") { var UFH = (from ufh in db.UploadFilesHeaders where ufh.CompanyName == UserData.CompanyName && ufh.Role == "Finalyzer" select ufh).FirstOrDefault(); string[] RetValue = LI.GetOrgChartData(myla.Role, myla.Country, myla.ShowLevel, myla.ParentLevel, myla.Levels, myla.Oper, myla.Version, myla.OrgChartType, myla.SelectedPortraitModeMultipleLevel, myla.SelectedFunctionalManagerType); var viewModel = new MyModel { UserId = UserData.UserName, UseDate = DateTime.Now, CompanyName = UserData.CompanyName, KeyDate = myla.KeyDate, SelectedInitiative = myla.SelectedInitiative, SelectedPopulation = myla.SelectedPopulation, SelectedUser = myla.SelectedUser, SelectedVersion = myla.SelectedVersion, SelectedShape = myla.SelectedShape, SelectedSkin = myla.SelectedSkin, SelectedShowPicture = myla.SelectedShowPicture, SelectedSplitScreen = myla.SelectedSplitScreen, SelectedSplitScreenDirection = myla.SelectedSplitScreenDirection, SelectedTextColor = myla.SelectedTextColor, SelectedBorderColor = myla.SelectedBorderColor, SelectedBorderWidth = myla.SelectedBorderWidth, SelectedLineColor = myla.SelectedLineColor, SelectedBoxWidth = myla.SelectedBoxWidth, SelectedFunctionalManagerType = myla.SelectedFunctionalManagerType, SelectedFMLine = myla.SelectedFMLine, SelectedPortraitModeMultipleLevel = myla.SelectedPortraitModeMultipleLevel, OrgChartType = myla.OrgChartType, ShowLevel = myla.ShowLevel, Levels = myla.Levels, Version = myla.Version, Oper = myla.Oper, View = myla.View, SerialNoFlag = UFH == null ? "N" : UFH.SerialNoFlag, CopyPaste = myla.CopyPaste, Country = myla.Country, Countries = JsonConvert.SerializeObject((from co in db.LegalCountries select co).Distinct().ToList()), TreeData = RetValue[0], ChartData = RetValue[1], Role = myla.Role, AssignedRole = LI.GetUserRoles(), HRCoreVersion = LI.GetHRCoreVersion(myla.Country, myla.Oper), Menu = LI.GetMenuItems(myla.Role), DDL = JsonConvert.SerializeObject((from vd in db.VersionDetails where vd.CompanyName == UserData.CompanyName && vd.ActiveVersion == "Y" && vd.OperType == myla.Oper && (myla.Role == "Player" || myla.Role == "Finalyzer" || myla.Role == "User") select new { vd.UserName, vd.CompanyName, vd.UserRole, vd.OperType, vd.Country, vd.Initiative, vd.Population, vd.Version }).Distinct().ToList()), SelectFields = JsonConvert.SerializeObject((from sf in db.LEVEL_CONFIG_INFO where sf.DOWNLOAD_TYPE == "PDF" && sf.COMPANY_NAME == UserData.CompanyName select new { FIELD_NAME = sf.FIELD_NAME, FIELD_CAPTION = sf.FIELD_CAPTION, ACTIVE_IND = sf.ACTIVE_IND }).ToList()), SearchFields = GetSearchFields(VersionNumber), InitialValues = JsonConvert.SerializeObject((from iv in db.InitializeTables where iv.CompanyName == UserData.CompanyName select iv).FirstOrDefault()), FinalyzerVerion = LI.GetFinalyzerVerion(myla.Oper), GridDataTable = ShowGridTable, ValidateSecurity = Security }; Session.Contents[UserData.UserName + "_MyModel"] = viewModel; } MyModel MyModel = (MyModel)Session.Contents[UserData.UserName + "_MyModel"]; return(View(MyModel)); }