private void sendApproval(String role, StaffEmployee Performer, int performingType)
        {
            KindsCardKind kind = Context.GetObject <KindsCardKind>(new Guid("F841AEE1-6018-44C6-A6A6-D3BAE4A3439F"));    // Задание на согласование фин.документов

            DocsVision.BackOffice.ObjectModel.Task task = TaskService.CreateTask(kind);
            task.MainInfo.Name = "Согласование бухгалтерских документов " + Document.MainInfo.Name;
            task.Description   = "Согласование бухгалтерских документов " + Document.MainInfo.Name;
            string content = "Вы назначены " + role + " при согласовании бухгалтерских документов.";

            content = content + " Пожалуйста, отметьте свое решение кнопками Согласован или Не согласован и напишите соответствующий комментарий";
            task.MainInfo.Content   = content;
            task.MainInfo.Author    = this.StaffService.GetCurrentEmployee();
            task.MainInfo.StartDate = DateTime.Now;
            task.MainInfo.Priority  = TaskPriority.Normal;
            task.Preset.AllowDelegateToAnyEmployee = true;
            TaskService.AddSelectedPerformer(task.MainInfo, Performer);
            BaseCardSectionRow taskRow = (BaseCardSectionRow)task.GetSection(new System.Guid("20D21193-9F7F-4B62-8D69-272E78E1D6A8"))[0];

            taskRow["PerformanceType"] = performingType;
            addTaskRows(task);
            //добавляем ссылку на родительскую карточку
            TaskService.AddLinkOnParentCard(task, TaskService.GetKindSettings(kind), this.Document);
            //добавляем ссылку на задание в карточку
            TaskListService.AddTask(this.Document.MainInfo.Tasks, task, this.Document);
            //создаем и сохраняем новый список заданий
            TaskList newTaskList = TaskListService.CreateTaskList();

            Context.SaveObject <DocsVision.BackOffice.ObjectModel.TaskList>(newTaskList);
            //записываем в задание
            task.MainInfo.ChildTaskList = newTaskList;
            Context.SaveObject <DocsVision.BackOffice.ObjectModel.Task>(task);
            string oErrMessageForStart;
            bool   CanStart = TaskService.ValidateForBegin(task, out oErrMessageForStart);

            if (CanStart)
            {
                TaskService.StartTask(task);
                StatesState oStartedState = StateService.GetStates(kind).FirstOrDefault(br => br.DefaultName == "Started");
                task.SystemInfo.State = oStartedState;

                UIService.ShowMessage("Документ успешно отправлен пользователю " + Performer.DisplayString, "Отправка задания");
            }

            else
            {
                UIService.ShowMessage(oErrMessageForStart, "Ошибка отправки задания");
            }

            Context.SaveObject <DocsVision.BackOffice.ObjectModel.Task>(task);
        }
        private void addTaskRows(DocsVision.BackOffice.ObjectModel.Task currentTask)
        {
            //добавить исполниетлей и ход согласования
            var DocumentCuratorSection = Document.GetSection(new System.Guid("281A97FF-667F-46C8-8FBE-7CFC02EDFEDB"));

            foreach (BaseCardSectionRow docRow in DocumentCuratorSection)
            {
                var CuratorSection        = currentTask.GetSection(new System.Guid("7BEB89E5-4A68-445A-85BA-EEEFC0118623"));  // Секция Куратор Задания
                BaseCardSectionRow newRow = new BaseCardSectionRow();
                newRow["Curator"] = docRow["Approver"];
                CuratorSection.Add(newRow);
            }
            var TechDirectorSection = Document.GetSection(new System.Guid("F47D0D6B-07FE-4198-8F79-348AC55086E5"));

            foreach (BaseCardSectionRow docRow in TechDirectorSection)
            {
                var CuratorSection        = currentTask.GetSection(new System.Guid("947F528D-0400-428D-9403-3A6F76BFE4CE"));  // Секция тех.директор
                BaseCardSectionRow newRow = new BaseCardSectionRow();
                newRow["Director"] = docRow["Confirm"];
                CuratorSection.Add(newRow);
            }
            var AccountantSection = Document.GetSection(new System.Guid("D9F3BB4C-9C1A-464C-90F3-3D9657864709"));     // бухгалтер

            foreach (BaseCardSectionRow docRow in AccountantSection)
            {
                var CuratorSection        = currentTask.GetSection(new System.Guid("9D5136DB-59BD-4039-BC34-1D26227F0A34"));
                BaseCardSectionRow newRow = new BaseCardSectionRow();
                newRow["Accountant"] = docRow["Signer"];
                CuratorSection.Add(newRow);
            }
            var ManagerSection = Document.GetSection(new System.Guid("B6DFAEAD-BAAA-4024-908C-5DBD693D0FD3"));     // руководитель

            foreach (BaseCardSectionRow docRow in ManagerSection)
            {
                var CuratorSection        = currentTask.GetSection(new System.Guid("52B4B182-0FEE-4CB4-886C-965C8CC71CDE"));
                BaseCardSectionRow newRow = new BaseCardSectionRow();
                newRow["Manager"] = docRow["ReceiverStaff"];
                CuratorSection.Add(newRow);
            }
            var PerformerSection = Document.GetSection(new System.Guid("AF798AE7-BAAC-486E-84EF-82C59DC00A7E"));     // на ознакомление

            foreach (BaseCardSectionRow docRow in PerformerSection)
            {
                var CuratorSection        = currentTask.GetSection(new System.Guid("0E0E6967-2910-4D60-8132-B34F52DC1571"));  //Секция тех.директор
                BaseCardSectionRow newRow = new BaseCardSectionRow();
                newRow["AcquaintancePersons"] = docRow["AcquaintancePersons"];
                CuratorSection.Add(newRow);
            }

            BaseCardSectionRow mainRow     = (BaseCardSectionRow)this.Document.GetSection(new System.Guid("30EB9B87-822B-4753-9A50-A1825DCA1B74"))[0]; //First row of document main section
            BaseCardSectionRow mainTaskRow = (BaseCardSectionRow)currentTask.GetSection(new System.Guid("20D21193-9F7F-4B62-8D69-272E78E1D6A8"))[0];   //First row of task main section

            mainTaskRow["Partially"]       = mainRow["WasSent"];
            mainTaskRow["PartialPurchase"] = mainRow["Sum"];
            mainTaskRow["Comment"]         = mainRow["ExternalNumber"];
            //информацию о ходе согласования из род документа
            foreach (BaseCardSectionRow row in this.Document.GetSection(new System.Guid("AACEF937-EAD2-4AFD-A64C-DC42D7846B80")))      // журнал согласования
            {
                var CuratorTaskSection    = currentTask.GetSection(new System.Guid("4B787F44-FBBD-47C1-A883-D9518B7B06DB"));
                BaseCardSectionRow newRow = new BaseCardSectionRow();
                newRow["Approver"] = row["Employee"];
                newRow["Date"]     = row["Date"];
                newRow["Result"]   = row["Result"];
                newRow["Comment"]  = row["Comment"];
                CuratorTaskSection.Add(newRow);
            }

            Context.SaveObject <DocsVision.BackOffice.ObjectModel.Task>(currentTask);
        }