コード例 #1
0
        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;
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: LegalLogic.cs プロジェクト: sergeysy/Novelco
 public int CreateLegal(Legal legal)
 {
     using (var db = new LogistoDb())
     {
         return(Convert.ToInt32(db.InsertWithIdentity(legal)));
     }
 }
コード例 #3
0
ファイル: LegalLogic.cs プロジェクト: sergeysy/Novelco
 public int CreateRouteContact(RouteContact contact)
 {
     using (var db = new LogistoDb())
     {
         return(Convert.ToInt32(db.InsertWithIdentity(contact)));
     }
 }
コード例 #4
0
ファイル: BankLogic.cs プロジェクト: sergeysy/Novelco
 public int CreateBank(Bank bank)
 {
     using (var db = new LogistoDb())
     {
         return(Convert.ToInt32(db.InsertWithIdentity(bank)));
     }
 }
コード例 #5
0
ファイル: AccountingLogic.cs プロジェクト: sergeysy/Novelco
 public int CreateAccountingRouteSegment(OrderAccountingRouteSegment segment)
 {
     using (var db = new LogistoDb())
     {
         return(Convert.ToInt32(db.InsertWithIdentity(segment)));
     }
 }
コード例 #6
0
ファイル: AccountingLogic.cs プロジェクト: sergeysy/Novelco
 public int CreateAccounting(Accounting accounting)
 {
     using (var db = new LogistoDb())
     {
         return(Convert.ToInt32(db.InsertWithIdentity(accounting)));
     }
 }
コード例 #7
0
ファイル: AccountingLogic.cs プロジェクト: sergeysy/Novelco
 public int CreatePayment(Payment payment)
 {
     using (var db = new LogistoDb())
     {
         return(Convert.ToInt32(db.InsertWithIdentity(payment)));
     }
 }
コード例 #8
0
 public int CreateRole(IdentityRole role)
 {
     using (var db = new LogistoDb())
     {
         return(Convert.ToInt32(db.InsertWithIdentity(role)));
     }
 }
コード例 #9
0
 public int CreatePersonPhone(PersonPhone phone)
 {
     using (var db = new LogistoDb())
     {
         return(Convert.ToInt32(db.InsertWithIdentity(phone)));
     }
 }
コード例 #10
0
ファイル: HomeController.cs プロジェクト: sergeysy/Novelco
        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"));
            }
        }
コード例 #11
0
ファイル: RequestLogic.cs プロジェクト: sergeysy/Novelco
 public int CreateRequest(Request request)
 {
     using (var db = new LogistoDb())
     {
         return(Convert.ToInt32(db.InsertWithIdentity(request)));
     }
 }
コード例 #12
0
ファイル: DocumentLogic.cs プロジェクト: sergeysy/Novelco
 public int CreateTemplatedDocument(TemplatedDocument file)
 {
     using (var db = new LogistoDb())
     {
         return(Convert.ToInt32(db.InsertWithIdentity(file)));
     }
 }
コード例 #13
0
ファイル: DocumentLogic.cs プロジェクト: sergeysy/Novelco
 public int CreateDocument(Document document)
 {
     using (var db = new LogistoDb())
     {
         return(Convert.ToInt32(db.InsertWithIdentity(document)));
     }
 }
コード例 #14
0
ファイル: ContractorLogic.cs プロジェクト: sergeysy/Novelco
 public int CreateContractor(Contractor contractor)
 {
     using (var db = new LogistoDb())
     {
         return(Convert.ToInt32(db.InsertWithIdentity(contractor)));
     }
 }
コード例 #15
0
ファイル: ContractLogic.cs プロジェクト: sergeysy/Novelco
 public void CreateContractCurrency(ContractCurrency entity)
 {
     using (var db = new LogistoDb())
     {
         db.InsertWithIdentity(entity);
     }
 }
コード例 #16
0
ファイル: ContractLogic.cs プロジェクト: sergeysy/Novelco
 public int CreateContractMarksHistory(ContractMarksHistory entity)
 {
     using (var db = new LogistoDb())
     {
         return(Convert.ToInt32(db.InsertWithIdentity(entity)));
     }
 }
コード例 #17
0
ファイル: AccountingLogic.cs プロジェクト: sergeysy/Novelco
 public int CreateService(Service service)
 {
     using (var db = new LogistoDb())
     {
         return(Convert.ToInt32(db.InsertWithIdentity(service)));
     }
 }
コード例 #18
0
ファイル: ParticipantLogic.cs プロジェクト: sergeysy/Novelco
        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);
            }
        }
コード例 #19
0
ファイル: PricelistLogic.cs プロジェクト: sergeysy/Novelco
 public int CreatePricelist(Pricelist entity)
 {
     using (var db = new LogistoDb())
     {
         return(Convert.ToInt32(db.InsertWithIdentity(entity)));
     }
 }
コード例 #20
0
ファイル: BankLogic.cs プロジェクト: sergeysy/Novelco
 public int CreateBankAccount(BankAccount account)
 {
     using (var db = new LogistoDb())
     {
         var id = Convert.ToInt32(db.InsertWithIdentity(account));
         return(id);
     }
 }
コード例 #21
0
 public int CreateEmployee(Employee employee)
 {
     using (var db = new LogistoDb())
     {
         var id = Convert.ToInt32(db.InsertWithIdentity(employee));
         return(id);
     }
 }
コード例 #22
0
ファイル: DocumentLogic.cs プロジェクト: sergeysy/Novelco
 public int CreateOrUpdateDocumentLog(DocumentLog data)
 {
     using (var db = new LogistoDb())
     {
         // TODO:
         var id = Convert.ToInt32(db.InsertWithIdentity(data));
         return(id);
     }
 }
コード例 #23
0
ファイル: DocumentLogic.cs プロジェクト: sergeysy/Novelco
        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);
            }
        }
コード例 #24
0
 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
             });
         }
     }
 }
コード例 #25
0
        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);
            }
        }
コード例 #26
0
ファイル: PricelistLogic.cs プロジェクト: sergeysy/Novelco
        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
                    });
                }
            }
        }
コード例 #27
0
ファイル: UserStore.cs プロジェクト: sergeysy/Novelco
        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));
                }
            });
        }
コード例 #28
0
ファイル: PricelistLogic.cs プロジェクト: sergeysy/Novelco
 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
                 });
             }
         }
     }
 }
コード例 #29
0
ファイル: PricelistLogic.cs プロジェクト: sergeysy/Novelco
        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
                    });
                }
            }
        }
コード例 #30
0
ファイル: ParticipantLogic.cs プロジェクト: sergeysy/Novelco
 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);
         }
     }
 }