private int BuildRationCDKey(List <string> temp_cdkey, CDKey_Event cdkey) { List <string> contrast_cdkey = new List <string>(); for (int i = 0; i < cdkey.CDKeyNum; i++) { string cdk_str = ""; cdk_str = CreateCDkey(cdkey.CDKeyLen, cdkey.letter); temp_cdkey.Add(cdk_str); contrast_cdkey.Add(cdk_str); } //检查是否重复 int count = 0; int check = 0; for (int i = 0; i < temp_cdkey.Count; i++) { for (int j = 0; j < contrast_cdkey.Count; j++) { if (temp_cdkey[i].Equals(contrast_cdkey[j])) { check++; if (check >= 2) { //temp_cdkey.Remove(temp_cdkey[i]); count++; break; } } } check = 0; } //返回重复数量 return(count); }
public int sendCreateCDKeyEventPara(CDKey_Event cdkey) { RCToCS.CreateCDKey msg = new RCToCS.CreateCDKey(); msg.title = cdkey.title; msg.platform = (int)cdkey.platform; msg.end_time = (UInt64)cdkey.end_time; msg.content = cdkey.gift_msg; msg.gift_type = cdkey.gift_type; msg.code_len = cdkey.CDKeyLen; for (int i = 0; i < cdkey.gift_num; i++) { RCToCS.CreateCDKey.giftInfo info = new RCToCS.CreateCDKey.giftInfo(); info.item_id = cdkey.item_id[i]; info.item_num = cdkey.item_num[i]; msg.gift.Add(info); } //MessageBox.Show("正在生成..."); //产生CDKey List <string> temp_cdkey = new List <string>(); int num = BuildRationCDKey(temp_cdkey, cdkey); //把CDKey发送到数据库 for (int i = 0; i < temp_cdkey.Count; i++) { msg.cdkey.Add(temp_cdkey[i]); if (i % 10000 == 0 || i == temp_cdkey.Count - 1) { sendMsg(msg, (int)msg.msgid); } } sendMsg(msg, (int)msg.msgid); return(0); }