Example #1
0
        public void Execute(IServiceProvider serviceProvider)
        {
            SqlDataAccess sda = null;

            #region | Service |
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }

            IPluginExecutionContext     context        = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
            IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
            IOrganizationService        adminService   = serviceFactory.CreateOrganizationService(Globals.AdministratorId);
            OrganizationServiceContext  orgContext     = new OrganizationServiceContext(adminService);
            #endregion
            Entity entity = (Entity)context.InputParameters["Target"];
            if (context.PostEntityImages.Contains("PostImage") && context.PostEntityImages["PostImage"] is Entity)
            {
                Entity postImage = (Entity)context.PostEntityImages["PostImage"];
                if (context.Depth < 2)
                {
                    BuildingsManagementHelper.CheckRecordDublicate(postImage, sda, adminService);
                    BuildingsManagementHelper.UpdatePortal(postImage, adminService);
                }
            }
        }
Example #2
0
        public void Execute(IServiceProvider serviceProvider)
        {
            SqlDataAccess sda = null;

            try
            {
                sda = new SqlDataAccess();
                sda.openConnection(Globals.ConnectionString);

                #region | Service |
                if (serviceProvider == null)
                {
                    throw new ArgumentNullException("serviceProvider");
                }

                IPluginExecutionContext     context        = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
                IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                IOrganizationService        adminService   = serviceFactory.CreateOrganizationService(Globals.AdministratorId);
                OrganizationServiceContext  orgContext     = new OrganizationServiceContext(adminService);
                #endregion

                if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
                {
                    Entity entity = (Entity)context.InputParameters["Target"];
                    BuildingsManagementHelper.CheckRecordDublicate(entity, sda, adminService);
                    BuildingsManagementHelper.SetNumber(entity, sda, adminService);
                    BuildingsManagementHelper.CreatePortal(entity, sda, adminService);
                }
            }
            catch (Exception ex)
            {
                throw new InvalidPluginExecutionException(ex.Message);
            }
            finally
            {
                if (sda != null)
                {
                    sda.closeConnection();
                }
            }
        }