Esempio n. 1
0
        public ActionResult SigningConfirm(Guid taskId)
        {
            Database.DataModel.Task task = db.Tasks.Include(o => o.Document).FirstOrDefault(o => o.Id == taskId);

            //var dictionaries = _db.Dictionaries.Where(o => o.Type == "Nomenclature" && o.IsGuide).ToList().Select(o => o.Id.ToString());

            Activity parentActivity = db.Activities.FirstOrDefault(x => x.DocumentId == task.DocumentId && x.Branch == 0 && !db.Activities.Where(o => o.DocumentId == task.DocumentId && o.Branch == 0).Select(c => c.ParentId).Contains(x.Id));

            Activity activity = new Activity
            {
                Id = Guid.NewGuid(),
                //	ParentTask = task.Id,
                DocumentId     = task.DocumentId,
                AuthorId       = UserHelper.GetCurrentEmployee().Id.ToString(),
                AuthorValue    = UserHelper.GetCurrentEmployee().DisplayName.ToString(),
                ExecutorsId    = task.AuthorId,
                ExecutorsValue = task.AuthorValue,
                //ResponsibleId = DictionaryHelper.GetItemsId(taskAction.ResponsibleId),
                //ResponsibleValue = DictionaryHelper.GetItemsName(taskAction.ResponsibleId),
                Type          = 4,
                IsParrent     = parentActivity == null,
                CreatedDate   = DateTime.Now,
                ParentId      = parentActivity == null ? (Guid?)null : parentActivity.Id,
                ExecutionDate = task.Document.ExecutionDate,
                Text          = "На регистрацию",
                IsNotActive   = true,
                //IsMainLine = task.IsMainLine
            };

            db.Activities.Add(activity);
            db.SaveChanges();



            Report report = new Report()
            {
                Id            = Guid.NewGuid(),
                TaskId        = task.Id,
                ExecutionDate = DateTime.Now,
                Type          = task.TypeEx == 1 ? 1 : 0,
                DocumentId    = task.DocumentId
            };

            task.State             = 2;
            task.DateOfOperation   = task.DateOfOperation ?? DateTime.Now;
            task.IsNotification    = false;
            task.NotificationCount = 0;
            db.Reports.Add(report);

            db.SaveChanges();

            return
                (Json(
                     new
            {
                State = true,
                Task =
                    new { task.Id, task.Type, task.State, task.Document.MonitoringType, DocumentState = task.Document.StateType }
            }));
        }
Esempio n. 2
0
        private void SendPrice(Guid id, bool isSgined, string xmlAuditForm)
        {
            Document baseDocument = db.Documents.FirstOrDefault(m => m.Id == id);

            if (baseDocument == null)
            {
                var      user     = UserHelper.GetCurrentEmployee();
                Document document = new Document()
                {
                    Id                  = id,
                    DocumentType        = 0,
                    ProjectType         = 0,
                    ExecutionDate       = DateTime.Now.AddDays(30),
                    DocumentDate        = DateTime.Now,
                    AttachPath          = FileHelper.GetObjectPathRoot(),
                    CorrespondentsInfo  = UserHelper.GetCurrentEmployee().DisplayName,
                    CorrespondentsId    = user.Id.ToString(),
                    CorrespondentsValue = user.DisplayName,
                    IsTradeSecret       = false
                };
                var project = db.PriceProjects.First(o => o.Id == id);

                project.Status          = (int)PriceProjectStatus.OnRegistration;
                project.IsSended        = true;
                project.IsSigned        = isSgined;
                db.Entry(project).State = EntityState.Modified;
                db.Documents.Add(document);
                if (project.Type == 2)
                {
                    var prices = db.Prices.Where(e => e.PriceProjectId == project.PriceProjectId);
                    foreach (var price in prices)
                    {
                        var newPrice = new Price()
                        {
                            Type        = price.Type,
                            AvgObkCost  = price.AvgObkCost,
                            AvgOptCost  = price.AvgOptCost,
                            AvgOptPrice = price.AvgOptPrice,
                            AvgOptPriceCurrencyDicId = price.AvgOptPriceCurrencyDicId,
                            AvgOptPriceNote          = price.AvgOptPriceNote,
                            AvgRozPrice = price.AvgRozPrice,
                            AvgRozPriceCurrencyDicId = price.AvgRozPriceCurrencyDicId,
                            AvgRozPriceNote          = price.AvgRozPriceNote,
                            AvgRznCost                     = price.AvgRznCost,
                            BritishCost                    = price.BritishCost,
                            BritishPrice                   = price.BritishPrice,
                            CalcDateEnd                    = price.CalcDateEnd,
                            CalcDateStart                  = price.CalcDateStart,
                            CipPrice                       = price.CipPrice,
                            CipPriceCurrencyDicId          = price.CipPriceCurrencyDicId,
                            CountryId                      = price.CountryId,
                            CreatedDate                    = price.CreatedDate,
                            Description                    = price.Description,
                            LimitCost                      = price.LimitCost,
                            LimitPrice                     = price.LimitPrice,
                            LimitPriceCurrencyDicId        = price.LimitPriceCurrencyDicId,
                            LimitPriceNote                 = price.LimitPriceNote,
                            ManufacturerPrice              = price.ManufacturerPrice,
                            ManufacturerPriceCurrencyDicId = price.ManufacturerPriceCurrencyDicId,
                            ManufacturerPriceNote          = price.ManufacturerPriceNote,
                            MarkupCost                     = price.MarkupCost,
                            MarkupCostOpt                  = price.MarkupCostOpt,
                            MinimalCost                    = price.MinimalCost,
                            MtPartsId                      = price.MtPartsId,
                            Name                    = price.Name,
                            OriginalCost            = price.OriginalCost,
                            OwnerPrice              = price.OwnerPrice,
                            OwnerPriceCurrencyDicId = price.OwnerPriceCurrencyDicId,
                            PriceProjectId          = project.Id,
                            RefPrice                = price.RefPrice,
                            RefPriceCurrencyDicId   = price.RefPriceCurrencyDicId,
                            RefPriceTypeDicId       = price.RefPriceTypeDicId,
                            RequestDate             = price.RequestDate,
                            UnitPrice               = price.UnitPrice,
                            UnitPriceCurrencyDicId  = price.UnitPriceCurrencyDicId,
                            ZakupCost               = price.ZakupCost,
                            Id = Guid.NewGuid()
                        };
                        db.Prices.Add(newPrice);
                    }
                }
                db.SaveChanges();
                SendNewAppNotification(id);
            }
            else
            {
                baseDocument.IsTradeSecret = false;
                Document baseDocument2 =
                    db.Documents.Where(m => m.DocumentType == 1)
                    .OrderByDescending(m => m.CreatedDate)
                    .FirstOrDefault(m => m.AnswersId == id.ToString());


                var project = db.PriceProjects.FirstOrDefault(o => o.Id == baseDocument.Id);
                if (project != null)
                {
                    project.Status          = (int)PriceProjectStatus.Registered;
                    db.Entry(project).State = EntityState.Modified;
                    project.IsSended        = true;
                    project.IsSigned        = isSgined;
                    db.SaveChanges();
                }

                if (baseDocument2 != null && !string.IsNullOrEmpty(baseDocument2.RegistratorId))
                {
                    if (baseDocument.CountDay > 0)
                    {
                        baseDocument.CompareConterDate = DateTime.Now.AddDays(baseDocument.CountDay.Value - 30);
                    }
                    baseDocument.CountDay = null;

                    var registartor = db.Employees.FirstOrDefault(x => x.Id == new Guid(baseDocument2.RegistratorId));
                    if (registartor != null)
                    {
                        new NotificationManager().SendNotification(
                            string.Format("Заявление №{0} исправлено заявителем",
                                          string.IsNullOrEmpty(baseDocument.OutgoingNumber)
                                    ? baseDocument.Number
                                    : baseDocument.OutgoingNumber),
                            ObjectType.Letter, baseDocument2.Id, registartor.Id);
                    }
                }

                if (baseDocument2 != null && baseDocument2.MainTaskId != null)
                {
                    Database.DataModel.Task task = db.Tasks.FirstOrDefault(m => m.Id == baseDocument2.MainTaskId);
                    if (task != null)
                    {
                        Activity activity = new Activity
                        {
                            Id             = Guid.NewGuid(),
                            ParentTask     = task.Id,
                            DocumentId     = task.DocumentId,
                            AuthorId       = UserHelper.GetCurrentEmployee().Id.ToString(),
                            AuthorValue    = UserHelper.GetCurrentEmployee().DisplayName,
                            ExecutorsId    = task.ExecutorId,
                            ExecutorsValue = task.ExecutorValue,
                            Type           = 2,
                            IsParrent      = false,
                            CreatedDate    = DateTime.Now,
                            ParentId       = task.ActivityId,
                            ExecutionDate  = task.Document.ExecutionDate,
                            Text           = "Замечания исправлены",
                            IsNotActive    = false,
                            TypeEx         = task.Stage,
                        };
                        db.Activities.Add(activity);
                        db.SaveChanges();
                    }
                }
            }
            var note = "";

            if (isSgined)
            {
                note = "Заявление отправлено. Дата отправки:" + DateTime.Now;
            }
            else
            {
                note = "Заявление отправлено без подписи. Дата отправки:" + DateTime.Now;
            }
            var history = new PriceProjectsHistory()
            {
                DateCreate     = DateTime.Now,
                PriceProjectId = id,
                XmlSign        = xmlAuditForm,
                StatusId       = (int)PriceProjectStatus.Registered,
                UserId         = UserHelper.GetCurrentEmployee().Id,
                Note           = note
            };

            db.PriceProjectsHistories.Add(history);
            db.SaveChanges();

            if (!isSgined)
            {
                new NotificationManager().SendNotification(
                    "Предупреждение! Отправленно без подписи ЭЦП, необходимо распечатать заявления и принести в НЦЭЛС.",
                    ObjectType.PriceProject, id, UserHelper.GetCurrentEmployee().Id);
            }
        }