protected void Page_Load(object sender, EventArgs e) { if (String.IsNullOrEmpty(ClassName)) { throw new ArgumentException("ClassName"); } if (!IsPostBack) { MetaClass mc = MetaDataWrapper.GetMetaClassByName(ClassName); // Tree BindTree(); // Default Values ItemText.Text = CHelper.GetResFileString(mc.PluralName); // Style Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), Guid.NewGuid().ToString(), String.Format("<link type='text/css' rel='stylesheet' href='{0}' />", ResolveClientUrl("~/Styles/Shell/mainLeftTemplate.css"))); // Header MainHeader.AddLink( CHelper.GetIconText(CHelper.GetResFileString("{IbnFramework.ListInfo:tClose}"), ResolveClientUrl("~/layouts/images/cancel.gif")), "javascript:window.close();"); // Buttons PublishButton.Attributes.Add("onclick", "DisableButtons(this);"); PublishButton.Style.Add(HtmlTextWriterStyle.Width, "150px;"); CloseButton.Attributes.Add("onclick", "window.close();"); CloseButton.Style.Add(HtmlTextWriterStyle.Width, "150px;"); } }
private void BindToolbar() { MainHeader.Title = GetGlobalResourceObject("IbnFramework.Profile", "PageCustomization").ToString(); string link = string.Empty; if (String.IsNullOrEmpty(ClassName)) { link = ResolveClientUrl("~/Apps/Administration/Pages/PortalCustomization.aspx?Tab=PageCustomization"); } else if (String.Compare(ClassName, CustomizationProfileEntity.ClassName, true) == 0) { link = String.Format(CultureInfo.InvariantCulture, "{0}?ClassName={1}&ObjectId={2}&Tab=PageCustomization", ResolveClientUrl("~/Apps/MetaUIEntity/Pages/EntityView.aspx"), ClassName, ObjectId); } string text = CHelper.GetIconText(GetGlobalResourceObject("IbnFramework.Common", "Back").ToString(), ResolveClientUrl("~/Images/IbnFramework/cancel.GIF")); if (!String.IsNullOrEmpty(link)) { MainHeader.AddLink(text, link); } }
/// <summary> /// 读取SPC文件头 /// </summary> /// <param name="fileData">文件数据</param> /// <returns>SPCHeader结构</returns> private static MainHeader GetMainHeader(byte[] fileData) { try { IntPtr retptr = IntPtr.Zero; if (CommonMethod.Is64BitVersion()) { retptr = FossGetMainHeader64(fileData, fileData.Length); } else { retptr = FossGetMainHeader32(fileData, fileData.Length); } bool retOK; MainHeader retheader = CommonMethod.CopyStructureFromIntptrAndFree <MainHeader>(ref retptr, out retOK); if (!retOK) { retheader.fileMark = UInt16.MaxValue; //表示错误数据 ErrorString = CommonMethod.ErrorString; } return(retheader); } catch (Exception ex) { ErrorString = ex.Message; MainHeader retheader = new MainHeader(); retheader.fileMark = UInt16.MaxValue; //表示错误数据 return(retheader); } }
private void BindToolbar() { MainHeader.Title = GetGlobalResourceObject("IbnFramework.BusinessProcess", "WorkflowSchema").ToString(); string link = GetOwnerLink(); string text = CHelper.GetIconText(GetGlobalResourceObject("IbnFramework.Common", "Back").ToString(), ResolveClientUrl("~/Images/IbnFramework/cancel.GIF")); if (!String.IsNullOrEmpty(link)) { MainHeader.AddLink(text, link); } }
private void BindToolbar() { if (template == null) { MainHeader.Title = GetGlobalResourceObject("IbnFramework.BusinessProcess", "NewTemplate").ToString(); } else { MainHeader.Title = GetGlobalResourceObject("IbnFramework.BusinessProcess", "TemplateEditing").ToString(); } string link = CHelper.GetLinkEntityList(WorkflowDefinitionEntity.ClassName); string text = CHelper.GetIconText(GetGlobalResourceObject("IbnFramework.Common", "Back").ToString(), ResolveClientUrl("~/Images/IbnFramework/cancel.GIF")); if (!String.IsNullOrEmpty(link)) { MainHeader.AddLink(text, link); } }
private Color GetColor(SprakExpression item) { return(item switch { Block block => GetColor(block.Header), Command _ => Colors.Blue, FunctionCall _ => Colors.Orange, FunctionHeader _ => Colors.Blue, IfHeader _ => Colors.DarkRed, LiteralArrayGet _ => Colors.Yellow, LiteralGet _ => Colors.Yellow, LoopHeader _ => Colors.Red, MainHeader _ => Colors.Orange, OperatorCall _ => Colors.Green, Return _ => Colors.Blue, VariableAssignment _ => Colors.Orange, VariableReference _ => Colors.Yellow, _ => Colors.Black });
public async Task <ActionResult> Edit([Bind(Include = "Id,Title,Photo")] MainHeader header) { MainHeader headerDb = db.MainHeader.First(); if (header.Photo != null) { if (!header.Photo.IsImage()) { ModelState.AddModelError("Photo", "Photo is not valid"); return(View(header)); } RemoveImage(headerDb.Image, "~/Assets/img"); headerDb.Image = header.Photo.SaveImage("e-commerce", "~/Assets/img"); } headerDb.Title = header.Title; await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
/// <summary> /// 读取文件中组分列表 /// <param name="fileData">文件内容</param> /// </summary> public static string[] GetComponentName(byte[] fileData) { MainHeader mainheader = GetMainHeader(fileData); if (mainheader.fileMark == UInt16.MaxValue) //读取文件头错误 { return(null); } string[] retData = new string[mainheader.componentCount]; byte[] nameArray = new byte[CompNameLength]; //组分名称最长0x10 for (int i = 0; i < mainheader.componentCount; i++) { Array.Copy(mainheader.components, i * CompNameLength, nameArray, 0, CompNameLength); retData[i] = CommonMethod.CovertByteArrayToString(nameArray, Encoding.Default); } return(retData); }
private void BindInfo() { if (CustomPageId == PrimaryKeyId.Empty) { MainHeader.Title = GetGlobalResourceObject("IbnFramework.Profile", "NewPage").ToString(); } else { MainHeader.Title = GetGlobalResourceObject("IbnFramework.Profile", "PageEditing").ToString(); } string text = CHelper.GetIconText(GetGlobalResourceObject("IbnFramework.Common", "Back").ToString(), ResolveClientUrl("~/Images/IbnFramework/cancel.GIF")); string link = ResolveClientUrl(GetLinkToList()); MainHeader.AddLink(text, link); SaveButton.CustomImage = ResolveUrl("~/layouts/images/saveitem.gif"); SaveButton.Text = GetGlobalResourceObject("IbnFramework.Global", "_mc_Save").ToString(); CancelButton.Text = GetGlobalResourceObject("IbnFramework.Global", "_mc_Cancel").ToString(); }
private void BindToolbar() { if (ObjectId != PrimaryKeyId.Empty) { MainHeader.Title = GetGlobalResourceObject("IbnFramework.BusinessProcess", "BusinessProcessEditing").ToString(); } else if (FromId != PrimaryKeyId.Empty) { MainHeader.Title = GetGlobalResourceObject("IbnFramework.BusinessProcess", "BusinessProcessDuplication").ToString(); } else { MainHeader.Title = GetGlobalResourceObject("IbnFramework.BusinessProcess", "New").ToString(); } string link = GetOwnerLink(); string text = CHelper.GetIconText(GetGlobalResourceObject("IbnFramework.Common", "Back").ToString(), ResolveClientUrl("~/Images/IbnFramework/cancel.GIF")); if (!String.IsNullOrEmpty(link)) { MainHeader.AddLink(text, link); } }
/// <summary> /// 读取光谱文件 /// </summary> public static bool ReadFile(byte[] fileData, FileFormat fileFormat) { fileFormat.dataInfoList = null; fileFormat.acquisitionInfo = null; fileFormat.xDataList = null; fileFormat.fileInfo = null; fileFormat.yDataList = null; MainHeader mainheader = GetMainHeader(fileData); if (mainheader.fileMark == UInt16.MaxValue) //读取文件头错误 { return(false); } //填充光谱文件信息 fileFormat.fileInfo = new FileFormat.FileInfo(); fileFormat.fileInfo.createTime = CreateFileDateTime(mainheader.fileTime); fileFormat.fileInfo.dataCount = (int)mainheader.specCols; fileFormat.fileInfo.fileMemo = CommonMethod.CovertByteArrayToString(mainheader.tile, Encoding.Default); //仪器描述 仪器名称-序列号 fileFormat.fileInfo.instDescription = CommonMethod.CovertByteArrayToString(mainheader.instrument, Encoding.Default) + instSerialSeprator + CommonMethod.CovertByteArrayToString(mainheader.serialNo, Encoding.Default); fileFormat.fileInfo.modifyFlag = 0; fileFormat.fileInfo.resolution = 16; //固定值 fileFormat.fileInfo.specType = FileFormat.SPECTYPE.SPCNIR; //固定值 fileFormat.fileInfo.xType = FileFormat.XAXISTYPE.XNMETR; //mainheader.xType = 1 fileFormat.fileInfo.zType = FileFormat.ZAXISTYPE.XMSEC; //固定值 fileFormat.fileInfo.fzinc = 0.5f; //固定值 fileFormat.fileInfo.fspare = new float[8]; //固定值 //读取X轴数据(肯定是均匀的X轴) fileFormat.xDataList = new List <double[]>(); double[] tempx = new double[mainheader.specCols]; int index = 0; for (int i = 0; i < mainheader.rangeCount; i++) //每个光谱段读取 { for (int j = 0; j < mainheader.rangeCols[i]; j++) { tempx[index] = mainheader.rangeFirstX[i] + j * mainheader.rangeStepX[i]; index++; } } fileFormat.xDataList.Add(tempx); //获取Y数据以及格式信息 fileFormat.dataInfoList = new List <FileFormat.DataInfo>(); fileFormat.yDataList = new List <double[]>(); for (int i = 0; i < mainheader.fileCount; i++) { FileHeader fileHeader = GetFileHeader(fileData, i); if (fileHeader.position == UInt16.MaxValue) { return(false); } //读取Y轴数据 double[] ydata = GetSpectrumData(fileData, i); if (ydata == null || ydata.Length == 0) { return(false); } fileFormat.yDataList.Add(ydata); //Y轴数据格式 FileFormat.DataInfo info = new FileFormat.DataInfo(); info.dataTitle = CommonMethod.CovertByteArrayToString(fileHeader.sampleNo, Encoding.Default); info.dataType = FileFormat.YAXISTYPE.YABSRB; info.firstX = mainheader.rangeFirstX[0]; info.lastX = mainheader.rangeLastX[mainheader.rangeCount - 1]; info.maxYValue = ydata.Max(); info.minYValue = ydata.Min(); fileFormat.dataInfoList.Add(info); } //读取光谱参数 fileFormat.acquisitionInfo = new FileFormat.AcquisitionInfo(); fileFormat.acquisitionInfo.GAIN = 0; fileFormat.acquisitionInfo.HIGHPASS = 0; fileFormat.acquisitionInfo.LOWPASS = 0; fileFormat.acquisitionInfo.LWN = 0; fileFormat.acquisitionInfo.SPEED = null; fileFormat.acquisitionInfo.SCANS = 0; fileFormat.acquisitionInfo.SCANSBG = 0; fileFormat.acquisitionInfo.IRMODE = FileFormat.enumIRMODE.NearIR; return(true); }
public static void unpackFile(string fileName) { Console.WriteLine("Unpacking " + fileName + "..."); FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); FileStream fileStream2; BinaryReader binaryReader = new BinaryReader(fileStream); MainHeader header = default(MainHeader); header.read(binaryReader); SubfileHeader[] files = new SubfileHeader[header.internalFileCount]; for (int i = 0; i < header.internalFileCount; ++i) { files[i].read(binaryReader); } fileStream.Seek(header.fileTableLocation, SeekOrigin.Begin); byte[] fileTable = binaryReader.ReadBytes(header.fileTableLength); Dictionary <int, string> dicttable = new Dictionary <int, string>(header.internalFileCount); int num = 0; string text = ""; for (int i = 0; i < fileTable.Length; ++i) { if (fileTable[i] == 0) { dicttable.Add(num, text); num = i + 1; text = ""; } else { text += (char)fileTable[i]; } } for (int i = 0; i < header.internalFileCount; ++i) { files[i].internalName = dicttable[files[i].fileNumber]; Console.WriteLine("\tOutput: " + files[i].internalName); fileStream.Seek(files[i].binLocation, SeekOrigin.Begin); byte[] array3 = binaryReader.ReadBytes(files[i].binLength); uint extraZeros = 0; try { while (binaryReader.ReadByte() == 0) { ++extraZeros; } } catch { // reached end of stream, stop here. } using (fileStream2 = new FileStream(files[i].internalName + ".bin", FileMode.Create, FileAccess.Write)) { fileStream2.Write(array3, 0, array3.Length); while (extraZeros > 0) { fileStream2.WriteByte(0); --extraZeros; } } fileStream.Seek(files[i].vltLocation, SeekOrigin.Begin); byte[] array4 = binaryReader.ReadBytes(files[i].vltLength); uint extraZerosTwo = 0; try { while (binaryReader.ReadByte() == 0) { ++extraZerosTwo; } } catch { // reached end of stream, stop here. } using (fileStream2 = new FileStream(files[i].internalName + ".vlt", FileMode.Create, FileAccess.Write)) { fileStream2.Write(array4, 0, array4.Length); while (extraZerosTwo > 0) { fileStream2.WriteByte(0); --extraZerosTwo; } } } FileInfo fileInfo = new FileInfo(fileName); string text2 = fileInfo.Name.Remove(fileInfo.Name.Length - fileInfo.Extension.Length, fileInfo.Extension.Length) + ".vls"; using (StreamWriter streamWriter = new StreamWriter(text2)) { foreach (SubfileHeader sh in files) { streamWriter.WriteLine(sh.internalName); } } // Store the VPAK header at the end of the .vls file! fileStream.Seek(0L, SeekOrigin.Begin); byte[] vpakHeaderData = binaryReader.ReadBytes(files[0].binLocation); using (fileStream2 = new FileStream(text2, FileMode.Append, FileAccess.Write)) { fileStream2.Write(vpakHeaderData, 0, vpakHeaderData.Length); } fileStream.Close(); }