コード例 #1
0
ファイル: DbController.cs プロジェクト: QuantumArt/QP
        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
ファイル: DbController.cs プロジェクト: QuantumArt/QP
        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
ファイル: RecordAttribute.cs プロジェクト: AuthorProxy/QP
        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
ファイル: DbController.cs プロジェクト: AuthorProxy/QP
        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());
        }