September 2010 - Posts

OAuth

It's nice to see that more and more , either social network site and other famous site Implement OAuth.

OAuth is an open source and Way of handling the loggin and that way we can loggged in and even use the Previllege that user already give to our application.

The way it works is request for token ,after that request for access and all is different between this site and that site. after it's being approved the site will call back to our Page/Handler.

Twitter will allowed you to enter with no expired token , you can have the acces forever as long as user not clicking the Deny

LinkedIn in other hand, will give you expired time, linked in has the logout Url to call but it's buggy.

Facebook Implement it with Expired, after success Facebook will write Cookie with pattern: fb_[applicationID]

Share this post: | | | |
Posted by cipto with 1 comment(s)
Filed under:

Sencha Touch

First of all. Senhca touch is actually Ext JS, we have to know how it works.

you can have a Root as Panel or tabPanel , and than add what ever you want like,ex: combination of Carousel and TabBar .

we can add it on Items:[component1,component2,....]

Card type is like a display Type, which you can navigate ,and switch between.

what about if i want to have the content coming from ajax call to a json handler and after finish Add the items to Tab Bar?

I do it using the Store. store is something that will hold your values/Cache it on client side.

navigation object is my tabpanel.

here is the code:

onReady: function() {

  Ext.regModel('PageResult', {
                fields: [
            {
                name: 'PageContent',
                type: 'string'
}]
            });

var store = new Ext.data.Store({
                    model: 'PageResult',
                    proxy: {
                        type: 'ajax',
                        url: '../service/MobileHandler.ashx',
                        reader: {
                            type: 'json',
                            root: 'PageResult'
                        },
                        extraParams:
                        {
                            page: 'about'
                        }
                    },
                    listeners: {
                        single: true,
                        datachanged: function() {
                            Ext.getBody().unmask();
                            var items = [];

                            store.each(function(rec) {
                               // debugger;
                                items.push({
                                    html: rec.get('PageContent'),
                                    title: 'About',
                                    id: 'AboutButton',
                                    iconCls: 'info',
                                    cls: 'card card1'
                                });
                            });
                    
                            navigation.add(items[0]);
                            navigation.doLayout();
                        }
                    }
                });


                store.read();
 }

Share this post: | | | |
Posted by cipto with no comments
Filed under:

Between EF, LinqToSql, and telerik OpenAccess ORM

I've got a scenario for Winform and would like to have this Offline Tracking Changes like dataset.but i don't quite like using dataset so i am looking for other alternative.

I wanna incorporate the BindingSource and the ORM. with linq to sql it's Very tedious and not possible, try using attach and other stuff it will throw you that it's not coming from same Data Context.

Again i try the NHibernate, Oh My God ain't it tedious just to make it run :)

I personally don't know what EF on vs2008 does for. I've try it and even the designer is buggy, and it is so hard to use the mapping etc. after reading a couple articles it's being enhanced as version 3 or something but it is on vs2010, and i even read the one on 2008 is like a prototype? not ready for production?

than i found out this telerik openAccess ,full orm . support model to db or DB to model, offline tracking changes, incorporate linq to it's context.

It's quite easy to use,

    private MyDbContext dbContext = new MyDbContext ();
    private BindingSource dataSource = new BindingSource();

    MyGrid.DataSource = dataSource;


How about if you want to load the relationship object?

for example you have Product (1:many ProductPrice), Unit (1:many ProductPrice) and ProductPrice .

you want the Product Price to load the Product object and Order Related , since this telerik openAccess is on lazy load meaning, it doesn't load the relationship until you told him so.

just use the FetchStrategy

 FetchStrategy fecthStrategy = new FetchStrategy();
            //Load product Has Satuan with Satuan and Produk
            //With this the Track Changes work, but when adding new object ,have to add manualy as usual
            fecthStrategy.LoadWith<Produkhassatuan>(c => c.Satuan);
            fecthStrategy.LoadWith<Produkhassatuan>(c => c.Produk);

 When you query your ProductPrice you have the Unit and Product Object related Filled in.

you just have to handle the BindingSource on AddNew event, to initiate your class and handle the Save Clicked :

like

dataSource.EndEdit();

dbContext.SaveChanges();

Less Code , Less Pain
Share this post: | | | |
Posted by cipto with no comments
Filed under:

Indonesian Language Localization Telerik Winform GridView

Here is the Class 

public class MyIndonesianLocalizationProvider : RadGridLocalizationProvider
    {
        public override string GetLocalizedString(string id)
        {
            switch (id)
            {
                case RadGridStringId.FilterFunctionBetween: return "Di Antara";
                case RadGridStringId.FilterFunctionContains: return "Berisi";
                case RadGridStringId.FilterFunctionDoesNotContain: return "Tdk Berisi";
                case RadGridStringId.FilterFunctionEndsWith: return "Berakhir Dengan";
                case RadGridStringId.FilterFunctionEqualTo: return "Sama dengan";
                case RadGridStringId.FilterFunctionGreaterThan: return "Lebih Besar Dari";
                case RadGridStringId.FilterFunctionGreaterThanOrEqualTo: return "Lbh Besar Sama Dengan";
                case RadGridStringId.FilterFunctionIsEmpty: return "Kosong";
                case RadGridStringId.FilterFunctionIsNull: return "Null";
                case RadGridStringId.FilterFunctionLessThan: return "Kurang Dari";
                case RadGridStringId.FilterFunctionLessThanOrEqualTo: return "Krg Dari Sama Dengan";
                case RadGridStringId.FilterFunctionNoFilter: return "Tidak ada Filter";
                case RadGridStringId.FilterFunctionNotBetween: return "Tidak Di antara";
                case RadGridStringId.FilterFunctionNotEqualTo: return "Tidak Sama Dengan";
                case RadGridStringId.FilterFunctionNotIsEmpty: return "Tidak Kosong";
                case RadGridStringId.FilterFunctionNotIsNull: return "Tidak Null";
                case RadGridStringId.FilterFunctionStartsWith: return "Berawal Dengan";
                case RadGridStringId.FilterFunctionCustom: return "Custom";
                case RadGridStringId.CustomFilterMenuItem: return "Custom Filter Menu Item";
                case RadGridStringId.CustomFilterDialogCaption: return "Custom Filter Dialog";
                case RadGridStringId.CustomFilterDialogLabel: return "Custom Text:";
                case RadGridStringId.CustomFilterDialogRbAnd: return "Dan";
                case RadGridStringId.CustomFilterDialogRbOr: return "Atau";
                case RadGridStringId.CustomFilterDialogBtnOk: return "OK";
                case RadGridStringId.CustomFilterDialogBtnCancel: return "Batal";
                case RadGridStringId.DeleteRowMenuItem: return "Hapus Baris Item";
                case RadGridStringId.SortAscendingMenuItem: return "Urutkan Dari terkecil";
                case RadGridStringId.SortDescendingMenuItem: return "Urutkan Dari terbesar";
                case RadGridStringId.ClearSortingMenuItem: return "Bersihkan Urutan";
                case RadGridStringId.ConditionalFormattingMenuItem: return "Conditional Formatting";
                case RadGridStringId.GroupByThisColumnMenuItem: return "Grup Berdasarkan Kolom ini";
                case RadGridStringId.UngroupThisColumn: return "Batalkan Grup Berdasarkan Kolom ini";
                case RadGridStringId.ColumnChooserMenuItem: return "Pilih Kolom Utk Dibuang";
                case RadGridStringId.HideMenuItem: return "Sembunyikan";
                case RadGridStringId.UnpinMenuItem: return "Unpin";
                case RadGridStringId.PinMenuItem: return "Pin";
                case RadGridStringId.PinAtLeftMenuItem: return "Pin ke kiri";
                case RadGridStringId.PinAtRightMenuItem: return "Pin ke kanan";
                case RadGridStringId.BestFitMenuItem: return "Lebarkan Sampai Muat";
                case RadGridStringId.PasteMenuItem: return "Paste";
                case RadGridStringId.EditMenuItem: return "Edit";
                case RadGridStringId.CopyMenuItem: return "Copy";
                case RadGridStringId.AddNewRowString: return "Tambah Baris Baru";
                case RadGridStringId.ConditionalFormattingCaption: return "Conditional Formating Editor";
                case RadGridStringId.ConditionalFormattingLblColumn: return "Conditional Formatting:";
                case RadGridStringId.ConditionalFormattingLblName: return "Nama:";
                case RadGridStringId.ConditionalFormattingLblType: return "Tipe:";
                case RadGridStringId.ConditionalFormattingRuleAppliesOn: return "Regex Rule";
                case RadGridStringId.ConditionalFormattingLblValue1: return "Conditional 1:";
                case RadGridStringId.ConditionalFormattingLblValue2: return "Conditional 2:";
                case RadGridStringId.ConditionalFormattingGrpConditions: return "Conditional Group Condition";
                case RadGridStringId.ConditionalFormattingGrpProperties: return "Conditional Formating";
                case RadGridStringId.ConditionalFormattingChkApplyToRow: return "Apply to row";
                case RadGridStringId.ConditionalFormattingBtnAdd: return "Tambah";
                case RadGridStringId.ConditionalFormattingBtnRemove: return "Hapus";
                case RadGridStringId.ConditionalFormattingBtnOK: return "OK";
                case RadGridStringId.ConditionalFormattingBtnCancel: return "Batal";
                case RadGridStringId.ConditionalFormattingBtnApply: return "Pakaikan";
                case RadGridStringId.ColumnChooserFormCaption: return "Pilih Kolumn untuk di buang";
                case RadGridStringId.ColumnChooserFormMessage: return "Pilih Kolumn untuk di buang dari Grid ini";
                default:
                    return base.GetLocalizedString(id);
            }
        }
    }

 

On your Behind code File winform:

  RadGridLocalizationProvider.CurrentProvider = new MyIndonesianLocalizationProvider();   

There you have it . a grid with all filtering and other stuff in Indonesian

Share this post: | | | |
Posted by cipto with no comments
Filed under:

How to save Value in Session StateServer mode

I've just spotted this problem from dotnetindonesia mailing list.

It's so long i haven't write a blog..

I've been through this last year, on Session StateServer and load balancing Servers.

actually load balancing can be achived from Hardware it's just another part and has nothing to do with this session State

in order so the loadbalancing can run there are lot's of configuration on the IIS, to macth the Machine key, the Division of Folder structure etc.

 

Session State Server will automatically serialize each time on each request with out we told him  to do so.

to save the value is to be able to serialize or deserialize the object that we passed in to the session.

what i found and work is to serialize to Memory Stream and Deserialize back as that object

 this is from somebody's code:

public static class WebFarmSerializer
{
    public static MemoryStream Serialize<T>(T obj)
  {
        try
        {
            DataContractSerializer s = new DataContractSerializer(typeof(T));
            MemoryStream ms = new MemoryStream();
            s.WriteObject(ms, obj);
            ms.Position = 0;
            return ms;
   
        }
        catch (Exception)
        {
           
        }
        return null;
    }


    public static T Deserialize<T>(MemoryStream ms)
    {
        try
        {
            Stream stream = (Stream)ms;
            stream.Position = 0;
            XmlDictionaryReader reader =
                XmlDictionaryReader.CreateTextReader(ms.ToArray(), new XmlDictionaryReaderQuotas());
            DataContractSerializer s = new DataContractSerializer(typeof(T));
            T retObject = (T)s.ReadObject(reader,true);
            reader.Close();
            return retObject;

        }
        catch (Exception exception)
        {
          
        }
        return default(T);
    }
}

 

.Net already have the DataContractSerializer which is very powerfull can even serialize object to JSON, I've used it before

Hope this help you out

Share this post: | | | |
Posted by cipto with 1 comment(s)
Filed under: