예제 #1
0
        public FileResult GetRecordedUserActions()
        {
            var fileName = $"{QPContext.CurrentCustomerCode}.xml";
            var stream   = System.IO.File.Open(QPContext.GetRecordXmlFilePath(), FileMode.Open);

            return(File(stream, MediaTypeNames.Application.Octet, fileName));
        }
예제 #2
0
        public async Task <ActionResult> Settings(string tabId, int parentId, string successfulActionCode)
        {
            var db    = DbService.ReadSettings();
            var model = EntityViewModel.Create <DbViewModel>(db, tabId, parentId);

            model.SuccesfulActionCode = successfulActionCode;

            ViewBag.IsRecordAvailableForDownload = System.IO.File.Exists(QPContext.GetRecordXmlFilePath());
            return(await JsonHtml("Settings", model));
        }
예제 #3
0
        private static void RemoveRecordsXml()
        {
            var path = QPContext.GetRecordXmlFilePath();

            if (File.Exists(path))
            {
                File.SetAttributes(path, FileAttributes.Normal);
                File.Delete(path);
            }
        }
예제 #4
0
        internal static void ErasePreviouslyRecordedActions(string backendUrl, string currentDbVersion)
        {
            RemoveRecordsXml();
            var root = GetOrCreateRoot(backendUrl, currentDbVersion);
            var doc  = root.Document;

            if (doc != null)
            {
                if (root.HasElements)
                {
                    root.Remove();
                    doc.Add(CreateActionsRoot(backendUrl, currentDbVersion));
                }

                doc.Save(QPContext.GetRecordXmlFilePath());
            }
        }
예제 #5
0
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            try
            {
                var isValid = filterContext.Exception == null && filterContext.Controller.ViewData.ModelState.IsValid && !QPController.IsError(filterContext.HttpContext);
                if (isValid && DbRepository.Get().RecordActions)
                {
                    var currentDbVersion  = new ApplicationInfoRepository().GetCurrentDbVersion();
                    var actionToSerialize = XmlDbUpdateHttpContextHelpers.CreateXmlDbUpdateActionFromHttpContext(filterContext.HttpContext, _code ?? BackendActionContext.Current.ActionCode, _ignoreForm);
                    XmlDbUpdateSerializerHelpers
                    .SerializeAction(actionToSerialize, currentDbVersion, CommonHelpers.GetBackendUrl(filterContext.HttpContext))
                    .Save(QPContext.GetRecordXmlFilePath(), SaveOptions.None);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("There was an error while recording xml actions", ex);
            }

            base.OnActionExecuted(filterContext);
        }
예제 #6
0
        public FileResult GetRecordedUserActions()
        {
            var fileName = $"{QPContext.CurrentCustomerCode}_{System.IO.File.GetLastWriteTime(QPContext.GetRecordXmlFilePath()):yyyy-MM-dd_HH-mm-ss}.xml";

            return(File(QPContext.GetRecordXmlFilePath(), MediaTypeNames.Application.Octet, fileName));
        }
예제 #7
0
        private static XElement GetOrCreateRoot(string backendUrl, string currentDbVersion)
        {
            var doc = File.Exists(QPContext.GetRecordXmlFilePath()) ? XDocument.Load(QPContext.GetRecordXmlFilePath()) : new XDocument(CreateActionsRoot(backendUrl, currentDbVersion));

            return(doc.Elements(XmlDbUpdateXDocumentConstants.RootElement).Single());
        }