Archive

Archive for October, 2010

Get details of item(component,schema etc…) through Buisness Connector in SDL Tridion

October 7, 2010 3 comments

This code helps us to retrieve all the details of a particular item.
I have used Business Connector to connect with sdl tridion.
This code is written in console application(c# .net)

public void Details()
{
      public StringBuilder stringbuilder = new StringBuilder();

      #region ..item details..
     
      string path;
      /*this is used to get template from external source,
      for which we have created a folder in our project named as temp
      in that we have a stringTemplate named as folder.st */
      path = Environment.CurrentDirectory + "\\temp";

      StringTemplateGroup grp = new StringTemplateGroup("myGroup", path);
      StringTemplate query = grp.GetInstanceOf("folder");

      /* this is to fetch details of the item for which id is specified */
      query.SetAttribute("itemuri", "tcm:88-11828");
            
      /* this connects to tridion */
      BusinessConnector service = new BusinessConnector();
      service.Credentials = new System.Net.NetworkCredential("administrator", "admin");

            
      string BC = service.execute("default", query.ToString(), null);
      Console.WriteLine(BC);

      /*stringbuilder is used to print out put on external file*/
      stringbuilder.AppendFormat(@"{0}",BC);
      stringbuilder.Append(Environment.NewLine);

      /*name of the file to which we have to store*/
      File.WriteAllText(@"c:\ShowComponentRaw.xml", stringbuilder.ToString());

            
      #endregion ..item details...
}

Here’s the template
/*save it as .st because its string template */
folder.st

<?xml version='1.0'?>
<tcmapi:Message xmlns:tcmapi="http://www.tridion.com/ContentManager/5.0/TCMAPI"
version="5.0" from="Nishant" failOnError="false">
<tcmapi:Request ID="Request1" preserve="false">
  <tcmapi:GetItem itemURI="$itemuri$" writeBinaryToDisk="true">
    <tcmapi:ItemFilter type="XMLReadAll"/>
  </tcmapi:GetItem>
</tcmapi:Request>
</tcmapi:Message>

Enjoy.. 😉 ..!!!

Advertisements
Categories: SDL Tridion Tags: , ,

Remove HTML tags using regular expressions

October 6, 2010 Leave a comment

Hi.

<\/?\w[^>]*>
      or
<(.|\n)*?>
      or
<[^>]+>
      or
<\\??.+?>
      or
<[^]+>

This will help u to remove all html tags.

Enjoy.. 😉 ..!!!

Categories: .NET, Regex Tags: ,

Extract content within tags : Regular Expression

October 6, 2010 Leave a comment

By this you can extract content which is in span tag or any tag

<span[^> ]*>(.*?)</span>

here you can use any tag like h1 or p etc…

Enjoy.. 😉 ..!!!

Categories: .NET, Regex Tags: ,

Change color of button on click :Android

October 5, 2010 7 comments

This is used to change color of button on pressed or focused
write this code in your drawable folder

login_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Button Focused-->
    <item   android:state_focused="true"
            android:state_pressed="false"
            android:drawable="@drawable/login_hover"
            />
<!-- Button Focused Pressed-->
    <item   android:state_focused="true"
            android:state_pressed="true"
            android:drawable="@drawable/login_hover"
            />
<!-- Button Pressed-->
    <item   android:state_focused="false"
            android:state_pressed="true"
            android:drawable="@drawable/login_hover"
            />
<!-- Button Default Image-->
    <item   android:drawable="@drawable/login_bg"/>

</selector>

login_hover.xml

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" shape="rectangle">
<!--this is to give gradient effect -->
<gradient   android:angle="270"
               android:startColor="#6b6b6b"
               android:endColor="#0e0e0e"
               />
<!-- this is make corners of button rounded -->
<corners    android:topLeftRadius="5dip"
               android:bottomRightRadius="5dip"
               android:topRightRadius="5dip"
               android:bottomLeftRadius="5dip"/>

</shape>

login_bg.xml

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" shape="rectangle">
<!--this is to give gradient effect -->
<gradient   android:angle="270"
            android:startColor="#e7ff47"
            android:endColor="#90a501"
            />
<!-- this is make corners of button rounded -->
<corners    android:topLeftRadius="5dip"
               android:bottomRightRadius="5dip"
               android:topRightRadius="5dip"
               android:bottomLeftRadius="5dip"/>

</shape>

and in your code in res/layout/login.xml
or in your button’s code
android:background=”@drawable/login_selector”

Enjoy.. 😉 ..!!!

Categories: Android Tags: ,

Fading color effect with TransitionDrawable :Android

October 5, 2010 3 comments
RelativeLayout layout = (RelativeLayout) findViewById(R.id.Layout);
layout.setBackgroundResource(R.drawable.translate);
TransitionDrawable transition = (TransitionDrawable) layout.getBackground();
transition.startTransition(5000);

This code gives you a fading effect like from yellow to white(original color).

translate.xml

<?xml version="1.0" encoding="UTF-8"?>
   <transition xmlns:android="http://schemas.android.com/apk/res/android">
          <!-- The drawables used here can be solid colors, gradients, shapes, images, etc. -->
          <item android:drawable="@drawable/new_state" />
          <item android:drawable="@drawable/original_state" />
   </transition>

new_state.xml

<?xml version="1.0" encoding="UTF-8"?>
<shape   xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle">
    <solid android:color="#FFFFA7"/>
</shape>

original_state.xml

<?xml version="1.0" encoding="UTF-8"?>
<shape   xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle">
    <solid android:color="#FFFFFF"/>
</shape>

Enjoy.. 😉 ..!!!

Categories: Android Tags: , ,

Rotation animation in android

October 5, 2010 4 comments

Using this code you can rotate an image

        RotateAnimation rAnim = new RotateAnimation(0.0f, 360.0f, Animation.RELATIVE_TO_SELF, 0.5f,Animation.RELATIVE_TO_SELF, 0.5f);
        rAnim.setRepeatCount(Animation.INFINITE);
        rAnim.setInterpolator(new LinearInterpolator());
        rAnim.setDuration(700);
        /* refreshIcon is object of an imageView */
        refreshIcon.startAnimation(rAnim);

Enjoy.. 😉 ..!!!

Categories: Android Tags: ,
%d bloggers like this: