NPOI,导出Execl,压缩文件zip,发送Email
private void SendEmail(string emailAddress, string companyName,string proxy, string officer, DataTable dt)
{
ChangeOfOwnerReport report = new ChangeOfOwnerReport();
MemoryStream stream = report.ExportToExcel(companyName, proxy, officer, dt); string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, string.Format("{0}.xls", "Nomination Notice " + Guid.NewGuid().ToString()));
FileStream ss = new FileStream(fileName, FileMode.OpenOrCreate);
byte[] data = stream.GetBuffer();
ss.Write(data, , data.Length);
ss.Flush();
ss.Close(); EmailTransaction email = new EmailTransaction();
//create zip file
string zipFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, string.Format("{0}.zip", "Nomination Notice " + Guid.NewGuid().ToString())); List<string> srcList = new List<string>();
srcList.Add(fileName); ZipUtility.Zip(zipFileName, srcList, String.Empty);
FileInfo zipFile = new FileInfo(zipFileName);
FileStream fs = zipFile.OpenRead();
byte[] zipByte = new byte[(int)zipFile.Length];
fs.Read(zipByte, , (int)zipFile.Length); email.EmTrAttachment = zipByte;
email.EmTrAttachmentName = "Nomination Notice Response.zip"; fs.Close();
fs.Dispose();
System.IO.File.Delete(zipFileName);
System.IO.File.Delete(fileName); email.EmTrSubject = "Nomination Notice Response";
email.EmTrTo = emailAddress;
string content = "Greetings\r\nPlease find attached CofCT adjudication of change of offender, request submitted by you.\r\nRegards";
content += "\r\nCity of Cape Town Traffic management";
email.EmTrContent = content; EmailManager emailManager = new EmailManager();
emailManager.SendMail(email);
}
NPOI 导出:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Data; using SIL.AARTO.BLL.EntLib;
using NPOI.HSSF.UserModel;
using NPOI.HPSF;
using NPOI.POIFS.FileSystem;
using NPOI.SS.UserModel;
using NPOI.SS.Util; namespace SIL.AARTO.BLL.Report
{
public class ChangeOfOwnerReport
{
private HSSFWorkbook wb;
private ISheet sheet;
public ChangeOfOwnerReport()
{
wb = new HSSFWorkbook();
} public MemoryStream ExportToExcel(string companyName,string proxy,string officer, DataTable dt)
{
try
{
MemoryStream stream = new MemoryStream(); sheet = wb.CreateSheet();
wb.SetSheetName(, "Proxy Nomination Notice"); this.createHeading(companyName, proxy, officer);
this.createTitle();
this.createDataRows(dt); for (int i = ; i < ; i++)
{
sheet.AutoSizeColumn((short)i);
} wb.Write(stream);
return stream;
}
catch (Exception e)
{
EntLibLogger.WriteErrorLog(e, LogCategory.Exception, "COO");
throw e;
}
} private void createHeading(string companyName, string proxy, string officer)
{
IFont font = wb.CreateFont();
font.Boldweight = (short)FontBoldWeight.BOLD;
font.FontHeightInPoints = (short); ICellStyle style = wb.CreateCellStyle();
style.Alignment = HorizontalAlignment.LEFT;
style.VerticalAlignment = VerticalAlignment.CENTER; sheet.CreateRow(); ICell cell = sheet.GetRow().CreateCell();
cell.CellStyle = style;
HSSFRichTextString rtf = new HSSFRichTextString("Submitted by " + companyName + " Proxy " + proxy);
rtf.ApplyFont(font);
cell.SetCellValue(rtf);
CellRangeAddress region = new CellRangeAddress(, , , );
sheet.AddMergedRegion(region); IFont font1 = wb.CreateFont();
font1.Boldweight = (short)FontBoldWeight.BOLD; sheet.CreateRow(); ICell cell1 = sheet.GetRow().CreateCell();
cell1.CellStyle = style;
HSSFRichTextString rtf1 = new HSSFRichTextString("Processed by Officer:" + officer);
rtf1.ApplyFont(font1);
cell1.SetCellValue(rtf1);
CellRangeAddress region1 = new CellRangeAddress(, , , );
sheet.AddMergedRegion(region1); ICell cell2 = sheet.GetRow().CreateCell();
cell2.CellStyle = style;
HSSFRichTextString rtf2 = new HSSFRichTextString(DateTime.Now.ToString("yyyy-MM-dd"));
rtf2.ApplyFont(font1);
cell2.SetCellValue(rtf2);
} private void createTitle()
{
sheet.CreateRow();
IFont fontHeading = wb.CreateFont();
fontHeading.Boldweight = (short)FontBoldWeight.BOLD;
ICellStyle styleHeading = wb.CreateCellStyle();
styleHeading.Alignment = HorizontalAlignment.CENTER;
styleHeading.VerticalAlignment = VerticalAlignment.CENTER; ICell cell1 = sheet.GetRow().CreateCell();
cell1.CellStyle = styleHeading;
HSSFRichTextString rtf1 = new HSSFRichTextString("Notice No");
rtf1.ApplyFont(fontHeading);
cell1.SetCellValue(rtf1); ICell cell2 = sheet.GetRow().CreateCell();
cell2.CellStyle = styleHeading;
HSSFRichTextString rtf2 = new HSSFRichTextString("Registration");
rtf2.ApplyFont(fontHeading);
cell2.SetCellValue(rtf2); ICell cell3 = sheet.GetRow().CreateCell();
cell3.CellStyle = styleHeading;
HSSFRichTextString rtf3 = new HSSFRichTextString("Offence Date");
rtf3.ApplyFont(fontHeading);
cell3.SetCellValue(rtf3); ICell cell4 = sheet.GetRow().CreateCell();
cell4.CellStyle = styleHeading;
HSSFRichTextString rtf4 = new HSSFRichTextString("Offender");
rtf4.ApplyFont(fontHeading);
cell4.SetCellValue(rtf4); ICell cell5 = sheet.GetRow().CreateCell();
cell5.CellStyle = styleHeading;
HSSFRichTextString rtf5 = new HSSFRichTextString("Status");
rtf5.ApplyFont(fontHeading);
cell5.SetCellValue(rtf5);
} private void createDataRows(DataTable dt)
{
for (int i = ; i < dt.Rows.Count; i++)
{
sheet.CreateRow( + i); ICell cell1 = sheet.GetRow( + i).CreateCell();
cell1.SetCellValue(dt.Rows[i]["Notice No"].ToString()); ICell cell2 = sheet.GetRow( + i).CreateCell();
cell2.SetCellValue(dt.Rows[i]["Registration"].ToString()); ICell cell3 = sheet.GetRow( + i).CreateCell();
cell3.SetCellValue(dt.Rows[i]["Offence Date"].ToString()); ICell cell4 = sheet.GetRow( + i).CreateCell();
cell4.SetCellValue(dt.Rows[i]["Offender"].ToString()); ICell cell5 = sheet.GetRow( + i).CreateCell();
cell5.SetCellValue(dt.Rows[i]["Status"].ToString());
}
}
}
}
发邮件:EmailManager.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Net.Mail; using SIL.ServiceQueueLibrary.DAL.Entities;
using SIL.ServiceQueueLibrary.DAL.Services;
using System.ComponentModel;
using System.Net;
using System.IO;
using System.Net.Mime;
//using SIL.ServiceLibrary.Email; namespace SIL.ServiceLibrary
{ public class EmailManager
{
private string _from = string.Empty;
private string _userName = string.Empty;
private string _smtp = string.Empty;
private string _password = string.Empty;
private bool _isAuthenticate = false;
private int _port = ;
static object lockEmail = new object(); //readonly Email.EmailServerInformation emailServer = new Email.EmailServerInformation();
//readonly string _connStr = string.Empty; public EmailManager()
{ } public EmailManager(string from, string smtp, string userName, string password, bool isAuthenticate, int? port)
{
//this._connStr = connStr;
//_from = System.Configuration.ConfigurationManager.AppSettings["AdminEmailAddress"];
//_smtp = System.Configuration.ConfigurationManager.AppSettings["SmtpServer"];
//_userName = System.Configuration.ConfigurationManager.AppSettings["SmtpUserName"];
//_password = System.Configuration.ConfigurationManager.AppSettings["SmtpPassword"];
//_isAuthenticate = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["IsAuthenticate"]);
//_port = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpPort"]); this._from = from;
this._smtp = smtp; if (isAuthenticate)
{
this._userName = userName;
this._password = password;
this._isAuthenticate = isAuthenticate;
}
if (port != null)
{
this._port = port.Value;
}
} /// <summary>
/// Update sentToQueueDateTime field by FK(emtrID)
/// </summary>
/// <param name="emTrID"></param>
/// <param name="sentToQueueDate"></param>
/// <returns></returns> //public List<EmailTransaction> GetEmailTransaction(int pageSize)
//{ // SqlParameter[] para = new SqlParameter[]{
// new SqlParameter("@PageSize",SqlDbType.Int)
// };
// para[0].Value = pageSize; // EmailTransaction email = null;
// List<EmailTransaction> returnList = new List<EmailTransaction>(); // SqlConnection con = new SqlConnection(this._connStr);
// SqlCommand cmd = con.CreateCommand();
// cmd.CommandText = "SILCustom_EmailTransaction_GetEmailTransaction";
// cmd.CommandType = CommandType.StoredProcedure;
// cmd.Parameters.AddRange(para); // try
// {
// if (con.State == ConnectionState.Closed)
// con.Open(); // using (SqlDataReader reader = cmd.ExecuteReader())
// {
// while (reader.Read())
// {
// email = new EmailTransaction();
// email.EmTrId = (decimal)reader["EmTrId"]; // email.EmTrTo = reader["EmTrTo"].ToString();
// email.EmTrCc = reader["EmTrCc"].ToString();
// email.EmTrBcc = reader["EmTrBcc"].ToString();
// //email.EmTrFrom = reader["EmTrFrom"].ToString();
// email.EmTrSubject = reader["EmTrSubject"].ToString();
// email.EmTrContent = reader["EmTrContent"].ToString();
// email.EmTrSendDate = reader["EmTrSendDate"] is DBNull ? null : (DateTime?)reader["EmTrSendDate"];
// email.EmTrRetryCount = reader["EmTrRetryCount"] is DBNull ? null : (byte?)reader["EmTrRetryCount"];
// email.EmTrSendSuccess = reader["EmTrSendSuccess"] is DBNull ? null : (bool?)reader["EmTrSendSuccess"];
// email.LastUser = reader["LastUser"].ToString();
// //email.EmTrLoadedDate = Convert.ToDateTime(reader["EmTrLoadedDate"]);
// // email.SentToQueueDateTime = reader["SentToQueueDateTime"] is DBNull ? null : (DateTime?)reader["SentToQueueDateTime"];
// //email.IsHtmlEmail = Convert.ToBoolean(reader["EmTrIsHtml"]); // returnList.Add(email);
// }
// } // return returnList;
// }
// catch
// {
// return null;
// }
// finally
// {
// if (con.State == ConnectionState.Open)
// con.Close();
// }
//} public void GetEmailToSend()
{
//<add key="SmtpServer" value="smtp.163.com"/>
//<add key="UserName" value="test@163.com"/>
//<add key="Password" value="000000"/>
//System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(); string sql = " EmTrSendDate IS NULL AND (EmTrSendSuccess IS NULL OR EmTrSendSuccess= 0) AND (EmTrRetryCount IS NULL OR EmTrRetryCount < 3 )";
int totalCount = ;
TList<EmailTransaction> emails = new EmailTransactionService().GetPaged(sql, "", , , out totalCount);
MailMessage message = null;
foreach (EmailTransaction email in emails)
{
message = new MailMessage(); message.From = new MailAddress(_from.Trim()); if (!String.IsNullOrEmpty(email.EmTrTo))
{
foreach (string addr in email.EmTrTo.Trim().Split(';'))
{
if (!String.IsNullOrEmpty(addr))
message.To.Add(new MailAddress(addr));
}
}
if (!String.IsNullOrEmpty(email.EmTrCc))
{
foreach (string addr in email.EmTrCc.Trim().Split(';'))
{
if (!String.IsNullOrEmpty(addr))
message.CC.Add(new MailAddress(addr));
}
} message.Subject = email.EmTrSubject;
message.Body = email.EmTrContent;
message.Priority = MailPriority.High; //msg.Subject = message.Subject;
message.SubjectEncoding = System.Text.Encoding.UTF8; message.BodyEncoding = System.Text.Encoding.UTF8;
message.IsBodyHtml = false; //add attachment
if (!String.IsNullOrEmpty(email.EmTrAttachmentName)
&& email.EmTrAttachment != null
&& email.EmTrAttachment.Count() > )
{
message.Attachments.Add(AddAttachment(email.EmTrAttachment, email.EmTrAttachmentName));
} SmtpClient client = new SmtpClient(_smtp);
//client.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback);
//client.UseDefaultCredentials = true;
if (_isAuthenticate)
{
client.Credentials = new System.Net.NetworkCredential(_userName, _password);
client.DeliveryMethod = SmtpDeliveryMethod.Network;
}
else
{
client.UseDefaultCredentials = true;
//client.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
//client.Credentials = CredentialCache.DefaultNetworkCredentials;
}
//client.EnableSsl = true; if (_port > ) client.Port = _port;
object userState = email.EmTrId;
try
{
lock (lockEmail)
{
client.Send(message);
//client.SendAsync(message, userState);
//EmailInterface e = new EmailInterface();
//e.MhtUnLockCode = System.Configuration.ConfigurationManager.AppSettings["MhtUnLockCode"]; ;
//e.EmailUnLockCode = System.Configuration.ConfigurationManager.AppSettings["MailUnLockCode"];
//e.SmtpServer = emailServer.SmtpServer; //e.SendMail(email,emailServer);
//client.Send(message); EmailTransaction emailTran = new EmailTransactionService().GetByEmTrId(email.EmTrId);
if (emailTran != null)
{
emailTran.EmTrSendDate = DateTime.Now;
emailTran.EmTrSendSuccess = true;
new EmailTransactionService().Save(emailTran);
}
}
//while (mailSent == false)
//{ //}
}
catch (System.Net.Mail.SmtpException ex)
{
throw ex;
} } } /// <summary>
/// Test function
/// </summary>
/// <param name="from"></param>
/// <param name="mailTo"></param>
/// <param name="subject"></param>
/// <param name="body"></param>
/// <returns></returns>
public bool SendEmail(string from, string mailTo, string subject, string body)
{
bool r = false;
try
{
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(); msg.To.Add(mailTo); msg.From = new MailAddress(from, from, System.Text.Encoding.UTF8);
msg.Subject = subject;
msg.SubjectEncoding = System.Text.Encoding.UTF8;
msg.Body = body;
msg.BodyEncoding = System.Text.Encoding.UTF8;
msg.IsBodyHtml = true;
msg.Priority = System.Net.Mail.MailPriority.High;
SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential("jakezyz@163.com", "test");
client.Port = ;
client.Host = "smtp.163.com";
client.EnableSsl = true;
object userState = msg;
client.Send(msg);
r = true;
}
catch (System.Net.Mail.SmtpException ex)
{
throw ex;
}
return r; } public void SendMail(EmailTransaction emailTran)
{
try
{
if (emailTran != null)
{
emailTran.EmTrRetryCount = ;
emailTran.EmTrCreatedDate = DateTime.Now;
emailTran.EmTrSendDate = null;
emailTran.EmTrSendSuccess = false;
new EmailTransactionService().Save(emailTran);
}
}
catch (Exception ex)
{
throw ex;
}
} public static void SendCompletedCallback(object sender, AsyncCompletedEventArgs e)
{
// Get the unique identifier for this asynchronous operation.
decimal token = (decimal)e.UserState; if (e.Cancelled || e.Error != null)
{ }
else
{
EmailTransaction emailTran = new EmailTransactionService().GetByEmTrId(token);
if (emailTran != null)
{
emailTran.EmTrSendDate = DateTime.Now;
emailTran.EmTrSendSuccess = true;
new EmailTransactionService().Save(emailTran);
}
} } public Attachment AddAttachment(byte[] attachment, string fileName)
{
try
{
MemoryStream ms = new MemoryStream(attachment);
string extension = Path.GetExtension(fileName); ContentType contentType = null; if (!String.IsNullOrEmpty(extension))
{
switch (extension.ToLower())
{
case ".zip":
contentType = new ContentType("application/x-zip-compressed"); break;
case ".pdf":
contentType = new ContentType("application/pdf"); break;
case ".doc":
contentType = new ContentType("application/msword"); break;
case ".docx":
contentType = new ContentType("application/msword"); break;
case ".xls":
contentType = new ContentType("application/x-excel"); break;
case ".xlsx":
contentType = new ContentType("application/x-excel"); break;
case ".txt":
contentType = new ContentType("text/plain"); break;
case ".html":
contentType = new ContentType("text/html"); break;
case ".htm":
contentType = new ContentType("text/html"); break;
default:
contentType = new ContentType("application/x-zip-compressed"); break;
}
}
else
{
contentType = new ContentType("application/x-zip-compressed");
}
Attachment atth = new Attachment(ms, contentType);
atth.Name = fileName;
atth.NameEncoding = Encoding.UTF8;
//atth.TransferEncoding = TransferEncoding.SevenBit; return atth;
}
catch (Exception ex)
{
throw ex;
}
}
}
}
zip 压缩:要添加ICSharpCode.SharpZipLib.dll
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.Checksums;
using System.IO; namespace MvcModelApp.Common
{
public class ZipUtility
{
public static int Zip(string zipFileName, List<string> srcFiles, string password)
{
ZipOutputStream zipStream = null;
FileStream streamWriter = null;
string fileName;
int count = ; try
{
if (srcFiles == null) return count;
//Use Crc32
Crc32 crc32 = new Crc32(); //Create Zip File
zipStream = new ZipOutputStream(File.Create(zipFileName)); //Specify Level
zipStream.SetLevel(Convert.ToInt32()); //Specify Password
if (password != null && password.Trim().Length > )
{
zipStream.Password = password;
} //Foreach File
foreach (string file in srcFiles)
{
//Read the file to stream
streamWriter = File.OpenRead(file);
byte[] buffer = new byte[streamWriter.Length];
streamWriter.Read(buffer, , buffer.Length);
streamWriter.Close(); //Specify ZipEntry
crc32.Reset();
crc32.Update(buffer);
fileName = file.Substring(file.LastIndexOf('\\') + );
ZipEntry zipEntry = new ZipEntry(fileName);
zipEntry.DateTime = DateTime.Now;
zipEntry.Size = buffer.Length;
zipEntry.Crc = crc32.Value; //Put file info into zip stream
zipStream.PutNextEntry(zipEntry); //Put file data into zip stream
zipStream.Write(buffer, , buffer.Length); count++;
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
//Clear Resource
if (streamWriter != null)
{
streamWriter.Close();
}
if (zipStream != null)
{
zipStream.Finish();
zipStream.Close();
}
} return count;
} public static List<string> Unzip(string destFolder, string srcZipFile, string password)
{
List<string> fileList = new List<string>();
ZipInputStream zipStream = null;
ZipEntry zipEntry = null;
FileStream streamWriter = null;
int count = ;
int bufferSize = ; try
{
zipStream = new ZipInputStream(File.OpenRead(srcZipFile));
zipStream.Password = password; while ((zipEntry = zipStream.GetNextEntry()) != null)
{
string zipFileDirectory = Path.GetDirectoryName(zipEntry.Name);
string destFileDirectory = Path.Combine(destFolder, zipFileDirectory);
if (!Directory.Exists(destFileDirectory))
{
Directory.CreateDirectory(destFileDirectory);
} string fileName = Path.GetFileName(zipEntry.Name);
if (fileName.Length > )
{
string destFilePath = Path.Combine(destFileDirectory, fileName); streamWriter = File.Create(destFilePath);
int size = bufferSize;
byte[] data = new byte[bufferSize];
long extractCount = ;
while (true)
{
size = zipStream.Read(data, , data.Length);
if (size > )
{
streamWriter.Write(data, , size);
}
else
{
break;
}
extractCount += size;
} streamWriter.Flush();
streamWriter.Close();
fileList.Add(fileName);
count++; }
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (zipStream != null)
{
zipStream.Close();
} if (streamWriter != null)
{
streamWriter.Close();
}
} return fileList;
}
}
}
NPOI,导出Execl,压缩文件zip,发送Email的更多相关文章
- C# NPOI 导出Execl 工具类
NPOI 导出Execl 自己单独工具类 详见代码 using System; using System.Collections.Generic; using System.Linq; using S ...
- 【转载】在linux下别用zip 用tar来压缩文件 zip解压后还是utf-8 window10是GBK
3.2 使用 unzip 命令解压缩 zip 文件 将 shiyanlou.zip 解压到当前目录: $ unzip shiyanlou.zip 使用安静模式,将文件解压到指定目录: $ un ...
- asp.net NPOI导出xlsx格式文件,打开文件报“Excel 已完成文件级验证和修复。此工作簿的某些部分可能已被修复或丢弃”
NPOI导出xlsx格式文件,会出现如下情况: 点击“是”: 导出代码如下: /// <summary> /// 将datatable数据写入excel并下载 /// </summa ...
- java上传图片到数据库,涉及压缩文件zip/rar上传等
项目中有这个需求: 1)上传文件通过公司平台的校验,校验成功后,通过接口,返回文件流: 2)我们根据这个文件流进行操作.这里,先将文件流复制文件到项目临时目录WEB-INF/temp;文件使用完毕,删 ...
- php 压缩文件 zip
<?php class PHPZip { private $ctrl_dir = array(); private $datasec = ...
- tp 内置压缩文件zip
一.解压缩zip文件 $zip = new ZipArchive;//新建一个ZipArchive的对象 /* 通过ZipArchive的对象处理zip文件 $zip->open这个方法的参数表 ...
- CentOS 打包压缩文件 zip 命令详解
我们再linux中常见的压缩文件有.tar.gz,.zip,.gz,在linux中,你要习惯没有.rar的日子. 一下为tar,zip命令详解 tar -zcvf /home/files.tar.gz ...
- 一个NPOI导出到excel文件的范例记录
'使用NPOI写入新创建的excel文件,导出文件: Private Sub Sub_WriteXls() Dim XlsBook As XSSFWorkbook Dim XlsSheet As XS ...
- php压缩文件zip格式并打包(单个或多个文件压缩)
最近接到一个需求,就是选择多个文件下载时,不要一个一个下载,直接把多个文件打包成一个文件进行下载.我们项目是前后端分离,所以我写了个接口,让前端传参数,后台下载. 废话不多说,直接上代码: 先是压缩单 ...
随机推荐
- servlet类常用代码
1.设置响应编码格式 response.setContentType(");
- Js 类继承 extends
html 及 js 代码 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&q ...
- [蓝桥杯2017初赛]k倍区间 前缀和
题目描述 给定一个长度为N的数列,A1, A2, ... AN. 如果其中一段连续的子序列Ai, Ai+1, ... Aj(i <= j)之和是K的倍数,我们就称这个区间[i, j]是K倍区间. ...
- 零基础入门深度学习(6) - 长短时记忆网络(LSTM)
代码: def forward(self, x): ''' 根据式1-式6进行前向计算 ''' self.times += 1 # 遗忘门 fg = self.calc_gate(x, self.Wf ...
- Python安装numpy,pandas慢,超时报错,下载不了的解决方法
由于python的默认源是国外的,所以下载的时候会很慢,甚至会出现超时下载失败,提供两个解决方法 1.设置pip的超时限制 打开cmd 输入pip --default-timeout=100 inst ...
- 「AT2381 [AGC015C] Nuske vs Phantom Thnook」
题目大意 给出一个01矩阵,这个矩阵有一个特殊的性质: 对于任意两个 \(1\) 之间最多只有 \(1\) 条由 \(1\) 构成的路径.每次询问给出一个矩形范围,查询在这个范围内的联通快个数. 分析 ...
- LVS负载均衡软件使用及(LVS简介、三种工作模式、十种调度算法)
一.LVS简介 LVS(Linux Virtual Server)即Linux虚拟服务器,目前LVS已经被集成到Linux内核模块中.该项目在Linux内核中实现了基于IP的数据请求负载均衡调度方案, ...
- 「JSOI2010」挖宝藏
「JSOI2010」挖宝藏 传送门 由于题目中说道挖一个位置的前提是挖掉它上面的三个,以此类推可以发现,挖掉一个点就需要挖掉这个点往上的整个倒三角,那么也就会映射到 \(x\) 轴上的一段区间(可以发 ...
- k8spod的介绍
yaml介绍 apiVersion: v1 APIserver 的版本 kind: Pod 资源类型 metadata: 元数据定义 name: pod-demo 元数据资源名字 labels: 定义 ...
- 【剑指Offer面试编程题】题目1356:孩子们的游戏(圆圈中最后剩下的数)--九度OJ
题目描述: 每年六一儿童节,JOBDU都会准备一些小礼物去看望孤儿院的小朋友,今年亦是如此.HF作为JOBDU的资深元老,自然也准备了一些小游戏.其中,有个游戏是这样的:首先,让小朋友们围成一个大圈. ...