private void Awake() { // if (instance != null && instance != this) // { // Destroy(this.gameObject); // } // // instance = this; // DontDestroyOnLoad( this.gameObject ); if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(this); } //Get Update [must download content i.e. critical asset / csv] //Load all CSV data into dictionary lvMasterData = CSVHelper.Read(LV_CSV); //Bluprint //read from blueprint.csv //then seperate craft_type into different dictionary; }
protected void imgImportData_Click(object sender, ImageClickEventArgs e) { //Thread.Sleep(1000000); try { #region 订单交易导入 if (!String.IsNullOrEmpty(fileOrderUpload.PostedFile.FileName)) { //文件扩展名 string fileExtend = ""; string filePath = ""; //文件大小 int fileSize = 0; filePath = fileOrderUpload.PostedFile.FileName.ToLower().Trim(); //取得上传前的文件(存在于客户端)的文件或文件夹的名称 string[] names = filePath.Split('\\'); //取得文件名 string name = names[names.Length - 1]; //获得服务器端的根目录 string serverPath = Server.MapPath("~/SellerReport"); //判断是否有该目录 if (!Directory.Exists(serverPath)) { Directory.CreateDirectory(serverPath); } filePath = serverPath + "\\" + name; var fileImprtPath = serverPath + "\\"; //如果存在,删除文件 if (File.Exists(filePath)) { File.Delete(filePath); } // 上传文件 fileOrderUpload.PostedFile.SaveAs(filePath); //得到扩展名 fileExtend = filePath.Substring(filePath.LastIndexOf(".")); if (fileExtend != ".csv") { lbError.Text = "只支持CSV格式的文件!"; return; } CSVHelper obj = new CSVHelper(fileImprtPath, fileOrderUpload.FileName.ToLower().Trim()); DataTable tb = obj.Read(); //将订单交易信息写入到DB,同时更新买家表信息 if (tb != null && tb.Rows.Count > 0) { Trade o = null; Buyers objBuyer = null; string sellerId = SellersBLL.GetSellerIdByNick(Users.Nick); DataTable tbSource = BuyerBLL.GetSellerNoDetailsInfo(sellerId); foreach (DataRow row in tb.Rows) { try { o = new Trade(); o.Tid = Convert.ToInt64(string.IsNullOrEmpty(row["订单编号"].ToString()) ? "000000" : row["订单编号"].ToString()); o.BuyerNick = row["买家会员名"].ToString(); o.SellerNick = Users.Nick; o.ReceiverAddress = row["收货地址 "].ToString(); o.ReceiverName = row["收货人姓名"].ToString(); o.ReceiverPhone = row["联系电话 "].ToString(); o.ReceiverMobile = row["联系手机"].ToString(); //更新买家信息表数据 objBuyer = new Buyers(); objBuyer.Address = o.ReceiverAddress; if (!String.IsNullOrEmpty(o.ReceiverAddress)) { string[] info = o.ReceiverAddress.Split(new char[] { ' ' }); if (info.Length > 0) { objBuyer.BuyerProvince = info[0].ToString(); } } objBuyer.BuyerNick = o.BuyerNick; objBuyer.CellPhone = o.ReceiverMobile == null ? "" : o.ReceiverMobile.Replace("'", ""); objBuyer.Phone = o.ReceiverPhone == null ? "" : o.ReceiverPhone.Replace("'", ""); objBuyer.Buyer_reallName = String.IsNullOrEmpty(o.ReceiverName) ? "unknown!" : o.ReceiverName; objBuyer.SELLER_ID = Users.Nick; if (SellersBLL.SearchBuyers(tbSource, objBuyer.BuyerNick)) { BuyerBLL.UpdateForHistory(objBuyer, sellerId); } } catch (Exception ex) { //ExceptionReporter.WriteLog(ex, ExceptionPostion.TBApply_Web_UI); continue; } } } } #endregion } catch (Exception ex) { ExceptionReporter.WriteLog(ex, ExceptionPostion.TBApply_Data); lbError.Text = "导入报表失败,请联系客服!"; return; } lbError.Text = "导入报表数据成功!"; lbError.ForeColor = Color.Blue; }
protected void imgImportData_Click(object sender, ImageClickEventArgs e) { //Thread.Sleep(1000000); try { //ImageButton1.ImageUrl = @"~/Images/importing.png"; #region 订单交易导入 if (!String.IsNullOrEmpty(fileOrderUpload.PostedFile.FileName)) { //文件扩展名 string fileExtend = ""; string filePath = ""; //文件大小 long fileSize = 0; filePath = fileOrderUpload.PostedFile.FileName.ToLower().Trim(); //取得上传前的文件(存在于客户端)的文件或文件夹的名称 string[] names = filePath.Split('\\'); //取得文件名 string name = names[names.Length - 1]; //获得服务器端的根目录 string serverPath = Server.MapPath("~/SellerReport"); //判断是否有该目录 if (!Directory.Exists(serverPath)) { Directory.CreateDirectory(serverPath); } filePath = serverPath + "\\" + name; var fileImprtPath = serverPath + "\\"; //如果存在,删除文件 if (File.Exists(filePath)) { File.Delete(filePath); } // 上传文件 fileOrderUpload.PostedFile.SaveAs(filePath); //得到扩展名 fileExtend = filePath.Substring(filePath.LastIndexOf(".")); if (fileExtend != ".csv") { lbError.Text = "只支持CSV格式的文件!"; lbError.ForeColor = Color.Red; return; } System.IO.FileInfo f = new FileInfo(filePath); fileSize = f.Length; int size = Convert.ToInt32(fileSize) / (1024 * 1024); if (size >= 20) { lbError.Text = "最大可上传文件大小为20M!"; lbError.ForeColor = Color.Red; return; } CSVHelper obj = new CSVHelper(fileImprtPath, fileOrderUpload.FileName.ToLower().Trim()); DataTable tb = obj.Read(); long tick = DateTime.Now.Ticks; Random ran = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32)); //将订单交易信息写入到DB,同时更新买家表信息 if (tb != null && tb.Rows.Count > 0) { Trade o = null; Buyers objBuyer = null; foreach (DataRow row in tb.Rows) { try { o = new Trade(); //o.Tid = Convert.ToInt64(string.IsNullOrEmpty(row["订单编号"].ToString()) ? "000000" : row["订单编号"].ToString()); o.BuyerNick = row["买家会员名"].ToString(); o.SellerNick = Users.Nick; o.ReceiverAddress = row["收货地址 "].ToString(); o.ReceiverName = row["收货人姓名"].ToString(); o.ReceiverPhone = row["联系电话 "].ToString(); o.ReceiverMobile = row["联系手机"].ToString(); //更新买家信息表数据 objBuyer = new Buyers(); objBuyer.Address = o.ReceiverAddress; if (!String.IsNullOrEmpty(o.ReceiverAddress)) { string[] info = o.ReceiverAddress.Split(new char[] { ' ' }); if (info.Length > 0) { objBuyer.BuyerProvince = info[0].ToString(); } } objBuyer.BuyerId = Convert.ToInt64(ran.Next().ToString()); objBuyer.BuyerNick = o.BuyerNick; objBuyer.CellPhone = o.ReceiverMobile == null ? "" : o.ReceiverMobile.Replace("'", ""); objBuyer.Phone = o.ReceiverPhone == null ? "" : o.ReceiverPhone.Replace("'", ""); objBuyer.Buyer_reallName = String.IsNullOrEmpty(o.ReceiverName) ? "unknown!" : o.ReceiverName; objBuyer.SELLER_ID = Users.Nick; objBuyer.UpdateDate = DateTime.Now.ToString(); objBuyer.LastTradeTime = Convert.ToString(row["订单付款时间 "]); objBuyer.TradeAmount = row["买家实际支付金额"].ToString(); objBuyer.ItemNum = Convert.ToInt64(row["宝贝总数量"]); objBuyer.TradeCount = 1L; objBuyer.Grade = 1; objBuyer.Address = o.ReceiverAddress; if (BuyerBLL.CheckBuyerIsExit(objBuyer.BuyerNick, Users.Nick, sellerId)) { BuyerBLL.UpdateForHistory(objBuyer, sellerId); } else { BuyerBLL.AddBuyerBySeller(objBuyer); } } catch (Exception ex) { //ExceptionReporter.WriteLog(ex, ExceptionPostion.TBApply_Web_UI); continue; } } //将最新同步数据时间更新写入DB Sellers objSeller = new Sellers(); objSeller.Nick = Users.Nick; SellersBLL.UpdateSellerSynDate(objSeller); } lbError.Text = "导入报表数据成功!"; } else { lbError.Text = "请选择小于20M的CSV格式文件!"; } //ImageButton1.ImageUrl = @"~/Images/import.png"; #endregion } catch (Exception ex) { ExceptionReporter.WriteLog(ex, ExceptionPostion.TBApply_Data); //lbError.Text = "导入报表失败,请联系客服!"; lbError.Text = "导入报表失败,报表内容格式不正确!"; lbError.ForeColor = Color.Red; //ImageButton1.ImageUrl = @"~/Images/import.png"; return; } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string sigNames = SellersBLL.GetSignName(Users.Nick); string sigName = "【" + SellersBLL.GetSignName(Users.Nick) + "】"; //string sigName = "【澄腾科技01】"; HttpFileCollection files = context.Request.Files; if (files.Count > 0) { HttpPostedFile file = files[0]; string[] noWenmings = new string[] { "傻逼", "草", "靠", "黄片", "尼玛", "你妈", "屌丝", "逗比", "你妹", "装逼", "妈蛋", "逼格", "撕逼" , "滚粗", "蛋疼", "婊砸", "跪舔", "婊", "碧池", "土肥圆", "矮穷挫" }; string content = context.Request.QueryString["msgContent"]; for (int s = 0; s < noWenmings.Length - 1; s++) { if (content.IndexOf(noWenmings[s]) > 0) { context.Response.Write("6"); HttpContext.Current.ApplicationInstance.CompleteRequest(); return; } } List <string> phones = new List <string>(); if (!String.IsNullOrEmpty(file.FileName)) { #region 文件上传 //文件扩展名 string fileExtend = ""; string filePath = ""; //文件大小 int fileSize = 0; filePath = file.FileName.ToLower().Trim(); //取得上传前的文件(存在于客户端)的文件或文件夹的名称 string[] names = filePath.Split('\\'); //取得文件名 string name = names[names.Length - 1]; //获得服务器端的根目录 string serverPath = context.Server.MapPath("~/SellerReport"); //判断是否有该目录 if (!Directory.Exists(serverPath)) { Directory.CreateDirectory(serverPath); } filePath = serverPath + "\\" + name; var fileImprtPath = serverPath + "\\"; //如果存在,删除文件 if (File.Exists(filePath)) { File.Delete(filePath); } // 上传文件 file.SaveAs(filePath); //得到扩展名 fileExtend = filePath.Substring(filePath.LastIndexOf(".")); if (fileExtend != ".txt" && fileExtend != ".csv") { context.Response.Write("1"); context.Response.End(); } #endregion // 获得给卖家设置的发送百分之几 int i = 100; DataTable dtPrecent = MsgBLL.GetSellerMsgSendPrecent(Users.Nick); if (dtPrecent == null || dtPrecent.Rows.Count == 0 || dtPrecent.Rows[0]["sendPrecent"] == DBNull.Value) { i = 100; } else { try { i = Convert.ToInt32(dtPrecent.Rows[0]["sendPrecent"]); } catch (Exception es) { i = 100; } } //短信发送开始记录 msgSendingBLL.update(Users.Nick, 1); //CSV格式 if (fileExtend == ".csv") { System.IO.FileInfo f = new FileInfo(filePath); CSVHelper obj = new CSVHelper(serverPath + "\\", name); DataTable tb = obj.Read(); //将订单交易信息写入到DB,同时更新买家表信息 if (tb != null && tb.Rows.Count > 0) { float ftemp = (float)i / 100; //可以发送的短信条数 int cansendCount = Convert.ToInt32(tb.Rows.Count * ftemp); int sendedCount = 1; for (int t = 0; t < tb.Rows.Count; t++) { string cellPhone = tb.Rows[t]["联系手机"].ToString(); if (string.IsNullOrEmpty(cellPhone) == true) { continue; } string num_char = cellPhone.Substring(0, 1); if (Utility.IsINT(num_char) == false) { cellPhone = cellPhone.Substring(1, cellPhone.Length - 1); } if (phones.Contains(cellPhone) || cellPhone == "") { continue; } cellPhone = cellPhone.Replace("\'", ""); phones.Add(cellPhone); try { //判断手机 if (Utility.IsCellPhone(cellPhone.Replace("\'", ""))) { //if(true) if (MsgBLL.CheckSellerMsgStatus()) { MsgSendHis objHis = new MsgSendHis(); objHis.TransNumber = DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + cellPhone; //手机号码 2016 yao c objHis.SellerNick = Users.Nick; //objHis.SellerNick = "澄腾科技"; objHis.Buyer_nick = "*****"; objHis.CellPhone = cellPhone; objHis.SendDate = DateTime.Now; objHis.SendType = "手工发送"; objHis.SendStatus = "0"; objHis.Count = "1"; //objHis.MsgContent = "【" + SellersBLL.GetSignName(Users.Nick) + "】" + txtContent.Text.Trim();// +"退订回T"; objHis.MsgContent = sigName + content.Trim() + "退订回N"; if (!Utility.IsYiDongCellPhoneNo(cellPhone)) { objHis.HelpSellerNick = "电信联通"; } else { objHis.HelpSellerNick = "移动"; } //if (true) test if (SmartBLL.AddMsgSendHis(objHis)) { try { objHis.MsgContent = objHis.MsgContent.Replace(" ", ""); if (objHis.MsgContent.Length <= 70) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 1); } else if (objHis.MsgContent.Length > 70 && objHis.MsgContent.Length <= 134) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 2); } else if (objHis.MsgContent.Length > 134 && objHis.MsgContent.Length <= 195) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 3); } else if (objHis.MsgContent.Length > 195 && objHis.MsgContent.Length <= 260) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 4); } //File.AppendAllText(@"D:\log\1.txt", "sendedCount:" + t + " cansendCount:" + cansendCount + "\n"); if (t >= cansendCount) { SmartBLL.UpdateSendStatus("99", objHis.TransNumber); } else { string sendStatus = TBSendMSg.SendMsg(cellPhone, sigNames, objHis.MsgContent.Replace(sigName, "")); //SendMsg(cellPhone, sigName, objHis.MsgContent.Trim()); if (!Utility.IsYiDongCellPhoneNo(cellPhone)) { //string sendStatus = Mobile.PostDataToMyServer(cellPhone, objHis.MsgContent.Trim());//20160626 yao c //IDictionary resultDic = TopUtils.ParseJson(sendStatus); SmartBLL.UpdateSendStatus(sendStatus, objHis.TransNumber); } else { //string sendStatus = Mobile.SendMsgHubeiYDPost(cellPhone, objHis.MsgContent);//\r\n\r\n\r\n\r\n0 //sendStatus = sendStatus.Replace("\r", "").Replace("\n", ""); if (sendStatus.Equals("0")) { sendStatus = "100"; } SmartBLL.UpdateSendStatus(sendStatus, objHis.TransNumber); } } } catch (Exception ex) { continue; } } } else { context.Response.Write("3"); //余额不足 //context.Response.End();//使用 Response.End方法,将出现 ThreadAbortException 异常。 HttpContext.Current.ApplicationInstance.CompleteRequest(); return; } } } catch (Exception ex) { continue; } sendedCount++; } } //短信发送成功记录 msgSendingBLL.update(Users.Nick, 2, phones.Count); context.Response.Write("2"); //context.Response.End(); HttpContext.Current.ApplicationInstance.CompleteRequest(); } else if (fileExtend == ".txt") { using (StreamReader Sr = new StreamReader(filePath, true)) { /*读取到的每行内容*/ string cellPhone1 = String.Empty; while (Sr.EndOfStream != true) { cellPhone1 = Sr.ReadLine().Trim(); if (phones.Contains(cellPhone1) || cellPhone1 == "") { continue; } cellPhone1 = cellPhone1.Replace("\'", ""); phones.Add(cellPhone1); } float ftemp = (float)i / 100; //可以发送的短信条数 int cansendCount = Convert.ToInt32(phones.Count * ftemp); int sendedCount = 0; #region 发短信 foreach (string cellPhone in phones) { int j = 0; try { //判断手机 if (Utility.IsCellPhone(cellPhone)) { if (MsgBLL.CheckSellerMsgStatus()) { MsgSendHis objHis = new MsgSendHis(); objHis.TransNumber = DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + cellPhone;//手机号码 2016 yao c objHis.SellerNick = Users.Nick; //objHis.SellerNick = "澄腾科技"; objHis.Buyer_nick = "*****"; objHis.CellPhone = cellPhone; objHis.SendDate = DateTime.Now; objHis.SendType = "手工发送"; objHis.SendStatus = "0"; objHis.Count = "1"; objHis.MsgContent = sigName + content.Trim() + " 退订回N"; if (!Utility.IsYiDongCellPhoneNo(cellPhone)) { objHis.HelpSellerNick = "电信联通"; } else { objHis.HelpSellerNick = "移动"; } //if (true) test if (SmartBLL.AddMsgSendHis(objHis)) { try { objHis.MsgContent = objHis.MsgContent.Replace(" ", ""); if (objHis.MsgContent.Length <= 70) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 1); } else if (objHis.MsgContent.Length > 70 && objHis.MsgContent.Length <= 134) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 2); } else if (objHis.MsgContent.Length > 134 && objHis.MsgContent.Length <= 195) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 3); } else if (objHis.MsgContent.Length > 195 && objHis.MsgContent.Length <= 260) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 4); } if (sendedCount >= cansendCount) { SmartBLL.UpdateSendStatus("99", objHis.TransNumber); } else { string sendStatus = TBSendMSg.SendMsg(cellPhone, sigNames, objHis.MsgContent.Replace("退订回N", "").Replace(sigName, "")); if (!Utility.IsYiDongCellPhoneNo(cellPhone)) { //string sendStatus = Mobile.SendMsgKeTongDX(cellPhone, objHis.MsgContent); //string sendStatus = Mobile.PostDataToMyServer(cellPhone, objHis.MsgContent.Trim());//20160626 yao c //IDictionary resultDic = TopUtils.ParseJson(sendStatus); //SmartBLL.UpdateSendStatus(resultDic["status"].ToString(), objHis.TransNumber); SmartBLL.UpdateSendStatus(sendStatus, objHis.TransNumber); } else { //string sendStatus = Mobile.SendMsgHubeiYDPost(cellPhone, objHis.MsgContent);//\r\n\r\n\r\n\r\n0 //sendStatus = sendStatus.Replace("\r", "").Replace("\n", ""); if (sendStatus.Equals("0")) { sendStatus = "100"; } SmartBLL.UpdateSendStatus(sendStatus, objHis.TransNumber); } } sendedCount++; j++; //} //else //{ // if (!Utility.IsYiDongCellPhoneNo(cellPhone)) // { // string sendStatus = Mobile.PostDataToMyServer(cellPhone, objHis.MsgContent.Trim(), ""); // } // else // { // Mobile.SendMsgKeTongYD(cellPhone, objHis.MsgContent); // } //} } catch (Exception ex) { continue; } } } else { context.Response.Write("3");//余额不足 //context.Response.End();//使用 Response.End方法,将出现 ThreadAbortException 异常。 HttpContext.Current.ApplicationInstance.CompleteRequest(); return; } } } catch (Exception ex) { continue; } } #endregion //短信发送成功记录 msgSendingBLL.update(Users.Nick, 2, phones.Count); context.Response.Write("2"); //context.Response.End(); HttpContext.Current.ApplicationInstance.CompleteRequest(); } } } else { context.Response.Write("0"); //context.Response.End(); HttpContext.Current.ApplicationInstance.CompleteRequest(); msgSendingBLL.update(Users.Nick, 2, phones.Count); } } }