public void Add(uint clientId, User client = null) { /*Грязный ХАК, почему-то если принудительно не загрузить так, не делается Service.FindAndCheck<Service>(clientId)*/ DbSession.Get <Client>(clientId); DbSession.Get <Supplier>(clientId); var service = client == null?Service.FindAndCheck <Service>(clientId) : client.RootService; var user = client ?? new User(service); PropertyBag["UserMessage"] = "Текст сообщения"; PropertyBag["deliveryAddress"] = ""; PropertyBag["account"] = user.Accounting; if (client == null) { PropertyBag["UseDefPermession"] = true; PropertyBag["SendToEmail"] = true; //Для вьюшки - по умолчанию должен быть True. //Но в модели мы это не можем разместить, так как по здравому смыслу он по-умолчанию false. //Так мы избежим лишних действий по созданию прав на директории user.FtpAccess = true; var rejectWaibillParams = new RejectWaibillParams().Get(clientId, DbSession); user.SendWaybills = rejectWaibillParams.SendWaybills; user.SendRejects = rejectWaibillParams.SendRejects; } PropertyBag["phonesForSendToUserList"] = user.GetPhonesForSendingSms(); //"9031848398"; PropertyBag["phonesForSendToAdminList"] = GetAdminByRegionForSms(user.RootService.HomeRegion.Id); PropertyBag["client"] = service; if (service.IsClient()) { PropertyBag["drugstore"] = ((Client)service).Settings; var organizations = ((Client)service).Orgs().ToArray(); if (organizations.Length == 1) { PropertyBag["address"] = new Address { LegalEntity = organizations.First() }; } PropertyBag["Organizations"] = organizations; PropertyBag["permissions"] = UserPermission.FindPermissionsForDrugstore(DbSession); } else { PropertyBag["singleRegions"] = true; PropertyBag["registerSupplierUser"] = true; PropertyBag["availibleRegions"] = ((Supplier)service).RegionMask; PropertyBag["permissions"] = UserPermission.FindPermissionsByType(DbSession, UserPermissionTypes.SupplierInterface); } PropertyBag["user"] = user; PropertyBag["ExcelPermissions"] = UserPermission.FindPermissionsByType(DbSession, UserPermissionTypes.AnalitFExcel); PropertyBag["AccessPermissions"] = UserPermission.FindPermissionsByType(DbSession, UserPermissionTypes.AnalitFPrint) .Where(r => r.Shortcut == "ORDR" || r.Shortcut == "CASH" || r.Shortcut == "STCK").ToArray(); PropertyBag["PrintPermissions"] = UserPermission.FindPermissionsByType(DbSession, UserPermissionTypes.AnalitFPrint) .Where(r => r.Shortcut != "ORDR" && r.Shortcut != "CASH" && r.Shortcut != "STCK").ToArray(); PropertyBag["emailForSend"] = user.GetAddressForSendingClientCard(); PropertyBag["EmailContactType"] = ContactType.Email; PropertyBag["PhoneContactType"] = ContactType.Phone; PropertyBag["regions"] = Region.All(DbSession).ToArray(); IList <Payer> payers = new List <Payer>(); if (service.IsClient()) { payers = ((Client)service).Payers; } else { payers = new List <Payer> { DbSession.Load <Supplier>(service.Id).Payer } }; if (payers.Count == 1) { user.Payer = payers.First(); PropertyBag["onePayer"] = true; } else { PropertyBag["onePayer"] = false; } PropertyBag["Payers"] = payers; PropertyBag["maxRegion"] = UInt64.MaxValue; PropertyBag["UserRegistration"] = true; PropertyBag["defaultSettings"] = Defaults; }
public virtual List <Region> GetRegions() { return(Region.All(BaseController.CurrentDbSession).Where(r => (r.Id & WorkRegionMask) > 0).ToList()); }
public ConfigService() { DataDragonBaseUrl = GetAppSetting <string>("DataDragonBaseUrl"); DefaultRegion = Region.All().Single(r => r.Name == GetAppSetting <string>("DefaultRegion")); }
public virtual List <Region> GetRegions(ISession session) { return(Region.All(session).Where(r => (r.Id & WorkRegionMask) > 0).ToList()); }
private bool ShouldBeFull(Region region) { return(region.All(v => state.TargetMatrix[v])); }
public IList <UpdateLogView> Find(ISession s) { var projectionsList = new List <IProjection> { Projections.Property("Id").As("Id"), Projections.Property("Addition").As("Addition"), Projections.Property("Commit").As("Commit"), Projections.Property("AppVersion").As("AppVersion"), Projections.Property("ResultSize").As("ResultSize"), Projections.Property("UpdateType").As("UpdateType"), Projections.Property("RequestTime").As("RequestTime"), Projections.Alias(Projections.Conditional(Restrictions.IsNotNull("Log"), Projections.Constant(1), Projections.Constant(0)), "HaveLog"), Projections.Property("u.Id").As("UserId"), Projections.Property("u.Name").As("UserName"), Projections.Property("u.Login").As("Login"), Projections.Property("c.Id").As("ClientId"), Projections.Property("c.Name").As("ClientName"), Projections.SqlProjection("c2_.RegionCode as RegionId", new[] { "RegionId" }, new[] { NHibernateUtil.String }) }; if (UpdateType == Models.Logs.UpdateType.AccessError) { projectionsList.Add(Projections.ProjectionList().Add(Projections.Alias(Projections.SubQuery(DetachedCriteria.For <UpdateLogEntity>("ule") .Add(Restrictions.EqProperty("ue.User", "ule.User")) .Add(Restrictions.Eq("ule.Commit", true)) .Add(Restrictions.In("ule.UpdateType", new object[] { Models.Logs.UpdateType.Accumulative, Models.Logs.UpdateType.Cumulative, Models.Logs.UpdateType.LimitedCumulative, Models.Logs.UpdateType.AutoOrder, Models.Logs.UpdateType.LoadingDocuments })) .Add(Restrictions.GtProperty("ule.RequestTime", "ue.RequestTime")) .SetProjection(Projections.ProjectionList() .Add(Projections.Conditional(Restrictions.Gt( Projections.Count(Projections.Property("ule.Id")), 0), Projections.Constant(1), Projections.Constant(0))))), "OkUpdate"))); } var criteria = s.CreateCriteria <UpdateLogEntity>("ue") .CreateAlias("User", "u", JoinType.InnerJoin) .CreateAlias("u.Client", "c", JoinType.LeftOuterJoin) .SetProjection(projectionsList.ToArray()); if (User != null) { criteria.Add(Restrictions.Eq("User", User)); } if (Client != null) { criteria.Add(Restrictions.Eq("u.Client", Client)); } if (UpdateType != null) { criteria.Add(Restrictions.Eq("UpdateType", UpdateType)); } criteria .Add(Restrictions.Ge("RequestTime", BeginDate)) .Add(Restrictions.Le("RequestTime", EndDate.AddDays(1))); var regionMask = RegionMask; if (regionMask == 0) { regionMask = SecurityContext.Administrator.RegionMask; } else { regionMask = RegionMask & SecurityContext.Administrator.RegionMask; } criteria.Add(Restrictions.Gt(Projections2.BitOr("u.WorkRegionMask", regionMask), 0)); ApplySort(criteria); if (SortBy != "RequestTime") { criteria.AddOrder(Order.Desc("RequestTime")); } var items = criteria.ToList <UpdateLogView>(); var regions = Region.All(s); items.Where(i => i.RegionId != null).Each(i => { var region = regions.FirstOrDefault(r => r.Id == i.RegionId.Value); if (region == null) { return; } i.Region = region.Name; }); if (String.Equals(SortBy, "Region", StringComparison.OrdinalIgnoreCase)) { if (IsDesc()) { items = items.OrderByDescending(i => i.Region).ToList(); } else { items = items.OrderBy(i => i.Region).ToList(); } var bufList = new List <UpdateLogView>(); var groupItems = items.GroupBy(i => i.Region); groupItems.Each(g => bufList.AddRange(g.OrderByDescending(i => i.RequestTime).ToList())); items = bufList; } return(items); }
public void Edit(ulong id, [DataBind("DefaultRegions")] ulong[] defaultRegions, [DataBind("DefaultShowRegion")] ulong[] defaultShowRegion, [DataBind("SuppliersMarkup")] Markup[] suppliersMarkup, [DataBind("DrugstoreMarkup")] Markup[] drugstoreMarkup) { var region = DbSession.Load <Region>(id); var qsuppliersMarkup = DbSession.Query <Markup>() .Where(m => m.RegionId == region.Id && m.Type == 0).ToList(); var qdrugstoreMarkup = DbSession.Query <Markup>() .Where(m => m.RegionId == region.Id && m.Type == 1).ToList(); foreach (var limit in MarkupLimits.markupLimits) { if (!qsuppliersMarkup.Any(m => m.Begin == limit.Begin && m.End == limit.End)) { var markup = new Markup { RegionId = region.Id, Type = 0, Begin = limit.Begin, End = limit.End }; qsuppliersMarkup.Add(markup); DbSession.Save(markup); } if (!qdrugstoreMarkup.Any(m => m.Begin == limit.Begin && m.End == limit.End)) { var markup = new Markup { RegionId = region.Id, Type = 1, Begin = limit.Begin, End = limit.End }; qdrugstoreMarkup.Add(markup); DbSession.Save(markup); } } if (IsPost) { BindObjectInstance(region, "region"); region.DefaultRegionMask = defaultRegions.Aggregate(0UL, (v, a) => a + v); region.DefaultShowRegionMask = defaultShowRegion.Aggregate(0UL, (v, a) => a + v); if (IsValid(region)) { DbSession.Save(region); foreach (var markup in qsuppliersMarkup) { markup.Value = suppliersMarkup.Where(x => x.Id == markup.Id).FirstOrDefault().Value; DbSession.Update(markup); } foreach (var markup in qdrugstoreMarkup) { markup.Value = drugstoreMarkup.Where(x => x.Id == markup.Id).FirstOrDefault().Value; DbSession.Update(markup); } Notify("Сохранено"); RedirectToReferrer(); } } var regions = Region.All(DbSession); PropertyBag["region"] = region; PropertyBag["childRegions"] = regions.Where(x => x.Parent == region).ToList(); PropertyBag["AllRegions"] = regions; PropertyBag["SuppliersMarkup"] = qsuppliersMarkup; PropertyBag["DrugstoreMarkup"] = qdrugstoreMarkup; }
public void Index() { PropertyBag["regions"] = Region.All(DbSession); }