internal void ProcessJob() { using (var db = new LogistoDb()) { var lastJobDate = db.Job.Max(w => w.Date); while (lastJobDate.Date < DateTime.Today) { lastJobDate = lastJobDate.AddDays(1); var schedules = db.Schedule.Where(w => w.Weekday == (int)lastJobDate.DayOfWeek).ToList(); if (schedules.Count > 0) { foreach (var item in schedules) // создать задания на день { db.InsertWithIdentity(new Job { Date = new DateTime(lastJobDate.Year, lastJobDate.Month, lastJobDate.Day, item.Hour, item.Minute, 0), ScheduleId = item.ID }); } } else { db.InsertWithIdentity(new Job { Date = lastJobDate, IsDone = true }); // создать пустое задание } } var job = db.Job.FirstOrDefault(w => !w.IsDone && (w.Date < DateTime.Now)); if (job != null) { db.Job.Where(w => w.ID == job.ID).Set(s => s.IsDone, true).Update(); if (job.ScheduleId > 0) { var schedule = db.Schedule.First(w => w.ID == job.ScheduleId); switch (schedule.ReportName) { case "Контроль дебиторской задолженности": var r = new RController(); r.ControllerContext = this.ControllerContext; var users = db.Users.ToList(); foreach (var user in users) { r.SendAccountsReceivableReport(user.ID); } break; case "Рассылка уведомлений клиентам": new NotificationMailer().SendNotificationOf_ChangeDocument(job.Date); break; } } } } }
public int CreateLegal(Legal legal) { using (var db = new LogistoDb()) { return(Convert.ToInt32(db.InsertWithIdentity(legal))); } }
public int CreateRouteContact(RouteContact contact) { using (var db = new LogistoDb()) { return(Convert.ToInt32(db.InsertWithIdentity(contact))); } }
public int CreateBank(Bank bank) { using (var db = new LogistoDb()) { return(Convert.ToInt32(db.InsertWithIdentity(bank))); } }
public int CreateAccountingRouteSegment(OrderAccountingRouteSegment segment) { using (var db = new LogistoDb()) { return(Convert.ToInt32(db.InsertWithIdentity(segment))); } }
public int CreateAccounting(Accounting accounting) { using (var db = new LogistoDb()) { return(Convert.ToInt32(db.InsertWithIdentity(accounting))); } }
public int CreatePayment(Payment payment) { using (var db = new LogistoDb()) { return(Convert.ToInt32(db.InsertWithIdentity(payment))); } }
public int CreateRole(IdentityRole role) { using (var db = new LogistoDb()) { return(Convert.ToInt32(db.InsertWithIdentity(role))); } }
public int CreatePersonPhone(PersonPhone phone) { using (var db = new LogistoDb()) { return(Convert.ToInt32(db.InsertWithIdentity(phone))); } }
public ActionResult ChangeEmployeePassword(ChangeEmployeePasswordViewModel model) { // TODO: check valid var hash = EncodePassword2(model.Password, model.EmployeeId.ToString()); using (var db = new LogistoDb()) { db.Employees.Where(w => w.ID == model.EmployeeId).Set(u => u.Password, hash).Update(); if (!db.ContractorEmployeeSettings.Any(w => w.EmployeeId == model.EmployeeId)) { db.InsertWithIdentity(new ContractorEmployeeSettings { ContractorId = model.ContractorId, EmployeeId = model.EmployeeId, Password = hash, IsEnUI = false, NotifyDocumentChanged = true, NotifyDocumentCreated = true, NotifyDocumentDeleted = true, NotifyEventCreated = true, NotifyStatusChanged = true, NotifyTemplatedDocumentChanged = true, NotifyTemplatedDocumentCreated = true }); } return(RedirectToAction("Index")); } }
public int CreateRequest(Request request) { using (var db = new LogistoDb()) { return(Convert.ToInt32(db.InsertWithIdentity(request))); } }
public int CreateTemplatedDocument(TemplatedDocument file) { using (var db = new LogistoDb()) { return(Convert.ToInt32(db.InsertWithIdentity(file))); } }
public int CreateDocument(Document document) { using (var db = new LogistoDb()) { return(Convert.ToInt32(db.InsertWithIdentity(document))); } }
public int CreateContractor(Contractor contractor) { using (var db = new LogistoDb()) { return(Convert.ToInt32(db.InsertWithIdentity(contractor))); } }
public void CreateContractCurrency(ContractCurrency entity) { using (var db = new LogistoDb()) { db.InsertWithIdentity(entity); } }
public int CreateContractMarksHistory(ContractMarksHistory entity) { using (var db = new LogistoDb()) { return(Convert.ToInt32(db.InsertWithIdentity(entity))); } }
public int CreateService(Service service) { using (var db = new LogistoDb()) { return(Convert.ToInt32(db.InsertWithIdentity(service))); } }
public int CreateParticipant(Participant entity) { using (var db = new LogistoDb()) { if (entity.FromDate.HasValue) { entity.FromDate = entity.FromDate.Value.Date; } if (entity.ToDate.HasValue) { entity.ToDate = entity.ToDate.Value.Date.AddDays(1).AddSeconds(-1); } var id = Convert.ToInt32(db.InsertWithIdentity(entity)); //if (entity.IsResponsible) //{ // // снять ответственность с другого участника // var workgroup = db.Participants.First(w => w.ID == id); // db.Participants.Where(w => w.ID != id && w.ContractorId == workgroup.ContractorId && w.OrderId == workgroup.OrderId) // .Set(u => u.IsResponsible, false) // .Update(); //} return(id); } }
public int CreatePricelist(Pricelist entity) { using (var db = new LogistoDb()) { return(Convert.ToInt32(db.InsertWithIdentity(entity))); } }
public int CreateBankAccount(BankAccount account) { using (var db = new LogistoDb()) { var id = Convert.ToInt32(db.InsertWithIdentity(account)); return(id); } }
public int CreateEmployee(Employee employee) { using (var db = new LogistoDb()) { var id = Convert.ToInt32(db.InsertWithIdentity(employee)); return(id); } }
public int CreateOrUpdateDocumentLog(DocumentLog data) { using (var db = new LogistoDb()) { // TODO: var id = Convert.ToInt32(db.InsertWithIdentity(data)); return(id); } }
public int CreateTemplatedDocumentData(TemplatedDocumentData data) { using (var db = new LogistoDb()) { var id = Convert.ToInt32(db.InsertWithIdentity(data)); if (data.Data != null) { File.WriteAllBytes(TEMPLATED_DOCUMENTS_ROOT + id, data.Data); } return(id); } }
public void AddUserToRole(int userId, int roleId) { using (var db = new LogistoDb()) { var rel = db.IdentityUserInRoles.FirstOrDefault(w => w.UserId == userId && w.RoleId == roleId); if (rel == null) { db.InsertWithIdentity(new IdentityUserInRole { UserId = userId, RoleId = roleId }); } } }
public int CreateUser(IdentityUser user) { using (var db = new LogistoDb()) { var userId = Convert.ToInt32(db.InsertWithIdentity(user)); var userManager = new UserManager(new UserStore(new LogistoDb()), Startup.IdentityFactoryOptions, new EmailService()); var stamp = userManager.PasswordHasher; // добавить аккаунт var account = new IdentityAccount { CreatedDate = DateTime.Now, IsApproved = true, Password = stamp.HashPassword("123456789"), // default password UserId = userId }; db.InsertWithIdentity(account); return(userId); } }
public void InitPricelist(int id, int productId) { using (var db = new LogistoDb()) { var sks = db.ServiceKinds.Where(w => w.ProductId == productId).ToList(); foreach (var item in sks) { db.InsertWithIdentity(new PriceKind { PricelistId = id, ServiceKindId = item.ID, Name = item.Name, EnName = item.EnName }); } var skids = db.ServiceKinds.Where(w => w.ProductId == productId).Select(s => s.ID).ToList(); var services = db.ServiceTypes.Where(w => skids.Contains(w.ServiceKindId)).ToList(); var query = from sk in db.ServiceKinds join s in db.ServiceTypes on sk.ID equals s.ServiceKindId where sk.ProductId == productId select new { sk, s }; foreach (var item in query.ToList()) { db.InsertWithIdentity(new Price { CurrencyId = 1, PricelistId = id, ServiceId = item.s.ID, VatId = item.sk.VatId.Value, Sum = item.s.Price ?? 0, Count = item.s.Count ?? 1 }); } } }
public async Task CreateAsync(IdentityUser user) { ThrowIfDisposed(); if (user == null) { throw new ArgumentNullException("user"); } await Task.Run(() => { using (var usersDb = new LogistoDb()) { user.Id = Convert.ToInt32(usersDb.InsertWithIdentity(user)); } }); }
public void FixPricelistKinds(int id, int productId) { using (var db = new LogistoDb()) { var sks = db.ServiceKinds.Where(w => w.ProductId == productId).ToList(); foreach (var item in sks) { if (!db.PriceKinds.Any(w => w.PricelistId == id && w.ServiceKindId == item.ID)) { db.InsertWithIdentity(new PriceKind { PricelistId = id, ServiceKindId = item.ID, Name = item.Name, EnName = item.EnName }); } } } }
public void ImportPricelist(int fromPricelistId, int toPricelistId) { using (var db = new LogistoDb()) { var prices = db.Prices.Where(w => w.PricelistId == fromPricelistId); foreach (var item in prices.ToList()) { db.InsertWithIdentity(new Price { CurrencyId = item.CurrencyId, PricelistId = toPricelistId, ServiceId = item.ServiceId, VatId = item.VatId, Sum = item.Sum, Count = item.Count }); } } }
public void AllowRole(int actionId, int participantRoleId, bool allow) { using (var db = new LogistoDb()) { if (allow) { var permission = db.ParticipantPermissions.FirstOrDefault(w => w.ActionId == actionId && w.ParticipantRoleId == participantRoleId); if (permission == null) { db.InsertWithIdentity(new ParticipantPermission { ActionId = actionId, ParticipantRoleId = participantRoleId }); } } else { db.ParticipantPermissions.Delete(w => w.ActionId == actionId && w.ParticipantRoleId == participantRoleId); } } }