Friday, June 14, 2013

Kendo datasource

   1: <div id="form-container">
   2:  
   3:     <div class="form" >
   4:                    <select data-role="dropdownlist" data-value-field="ProductID" data-text-field="ProductName" data-bind="source: productsSource, value: selectedProduct"></select>
   5:         <ul>
   6:             <li>
   7:                 <label>ID</label>
   8:                 <span data-bind=  "source: productsSource, events: { change: change }"></span></li>
   9: @*            <li>
  10:                 <label>Name</label>
  11:                 <input type="text" class="k-textbox" id="products" data-bind="value: selectedProduct.ProductName, events: { change: change }" /></li>
  12:             <li>
  13:                 <label>UnitPrice</label>
  14:                 <input type="text" data-role="numerictextbox" data-bind="value: selectedProduct.UnitPrice, events: { change: change }" /></li>*@
  15:         </ul>
  16:  
  17:         <button data-bind="click: remove">Delete Product</button>
  18:  
  19:     </div>
  20: </div>
  21: <script>
  22:     var crudServiceBaseUrl = "@Url.Action("Index", "Duyuru", new { area = "Ayarlar" })";
  23:  
  24:     $(document).ready(function () {
  25:         //setTimeout(function () {
  26:             alert("hi");
  27:         var uniqId = '@(ViewBag.UniqEkId)'
  28:         var messageId = '@(ViewBag.Id)'
  29:         alert(crudServiceBaseUrl);
  30:         var viewModel = kendo.observable({
  31:             productsSource: new kendo.data.DataSource({
  32:  
  33:                 transport: { 
  34:                     read: {
  35:                         contentType: "application/json; charset=utf-8",
  36:                         type: "POST",
  37:                         url: crudServiceBaseUrl + "/Read",
  38:                         dataType: "json",
  39:                         data: { id: messageId }
  40:                     },
  41:                     update: {
  42:                         contentType: "application/json; charset=utf-8",
  43:                         type: "POST",
  44:                         cache: false,
  45:                         url: crudServiceBaseUrl + "/Update",
  46:                         dataType: "json"
  47:                     },
  48:                     destroy: {
  49:                         contentType: "application/json; charset=utf-8",
  50:                         type: "POST",
  51:                         cache: false,
  52:                         url: crudServiceBaseUrl + "/Delete",
  53:                         dataType: "json"
  54:                     },
  55:                     parameterMap: function (options, operation) {
  56:                         if (operation !== "read" && options.models) {
  57:                             var x = " { models :" + JSON.stringify(options.models) + "}";
  58:                             console.log(x);
  59:                             return x;
  60:                         }
  61:                         return options;
  62:                     }
  63:                 },
  64:                 autoSync:true,
  65:                 batch: true,
  66:                 schema: {
  67:                     model: { id: "KayitNo" },
  68:                     data: function (result) {
  69:                         if ($.isArray(result)) {
  70:                             return result;
  71:                         }
  72:                         else {
  73:                             return [result];
  74:                         }
  75:                     }
  76:                 }
  77:             }),
  78:             selectedProduct: null,
  79:             hasChanges: false,
  80:             save: function () {
  81:                 this.productsSource.sync();
  82:                 this.set("hasChanges", false);
  83:             },
  84:             remove: function () {
  85:                 if (confirm("Silmek istediğinize emin misiniz?")) {
  86:                     this.productsSource.remove(this.selectedProduct);
  87:                     this.save();
  88:                 }
  89:             },
  90:          
  91:             change: function () {
  92:                 this.set("hasChanges", true);
  93:             }
  94:         });
  95:         console.log(viewModel);
  96:         kendo.bind($("#form-container"), viewModel);
  97:         });
  98:  
  99:  
 100:     //}, 1);
 101: </script>

Thursday, January 5, 2012

WPF

Rendering Tier 0 directx 7 aşağısı

Rendering Tier 1 Directx 7-9

Rendering Tier 2 Direct x 9+

 

int renderingTier = (RenderCapability.Tier >> 16);
 
if (renderingTier == 0)
{ ... }
else if (renderingTier == 1)
{ ... }

 

milcore.dll media integration layer MIL

DWM Desktop Wİndow Manager

wpf ile herşey 3d render edilir 2 boyutlu şeyler bile üçgenlere çevrilip 3d pipeline dan geçer

The client profile is the subset of the .NET Framework that’s required for rich client applications 
like WPF. It doesn’t include server-side features such as ASP.NET, debuggers, developer tools, code compilers.

Concurrent Bag

[Serializable] public class ConcurrentList<T> : ConcurrentBag<T> //where T : ICloneable { private object lockObject = new object(); public ConcurrentList<T> CloneOnlyList() { lock (lockObject) { ConcurrentList<T> clone = new ConcurrentList<T>(); foreach (T t in this) { clone.Add(t); } return clone; } } public T this[int i] { get { return this.ElementAt(i); } } public void Clear() { T someItem; lock (lockObject) { while (!this.IsEmpty) { this.TryTake(out someItem); } } } }

lock static objects

// C#
lock(typeof(Foo)) { // BAD CODE! NO! NO! NO!
// statements;
}
' VB .NET
SyncLock GetType(MyClass) ' BAD CODE! NO! NO! NO!
' statements
End SyncLock
…into the following good code:
// C#
lock(somePrivateStaticObject) { // Good code!
// statements;
}
' VB .NET
SyncLock GetType(somePrivateStaticObject) ' Good code!
' statements
End SyncLock

Tuesday, December 27, 2011

Cathing exceptions in pararlel for

private static void ProcessDataInParallel(byte[] data) { // Use ConcurrentQueue to enable safe enqueueing from multiple threads. var exceptions = new ConcurrentQueue<Exception>(); // Execute the complete loop and capture all exceptions. Parallel.ForEach(data, d => { try { // Cause a few exceptions, but not too many. if (d < 0x3) throw new ArgumentException(String.Format("value is {0:x}. Elements must be greater than 0x3.", d)); else Console.Write(d + " "); } // Store the exception and continue with the loop. catch (Exception e) { exceptions.Enqueue(e); } }); // Throw the exceptions here after the loop completes. if (exceptions.Count > 0) throw new AggregateException(exceptions); }

Parallel for

int[] nums = Enumerable.Range(0, 1000000).ToArray(); int[] results = new int[nums.Length]; Parallel.For(0, nums.Length, (i,loopsatate) => { if (i < 100) results[i] = 2 * nums[i]; else { loopsatate.Stop(); return; } } );

Struct larda aynı yere iki değişkenle bakmak

[StructLayout(LayoutKind.Explicit)] struct TestExplicit { [FieldOffset(0)] public long lg; [FieldOffset(0)] public int i1; [FieldOffset(4)] public int i2; } public static void Main(string[] args) { TestExplicit t = new TestExplicit(); t.lg = long.MaxValue; int a = t.i1; int b = t.i2; }

Thursday, February 17, 2011

Oracle Notes

DML data manipulation language

Client  -server uygulamalar direk client daki program database e erişir

Multitier application lar çok katmanlı yazılımlar presentation katmanı  application katmanı database katmanı birbirlerinden farklı

raid 0  stripping sadece performans

raid 1  mirroring sadece veri güvenliği

raid 1+0 stripping +mirroring performans + güvenlik

raid 5 stripping with parity  performans +güvenlik ama disk boyutunu ikiye katlamadan

Oracle Net protocol 1521 1526

MVC ile three tier application farkı mvc de her tier birbirine mesaj gönderir ama three tier da üst ile alt birbirini görmez

Oracle file extension

-Oracle ın disk block boyutları sisteminki ile aynı veya kolay bölünebilir olmalı asla sistem bloklarının boyutundan küçük olmamalı

-Oracle data dosyalarının uzantısı .dbf data base file

-Archive log files has extension .log .arc .arch

Oracle Buffer cache state

Free blocks

Pinned bloklar şu anda erişilen bloklar

Dirty bloklar değiştirilmiş olanlar

Dirty bloklar database kapatma komutu ile her 3 saniyede bir checkpoint oluşturulduğunda diske yazılır