Exemplo n.º 1
0
        public override bool Execute(CommandActivity commandActivity)
        {
            const string fileCaseTemplateReferenceId = "04248329-15C8-40C8-8888-90DF1C782A56";

            try
            {
                var hostObject = (File)commandActivity.WorkItem;

                if (hostObject == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFile
                                                                           .ToLocalizedName()
                                                                           .FormatWith(commandActivity));
                }

                if (!hostObject.CanEdit(true))
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NotEditable
                                                                           .ToLocalizedName()
                                                                           .FormatWith(hostObject));
                }

                var fileCaseTemplate = new ReferenceHandle <FileCaseTemplate>(fileCaseTemplateReferenceId).GetObject();

                if (fileCaseTemplate == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate
                                                                           .ToLocalizedName()
                                                                           .FormatWith(fileCaseTemplateReferenceId));
                }

                var startFileCases = new List <FileCase>();

                var fileCaseRecipientGroups =
                    hostObject.GetProperty("#LHIND_Mitbericht_VE_WeiterleitenAn") as SpecialdataListPropertyValueCollection;

                if (fileCaseRecipientGroups == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoRecipients
                                                                           .ToLocalizedName()
                                                                           .FormatWith(hostObject));
                }

                foreach (var recipientGroup in fileCaseRecipientGroups)
                {
                    var newFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplate);

                    if (newFileCase == null)
                    {
                        throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCase
                                                                               .ToLocalizedName()
                                                                               .FormatWith(commandActivity));
                    }

                    newFileCase.LeadingGroup = recipientGroup.Unwrap() as TenantGroup;
                    var newTitle = hostObject.GetMultilingualValue(fc => fc.Title) + " [" + hostObject.FormattedNumber +
                                   "] - " + newFileCase.LeadingGroup.GetMultilingualValue(g => g.ShortName);
                    newFileCase.SetMultilingualValue(fc => fc.Title, newTitle);

                    startFileCases.Add(newFileCase);
                }

                ClientTransaction.Current.Commit();

                foreach (var startFileCase in startFileCases)
                {
                    startFileCase.StartObject();
                }

                ClientTransaction.Current.Commit();
            }
            catch (Exception ex)
            {
                s_logger.Error(ex.Message, ex);
                ClientTransaction.Current.Rollback();
                throw;
            }

            return(true);
        }
Exemplo n.º 2
0
        public override bool Execute(CommandActivity commandActivity)
        {
            //Set templates for FileCase creation.
            const string fileCaseFfTemplateReferenceId = "6220CB49-8E09-4AB7-B4F1-673C6C91CC7E";
            const string fileCaseMbTemplateReferenceId = "56E01B36-E6DE-4DA3-ABE8-95C6551A76D3";

            var startFileCases = new List <FileCase>();

            try
            {
                var hostObject = (File)commandActivity.WorkItem;

                if (hostObject == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFile
                                                                           .ToLocalizedName()
                                                                           .FormatWith(commandActivity));
                }

                if (!hostObject.CanEdit(true))
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NotEditable
                                                                           .ToLocalizedName()
                                                                           .FormatWith(hostObject));
                }

                //Create FF FileCase
                var fileCaseTemplateFf =
                    new ReferenceHandle <FileCaseTemplate>(fileCaseFfTemplateReferenceId).GetObject();
                if (fileCaseTemplateFf == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate
                                                                           .ToLocalizedName()
                                                                           .FormatWith(fileCaseFfTemplateReferenceId));
                }
                var newTitle = String.Empty;

                var ffCatalogValue = hostObject.GetProperty("#LHIND_Mitbericht_FederführendesAmt") as SpecialdataCatalogValue;
                if (ffCatalogValue != null)
                {
                    var ffGroup = ffCatalogValue.GetProperty("#LHIND_Mitbericht_Spoc") as TenantGroup;
                    if (ffGroup == null)
                    {
                        throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoGroupDefined
                                                                               .ToLocalizedName()
                                                                               .FormatWith(ffCatalogValue));
                    }

                    var ffFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplateFf);
                    ffFileCase.LeadingGroup = ffGroup;

                    newTitle = ffFileCase.GetMultilingualValue(fc => fc.Title) + " - " + ffGroup.GetMultilingualValue(g => g.ShortName);
                    ffFileCase.SetMultilingualValue(fc => fc.Title, newTitle);

                    startFileCases.Add(ffFileCase);
                }

                //Create MB FileCases
                var fileCaseTemplateMb =
                    new ReferenceHandle <FileCaseTemplate>(fileCaseMbTemplateReferenceId).GetObject();
                if (fileCaseTemplateMb == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate
                                                                           .ToLocalizedName()
                                                                           .FormatWith(fileCaseMbTemplateReferenceId));
                }

                var mbCatalogValues =
                    hostObject.GetProperty("#LHIND_Mitbericht_MitbeteiligtFdListe") as SpecialdataListPropertyValueCollection;

                foreach (var mbCatalogValue in mbCatalogValues)
                {
                    var mbGroup = mbCatalogValue.WrappedValue.GetProperty("#LHIND_Mitbericht_Spoc") as TenantGroup;
                    if (mbGroup == null)
                    {
                        throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoGroupDefined
                                                                               .ToLocalizedName()
                                                                               .FormatWith(ffCatalogValue));
                    }

                    var mbFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplateMb);
                    mbFileCase.LeadingGroup = mbGroup;

                    newTitle = mbFileCase.GetMultilingualValue(fc => fc.Title) + " - " + mbFileCase.LeadingGroup.GetMultilingualValue(g => g.ShortName);
                    mbFileCase.SetMultilingualValue(fc => fc.Title, newTitle);

                    startFileCases.Add(mbFileCase);
                }

                ClientTransaction.Current.Commit();

                foreach (var startFileCase in startFileCases)
                {
                    startFileCase.StartObject();
                }

                ClientTransaction.Current.Commit();
            }
            catch (Exception ex)
            {
                s_logger.Error(ex.Message, ex);
                ClientTransaction.Current.Rollback();
                throw;
            }

            return(true);
        }
Exemplo n.º 3
0
        public override bool Execute(CommandActivity commandActivity)
        {
            //Set templates for FileCase creation.
            const string fileCaseFfTemplateReferenceId = "9B9A5D57-3DC5-41A6-81DB-6D4ADC1335E6";
            const string fileCaseMbTemplateReferenceId = "7AAA0700-CA11-4759-B250-DF3BC05B9754";

            var startFileCases = new List <FileCase>();

            try
            {
                var hostObject = (File)commandActivity.WorkItem;

                if (hostObject == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFile
                                                                           .ToLocalizedName()
                                                                           .FormatWith(commandActivity));
                }

                if (!hostObject.CanEdit(true))
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NotEditable
                                                                           .ToLocalizedName()
                                                                           .FormatWith(hostObject));
                }

                //Create FF FileCase
                var fileCaseTemplateFf =
                    new ReferenceHandle <FileCaseTemplate>(fileCaseFfTemplateReferenceId).GetObject();
                if (fileCaseTemplateFf == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate
                                                                           .ToLocalizedName()
                                                                           .FormatWith(fileCaseFfTemplateReferenceId));
                }
                var newTitle = String.Empty;
                var ffGroup  = hostObject.GetProperty("#LHIND_Antrag_Ff") as TenantGroup;

                if (ffGroup != null)
                {
                    var ffFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplateFf);

                    ffFileCase.LeadingGroup = ffGroup;

                    newTitle = ffFileCase.GetMultilingualValue(fc => fc.Title) + " - " +
                               ffGroup.GetMultilingualValue(g => g.ShortName);
                    ffFileCase.SetMultilingualValue(fc => fc.Title, newTitle);

                    startFileCases.Add(ffFileCase);
                }

                //Create MB FileCases
                var fileCaseTemplateMb =
                    new ReferenceHandle <FileCaseTemplate>(fileCaseMbTemplateReferenceId).GetObject();
                if (fileCaseTemplateMb == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate
                                                                           .ToLocalizedName()
                                                                           .FormatWith(fileCaseMbTemplateReferenceId));
                }

                var mbFileCaseRecipients =
                    hostObject.GetProperty("#LHIND_Antrag_Mb") as SpecialdataListPropertyValueCollection;

                foreach (var fileCaseRecipient in mbFileCaseRecipients)
                {
                    var mbFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplateMb);
                    mbFileCase.LeadingGroup = fileCaseRecipient.Unwrap() as TenantGroup;

                    newTitle = mbFileCase.GetMultilingualValue(fc => fc.Title) + " - " +
                               mbFileCase.LeadingGroup.GetMultilingualValue(g => g.ShortName);
                    mbFileCase.SetMultilingualValue(fc => fc.Title, newTitle);

                    startFileCases.Add(mbFileCase);
                }

                ClientTransaction.Current.Commit();

                foreach (var startFileCase in startFileCases)
                {
                    startFileCase.StartObject();
                }

                ClientTransaction.Current.Commit();
            }
            catch (Exception ex)
            {
                s_logger.Error(ex.Message, ex);
                ClientTransaction.Current.Rollback();
                throw;
            }

            return(true);
        }
Exemplo n.º 4
0
        public override bool Execute(CommandActivity commandActivity)
        {
            //Set templates for FileCase creation.
            var fileCaseFfTemplateReferenceId = "F0754977-092B-481B-8A59-AA806FFE1499";

            var startFileCases = new List <FileCase>();

            try
            {
                var hostObject = (File)commandActivity.WorkItem;

                if (hostObject == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFile
                                                                           .ToLocalizedName()
                                                                           .FormatWith(commandActivity));
                }

                if (!hostObject.CanEdit(true))
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NotEditable
                                                                           .ToLocalizedName()
                                                                           .FormatWith(hostObject));
                }

                //Create FF FileCase
                var fileCaseTemplateFf =
                    new ReferenceHandle <FileCaseTemplate>(fileCaseFfTemplateReferenceId).GetObject();
                if (fileCaseTemplateFf == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate
                                                                           .ToLocalizedName()
                                                                           .FormatWith(fileCaseFfTemplateReferenceId));
                }
                var newTitle = String.Empty;

                var ffCatalogValue = hostObject.GetProperty("#LHIND_Monatsgespraeche_Federfuehrung") as SpecialdataCatalogValue;
                if (ffCatalogValue != null)
                {
                    var ffGroup = ffCatalogValue.GetProperty("#LHIND_Monatsgespraeche_Spoc") as TenantGroup;
                    if (ffGroup == null)
                    {
                        throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoGroupDefined
                                                                               .ToLocalizedName()
                                                                               .FormatWith(ffCatalogValue));
                    }

                    var ffFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplateFf);
                    ffFileCase.LeadingGroup = ffGroup;

                    newTitle = ffFileCase.GetMultilingualValue(fc => fc.Title) + " - " + ffGroup.GetMultilingualValue(g => g.ShortName);
                    ffFileCase.SetMultilingualValue(fc => fc.Title, newTitle);

                    startFileCases.Add(ffFileCase);
                }

                ClientTransaction.Current.Commit();

                foreach (var startFileCase in startFileCases)
                {
                    startFileCase.StartObject();
                }

                ClientTransaction.Current.Commit();
            }
            catch (Exception ex)
            {
                s_logger.Error(ex.Message, ex);
                ClientTransaction.Current.Rollback();
                throw;
            }

            return(true);
        }
Exemplo n.º 5
0
        public override bool Execute(CommandActivity commandActivity)
        {
            //Set templates for FileCase creation.
            var fileCaseFfTemplateReferenceId = "B475F10A-94ED-4E75-9C64-DF6890569093";
            var fileCaseMbTemplateReferenceId = "8087873D-755F-40D4-84C6-1BA7EB8C26AC";

            var startFileCases = new List <FileCase>();

            try
            {
                var hostObject = (File)commandActivity.WorkItem;

                if (hostObject == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFile
                                                                           .ToLocalizedName()
                                                                           .FormatWith(commandActivity));
                }

                if (!hostObject.CanEdit(true))
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NotEditable
                                                                           .ToLocalizedName()
                                                                           .FormatWith(hostObject));
                }

                //Create FF FileCase
                var fileCaseTemplateFf =
                    new ReferenceHandle <FileCaseTemplate>(fileCaseFfTemplateReferenceId).GetObject();
                if (fileCaseTemplateFf == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate
                                                                           .ToLocalizedName()
                                                                           .FormatWith(fileCaseFfTemplateReferenceId));
                }
                var newTitle = String.Empty;

                var ffCatalogValue = hostObject.GetProperty("#LHIND_MitberichtExtern_FederfuhrendesAmt") as SpecialdataCatalogValue;
                if (ffCatalogValue != null)
                {
                    var ffGroup = ffCatalogValue.GetProperty("#LHIND_MitberichtExtern_Spoc") as TenantGroup;
                    if (ffGroup == null)
                    {
                        throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoGroupDefined
                                                                               .ToLocalizedName()
                                                                               .FormatWith(ffCatalogValue));
                    }

                    var ffFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplateFf);
                    ffFileCase.LeadingGroup = ffGroup;

                    newTitle = ffFileCase.GetMultilingualValue(fc => fc.Title) + " - " + ffGroup.GetMultilingualValue(g => g.ShortName);
                    ffFileCase.SetMultilingualValue(fc => fc.Title, newTitle);

                    startFileCases.Add(ffFileCase);
                }

                //Create MB FileCases
                var fileCaseTemplateMb =
                    new ReferenceHandle <FileCaseTemplate>(fileCaseMbTemplateReferenceId).GetObject();
                if (fileCaseTemplateMb == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate
                                                                           .ToLocalizedName()
                                                                           .FormatWith(fileCaseMbTemplateReferenceId));
                }

                var mbCatalogValues =
                    hostObject.GetProperty("#LHIND_MitberichtExtern_MitbeteiligtFdListe") as SpecialdataListPropertyValueCollection;

                foreach (var mbCatalogValue in mbCatalogValues)
                {
                    var mbGroup = mbCatalogValue.WrappedValue.GetProperty("#LHIND_MitberichtExtern_Spoc") as TenantGroup;
                    if (mbGroup == null)
                    {
                        throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoGroupDefined
                                                                               .ToLocalizedName()
                                                                               .FormatWith(ffCatalogValue));
                    }

                    var mbFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplateMb);
                    mbFileCase.LeadingGroup = mbGroup;

                    newTitle = mbFileCase.GetMultilingualValue(fc => fc.Title) + " - " + mbFileCase.LeadingGroup.GetMultilingualValue(g => g.ShortName);
                    mbFileCase.SetMultilingualValue(fc => fc.Title, newTitle);

                    startFileCases.Add(mbFileCase);
                }

                ClientTransaction.Current.Commit();

                foreach (var startFileCase in startFileCases)
                {
                    startFileCase.StartObject();
                }

                ClientTransaction.Current.Commit();
            }
            catch (Exception ex)
            {
                s_logger.Error(ex.Message, ex);
                ClientTransaction.Current.Rollback();
                throw;
            }

            return(true);
        }