Monthly Archives: July 2010

Bihać .NET User Grupa počela s radom


Već neko vrijeme postoji inicijativa za osnivanjem .NET user grupe u Bihaću. U razgovoru sa ljudima iz Microsoft BiH, kao i to da postoji kritični broj zainteresiranih za ovu grupu ušlo se u ovaj projekat. Tako je 29. maja. održan je inicijativni sastanak na kojem se podržala ova inicijativa . Nakon toga se i prišlo realizaciji.

Kao glavni sponzor osim Microsofta BiH, ponudila se firma LASER doo, koja nam je ustupila svu tehničku podšku u organizaciji budućih sastanaka UG. Sa svojim prostorom i opremom u stanju smo održavati bilo klasične sastanke bilo predavanja preko live meetinga i sl.

Prije nekoliko dana i službeno je prošla registracija Bihać .NET UG kod INETA asocijacije. Web prezentacija grupe kao i hosting iste, obezbjeđen je od firme Kentico i Apliedi. Domena grupe http://bihac.mscommunity.ba biće obezbjeđena uskoro, do tada stranica se može dobiti sa privremenom web adresom:
http://bihac.mscommunity.ba.mytempweb.com/default.aspx.

Do službenog početka oficijenih sastanaka koji se očekuju na jesen Septembar/Oktobar potrebno je još odraditi nekoliko formalnosti vezano za registrciju grupe na Microsoftovom service provideru za user grupe.

Ovom prilikom želim da obavijestim se zainteresirane za rad grupe a koji bi željeli biti dio ove zajednice da nam se pridruže. Mogu se registrovati direktno na stranicu ili me kontaktirati putem maila koji se nalazi na About stranici.

Na kraju bi se zahvalio svima na podršci i pomoći u realizaciji ovog projekta:

Ljudima iz INETA Europa:  Tomislav Bronzin Vice President Community Activities, Dobriša Adamec, Vice President Membership

Microsoft BiH: Dragan Panjkov Technology Specialist for Development Tools (DPE)

MSCommunity: Damir Dizdarević Country Leader for BiH

JasimuRadenku, Spasi vođama User grupa u BiH, te ostalim koji su posredno ili neposredno doprinjeli ili će doprinjeti realizaciji ovog projekta.

Ugodno programiranje i ljetni odmor.

Advertisements

Interview with famouswhy.com


Regarding my open source project ScreenPainter which I published on Code Project in 2004, several sites asked me if I could put my application on their site as a freeware software.

One of the site (famouswhy.com) send me request to make an interview with me, which you can see below or visit the link.

Silverlight 4 Business Application Part 1 of n


Logins, Users, Roles, Page Content

Currently I am trying to learn Silverlight Business Application development, and during this phase I will try to post some interesting tips and tricks on which I will encounter. I hope you will find some of a code usefull.

In this post I will show how to create starting silverlight business application skeleton, and how you can manipulate with users, roles and content within Silverlight application. As you already know, Silverlight BA uses ASP.NET database model in order to display or hide business data via RIA Services. So, if you want to develop SL application with several modules and each module can access different set of users, you need to handle with users and rolls similar as in ASP.NET application. In this post we will make demo with three pages. Each page will be opened with different users, and admin can open all pages. The screenshot below shows the SL application.

So lets start VS 2010, and choose File New Project, and in list choose Silverlight Business Application see picture below:

Name the new project SLBAPart1 and choose OK button. The VS designer will do a lot of works for us in order to generate starter business application. VS designer generated the two page, completed login and user registration logic as well as database and RIA services. We will add another page called Product, and implementi another link button in mainpage.xaml (see picture below).

  1. To create the new Product.xaml page, right click on Views folder, and choose Add new item
  2. In opened dialog choose Silverlight Page name it Product and click OK.
  3. Add xaml code as depicted on the picture above.

When you run the application you can see the application similar as the first picture shows, which you can access all three pages. There is also “login” link button wich you can login as well as register a new user for SL application.

To define user membership in SL application, select SLBAPart1.Web project  and choose menu ASP.NET Configuration from the Project menu of Visual Studio 2010. Internet Explorer page shows content similar like picture below. Choose Security link button, and click on Creates and Manages roles. Define four roles like picture shows below.

Click Back button and create four users with corresponding roles. The final result of user defining is shown on picture below.

Each user has its own corresponding roles. When you use the attached sample pasword for each user is defined similar as for the first user “$user1user1“. Password for admin user is “$adminadmin“.

After we defined roles and users it is time to define content for each page. Open Product.xaml page from Visual Vtudio project, define content like picture below.

We have to define Public.xaml page which can be accessed if we not logged in. Similar to previous page creation define Public.xaml page, and put some text in it.

Next step in implementation is  prevent user to see content if it is not authorized. To implement that, we need to expand ContentFrame_Navigated event of the mainpage.xaml.cs.

private void ContentFrame_Navigated(object sender, NavigationEventArgs e)
{
     //Check to see if user has right to navigate
     if (!UserCanNavigate(e))
       return;

     foreach (UIElement child in LinksStackPanel.Children)
     {
         HyperlinkButton hb = child as HyperlinkButton;
         if (hb != null && hb.NavigateUri != null)
          {
            if (hb.NavigateUri.ToString().Equals(e.Uri.ToString()))
             {
                VisualStateManager.GoToState(hb, "ActiveLink", true);
             }
           else
            {
               VisualStateManager.GoToState(hb, "InactiveLink", true);
            }
         }
     }
}

When the user click for content ContentFrame_Navigated event fires up. Then UserCanNavigate method gets call. The implementation of this method is the following:

private bool UserCanNavigate(NavigationEventArgs sender)
{
    //if user is not authenticated show public content
    if (!WebContext.Current.User.IsAuthenticated)
    {
        ContentFrame.Source = new System.Uri("/Public", UriKind.RelativeOrAbsolute);
        return false;
    } //If the user is loged show only content on which is authorizated
    else
    {
        //If user is admin alow everithing
        if(WebContext.Current.User.IsInRole("AdminRols"))
            return true;
        //if user is in rol1 open Home content
        if (WebContext.Current.User.IsInRole("Rol1"))
        {
            ContentFrame.Source = new System.Uri("/Home", UriKind.RelativeOrAbsolute);
            return false;
        }//Similar to previous
        if (WebContext.Current.User.IsInRole("Rol2"))
        {
            ContentFrame.Source = new System.Uri("/About", UriKind.RelativeOrAbsolute);
            return false;
        }
        else
        {
            ContentFrame.Source = new System.Uri("/Product", UriKind.RelativeOrAbsolute);
            return false;
        }

    }
}

Build application and run. The picture below shows our application. If we try to navigate to any content before we LogedIn we always get the same public content. Depending on user information when we logged in ,we get coresponding content.

Thats all for now. We learned how we can manipulate with content and different user roles. Source code for this demo can be downloaded from here.