本文整理汇总了C#中System.Image.Read方法的典型用法代码示例。如果您正苦于以下问题:C# Image.Read方法的具体用法?C# Image.Read怎么用?C# Image.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Image
的用法示例。
在下文中一共展示了Image.Read方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getPartLayout
public void getPartLayout(string imgName, string hdToGet, string newHDSize, string clientHD, string taskType)
{
Image image = new Image();
image.ID = image.GetImageID(imgName);
image.Read(image);
Image_Physical_Specs ips = new Image_Physical_Specs();
if (!string.IsNullOrEmpty(image.ClientSizeCustom))
ips = JsonConvert.DeserializeObject<Image_Physical_Specs>(image.ClientSizeCustom);
else
ips = JsonConvert.DeserializeObject<Image_Physical_Specs>(image.ClientSize);
int activeCounter = Convert.ToInt32(hdToGet);
int hdNumberToGet = Convert.ToInt32(hdToGet) - 1;
//Look for first active hd
if (ips.hd[hdNumberToGet].active != "1")
{
while (activeCounter <= ips.hd.Count())
{
if (ips.hd[activeCounter - 1].active == "1")
{
hdNumberToGet = activeCounter - 1;
}
activeCounter++;
}
}
newHDSize = (Convert.ToInt64(newHDSize) * .99).ToString("#");
int lbs_BYTE = Convert.ToInt32(ips.hd[hdNumberToGet].lbs);
long newHD_BYTES = Convert.ToInt64(newHDSize);
long newHD_BLK = Convert.ToInt64(newHDSize) / lbs_BYTE;
List<Partition_Resized_Client> listPhysicalAndExtended = new List<Partition_Resized_Client>();
List<Partition_Resized_Client> listLogical = new List<Partition_Resized_Client>();
List<Partition_Resized_Client_LVM> listLVM = new List<Partition_Resized_Client_LVM>();
string bootPart = null;
if(ips.hd[hdNumberToGet].boot.Length > 0)
bootPart = ips.hd[hdNumberToGet].boot.Substring(ips.hd[hdNumberToGet].boot.Length - 1, 1);
ExtendedPartition EP = image.CalculateMinSizeExtended(imgName,hdNumberToGet);
List<VolumeGroup> listVGS = new List<VolumeGroup>();
long agreedExtendedSize_BLK = 0;
double percentCounter = 0;
bool partLayoutVerified = false;
bool hasResizableVG = false;
int startPart = 0;
while (!partLayoutVerified)
{
double totalPercentage = 0;
listPhysicalAndExtended.Clear();
listLogical.Clear();
listVGS.Clear();
startPart = Convert.ToInt32(ips.hd[hdNumberToGet].partition[0].start);
int partCounter = 0;
hasResizableVG = false;
foreach (var part in ips.hd[hdNumberToGet].partition)
{
if (Convert.ToInt32(part.start) < startPart)
startPart = Convert.ToInt32(part.start);
if (part.active != "1")
continue;
if (part.type.ToLower() == "logical")
continue;
VolumeGroup VG = image.SinglePartMinSizeVG(imgName, hdNumberToGet, partCounter);
if (VG.pv != null)
{
part.resize = (VG.minSize_BLK * lbs_BYTE / 1024 / 1024).ToString();
hasResizableVG = true;
}
Partition_Resized_Client resizedPart = new Partition_Resized_Client();
if (bootPart == part.number)
resizedPart.isBoot = true;
else
resizedPart.isBoot = false;
resizedPart.number = part.number;
resizedPart.start = part.start;
resizedPart.type = part.type;
resizedPart.fsid = part.fsid;
resizedPart.uuid = part.uuid;
resizedPart.guid = part.guid;
resizedPart.fstype = part.fstype;
//If not resizable set aside a minimum size based off original partition length
long newPartSize_BLK = 0;
double tmpTotalPercentage = 0;
if (!string.IsNullOrEmpty(part.size_override))
{
newPartSize_BLK = Convert.ToInt64(part.size_override);
resizedPart.size = newPartSize_BLK.ToString();
tmpTotalPercentage = (double)newPartSize_BLK / newHD_BLK;
resizedPart.partResized = false;
if (resizedPart.type.ToLower() == "extended")
{
resizedPart.size = EP.minSize_BLK.ToString();
//.........这里部分代码省略.........
示例2: getOriginalLVM
public void getOriginalLVM(string imgName, string hdToGet, string clienthd)
{
Image image = new Image();
image.ID = image.GetImageID(imgName);
image.Read(image);
Image_Physical_Specs ips = new Image_Physical_Specs();
if (!string.IsNullOrEmpty(image.ClientSizeCustom))
ips = JsonConvert.DeserializeObject<Image_Physical_Specs>(image.ClientSizeCustom);
else
ips = JsonConvert.DeserializeObject<Image_Physical_Specs>(image.ClientSize);
int hdNumberToGet = Convert.ToInt32(hdToGet) - 1;
foreach (var part in ips.hd[hdNumberToGet].partition)
{
if (part.active != "1")
continue;
if (part.vg != null)
{
if (part.vg.lv != null)
{
HttpContext.Current.Response.Write("pvcreate -u " + part.uuid + " --norestorefile -yf " + clienthd+part.vg.pv[part.vg.pv.Length - 1] + "\r\n");
HttpContext.Current.Response.Write("vgcreate " + part.vg.name + " " + clienthd + part.vg.pv[part.vg.pv.Length - 1] + " -yf" + "\r\n");
HttpContext.Current.Response.Write("echo \"" + part.vg.uuid + "\" >>/tmp/vg-" +part.vg.name + "\r\n");
foreach (var lv in part.vg.lv)
{
if (lv.active == "1")
{
HttpContext.Current.Response.Write("lvcreate -L " + lv.size + "s -n " + lv.name + " " + lv.vg + "\r\n");
HttpContext.Current.Response.Write("echo \"" + lv.uuid + "\" >>/tmp/" + lv.vg + "-" + lv.name + "\r\n");
}
}
HttpContext.Current.Response.Write("vgcfgbackup -f /tmp/lvm-" + part.vg.name + "\r\n");
}
}
}
}
示例3: getHDParameter
public void getHDParameter(string imgName, string paramName, string hdToGet, string partNumber)
{
Image image = new Image();
image.ID = image.GetImageID(imgName);
image.Read(image);
Image_Physical_Specs ips = new Image_Physical_Specs();
if (!string.IsNullOrEmpty(image.ClientSizeCustom))
ips = JsonConvert.DeserializeObject<Image_Physical_Specs>(image.ClientSizeCustom);
else
ips = JsonConvert.DeserializeObject<Image_Physical_Specs>(image.ClientSize);
int activeCounter = Convert.ToInt32(hdToGet);
int hdNumberToGet = Convert.ToInt32(hdToGet) - 1;
//Look for first active hd
if (ips.hd[hdNumberToGet].active != "1")
{
while (activeCounter <= ips.hd.Count())
{
if (ips.hd[activeCounter - 1].active == "1")
{
hdNumberToGet = activeCounter - 1;
}
activeCounter++;
}
}
if (paramName == "uuid")
{
foreach (var partition in ips.hd[hdNumberToGet].partition)
if (partition.number == partNumber)
{
HttpContext.Current.Response.Write(partition.uuid);
break;
}
}
else if (paramName == "lvmswap")
{
foreach (var partition in ips.hd[hdNumberToGet].partition)
{
if (partition.vg != null)
{
if (partition.vg.lv != null)
{
foreach (var lv in partition.vg.lv)
{
if (lv.fstype.ToLower() == "swap" && lv.active == "1")
{
HttpContext.Current.Response.Write(lv.vg.Replace("-","--") + "-" + lv.name.Replace("-","--") + "," + lv.uuid);
break;
}
}
}
}
}
}
else if (paramName == "guid")
{
foreach (var partition in ips.hd[hdNumberToGet].partition)
if (partition.number == partNumber)
{
HttpContext.Current.Response.Write(partition.guid);
break;
}
}
else if (paramName == "table")
{
HttpContext.Current.Response.Write(ips.hd[hdNumberToGet].table);
}
else if (paramName == "partCount")
{
int activePartsCounter = 0;
foreach(var part in ips.hd[hdNumberToGet].partition)
{
if (part.active == "1")
activePartsCounter++;
}
HttpContext.Current.Response.Write(activePartsCounter.ToString());
}
else if (paramName == "activeParts")
{
Utility settings = new Utility();
string parts = null;
string imageFiles = null;
String[] partFiles = null;
string compExt = null;
foreach (var part in ips.hd[hdNumberToGet].partition)
{
if (part.active == "1")
{
if (hdNumberToGet == 0)
imageFiles = settings.GetSettings("Image Store Path") + imgName;
else
imageFiles = settings.GetSettings("Image Store Path") + imgName + Path.DirectorySeparatorChar + "hd" + (hdNumberToGet + 1).ToString();
try
{
// modified by cocoon^M
foreach (var ext in ImageExtensions)
{
//.........这里部分代码省略.........
示例4: getMinHDSize
public void getMinHDSize(string imgName, string hdToGet, string newHDSize)
{
Image image = new Image();
image.ID = image.GetImageID(imgName);
image.Read(image);
Image_Physical_Specs ips = new Image_Physical_Specs();
if (!string.IsNullOrEmpty(image.ClientSizeCustom))
{
ips = JsonConvert.DeserializeObject<Image_Physical_Specs>(image.ClientSizeCustom);
try
{
ips = JsonConvert.DeserializeObject<Image_Physical_Specs>(image.ClientSizeCustom);
}
catch { }
}
else
{
ips = JsonConvert.DeserializeObject<Image_Physical_Specs>(image.ClientSize);
try
{
ips = JsonConvert.DeserializeObject<Image_Physical_Specs>(image.ClientSize);
}
catch { }
}
if(ips.hd == null)
{
HttpContext.Current.Response.Write("compatibility,0");
return;
}
if (ips.hd.Count() < Convert.ToInt32(hdToGet))
{
HttpContext.Current.Response.Write("notexist,0");
return;
}
int activeCounter = Convert.ToInt32(hdToGet);
bool foundActive = false;
int hdNumberToGet = Convert.ToInt32(hdToGet) - 1;
//Look for first active hd
if (ips.hd[hdNumberToGet].active == "1")
{
foundActive = true;
}
else
{
while(activeCounter <= ips.hd.Count())
{
if(ips.hd[activeCounter -1 ].active == "1")
{
hdNumberToGet = activeCounter - 1;
foundActive = true;
break;
}
activeCounter++;
}
}
if(!foundActive)
{
HttpContext.Current.Response.Write("notactive,0");
return;
}
long minHDSizeRequired_BYTE = image.CalculateMinSizeHD(imgName, hdNumberToGet, newHDSize);
long newHD_BYTES = Convert.ToInt64(newHDSize);
if (minHDSizeRequired_BYTE > newHD_BYTES)
{
HttpContext.Current.Response.Write("false," + (hdNumberToGet + 1));
Logger.Log("Error: " + newHD_BYTES / 1024 / 1024 + " MB Is Less Than The Minimum Required HD Size For This Image(" + minHDSizeRequired_BYTE / 1024 / 1024 + " MB)");
}
else if(minHDSizeRequired_BYTE == newHD_BYTES)
{
HttpContext.Current.Response.Write("original,"+ (hdNumberToGet + 1));
}
else
HttpContext.Current.Response.Write("true," + (hdNumberToGet + 1));
}
示例5: imagesize
public void imagesize()
{
Utility utility = new Utility();
HttpContext postedContext = HttpContext.Current;
HttpFileCollection Files = postedContext.Request.Files;
string imagename = utility.Decode((string)postedContext.Request.Form["imgName"]);
string imagesize = utility.Decode((string)postedContext.Request.Form["imageSize"]);
try
{
using (NpgsqlConnection conn = new NpgsqlConnection(Utility.DBString))
{
NpgsqlCommand cmd = new NpgsqlCommand("images_updatesize", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new NpgsqlParameter("@imagename", imagename));
cmd.Parameters.Add(new NpgsqlParameter("@imagesize", imagesize));
conn.Open();
cmd.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Logger.Log(ex.ToString());
HttpContext.Current.Response.Write("false");
return;
}
//Validate image specifications were recorded successfully
Image image = new Image();
image.ID = image.GetImageID(imagename);
image.Read(image);
Image_Physical_Specs existingips = new Image_Physical_Specs();
try
{
existingips = JsonConvert.DeserializeObject<Image_Physical_Specs>(image.ClientSize);
}
catch(Exception ex)
{
Logger.Log(ex.ToString());
HttpContext.Current.Response.Write("false");
return;
}
if (existingips.hd == null)
{
HttpContext.Current.Response.Write("false");
return;
}
//Reset Custom Specs
image.UpdateSpecs(image.Name, "");
HttpContext.Current.Response.Write("true");
}