Example #1
0
        public ActionResult LogParameterSave(NippsModule nippsModule)
        {
            ModuleNameParser mnp = new ModuleNameParser(nippsModule.ModuleName);

            try
            {
                UpdateLogParameter(nippsModule, mnp, ViewBag);

                UpdateNippsModule(nippsModule, ViewBag);

                SetLogLevel(nippsModule, mnp, ViewBag);
            }
            catch (Exception ex)
            {
                if (ViewBag.Result == Result.OK)
                {
                    ViewBag.Result = Result.SUCCESSWITHWARN;
                }
                ViewBag.ResultMessages.Add(ex.ToString());
            }

            ViewBag.ReturnToAction     = ReturnToAction;
            ViewBag.ReturnToController = ReturnToController;
            ViewBag.Title = Resources.Global.LogParametersChangeTitle;

            if (ViewBag.Result == Result.OK)
            {
                return(RedirectToAction("StatusList"));
            }

            return(View(NippsSiteHelper.ResultMessageView));
        }
Example #2
0
        private static void UpdateLogParameter(NippsModule nippsModule, ModuleNameParser mnp, dynamic ViewBag)
        {
            string uri             = CommonHelper.ConfigManagerServiceUrl + "NippsParameterService/Update";
            string newLogLevel     = Enum.GetName(typeof(NippsLogLevel), nippsModule.LogLevelId);
            string newArchiveEvery = Enum.GetName(typeof(FileArchivePeriod), nippsModule.ArchiveEvery);
            string categoryName    = mnp.Service.ToUpper();

            NippsParameterRequest parameterRequest = new NippsParameterRequest
            {
                NippsParameters = new List <NippsParameter> {
                    new NippsParameter {
                        CategoryName = categoryName, ParameterName = "MinLevel", ParameterValue = newLogLevel
                    }
                    , new NippsParameter {
                        CategoryName = categoryName, ParameterName = "ArchiveEvery", ParameterValue = newArchiveEvery
                    }
                    , new NippsParameter {
                        CategoryName = categoryName, ParameterName = "ArchiveAboveSize", ParameterValue = (nippsModule.ArchiveAboveSize * 1000000).ToString()
                    }
                    , new NippsParameter {
                        CategoryName = categoryName, ParameterName = "MaxArchiveFiles", ParameterValue = nippsModule.MaxArchiveFiles.ToString()
                    }
                }
            };
            NippsParameterResponse parameterResponse = RestHelper.RestPostObject <NippsParameterResponse, NippsParameterRequest>(uri, parameterRequest);

            ViewBag.Name = Resources.Global.LogParametersChange;
            SetViewBagResult(parameterResponse, ViewBag);
        }
Example #3
0
        public ActionResult LogDownload(NippsModule nippsModule)
        {
            List <NippsLogFile> logFiles = new List <NippsLogFile>();

            try
            {
                ModuleNameParser mnp       = new ModuleNameParser(nippsModule.ModuleName);
                string           svcLogUrl = NippsSiteHelper.ServiceLogUrl(mnp);
                Logger.Debug("MODULE={0}, URL={1}", mnp.ToString(), svcLogUrl);

                logFiles           = LogGetFileList(svcLogUrl, logFiles);
                ViewBag.ResultList = logFiles;
                SetViewBagResult(new NippsLogResponse {
                    Result = logFiles.Count > 0 ? Result.OK : Result.SUCCESSWITHWARN, ResultMessages = new List <string>()
                }, ViewBag);
            }
            catch (Exception ex)
            {
                Logger.Error("{0}\n{1}", nippsModule, ex.ToString());
                SetViewBagResult(new NippsLogResponse {
                    Result = Result.FAIL, ResultMessages = new List <string> {
                        ex.ToString()
                    }
                }, ViewBag);
            }

            return(PartialView("LogDownload", nippsModule));
        }
Example #4
0
        public ActionResult LogDownloadAll(NippsLogFileRequest logStartFinish)
        {
            string systemManager   = Request.Params["IsSystemManager"];
            bool   isSystemManager = !string.IsNullOrEmpty(systemManager) && systemManager.Equals("true");

            if (logStartFinish.LogFinishDate < logStartFinish.LogStartDate || logStartFinish.LogFinishDate > DateTime.Now)
            {
                ModelState.AddModelError("LogFinishDate", Resources.Global.MessageInvalidFinishDate);
                ViewBag.IsSystemManager = isSystemManager;
                ViewBag.ModelState      = ModelState;
                return(View("LogDownloadConfirm"));
            }

            List <NippsLogFile> logFiles = new List <NippsLogFile>();

            ViewBag.Title = string.Format(Resources.Global.MessageDownloadAllLogs
                                          , logStartFinish.LogStartDate.ToShortDateString()
                                          , logStartFinish.LogFinishDate.ToShortDateString());

            if (isSystemManager)
            {
                logFiles = SMNippsLogZipFileList(new List <NippsLogFile>(), logStartFinish);
            }
            else
            {
                ModuleNameParser    mnp;
                string              uri            = CommonHelper.LogManagerServiceUrl + "NippsModuleService/List";
                NippsModuleResponse moduleResponse = RestHelper.RestPostObject <NippsModuleResponse, NippsModuleRequest>(uri, new NippsModuleRequest());
                foreach (NippsModule nippsModule in moduleResponse.NippsModules)
                {
                    try
                    {
                        mnp = new ModuleNameParser(nippsModule.ModuleName);
                        uri = NippsSiteHelper.ServiceLogUrl(mnp);

                        logFiles = LogGetZipFileList(uri, logFiles, logStartFinish);
                    }
                    catch (Exception ex) { Logger.Error(ex.ToString()); }
                }
            }

            if (logFiles.Count > 0)
            {
                ViewBag.Result = Result.OK;
            }
            else
            {
                ViewBag.Result = Result.SUCCESSWITHWARN;
            }

            ViewBag.ResultList = logFiles;

            return(View());
        }
Example #5
0
        private static void SetLogLevel(NippsModule nippsModule, ModuleNameParser mnp, dynamic ViewBag)
        {
            string             uri        = NippsSiteHelper.ServiceLogUrl(mnp) + "LogSetLevel";
            NippsModuleRequest logRequest = new NippsModuleRequest {
                NippsModules = new List <NippsModule> {
                    nippsModule
                }
            };
            NippsModuleResponse logResponse = RestHelper.RestPostObject <NippsModuleResponse, NippsModuleRequest>(uri, logRequest);

            ViewBag.Name = Resources.Global.LogLevelChange;
            SetViewBagResult(logResponse, ViewBag);
        }
Example #6
0
        public ActionResult LogParameterChange(NippsModule nippsModule)
        {
            try
            {
                ModuleNameParser mnp = new ModuleNameParser(nippsModule.ModuleName);
                string           uri = CommonHelper.ConfigManagerServiceUrl + "NippsParameterService/List";

                NippsParameterRequest listRequest = new NippsParameterRequest {
                    Category = mnp.Service.ToUpper()
                };
                NippsParameterResponse listResponse = RestHelper.RestPostObject <NippsParameterResponse, NippsParameterRequest>(uri, listRequest);

                if (listResponse.Result == Result.OK)
                {
                    nippsModule.LogLevelId = (NippsLogLevel)Enum.Parse(typeof(NippsLogLevel),
                                                                       listResponse.NippsParameters.Where(p => p.ParameterName.Equals("MinLevel")).Single().ParameterValue, false);

                    nippsModule.ArchiveEvery = (FileArchivePeriod)Enum.Parse(typeof(FileArchivePeriod),
                                                                             listResponse.NippsParameters.Where(p => p.ParameterName.Equals("ArchiveEvery")).Single().ParameterValue, false);

                    nippsModule.ArchiveAboveSize = int.Parse(
                        listResponse.NippsParameters.Where(p => p.ParameterName.Equals("ArchiveAboveSize")).Single().ParameterValue) / 1000000;

                    nippsModule.MaxArchiveFiles = int.Parse(
                        listResponse.NippsParameters.Where(p => p.ParameterName.Equals("MaxArchiveFiles")).Single().ParameterValue);
                }
                else //could not get, so set defaults
                {
                    nippsModule.LogLevelId       = NippsLogLevel.Warn;
                    nippsModule.ArchiveEvery     = FileArchivePeriod.Day;
                    nippsModule.ArchiveAboveSize = 10 * 1000000;
                    nippsModule.MaxArchiveFiles  = 10;
                }
            }
            catch (Exception ex)
            {
                Logger.Error("{0}: {1}", nippsModule, ex);

                nippsModule.LogLevelId       = NippsLogLevel.Warn;
                nippsModule.ArchiveEvery     = FileArchivePeriod.Day;
                nippsModule.ArchiveAboveSize = 10 * 1000000;
                nippsModule.MaxArchiveFiles  = 10;
            }

            return(View(nippsModule));
        }
Example #7
0
 public static string ServiceLogUrl(ModuleNameParser mnp)
 {
     return(ServiceBaseUrl(mnp.Host, mnp.Site, mnp.Application) + "/api/" + ConfigurationManager.AppSettings[mnp.Service + "LogUrl"]);
 }