Beispiel #1
0
        public override void Initializing(Sungero.Domain.ModuleInitializingEventArgs e)
        {
            // Создание ролей.
            InitializationLogger.Debug("Init: Create roles.");
            CreateRoles();

            // Выдача прав роли "Ответственные за совещания".
            InitializationLogger.Debug("Init: Grant right on financial documents for responsible.");
            GrantRightToMeetingResponsible();

            CreateDocumentTypes();
            CreateDocumentKinds();
            CreateDocumentRegistersAndSettings();
        }
Beispiel #2
0
        /// <summary>
        /// Функция инициализации для выдачи прав на вычисляемые папки.
        /// </summary>
        public static void GrantRightsOnFolder()
        {
            var allUsers = Roles.AllUsers;

            finex.Subject.Module.RecordManagementUI.SpecialFolders.IncomingDocumentsfinex.AccessRights.Grant(allUsers, DefaultAccessRightsTypes.Read);
            finex.Subject.Module.RecordManagementUI.SpecialFolders.IncomingDocumentsfinex.AccessRights.Save();
            InitializationLogger.Debug("Выданы права на вычисляемую папку 'Входящие документы'");
            finex.Subject.Module.RecordManagementUI.SpecialFolders.OutgoingDocumentsfinex.AccessRights.Grant(allUsers, DefaultAccessRightsTypes.Read);
            finex.Subject.Module.RecordManagementUI.SpecialFolders.OutgoingDocumentsfinex.AccessRights.Save();
            InitializationLogger.Debug("Выданы права на вычисляемую папку 'Исходящие документы'");
            finex.Subject.Module.RecordManagementUI.SpecialFolders.InternalDocumentsfinex.AccessRights.Grant(allUsers, DefaultAccessRightsTypes.Read);
            finex.Subject.Module.RecordManagementUI.SpecialFolders.InternalDocumentsfinex.AccessRights.Save();
            InitializationLogger.Debug("Выданы права на вычисляемую папку 'Внутренние документы'");
        }
Beispiel #3
0
        /// <summary>
        /// Инициализация роли "Пользователи с правами на работу через сервис обмена".
        /// </summary>
        public static void InitializeExchangeServiceUsersRole()
        {
            InitializationLogger.Debug("Init: Initialize Exchange Service Users role");

            var exchangeServiceUsersRole = ExchangeCore.PublicFunctions.Module.GetExchangeServiceUsersRole();

            if (exchangeServiceUsersRole == null)
            {
                InitializationLogger.Debug("Init: No service users role found");
                return;
            }

            Parties.Counterparties.AccessRights.Grant(exchangeServiceUsersRole, Constants.Module.DefaultAccessRightsTypeSid.SetExchange);
            Parties.Counterparties.AccessRights.Save();
        }
Beispiel #4
0
        /// <summary>
        /// Выдать права роли "Ответственные за настройку регистрации".
        /// </summary>
        public static void GrantRightToRegistrationManagersRole()
        {
            InitializationLogger.Debug("Init: Grant rights on logs and registration settings to registration managers.");

            var registrationManagers  = Roles.GetAll().SingleOrDefault(n => n.Sid == Docflow.Constants.Module.RoleGuid.RegistrationManagersRole);
            var registrationContracts = Roles.GetAll().SingleOrDefault(n => n.Sid == Docflow.Constants.Module.RoleGuid.RegistrationContractualDocument);

            if (registrationManagers == null || registrationContracts == null)
            {
                return;
            }

            registrationContracts.AccessRights.Grant(registrationManagers, DefaultAccessRightsTypes.Change);
            registrationContracts.Save();
        }
Beispiel #5
0
        /// <summary>
        /// Выдать права роли "Регистраторы внутренних документов".
        /// </summary>
        public static void GrantRightsToRegistrationInternalRole()
        {
            InitializationLogger.Debug("Init: Grant rights on documents to registration internal doсument role.");

            var registrationRole = Roles.GetAll().FirstOrDefault(r => r.Sid == Docflow.Constants.Module.RoleGuid.RegistrationInternalDocument);

            if (registrationRole == null)
            {
                return;
            }

            // Права на документы.
            RecordManagement.OrderBases.AccessRights.Grant(registrationRole, Docflow.Constants.Module.DefaultAccessRightsTypeSid.Register);
            RecordManagement.OrderBases.AccessRights.Save();
        }
Beispiel #6
0
        /// <summary>
        /// Создать роль согласования.
        /// </summary>
        /// <param name="roleType">Тип роли.</param>
        /// <param name="description">Описание роли.</param>
        public static void CreateApprovalRole(Enumeration roleType, string description)
        {
            InitializationLogger.DebugFormat("Init: Create contract approval rule {0}", ApprovalRoleBases.Info.Properties.Type.GetLocalizedValue(roleType));

            var role = ContractApprovalRoles.GetAll().Where(r => Equals(r.Type, roleType)).FirstOrDefault();

            if (role == null)
            {
                role = ContractApprovalRoles.Create();
            }

            role.Type        = roleType;
            role.Description = description;
            role.Save();
        }
Beispiel #7
0
        /// <summary>
        /// Выдать права всем пользователям на задачи.
        /// </summary>
        /// <param name="allUsers">Группа "Все пользователи".</param>
        public static void GrantRightsOnTasks(IRole allUsers)
        {
            InitializationLogger.Debug("Init: Grant rights on tasks to all users.");

            RecordManagement.DocumentReviewTasks.AccessRights.Grant(allUsers, DefaultAccessRightsTypes.Create);
            RecordManagement.ActionItemExecutionTasks.AccessRights.Grant(allUsers, DefaultAccessRightsTypes.Create);
            RecordManagement.StatusReportRequestTasks.AccessRights.Grant(allUsers, DefaultAccessRightsTypes.Create);
            RecordManagement.DeadlineExtensionTasks.AccessRights.Grant(allUsers, DefaultAccessRightsTypes.Create);
            RecordManagement.AcquaintanceTasks.AccessRights.Grant(allUsers, DefaultAccessRightsTypes.Create);

            RecordManagement.DocumentReviewTasks.AccessRights.Save();
            RecordManagement.ActionItemExecutionTasks.AccessRights.Save();
            RecordManagement.StatusReportRequestTasks.AccessRights.Save();
            RecordManagement.DeadlineExtensionTasks.AccessRights.Save();
            RecordManagement.AcquaintanceTasks.AccessRights.Save();
        }
Beispiel #8
0
        public override void Initializing(Sungero.Domain.ModuleInitializingEventArgs e)
        {
            // Создание ролей.
            InitializationLogger.Debug("Init: Create roles.");
            CreateRoles();

            // Выдача прав роли "Ответственные за финансовый архив".
            InitializationLogger.Debug("Init: Grant right on financial documents for responsible.");
            GrantRightToFinancialResponsible();

            CreateDocumentTypes();
            CreateDocumentKinds();
            CreateFinancialDocumentRegistersAndSettings();
            CreateDefaultFinancialApprovalRules();
            CreateReportsTables();
        }
Beispiel #9
0
        public void LogMessage_CreatesProperEvents(EventLevel eventLevel, LogLevel logLevel, EventSourcesEventIds eventId)
        {
            TestEventListener listener = new TestEventListener();

            listener.EnableEvents(OmexLogEventSource.Instance, eventLevel);
            listener.EnableEvents(ServiceInitializationEventSource.Instance, EventLevel.Informational);

            string   message  = "Test message";
            string   category = "Test category";
            int      tagId    = 0xFFF9;
            Activity activity = new Activity("Test activity");

            activity.Start().Stop();             // start and stop activity to get correlation id

            Mock <IOptionsMonitor <OmexLoggingOptions> > mockOptions = new Mock <IOptionsMonitor <OmexLoggingOptions> >();

            mockOptions.Setup(m => m.CurrentValue).Returns(new OmexLoggingOptions());

            OmexLogEventSender logsSender = new OmexLogEventSender(
                OmexLogEventSource.Instance,
                new Mock <IExecutionContext>().Object,
                new EmptyServiceContext(),
                mockOptions.Object);

            logsSender.LogMessage(activity, category, logLevel, tagId, 0, message, new Exception("Not expected to be part of the event"));

            EventWrittenEventArgs eventInfo = listener.EventsInformation.Single(e => e.EventId == (int)eventId);

            eventInfo.AssertPayload("message", message);
            eventInfo.AssertPayload("category", category);
            eventInfo.AssertPayload("activityId", activity.Id ?? string.Empty);
            eventInfo.AssertPayload("tagId", "fff9");

            InitializationLogger.LogInitializationSucceed(category, message);


            eventInfo = listener.EventsInformation.Single(e => e.EventId == (int)EventSourcesEventIds.GenericHostBuildSucceeded);

            eventInfo.AssertPayload("message", "Initialization successful for Test category, Test message");

            string newMessage = "New message";

            InitializationLogger.LogInitializationFail(category, new Exception("Not expected to be part of the event"), newMessage);

            eventInfo = listener.EventsInformation.Single(e => e.EventId == (int)EventSourcesEventIds.GenericHostFailed);
            eventInfo.AssertPayload("message", newMessage);
        }
Beispiel #10
0
        /// <summary>
        /// Выдать права роли "Ответственные за финансовый архив".
        /// </summary>
        public static void GrantRightToFinancialResponsible()
        {
            InitializationLogger.Debug("Init: Grant rights on financial document to resposible managers.");

            var financialResponsible = Roles.GetAll().Where(n => n.Sid == FinancialArchive.Constants.Module.FinancialArchiveResponsibleRole).FirstOrDefault();

            if (financialResponsible == null)
            {
                return;
            }

            var allUsers = Roles.AllUsers;

            // Если нет лицензии на финансовые документы (есть такие неудачные лицензии, где оно требуется), то используем РОФ.
            var hasLicense = Docflow.PublicFunctions.Module.Remote.IsModuleAvailableByLicense(Guid.Parse("59797aba-7718-45df-8ac1-5bb7a36c7a66"));
            Dictionary <int, byte[]> licenses = null;

            try
            {
                if (!hasLicense)
                {
                    licenses = Docflow.PublicFunctions.Module.ReadLicense();
                    Docflow.PublicFunctions.Module.DeleteLicense();
                }

                // Права на документы.
                IncomingTaxInvoices.AccessRights.Grant(financialResponsible, DefaultAccessRightsTypes.Create);
                OutgoingTaxInvoices.AccessRights.Grant(financialResponsible, DefaultAccessRightsTypes.Create);
                Waybills.AccessRights.Grant(financialResponsible, DefaultAccessRightsTypes.Create);
                ContractStatements.AccessRights.Grant(financialResponsible, DefaultAccessRightsTypes.Create);
                UniversalTransferDocuments.AccessRights.Grant(financialResponsible, DefaultAccessRightsTypes.Create);
                IncomingTaxInvoices.AccessRights.Save();
                OutgoingTaxInvoices.AccessRights.Save();
                Waybills.AccessRights.Save();
                ContractStatements.AccessRights.Save();
                UniversalTransferDocuments.AccessRights.Save();

                // Права на отчет.
                Reports.AccessRights.Grant(Reports.GetFinArchiveExportReport().Info, allUsers, DefaultReportAccessRightsTypes.Execute);
            }
            finally
            {
                Docflow.PublicFunctions.Module.RestoreLicense(licenses);
            }

            GrantRightOnFolders(allUsers);
        }
Beispiel #11
0
        public override void Initializing(Sungero.Domain.ModuleInitializingEventArgs e)
        {
            // Выдача прав всем пользователям.
            var allUsers = Roles.AllUsers;

            if (allUsers != null)
            {
                // Справочники.
                GrantRightsOnDatabooks(allUsers);

                // Документы.
                GrantRightsOnDocuments(allUsers);

                // Задачи.
                GrantRightsOnTasks(allUsers);

                // Спец.папки.
                GrantRightOnFolders(allUsers);

                // Отчеты.
                InitializationLogger.Debug("Init: Grant right on reports to all users.");
                Reports.AccessRights.Grant(Reports.GetActionItemsExecutionReport().Info, allUsers, DefaultReportAccessRightsTypes.Execute);
                Reports.AccessRights.Grant(Reports.GetDocumentReturnReport().Info, allUsers, DefaultReportAccessRightsTypes.Execute);
                Reports.AccessRights.Grant(Reports.GetAcquaintanceReport().Info, allUsers, DefaultReportAccessRightsTypes.Execute);
                Reports.AccessRights.Grant(Reports.GetAcquaintanceFormReport().Info, allUsers, DefaultReportAccessRightsTypes.Execute);
                Reports.AccessRights.Grant(Reports.GetDraftResolutionReport().Info, allUsers, DefaultReportAccessRightsTypes.Execute);
            }

            // Выдача дополнительных прав роли "Делопроизводители".
            GrantRightsToClerk();

            // Выдача прав ролям безопасности.
            InitializationLogger.Debug("Init: Grant right for security roles.");
            GrantRightsToRegistrationIncomingRole();
            GrantRightsToRegistrationOutgoingRole();
            GrantRightsToRegistrationInternalRole();

            CreateDocumentTypes();
            CreateDocumentKinds();
            CreateAssignmentIndex();
            CreateTaskIndex();
            CreateReportsTables();

            // Добавление в таблицу параметров ограничения исполнителей для задачи на ознакомление.
            AddAcquaintanceTaskPerformersLimit();
        }
Beispiel #12
0
        public override void Initializing(Sungero.Domain.ModuleInitializingEventArgs e)
        {
            // Создание ролей.
            InitializationLogger.Debug("Init: Create roles.");
            CreateRoles();

            // Справочники.
            InitializationLogger.Debug("Init: Grant rights on databooks to all users.");
            GrantRightsOnDatabooks();

            // Создание типов прав модуля.
            InitializationLogger.Debug("Init: Create access rights.");
            CreateCounterpartyAccessRights();

            CreateExchangeServices();
            InitializeExchangeServiceUsersRole();
        }
Beispiel #13
0
        /// <summary>
        /// Назначить права роли "Делопроизводители".
        /// </summary>
        public static void GrantRightsToClerk()
        {
            InitializationLogger.Debug("Init: Grant rights on reports to clerks");

            var clerks = Docflow.PublicFunctions.DocumentRegister.Remote.GetClerks();

            if (clerks == null)
            {
                return;
            }

            // Права на отчеты модуля.
            Reports.AccessRights.Grant(Reports.GetIncomingDocumentsReport().Info, clerks, DefaultReportAccessRightsTypes.Execute);
            Reports.AccessRights.Grant(Reports.GetOutgoingDocumentsReport().Info, clerks, DefaultReportAccessRightsTypes.Execute);
            Reports.AccessRights.Grant(Reports.GetInternalDocumentsReport().Info, clerks, DefaultReportAccessRightsTypes.Execute);
            Reports.AccessRights.Grant(Reports.GetIncomingDocumentsProcessingReport().Info, clerks, DefaultReportAccessRightsTypes.Execute);
        }
Beispiel #14
0
        /// <summary>
        /// Создать журнал и настройки регистрации для счетов и накладных.
        /// </summary>
        public static void CreateFinancialDocumentRegistersAndSettings()
        {
            InitializationLogger.Debug("Init: Create default logs and settings for financial archive.");

            var taxInvoiceOutgoingDocumentRegister = CreateLeadNumberedDocumentRegister(Resources.RegistersAndSettingsOutgoingTaxInvoiceName,
                                                                                        Resources.RegistersAndSettingsOutgoingTaxInvoiceIndex,
                                                                                        Docflow.RegistrationSetting.DocumentFlow.Outgoing,
                                                                                        Init.OutgoingTaxInvoiceRegister);
            var taxInvoiceIncomingDocumentRegister = CreateLeadNumberedDocumentRegister(Resources.RegistersAndSettingsIncomingTaxInvoiceName,
                                                                                        Resources.RegistersAndSettingsIncomingTaxInvoiceIndex,
                                                                                        Docflow.RegistrationSetting.DocumentFlow.Incoming,
                                                                                        Init.IncomingTaxInvoiceRegister);
            var waybillDocumentRegister = CreateLeadNumberedDocumentRegister(Resources.RegistersAndSettingsWaybillName,
                                                                             Resources.RegistersAndSettingsWaybillIndex,
                                                                             Docflow.RegistrationSetting.DocumentFlow.Contracts,
                                                                             Init.WaybillRegister);
            var actDocumentRegister = CreateLeadNumberedDocumentRegister(Resources.RegistersAndSettingsActName,
                                                                         Resources.RegistersAndSettingsActIndex,
                                                                         Docflow.DocumentRegister.DocumentFlow.Contracts,
                                                                         Init.ContractStatementRegister);
            var universalDocumentRegister = CreateLeadNumberedDocumentRegister(Resources.RegistersAndSettingsUniversalName,
                                                                               Resources.RegistersAndSettingsUniversalIndex,
                                                                               Docflow.DocumentRegister.DocumentFlow.Contracts,
                                                                               Init.UniversalRegister);

            Docflow.PublicInitializationFunctions.Module.CreateNumerationSetting(OutgoingTaxInvoice.ClassTypeGuid,
                                                                                 Docflow.RegistrationSetting.DocumentFlow.Outgoing,
                                                                                 taxInvoiceOutgoingDocumentRegister);

            Docflow.PublicInitializationFunctions.Module.CreateNumerationSetting(IncomingTaxInvoice.ClassTypeGuid,
                                                                                 Docflow.RegistrationSetting.DocumentFlow.Incoming,
                                                                                 taxInvoiceIncomingDocumentRegister);

            Docflow.PublicInitializationFunctions.Module.CreateNumerationSetting(Waybill.ClassTypeGuid,
                                                                                 Docflow.RegistrationSetting.DocumentFlow.Contracts,
                                                                                 waybillDocumentRegister);

            Docflow.PublicInitializationFunctions.Module.CreateNumerationSetting(ContractStatement.ClassTypeGuid,
                                                                                 Docflow.RegistrationSetting.DocumentFlow.Contracts,
                                                                                 actDocumentRegister);

            Docflow.PublicInitializationFunctions.Module.CreateNumerationSetting(UniversalTransferDocument.ClassTypeGuid,
                                                                                 Docflow.RegistrationSetting.DocumentFlow.Contracts,
                                                                                 universalDocumentRegister);
        }
Beispiel #15
0
        public static void CreateProjectKind(string name, Guid entityId)
        {
            var externalLink = Docflow.PublicFunctions.Module.GetExternalLink(ProjectKind.ClassTypeGuid, entityId);

            if (externalLink != null)
            {
                return;
            }

            InitializationLogger.DebugFormat("Init: Create project kind '{0}'.", name);

            var projectKind = ProjectKinds.Create();

            projectKind.Name = name;
            projectKind.Save();

            Docflow.PublicFunctions.Module.CreateExternalLink(projectKind, entityId);
        }
Beispiel #16
0
        /// <summary>
        /// Выдать права роли "Регистраторы договоров".
        /// </summary>
        public static void GrantRightToRegistrationContractsRole()
        {
            InitializationLogger.Debug("Init: Grant rights on documents to registration contractual documents role.");

            var registrationContracts = Roles.GetAll().FirstOrDefault(n => n.Sid == Docflow.Constants.Module.RoleGuid.RegistrationContractualDocument);

            if (registrationContracts == null)
            {
                return;
            }

            // Модуль "Документооборот".
            Docflow.CaseFiles.AccessRights.Grant(registrationContracts, DefaultAccessRightsTypes.Read);
            Docflow.MailDeliveryMethods.AccessRights.Grant(registrationContracts, DefaultAccessRightsTypes.Read);
            Docflow.FileRetentionPeriods.AccessRights.Grant(registrationContracts, DefaultAccessRightsTypes.Read);
            Docflow.CaseFiles.AccessRights.Save();
            Docflow.MailDeliveryMethods.AccessRights.Save();
            Docflow.FileRetentionPeriods.AccessRights.Save();
        }
Beispiel #17
0
        /// <summary>
        /// Создать правила по умолчанию.
        /// </summary>
        public static void CreateDefaultContractualRules()
        {
            InitializationLogger.Debug("Init: Create default contractual approval rules.");

            var stages = new List <Enumeration>
            {
                StageType.Manager, StageType.Approvers, StageType.Print, StageType.Sign, StageType.Register, StageType.Sending, StageType.CheckReturn, StageType.Notice
            };

            var rule = CreateDefaultRule(Resources.DefaultApprovalRuleNameContracts,
                                         Docflow.ApprovalRuleBase.DocumentFlow.Contracts,
                                         stages);

            // Добавить условие по способу отправки и непосредственный руководитель - подписывающий, для созданного правила.
            if (rule != null)
            {
                var deliveryCondition = ContractConditions.Create();
                deliveryCondition.ConditionType = Docflow.ConditionBase.ConditionType.DeliveryMethod;
                var newDeliveryMethod = deliveryCondition.DeliveryMethods.AddNew();
                newDeliveryMethod.DeliveryMethod = Docflow.MailDeliveryMethods.GetAll(m => m.Sid == Docflow.Constants.MailDeliveryMethod.Exchange).FirstOrDefault();
                deliveryCondition.Save();
                var printStageNumber = stages.IndexOf(StageType.Print) + 1;
                Docflow.PublicInitializationFunctions.Module.AddConditionToRule(rule, deliveryCondition, printStageNumber);

                var rolesCompareCondition = Docflow.PublicInitializationFunctions.Module.CreateRoleCompareSignatoryAndInitManagerCondition(ContractConditions.Create());
                var managerStageNumber    = stages.IndexOf(StageType.Manager) + 1;
                Docflow.PublicInitializationFunctions.Module.AddConditionToRule(rule, rolesCompareCondition, managerStageNumber);
            }

            InitializationLogger.Debug("Init: Create default invoice approval rules.");
            var invoiceStages = new List <Enumeration>
            {
                StageType.Manager, StageType.Approvers, StageType.Sign
            };
            var invoiceRule = CreateDefaultInvoiceRule(Resources.DefaultApprovalRuleNameInvoice, invoiceStages);

            if (invoiceRule != null)
            {
                var rolesCompareCondition = Docflow.PublicInitializationFunctions.Module.CreateRoleCompareSignatoryAndInitManagerCondition(Conditions.Create());
                var managerStageNumber    = invoiceStages.IndexOf(StageType.Manager) + 1;
                Docflow.PublicInitializationFunctions.Module.AddConditionToRule(invoiceRule, rolesCompareCondition, managerStageNumber);
            }
        }
Beispiel #18
0
        public override void Initializing(Sungero.Domain.ModuleInitializingEventArgs e)
        {
            var allUsers = Roles.AllUsers;

            if (allUsers != null)
            {
                // Справочники.
                InitializationLogger.Debug("Init: Grant rights on databooks to all users.");
                GrantRightsOnDatabooks(allUsers);

                // Документы.
                InitializationLogger.Debug("Init: Grant rights on documents to all users.");
                GrantRightsOnDocuments(allUsers);

                GrantRightOnFolders(allUsers);
            }

            // Создание ролей.
            InitializationLogger.Debug("Init: Create roles.");
            CreateRoles();

            // Довыдача прав роли "Ответственные за настройку регистрации".
            InitializationLogger.Debug("Init: Grant right on registration for registration managers.");
            GrantRightToRegistrationManagersRole();

            // Выдача прав роли "Ответственные за договоры".
            InitializationLogger.Debug("Init: Grant right on contract documents for contracts responsible.");
            GrantRightToContractsResponsible();

            // Выдача прав роли "Регистраторы договоров".
            InitializationLogger.Debug("Init: Grant right on contract documents for registration contractual documents.");
            GrantRightToRegistrationContractsRole();

            CreateDocumentTypes();
            CreateDocumentKinds();
            CreateDefaultApprovalRoles();
            CreateDefaultRelationTypes();
            CreateDefaultContractualRules();
            CreateDocumentRegisterAndSettingsForContracts();
            CreateEDocIndex();
        }
Beispiel #19
0
        /// <summary>
        /// Создать виды документов для договоров.
        /// </summary>
        public static void CreateDocumentKinds()
        {
            InitializationLogger.Debug("Init: Create document kinds.");

            var notifiable   = Docflow.DocumentKind.NumberingType.Registrable;
            var numerable    = Docflow.DocumentKind.NumberingType.Numerable;
            var notNumerable = Docflow.DocumentKind.NumberingType.NotNumerable;

            Docflow.PublicInitializationFunctions.Module.CreateDocumentKind(Sungero.Contracts.Resources.ContractKindName,
                                                                            Sungero.Contracts.Resources.ContractKindShortName,
                                                                            notifiable, DocumentFlow.Contracts, true, false,
                                                                            Contract.ClassTypeGuid, null, Init.ContractKind);
            Docflow.PublicInitializationFunctions.Module.CreateDocumentKind(Sungero.Contracts.Resources.SupAgreementKindName,
                                                                            Sungero.Contracts.Resources.SupAgreementKindShortName,
                                                                            numerable, DocumentFlow.Contracts, true, false,
                                                                            SupAgreement.ClassTypeGuid, null, Init.SupAgreementKind);
            Docflow.PublicInitializationFunctions.Module.CreateDocumentKind(Sungero.Contracts.Resources.IncomingInvoiceKindName,
                                                                            Sungero.Contracts.Resources.IncomingInvoiceKindShortName,
                                                                            notNumerable, DocumentFlow.Incoming, true, false,
                                                                            IncomingInvoice.ClassTypeGuid, new Domain.Shared.IActionInfo[] { OfficialDocuments.Info.Actions.SendForFreeApproval, OfficialDocuments.Info.Actions.SendForApproval },
                                                                            Init.IncomingInvoiceKind);
        }
Beispiel #20
0
        public static void CreateProjectFolder()
        {
            var shared        = Core.SpecialFolders.Shared;
            var projectFolder = Folders.GetAll().SingleOrDefault(f => f.Uid == Constants.Module.ProjectFolders.ProjectFolderUid);

            if (projectFolder == null)
            {
                InitializationLogger.Debug("Init: Create default projects folder.");
                projectFolder      = Folders.Create();
                projectFolder.Name = Resources.ProjectFolderName;
                projectFolder.Uid  = Constants.Module.ProjectFolders.ProjectFolderUid;
                projectFolder.Save();
            }
            shared.Items.Add(projectFolder);

            var archiveFolder = Folders.GetAll().SingleOrDefault(f => f.Uid == Constants.Module.ProjectFolders.ProjectArhiveFolderUid);

            if (archiveFolder == null)
            {
                InitializationLogger.Debug("Init: Create default projects archive folder.");
                archiveFolder      = Folders.Create();
                archiveFolder.Name = Resources.ProjectArhiveFolderName;
                archiveFolder.Uid  = Constants.Module.ProjectFolders.ProjectArhiveFolderUid;
                archiveFolder.Save();
            }
            projectFolder.Items.Add(archiveFolder);

            var role = Docflow.PublicInitializationFunctions.Module.GetProjectManagersRole();

            if (role == null)
            {
                return;
            }

            projectFolder.AccessRights.Grant(role, Docflow.Constants.Module.DefaultAccessRightsTypeSid.ChangeContent);
            archiveFolder.AccessRights.Grant(role, Docflow.Constants.Module.DefaultAccessRightsTypeSid.ChangeContent);
            projectFolder.AccessRights.Save();
            archiveFolder.AccessRights.Save();
        }
Beispiel #21
0
 /// <summary>
 /// Обновить банки.
 /// </summary>
 public static void UpdateBanksFromCBR()
 {
     if (Commons.PublicFunctions.Module.IsServerCultureRussian())
     {
         InitializationLogger.DebugFormat("Init: Update banks from CBR.");
         Docflow.PublicFunctions.Module.ExecuteSQLCommand(Queries.Module.PrepareBanksUpdate);
         Docflow.PublicFunctions.Module.ExecuteSQLCommand(Queries.Module.UpdateBanksFromCBR);
         var count = int.Parse(Docflow.PublicFunctions.Module.ExecuteScalarSQLCommand(Queries.Module.GetNewCountBanks).ToString());
         if (count > 0)
         {
             // BUG 75302, Zamerov: генерируем ID для новых банков кодом, иначе создание контрагентов через Create будет ставить дедлок.
             var tableName = Banks.Info.DBTableName;
             var ids       = Domain.IdentifierGenerator.GenerateIdentifiers(tableName, count).ToList();
             using (var command = SQL.GetCurrentConnection().CreateCommand())
             {
                 command.CommandText = Queries.Module.CreateBanksFromCBR;
                 Docflow.PublicFunctions.Module.AddIntegerParameterToCommand(command, "@newId", ids.First());
                 command.ExecuteNonQuery();
             }
         }
         Docflow.PublicFunctions.Module.ExecuteSQLCommand(Queries.Module.CleanTempTablesAfterUpdateBanks);
     }
 }
Beispiel #22
0
        /// <summary>
        /// Выдать права роли "Ответственные за договоры".
        /// </summary>
        public static void GrantRightToContractsResponsible()
        {
            InitializationLogger.Debug("Init: Grant rights on contractual document to resposible managers.");

            var contractsResponsible = Roles.GetAll().Where(n => n.Sid == Docflow.Constants.Module.RoleGuid.ContractsResponsible).FirstOrDefault();

            if (contractsResponsible == null)
            {
                return;
            }

            // Права на документы.
            ContractBases.AccessRights.Grant(contractsResponsible, DefaultAccessRightsTypes.Create);
            SupAgreements.AccessRights.Grant(contractsResponsible, DefaultAccessRightsTypes.Create);
            ContractBases.AccessRights.Save();
            SupAgreements.AccessRights.Save();

            // Если нет лицензии на финансовые документы (есть такие неудачные лицензии, где оно требуется), то используем РОФ.
            var hasLicense = Docflow.PublicFunctions.Module.Remote.IsModuleAvailableByLicense(Guid.Parse("59797aba-7718-45df-8ac1-5bb7a36c7a66"));
            Dictionary <int, byte[]> licenses = null;

            try
            {
                if (!hasLicense)
                {
                    licenses = Docflow.PublicFunctions.Module.ReadLicense();
                    Docflow.PublicFunctions.Module.DeleteLicense();
                }

                FinancialArchive.ContractStatements.AccessRights.Grant(contractsResponsible, DefaultAccessRightsTypes.Create);
                FinancialArchive.ContractStatements.AccessRights.Save();
            }
            finally
            {
                Docflow.PublicFunctions.Module.RestoreLicense(licenses);
            }
        }
Beispiel #23
0
        /// <summary>
        /// Выдать права роли "Ответственные за совещания".
        /// </summary>
        public static void GrantRightToMeetingResponsible()
        {
            InitializationLogger.Debug("Init: Grant rights on meeting to resposible managers.");

            var meetingResponsible = Roles.GetAll().Where(n => n.Sid == Constants.Module.MeetingResponsibleRole).FirstOrDefault();

            if (meetingResponsible == null)
            {
                return;
            }

            // Права на документы.
            Agendas.AccessRights.Grant(meetingResponsible, DefaultAccessRightsTypes.Create);
            Agendas.AccessRights.Save();

            // Права на справочники.
            Meetings.AccessRights.Grant(meetingResponsible, DefaultAccessRightsTypes.Create);
            Meetings.AccessRights.Save();

            // Права на спец. папки.
            var allUsers = Roles.AllUsers;

            GrantRightOnFolders(allUsers);
        }
Beispiel #24
0
        /// <summary>
        /// Создать базовые типы связей.
        /// </summary>
        public static void CreateDefaultRelationTypes()
        {
            InitializationLogger.Debug("Init: Create default relation types.");

            // Дополнительное соглашение.
            var supAgreement = Docflow.PublicInitializationFunctions.Module.CreateRelationType(Constants.Module.SupAgreementRelationName, Resources.RelationSupAgreementSourceTitle,
                                                                                               Resources.RelationSupAgreementTargetTitle, Resources.RelationSupAgreementSourceTitle,
                                                                                               Resources.RelationSupAgreementDescription, true, false, false, true);

            supAgreement.Mapping.Clear();
            var supAgreementRow = supAgreement.Mapping.AddNew();

            supAgreementRow.Source          = Sungero.Contracts.ContractBases.Info;
            supAgreementRow.Target          = Sungero.Contracts.SupAgreements.Info;
            supAgreementRow.RelatedProperty = Sungero.Contracts.SupAgreements.Info.Properties.LeadingDocument;
            supAgreement.Save();

            // Бухгалтерский документ.
            var accounting = Docflow.PublicInitializationFunctions.Module.CreateRelationType(Constants.Module.AccountingDocumentsRelationName, Resources.RelationAccountingSourceTitle,
                                                                                             Resources.RelationAccountingTargetTitle, Resources.RelationAccountingSourceTitle,
                                                                                             Resources.RelationAccountingDescription, true, false, false, true);

            accounting.UseTarget    = true;
            accounting.HasDirection = true;
            accounting.Mapping.Clear();
            var accountingRow = accounting.Mapping.AddNew();

            accountingRow.Source          = Sungero.Contracts.ContractualDocuments.Info;
            accountingRow.Target          = Sungero.Docflow.AccountingDocumentBases.Info;
            accountingRow.RelatedProperty = Sungero.Docflow.AccountingDocumentBases.Info.Properties.LeadingDocument;
            accountingRow                 = accounting.Mapping.AddNew();
            accountingRow.Source          = Sungero.Contracts.ContractBases.Info;
            accountingRow.Target          = Sungero.Contracts.IncomingInvoices.Info;
            accountingRow.RelatedProperty = Sungero.Contracts.IncomingInvoices.Info.Properties.Contract;
            accounting.Save();
        }
Beispiel #25
0
        /// <summary>
        /// Создать типы проектных документов.
        /// </summary>
        public static void CreateDocumentTypes()
        {
            InitializationLogger.Debug("Init: Create document types");

            Docflow.PublicInitializationFunctions.Module.CreateDocumentType(Sungero.Projects.Resources.ProjectTypeName, ProjectDocument.ClassTypeGuid, Docflow.DocumentType.DocumentFlow.Inner, true);
        }
Beispiel #26
0
 /// <summary>
 /// Создать предопределенные роли.
 /// </summary>
 public static void CreateRoles()
 {
     InitializationLogger.Debug("Init: Create Default Roles");
     Docflow.PublicInitializationFunctions.Module.CreateRole(Resources.Synchronization1CResponsibleRoleName, Resources.Synchronization1CResponsibleRoleDescription, Integration1C.Constants.Module.SynchronizationResponsibleRoleGuid);
 }
Beispiel #27
0
 public override void Initializing(Sungero.Domain.ModuleInitializingEventArgs e)
 {
     // Создание ролей.
     InitializationLogger.Debug("Init: Create roles.");
     CreateRoles();
 }
Beispiel #28
0
        /// <summary>
        /// Создать предопределенные роли.
        /// </summary>
        public static void CreateRoles()
        {
            InitializationLogger.Debug("Init: Create Default Roles");

            Docflow.PublicInitializationFunctions.Module.CreateRole(Resources.RoleNameFinancialArchiveResponsible, Resources.DescriptionFinancialArchiveResponsible, FinancialArchive.Constants.Module.FinancialArchiveResponsibleRole);
        }
Beispiel #29
0
 /// <summary>
 /// Создать типы прав для контрагентов.
 /// </summary>
 public static void CreateCounterpartyAccessRights()
 {
     InitializationLogger.Debug("Init: Create access rights for counterparty type Counterparty");
     CreateAccessRightsForCounterpartyType(Guid.Parse("294767f1-009f-4fbd-80fc-f98c49ddc560"));
 }
Beispiel #30
0
 /// <summary>
 /// Создать предопределенные роли.
 /// </summary>
 public static void CreateRoles()
 {
     InitializationLogger.Debug("Init: Create Default Roles");
     Docflow.PublicInitializationFunctions.Module.CreateRole(Resources.NameMeetingResponsibleRole, Resources.DescriptionMeetingResponsibleRole, Constants.Module.MeetingResponsibleRole);
 }