public static SqlQuery Build(QueryDef def, BizForm form, IEnumerable <AttributeSort> sortAttrs, Guid userId, IDataContext dataContext) { var factory = AppServiceProviderFactoryProvider.GetFactory(); using (var provider = factory.Create(dataContext)) { var sqb = new SqlQueryBuilderTool(provider, dataContext, userId); return(sqb.Build(def, form, sortAttrs)); } /*var query = SqlQueryBuilder.Build(dataContext, def, userId); * try * { * query.AddAttribute("&Id"); * AddFormAttributes(query, query.Source, form); * if (sortAttrs != null) * foreach (var attr in sortAttrs) * query.AddOrderAttribute(attr.AttributeId, attr.Asc); * else * AddFormSortOrders(query, query.Source, form); * * return query; * } * catch * { * query.Dispose(); * throw; * }*/ }
// public DynaDoc(Doc doc) : this(doc, Guid.Empty, null) {} public DynaDoc(Doc doc, Guid userId) { if (doc == null) { throw new ApplicationException("Не могу создать динамический документ. Документ не передан!"); } Doc = doc; var factory = AppServiceProviderFactoryProvider.GetFactory(); Provider = factory.Create(); _ownProvider = true; DataContext = Provider.Get <IDataContext>(); if (userId == Guid.Empty) { // var userData = Provider.Get<IUserDataProvider>(); UserId = Provider.GetCurrentUserId(); } else { UserId = userId; } _docRepo = Provider.Get <IDocRepository>(); _docStateRepo = Provider.Get <IDocStateRepository>(); _userRepo = Provider.Get <IUserRepository>(); }
/*public static SqlQuery Build(Doc doc, IDataContext dataContext = null) * { * var query = new SqlQuery(doc.DocDef.Id, dataContext); * try * { * AddDocConditions(query, query.Source, doc); * * return query; * } * catch * { * query.Dispose(); * throw; * } * }*/ /*public static SqlQuery Build(DocDef docDef, IDataContext dataContext = null) * { * var query = new SqlQuery(dataContext, docDef); * try * { * AddDocDefAttributes(query, query.Source, docDef); * * return query; * } * catch * { * query.Dispose(); * throw; * } * }*/ public static SqlQuery Build(BizForm form, IEnumerable <Guid> docIds, IEnumerable <AttributeSort> sortAttrs, Guid userId, IDataContext dataContext) { var factory = AppServiceProviderFactoryProvider.GetFactory(); using (var provider = factory.Create(dataContext)) { var sqb = new SqlQueryBuilderTool(provider, dataContext, userId); return(sqb.Build(form, docIds, sortAttrs)); } /*if (form.DocumentDefId == null) * throw new ApplicationException("Не могу создать запрос! Форма не связана с документом!"); * * var query = new SqlQuery(dataContext, (Guid) form.DocumentDefId, userId); * try * { * query.AddAttribute("&Id"); * AddFormAttributes(query, query.Source, form); * query.AddCondition(ExpressionOperation.And, query.Source.GetDocDef(), "&Id", ConditionOperation.In, * docIds.Cast<object>()); * if (sortAttrs != null) * foreach (var attr in sortAttrs) * query.AddOrderAttribute(attr.AttributeId, attr.Asc); * else * AddFormSortOrders(query, query.Source, form); * * return query; * } * catch * { * query.Dispose(); * throw; * }*/ }
public static SqlQuery Build(BizForm form, Guid userId, IDataContext dataContext) { var factory = AppServiceProviderFactoryProvider.GetFactory(); using (var provider = factory.Create(dataContext)) { var sqb = new SqlQueryBuilderTool(provider, dataContext, userId); return(sqb.Build(form)); } /*if (form.DocumentDefId == null) * throw new ApplicationException("Не могу создать запрос! Форма не связана с документом!"); * * var query = new SqlQuery(dataContext, (Guid)form.DocumentDefId, userId); * try * { * query.AddAttribute("&Id"); * AddFormAttributes(query, query.Source, form); * AddFormSortOrders(query, query.Source, form); * * return query; * } * catch * { * query.Dispose(); * throw; * }*/ }
public DynaDoc(Guid docId, Guid userId, IDataContext dataContext) { var factory = AppServiceProviderFactoryProvider.GetFactory(); Provider = factory.Create(); _ownProvider = true; if (dataContext == null) { DataContext = Provider.Get <IDataContext>(); //new DataContext(); // _ownDataContext = true; } else { DataContext = dataContext; } UserId = userId; _docRepo = Provider.Get <IDocRepository>(); _docStateRepo = Provider.Get <IDocStateRepository>(); _userRepo = Provider.Get <IUserRepository>(); Doc = _docRepo.LoadById(docId); }
public static SqlQuery BuildAttrList(BizControl form, Guid docId, Guid docDefId, Guid attrDefId, BizForm filter, IEnumerable <AttributeSort> sortAttrs, Guid userId, IDataContext dataContext) { var factory = AppServiceProviderFactoryProvider.GetFactory(); using (var provider = factory.Create(dataContext)) { var sqb = new SqlQueryBuilderTool(provider, dataContext, userId); return(sqb.BuildAttrList(form, docId, docDefId, attrDefId, filter, sortAttrs)); } /*var query = new SqlQuery(docDefId, docId, attrDefId, dataContext); * try * { * query.AddAttribute("&Id"); * AddFormAttributes(query, query.Source, form); * if (filter != null) * AddFormConditions(query, query.Source, filter); * * if (sortAttrs != null) * foreach (var attr in sortAttrs) * { * query.AddOrderAttribute(attr.AttributeId, attr.Asc); * } * else * AddFormSortOrders(query, query.Source, form); * * return query; * } * catch * { * query.Dispose(); * throw; * }*/ }
public BizService(IMultiDataContext dataContext, string currentUserName) { CurrentUserName = currentUserName; _dataContext = dataContext; var factory = AppServiceProviderFactoryProvider.GetFactory(); Provider = factory.Create(DataContext); //new AppServiceProvider(DataContext); UserRepo = Provider.Get <IUserRepository>(); var serviceRegistrator = Provider.Get <IAppServiceProviderRegistrator>(); serviceRegistrator.AddService(new UserDataProvider(CurrentUserId, CurrentUserName)); EnumRepo = Provider.Get <IEnumRepository>(); DocRepo = Provider.Get <IDocRepository>(); FormRepo = Provider.Get <IFormRepository>(); var workflowRepo = Provider.Get <IWorkflowRepository>(); WorkflowRepo = workflowRepo; WorkflowEngine = Provider.Get <IWorkflowEngine>(); ReportGeneratorProvider = Provider.Get <ITemplateReportGeneratorProvider>(); LangRepo = Provider.Get <ILanguageRepository>(); _sqlQueryBuilderFactory = Provider.Get <ISqlQueryBuilderFactory>(); _sqlQueryReaderFactory = Provider.Get <ISqlQueryReaderFactory>(); }
public WorkflowContext(WorkflowContextData data, IDataContext dataContext) { if (data == null) { throw new ArgumentNullException(@"data"); } if (dataContext == null) { throw new ArgumentNullException(@"dataContext"); } _dataContext = dataContext; Data = data; var factory = AppServiceProviderFactoryProvider.GetFactory(); Provider = factory.Create(); /*_docRepo = new DocRepository(DataContext, UserId); * _userRepo = new UserRepository(DataContext); * _defRepo = new DocDefRepository(DataContext, UserId); * _orgRepo = new OrgRepository(DataContext/*, Data.UserId#1#); * _enumRepo = new EnumRepository(DataContext);*/ _docRepo = Provider.Get <IDocRepository>(); _userRepo = Provider.Get <IUserRepository>(); _defRepo = Provider.Get <IDocDefRepository>(); _orgRepo = Provider.Get <IOrgRepository>(); _enumRepo = Provider.Get <IEnumRepository>(); _sqlQueryBuilderFactory = Provider.Get <ISqlQueryBuilderFactory>(); _sqlQueryReaderFactory = Provider.Get <ISqlQueryReaderFactory>(); }
public DynaDoc(Doc doc, Guid userId, IDataContext dataContext) { if (doc == null) { throw new ApplicationException("Не могу создать динамический документ. Документ не передан!"); } Doc = doc; var factory = AppServiceProviderFactoryProvider.GetFactory(); Provider = factory.Create(); _ownProvider = true; if (dataContext == null) { DataContext = Provider.Get <IDataContext>(); //new DataContext(); // _ownDataContext = true; } else { DataContext = dataContext; } UserId = userId; _docRepo = Provider.Get <IDocRepository>(); // new DocRepository(DataContext, UserId); _docStateRepo = Provider.Get <IDocStateRepository>(); // new DocStateRepository(DataContext); _userRepo = Provider.Get <IUserRepository>(); // new UserRepository(DataContext); }
public static IAppServiceProvider CreateProvider(IDataContext dataContext) { CreateBaseServiceFactories(); var factory = AppServiceProviderFactoryProvider.GetFactory(); var provider = factory.Create(dataContext); return(provider); }
public static IAppServiceProvider CreateProvider() { CreateBaseServiceFactories(); AppServiceProvider.SetServiceFactoryFunc(typeof(IDataContext), CreateDataContext); var factory = AppServiceProviderFactoryProvider.GetFactory(); var provider = factory.Create(); return(provider); }
public DocDataSet(IDataContext dataContext, IEnumerable <Guid> docs, Guid userId) { DataContext = dataContext; DocList = new List <Guid>(docs); var factory = AppServiceProviderFactoryProvider.GetFactory(); Provider = factory.Create(); _ownProvider = true; DocRepo = Provider.Get <IDocRepository>(); // new DocRepository(DataContext, userId); }
public static SqlQuery Build(IDataContext dataContext, QueryDef def) { if (def.Source == null) { throw new PropertyConstraintException("QueryDef Source not defined!"); } var factory = AppServiceProviderFactoryProvider.GetFactory(); using (var provider = factory.Create(dataContext)) { var bldr = new SqlQueryBuilderTool(provider, dataContext, def.UserId); return(bldr.Build(def)); } /*using (var defRepo = new DocDefRepository(dataContext)) * { * var docDef = def.Source.DocDefId == Guid.Empty * ? defRepo.DocDefByName(def.Source.DocDefName) * : defRepo.DocDefById(def.Source.DocDefId); * * var query = new SqlQuery(dataContext, docDef, def.Alias, def.UserId) * { * DocumentId = def.DocumentId, * ListAttrDefId = def.ListAttrId * }; * try * { * foreach (var source in def.Sources) * { * BuildSource(query, source, defRepo, dataContext); * } * foreach (var join in def.Joins) * { * BuildJoin(query, join, docDef, dataContext); * } * foreach (var condition in def.WhereConditions) * { * BuildCondition(query, condition, docDef, null); * } * foreach (var order in def.OrderAttributes) * { * query.AddOrderAttribute(order); * } * return query; * } * catch * { * query.Dispose(); * throw; * } * }*/ }
/// <summary> /// Проверяет данные подлючающегося клиента /// </summary> /// <param name="userName">Логин клиента</param> /// <param name="password">Пароль клиента</param> public override void Validate(string userName, string password) { try { //using (var connection = new EntityConnection("name=cissaEntities")) { //using (var dataContext = new DataContext(connection)) { BaseServiceFactory.CreateBaseServiceFactories(); var dataContextFactory = DataContextFactoryProvider.GetFactory(); using (var multiDC = dataContextFactory.CreateMultiDc(BaseServiceFactory.DataContextConfigSectionName)) { var providerFactory = AppServiceProviderFactoryProvider.GetFactory(); var serviceProvider = providerFactory.Create(multiDC); var userRepo = serviceProvider.Get <IUserRepository>(); //new UserRepository(dataContext); if (userRepo.Validate(userName, password)) { return; } } Thread.Sleep(1000); // притормозим выполнение для сложности подбора пароля throw new SecurityTokenException("Unknown Username or Password"); } } } catch (Exception e) { try { using (var writer = new StreamWriter(Logger.GetLogFileName("bizServiceValidate"), true)) { writer.WriteLine("{0}: Log error for username: \"{1}\"; message: \"{2}\"", DateTime.Now, userName, e.Message); if (e.InnerException != null) { writer.WriteLine(" - inner exception: \"{0}\"", e.InnerException.Message); } writer.WriteLine(" -- Stack: {0}", e.StackTrace); writer.WriteLine(Directory.GetCurrentDirectory()); // writer.WriteLine(HostingEnvironment.MapPath(".")); } } catch { // ignored } throw; } }
public DocDefRepository(IDataContext dataContext, Guid userId) { var factory = AppServiceProviderFactoryProvider.GetFactory(); Provider = factory.Create(); _ownProvider = true; DataContext = dataContext ?? Provider.Get <IDataContext>(); _enumRepo = Provider.Get <IEnumRepository>(); _permissionRepository = Provider.Get <IPermissionRepository>(); UserId = userId; }
// private static readonly Logger Log = LogManager.GetCurrentClassLogger(); public BizService() { try { _monitor = new Monitor("BizService session"); /*Connection = new EntityConnection("name=cissaEntities"); * _ownConnection = true;*/ CurrentUserName = ServiceSecurityContext.Current.PrimaryIdentity.Name; // Log.Info(string.Format("Система запущена пользователем {0}", CurrentUserName)); //var dc = new DataContext(Connection); var dataContextFactory = DataContextFactoryProvider.GetFactory(); _dataContext = dataContextFactory.CreateMultiDc(BaseServiceFactory.DataContextConfigSectionName); //new MultiDataContext(/*new[] {dc}*/); _ownDataContext = true; var providerFactory = AppServiceProviderFactoryProvider.GetFactory(); Provider = providerFactory.Create(DataContext); UserRepo = Provider.Get <IUserRepository>(); // new UserRepository(Provider); var serviceRegistrator = Provider.Get <IAppServiceProviderRegistrator>(); serviceRegistrator.AddService(new UserDataProvider(CurrentUserId, CurrentUserName)); EnumRepo = Provider.Get <IEnumRepository>(); //new EnumRepository(Provider); DocRepo = Provider.Get <IDocRepository>(); //new DocRepository(DataContext, CurrentUserId); DocDefRepo = Provider.Get <IDocDefRepository>(); FormRepo = Provider.Get <IFormRepository>(); //new FormRepository(DataContext, CurrentUserId); var workflowRepo = Provider.Get <IWorkflowRepository>(); //new WorkflowRepository(DataContext); WorkflowRepo = workflowRepo; WorkflowEngine = Provider.Get <IWorkflowEngine>(); //new WorkflowEngine(DataContext, workflowRepo, CurrentUserId); ReportGeneratorProvider = Provider.Get <ITemplateReportGeneratorProvider>(); //new TemplateReportGeneratorProvider(DataContext, CurrentUserId); //PdfTempRepo = new PdfTemplateRepository(DataContext, CurrentUserId); //ExcelTempRepo = new ExcelTemplateRepository(DataContext, CurrentUserId); LangRepo = Provider.Get <ILanguageRepository>(); _sqlQueryBuilderFactory = Provider.Get <ISqlQueryBuilderFactory>(); _sqlQueryReaderFactory = Provider.Get <ISqlQueryReaderFactory>(); _comboBoxValueProvider = Provider.Get <IComboBoxEnumProvider>(); _id = RegisterProcess(CurrentUserId, CurrentUserName); } catch (Exception e) { Logger.OutputLog(e, "BizService construction"); throw; } }
public static Int64 GetNewId(Guid orgId, Guid docDefId) { // DOТУ: Переделать!!! // using (var dataContext = new DataContext()) var factory = AppServiceProviderFactoryProvider.GetFactory(); using (var provider = factory.Create()) { var mdc = provider.Get <IMultiDataContext>(); return(GetNewId(mdc, orgId, docDefId)); } }
static IAppServiceProvider InitProvider(string username, Guid userId) { var dataContextFactory = DataContextFactoryProvider.GetFactory(); var dataContext = dataContextFactory.CreateMultiDc("DataContexts"); BaseServiceFactory.CreateBaseServiceFactories(); var providerFactory = AppServiceProviderFactoryProvider.GetFactory(); var provider = providerFactory.Create(dataContext); var serviceRegistrator = provider.Get <IAppServiceProviderRegistrator>(); serviceRegistrator.AddService(new UserDataProvider(userId, username)); return(provider); }
public XlsFormDefBuilder(IDataContext dataContext, BizForm form, Guid userId) { DataContext = dataContext; Form = form; UserId = userId; var providerFactory = AppServiceProviderFactoryProvider.GetFactory(); Provider = providerFactory.Create(dataContext, new UserDataProvider(UserId, "")); _formRepo = Provider.Get <IFormRepository>(); _sqlQueryBuilderFactory = Provider.Get <ISqlQueryBuilderFactory>(); _sqlQueryReaderFactory = Provider.Get <ISqlQueryReaderFactory>(); _comboBoxValueProvider = Provider.Get <IComboBoxEnumProvider>(); }
// public DynaDoc(Guid docId) : this(docId, Guid.Empty, null) { } /// <summary> /// Создает новый экземпляр документа /// </summary> /// <param name="docDefId">Идентификатор класса документа</param> /// <param name="userId">Идентификатор пользователя</param> /// <returns>Документ</returns> public static DynaDoc CreateNew(Guid docDefId, Guid userId) { //using (var docRepo = new DocRepository(userId)) //return new DynaDoc(/*docRepo.New(*/docDefId/*)*/, userId); var factory = AppServiceProviderFactoryProvider.GetFactory(); using (var provider = factory.Create()) { var docRepo = provider.Get <IDocRepository>(); return(new DynaDoc(docRepo.New(docDefId), userId)); } }
// TODO: Удалить конструктор public ComboBoxEnumProvider(IDataContext context, Guid userId) { DataContext = context; UserId = userId; var providerFactory = AppServiceProviderFactoryProvider.GetFactory(); var userData = new UserDataProvider(userId, ""); Provider = providerFactory.Create(context, userData); _orgRepo = new OrgRepository(context); _docDefRepo = new DocDefRepository(context, UserId); _userRepo = new UserRepository(DataContext); _enumRepo = new EnumRepository(Provider, context); }
public BizService(string userName) { _monitor = new Monitor("BizService session"); /*Connection = new EntityConnection("name=cissaEntities"); * _ownConnection = true;*/ CurrentUserName = userName; //var dc = new DataContext(Connection); var dataContextFactory = DataContextFactoryProvider.GetFactory(); _dataContext = dataContextFactory.CreateMultiDc(BaseServiceFactory.DataContextConfigSectionName); //new MultiDataContext(/*new[] { dc }*/); _ownDataContext = true; var providerFactory = AppServiceProviderFactoryProvider.GetFactory(); Provider = providerFactory.Create(DataContext); UserRepo = Provider.Get <IUserRepository>(); // new UserRepository(Provider); var serviceRegistrator = Provider.Get <IAppServiceProviderRegistrator>(); serviceRegistrator.AddService(new UserDataProvider(CurrentUserId, CurrentUserName)); EnumRepo = Provider.Get <IEnumRepository>(); //new EnumRepository(Provider); DocRepo = Provider.Get <IDocRepository>(); //new DocRepository(DataContext, CurrentUserId); DocDefRepo = Provider.Get <IDocDefRepository>(); FormRepo = Provider.Get <IFormRepository>(); //new FormRepository(DataContext, CurrentUserId); var workflowRepo = Provider.Get <IWorkflowRepository>(); //new WorkflowRepository(DataContext); WorkflowRepo = workflowRepo; WorkflowEngine = Provider.Get <IWorkflowEngine>(); //new WorkflowEngine(DataContext, workflowRepo, CurrentUserId); ReportGeneratorProvider = Provider.Get <ITemplateReportGeneratorProvider>(); //new TemplateReportGeneratorProvider(DataContext, CurrentUserId); //PdfTempRepo = new PdfTemplateRepository(DataContext, CurrentUserId); //ExcelTempRepo = new ExcelTemplateRepository(DataContext, CurrentUserId); LangRepo = Provider.Get <ILanguageRepository>(); _sqlQueryBuilderFactory = Provider.Get <ISqlQueryBuilderFactory>(); _sqlQueryReaderFactory = Provider.Get <ISqlQueryReaderFactory>(); _comboBoxValueProvider = Provider.Get <IComboBoxEnumProvider>(); _id = RegisterProcess(CurrentUserId, CurrentUserName); }
public Service() { if (dataContextFactory == null) { dataContextFactory = DataContextFactoryProvider.GetFactory(); if (dataContext == null) { dataContext = dataContextFactory.CreateMultiDc("DataContexts"); BaseServiceFactory.CreateBaseServiceFactories(); if (providerFactory == null) { providerFactory = AppServiceProviderFactoryProvider.GetFactory(); if (provider == null) { provider = providerFactory.Create(dataContext); } } } } }
public void ValidateSecurityUserName() { //using (var connection = new SqlConnection(ConnectionString)) { //using (var dataContext = new DataContext(connection)) { BaseServiceFactory.CreateBaseServiceFactories(); using (var multiDc = new MultiDataContext(BaseServiceFactory.DataContextConfigSectionName /*new[] {dataContext}*/)) { var providerFactory = AppServiceProviderFactoryProvider.GetFactory(); var serviceProvider = providerFactory.Create(multiDc); var userRepo = serviceProvider.Get <IUserRepository>(); //new UserRepository(dataContext); Console.WriteLine(userRepo.GetType().Name); Assert.IsTrue(userRepo.Validate("R", "803")); } } } }
public void TestMethod1() { var factory = AppServiceProviderFactoryProvider.GetFactory(); using (var provider = factory.Create()) { var prms = new StringParams(); prms.Params.Add("OrganizationMSEC", "МСЭК-1"); var temp = new ExcelTemplateRepository(provider, Guid.Empty); using (var stream = temp.Generate("F:\\Temp\\StatTalonGrown.xls", prms)) { stream.Position = 0; using (var file = new FileStream("f:\\temp\\outputGrowth.xls", FileMode.CreateNew)) { stream.CopyTo(file); } } } }
/* public static SqlQuery Build(Guid docDefId, Guid docStateId, BizForm filter, IEnumerable<AttributeSort> sortAttrs, IDataContext dataContext = null) * { * var query = new SqlQuery(docDefId, dataContext); * try * { * query.AddAttribute("&Id"); * query.AddCondition(ExpressionOperation.And, query.Source.GetDocDef(), "&State", ConditionOperation.Equal, * docStateId); * if (filter != null) * { * AddFormAttributes(query, query.Source, filter); * AddFormConditions(query, query.Source, filter); * } * else * AddDocDefAttributes(query, query.Source, query.Source.GetDocDef()); * * if (sortAttrs != null) * foreach (var attr in sortAttrs) * { * query.AddOrderAttribute(attr.AttributeId, attr.Asc); * } * * return query; * } * catch * { * query.Dispose(); * throw; * } * }*/ /*[Obsolete("Не завершенный метод!")] * private static void AddDocDefAttributes(SqlQuery query, SqlQuerySource source, DocDef docDef) * { * foreach (var attrDef in docDef.Attributes) * { * if (attrDef.Type.Id == (short) CissaDataType.Doc || attrDef.Type.Id == (short)CissaDataType.DocList) * { * // var slave = query.JoinSource(source, attrDef.DocDefType.Id, SqlSourceJoinType.Inner, attrDef.Id); * * query.AddAttribute(source, attrDef.Id); * } * else * { * query.AddAttribute(source, attrDef.Id); * } * } * }*/ public static SqlQuery Build(BizForm form, Guid?docStateId, BizForm filter, IEnumerable <AttributeSort> sortAttrs, Guid userId, IDataContext dataContext) { var factory = AppServiceProviderFactoryProvider.GetFactory(); using (var provider = factory.Create(dataContext)) { var sqb = new SqlQueryBuilderTool(provider, dataContext, userId); return(sqb.Build(form, docStateId, filter, sortAttrs)); } /*var query = new SqlQuery(dataContext, form.DocumentDefId ?? Guid.Empty, userId); * try * { * query.AddAttribute("&Id"); * if (docStateId != null) * query.AddCondition(ExpressionOperation.And, query.Source.GetDocDef(), "&State", * ConditionOperation.Equal, * (Guid) docStateId); * AddFormAttributes(query, query.Source, form); * if (filter != null) * AddFormConditions(query, query.Source, filter); * * if (sortAttrs != null) * foreach (var attr in sortAttrs) * query.AddOrderAttribute(attr.AttributeId, attr.Asc); * else * AddFormSortOrders(query, query.Source, form); * * return query; * } * catch * { * query.Dispose(); * throw; * }*/ }
public void TestMethod2() { using (var connection = new SqlConnection(ChatkalConnectionString)) { using (var dataContext = new DataContext(connection)) { using (var mdc = new MultiDataContext(new[] { dataContext })) { var factory = AppServiceProviderFactoryProvider.GetFactory(); using (var provider = factory.Create()) { var defRepo = provider.Get <IDocDefRepository>(); // new DocDefRepository(dataContext); var docDef = defRepo.DocDefByName("Person-Sheet"); using (var def = new XlsDef()) { // Header def.Style.FontName = "Arial Narrow"; def.AddArea().AddRow().AddEmptyCell(); def.AddArea().AddRow().AddText("Список граждан"); def.AddArea().AddRow().AddEmptyCell(); // Grid Header var h1 = def.AddArea().AddRow(); foreach (var attr in docDef.Attributes) { h1.AddNode(attr.Name).ShowAllBorders(true); } var qb = new QueryBuilder(docDef.Id); qb.Where("LastName").Contains("ИВАН"); var sqlQueryBuilder = provider.Get <ISqlQueryBuilder>(); var query = sqlQueryBuilder.Build(qb.Def); query.AddAttribute("&Id"); var list = new List <Guid>(); using (var r = new SqlQueryReader(dataContext, query)) while (r.Read()) { list.Add(r.GetGuid(0)); } using (var docDataSet = new DocDataSet(provider, dataContext, list, Guid.Empty)) { var gridRow = def.AddGrid(docDataSet).AddRow(); foreach (var attr in docDef.Attributes) { gridRow.ShowAllBorders(true); gridRow.Style.AutoWidth = true; gridRow.Style.AutoHeight = true; gridRow.AddDataField(new DocDataSetField(docDataSet, attr)); } var builder = new XlsBuilder(def); var workbook = builder.Build(); using ( var stream = new FileStream(@"c:\distr\cissa\testXlsDefPersons.xls", FileMode.Create)) { workbook.Write(stream); } } } } } } } }