// GET: PlantiT.Web.HeinekenMassafra.MES/DrillInController public ActionResult Index(string BatchKey, string ConfigKey) { // Berechtigungen ermitteln PPrincipal principal = System.Web.HttpContext.Current.GetPrincipal(); if ((null != principal) && !String.IsNullOrWhiteSpace(principal.AuthenticationType)) { ViewBag.AuthenticationToken = principal.AuthenticationToken; ViewBag.AuthenticationType = principal.AuthenticationType; } // Gateway Verbindung PGatewayConnection gatewayConnection = DependencyResolver.Current.GetService(typeof(PGatewayConnection)) as PGatewayConnection; if (gatewayConnection == null) { return(new HttpStatusCodeResult(HttpStatusCode.Conflict, "Gateway information not found")); } ViewBag.GatewayPath = gatewayConnection.BaseUri; try { ViewBag.BatchKey = Int64.Parse(BatchKey); ViewBag.ConfigKey = Int64.Parse(ConfigKey); } catch (Exception) { return(new HttpStatusCodeResult(HttpStatusCode.Conflict, "Parameter type not correct")); } return(View()); }
public virtual async Task <ActionResult> IndexEH(long ml) { // Berechtigungen ermitteln PPrincipal principal = System.Web.HttpContext.Current.GetPrincipal(); if ((null != principal) && !String.IsNullOrWhiteSpace(principal.AuthenticationType)) { ViewBag.AuthenticationToken = principal.AuthenticationToken; ViewBag.AuthenticationType = principal.AuthenticationType; } // Gateway Verbindung PGatewayConnection gatewayConnection = DependencyResolver.Current.GetService(typeof(PGatewayConnection)) as PGatewayConnection; if (gatewayConnection == null) { return(new HttpStatusCodeResult(HttpStatusCode.Conflict, "Gateway information not found")); } Models.Database.MenuItem menuItem = this.configurationProvider.GetCurrentMenuItem(ml); System.Web.Routing.RouteValueDictionary routeValues = menuItem.GetRouteValues(true); String select_usage = "*[Template Type].2*"; ViewBag.GatewayPath = gatewayConnection.BaseUri; ViewBag.select_usage = select_usage; return(View("Index")); }
public ActionResult DownloadBrewReport(String _BatchKey, bool CreateLogFile = false) { // Parameterhandling const string FILENAME_TYPE = "xlsx"; const string EXCEL_TEMPLATE_NAME = "ExcelReport_BatchBrew_Template" + "." + FILENAME_TYPE; const string SSIS_PACKAGE = "ExcelReport_BatchBrew.dtsx"; const string FOLDER_BASE_SOURCE = "Areas\\PlantiT.Web.HeinekenMassafra.MES\\Excel"; const string FOLDER_BIN = "bin"; const string FOLDER_TEMPLATE = "template"; const string FOLDER_BASE_OUTPUT = "Areas\\PlantiT.Web.HeinekenMassafra.MES\\Excel\\output"; const string LOG_FILE_NAME = "DownloadBrewBatch_Log.txt"; const int WAITTIME_IN_MS = 1000; const int MAXWAITTIME_IN_MS = 30000; String sLocation = Assembly.GetExecutingAssembly().Location; // Get current directory Logger logger = null; long nBatchKey = 0; string sBatchName = String.Empty; string sBatchNumber = String.Empty; string sSAPMaterial = String.Empty; string sSAP_Batch = String.Empty; string sBrewLine = String.Empty; string sShortMaterial = String.Empty; string sSourcePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, FOLDER_BASE_SOURCE); string sDestinationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, FOLDER_BASE_OUTPUT); string sDestinationFilePath = String.Empty; string sFileName = String.Empty; DateTime dtCheckTime = DateTime.Now; List <CBatch> listBatch = null; // Log generieren if (CreateLogFile) { logger = new Logger(Path.Combine(sDestinationPath, LOG_FILE_NAME), true); } // Batch Key ermitteln try { nBatchKey = Convert.ToInt64(_BatchKey); } catch { return(new HttpNotFoundResult(String.Format("Invalid BatchKey: {0}", _BatchKey))); } // Batchdaten ermitteln String odataURI = String.Format("odata/ods/ZWebSAPInterfaceStatuses?$select=_BatchKey,BatchName,SAPMaterial,SAP_Batch,BatchProcessStartTime&$filter=_BatchKey eq {0}", _BatchKey); PGatewayConnection gatewayConnection = DependencyResolver.Current.GetService(typeof(PGatewayConnection)) as PGatewayConnection; try { listBatch = gatewayConnection.ReadItem <CODataResponse <CBatch> >(odataURI).Value; } catch { return(new HttpNotFoundResult(String.Format("OData query invalid for BatchKey: {0}", _BatchKey))); } // Daten prüfen if (listBatch == null || listBatch.Where(x => x._BatchKey == nBatchKey).Count() == 0) { return(new HttpNotFoundResult(String.Format("Data not found for BatchKey: {0}", _BatchKey))); } // Namen von Auftrag ermitteln sBatchName = listBatch.Where(x => x._BatchKey == nBatchKey).FirstOrDefault().BatchName; sBatchNumber = sBatchName.Substring(0, 12).Substring(sBatchName.Substring(0, 12).Length - 4, 4); sSAPMaterial = listBatch.Where(x => x._BatchKey == nBatchKey).FirstOrDefault().SAPMaterial; sSAP_Batch = listBatch.Where(x => x._BatchKey == nBatchKey).FirstOrDefault().SAP_Batch; sBrewLine = sSAP_Batch.Substring(5, 1); sShortMaterial = sSAPMaterial.Substring(sSAPMaterial.Length - 5); string FILENAME_PREFIX = (listBatch.Where(x => x._BatchKey == nBatchKey).FirstOrDefault().BatchProcessStartTime).ToString("yy"); // BatchName prüfen if (sBatchName.Equals(String.Empty)) { return(new HttpNotFoundResult(String.Format("No Batchname found for BatchKey: {0}", _BatchKey))); } // Nach Datei suchen sFileName = FILENAME_PREFIX + "_" + sBatchNumber + "_" + sBrewLine + "_1_" + sShortMaterial; Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application(); Microsoft.SqlServer.Dts.Runtime.Package package = null; MyEventListener eventListener = new MyEventListener(); //Load the SSIS Package which will be executed app.PackagePassword = "******"; String sPackageFilePath = Path.Combine(sSourcePath, FOLDER_BIN, SSIS_PACKAGE); // Execute try { // Load package package = app.LoadPackage(sPackageFilePath, eventListener); // Set values Variables vars = package.Variables; vars["User::InputBatchKey"].Value = nBatchKey; vars["User::InputDestinationFile"].Value = sFileName + "." + FILENAME_TYPE; vars["User::InputDestinationPath"].Value = sDestinationPath; vars["User::InputTemplateFilePath"].Value = Path.Combine(sSourcePath, FOLDER_TEMPLATE, EXCEL_TEMPLATE_NAME); vars["User::InputCreateLogFile"].Value = CreateLogFile; vars["User::InputLogFilePath"].Value = (logger != null) ? logger.FilePath : String.Empty; // Log erzeugen if (logger != null) { logger.Log("InputBatchKey", vars["User::InputBatchKey"].Value.ToString()); logger.Log("InputDestinationFile", vars["User::InputDestinationFile"].Value.ToString()); logger.Log("InputDestinationPath", vars["User::InputDestinationPath"].Value.ToString()); logger.Log("InputTemplateFilePath", vars["User::InputTemplateFilePath"].Value.ToString()); } vars["InputToOverwrite"].Value = true; DTSExecResult results = package.Execute(null, null, eventListener, null, null); } catch (Exception ex) { if (logger != null) { logger.Log("Error", String.Format("Error: {0} // Innermessage: {1}", ex.Message, (ex.InnerException != null) ? ex.InnerException.Message : String.Empty)); } return(new HttpNotFoundResult(String.Format("Error: {0} // Innermessage: {1}", ex.Message, (ex.InnerException != null) ? ex.InnerException.Message : String.Empty))); } // zyklisch prüfen ob Datei vorhanden ist, maximal MAXWAITTIME_IN_MS for (int i = 0; i < MAXWAITTIME_IN_MS; i += WAITTIME_IN_MS) { // erstmal eine Sekunde zeit geben, zyklisch prüfen System.Threading.Thread.Sleep(WAITTIME_IN_MS); // alle Dateien des Pfades holen die dem Suchmuster entsprechen DirectoryInfo dirInfo = new DirectoryInfo(Path.Combine(sDestinationPath)); var filesInPath = dirInfo.EnumerateFiles(String.Format("{0}*.{1}", sFileName, FILENAME_TYPE)); var file = filesInPath.Where(x => x.Name.Contains(sFileName)).OrderByDescending(x => x.LastWriteTime).FirstOrDefault(); // nur welche die eben erstellt wurde if (file == null) { continue; } // Falls eben erstellt... if (file.LastWriteTime >= dtCheckTime) { // gefunden, Abbruch sFileName = file.Name; break; } } // Pfad mit Datei erzeugen sDestinationFilePath = Path.Combine(sDestinationPath, sFileName); // Datei vorhanden? if (!System.IO.File.Exists(sDestinationFilePath)) { return(new HttpNotFoundResult(String.Format("Excel file could not created for BatchKey: {0}", _BatchKey))); } // Create data return stream byte[] fileData = System.IO.File.ReadAllBytes(sDestinationFilePath); string contentType = System.Web.MimeMapping.GetMimeMapping(sDestinationFilePath); // Datei entfernen System.IO.File.Delete(sDestinationFilePath); var cd = new System.Net.Mime.ContentDisposition() { // for example foo.bak FileName = sFileName, // always prompt the user for downloading, set to true if you want // the browser to try to show the file inline Inline = false, }; Response.AppendHeader("Content-Disposition", cd.ToString()); return(File(fileData, contentType)); }
/// <summary> /// Return menugroups /// </summary> /// <returns>Menu groups</returns> public IEnumerable <MenuGroup> GetMenu() { PGatewayConnection gatewayConnection = DependencyResolver.Current.GetService(typeof(PGatewayConnection)) as PGatewayConnection; IClientAuthorization authorizationService = DependencyResolver.Current.GetService <IClientAuthorization>(); // Header über ID ermitteln int nLanguageId = ((IPWebPortalInfo)DependencyResolver.Current.GetService <IPWebPortalInfo>()).GetCurrentLanguage().LanguageId(); lock (lockObject) { MenuGroup menuGroup = null; m_menu.Clear(); #region MenuGroup: Reports - not used (BasicInstall) //menuGroup = new MenuGroup //{ // Id = 1, // LocalName = PLanguageTexts.TXT_MENUGROUP_REPORTS, // GlobalName = PLanguageTexts.TXT_MENUGROUP_REPORTS, // Sequence = 1000000, // ProviderLink = ProviderInfo.Id //}; //try //{ // menuGroup.Items.Add( // new MenuItem // { // Id = 1000001, // MenuGroupId = menuGroup.Id, // Area = "PlantiT.Web.HeinekenMassafra.MES", // Controller = "Reports", // Action = "Index", // PlantitRight = "", // GlobalName = PLanguageTexts.TXT_MENUGROUPITEM_REPORTOVERVIEW, // LocalName = PLanguageTexts.TXT_MENUGROUPITEM_REPORTOVERVIEW, // AddInType = AddInType.EmbeddedView, // } // ); //} //// ToDo: change errors handling //catch (Exception) //{ // m_menu.Clear(); // return m_menu; //} //m_menu.Add(menuGroup); #endregion #region MenuGroup: Dashboards - not used (BasicInstall) //menuGroup = new MenuGroup //{ // Id = 2, // LocalName = PLanguageTexts.TXT_MENUGROUP_DASHBOARDS, // GlobalName = PLanguageTexts.TXT_MENUGROUP_DASHBOARDS, // Sequence = 2000000, // ProviderLink = ProviderInfo.Id //}; //try //{ // menuGroup.Items.Add( // new MenuItem // { // Id = 2000001, // MenuGroupId = menuGroup.Id, // Area = "Dashboard", // Controller = "Dashboards", // Action = "Dashboard", // RouteValues = new Dictionary<string, string>() { // { "doc", "Plant iT Batch Analytics.qvw"}, // { "width", "1609"} // }, // PlantitRight = "", // GlobalName = PLanguageTexts.TXT_MENUGROUPITEM_PLANTITBATCHANALYTICS, // LocalName = PLanguageTexts.TXT_MENUGROUPITEM_PLANTITBATCHANALYTICS, // AddInType = AddInType.EmbeddedView, // } // ); //} //// ToDo: change errors handling //catch (Exception) //{ // m_menu.Clear(); // return m_menu; //} //m_menu.Add(menuGroup); #endregion #region MenuGroup: Batch Tracking - not used (BasicInstall) //menuGroup = new MenuGroup //{ // Id = 3, // LocalName = PLanguageTexts.TXT_MENUGROUP_BATCHTRACKING, // GlobalName = PLanguageTexts.TXT_MENUGROUP_BATCHTRACKING, // Sequence = 3000000, // ProviderLink = ProviderInfo.Id //}; //try //{ // menuGroup.Items.Add( // new MenuItem // { // Id = 3000001, // MenuGroupId = menuGroup.Id, // Area = "PlantiT.Web.HeinekenMassafra.MES", // Controller = "BatchTracker", // Action = "Batch", // PlantitRight = "", // GlobalName = PLanguageTexts.TXT_MENUGROUPITEM_BATCHTRACKER, // LocalName = PLanguageTexts.TXT_MENUGROUPITEM_BATCHTRACKER, // AddInType = AddInType.EmbeddedView, // } // ); //} //// ToDo: change errors handling //catch (Exception) //{ // m_menu.Clear(); // return m_menu; //} //m_menu.Add(menuGroup); #endregion #region MenuGroup: Analysis menuGroup = new MenuGroup { Id = 4, LocalName = PLanguageTexts.TXT_MENUGROUP_ANALYSIS, GlobalName = PLanguageTexts.TXT_MENUGROUP_ANALYSIS, Sequence = 4000000, ProviderLink = ProviderInfo.Id }; try { menuGroup.Items.Add( new MenuItem { Id = 4000001, MenuGroupId = menuGroup.Id, Area = "PlantiT.Web.HeinekenMassafra.MES", Controller = "Batchoverview", Action = "Index", PlantitRight = "", GlobalName = PLanguageTexts.TXT_MENUGROUPITEM_BATCHOVERVIEW, LocalName = PLanguageTexts.TXT_MENUGROUPITEM_BATCHOVERVIEW, AddInType = AddInType.EmbeddedView, } ); menuGroup.Items.Add( new MenuItem { Id = 4000002, MenuGroupId = menuGroup.Id, Area = "PlantiT.Web.HeinekenMassafra.MES", Controller = "SAPInterface", Action = "Index", PlantitRight = "", GlobalName = PLanguageTexts.TXT_MENUGROUPITEM_SAPINTERFACE, LocalName = PLanguageTexts.TXT_MENUGROUPITEM_SAPINTERFACE, AddInType = AddInType.EmbeddedView, } ); menuGroup.Items.Add( new MenuItem { Id = 4000003, MenuGroupId = menuGroup.Id, Area = "PlantiT.Web.HeinekenMassafra.MES", Controller = "FTR", Action = "Index", PlantitRight = "", GlobalName = PLanguageTexts.TXT_MENUGROUPITEM_FTRREPORT, LocalName = PLanguageTexts.TXT_MENUGROUPITEM_FTRREPORT, AddInType = AddInType.EmbeddedView, } ); menuGroup.Items.Add( new MenuItem { Id = 4000004, MenuGroupId = menuGroup.Id, Area = "PlantiT.Web.HeinekenMassafra.MES", Controller = "DataExport", Action = "Index", PlantitRight = "", GlobalName = PLanguageTexts.TXT_MENUGROUPITEM_DATAEXPORT, LocalName = PLanguageTexts.TXT_MENUGROUPITEM_DATAEXPORT, AddInType = AddInType.EmbeddedView, } ); menuGroup.Items.Add( new MenuItem { Id = 4000005, MenuGroupId = menuGroup.Id, Area = "PlantiT.Web.HeinekenMassafra.MES", Controller = "DosingBatchManagement", Action = "Index", PlantitRight = "", GlobalName = PLanguageTexts.TXT_MENUGROUPITEM_DOSINGBATCHES, LocalName = PLanguageTexts.TXT_MENUGROUPITEM_DOSINGBATCHES, AddInType = AddInType.EmbeddedView, } ); menuGroup.Items.Add( new MenuItem { Id = 4000006, MenuGroupId = menuGroup.Id, Area = "PlantiT.Web.HeinekenMassafra.MES", Controller = "EventHistory", Action = "Index", PlantitRight = "", GlobalName = PLanguageTexts.TXT_MENUGROUPITEM_EVENTHISTORY, LocalName = PLanguageTexts.TXT_MENUGROUPITEM_EVENTHISTORY, AddInType = AddInType.EmbeddedView, } ); menuGroup.Items.Add( new MenuItem { Id = 4000007, MenuGroupId = menuGroup.Id, Area = "PlantiT.Web.HeinekenMassafra.MES", Controller = "ExceptionReport", Action = "Index", PlantitRight = "", GlobalName = PLanguageTexts.TXT_MENUGROUPITEM_EXCEPTIONREPORT, LocalName = PLanguageTexts.TXT_MENUGROUPITEM_EXCEPTIONREPORT, AddInType = AddInType.EmbeddedView, } ); menuGroup.Items.Add( new MenuItem { Id = 4000008, MenuGroupId = menuGroup.Id, Area = "PlantiT.Web.HeinekenMassafra.MES", Controller = "TestConformance", Action = "Index", PlantitRight = "", GlobalName = PLanguageTexts.TXT_MENUGROUPITEM_TESTCONFORMANCE, LocalName = PLanguageTexts.TXT_MENUGROUPITEM_TESTCONFORMANCE, AddInType = AddInType.EmbeddedView, } ); menuGroup.Items.Add( new MenuItem { Id = 4000009, MenuGroupId = menuGroup.Id, Area = "PlantiT.Web.HeinekenMassafra.MES", Controller = "VariableConformance", Action = "Index", PlantitRight = "", GlobalName = PLanguageTexts.TXT_MENUGROUPITEM_VARIABLECOMFORMANCE, LocalName = PLanguageTexts.TXT_MENUGROUPITEM_VARIABLECOMFORMANCE, AddInType = AddInType.EmbeddedView, } ); menuGroup.Items.Add( new MenuItem { Id = 4000010, MenuGroupId = menuGroup.Id, Area = "PlantiT.Web.HeinekenMassafra.MES", Controller = "OPICalculation", Action = "Index", PlantitRight = "", GlobalName = PLanguageTexts.TXT_MENUGROUPITEM_OPICALCULATION, LocalName = PLanguageTexts.TXT_MENUGROUPITEM_OPICALCULATION, AddInType = AddInType.EmbeddedView, } ); } // ToDo: change errors handling catch (Exception) { m_menu.Clear(); return(m_menu); } m_menu.Add(menuGroup); #endregion #region MenuGroup: Templates menuGroup = new MenuGroup { Id = 5, LocalName = PLanguageTexts.TXT_MENUGROUP_TEMPLATES, GlobalName = PLanguageTexts.TXT_MENUGROUP_TEMPLATES, Sequence = 5000000, ProviderLink = ProviderInfo.Id }; try { menuGroup.Items.Add( new MenuItem { Id = 5000001, MenuGroupId = menuGroup.Id, Area = "PlantiT.Web.HeinekenMassafra.MES", Controller = "MaintainFTRTemplate", Action = "Index", PlantitRight = "", GlobalName = PLanguageTexts.TXT_MENUGROUPITEM_FTRTEMPLATE, LocalName = PLanguageTexts.TXT_MENUGROUPITEM_FTRTEMPLATE, AddInType = AddInType.EmbeddedView, } ); menuGroup.Items.Add( new MenuItem { Id = 5000002, MenuGroupId = menuGroup.Id, Area = "PlantiT.Web.HeinekenMassafra.MES", Controller = "MaintainTemplate", Action = "IndexDE", PlantitRight = "", GlobalName = PLanguageTexts.TXT_MENUGROUPITEM_EXCELREPORTTEMPLATE, LocalName = PLanguageTexts.TXT_MENUGROUPITEM_EXCELREPORTTEMPLATE, AddInType = AddInType.EmbeddedView, } ); menuGroup.Items.Add( new MenuItem { Id = 5000003, MenuGroupId = menuGroup.Id, Area = "PlantiT.Web.HeinekenMassafra.MES", Controller = "MaintainTemplate", Action = "IndexEH", PlantitRight = "", GlobalName = PLanguageTexts.TXT_MENUGROUPITEM_EVENTHISTORYTEMPLATE, LocalName = PLanguageTexts.TXT_MENUGROUPITEM_EVENTHISTORYTEMPLATE, AddInType = AddInType.EmbeddedView, } ); } // ToDo: change errors handling catch (Exception) { m_menu.Clear(); return(m_menu); } m_menu.Add(menuGroup); #endregion #region MenuGroup: Administration - not used (BasicInstall) //menuGroup = new MenuGroup //{ // Id = 6, // LocalName = PLanguageTexts.TXT_MENUGROUP_ADMINISTRATION, // GlobalName = PLanguageTexts.TXT_MENUGROUP_ADMINISTRATION, // Sequence = 6000000, // ProviderLink = ProviderInfo.Id //}; //try //{ // menuGroup.Items.Add( // new MenuItem // { // Id = 6000001, // MenuGroupId = menuGroup.Id, // Area = "PlantiT.Web.HeinekenMassafra.MES", // Controller = "Administration", // Action = "Index", // PlantitRight = "", // GlobalName = PLanguageTexts.TXT_MENUGROUPITEM_WEBPORTAL, // LocalName = PLanguageTexts.TXT_MENUGROUPITEM_WEBPORTAL, // AddInType = AddInType.EmbeddedView, // } // ); //} //// ToDo: change errors handling //catch (Exception) //{ // m_menu.Clear(); // return m_menu; //} //m_menu.Add(menuGroup); #endregion } return(m_menu); }