Wednesday 30 July 2014

How to "PUT" and "GET" queue item IBM WebSphere Queue - C#

Leave a Comment
This is example C# code how to insert value into IBM WebSphere  Queue, and Get The Queue value back.
You can use Queue to store some information to processed later without involve database. You can read more about IBM WebSphere queue in here

Put Message C# Code

            MQQueueManager queueManager;
            MQQueue queue;
            MQMessage queueMessage;
            MQPutMessageOptions queuePutMessageOptions;
            MQGetMessageOptions queueGetMessageOptions;


            string ChannelInfo;
            string channelName;
            string transportType;
            string connectionName;

            //get channel info
            char[] separator = { '/' };
            string[] ChannelParams;

            ChannelInfo = "CHANNEL3/TCP/172.19.37.2";
            ChannelParams = ChannelInfo.Split(separator);
            channelName = ChannelParams[0];
            transportType = ChannelParams[1];
            connectionName = ChannelParams[2];

            //get queue manager
            string queueManagerName = "QMGR3";
            string queueName = "TESTQ";

            queueManager = new MQQueueManager(queueManagerName, channelName, connectionName);
            queue = queueManager.AccessQueue(queueName, MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING);
            queueMessage = new MQMessage();
            queueMessage.WriteString("TEST");
            queueMessage.Format = MQC.MQFMT_STRING;
            queuePutMessageOptions = new MQPutMessageOptions();

            //putting the message into the queue
            queue.Put(queueMessage, queuePutMessageOptions);
            queue.Close();
            MessageBox.Show("Successfully put data into queue");



Get Message C# Code

            MQQueueManager queueManager;
            MQQueue queue;
            MQMessage queueMessage;
            MQPutMessageOptions queuePutMessageOptions;
            MQGetMessageOptions queueGetMessageOptions;

            string ChannelInfo;
            string channelName;
            string transportType;
            string connectionName;

            //get channel info
            char[] separator = { '/' };
            string[] ChannelParams;
            ChannelInfo = "CHANNEL3/TCP/172.19.37.2";

            ChannelParams = ChannelInfo.Split(separator);
            channelName = ChannelParams[0];
            transportType = ChannelParams[1];
            connectionName = ChannelParams[2];

            //get queue manager
            string queueManagerName = "QMGR3";
            string queueName = "TESTQ";

            queueManager = new MQQueueManager(queueManagerName, channelName, connectionName);
            queue = queueManager.AccessQueue(queueName, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING);
            string str_rtn = string.Empty;

            while (true)
            {
                try
                {
                    queueMessage = new MQMessage();
                    queueMessage.Format = MQC.MQFMT_STRING;

                    queueGetMessageOptions = new MQGetMessageOptions();
                    queue.Get(queueMessage, queueGetMessageOptions);
                    str_rtn = queueMessage.ReadString(queueMessage.MessageLength);

                    MessageBox.Show(str_rtn);
                    break;

                }
                catch (MQException MQExp)
                {
                    str_rtn = "MQQueue::Get ended with " + MQExp.Message;
                    MessageBox.Show(str_rtn);
                    return;                  

                }
            }
            queue.Close();


Note : You need to include library IBM.WMQ . ( using IBM.WMQ; )


By
NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)
Read More...

How to get user name of logon windows user.

Leave a Comment
This Code shows how to get user name of log on windows user.

Here is the code :

C# Code 

string a;
a = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString(); 
MessageBox.Show(a.ToString());




By
NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)
Read More...

Friday 4 July 2014

How to specify WhereCondition in Transformation - Nested Control - kentico 8, 7, 6

Leave a Comment
Before this i wonder how to pass some where condition in transformation repeater. So i ask the kentico guys and he give me a solution which i think i can share to the others.

So in your transformation you can specify the <script runat="server"></script> element. This is where you can pass the where condition.

Let see the example :

Transformation Code


<cms:queryrepeater id="repItems" ... DelayedLoading="true" ... />

<script runat="server">
protected void Page_PreRender(object sender, EventArgs e)
{
queryrepeater.WhereCondition= "NodeAliasPath LIKE '"+(string)Eval("NodeAliasPath")+"'";
queryrepeater.ReloadData(true);
}
</script>

Note : queryrepeater dont have DelayedLoading properties, use DataBindByDefault="false" instead.



By
NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)
Read More...

Update Panel - Handle async partial-page state with client script

Leave a Comment
This is a sample script you can put at the master page. So that you dont need to have updatepanel progress every time you add the update panel in you aspx page.

Script 

<div id="pageUpdating"></div>

    <script type="text/javascript">
        Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
        function BeginRequestHandler(sender, args) {
            //page is begin request, you can put code to lock screen etc.  
            writePageLoading();

        }
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler)
        function endRequestHandler(sender, args) {
            //page load successfully , end request  
            RemoveLoading();
            if (args.get_error() != undefined && args.get_error().httpStatusCode == '500') {
                //if have error
                var errorMessage = args.get_error().message;
                alert(errorMessage + " . " + errorMessageAdditional);
            }
        }

        Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(pageLoadingHandler)
        function pageLoadingHandler(sender, args) {
            //page updating..
            writePageUpdating();
        }

        Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoadedHandler)
        function pageLoadedHandler(sender, args) {
            //page loaded
            RemoveLoading();
        }

        //method to write loading indicator
        function writePageLoading() {
            var divPageUpdating = document.getElementById('pageUpdating');
            divPageUpdating.innerHTML = "<div id=\"loading\" style=\"position: absolute; top: 46%; left: 40%; width: 200px; z-index: 100000;\" class=\"PopupBackground\"><center><br /> <img src=\"images/loading.gif\" alt=\"page is updating\" /><br /><br/>Please Wait While Processing Your Request...</center></div>";

        }

        //method to remove any updating / loading indicator
        function RemoveLoading() {
            var divPageUpdating = document.getElementById('pageUpdating');
            divPageUpdating.innerHTML = "";
        }

        //method to write updating indicator
        function writePageUpdating() {
            var divPageUpdating = document.getElementById('pageUpdating');
            divPageUpdating.innerHTML = "<div id=\"loading\" style=\"position: absolute; top: 46%; left: 40%; width: 200px; z-index: 100000;\" class=\"PopupBackground\"><center><br /> <img src=\"images/loading.gif\" alt=\"page is updating\" /><br /><br/>Please Wait While System Updating Your Page...</center></div>";
        }
    </script>


By
NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)
Read More...

Subscribe to our newsletter to get the latest updates to your inbox.

Your email address is safe with us!




Founder of developersnote.com, love programming and help others people. Work as Software Developer. Graduated from UiTM and continue study in Software Engineering at UTMSpace. Follow him on Twitter , or Facebook or .



Powered by Blogger.