Monday, 23 April 2012

Oracle create or replace Stored Procedure example basics

An Oracle stored procedure is an Oracle object that you create using PL/SQL. PL/SQL is a procedural language which is used by Oracle developers to process and manipulate data stored in an Oracle database.
The basic form of an Oracle stored procedure is
CREATE OR REPLACE PROCEDURE p_procedure1 IS
BEGIN

null;
END p_procedure1;


The stored procedure above will compile successfully.
Now lets discuss the procedure above.
CREATE OR REPLACE: You must use CREATE command whereas REPLACE is optional. But if you do not put REPLACE then you can not recompile the stored procedure if it already exists. By putting CREATE OR REPLACE you are saying that if it already exists then replace it with the new version.
PROCEDURE: This clause specifies the type of object that you want to create. Here we are saying it to be a procedure.
BEGIN and END: This is the body of the procedure. All code that you want to put in the procedure should live here. In the example above I have put null; It means do nothing. However even if you do nothing and just want to create a stored procedure (as above) you still need to put the Begin and End to complete the frame of the stored procedure. For clarity I have put End p_procedure1 which is not required. Instead you could just put End;
Example of Oracle Store Procedure with parameters:
Most of the time when calling an Oracle procedure you would like to pass on some parameter to the procedure to process it or to do something with the data in the parameter. You can pass parameters to a stored procedure as below:
CREATE OR REPLACE PROCEDURE p_procedure2(p_name varchar2) IS
BEGIN

dbms_output.put_line(p_name);
END p_procedure2;
Here I am passing a parameter called p_name to the stored procedure p_procedure1; Then in the body section I am displaying the value of the parameter.
You can use “dbms_output.put_line()” to display the values of parameters in SQL*Plus window. This is same PRINT/ECHO/PRINTLN used in other programming languages.
Now the parameters that you pass to a stored procedure can be of three types (IN, OUT and IN OUT).
IN - is the default type. So if you do not specify the parameter type then IN is used. This is telling that I am supplying a parameter to the stored procedure.
OUT – is used to get values back from the stored procedure.
IN OUT – is used to pass values to a stored procedure and to get values from the stored procedure using the same parameter.
Unlike Oracle functions you can return multiple values using the out parameter.
For example: if you want to get back the employee name of an employee and you have just the emp_no (employee number) then you can pass the emp_no to a stored procedure using an IN parameter and then get the employee name using an out parameter. This is demonstrated below:
CREATE OR REPLACE PROCEDURE p_procedure3(p_emp_no IN number, p_name OUT varchar2) IS
BEGIN

SELECT ename
INTO p_name
FROM emp
WHERE emp_no = p_emp_no;
END p_procedure3;


Here we are passing the emp_no and using that we are getting ename from table emp. The returned value is put into p_name and the calling program will be able to access this p_name.
Now when we use out parameter it becomes a little bit different while executing a stored procedure.

Source - http://www.oraclecity.com/plsql-tutorial/oracle-create-or-replace-stored-procedure-example-basics/

regards
Rajesh K

Wednesday, 11 April 2012

In which scenario we use Abstract Classes and Interfaces

Interface: 
–> If your child classes should all implement a certain group of methods/functionalities but each of the child classes is free to provide its own implementation then use interfaces.
For e.g. if you are implementing a class hierarchy for vehicles implement an interface called Vehicle which has properties like Colour MaxSpeed etc. and methods like Drive(). All child classes like Car Scooter AirPlane SolarCar etc. should derive from this base interface but provide a seperate implementation of the methods and properties exposed by Vehicle.
–> If you want your child classes to implement multiple unrelated functionalities in short multiple inheritance use interfaces.
For e.g. if you are implementing a class called SpaceShip that has to have functionalities from a Vehicle as well as that from a UFO then make both Vehicle and UFO as interfaces and then create a class SpaceShip that implements both Vehicle and UFO .
Abstract Classes
–> When you have a requirement where your base class should provide default implementation of certain methods whereas other methods should be open to being overridden by child classes use abstract classes.
For e.g. again take the example of the Vehicle class above. If we want all classes deriving from Vehicle to implement the Drive() method in a fixed way whereas the other methods can be overridden by child classes. In such a scenario we implement the Vehicle class as an abstract class with an implementation of Drive while leave the other methods / properties as abstract so they could be overridden by child classes.
–> The purpose of an abstract class is to provide a common definition of a base class that multiple derived classes can share.
For example a class library may define an abstract class that is used as a parameter to many of its functions and require programmers using that library to provide their own implementation of the class by creating a derived class.

Use an abstract class

  • When creating a class library which will be widely distributed or reused—especially to clients, use an abstract class in preference to an interface; because, it simplifies versioning. This is the practice used by the Microsoft team which developed the Base Class Library. ( COM was designed around interfaces.)
  • Use an abstract class to define a common base class for a family of types.
  • Use an abstract class to provide default behavior.
  • Subclass only a base class in a hierarchy to which the class logically belongs.
 Use an interface
  • When creating a standalone project which can be changed at will, use an interface in preference to an abstract class; because, it offers more design flexibility.
  • Use interfaces to introduce polymorphic behavior without subclassing and to model multiple inheritance—allowing a specific type to support numerous behaviors.
  • Use an interface to design a polymorphic hierarchy for value types.
  • Use an interface when an immutable contract is really intended.
  • A well-designed interface defines a very specific range of functionality. Split up interfaces that contain unrelated functionality.
 Source - http://mycodelines.wordpress.com/2009/09/01/in-which-scenario-we-use-abstract-classes-and-interfaces/

happy coding
Rajesh K

What's the difference between an ABSTRACT CLASS and an INTERFACE

A good way to distinguish between a case for the one or the other for me has always been the following:

1. Are there many classes that can be "grouped together" and described by one noun? If so, have an abstract class by the name of this noun, and inherit the classes from it. (A key decider is that these classes share functionality, and you would never instantiate just an Animal... you would always instantiate a certain kind of Animal: an implementation of your Animal base class)
Example: Cat and Dog can both inherit from abstract class Animal, and this abstract base class will implement a method void Breathe() which all animals will thus do in exactly the same fashion. (I might make this method virtual so that I can override it for certain animals, like Fish, which does not breath the same as most animals).

2. What kinds of verbs can be applied to my class, that might in general also be applied to others? Create an interface for each of these verbs.
Example: All animals can be fed, so I will create an interface called IFeedable and have Animal implement that. Only Dog and Horse are nice enough though to implement ILikeable - I will not implement this on the base class, since this does not apply to Cat.

As said by someone else's reply: the main difference is where you want your implementation. By creating an interface, you can move your implementation to any class that implements your interface.
By creating an abstract class, you can share implementation for all derived classes in one central place, and avoid lots of bad things like code duplication.

Source - http://social.msdn.microsoft.com/forums/en-US/csharplanguage/thread/8ad621b8-a915-4d7e-89c3-5dbbc47202fd/

happy coding
 Rajesh K

Tuesday, 14 February 2012

It's a gap again, working with Python, will be posting the step by step guide to work with IronPython,,, also I have not seen much work in GIS using IronPython.... let me think about it

Happy coding,
Rajesh K

Monday, 6 February 2012

Python - I'm lovin it :)

Soon expect good post in Python. Yes, Iron Python....lots of ideas flowing in mind would soon execute them and share right now busy working with GDB manager documentation, cheers

happy coding
Rajesh K

Saturday, 21 January 2012

Process Framework Administration Tool - Configuration and Customization


Introduction: The Process Framework Administration Tool (PFA@) is one of the most interesting tools in ArcFM. This tool mainly takes complete control over various extensions and in my experience it’s over Session Manger(SM*) and Workflow Manger (WFM*).
When I say complete control, I really mean the complete workflow of both the extensions from the start till the end or in simple language the lifecycle of the extension in action.
I would like to share in this post the configuration involved within this PFA@ tool either for SM* or WFM*. There are pretty much interesting facts within this PFA@ and I love to share them all in this article.

Get started -- 
The main role of PFA@ tool is that to manipulate the table at the back drop in the DB which controls the workflow of these extensions. This is just an UI for you to manipulate or to get your business requirements solved with the extensions.

In the PFA@ tool, one will be encountering lots of tabs as seen in the screen shot below.



Each of these tabs is each of different themes but all are interrelated to each other. A business requirement can only be completed by having proper configuration of all these tabs. Any one mistake in these tab or failed to set a value or user or his role, the business requirement would fail even the workflow too.

USERS --
Once you log into the PFA@ tool the very first tab should be dealing with is USERS tab. Under this tab an administrator can add his users who might be eligible to edit or handle any session or a design in ArcMap. The key point in here is that both the PFA@ tool and SDE should share same users between them. It doesn't mean that you cannot ad a new name here but it's worthless adding a name or user without having the same one in SDE.

User Name#The user id of any user.
Display Name - Will be the values that would be displaying in the SM* or WFM* UI in ArcMap.
Description – Description of the user.
Below the list of Users or the user names we have the roles listed out. Before explaining Roles, you can assign the role of each individual user, say “User1” can edit, “User2” can approve a design or session, “User3” can reject. Similarly it’s possible for a user to have multiple roles assigned to him based on the business requirement.
  
ROLES --
Under this tab we can assign create or add roles, whereas the same should be shared in SDE in case of enterprise GDB as discussed earlier. Assigning these roles to a user means, as described earlier, which is eligible for what action to perform.

Role- The login name of the user.
Role Name – Name displayed in the SM* or WFM* UI.
Description- Description of the role, if any.

Extension - The value under the EXTENSION field denotes that for what extension this role is applicable, if configured for SM* this role would only be applicable for SM* i.e. MMSessionManager but not for WFM*. Similarly if you have WMF or Designer license we would have further more roles in the same list.

 STATES --
States is one of my most interesting tabs in PFA@. The states of a session or a design denote or mean the status of the SESSION or DESIGN. Say a user created a design and the current status of the design immediately after creation may be DESIGN CREATED, after creation of the design the user gets down to design by now the status of the same design may be DESIGN IN PROGRESS and as this designer workflow progresses the state of the design keeps changing (as configured).
We have room for any design or a session to move from any state to any state and this room availability is purely allowed by PFA@ tool. The configuration in PFA@ can help you move the states from any state to other.

 Field State – the numeric notation of a state
Node Type – the Type of node that the state should be available for. For example in SM* UI, all the controls you see are considered as a node but the node type differentiates them. A PxControl is also a node, a PxFilter is also a node but all the type differentiates. So, the value under the NODE TYPE filed sets to which node the state should be applicable.
State Name – Name of the state of the value that appears in the UI in ArcMap.
Description – Any meaningful description for you state.
Control - Apart from the states, this STATES tab is also holds control over the PxControl. As per the screen shot below “Session UI” is the ArcFM OOTB PxControl. Still you can customize your own UI as per the requirement. Can read about creating and configuring custom PxControl http://rrajeshh.blogspot.com/2012/01/arcfm-snippet-5-implementing-pxcontrol.html
Bitmap – You can define your own icon or symbology for your session or designs based on each state other than ArcFM OOTB. This is again an option to the users to customize their application to maximum.


As like the USERS tab STATES tab too has ROLES listed here, again this is to have control over your requirement. You can define who can have what state or who can view a session of a particular state. You can control a user to view a session of a particular state.

In a simple scenario let us consider we have THREE USERS
1) Session Editor 2) Session Approver and 3) Session Administrator,
THREE STATES
1)  In Progress 2) Pending Approval and 3) Session posted
And the ROLES allotted for each state are as below

In Progress – Session Editor
Pending Approval – Session Editor and Session Approver
Posting in Progress – Session Approver and Session Administrator

Scene 1 – the editor creates a session with name “TEST SESSION”. Once after successful creation of the session. The state of “TEST SESSION” will be In Progress. This session will only be visible for the Session Editor, because the role property of the state (In Progress) has been assigned only to the Session Editor.

Scene 2- He starts editing, by now the state of the session will be In Progress and once after he completes the his editing he submits or send his session to the SESSION APPROVER for validating or for any approval, by now or once the session is sent to the session Approver the session's state will be Pending Approval which would only be visible to Session Approver and Session Editor as because of the roles assigned to Pending Approval state in PFA@ configuration. It is sure that both Session Editor and Session Approver can get the “TEST SESSION” listed in their respective SM* UI because of the same above reason. Whereas the TEST SESSION will not be listed for Session Administrator in his SM* UI.

Scene 3 – The Session Approver is happy with the edits and he is sending the same session “TEST SESSION” to Session Administrator to post it to SDE.Default. Once he sends the session to the Session Administrator. The session will no longer be listed for SESSION EDITOR but for both SESSION ADMINISTRATOR and SESSION APPROVER. Because the state of the session now would be “Posting in Progress” and only because of the roles assigned to this State.

Here what we have seen is a very simple scenario; still we can have many states within the very same short story. Let's say if the edits made by the session Editor is not good and the Session Approver thinks to send it back to the editor for rework. In such case, we can have one more state as “Session Rejected” or “Rework” etc and the roles can be assigned to Session Editor as the Session Approver has nothing to do with that session while rework.

Make use of the add button and add any number STATES.

Note: Even if you want a separate state between creating and editing a session yes, still you can have. The action of states is not done within the STATES tab, as we have understood earlier all tabs are interrelated with each other. The discussion we have above is just to understand how a state would work but we are yet to understand how other factors are controlling the states and how state would control other TABS.

During customization one can access these states as below
  
Type appReference = Type.GetTypeFromProgID("esriFramework.AppRef");
                object appRefObject = Activator.CreateInstance(appReference );
             IApplication applicationPx =     appRefObject as Iapplication;
            IMMPxIntegrationCache mmPxIntegrationCache = applicationPx.FindExtensionByName("Session Manager Integration Extension") as IMMPxIntegrationCache;
            IMMPxApplication mxApplication = mmPxIntegrationCache.Application;           IMMEnumPxStates states= mxApplication.States;
IMMPxState eachState= states.Next();


TRANSITIONS --
Transition and State are like fire and heat. This ArcFM transition has no other meaning which we are unaware; the move of one form to other is called transition. In ArcFM terminology movement of one STATE to other is called as TRANSITION. Let's get back to the same story we discussed under STATES tab.

Each State change we discussed earlier is only because of the Transition. In Scene 1, we have seen the editor creates a new session to make his edits. Once he creates a new session “In Progress” happens to be the state while he created a session or in editing mode (as per our story). So, behind the scene it’s really the transitions that have brought in the change. The screen shot above depicts the same

For the transition SESSIONCREATE, the ROLE Property is SESSION EDITOR (don't mind Redline Technician). It's because as per our simple scenario only a session editor is creating a session so the role for the transition SESSIONCREATE has been assigned to a SESSION EDITOR but no other.
Also, on the right side we have two other properties for the transition i.e. FROM STATE and TO STATE. These two properties are the way finder for any transition; this tells the transition to move in which direction. Coming back to the same scene 1 in our scenario the session editor creates a session and the transition SESSIONCREATE will be called and the transition will look for the FROM and TO STATE property, as in the picture above it has configured from NONE to IN PROGRESS. So this transition allocates the state for the “TEST SESSION”. The same method is followed for other state changes too e.g. Pending Approval etc.
A FROM property can have any number of TO association and vice versa. Based on any business requirement we can have any number of transitions and any combination of FROM and TO state property.

Click on the ADD button to add a new transition.
The value under Transition is the transition Name
The value under Transition Name is the Name of the transition which would appear in GUI
The value under Description is the description for your transition.
The value under Node type is that to say on which node type the transition should act.

NODE TYPES --
A node type is a name given to any node with common process flow.
The value under the ID Field is the ID of the Node type.
The Value under the Node Type is the type of node.
The value under Description is the description for your Node type.
The value under the Extension is extension to which the node type is of.
The value under Deleter and Version Names allows you to assign Deleter and Version Namer objects to a node type. You may select a deleter or version namer from the pull-down menus in each field. These menus are populated based on components in the M&M Process Framework Deleter and M&M Process Framework Namer component categories.

Deleter objects coordinate the deletion of node data in the Process Framework with deletion of data in ArcMap. Enter the Deleter object's ProgID in the Deleter Prog ID field to enable it for the selected node type.

Version Namer objects determine a logical name when a new version is created for a node. Enter the Version Namer object's ProgID in the Version Namer ProgID field to assign it to the selected node type.

Session Manager Node type

Workflow Manager Node types
TASKS --
Tasks are director of the complete workflow, irrespective of SM* or WFM*. Each Task performs one or serious of actions, and that one or serious of actions are the SUBTASKS. In other words a PxTASK is nothing but the collection of SUBTASK (IMMPxSUBTASK). Looking back our scene 2, it is a TASK of a session editor to send his edits to the Session Approver, but behind this task we have couple of subtasks working viz. Subtask to set the state and Subtask to change the owner of the session.
Each node type can have a set of tasks (which are made up of subtasks) associated with it. Only tasks associated with a node type can be invoked by a node of that type. If the same task is applicable to more than one node type, each node type must have a separate task defined and configured.


For adding a new task you can click on ADD TASK and add a new task, certainly as discussed earlier a TASK is a combination of subtasks.

Before getting down to configure a new task or a subtask, let's discuss on creating a new subtask “CHANGE SESSION OWNER”. The code below I have shared is just to replicate the following screen shot but do not expect the code to function properly.
Implement IMMPxSUBTASK to create a Subtaks

public class SetStateForMySession : IMMPxSubtask, IMMPxSubtask2

    {
          /// <summary>
         /// Unique name for the subtask
         /// </summary>

         private string _pxSubtaskName = "Change Session Owner";
      
         /// <summary>
         /// Dictionaries subtask parameters and parameter values
         /// </summary>
         private IDictionary _supportedParams, _parameterValues;

        /// <summary>
         /// object to display in process manager
         /// </summary>
         private object _key1 ="DefaultUser” ;
         private object _key2 ="AutoChangeOwner” ;

        /// <summary>
        /// Object to read the value from the process manager
        /// </summary>
        private object _value1;
        private object _value2;

        ///  Method which ENABLES the subtask. If returned false the Subtask will not be enabled for execution. Which may affect the following Subtask also making your TASK to fail.
         bool IMMPxSubtask.Enabled(IMMPxNode pPxNode)
         {
             return true;
         }
     

         ///  Method which EXECUTES the subtask. If returned false the Subtask will not be executed. Which may affect the following Subtask making your TASK to fail.
       bool IMMPxSubtask.Execute(IMMPxNode pPxNode)
         {
           return true;
         }
  
        /// Method return the name of the subtask
         string IMMPxSubtask.Name
         {
             get { return _pxSubtaskName ; }
         }

         // Method which retuns the parameter values
         IDictionary IMMPxSubtask2.Parameters
         {
             set
             {
                 // Parameter value read from the Process frame work manager
                 _parameterValues= value;
             }
         }
  
        // Method which identifies the Extension for the subtask     
         IMMEnumExtensionNames IMMPxSubtask2.SupportedExtensions
         {
             get
             {
                 // Finding the application extension
                 IMMEnumExtensionNames enumExtNames = new PxExtensionNamesClass();
                 enumExtNames.Add(”MMSessionManager”);
                 return enumExtNames;
             }
         }
  
       /// Method which takes the Parameter names
          IDictionary IMMPxSubtask2.SupportedParameterNames
         {
             get
             {
                 // Parameters to be displayed in the process manager
                 // You can add as many as Params you require to be dispalyed in Processframework Administration tool
               
            }
        }
    }
}
OOPS, you forgot to register your Subtask ;)

Once after successful creation of a custom SUBTASK, the following steps are to configure them to see in action.
1 Enter a task name and description.
2 Check the Visible in Task Tool checkbox if you want the task to be shown in your Process Framework extension (such as Session Manager). If this checkbox is selected, the user has the necessary role to perform the tasks, and all of its criteria to be enabled are satisfied, the task will appear in the Task Tool. Uncheck this field if you wish to hide a task.
3 Use the bottom window the add subtasks to your task. The up/down arrow buttons allow you to arrange the subtasks in the order you want them to execute.
4 If you select a subtask that contains parameters, you may designate the parameter values. In the example below, the Change Owner by Role subtask contains a Roles parameter. The subtask will return a list of users filtered by the parameter value entered in the Parameter Values field. The sample parameter below uses the Role field (on the Roles tab). When configuring the task, the user may enter a value to determine who the list of users is filtered. For information about custom subtasks, refer to the ArcFM Solution Developer Help, Customize Process Framework section.
5 Select a transition or a task role. If you select a transition, that transition and the roles assigned to it will be used. If you do not select a transition, you may apply user roles using the task roles field.
6 Click OK to save the task.
7 On the Node Types tab, the Order button allows you to determine the order in which the tasks appear in the Task tool in you extension.

FILTERS --
Filters are one of the useful tool  for a user in SM* and WFM* UI. It filters out the sessions or designs based on a user, state etc. Yes, we have room to create custom filters based on busniess requirement. Again roles can be assigned to a particular filter by which that particular user has accessibility for that particular filter.


When you talk about creating your own custom filter use IMMPxFilter and IMMPxFilterEx to create a custom filters.
Do not fail you register your filter

Miner.ComCategories.MMFilter.Register(regKey);
Miner.ComCategories.MMFilter.UnRegister(regKey);
  
EXTENSIONS --
The Extensions tab allows you to list the extensions that are supported by the database to which you are currently logged in. Use the Add and Delete buttons to modify the list.


IMPORT/ EXPORT --
This tab helps the administrator to export the configuration/ Compatible Units to a XML for future use or as a backup.
                              
While you try to import similar XML, one will encounter the similar UI asking to replace or to append the already available configuration. When you say append it really appends the data if there is any change from the earlier available configuration.


While to try to export,the following UI should be encountered asking what has to be exported and where.
The same Import and Export is possible in command line, refer http://resources.arcfmsolution.com/DesktopConfig/webframe.html

CONFIGURATION --
 This configuration tab really stores the information in one of the process tables I.e. MM_PX_CONFIG table available in the database. This tab enables you to configure the general configuration to designer or WFM* and Mobile configurations.
The basic configuration includes the prefix of the session SN_, default version, Px_Command Timeout, checking out ESRI license etc.


Conclusion: Yes, a deep look on the configuration and customization of PFA@ is been discussed here. By this article one cannot be successful either in configuration or customization, practice and further deep understanding of this tool makes any implementation perfect. Suggesting the readers of this article to get into PFA@ tool with lots of trail configurations to realize the actual relationship of the tabs in this PFA@ tool. Also, this article is not concluding the complete workflow of SM* or WFM*, we are yet to conclude with Geodatabase Manger (GDB Manager). In next post will discuss about configuring and customizing GDB manager too.
Please make note you can always refer to Telvent web pages for much better understanding of the same tool. Contents in this article cannot be taken as a complete configuration and customization guide, the information you came across are purely my experience but am sure this will get anyone a good start.
For more details information in this configuration please refer to http://resources.arcfmsolution.com/DesktopConfig/webframe.html

References:

* - My own short forms
@ - Process Framework Administration Tool
# - Use Name should not have spaces in between and any special character.



Happy Coding
Rajesh K


Friday, 20 January 2012

Post for the weekend - ProcessFramework Administration Tool Configuration and Customization

Already, I'm half the way through with my documentation for PFA tool configuration and customization. Planning to post for this weekend..... Expecting good amount of response as I'm getting :)

Cheers
Happy Weekend

ArcFM Snippet #6 Special AutoUpdater

This is a very short post in how to use the methods of an AutoUpdater. Implement IMMSpecialAUStrategyEx if you wish to set any AU on editing event, importantly a feature.


namespace AutoUpdaterTest
{
   
    [Guid("749cbcee-89c7-48a1-a39c-90d16w99ye18")]
     public class NewAU : IMMSpecialAUStrategyEx
    {
       
        #region Com Registration
        [ComRegisterFunction()]
        static public void Reg(string regKey)
        {
            SpecialAutoUpdateStrategy.Register(regKey);
        }

        [ComUnregisterFunction()]
        static public void Unreg(string regKey)
        {
            SpecialAutoUpdateStrategy.Unregister(regKey);
        }
        #endregion

      
       #region IMMSpecialAUStrategyEx Members

        void IMMSpecialAUStrategyEx.Execute(ESRI.ArcGIS.Geodatabase.IObject pObject, mmAutoUpdaterMode eAUMode, mmEditEvent eEvent)
        {
        //eAUMODE defines the mode of the AU, which you can enable and disable an AU at runtime
        //eEvent defines or says which edit event really has happened in runtime. Feature Creation, Feature deletion or updation( refer ArcFM Snippet #4)
          }

        string IMMSpecialAUStrategyEx.Name
        {
            // AU Name
            get { return "My Own Au"; }
        }


// Here really you say whether you like to enable or disable your AU, if required you can check some prerequisite for your AU to get executed. If returned FALSE, the AU will not execute.       
     bool IMMSpecialAUStrategyEx.get_Enabled(ESRI.ArcGIS.Geodatabase.IObjectClass pObjectClass, mmEditEvent eEvent)
        {
            return true;
        }

        #endregion

    }
}

Later in following posts will write about the other two types of AUs( Attribute and Relationship)



Happy coding
Rajesh K

Tuesday, 10 January 2012

ArcFM Snippet 5# Implementing a PxControl

This is yet another simple implementation. I, here share you the idea how we would create and bring in a custom PxControl in either Workflow manager or Session Manager UI.
First, you decide and design your UI for the PxControl the very normal way you would design for a windows form application. Once you are done with your design all you need to do is to refer your form instance in a class file, which really implements the IMMPxControl interface. Yes, create a class file which implements IMMPxControl and add all the methods implicitly or explicitly and there you go, you are done with your PxContorl.

Please mind to register your PxControl :) as below with  [ComRegisterFunction()]


MMProcessMgrControl.Register() and MMProcessMgrControl.UnRegister()


Other Methods would be as below

public bool Enable
{
get { return anyBoolValue;}
set { value= anyBoolValue;}

}

I use InitData to initialize my IMMPxApplication
public void IMMPxControl.Initialize(object vInitData)
{
  IMMPxApplication  pxApplication = vInitData as IMMPxApplication;

}

The node which is getting into picture at the runtime
public  IMMPxNode Node
{
    set {
IMMPxNode pxNode= value;}
}


Sets the PxControl's Visibility, return your form's visibility.
public bool Visible
{
      get {
return YouWindowsForm.Visible; }
      set {
YouWindowsForm.Visible = value;}
}

Return your form's Handle value
public int hWnd
{
      get{
return YouWindowsForm.Handle.ToInt32();}
}


Also, you can implement IMMPxDisplayName for your PxConrol, which gives the specific name for your PxControl, used to select in ProcessFrameWork Administration Tool.

        public string IMMPxDisplayName.DisplayName
        {
            get { return "My New PxControl"; }
        }


Once after all these, build your application and your PxControl should get registered and ready for you to configure. Log into your PFA->STATES tab-> Select the NODE TYPE as SESSION (if you want this PxControl for a Session), If you are interested to show your PxControl only on a particular SESSION's STATE-> Select a state and and under CONTROL click on the right end of the text box you will get drop down and choose your PxControl( "My New PxControl"). Next the BITMAP-> if you wish to have a unique icon for your sessions, you can add and use them.

 


If you do not find your PxControl listed in the drop down, am sure something has not went well with you code or registration. Save your settings and log into your session manager and and click on any of your session and make sure your session is in the state you have configured in PFA tool for your PxControl.

This is the default PxControl, similarly one can design his own PxControl.


Happy Coding

Rajesh K

Friday, 6 January 2012

Shift in my Coordinate conversion

Anyone out there with a solution for me??? for the shift am getting in my coordinate conversion....
Yea, I try to convert WGS84 to GDA1994MGA_50 am getting the shift in my result.
I get the WGS84 coordinates @ runtime and I convert SR the below way which results in a shift :( :( .....


private static IGeometry5 ConversionFromWGS84(IGeometry5 geometryFromWGS)
        {
            ISpatialReferenceFactory SRFactory = null

            Type t = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
            object obj = Activator.CreateInstance(t);
            SRFactory = obj as ISpatialReferenceFactory;

            ISpatialReference srGCS = new GeographicCoordinateSystemClass();
            ISpatialReference srPCS = new ProjectedCoordinateSystemClass();
            srGCS = SRFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);
            srPCS = SRFactory.CreateProjectedCoordinateSystem(m_Document.FocusMap.SpatialReference.FactoryCode); 
            geometryFromWGS.SpatialReference = srGCS;
            geometryFromWGS.Project(srPCS);
            return geometryFromWGS;
        }


I even tried implementing IGeoTransformation but no luck

sometimes unhappy coding too .....

regards
Rajesh K