本文整理汇总了C#中System.Collections.Generic.System.Collections.Generic.Dictionary.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.Dictionary.Clear方法的具体用法?C# System.Collections.Generic.Dictionary.Clear怎么用?C# System.Collections.Generic.Dictionary.Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic.System.Collections.Generic.Dictionary
的用法示例。
在下文中一共展示了System.Collections.Generic.Dictionary.Clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: deleteImage
public static string deleteImage(int idUser, int idProduct, int idImage)
{
string errorMessage = string.Empty;
Dictionary<string, object> parameters = new System.Collections.Generic.Dictionary<string, object>();
parameters.Add("idUser", idUser);
string carpeta = string.Empty;
//revisar en BD si el cliente tiene carpeta
carpeta = DataAccess.executeStoreProcedureString("spr_Get_InfoLogo", parameters);
if (!String.IsNullOrEmpty(carpeta))
{
string PathDocs = ConfigurationManager.AppSettings["EmpresasFiles"];
string inicio = HttpContext.Current.Server.MapPath(PathDocs);
string directorioFisico = inicio + carpeta + "\\products\\" + idProduct;
parameters.Clear();
parameters.Add("idUser", idUser);
parameters.Add("idProducto", idProduct);
parameters.Add("idImagen", idImage);
string result = string.Empty;
try
{
result = DataAccess.executeStoreProcedureString("Spr_delete_image", parameters);
}
catch (Exception ex)
{
errorMessage = ex.Message;
}
string filename = result;
Common.makeDirectoryIfNotExists(directorioFisico);
//si existe, borra el que habia
if (System.IO.File.Exists(directorioFisico + "\\" + filename))
File.Delete(directorioFisico + "\\" + filename);
if (System.IO.File.Exists(directorioFisico + "\\small_" + filename))
File.Delete(directorioFisico + "\\small_" + filename);
}
return "{ \"success\": " + (string.IsNullOrEmpty(errorMessage) ? "true" : "false") + ", \"idImage\": " + idImage + " , \"message\": \"" + errorMessage + " \" }";
}
示例2: deleteProduct
public static GenericResponse deleteProduct(int idUser, int idProduct)
{
GenericResponse ret = new GenericResponse();
Dictionary<string, object> parameters = new System.Collections.Generic.Dictionary<string, object>();
parameters.Add("idUser", idUser);
parameters.Add("idProducto", idProduct);
DataSet result;
try
{
result = DataAccess.executeStoreProcedureDataSet("Spr_delete_product", parameters);
if (null != result)
{
//Verificando respuesta
if ((int)result.Tables[0].Rows[0]["Success"] == 1)
{
string carpeta = string.Empty;
parameters.Clear();
parameters.Add("idUser", idUser);
carpeta = DataAccess.executeStoreProcedureString("spr_Get_InfoLogo", parameters);
if (!String.IsNullOrEmpty(carpeta))
{
string PathDocs = ConfigurationManager.AppSettings["EmpresasFiles"];
string inicio = HttpContext.Current.Server.MapPath( PathDocs );
string directorioFisico = inicio + carpeta + "\\products\\" + idProduct;
//Si ok Eliminando fotos
foreach ( DataRow row in result.Tables[1].Rows )
{
if (System.IO.File.Exists(directorioFisico + "\\" + (string)row["nombreArchivo"] ))
File.Delete(directorioFisico + "\\" + (string)row["nombreArchivo"]);
if (System.IO.File.Exists(directorioFisico + "\\small_" + (string)row["nombreArchivo"]))
File.Delete(directorioFisico + "\\small_" + (string)row["nombreArchivo"]);
}
}
}
}
}
catch (Exception ex)
{
ret.success = false;
ret.message = ex.Message;
}
return ret;
}
示例3: saveImage
private string saveImage()
{
string ret = string.Empty;
string filename = string.Empty;
try
{
if ( Request.Files.Count > 0 )
{
var file = Request.Files[0];
Dictionary< string, object > parameters = new System.Collections.Generic.Dictionary< string, object >();
parameters.Add( "idUser", HttpContext.Current.Session["findOut"].ToString() );
string carpeta = string.Empty;
//revisar en BD si el cliente tiene carpeta
carpeta = DataAccess.executeStoreProcedureString( "spr_Get_InfoLogo", parameters );
//ver si tiene carpeta
if ( !String.IsNullOrEmpty( carpeta ) )
{
//buscar el directorio
string PathDocs = ConfigurationManager.AppSettings["EmpresasFiles"];
string inicio = HttpContext.Current.Server.MapPath( PathDocs );
string directorioFisico = inicio + carpeta + "\\products\\" + Request.Form["idProduct"];
//string directorioVirtual = ConfigurationManager.AppSettings["EmpresasFiles"];
//string extension = System.IO.Path.GetExtension(Request.Files[0].FileName);
filename = file.FileName;
Common.makeDirectoryIfNotExists( directorioFisico );
//si existe, borra el que habia
if ( System.IO.File.Exists( directorioFisico + "\\" + filename ) )
File.Delete( directorioFisico + "\\" + filename );
if ( System.IO.File.Exists( directorioFisico + "\\small_" + filename ) )
File.Delete( directorioFisico + "\\small_" + filename );
//cambiar tamaño
System.Drawing.Image originalImage =
System.Drawing.Image.FromStream( file.InputStream, true, true );
//logo grande
System.Drawing.Image resizedImage = originalImage.GetThumbnailImage( 160, 160, null, IntPtr.Zero );
//logo chico
System.Drawing.Image resizedImageCh = originalImage.GetThumbnailImage( 50, 50, null, IntPtr.Zero );
//guarda el nuevo
//Request.Files[0].SaveAs(Server.MapPath(directorioVirtual) + carpeta + "\\logo.png" );
resizedImage.Save( directorioFisico + "\\" + filename );
resizedImageCh.Save( directorioFisico + "\\small_" + filename );
parameters.Clear();
parameters.Add( "idUser", HttpContext.Current.Session["findOut"].ToString() );
parameters.Add( "idProducto", Request.Form["idProduct"] );
parameters.Add( "idImagen", Request.Form["idImage"] );
parameters.Add( "nombreArchivo", filename );
int result = 0;
try
{
result = DataAccess.executeStoreProcedureGetInt( "Spr_insert_image", parameters );
}
catch ( Exception ex )
{
}
if (result > 0)
{
ret = "{\"success\": true, \"message\": \"\", \"attr\": {\"idImage\": " + result + " , \"fileName\": \"" +
filename + "\"}}";
}
else
{
ret = "{\"success\": false, \"message\": \"Error al guardar los datos\"}";
}
}
}
/*ret = "{\"success\": true, \"message\": \"\", \"attr\": {\"idProductImage\": " + 56 + " , \"name\": \"" +
filename + "\"}}";*/
}
catch ( Exception ex )
{
ret = "{\"success\": false, \"message\": \"" + ex.Message + "\"}";
}
return ret;
}