Показать сообщение отдельно
Старый 09.02.2011, 15:29   #6  
Буденый is offline
Буденый
Участник
 
70 / 15 (1) ++
Регистрация: 07.06.2010
Адрес: Донецк
вот код:
Код:
        public void Execute(IPluginExecutionContext context)
        {
            DynamicEntity entity = null;

            if (context.InputParameters.Properties.Contains(ParameterName.Target) &&
               context.InputParameters.Properties[ParameterName.Target] is DynamicEntity)
            {
                entity = (DynamicEntity)context.InputParameters.Properties[ParameterName.Target];
            }
            else
            {
                return;
            }

            try
            {
                lock (_sync)
                {
                    // simple query to get incremental settings for this entity
                    using (ICrmService service = context.CreateCrmService(true))
                    {
                       
                        IncrementalNumbering setting = IncrementalNumbering.GetSettings(service, entity.Name);

                        // system generated, if its assigned ignore this record
                        if (setting != null && !entity.Properties.Contains(setting.PropertyName))
                        {
                            int next = setting.CurrentPosition + 1;
                        
                            StringProperty increment = new StringProperty(setting.PropertyName,setting.Prefix.ToString()+ next.ToString());
                            entity.Properties.Add(increment);

                            // keep track of the latest id inside the custom entity
                            setting.Increment(service, next);
                        }
                    }
                }
            }
            catch (System.Web.Services.Protocols.SoapException ex)
            {
........
            }
        }
если я правильно понял, то нужно создать свой метод в котором будет происходить подключение к СРМ?