Inheritance: INotifyPropertyChanging, INotifyPropertyChanged
 public static void InsertUser(User u)
 {
     naturenet_dataclassDataContext db = new naturenet_dataclassDataContext();
     db.Users.InsertOnSubmit(u);
     Action a = new Action();
     a.date = DateTime.Now; a.type_id = 1; a.object_type = u.GetType().ToString();
     try { db.SubmitChanges(); a.user_id = 0; a.object_id = u.id;
     db.Actions.InsertOnSubmit(a); db.SubmitChanges(); }
     catch (Exception e) { log.WriteErrorLog(e); }
 }
        public static void retrieve_and_process_user_changes_from_googledrive()
        {
            var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description);
            provider.ClientIdentifier = configurations.googledrive_client_id;
            provider.ClientSecret = configurations.googledrive_client_secret;
            IAuthenticator authenticator = new OAuth2Authenticator<NativeApplicationClient>(provider, googledrive_getauthorization);
            DriveService gd_service = new DriveService(authenticator);

            FilesResource.ListRequest list_request = gd_service.Files.List();
            list_request.Q = "title = '" + configurations.googledrive_userfiletitle + "'";
            FileList file_list = list_request.Fetch();
            if (file_list.Items.Count == 0) return;
            Google.Apis.Drive.v2.Data.File users_list_file = file_list.Items[0];
            if (String.IsNullOrEmpty(users_list_file.DownloadUrl)) return;
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(users_list_file.DownloadUrl));
            authenticator.ApplyAuthenticationToRequest(request);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            if (response.StatusCode != HttpStatusCode.OK) return;
            System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream());
            string users_list = reader.ReadToEnd();
            reader.Close();
            List<string> usernames = configurations.GetUserNameList_GDText(users_list);
            List<string> avatars = configurations.GetAvatarList_GDText(users_list);

            naturenet_dataclassDataContext db = new naturenet_dataclassDataContext();
            var ru = from u in db.Users
                     where u.id > 0
                     select u.name;
            List<string> users = ru.ToList<string>();
            for (int counter = 0; counter < usernames.Count; counter++)
            {
                if (!users.Contains(usernames[counter]))
                {
                    User u3 = new User();
                    u3.name = usernames[counter]; u3.password = ""; u3.email = "";
                    try { u3.avatar = avatars[counter]; }
                    catch (Exception) { u3.avatar = ""; }
                    db.Users.InsertOnSubmit(u3);
                }
                else
                    users.Remove(usernames[counter]);
            }

            //var du = db.Users.Where(a => users.Contains(a.name));
            //if (du.Count() == 0) return;
            //string udel = "";
            //foreach (User u1 in du)
            //    udel = udel + ";" + u1.id + "," + u1.name + "," + u1.avatar + "," + u1.email + "," + u1.technical_info;
            //Action del = new Action();
            //del.date = DateTime.Now;
            //del.object_type = "nature_net.User";
            //del.user_id = 0;
            //del.type_id = 3;
            //del.technical_info = udel;
            //db.Actions.InsertOnSubmit(del);
            //db.Users.DeleteAllOnSubmit(du);
            db.SubmitChanges();
        }
 partial void DeleteUser(User instance);
 partial void UpdateUser(User instance);
 partial void InsertUser(User instance);