C# ASP.NET MVC 5

TODO task for learning ASP.NET MVC 5:

1. Consume ArcGIS REST API service in server side, i.e. generate token service for login

2. Customize login page and redirect, aka. routing issue

3. User registration module for application with SQL Express

4. Port ePlanner 2.0 to MVC and make it run

5. Write more using C#

Finish the book Professional ASP.NET MVC 5.

Articles

1. Make Yahoo! Web Service Rest API Call using C#

2. Using Secured Web Services and Tokens

[C#]
string url = tokenServiceUrl + "?request=getToken&username=
myuser&password=secret"; System.Net.WebRequest request = System.Net.WebRequest.Create(url);

string myToken, errorMsg;
try {
   System.Net.WebResponse response = request.GetResponse();
   System.IO.Stream responseStream = response.GetResponseStream();
   System.IO.StreamReader readStream = new System.IO.StreamReader(responseStream);

   myToken = readStream.ReadToEnd();
}
catch (WebException we) {
   if (we.Message.Contains("403")
      errorMsg = "Server returned forbidden (403) code."
}


3. How to Customize ASP.NET MVC Authentication

4.ASP.NET MVC Authentication – Customizing Authentication and Authorization The Right Way

5.Sesseion Hijacking

6. Read Web.config data
in Web.config add:

<appSettings>
<add key="customsetting1" value="Some text here"/>
</appSettings>

[C#]

			System.Configuration.Configuration rootWebConfig1 =
				System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(null);
			if (rootWebConfig1.AppSettings.Settings.Count > 0)
			{
				System.Configuration.KeyValueConfigurationElement customSetting = 
					rootWebConfig1.AppSettings.Settings["customsetting1"];
				if (customSetting != null)
					Console.WriteLine("customsetting1 application string = \"{0}\"", 
						customSetting.Value);
				else
					Console.WriteLine("No customsetting1 application string");
			}
Advertisements

Map Cluster Layer Heuristics Algorithm

I am implementing an Cluster Layer with heuristics algorithm  based on Google Maps JS API with reference to MarkerCluster.

It works like this:

1. Set a maximum zoom level Max

2. If map.getZoom() > Max, remove the cluster layer, and display the original point layer

3. If map.getZoom() <= Max, remove the original point layer

If init load on minimal zoom level, query all points out, and store on client side, later use this data to Filter cluster layer markers based on map.getBounds(), i.e. map extent

If map load on between minimal zoom level and Max, query data based on map.getBounds()

4. Filter function

a. get xmin, ymin, xmax, ymax from the map bounds.

b. filter points within the map bounds to redraw Cluster Layer

Web Analytics Design

I know that Google Analytics and Piwik are great tools to perform web analytics, but either of them can meet my requirements fully.

My web app is live in the company intranet only, and no IP is allowed to expose to the internet. Hence, Google Analytics is out of choice. Piwik can work partially for my scenario, however open source technology is not supported by company directors, and some critical requirements can not be fulfilled by Piwik.

I am going to construct my own module to achieve this web analytics goal.

Management View Requirements:

  1. Users per day
  2. Which departments users from
  3. Average durations for users
  4. Most popular modules
  5. Which resource is most used
  6. Which tool is most used
  7. Search keywords

Development View Requirements:

  1. Most failed functional calls
  2. Most popular new requirements from users (A survey form)

Guidelines:

Once user logged in, run a tracking function to store all required data, update data on user actions.

Avoid frequently query to database, store the number of functional calls in web app data, then send data to backend after user refresh page or logout.

Size of the collected data must be limited in size, and once reaching the limit, send to backend and then reset the data.

Internal functions need to be per-determined in keywords in order to reduce the size of collected data, and analysis purpose.

Simple Git Commands

1. configure up git account
$ git config –global user.name “John Doe”
$ git config –global user.email johndoe@example.com

2. add a remote git
$ git remote add [local_git_name] [remote_git_url]

3. fetch the remote repository
$ git fetch [remote_git_name]

step 2, 3 can be done use clone
$ git clone [remote_git_url] [local_git_name]

4. create a branch named newfeature to work on
$ git branch newfeature
$ git checkout newfeature

or $ git checkout -b newfeature

5. add  all changes
$ git add -A

6. commit changes
$ git commit -m ‘comments’

7. change to master and update master
$ git checkout master
$ git pull

8. merge newfeature with master
$ git merge newfeature

9. push to origin
$ git push origin master

10. resolve conflicts
$ git diff

11. change remote git uri
$ git remote set-url [new_uri]

12. create a new git repository
$ git init

13. add a remote git
$ git remote add [remote_uri]

14. check all remote in repository
$ git remote -v

15. see git logs
$ git log

16. want undo commits
$ git checkout [commit-log-hash-num] .   (this . is necessary for all trees commit)

17. rollback to a point
$ git reset –hard [commit-log-hash-num]
$ git push -f [origin] [branch]

Reference : http://git-scm.com/docs

Salary Negotiation Method

Whenever going to an interview, keep a minimum salary in mind as well as consider all possible combinations of the salary package.

According to a recent study in the Journal of Organizational Behaviour, failing to negotiate on an initial job offer could mean missing out on over $600,000 in salary during a typical career.

If you are lucky to have many interviews in parallel, ask the recruiters about their maximum possible salary, and then decide to go or not unless you are attracted by the company itself.

Remember that the purpose of a job interview or performance review is to sell yourself. If you don’t believe you’re worth the price you’re asking, your employer won’t believe it either.

Focus on the value you bring to the company, not what comparable salaries are. When asking for a raise or making a move to another job, note your accomplishments, and attach time and money to them. For instance, you might point out that you automated your employer’s TPS Reports, saving 40 work hours a month (or $500 a day). Create a written list of talking points and use this to make your case for a higher salary. Hand the page to the interviewer so that she has the info in front of he/she.

If you’re just starting out—you’re a recent university graduate or moving to a new career—you might not have hard numbers to prove your worth. In that case, pitch your enthusiasm and work ethic. At the very least, ask for about ten percent more than what you’re offered.

Let’s look at a specific salary negotiation method.

The Noel Smith-Wenkle Salary Negotiation Method

The first rule of Smith-Wenkle’s method is to never tell the employer how much you’ll take. Let the company name the first number.

In practice, the Smith-Wenkle Method involves four steps:

  1. If the company asks for a number on the application, leave it blank.
  2. When the company verbally asks how much you’ll take, you say, “I’m much more interested in doing [type of work] here at [name of company] than I am in the size of the initial offer.” Smith-Wenkle says this will suffice about 40% of the time.
  3. If the company asks a second time, your answer is: “I will consider any reasonable offer.” This is a polite stalling tactic, and Smith-Wenkle says this will work another 30% of the time.
  4. About 30% of the time, you’ll reach this final step. Again, your response is a polite refusal to answer the question: “You’re in a much better position to know how much I’m worth to you than I am.” This is your final answer, no matter how many times the company tries to get you to go first.

Again, the purpose of this method is to get the company to be the first side to name a number. Once the company makes an offer, there are two options. If the offer is above your minimum, take the job. If it’s below your minimum, tell them it’s too low—but do not say by how much.

Salary Negotiation Tips

  1. Be brave. The biggest mistake you can make is to not negotiate at all. The courage to negotiate is especially important for women—men are four to eight times more likely to negotiate salary. Most companies are willing to negotiate salary, but most employees never give it a go.
  2. Be prepared.Research a fair salary. Figure out how much you want—but ask for a bit more to leave room for compromise. Practice negotiating your salary. Sit down with someone you trust and role-play the experience. Record yourself so that you can find your flaws. The more you practice, the more you’ll feel comfortable during the actual interview.
  3. Be silent.During salary negotiations, it’s often best to let the other side do the talking. When you receive an offer – no matter what it is – follow the offer with “the flinch”, a long period of silence. InYou Can Negotiate Anything, Herb Cohen writes,” Oddly enough, silence, which is probably easier to carry out, can be just as effective as tears, anger, and aggression.” Silence is golden.
  4. Be persistent.In many cases, the employer will reject your first request for a higher offer. Don’t let this deter you. Push back gently, justifying your proposed salary. Explain how the company will benefit from the investment.
  5. Be patient. The deeper you get in the process, the more committed the company is to hiring you. Do not mention your current income or your salary expectation—not even on the job application. If you do, you provide an anchor for the negotiation, and that can only hurt you. Wait for the employer to make the first mention of money.
  6. Be flexible.If the company won’t budge on salary, negotiate other compensation. Ask for things like an extra week of vacation, a private office, or a flexible schedule. Other possible perks include transit passes, educational reimbursement, better health insurance, performance bonuses.