Here i share i have learned as a developer (in my 1.5 years of experience).
Planning
0) Before take project be sure that you are familiar and have complete understanding of the specified problematic domain
1) Never start single task or project with unclear basic requirements!
2) Make plan(time, resources...) and try to stick with it (even if you fail(yes you will) to stick with it, you will have a nice view of where are you at the moment and what you must change to proceed).
3) If there is a working solution - use it. Don't reinvent the wheel!
4) Choose precisely the technology/platform... that will be used.
5) If project is done from scratch - invest more time in architecturing!
6) Don't make compromises with ad hoc solutions at base stage of architecturing! Never!
7) Aim for a scalable model in order to confront upcoming changes/new requirements! (believe me, requirements are something extremely volatile)
8) Invest time in learning new practices that will be helpfull during development stage.
9) Listen to every single opinion in planning stage.
10) Document everything (from begining to the end)!
Developing
11) Create or use code notation and standarts
11) Define milestones and define set of functualities to be completed for each milestone
12) Delegate each task precisely - choose the right man for it.
13) Major tasks must be delegated to pair of programmers.
14) Give your team freedom for the realization of each task (ofcource in the constraints of already planned architecture)
15) Start testing as soon as the developing process has started. Test every chunk of code before it's ready to take place on the big "picture"
16) Synchronize team actions.
17) Completing single milestone, you must have a working part of the big picture.
18) Talk with the client and show them the progress of the project.
Will be happy to share your advices!
When trying to restore a database backup you my across the following error "Restore failed for Server '...\SQLEXPRESS'. (Microsoft.SqlServer.Express.Smo)". There are 4 ways of solving this problem. Check the one that is working for you.
1) Change the sql service to run as a local(not as a NetworkService). You can do that in services in the administrative tools.
2) Check the "Overwrite the existing database" in Option section.
3) Add new admin user with privileges to write in mssql folder.
4) If nothing solves the problem try selecting new paths for the generated mdf and ldf files of the restored DB.
1) Change the sql service to run as a local(not as a NetworkService). You can do that in services in the administrative tools.
2) Check the "Overwrite the existing database" in Option section.
3) Add new admin user with privileges to write in mssql folder.
4) If nothing solves the problem try selecting new paths for the generated mdf and ldf files of the restored DB.
All that you must do is to create an instance of CurrencyManager class. This class primary work is to manage list of binding objects. So to get the data under the selected row we must supply the DataSource and the DataMember of the DataGridView. DataMember represents the current list or the current table that are displayed. By supplying:
we create an instance of class CurrencyManager which derives from the abstract class BindingManagerBase.
By supplying
we get the current item in a object type. The only thing that we have to do is to cast this object to the appropriate type. In our case DataViewRow. So here is a method returning currently selected row in DataGridView.
// ...
BindingContext[dgvDataView.DataSource, dgvDataView.DataMember];
// and casting to CurrencyManager
// ...
we create an instance of class CurrencyManager which derives from the abstract class BindingManagerBase.
By supplying
//...
currManager.Current
//...
we get the current item in a object type. The only thing that we have to do is to cast this object to the appropriate type. In our case DataViewRow. So here is a method returning currently selected row in DataGridView.
public static DataRow GetCurrentRow(DataGridView dgvDataView)
{
CurrencyManager currManager =
(CurrencyManager)dgvDataView.BindingContext[dgvDataView.DataSource, dgvDataView.DataMember];
DataRowView drView = (DataRowView)currManager.Current;
return drView.Row;
}
Публикувано от
Dimityr
в
10:34
Етикети:
BindingManagerBase,
CurruncyManagaer,
DataGridView,
DataTable,
Row,
selected row
Yesterday i had to make a little app which functionality was to download file attachments. The idea was simple. Find new mails, search for specific files, download them, mark letters as read, reconnect after some period of time. With current possibilities of .net you have to write your own client, with your own MIME parser... Of course to reinvent the wheel it's not very smart. What I found as third party library was . Very nice library with many features. Library is not free. The unregistered version is fully functional but puts sometimes on random mails' subject "Please purchase the license". If you are developing a serious project whit this kind of functionality this library is for you.
(Insist to say that my opinion is based only on my user experience and it's not an add)
Some sample code from the web-site:
All you need is to reference Mail.dll.
Easy and nice, right? :)
(Insist to say that my opinion is based only on my user experience and it's not an add)
Some sample code from the web-site:
All you need is to reference Mail.dll.
using Lesnikowski.Client.IMAP;
using Lesnikowski.Mail;
using Lesnikowski.Mail.Headers;
using Lesnikowski.Mail.Headers.Constants;
using System;
class Program
{
static void Main(string[] args)
{
Imap imap = new Imap();
imap.Connect("mail.host.com");
imap.User = "lesnikowski";
imap.Password = "password";
imap.Login();
imap.SelectInbox();
Listuids = imap.SearchFlag(Flag.Unseen);
foreach (long uid in uids)
{
string eml = imap.GetMessageByUID(uid);
ISimpleMailMessage email = new SimpleMailMessageBuilder()
.CreateFromEml(eml);
Console.WriteLine(email.Subject);
Console.WriteLine(email.TextDataString);
}
imap.Close(true);
}
};
Easy and nice, right? :)
Today a friend of mine asked me how to sort a list collection of custom object. The answer is very simple. All you need to do is to implement IComparable interface and it's method CompareTo. Lets see a little code:
In our scenario we have a class that represents some doc. It has only 2 property members. We gonna use docID for sorting criteria ;).
The class has one method CompareTo (implemented from IComparable)
Here comes the whole class declaration:
Now if we have a unsorted collection of List
Calling
will sort our collection.
If you want some different business logic, or sorting on two fields and so on... you need to create your own Comparer by declaring class and implementing IComparer interface.
In our scenario we have a class that represents some doc. It has only 2 property members. We gonna use docID for sorting criteria ;).
public int docID { get; set; }
public string SomeImportantDocText { get; set; }
The class has one method CompareTo (implemented from IComparable)
public int CompareTo(object obj)
{
ImportantDoc imd = (ImportantDoc)obj;
return docID.CompareTo(imd.docID);
}
Here comes the whole class declaration:
public class ImportantDoc : IComparable
{
public int docID { get; set; }
public string SomeImportantDocText { get; set; }
public int CompareTo(object obj)
{
ImportantDoc imd = (ImportantDoc)obj;
return docID.CompareTo(imd.docID);
}
}
Now if we have a unsorted collection of List
Listdocs = new List ();
///adding some unsorted docs
Calling
docs.Sort()
will sort our collection.
If you want some different business logic, or sorting on two fields and so on... you need to create your own Comparer by declaring class and implementing IComparer interface.
Some days ago I had to validate a Cyrillic text using regex class. Of course there is no way to do it using “[а-зА-З]{3}” (for example) . Good thing is that .net supports Unicode in it’s regex engine.
Let’s try to match that string “абв” in Cyrillic. To be able to do that, we have to know the Unicode mapping for each letter in the validated string. For the current example Unicode mapping is:
а - 0430
б - 0431
в – 0432
To create a regex pattern for Unicode validation is required to add \u to the pattern. So to match “а” we need that pattern \u0430. To match the whole string the pattern will be (obviously) \u0430\u0431\u0432
Let see:
Output:
We did it :D
Of course using unicode in regex It’s not only limited to single characters. You can use ranges and so on…
Let’s try to match that string “абв” in Cyrillic. To be able to do that, we have to know the Unicode mapping for each letter in the validated string. For the current example Unicode mapping is:
а - 0430
б - 0431
в – 0432
To create a regex pattern for Unicode validation is required to add \u to the pattern. So to match “а” we need that pattern \u0430. To match the whole string the pattern will be (obviously) \u0430\u0431\u0432
Let see:
Match match = Regex.Match("абв", "\u0430\u0431\u0432");
if(match.Success)
{
Console.WriteLine("We did it :D");
}
Output:
We did it :D
Of course using unicode in regex It’s not only limited to single characters. You can use ranges and so on…
Абонамент за:
Публикации (Atom)