question about CRI in reporting service

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • saraMoghazy
    New Member
    • Jun 2010
    • 6

    question about CRI in reporting service

    i have question please and need your help

    i have developed Custom Reporting item , i have make simple user control and sure it is done in win form , and then i took this control and have made design time component and run time component and i deploy me item,and it appear in report item toolbox , but when i tried to drag this control in the report there is an error appear : the method or operation is not implemented

    please can any one tell me what is the cause of this error

    best regards,
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Sounds like something in the in the Constructor trying to do it's job before the item is loaded.

    Can you move code from the constructor to the Load event?

    If you have custom/override on the On_Paint event, that could also be a source of the problem.

    Comment

    • saraMoghazy
      New Member
      • Jun 2010
      • 6

      #3
      re: question about CRI

      Dear tlhintoq :

      thanks for your fast reply , actually my constructor dont' do job excpet intilze varabile , and about on paint event could you please explain in more detial what do you mean by this cause

      this is my design time class


      Code:
          public class mapDesigner : CustomReportItemDesigner
          {
              private mapControl map_control;
              private DesignerVerbCollection _verbs;
      
              public mapDesigner()
              {
                  map_control = new mapControl();
              }
      
              public override void InitializeNewComponent()
              {
                  SetDefaults();
              }
      
             public void SetDefaults()
              {
                 // intial values 
                  Microsoft.ReportDesigner.Drawing.ReportColor outlineColor = new Microsoft.ReportDesigner.Drawing.ReportColor();
                  outlineColor.ColorRgb = Color.Black;
                  this.Style.BorderColor.Default = outlineColor; 
                 Microsoft.ReportDesigner.Drawing.ReportColor barColor = new Microsoft.ReportDesigner.Drawing.ReportColor();
                 barColor.ColorRgb = Color.Green;
                 this.Style.Color = barColor;
                 IComponentChangeService changeSvc = (IComponentChangeService)this.Site.GetService(typeof(IComponentChangeService));
                 changeSvc.OnComponentChanged(this, null, null, null);
              }
      
               // OVERIDE METHODS
               // override onpaint 
             public override void OnPaint(PaintEventArgs e)
             {
                  // give control some values
                 map_control.FillColor= this.Style.BorderColor.Default.ColorRgb;
                 map_control.Height = this.Height.Pixels;
                 map_control.Width = this.Width.Pixels;
                 map_control.DrawControl(e.Graphics);
             }
      
               // override default size
             public override Microsoft.ReportDesigner.Drawing.DesignSize DefaultSize
             {
                 get
                 {
                     return new Microsoft.ReportDesigner.Drawing.DesignSize(new RSDrawing.Unit(150),new RSDrawing.Unit(30));
                 }
             }
      
             public override Adornment Adornment { get { throw new NotImplementedException(); } }
             public override DesignerVerbCollection Verbs
             {
                 get
                 {
                     if (_verbs == null)
                     {
                         _verbs = new DesignerVerbCollection();
                         _verbs.Add(new DesignerVerb("Reset Defaults", new EventHandler(OnCustomAction)));
                     }
      
                     return _verbs;
                 }
             }
      
             private void OnCustomAction(object sender, EventArgs e)
             {
                 switch (((System.ComponentModel.Design.DesignerVerb)sender).Text)
                 {
                     case "Reset Defaults": SetDefaults(); Invalidate(); break;
                     default: MessageBox.Show("Not supported"); break;
      
                 }
             }
      
      
              //
             public override void BeginEdit() { }
             public override void Dispose() { }
             protected override void Dispose(bool disposing) { }
             public override void DoDefaultAction() { }
             public override void EndEdit() { }
             public override void OnBackgroundColorChanged() { }
             public override void OnColorChanged() { }
             public override void OnDragDrop(DragEventArgs e) { }
             public override void OnDragEnter(DragEventArgs e) { }
             public override void OnDragLeave(EventArgs e) { }
             public override void OnDragOver(DragEventArgs e) { }
             public override void OnFontChanged() { }
             public override void OnLocationChanged() { }
             public override void OnPaddingChanged() { }
      
             public override void OnSizeChanged() { }
             public override void OnTextAlignChanged() { }
             public override void OnTextDecorationChanged() { }
             public override bool ShowContextMenu(int x, int y) 
             {
                 return true;
             }
          }
      hint : i override all these methods cause they are virtual in parent class (do i have to do so???)

      and this is my run time class :

      Code:
      public class mapRender : ICustomReportItem 
          {
      
             private CustomReportItem _cri;
              private Microsoft.ReportingServices.ReportRendering.Image _image;
              private mapControl _progress = null;
      
      
              public mapRender()
              {
                  _progress = new mapControl();
              }
      
             // Initialize
      
             private void Initialize()
             {
                 if (null == _progress)
                 {
                     _progress = new mapControl();
                 }
                 _progress.FillColor=Color.Red;
                 _progress.Height = 100;
                 _progress.Width = 200;
             }
      
      
           public  Action Action_public
                     {
                         get
                         {
                             return null;
                         }
                     }
            public ReportItem RenderItem_public
            {
                get
                {
                    if (_image == null)
                    {
                       Process_public();
                    }
                    return _image;
                }
            }
      
          public ChangeType Process_public()
             {
                 // initialize CRI from properies in RDL
                 Initialize();
      
                 // create a memory stream to save the image
                 MemoryStream stream = new MemoryStream();
                 Drawing.Bitmap bmp = new Drawing.Bitmap(_progress.Width, _progress.Height, PixelFormat.Format32bppArgb);
                 System.Drawing.Graphics graphics = Drawing.Graphics.FromImage(bmp);
                 Drawing.Color backgroundColor = ((ReportColor)_cri.Style["BackgroundColor"]).ToColor();
                 if (backgroundColor == Drawing.Color.Transparent)
                     backgroundColor = Drawing.Color.White;
                 graphics.Clear(backgroundColor);
                 _progress.DrawControl(graphics);
                 bmp.Save(stream, ImageFormat.Bmp);
      
                 // Rewind image stream
                 stream.Position = 0;
      
                 // Create a new RS image object
                 _image = new Microsoft.ReportingServices.ReportRendering.Image(_cri.Name, _cri.ID);
                 _image.MIMEType = "image/bmp";
      
                 // serialize the image stream into the RS image
                 _image.ImageData = stream.ToArray();
      
                 _image.Sizing = Microsoft.ReportingServices.ReportRendering.Image.Sizings.AutoSize;
      
                 return ChangeType.None;
             }
      
          Action ICustomReportItem.Action
          {
              get { return Action_public; }
          }
      
          CustomReportItem ICustomReportItem.CustomItem
          {
              set
              {
                  _cri = value;
              }
          }
      
          ChangeType ICustomReportItem.Process()
          {
              return Process_public();
          }
      
          ReportItem ICustomReportItem.RenderItem
          {
              get { return RenderItem_public; }
          }
      
          }
      can you please tell me if i have problem on this implementation

      Best Regards
      Last edited by tlhintoq; Jun 7 '10, 07:50 PM. Reason: [code] your code here [/code] tags added

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        TIP: When you first created your question you were asked to wrap your code with [code] tags.
        [imgnothumb]http://files.me.com/tlhintoq/10jihf[/imgnothumb]
        It really does help a bunch. Look how much easier it is to read now that someone has done it for you. Its the button with a '#' on it. [imgnothumb]http://clint.stlaurent .net/bytes/tags-code.jpg[/imgnothumb]More on tags. They're cool. Check'em out.

        Comment

        • tlhintoq
          Recognized Expert Specialist
          • Mar 2008
          • 3532

          #5
          Personally, I wouldn't do this
          Code:
           map_control.Height = this.Height.Pixels;
                     map_control.Width = this.Width.Pixels;
          in the OnPaint. It means you are sizing every time the control is painted. I would put it in the SizeChangeCompl eted event. So when your parent control is resized, so is the encapsulated child control... but not every time it is painted.

          Things like this can cause a problem with the designer. As soon as the designer tries to paint this control, your OnPaint override is executed. But if 'this' doesn't exist... then you cannot do this.width .. and so on.

          See how this trickles down?

          Comment

          • saraMoghazy
            New Member
            • Jun 2010
            • 6

            #6
            re: question about CRI

            thank you for this advice , it really help

            Code:
             public class mapDesigner : CustomReportItemDesigner
                {
                    private mapControl map_control;
                    private DesignerVerbCollection _verbs;
            
                    public mapDesigner()
                    {
                        map_control = new mapControl();
                    }
            
                    public override void InitializeNewComponent()
                    {
                        SetDefaults();
                    }
            
                   public void SetDefaults()
                    {
                       // intial values 
                        Microsoft.ReportDesigner.Drawing.ReportColor outlineColor = new Microsoft.ReportDesigner.Drawing.ReportColor();
                        outlineColor.ColorRgb = Color.Black;
                        this.Style.BorderColor.Default = outlineColor; 
                       Microsoft.ReportDesigner.Drawing.ReportColor barColor = new Microsoft.ReportDesigner.Drawing.ReportColor();
                       barColor.ColorRgb = Color.Green;
                       this.Style.Color = barColor;
                       IComponentChangeService changeSvc = (IComponentChangeService)this.Site.GetService(typeof(IComponentChangeService));
                       changeSvc.OnComponentChanged(this, null, null, null);
                    }
            
                     // OVERIDE METHODS
                     // override onpaint 
                   public override void OnPaint(PaintEventArgs e)
                   {
                        // give control some values
                       map_control.FillColor= this.Style.BorderColor.Default.ColorRgb;
                       map_control.Height = this.Height.Pixels;
                       map_control.Width = this.Width.Pixels;
                       map_control.DrawControl(e.Graphics);
                   }
            
                     // override default size
                   public override Microsoft.ReportDesigner.Drawing.DesignSize DefaultSize
                   {
                       get
                       {
                           return new Microsoft.ReportDesigner.Drawing.DesignSize(new RSDrawing.Unit(150),new RSDrawing.Unit(30));
                       }
                   }
            
                   public override Adornment Adornment { get { throw new NotImplementedException(); } }
                   public override DesignerVerbCollection Verbs
                   {
                       get
                       {
                           if (_verbs == null)
                           {
                               _verbs = new DesignerVerbCollection();
                               _verbs.Add(new DesignerVerb("Reset Defaults", new EventHandler(OnCustomAction)));
                           }
            
                           return _verbs;
                       }
                   }
            
                   private void OnCustomAction(object sender, EventArgs e)
                   {
                       switch (((System.ComponentModel.Design.DesignerVerb)sender).Text)
                       {
                           case "Reset Defaults": SetDefaults(); Invalidate(); break;
                           default: MessageBox.Show("Not supported"); break;
            
                       }
                   }
            
            
                    //
                   public override void BeginEdit() { }
                   public override void Dispose() { }
                   protected override void Dispose(bool disposing) { }
                   public override void DoDefaultAction() { }
                   public override void EndEdit() { }
                   public override void OnBackgroundColorChanged() { }
                   public override void OnColorChanged() { }
                   public override void OnDragDrop(DragEventArgs e) { }
                   public override void OnDragEnter(DragEventArgs e) { }
                   public override void OnDragLeave(EventArgs e) { }
                   public override void OnDragOver(DragEventArgs e) { }
                   public override void OnFontChanged() { }
                   public override void OnLocationChanged() { }
                   public override void OnPaddingChanged() { }
            
                   public override void OnSizeChanged() { }
                   public override void OnTextAlignChanged() { }
                   public override void OnTextDecorationChanged() { }
                   public override bool ShowContextMenu(int x, int y) 
                   {
                       return true;
                   }
            
                }
            Code:
            public class mapRender : ICustomReportItem 
                {
            
                   private CustomReportItem _cri;
                    private Microsoft.ReportingServices.ReportRendering.Image _image;
                    private mapControl _progress = null;
            
            
                    public mapRender()
                    {
                        _progress = new mapControl();
                    }
            
                   // Initialize
            
                   private void Initialize()
                   {
                       if (null == _progress)
                       {
                           _progress = new mapControl();
                       }
                       _progress.FillColor=Color.Red;
                       _progress.Height = 100;
                       _progress.Width = 200;
                   }
            
            
                 public  Action Action_public
                           {
                               get
                               {
                                   return null;
                               }
                           }
                  public ReportItem RenderItem_public
                  {
                      get
                      {
                          if (_image == null)
                          {
                             Process_public();
                          }
                          return _image;
                      }
                  }
            
                public ChangeType Process_public()
                   {
                       // initialize CRI from properies in RDL
                       Initialize();
            
                       // create a memory stream to save the image
                       MemoryStream stream = new MemoryStream();
                       Drawing.Bitmap bmp = new Drawing.Bitmap(_progress.Width, _progress.Height, PixelFormat.Format32bppArgb);
                       System.Drawing.Graphics graphics = Drawing.Graphics.FromImage(bmp);
                       Drawing.Color backgroundColor = ((ReportColor)_cri.Style["BackgroundColor"]).ToColor();
                       if (backgroundColor == Drawing.Color.Transparent)
                           backgroundColor = Drawing.Color.White;
                       graphics.Clear(backgroundColor);
                       _progress.DrawControl(graphics);
                       bmp.Save(stream, ImageFormat.Bmp);
            
                       // Rewind image stream
                       stream.Position = 0;
            
                       // Create a new RS image object
                       _image = new Microsoft.ReportingServices.ReportRendering.Image(_cri.Name, _cri.ID);
                       _image.MIMEType = "image/bmp";
            
                       // serialize the image stream into the RS image
                       _image.ImageData = stream.ToArray();
            
                       _image.Sizing = Microsoft.ReportingServices.ReportRendering.Image.Sizings.AutoSize;
            
                       return ChangeType.None;
                   }
            
                Action ICustomReportItem.Action
                {
                    get { return Action_public; }
                }
            
                CustomReportItem ICustomReportItem.CustomItem
                {
                    set
                    {
                        _cri = value;
                    }
                }
            
                ChangeType ICustomReportItem.Process()
                {
                    return Process_public();
                }
            
                ReportItem ICustomReportItem.RenderItem
                {
                    get { return RenderItem_public; }
                }
            
                }

            Comment

            • saraMoghazy
              New Member
              • Jun 2010
              • 6

              #7
              Originally posted by tlhintoq
              Personally, I wouldn't do this
              Code:
               map_control.Height = this.Height.Pixels;
                         map_control.Width = this.Width.Pixels;
              in the OnPaint. It means you are sizing every time the control is painted. I would put it in the SizeChangeCompl eted event. So when your parent control is resized, so is the encapsulated child control... but not every time it is painted.

              Things like this can cause a problem with the designer. As soon as the designer tries to paint this control, your OnPaint override is executed. But if 'this' doesn't exist... then you cannot do this.width .. and so on.

              See how this trickles down?
              i have done that

              Comment

              • saraMoghazy
                New Member
                • Jun 2010
                • 6

                #8
                Originally posted by saraMoghazy
                i have done that
                but stil the same error appear

                Comment

                • tlhintoq
                  Recognized Expert Specialist
                  • Mar 2008
                  • 3532

                  #9
                  Code:
                  public mapDesigner()
                          {
                              map_control = new mapControl();
                          }
                  Just as a test, comment out this part. Don't make the mapControl when you make the Designer.

                  I've had this be a problem in a few cases when I nested one control inside another. The constructor for the nested control had some issue because it couldn't find a DLL it was dependent on in the new parent project and so on.

                  Comment

                  • saraMoghazy
                    New Member
                    • Jun 2010
                    • 6

                    #10
                    Originally posted by tlhintoq
                    Code:
                    public mapDesigner()
                            {
                                map_control = new mapControl();
                            }
                    Just as a test, comment out this part. Don't make the mapControl when you make the Designer.

                    I've had this be a problem in a few cases when I nested one control inside another. The constructor for the nested control had some issue because it couldn't find a DLL it was dependent on in the new parent project and so on.
                    i have done it , the same error appear when i drag the control to report layout , do you think this may be problem in deployment , let me say my steps in deploy :

                    1- i have copy the CRI dll to 2 folders

                    C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\P rivateAssemblie s

                    &&

                    C:\Program Files\Microsoft SQL Server\MSRS10.M SSQLSERVER\Repo rting Services\Report Server\bin

                    2- i have copy in the RSReportDesigne r this

                    Code:
                     <ReportItems>
                    		  <ReportItem Name="mapControl" Type="MapCRI.mapRender,MapCRI"/>
                    	  </ReportItems>
                    
                    
                    	  <ReportItemDesigner>
                    		  <ReportItem Name="mapControl" Type="MapCRI.mapDesigner,MapCRI"/>
                    where MapCRI is the namespace and mapDesigner , mapRender classes inside this solution

                    3- copy in rsreportserver this :

                    Code:
                    <ReportItem Name="mapControl" Type="MapCRI.mapRender,MapCRI"/>
                    in
                    in rssrvpolicy

                    <CodeGroup class="UnionCod eGroup" version="1" Name="CRICodeGr oup" Description="Co de group for the ProgressTracker CRI" PermissionSetNa me="FullTrust" >
                    <IMembershipCon dition class="UrlMembe rshipCondition" version="1"
                    Url="C:\Program Files\Microsoft SQL Server\MSRS10.S QLSERVER2008\Re porting Services\Report Server\bin\MapC RI.dll"/>

                    is that the compelete deploy

                    Comment

                    Working...