Wednesday, June 1, 2011

Mistery

If controller has some property which returns some value from TempData - this metada data becomes unpersistent, i.e. doesn't store in session, or WTF?

protected int CurrentPage
{
get return (int)TempData["page"];
}

Tuesday, May 31, 2011

Cool Stuff

XML tree transformation extension for chrome

УРА Победа!!!

In order to use Data Service CTP 2 you should use IIS or IIS express server, no Cassini!

Details

YES and it works mather fucker!!!

---
http://www.odata.org/blog/2010/8/6/enhancing-odata-support-for-querying-derived-types---revisited

Examps:
http://localhost:56308/WcfDataService1.svc/Bases?$orderby=Owner/DataModel.Derived/Name%20desc


http://localhost:56308/WcfDataService1.svc/Bases/DataModel.Derived

Monday, May 30, 2011

odata блин

http://social.msdn.microsoft.com/Forums/en-US/dataservices/thread/255d9dc4-a083-4558-92bd-6aa96fed09d0

бляяяяяяя! кассини не надо использовать а надо настраивать IIS Express.

/////////////////////

http://blogs.msdn.com/b/astoriateam/archive/2011/03/09/announcing-wcf-data-services-march-2011-ctp2-for-net4-amp-sl4.aspx

Although proudly anonced - Properties on derived types, it still haven't been implemented thorougly, you cant orderby by such properties nor select their value by select.

я был не прав

http://localhost:53449/ITSServiceOData.svc/Subjects?oftype='Company'&orderby=Name

It is neccessary to use oftype, still can't find proper documentation on thios topic, only found this one http://www.odata.org/blog/2010/7/30/enhancing-odata-support-for-querying-derived-types, but looks like blue print

Thursday, May 26, 2011

ubuntu stuff

netstat -lntup

chmod o+wx file2

sudo vi config.xml

$ sudo ufw allow $port
---


https://help.ubuntu.com/community/FilePermissions
http://www.jonathanhui.com/fisheye-ubuntu
http://bitnami.org/faq/virtual_machines

Шаблон JQuery plugin

Thursday, May 19, 2011

ODATA Custom Exceptions

http://msdn.microsoft.com/en-us/library/ee391967.aspx#Y1700
   1:  public class AuthenticationInterceptor : RequestInterceptor
   2:  {
   3:      public AuthenticationInterceptor() : base(false) { }
   4:      public override void ProcessRequest(ref RequestContext requestContext)
   5:      {
   6:          if (!IsValidApiKey(requestContext))
   7:              GenerateErrorResponse(requestContext,
   8:                  HttpStatusCode.Unauthorized,
   9:                  "Missing or invalid user key (supply via the Authorization header)");
  10:      }
  11:      public bool IsValidUserKey(Message req, string key, string uri)
  12:      {
  13:          ... // ommitted for brevity
  14:      }
  15:      public void GenerateErrorResponse(RequestContext requestContext,
  16:          HttpStatusCode statusCode, string errorMessage)
  17:      {
  18:          // The error message is padded so that IE shows the response by default
  19:          string errorHtml =
  20:              "<html><HEAD><TITLE>Request Error</TITLE></HEAD><BODY>" +
  21:              "<H1>Error processing request</H1><P>{0}</P></BODY></html>";
  22:          XElement response = XElement.Load(new StringReader(
  23:              string.Format(errorHtml, errorMessage)));
  24:          Message reply = Message.CreateMessage(MessageVersion.None, null, response);
  25:          HttpResponseMessageProperty responseProp = new HttpResponseMessageProperty()
  26:          {
  27:              StatusCode = statusCode
  28:          };
  29:          responseProp.Headers[HttpResponseHeader.ContentType] = "text/html";
  30:          reply.Properties[HttpResponseMessageProperty.Name] = responseProp;
  31:          requestContext.Reply(reply);
  32:          // set the request context to null to terminate processing of this request
  33:          requestContext = null;
  34:      }
  35:  }

ODATA Custom Exceptions

 
http://msdn.microsoft.com/en-us/library/ee391967.aspx#Y1700

public class AuthenticationInterceptor : RequestInterceptor
{     public AuthenticationInterceptor() : base(false) { }     public override void ProcessRequest(ref RequestContext requestContext)     {         if (!IsValidApiKey(requestContext))             GenerateErrorResponse(requestContext,                 HttpStatusCode.Unauthorized,                 "Missing or invalid user key (supply via the Authorization header)");     }     public bool IsValidUserKey(Message req, string key, string uri)     {         ... // ommitted for brevity     }     public void GenerateErrorResponse(RequestContext requestContext,         HttpStatusCode statusCode, string errorMessage)     {         // The error message is padded so that IE shows the response by default         string errorHtml =             "<html><HEAD><TITLE>Request Error</TITLE></HEAD><BODY>" +             "<H1>Error processing request</H1><P>{0}</P></BODY></html>";         XElement response = XElement.Load(new StringReader(             string.Format(errorHtml, errorMessage)));         Message reply = Message.CreateMessage(MessageVersion.None, null, response);         HttpResponseMessageProperty responseProp = new HttpResponseMessageProperty()         {             StatusCode = statusCode         };         responseProp.Headers[HttpResponseHeader.ContentType] = "text/html";         reply.Properties[HttpResponseMessageProperty.Name] = responseProp;         requestContext.Reply(reply);         // set the request context to null to terminate processing of this request         requestContext = null;     }
}

Wednesday, May 18, 2011

КРИТИ[Ц|Н]ИЗМ

 

http://thisdeveloperslife.com/post/2-0-1-criticism

Ayende Rahien звезда, критик и девелопер NHIBERNATE, любит критиковать, говорит с чмошным французским акцентом (нот персонал инсалт бат, лет ми спик форм май харт, франзузский язык звучит чмошно а тем более его англицкий аналог), сказал важную вещь чуваки которые делают Light Switch лохи и лэйзи вот – дальше бла-бла-бла – дальше Хасельман – “зачто ты назвал мой подкаст о революции в еджипте крапом?” (это он уже какокумо то петру петровичу в твите) – петр петрович сказал что он ваще сам с балкан и знает что такое революции это когда главный меняется а система остается той же а делаьше дженерал дизапойтмент – бла-бла-бла – вис девлоперс лайв – кул стафф эктуали

Monday, May 16, 2011

mvc wish list

1. Support complex type models. Now MVC can't get access to the comtainers metadata properties, lot of problems.
2.why it is needded to validate in ModelValidator, values which don't passed in request parameteres.
3. ValidateMessageFor - Template as for types

Sunday, May 15, 2011

jquery autocomplete with hidden id

 

jquery autocomplete works fine till you just use it to select some sting value and pass it to a server. But what if you need to pass not string label of the selected value but related to it id?

It's hard to override this behaviour (at least was for me). First of all there is a lot of solutions in the web

Such as custom widgets:
http://code.google.com/p/jquery-autocomplete/source/checkout
http://flux88.com/2009/06/jquery-autocomplete-with-a-hidden-value/
Won't use because of poor documentation and support

Or simplistic solutions like this one:
http://www.petefreitag.com/item/756.cfm
Here all works fine but some underlying issues are neglected: when you typed some text and out of input control before request to the server complete the id value not changed.

After searching the web more meticulously found this usefull pages:

Old-version:
http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/

Migration guide:
http://www.learningjquery.com/2010/06/autocomplete-migration-guide
Release notes:
http://blog.jqueryui.com/2010/08/extensible-autocomplete/

Extension for current widget:
https://github.com/scottgonzalez/jquery-ui-extensions/blob/master/autocomplete/jquery.ui.autocomplete.selectFirst.js

Why old version mentioned? Because it has two very usefull methods which serve exactly for my purpose, unfortunately they are "depricated" in new version and at this point we have to use extension to help with.

Again the lack of this functionality in current version of jquery plugin is common, for examp:

Sebastian
July 31, 2010 at 4:39 pm
HI there, I have a question about the selectFirst option - you say it is gone with no need for replacement, but I disagree.

I have a strong case for an instance where I need to be able to input something - say the word 'Widget'. If present in the source list I have, 'Widget' contains all kind of other information such as ID's that I need to have access to when the user blurs out of the autocomplete.

However if I type out 'Widget' in the autocomplete and just tab out without selecting the matching item 'Widget' from the dropdown list, this item is never selected and I don't get that extra data. This is bad behavior, at least for my needs, and there's got to be a way to address this issue. Do you have any solutions or workarounds?



But even using extensions the solution is not out of box;
at first glance this fits -
https://github.com/scottgonzalez/jquery-ui-extensions/blob/master/autocomplete/jquery.ui.autocomplete.autoSelect.js
but actually it works only for static list, not for server queries.

This way I couldn’t find in the web implementation which suits to my purpose and here you could see custom implementation of my plugin.

Main feature of this extension is:

The value of hidden input  filed will be changed either user directly select item from the list or user typed it before list was actually filled with item from the server, if one of the values from the server corresponds to text in input control, the corresponded id value will be set to the hidden field, if typed value isn’t contained in the list the hidden value will be reset to null.

<input type=”text” id=”item_label” data-autocomplete-for=”item_id” data-autocomplete-srv = “…” data-autocomplete-respformat=”…”/>

<input type=”hidden” id=”item_id”/>

$(“#item_label”).autoComplete(srvBaseUrl);

Ini params:

srvBaseUrl – base url to the srevice which provides data for control

examp:

$(“#item_label”).autoComplete(“http://localhost:58486/SomeODataService.svc”);

Attributes:

1. data-autocomplete-srv – Request to the service

Examp:

data-autocomplete-srv="Persons?$select=Id,NickName&$filter=startswith(NickName, '{0}')"

2. data-autocomplete-respformat – Format of the JSON response from the srevice

Format is  “KeyValue, LabelValue, ListValue” where:

KeyValue – value which will be set as id value (value of hidden control)

LabelValue – value which will be shown as selected value for input control

ListValue – value which will be shown in selection list of input control

Examp:

data-autocomplete-respformat = "Id,NickName,NickName"

BUgs + 2

1. AllowHtml, yestuday it suddenly stop working (Dangerous conetent detected was thrown) and today after detaching project from SVN it starts warking again WTF!!!
2. MS Test project .vdi file doesn't referesh till project not unloadaed-loadede

Monday, April 11, 2011

Is the combination of ADO.NET Entity Framework and ASP.MVC wrong by any chance?

http://stackoverflow.com/questions/1501616/is-the-combination-of-ado-net-entity-framework-and-asp-mvc-wrong-by-any-chance

Tuesday, April 5, 2011

MVC metadata annotation

http://odetocode.com/blogs/scott/archive/2010/07/25/notes-on-templates-and-data-annotations-in-mvc-2.aspx

Thursday, March 31, 2011

FUck CreateQuery - create chould be save before CreateQuery

FUck create

http://social.msdn.microsoft.com/Forums/en/adodotnetdataservices/thread/c168d808-ac10-4a29-a04a-55421d86fed9

Monday, March 28, 2011

bry r bry byr get the json formated response from data service

http://stackoverflow.com/questions/1145588/cannot-properly-set-the-accept-http-header-with-jquery

Saturday, March 26, 2011

Many ways

There s many ways to define metadata for model in MVC
http://bradwilson.typepad.com/blog/2010/01/why-you-dont-need-modelmetadataattributes.html

OLD school attributes still the Best. I neebet

Wednesday, March 23, 2011

Can't undersand it

Re: The controller for path /favicon.ico does not implement IController
Apr 26, 2008 12:37 AM

The Routing system no longer special-cases the period character. Take a look at the Global.asax provided with the April codeplex templates:

1 routes.MapRoute(
2 "Default", // Route name
3 "{controller}/{action}/{id}", // URL with parameters
4 new { controller = "Home", action = "Index", id = "" }, // Parameter defaults
5 new { controller = @"[^\.]*" } // Parameter constraints
6 );

Note that on line (5) above, we're constraining the controller parameter such that periods are invalid characters, so the routing system won't bother looking for the favicon.ico controller.

Try adding a similar constraint to your registered routes. Hopefully this will solve your issue. :)


And issue appears on when:
AppControllerFactory{...
public override IController CreateController(RequestContext requestContext, string controllerName)
{

//object controller = _kernel.TryGet(controllerName.ToLowerInvariant());

return base.CreateController(requestContext, controllerName);
}

WTF!!!????

Monday, March 21, 2011

+1 bug

/Invoke service operations from client

. The operation could only be invoked
http://localhost:51685/serv.svc/Companies no parentesis on the end allowed!!!

ServiceClient - CreateQuery works only if operation has no parameters, i.e. it creates request without parentesis on the end, as far as you add some parameter, it add parentesis and server refuse to recognaise such request WTF

The only safe way to invoke operation through execute request

var courses = proxy.Execute<Course>(

new Uri(string.Format("{0}CoursesByCredits?credit={1}",
proxy.BaseUri, 3),

UriKind.RelativeOrAbsolute));


Saturday, March 19, 2011

Блядь нет слов, это всегда так с лицензией
все таки у микросовт иногда очень прямые руки

попал на следующую проблему чуствую ебли часа на 2 будет, удалите блять все программы из списка вручную