Пример #1
0
		public static string Create()
		{
			while (true)
			{
				string key = Util.RandomAlphaNumericString(8);

				if (dict.TryAdd(key, DateTime.Now))
					return key;
			}
		}
Пример #2
0
        public static string Save(HttpFileCollection files)
        {
            string folder_name = Util.DateTimeToString(DateTime.Now, 4);
            string file_name   = Util.RandomAlphaNumericString(4);

            HttpPostedFile file = files["picture"];
            string         uri  = uploadFile(file, folder_name, file_name);

            return(uri);
        }
Пример #3
0
        public static string CreatePaper(string user_name)
        {
            for (; ;)
            {
                string vote_id = Util.RandomAlphaNumericString(8);

                if (NextIdStore.CreateIfNotExists(Warehouse.PapersTable, vote_id, 0))
                {
                    createAction(vote_id, user_name, new ActionData()
                    {
                        mat = "infos-create"
                    });

                    return(vote_id);
                }
            }
        }
Пример #4
0
        public static string ProcessUploadFiles(HttpFileCollection files)
        {
            foreach (string key in files.AllKeys)
            {
                string prefix           = key.Substring(0, 3 /*length of "n1/"*/);
                string prefix_thumbnail = null;
                string key_body         = key.Substring(3 /*length of "n1/"*/);

                if (prefix == "n3/")
                {
                    prefix_thumbnail = "n2/";
                }
                else if (prefix == "n5/")
                {
                    prefix_thumbnail = "n4/";
                }
                else if (prefix != "n1/" && prefix != "n6/")
                {
                    continue;
                }

                string folder_name   = Util.DateTimeToString(DateTime.Now, 4);
                string file_name     = Util.RandomAlphaNumericString(6);
                string thumbnail_uri = null;

                if (prefix_thumbnail != null)
                {
                    HttpPostedFile thumbnail_file = files[prefix_thumbnail + key_body];
                    thumbnail_uri = uploadFile(thumbnail_file, folder_name, prefix_thumbnail + file_name);
                }
                HttpPostedFile file = files[prefix + key_body];
                string         uri  = uploadFile(file, folder_name, prefix + file_name);

                return(uri);
            }
            return(null);
        }
Пример #5
0
		public UserSession(string user_name)
		{
			this.UserName = user_name;
			this.SessionKey = Util.RandomAlphaNumericString(6);
			this.LastActiveTime = DateTime.Now;
		}