예제 #1
0
        /// <summary>
        /// Конвертирование во внутренний документ
        /// </summary>
        /// <param name="objectContext"></param>
        /// <param name="project"></param>
        /// <param name="currentEmployee"></param>
        /// <param name="singInfo">Информация о подписывающем</param>
        public static void ConvertInCorrespondentDocument(Document document, Document project, Employee currentEmployee,
                                                          string singInfo)
        {
            ncelsEntities context  = UserHelper.GetCn();
            Template      template = context.Templates.First(o => o.Id == project.TemplateId);

            document.QrCode = GetQrCode(GetTextQRcode(singInfo, !string.IsNullOrEmpty(project.Digest)));
            //Template convTemplate = context.Templates.First(o => o.Id == template.ConvertDictionaryTypeId);
            //document.DocumentDictionaryTypeId = convTemplate.DictionaryTypeId;
            //document.DocumentDictionaryTypeValue = convTemplate.DictionaryTypeValue;
            document.MainTaskId       = project.MainTaskId;
            document.MainDocumentId   = project.MainDocumentId;
            document.SourceId         = project.Id.ToString();
            document.SourceValue      = project.DisplayName;
            document.RegistratorValue = currentEmployee.DisplayName;
            document.RegistratorId    = currentEmployee.Id.ToString();
            document.DocumentType     = 5;
            document.TemplateId       = context.Templates.First().Id;

            document.IsDeleted     = false;
            document.DocumentDate  = document.CreatedDate = document.ModifiedDate = DateTime.Now;
            document.ExecutionDate = document.ExecutionDate.HasValue ? document.ExecutionDate : DateTime.Now.AddDays(15);
            document.IsAttachments = false;
            document.AttachPath    = FileHelper.GetObjectPathRoot();

            if (document.ApplicantType == 0)
            {
                document.StateType = 2;
                Registrator.SetNumber(document);
                context.Activities.Add(GetNewActivity(document));
                CopyFile(project.AttachPath.ToString(), document.AttachPath.ToString());
                ReplaceText(document.AttachPath.ToString(), "Проект.docx", "DocumentNumber", document.Number);
                ReplaceText(document.AttachPath.ToString(), "Проект.docx", "DocumentDate",
                            document.DocumentDate.Value.ToString("dd.MM.yyyy"));
            }
            else
            {
                var items = DictionaryHelper.GetItems(document.ExecutorsId, document.ExecutorsValue).Select(o => new Guid(o.Id)).ToList();

                var employes = context.Employees.Where(o => items.Contains(o.Id)).ToList();
                var orgId    = new Guid("8F0B91F3-AF29-4D3C-96D6-019CBBDFC8BE");
                if (employes.Select(o => o.OrganizationId).Contains(orgId))
                {
                    document.OrganizationId = orgId;
                }


                CopyFile(project.AttachPath.ToString(), document.AttachPath.ToString());
                document.StateType = 0;
                document.Number    = null;
            }

            project.DestinationId    = document.Id.ToString();
            project.DestinationValue = document.Number;

            context.Documents.Add(document);
            context.SaveChanges();
        }
예제 #2
0
        public static void ConvertInAdminDocument(Document document, Document project, Employee currentEmployee,
                                                  string singInfo)
        {
            ncelsEntities context  = UserHelper.GetCn();
            Template      template = context.Templates.First(o => o.Id == project.TemplateId);

            document.QrCode = GetQrCode(GetTextQRcode(singInfo, !string.IsNullOrEmpty(project.Digest)));
            //Template convTemplate = context.Templates.First(o => o.Id == template.ConvertDictionaryTypeId);
            //document.DocumentDictionaryTypeId = convTemplate.DictionaryTypeId;
            //document.DocumentDictionaryTypeValue = convTemplate.DictionaryTypeValue;
            document.MainTaskId       = project.MainTaskId;
            document.MainDocumentId   = project.MainDocumentId;
            document.SourceId         = project.Id.ToString();
            document.SourceValue      = project.DisplayName;
            document.RegistratorValue = currentEmployee.DisplayName;
            document.RegistratorId    = currentEmployee.Id.ToString();
            document.DocumentType     = 3;
            document.TemplateId       = context.Templates.First().Id;

            document.IsDeleted     = false;
            document.DocumentDate  = document.CreatedDate = document.ModifiedDate = DateTime.Now;
            document.ExecutionDate = document.ExecutionDate.HasValue ? document.ExecutionDate : DateTime.Now.AddDays(15);
            document.IsAttachments = false;
            document.AttachPath    = FileHelper.GetObjectPathRoot();

            CopyFile(project.AttachPath.ToString(), document.AttachPath.ToString());

            if (document.ProjectType == 4)
            {
                document.StateType = 2;
                Registrator.SetNumber(document);
                context.Activities.Add(GetNewActivity(document));
                ReplaceText(document.AttachPath.ToString(), "Проект.docx", "DocumentNumber", document.Number);
                ReplaceText(document.AttachPath.ToString(), "Проект.docx", "DocumentDate", document.DocumentDate.Value.ToString("dd.MM.yyyy"));
            }
            if (document.ProjectType == 3)
            {
                document.Number    = null;
                document.StateType = 0;
            }
            if (document.ProjectType == 6)
            {
                document.Number    = null;
                document.StateType = 0;
            }
            context.Documents.Add(document);
            context.SaveChanges();
        }