本文整理汇总了C#中Random.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Random.ToString方法的具体用法?C# Random.ToString怎么用?C# Random.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Random
的用法示例。
在下文中一共展示了Random.ToString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnCreate_ServerClick
protected void btnCreate_ServerClick(object sender, EventArgs e)
{
var dir = new DirectoryInfo(Server.MapPath("~/GroupIcon"));
var files = dir.GetFiles("*.png").Select(o => "~/GroupIcon/" + o.Name).OrderBy(o => o).ToList();
var g = new Group();
g.Icon = icons.SelectedItems.Count == 0 ? "~/Common/默认/群组.png" : files[icons.SelectedIndexes[0]];
g.Id = HomoryContext.Value.GetId();
g.Introduction = intro.Text;
g.Name = name.Text;
g.OpenType = OpenType.互联网;
g.Ordinal = 1;
g.State = State.启用;
g.Type = GroupType.教研团队;
int s = new Random().Next(10000000, 99999999);
string sx=s.ToString();
while(HomoryContext.Value.Group.Count(o=>o.Serial==sx)>0)
{
s = new Random().Next(10000000, 99999999);
sx = s.ToString();
}
if (publish_course.SelectedIndex > 0)
g.CourseId = Guid.Parse(publish_course.SelectedItem.Value);
if (publish_grade.SelectedIndex > 0)
g.GradeId = Guid.Parse(publish_grade.SelectedItem.Value);
g.Serial = sx;
var gu = new GroupUser();
gu.GroupId = g.Id;
gu.Ordinal = 0;
gu.State = State.启用;
gu.Time = DateTime.Now;
gu.Type = GroupUserType.创建者;
gu.UserId = CurrentUser.Id;
HomoryContext.Value.Group.Add(g);
HomoryContext.Value.GroupUser.Add(gu);
HomoryContext.Value.SaveChanges();
panel.ResponseScripts.Add("RadCloseRebind();");
}
示例2: LoginButton_Click
protected void LoginButton_Click(object sender, EventArgs e)
{
if (phonenumber.Text.Trim() != "")
{
int smsCode = 0;
CheckNumberResult res = CheckNumber(out smsCode);
if (res == CheckNumberResult.Known)
{
if (smsCode.ToString() == password.Text.Trim())
{
int passcode = new Random().Next(100000, 999999);
try
{
//необходимо создать пользователя и авторизовать его
BXUser user = new BXUser(); //BXUserManager.Create(phonenumber.Text.Trim(), "BXSqlMembershipProvider", out status);
user.IsApproved = true;
user.UserName = phonenumber.Text.Trim();
user.PasswordAnswer = "volotour";
user.Password = passcode.ToString();
user.ProviderName = "BXSqlMembershipProvider";
user.Email = phonenumber.Text.Trim() + "@volotour.ru";
user.Save();
Volotour.PersonalOffice.PersonalOfficeModule.sendsms("c79166104232", "ltkmaby123", phonenumber.Text, "Ваш пароль для volotour.ru " + passcode.ToString() + "\r\nРекомендуется сменить пароль!", true);
//Активируем профиль
CustomerProfilesCollection list = BXEntity<CustomerProfiles, CustomerProfilesCollection, CustomerProfiles.Scheme>.GetList(
new BXFilter(new IBXFilterItem[1]
{
(IBXFilterItem) new BXFilterItem(BXEntity<CustomerProfiles, CustomerProfilesCollection, CustomerProfiles.Scheme>.Fields.login, BXSqlFilterOperators.Equal, (object) phonenumber.Text.Trim())
}),
new BXOrderBy(new BXOrderByPair[1]
{
new BXOrderByPair(BXEntity<CustomerProfiles, CustomerProfilesCollection, CustomerProfiles.Scheme>.Fields.registration_date, BXOrderByDirection.Asc)
}));
if (list.Count() > 0)
{
CustomerProfiles cp = list[0];
cp.active = true;
cp.Save();
}
AuthUser(phonenumber.Text.Trim(), passcode.ToString());
}
catch (Exception ex)
{
hasErrors = true;
LastError = "У нас что то сломалось. Уже чиним. (" + ex.Message + ")";
}
}
else
{
WrongSmsCode = true;
hasErrors = true;
LastError = "Неверный код подтверждения!";
}
}
else
{
// Авторизовываем пользователя по логину - телефону
AuthUser(phonenumber.Text.Trim(), password.Text);
}
}
else
{
hasErrors = true;
LastError = "Не введен номер!";
}
ErrorForm.Visible = hasErrors;
ErrorMessage.Text = LastError;
//changeform(res);
}
示例3: RegisterProfile
protected void RegisterProfile()
{
if (phonenumber.Text.Trim() != "")
{
int smscode = new Random().Next(1000, 9999);
Volotour.PersonalOffice.PersonalOfficeModule.sendsms("c79166104232", "ltkmaby123", phonenumber.Text, "Ваш проверочный код: " + smscode.ToString(), true);
bool smssent = true;
if (smssent)
{
//Регистрируем новый профиль
try
{
Volotour.PersonalOffice.References.CustomerProfiles cpr = new Volotour.PersonalOffice.References.CustomerProfiles();
cpr.active = false;
cpr.activate_code = smscode.ToString();
cpr.gsmnumber = phonenumber.Text;
cpr.login = cpr.gsmnumber;
cpr.registration_date = DateTime.Now;
cpr.Save();
changeform(CheckNumberResult.Known);
}
catch (Exception ex)
{
hasErrors = true;
LastError = ex.Message;
}
}
}
else
{
hasErrors = true;
LastError = "Не введен номер!";
}
if (hasErrors)
{
ErrorMessage.Text = LastError;
ErrorMessage.Visible = true;
}
}
示例4: BindData
private void BindData()
{
int max = new Random().Next(15, 30);
int maxb = new Random().Next(10, 20);
string sql = "select top 10 [_id],[user_name],[title],[filepath] from [blog] order by [_id] desc;";
sql += "select top 10 * from (select top " + maxb.ToString() + " [_id],[user_name],[title],[filepath] from [blog] order by [read_cnt] desc) b2 order by [_id];";
sql += "exec [dbo].[getHotGroup] 12," + max.ToString() + ",0;";
sql += "select top 15 [t_id],[t_title] from [topic] order by [t_reply_cnt] desc;";
sql += "exec [dbo].[getDefaultPageBlog];";
DataSet ds = DB.GetDataSet(sql);
DataTable dt_new = ds.Tables[0];
DataTable dt_hot = ds.Tables[1];
DataTable dt_group = ds.Tables[2];
DataTable dt_topic = ds.Tables[3];
DataTable dt_1 = ds.Tables[4];
DataTable dt_2 = ds.Tables[5];
DataTable dt_3 = ds.Tables[6];
DataTable dt_4 = ds.Tables[7];
StringBuilder sb = new StringBuilder();
foreach (DataRow row in dt_new.Rows)
{
sb.AppendFormat("<p class='nitem'><a href='{0}'>{1}</a>", row["filepath"], Tools.HtmlEncode(row["title"].ToString()));
sb.AppendFormat(" - <a class='hui' href='{0}{1}'>{0}</a></p>", row["user_name"], Settings.Ext);
}
lblNewBlogs.Text = sb.ToString();
sb = new StringBuilder();
foreach (DataRow row in dt_hot.Rows)
{
sb.AppendFormat("<p class='nitem'><a href='{0}'>{1}</a>", row["filepath"], Tools.HtmlEncode(row["title"].ToString()));
sb.AppendFormat(" - <a class='hui' href='{0}{1}'>{0}</a></p>", row["user_name"], Settings.Ext);
}
lblHotBlogs.Text = sb.ToString();
sb = new StringBuilder();
int i = 0;
foreach (DataRow row in dt_group.Rows)
{
sb.AppendFormat("<div class='gitem'><a href='/group/{0}{1}'><img src='/upload/group/{0}-s.jpg' {2} /></a>", row["g_id"], Settings.Ext, Strings.GroupSmallImageError);
sb.AppendFormat("<p><a href='/group/{0}{1}'>{2}</a></p></div>", row["g_id"], Settings.Ext, Tools.HtmlEncode(row["g_name"].ToString()));
if (++i % 6 == 0) sb.Append("<div class='clear'></div>");
}
lblGroups.Text = sb.ToString();
sb = new StringBuilder();
foreach (DataRow row in dt_topic.Rows)
{
sb.AppendFormat("<p class='nitem'><a href='/group/topic/{0}{1}'>{2}</a></p>", row["t_id"], Settings.Ext, Tools.HtmlEncode(row["t_title"].ToString()));
}
lblHotTopic.Text = sb.ToString();
sb = new StringBuilder();
foreach (DataRow row in dt_1.Rows)
{
sb.AppendFormat("<p class='nitem'><a href='{0}'>{1}</a>", row["filepath"], Tools.HtmlEncode(row["title"].ToString()));
sb.AppendFormat(" - <a class='hui' href='{0}{1}'>{0}</a></p>", row["user_name"], Settings.Ext);
}
lblBlogs1.Text = sb.ToString();
sb = new StringBuilder();
foreach (DataRow row in dt_2.Rows)
{
sb.AppendFormat("<p class='nitem'><a href='{0}'>{1}</a>", row["filepath"], Tools.HtmlEncode(row["title"].ToString()));
sb.AppendFormat(" - <a class='hui' href='{0}{1}'>{0}</a></p>", row["user_name"], Settings.Ext);
}
lblBlogs2.Text = sb.ToString();
sb = new StringBuilder();
foreach (DataRow row in dt_3.Rows)
{
sb.AppendFormat("<p class='nitem'><a href='{0}'>{1}</a>", row["filepath"], Tools.HtmlEncode(row["title"].ToString()));
sb.AppendFormat(" - <a class='hui' href='{0}{1}'>{0}</a></p>", row["user_name"], Settings.Ext);
}
lblBlogs3.Text = sb.ToString();
sb = new StringBuilder();
foreach (DataRow row in dt_4.Rows)
{
sb.AppendFormat("<p class='nitem'><a href='{0}'>{1}</a>", row["filepath"], Tools.HtmlEncode(row["title"].ToString()));
sb.AppendFormat(" - <a class='hui' href='{0}{1}'>{0}</a></p>", row["user_name"], Settings.Ext);
}
lblBlogs4.Text = sb.ToString();
ds.Dispose();
}
示例5: PosTest10
public bool PosTest10()
{
bool retVal = true;
string ActualResult;
object ObjA;
object ObjB;
TestLibrary.TestFramework.BeginScenario("PosTest10:Concat null and an object of Random ");
try
{
ObjA = null;
ObjB = new Random(-55);
ActualResult = string.Concat(ObjA,ObjB);
if (ActualResult != ObjB.ToString())
{
TestLibrary.TestFramework.LogError("019", "Concat null and an object of Random ExpectResult is equel" + ObjB.ToString() + ",ActualResult is (" + ActualResult + ")");
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("020", "Unexpected exception" + e);
retVal = false;
}
return retVal;
}
示例6: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
try
{
string[] hashVarsSeq;
string hash_string = string.Empty;
if (string.IsNullOrEmpty(Request.Form["txnid"])) // generating txnid
{
Random rnd = new Random();
string strHash = Generatehash512(rnd.ToString() + DateTime.Now);
txnid1 = strHash.ToString().Substring(0, 20);
}
else
{
txnid1 = Request.Form["txnid"];
}
if (string.IsNullOrEmpty(Request.Form["hash"])) // generating hash value
{
if (
string.IsNullOrEmpty(ConfigurationManager.AppSettings["MERCHANT_KEY"]) ||
string.IsNullOrEmpty(txnid1) ||
string.IsNullOrEmpty(Request.Form["amount"]) ||
string.IsNullOrEmpty(Request.Form["firstname"]) ||
string.IsNullOrEmpty(Request.Form["email"]) ||
string.IsNullOrEmpty(Request.Form["phone"]) ||
string.IsNullOrEmpty(Request.Form["productinfo"]) ||
string.IsNullOrEmpty(Request.Form["surl"]) ||
string.IsNullOrEmpty(Request.Form["furl"])
)
{
//error
frmError.Visible = true;
return;
}
else
{
frmError.Visible = false;
hashVarsSeq = ConfigurationManager.AppSettings["hashSequence"].Split('|'); // spliting hash sequence from config
hash_string = "";
foreach (string hash_var in hashVarsSeq)
{
if (hash_var == "key")
{
hash_string = hash_string + ConfigurationManager.AppSettings["MERCHANT_KEY"];
hash_string = hash_string + '|';
}
else if (hash_var == "txnid")
{
hash_string = hash_string + txnid1;
hash_string = hash_string + '|';
}
else if (hash_var == "amount")
{
hash_string = hash_string + Convert.ToDecimal(Request.Form[hash_var]).ToString("g29");
hash_string = hash_string + '|';
}
else
{
hash_string = hash_string + (Request.Form[hash_var] != null ? Request.Form[hash_var] : "");// isset if else
hash_string = hash_string + '|';
}
}
hash_string += ConfigurationManager.AppSettings["SALT"];// appending SALT
hash1 = Generatehash512(hash_string).ToLower(); //generating hash
action1 = ConfigurationManager.AppSettings["PAYU_BASE_URL"] + "/_payment";// setting URL
}
}
else if (!string.IsNullOrEmpty(Request.Form["hash"]))
{
hash1 = Request.Form["hash"];
action1 = ConfigurationManager.AppSettings["PAYU_BASE_URL"] + "/_payment";
}
if (!string.IsNullOrEmpty(hash1))
{
hash.Value = hash1;
txnid.Value = txnid1;
System.Collections.Hashtable data = new System.Collections.Hashtable(); // adding values in gash table for data post
data.Add("hash", hash.Value);
data.Add("txnid", txnid.Value);
data.Add("key", key.Value);
string AmountForm = Convert.ToDecimal(amount.Text.Trim()).ToString("g29");// eliminating trailing zeros
//.........这里部分代码省略.........
示例7: Button16_Click
protected void Button16_Click(object sender, EventArgs e)
{
try
{
//connect
string connectMessage = Connect();
IDebtor [] myDebtor = _session.Debtor.GetAll();
if (myDebtor.Length == 0) throw new Exception("No Debtors found");
ICurrentInvoice mycurInvoice = _session.CurrentInvoice.Create(myDebtor[0]);
if (mycurInvoice == null) throw new Exception("No curInvoice created");
ICurrentInvoiceLine myCurInvoiceLine = _session.CurrentInvoiceLine.Create(mycurInvoice);
if (myCurInvoiceLine == null) throw new Exception("No CurInvoiceLine created");
IProduct product = _session.Product.FindByNumber("101");
if (product == null) throw new Exception("No product found");
myCurInvoiceLine.Product = product;
myCurInvoiceLine.Quantity = 3;
myCurInvoiceLine.UnitNetPrice = 1000;
mycurInvoice.Date = DateTime.Now;
int otherRefNumber = new Random().Next(1000000);
mycurInvoice.OtherReference = "Ref_" + otherRefNumber.ToString();
IInvoice bookedInvoice = mycurInvoice.Book();
TextBox4.Text += "Current Invoice Booked.\nOther ref: " + bookedInvoice.OtherReference;
}
catch (Exception ex)
{
TextBox4.Text += ex.Message;
}
finally
{
//always disconnect after we are finished.
Disconnect();
}
}
示例8: GetProductData
private IProductData GetProductData()
{
int prodNumber = new Random().Next(1000000);
string productNumber = "Nr_ " + prodNumber.ToString();
string productName = "My New ProductName " + productNumber;
//Use Product name, if there is one.
if (TextBox5.Text != "") productName = TextBox5.Text;
IProductGroup productGroup = _session.ProductGroup.GetAll()[0];
if (productGroup == null) throw new Exception("No productgroup found.");
IProductData product = _session.ProductData.Create(productNumber, productGroup, productName);
//set sales price, as we ask for that when testing.
product.SalesPrice = prodNumber;
return product;
}
示例9: SendSMSButton_Click
protected void SendSMSButton_Click(object sender, EventArgs e)
{
if (CheckNumber() == CheckNumberResult.Registered)
{
BXUserCollection list = BXEntity<BXUser, BXUserCollection, BXUser.Scheme>.GetList(
new BXFilter(new IBXFilterItem[1]
{
(IBXFilterItem) new BXFilterItem(BXEntity<BXUser, BXUserCollection, BXUser.Scheme>.Fields.UserName, BXSqlFilterOperators.Equal, (object) phonenumber.Text.Trim())
}),
new BXOrderBy(new BXOrderByPair[1]
{
new BXOrderByPair(BXEntity<BXUser, BXUserCollection, BXUser.Scheme>.Fields.UserName, BXOrderByDirection.Asc)
}));
if (list.Count() > 0)
{
try
{
int passcode = new Random().Next(100000, 999999);
BXUser duser = list[0];
//duser.ResetPassword(null, "volotour", passcode.ToString());
//duser.Save();
duser.Delete();
BXUser user = new BXUser();
user.IsApproved = true;
user.UserName = phonenumber.Text.Trim();
user.Password = passcode.ToString();
user.ProviderName = "BXSqlMembershipProvider";
user.Email = phonenumber.Text.Trim() + "@volotour.ru";
user.Save();
Volotour.PersonalOffice.PersonalOfficeModule.sendsms("c79166104232", "ltkmaby123", phonenumber.Text, "Ваш новый пароль для volotour.ru " + passcode.ToString() + "\r\nРекомендуется сменить пароль!", true);
SmsMessagePanel.Visible = true;
SendSMSButtonPanel.Visible = false;
}
catch (Exception ex)
{
hasErrors = true;
LastError = ex.Message;
}
}
}
else
{
hasErrors = true;
LastError = "Номер не зарегистрирован";
}
ErrorForm.Visible = hasErrors;
ErrorMessage.Text = LastError;
}
示例10: GoToPayUMoney
protected void GoToPayUMoney()
{
try
{
string[] hashVarsSeq;
string hash_string = string.Empty;
if (string.IsNullOrEmpty(Request.Form["txnid"])) // generating txnid
{
Random rnd = new Random();
string strHash = Generatehash512(rnd.ToString() + DateTime.Now);
txnid1 = strHash.ToString().Substring(0, 20);
}
else
{
txnid1 = Request.Form["txnid"];
}
if (string.IsNullOrEmpty(Request.Form["hash"])) // generating hash value
{
if (
string.IsNullOrEmpty(payU.MERCHANT_KEY) ||
string.IsNullOrEmpty(payU.ORDER_ID) ||
string.IsNullOrEmpty(payU.AMOUNT) ||
string.IsNullOrEmpty(payU.FIRSTNAME) ||
string.IsNullOrEmpty(payU.EMAIL) ||
string.IsNullOrEmpty(payU.PHONE) ||
string.IsNullOrEmpty(payU.PRODUCT_INFO) ||
string.IsNullOrEmpty(payU.SUCCESS_URL) ||
string.IsNullOrEmpty(payU.FAILURE_URL) ||
string.IsNullOrEmpty(payU.SERVICE_PROVIDER)
)
{
//error
//frmError.Visible = true;
return;
}
else
{
// frmError.Visible = false;
hashVarsSeq = ConfigurationManager.AppSettings["hashSequence"].Split('|'); // spliting hash sequence from config
hash_string = "";
//Sc20Zv|e06a31fd11aee53fe4cb|200|Apple Iphone 6|Mayank|[email protected].com|||||||||||
hash_string = hash_string + payU.MERCHANT_KEY + "|" + payU.ORDER_ID + "|" + payU.AMOUNT + "|" + payU.PRODUCT_INFO + "|" + payU.FIRSTNAME + "|" + payU.EMAIL + "|||||||||||";
hash_string += ConfigurationManager.AppSettings["SALT"];// appending SALT
hash1 = Generatehash512(hash_string).ToLower(); //generating hash
action1 = ConfigurationManager.AppSettings["PAYU_BASE_URL"] + "/_payment";// setting URL
}
}
else if (!string.IsNullOrEmpty(Request.Form["hash"]))
{
hash1 = Request.Form["hash"];
action1 = ConfigurationManager.AppSettings["PAYU_BASE_URL"] + "/_payment";
}
if (!string.IsNullOrEmpty(hash1))
{
//hash.Value = hash1;
//txnid.Value = txnid1;
System.Collections.Hashtable data = new System.Collections.Hashtable(); // adding values in gash table for data post
data.Add("hash", hash1);
data.Add("txnid", payU.ORDER_ID);
data.Add("key", payU.MERCHANT_KEY);
string AmountForm = Convert.ToDecimal(payU.AMOUNT).ToString("g29");// eliminating trailing zeros
data.Add("amount", AmountForm);
data.Add("firstname", payU.FIRSTNAME);
data.Add("email", payU.EMAIL);
data.Add("phone", payU.PHONE);
data.Add("productinfo", payU.PRODUCT_INFO.Trim());
data.Add("surl", payU.SUCCESS_URL.Trim());
data.Add("furl", payU.FAILURE_URL.Trim());
data.Add("lastname", payU.lastName.Trim());
data.Add("curl", "");
data.Add("address1", "");
data.Add("address2", "");
data.Add("city", "");
data.Add("state", "");
data.Add("country","");
data.Add("zipcode", "");
data.Add("udf1", "");
data.Add("udf2", "");
data.Add("udf3","");
data.Add("udf4", "");
data.Add("udf5", "");
data.Add("pg", "");
data.Add("service_provider", payU.SERVICE_PROVIDER);
string strForm = PreparePOSTForm(action1, data);
Page.Controls.Add(new LiteralControl(strForm));
//.........这里部分代码省略.........
示例11: CreateUserLogin
private int CreateUserLogin()
{
//IUserResource userResource = new MockUserResource();
IUserService userService = new UserService();
int i = new Random().Next(1000);
UserLogin ul = new UserLogin();
ul.ExternalID = "wwwwwwwwww" + i.ToString();
ul.UserSourceType = Incyte.SourceType.Facebook;
ul.UserName = "";
ul.Password = "";
userService.LoginCreate(ul);
return ul.UserID;
}