public IActionResult Download(string userId, string picId) { var nowPic = services.getPicture(picId); var publisher = services.GetUserById(context.publishPicture.FirstOrDefault(p => p.p_id == picId).u_id); if (context.download.FirstOrDefault(d => d.u_id == userId && d.p_id == picId) == null && context.publishPicture.FirstOrDefault(p => p.u_id == userId && p.p_id == picId) == null) {//表示第一次下载且图片不是本人发布 //进行购买 var wallet = context.wallet.Find(userId); if (wallet.coin >= nowPic.price) {//能够支付 wallet.coin = wallet.coin - nowPic.price; wallet.buy_num = wallet.buy_num + 1; context.wallet.Attach(wallet); context.SaveChanges(); var newDownload = new download { u_id = userId, p_id = picId, downloadTime = DateTime.Now, price = nowPic.price }; context.download.Add(newDownload); context.SaveChanges(); //在payment中增加消费记录 var newPayment = new payment { pay_id = (context.payment.Count() + 1).ToString(), u_id = userId, pay_time = DateTime.Now, coin = nowPic.price, type = "CS" }; context.payment.Add(newPayment); context.SaveChanges(); //为图片发布者增加硬币 var publisherWallet = context.wallet.Find(publisher.u_id); publisherWallet.coin += nowPic.price; context.wallet.Attach(publisherWallet); context.SaveChanges(); } else { return(Ok(new { Success = false, msg = "Lack of Coin" })); } } //已经购买进行下载 return(Ok(new { Success = true, downloadUrl = nowPic.p_url, msg = "请右键图片进行手动下载" })); }
public string get_download_parteDiario_fotos(string idFotos, string iduser) { DataTable dt_detalle = new DataTable(); List <download> list_files = new List <download>(); string pathfile = ""; string ruta_descarga = ""; try { using (SqlConnection cn = new SqlConnection(Conexion.bdConexion.cadenaBDcx())) { cn.Open(); using (SqlCommand cmd = new SqlCommand("DSIGE_PROY_W_PARTE_DIARIO_LISTAR_FOTOS_ZIP", cn)) { cmd.CommandTimeout = 0; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@idFotos", SqlDbType.VarChar).Value = idFotos; using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(dt_detalle); pathfile = HttpContext.Current.Server.MapPath("~/Archivos/Fotos/"); foreach (DataRow Fila in dt_detalle.Rows) { download obj_entidad = new download(); obj_entidad.nombreFile = Fila["nombreArchivo"].ToString(); obj_entidad.ubicacion = pathfile; list_files.Add(obj_entidad); } if (list_files.Count > 0) { if (list_files.Count == 1) { ruta_descarga = ConfigurationManager.AppSettings["ServerFilesFoto"] + "Descargas/" + list_files[0].nombreFile; } else { ruta_descarga = comprimir_Files(list_files, iduser); } } else { throw new System.InvalidOperationException("No hay archivo para Descargar"); } } } } } catch (Exception) { throw; } return(ruta_descarga); }
// Use this for initialization IEnumerator Start() { instance = this; Debug.Log (Time.time); //yield return null; // prochaine image yield return new WaitForSeconds (2); //yield return new WaitForEndOfFrame (); // une fois le reste du script calculé sur l'image, il revient là; //StartCoroutine (LogTime ()); // LogTime fonctionne en parallèle // yield return StartCoroutine (LogTime ()); // copie colle le script de LogTime Debug.Log (Time.time); }
protected override void SetPageSessionContext() { base.SetPageSessionContext(); _testEntity = new download(); _privateObject = new PrivateObject(_testEntity); InitializeAllControls(_testEntity); InitializeSessionFakes(); QueryString.Clear(); QueryString.Add(FilterID, OneString); QueryString.Add(ChIDKey, OneString); QueryString.Add(CustIDKey, OneString); QueryString.Add(GroupIDKey, OneString); QueryString.Add(SearchEmailKey, TestEmailAddress); QueryString.Add(FileTypeKey, FileTypes[0]); }
private bool saveDownloadInfoToDB(download updateDownload, string name, string savePath, string status, dynamic movie, dynamic victim, NTVideoEntities context) { victim.downloadStatus = status; if (updateDownload == null) { var download = new download() { victimId = victim.victimId, name = name, savePath = savePath, status = status }; victim.downloads.Add(download); context.Entry(victim).State = System.Data.Entity.EntityState.Modified; } else { updateDownload.status = status; context.Entry(updateDownload).State = System.Data.Entity.EntityState.Modified; } context.SaveChanges(); return(true); }
private void 数据导出ToolStripMenuItem_Click(object sender, EventArgs e) { ////定义sql连接 //SqlConnectionStringBuilder sqlconStringBuilder = new SqlConnectionStringBuilder(); ////sql连接字串 //sqlconStringBuilder.ConnectionString = @"Data Source=(local);Initial Catalog=DBAS;Integrated Security=True"; ////定义语句计算选定sheet中数据的行数 string strSql = string.Format("select name from sys.tables"); //using (SqlConnection conn = new SqlConnection(sqlconStringBuilder.ConnectionString)) //{ //} SqlDataReader reader = null; List <string> list = new List <string>(); try { //conn.Open(); SqlCommand sqlCommand = new SqlCommand(strSql, conn as SqlConnection);//执行查询,返回查询结果 reader = sqlCommand.ExecuteReader(); while (reader.Read()) { list.Add(reader.GetString(0)); } //MessageBox.Show(list.LongCount().ToString()); download d = new download(list); d.Show(); //conn.Close(); reader.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } ////定义sql连接 //SqlConnectionStringBuilder sqlconStringBuilder = new SqlConnectionStringBuilder(); ////sql连接字串 //sqlconStringBuilder.ConnectionString = @"Data Source=(local);Initial Catalog=DBAS;Integrated Security=True"; ////定义语句计算选定sheet中数据的行数 //string strSql = string.Format("select name from sys.tables"); //using (SqlConnection conn = new SqlConnection(sqlconStringBuilder.ConnectionString)) //{ // SqlDataReader reader = null; // List<string> list = new List<string>(); // try // { // conn.Open(); // SqlCommand sqlCommand = new SqlCommand(strSql, conn);//执行查询,返回查询结果 // reader = sqlCommand.ExecuteReader(); // while (reader.Read()) // { // list.Add(reader.GetString(0)); // } // //MessageBox.Show(list.LongCount().ToString()); // d = new download(list); // d.Show(); // conn.Close(); // reader.Close(); // } // catch (Exception ex) // { // MessageBox.Show(ex.Message); // } //} }
public string get_download_archivosImportadosOC(string idFileOrdenCompra, string idusuario) { DataTable dt_detalle = new DataTable(); List <download> list_files = new List <download>(); string pathfile = ""; string rutaOrig = ""; string rutaDest = ""; string nombreArchivoReal = ""; string ruta_descarga = ""; try { using (SqlConnection cn = new SqlConnection(Conexion.bdConexion.cadenaBDcx())) { cn.Open(); using (SqlCommand cmd = new SqlCommand("DSIGE_PROY_W_ORDENCOMPRA_ADJUNTAR_DESCARGAR", cn)) { cmd.CommandTimeout = 0; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@idFileOrdenCompra", SqlDbType.VarChar).Value = idFileOrdenCompra; using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(dt_detalle); pathfile = HttpContext.Current.Server.MapPath("~/Archivos/OrdenCompra/"); foreach (DataRow Fila in dt_detalle.Rows) { download obj_entidad = new download(); obj_entidad.nombreFile = Fila["nombreArchivo"].ToString(); obj_entidad.nombreBd = Fila["nombreArchivo_bd"].ToString(); obj_entidad.ubicacion = pathfile; list_files.Add(obj_entidad); } ////----- restaurando el archivo... foreach (download item in list_files) { nombreArchivoReal = ""; nombreArchivoReal = item.nombreBd.Replace(item.nombreBd, item.nombreFile); rutaOrig = System.Web.Hosting.HostingEnvironment.MapPath("~/Archivos/OrdenCompra/" + item.nombreBd); rutaDest = System.Web.Hosting.HostingEnvironment.MapPath("~/Archivos/OrdenCompra/Descargas/" + nombreArchivoReal); if (System.IO.File.Exists(rutaDest)) //--- borrando restaurarlo { System.IO.File.Delete(rutaDest); System.IO.File.Copy(rutaOrig, rutaDest); } else //--- restaurandolo { System.IO.File.Copy(rutaOrig, rutaDest); } Thread.Sleep(1000); } if (list_files.Count > 0) { if (list_files.Count == 1) { ruta_descarga = ConfigurationManager.AppSettings["ServerFiles"] + "OrdenCompra/descargas/" + list_files[0].nombreFile; } //else //{ // ruta_descarga = comprimir_Files(list_files, id_usuario, tipo); //} } else { throw new System.InvalidOperationException("No hay archivo para Descargar"); } } } } } catch (Exception) { throw; } return(ruta_descarga); }
private void button1_Click(object sender, EventArgs e) { download DL = new download(); DL.Show(); }
public string getDownNav() { string res = string.Empty; string lb = Request.QueryString.Get("sid"); string newsid = Request.QueryString.Get("id"); downloadManager mgr = new downloadManager(); if (!string.IsNullOrEmpty(newsid)) { WhereClip where = new WhereClip(); where = where && download._.id == newsid; download model = new download(); model = mgr.GetdownloadItemById(where); if (model != null) { lb = model.sid.ToString(); } } if (!string.IsNullOrEmpty(lb)) { downclass modelclass = new downclass(); WhereClip where2 = new WhereClip(); where2 = where2 && downclass._.id == lb; modelclass = mgr.GetItemById(where2); res = string.Format(@"<a href='Category.aspx?type=download'>下载中心</a> > <a href='Category.aspx?sid={0}&type=download'>{1}</a>", modelclass.id, modelclass.classname); } else { res = "<a href='Category.aspx?type=download'>下载中心</a>"; } return res; }
static void Main(string[] args) { if (args.Length != 0) { downloads = new Dictionary <string, download>(); string[] data = File.ReadAllLines(args[0]); //read in File content numDownloads = data.Length; index = 0; //Console.WriteLine("links:{0}, numDownloads:{1}", data.Length, numDownloads); for (int i = 0; i < data.Length; i++) { string address = data[i].Trim(); try { if (!downloads.ContainsKey(address)) //dont download the same link twice { download newDownload = new download(); downloads.Add(address, newDownload); downloadLink(address); } } catch (Exception e) { Console.WriteLine("Error: {0} failed with ' {1} '", address, e.Message); } } bool notFin = true; while (notFin) { notFin = false; Thread.Sleep(1000); foreach (KeyValuePair <string, download> pair in downloads) { download d = pair.Value; string progress; if (d.response != null) { if (d.response.IsSuccessStatusCode) { if (d.progress != 100) { notFin = true; } progress = d.progress.ToString() + "%"; } else { progress = "DeadLink!!"; } } else { notFin = true; progress = "Waiting on response!!"; } Console.WriteLine("{0} : {1}", pair.Key, progress); } Console.WriteLine("------------------------------------"); } Console.WriteLine("All Done!!"); Console.Read(); } else { throw new Exception("Input Error!!! Need to pass the name of a file of links to download in \n'link newline link newline etc...' format"); } }