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)); }
/// <summary> /// Проверяет текст запроса на корректность /// </summary> internal static bool IsQueryQueryCorrect(string userQuery, out string errorMessage) { errorMessage = null; using (QPConfiguration.OutOfTransaction()) { try { var viewName = $"uq_v_test_{DateTime.Now.Ticks}"; var schema = SqlQuerySyntaxHelper.DbSchemaName(QPContext.DatabaseType); var createTestViewSql = $"CREATE VIEW {schema}.{viewName} AS {userQuery}"; using (var connect = QPContext.CreateDbConnection()) { connect.Open(); Common.ExecuteSql(connect, createTestViewSql); Common.DropView(connect, viewName); } return(true); } catch (SqlException ex) { errorMessage = ex.ErrorsToString(); return(false); } catch (NpgsqlException ex) { errorMessage = ex.Message; return(false); } } }
/// <summary> /// Возвращает список по ids /// </summary> /// <returns></returns> internal static IEnumerable <StatusType> GetList(IEnumerable <int> IDs) { var result = new List <StatusType>(); var cache = QPContext.GetStatusTypeCache(); if (cache != null) { foreach (var id in IDs) { if (cache.ContainsKey(id)) { result.Add(cache[id]); } else { result.Add(GetRealById(id)); } } } else { IEnumerable <decimal> decIDs = Converter.ToDecimalCollection(IDs).Distinct().ToArray(); result = MapperFacade.StatusTypeMapper .GetBizList(QPContext.EFContext.StatusTypeSet .Where(f => decIDs.Contains(f.Id)) .ToList() ); } return(result); }
internal static void RegisterUnity() { var resolver = new UnityDependencyResolver(); DependencyResolver.SetResolver(resolver); QPContext.SetUnityContainer(resolver.UnityContainer); GlobalHost.DependencyResolver = new SignalRUnityDependencyResolver(resolver.UnityContainer); }
private static void RemoveRecordsXml() { var path = QPContext.GetRecordXmlFilePath(); if (File.Exists(path)) { File.SetAttributes(path, FileAttributes.Normal); File.Delete(path); } }
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)); }
internal static StatusType GetByIdFromCache(int id) { StatusType result = null; var cache = QPContext.GetStatusTypeCache(); if (cache != null && cache.ContainsKey(id)) { result = cache[id]; } return(result); }
public ActionResult LogOut(DirectLinkOptions directLinkOptions) { var loginUrl = QPContext.LogOut(); if (directLinkOptions != null) { loginUrl = directLinkOptions.AddToUrl(loginUrl); } return(Redirect(loginUrl)); }
public void Configure(IApplicationBuilder app, IServiceProvider provider, IWebHostEnvironment env, ILoggerFactory loggerFactory) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler(new GlobalExceptionHandler().Action); } app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "Scripts")), RequestPath = "/Scripts" }); app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "Static")), RequestPath = "/Static" }); app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "plugins")), RequestPath = "/plugins" }); app.UseForwardedHeaders(); app.UseAuthentication(); QPContext.SetServiceProvider(provider); RegisterMappings(); app.Use(async(context, next) => { var claim = context.User.FindFirst("CultureName"); var cultureName = claim != null ? claim.Value : QPConfiguration.Options.Globalization.DefaultCulture; var cultureInfo = new CultureInfo(cultureName); CultureInfo.CurrentUICulture = cultureInfo; CultureInfo.CurrentCulture = cultureInfo; await next.Invoke(); }); app.UseSession(); app.UseMvc(RegisterRoutes); }
internal static User GetByIdFromCache(int id) { User result = null; var cache = QPContext.GetUserCache(); if (cache != null && cache.ContainsKey(id)) { result = cache[id]; } return(result); }
private static Field GetByIdFromCache(int fieldId) { Field result = null; var cache = QPContext.GetFieldCache(); if (cache != null && cache.ContainsKey(fieldId)) { result = cache[fieldId]; } return(result); }
private static Content GetByIdFromCache(int id) { Content result = null; var cache = QPContext.GetContentCache(); if (cache != null && cache.ContainsKey(id)) { result = cache[id]; } return(result); }
/// <summary> /// Возвращает список по ids /// </summary> internal static IEnumerable <User> GetList(IEnumerable <int> ids) { var result = new List <User>(); var cache = QPContext.GetUserCache(); if (cache != null) { result.AddRange(ids.Select(id => cache.ContainsKey(id) ? cache[id] : GetRealById(id))); } else { IEnumerable <decimal> decIDs = Converter.ToDecimalCollection(ids).Distinct().ToArray(); result = MapperFacade.UserMapper.GetBizList(QPContext.EFContext.UserSet.Where(f => decIDs.Contains(f.Id)).ToList()); } return(result); }
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()); } }
private static List <Field> GetListFromCache(int contentId) { IList <Field> result = null; var cache = QPContext.GetFieldCache(); var cache2 = QPContext.GetContentFieldCache(); if (cache != null && cache2 != null && cache2.ContainsKey(contentId)) { var fieldIds = cache2[contentId]; var tempFieldIds = fieldIds.Select(n => cache.ContainsKey(n) ? cache[n] : null).ToList(); if (tempFieldIds.All(n => n != null)) { result = tempFieldIds; } } return(result?.ToList()); }
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); }
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)); }
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()); }
public ActionResult LogOut(DirectLinkOptions directLinkOptions) { QPContext.LogOut(); return(RedirectToAction("Index")); }