public AnnotationDefaultAttribute Parse(Stream attributeDataStream, uint attributeDataLength, ClassReaderState readerState, AttributeScope scope) { return(new AnnotationDefaultAttribute { Value = ElementValue.Parse(attributeDataStream, readerState) }); }
public static ListValue PartList(this IShipconstruct vessel, string partType, SharedObjects sharedObj) { var list = new ListValue(); var partList = vessel.Parts.ToList(); switch (partType.ToUpper()) { case "RESOURCES": list = ResourceValue.PartsToList(partList); break; case "PARTS": list = PartValue.PartsToList(partList, sharedObj); break; case "ENGINES": list = EngineValue.PartsToList(partList, sharedObj); break; case "SENSORS": list = SensorValue.PartsToList(partList, sharedObj); break; case "ELEMENTS": list = ElementValue.PartsToList(partList); break; case "DOCKINGPORTS": list = DockingPortValue.PartsToList(partList, sharedObj); break; } return(list); }
/// <summary> /// Parses method annotations to fill up information /// </summary> /// <param name="readerState">Class reader state</param> internal void Parse(ClassReaderState readerState) { Signature = (GetAttribute(PredefinedAttributeNames.Signature)?.ParsedAttribute as SignatureAttribute)?.Value; { var attribute = GetAttribute(PredefinedAttributeNames.Code); if (attribute?.ParsedAttribute is CodeAttribute codeAttribute) { InstructionListConverter.ParseCodeAttribute(this, readerState, codeAttribute); } } { var attribute = GetAttribute(PredefinedAttributeNames.RuntimeInvisibleAnnotations); if (attribute != null) { InvisibleAnnotations = (attribute.ParsedAttribute as RuntimeInvisibleAnnotationsAttribute)?.Annotations; } } { var attribute = GetAttribute(PredefinedAttributeNames.RuntimeVisibleAnnotations); if (attribute != null) { VisibleAnnotations = (attribute.ParsedAttribute as RuntimeVisibleAnnotationsAttribute)?.Annotations; } } { var attribute = GetAttribute(PredefinedAttributeNames.Exceptions); if (attribute != null) { Throws = (attribute.ParsedAttribute as ExceptionsAttribute)?.ExceptionTable; } } AnnotationDefaultValue = (GetAttribute(PredefinedAttributeNames.AnnotationDefault)?.ParsedAttribute as AnnotationDefaultAttribute)?.Value; IsDeprecated = GetAttribute(PredefinedAttributeNames.Deprecated)?.ParsedAttribute != null; }
public ActionResult DeleteConfirmed(int id) { ElementValue elementValue = db.ElementValues.Find(id); db.ElementValues.Remove(elementValue); db.SaveChanges(); return(RedirectToAction("Index")); }
private bool AddUpdate(GeoArea geoArea, EquationYear equationYear, string userId, string[] elementValuesKeys) { var calculate = true; string values = ""; var elementIds = new List <int>(); foreach (string evs in elementValuesKeys) { string eeId = evs.Replace("ElementValue_", ""); EquationElement equationElement = db.EquationElements.Find(int.Parse(eeId)); if (equationElement == null) { throw new Exception("Equation Element Not Found"); } string strValue = Request[evs].Trim(); double _fValue = 0; double?fValue = null; if (string.IsNullOrEmpty(strValue) || double.TryParse(strValue, out _fValue)) { if (!string.IsNullOrEmpty(strValue)) { fValue = _fValue; } else { calculate = false; } values += string.Format("{0} : {1}\r\n", equationElement.Element.Name, strValue); var createdAt = DateTime.Now; var elementValue = new ElementValue() { EquationElementID = equationElement.ID, EquationYearID = equationYear.ID, GeoAreaID = geoArea.ID, Value = fValue, ApplicationUserID = userId, CreatedAt = createdAt, }; db.ElementValues.Add(elementValue); elementIds.Add(equationElement.ElementID); } else { throw new Exception("Value is in correct"); } } if (calculate) { var elementYearValues = db.ElementYearValues.Where(x => x.GeoAreaID == geoArea.ID && x.Year == equationYear.Year && elementIds.Contains(x.ElementID)).ToList(); foreach (var eyv in elementYearValues) { eyv.IsCommited = true; db.Entry(eyv).State = EntityState.Modified; } } return(calculate); }
public void FriendlyName() { RegistryHive hive = RegistryHive.Create(new MemoryStream()); Store s = Store.Initialize(hive.Root); BcdObject obj = s.CreateInherit(InheritType.AnyObject); Element el = obj.AddElement(WellKnownElement.LibraryApplicationPath, ElementValue.ForString(@"a\path\to\nowhere")); Assert.Equal("{path}", el.FriendlyName); }
public void RemoveElement() { RegistryHive hive = RegistryHive.Create(new MemoryStream()); Store s = Store.Initialize(hive.Root); BcdObject obj = s.CreateInherit(InheritType.AnyObject); obj.AddElement(WellKnownElement.LibraryApplicationPath, ElementValue.ForString(@"\a\path\to\nowhere")); obj.RemoveElement(WellKnownElement.LibraryApplicationPath); Assert.False(obj.HasElement(WellKnownElement.LibraryApplicationPath)); }
public ActionResult Edit([Bind(Include = "DEVID,DataElementValue,FKEVDataElementID,FKEVServiceID")] ElementValue elementValue) { if (ModelState.IsValid) { db.Entry(elementValue).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FKEVDataElementID = new SelectList(db.DataElements, "DEID", "DataElement1", elementValue.FKEVDataElementID); return(View(elementValue)); }
public void BooleanValue() { RegistryHive hive = RegistryHive.Create(new MemoryStream()); Store s = Store.Initialize(hive.Root); BcdObject obj = s.CreateInherit(InheritType.AnyObject); Element el = obj.AddElement(WellKnownElement.LibraryAutoRecoveryEnabled, ElementValue.ForBoolean(true)); el = obj.GetElement(WellKnownElement.LibraryAutoRecoveryEnabled); Assert.Equal(true.ToString(), el.Value.ToString()); }
public static new ArrayElementValue Read(BinaryReader Reader, ConstantPool Pool) { ushort Length = Reader.ReadUInt16BE(); ElementValue[] Values = new ElementValue[Length]; for (int i = 0; i < Length; i++) { Values[i] = ElementValue.Read(Reader, Pool); } return(new ArrayElementValue(Values)); }
public void IntegerListValue() { RegistryHive hive = RegistryHive.Create(new MemoryStream()); Store s = Store.Initialize(hive.Root); BcdObject obj = s.CreateInherit(InheritType.AnyObject); Element el = obj.AddElement(WellKnownElement.LibraryBadMemoryList, ElementValue.ForIntegerList(new long[] { 1234, 4132 })); el = obj.GetElement(WellKnownElement.LibraryBadMemoryList); Assert.NotNull(el.Value.ToString()); Assert.NotEmpty(el.Value.ToString()); }
public void DeviceValue_BootDevice() { RegistryHive hive = RegistryHive.Create(new MemoryStream()); Store s = Store.Initialize(hive.Root); BcdObject obj = s.CreateInherit(InheritType.AnyObject); Element el = obj.AddElement(WellKnownElement.LibraryApplicationDevice, ElementValue.ForBootDevice()); el = obj.GetElement(WellKnownElement.LibraryApplicationDevice); Assert.NotNull(el.Value.ToString()); Assert.NotEmpty(el.Value.ToString()); }
public void GuidValue() { Guid testGuid = Guid.NewGuid(); RegistryHive hive = RegistryHive.Create(new MemoryStream()); Store s = Store.Initialize(hive.Root); BcdObject obj = s.CreateInherit(InheritType.AnyObject); Element el = obj.AddElement(WellKnownElement.BootMgrDefaultObject, ElementValue.ForGuid(testGuid)); el = obj.GetElement(WellKnownElement.BootMgrDefaultObject); Assert.Equal(testGuid.ToString("B"), el.Value.ToString()); }
// GET: ElementValues/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ElementValue elementValue = db.ElementValues.Find(id); if (elementValue == null) { return(HttpNotFound()); } return(View(elementValue)); }
internal static TypeAnnotationNode Parse(Stream stream, ClassReaderState readerState, AttributeScope scope) { var typeAnnotation = new TypeAnnotationNode { TargetType = (TargetType)stream.ReadByteFully() }; typeAnnotation.Target = typeAnnotation.TargetType switch { TargetType.GenericClassOrInterfaceDeclaration when scope == AttributeScope.Class => (TypeAnnotationTarget) new TypeParameterTarget(), TargetType.GenericMethodOrConstructorDeclaration when scope == AttributeScope.Method => new TypeParameterTarget(), TargetType.ExtendsOrImplements when scope == AttributeScope.Class => new SupertypeTarget(), TargetType.TypeInBoundInGenericClassOrInterface when scope == AttributeScope.Class => new TypeParameterBoundTarget(), TargetType.TypeInBoundInGenericMethodOrConstructor when scope == AttributeScope.Method => new TypeParameterBoundTarget(), TargetType.FieldDeclaration when scope == AttributeScope.Field => new EmptyTarget(), TargetType.ReturnTypeOrNewObject when scope == AttributeScope.Method => new EmptyTarget(), TargetType.ReceiverTypeOfMethodOrConstructor when scope == AttributeScope.Method => new EmptyTarget(), TargetType.TypeInFormalParameterOfMethodOrConstructorOrLambda when scope == AttributeScope.Method => new FormalParameterTarget(), TargetType.ThrowsClause when scope == AttributeScope.Method => new ThrowsTarget(), TargetType.LocalVariableDeclaration when scope == AttributeScope.Code => new LocalvarTarget(), TargetType.ResourceVariableDeclaration when scope == AttributeScope.Code => new LocalvarTarget(), TargetType.ExceptionParameterDeclaration when scope == AttributeScope.Code => new CatchTarget(), TargetType.InstanceOfExpression when scope == AttributeScope.Code => new OffsetTarget(), TargetType.NewExpression when scope == AttributeScope.Code => new OffsetTarget(), TargetType.MethodReferenceExpressionNew when scope == AttributeScope.Code => new OffsetTarget(), TargetType.MethodReferenceExpressionIdentifier when scope == AttributeScope.Code => new OffsetTarget(), TargetType.CastExpression when scope == AttributeScope.Code => new TypeArgumentTarget(), TargetType.ArgumentForGenericConstructorInvocation when scope == AttributeScope.Code => new TypeArgumentTarget(), TargetType.ArgumentForGenericMethodInvocation when scope == AttributeScope.Code => new TypeArgumentTarget(), TargetType.ArgumentForGenericMethodReferenceExpressionNew when scope == AttributeScope.Code => new TypeArgumentTarget(), TargetType.ArgumentForGenericMethodReferenceExpressionIdentifier when scope == AttributeScope.Code => new TypeArgumentTarget(), _ => throw new ArgumentOutOfRangeException(nameof(TargetType)) }; typeAnnotation.Target.Read(stream, readerState); typeAnnotation.TypePath = new TypePath(); typeAnnotation.TypePath.Read(stream, readerState); var elementValuePairsCount = Binary.BigEndian.ReadUInt16(stream); typeAnnotation.ElementValuePairs.Capacity = elementValuePairsCount; for (var i = 0; i < elementValuePairsCount; i++) { typeAnnotation.ElementValuePairs.Add(new ElementValuePair { ElementName = readerState.ConstantPool .GetEntry <Utf8Entry>(Binary.BigEndian.ReadUInt16(stream)).String, Value = ElementValue.Parse(stream, readerState) }); } return(typeAnnotation); }
public void GuidListValue() { Guid testGuid1 = Guid.NewGuid(); Guid testGuid2 = Guid.NewGuid(); RegistryHive hive = RegistryHive.Create(new MemoryStream()); Store s = Store.Initialize(hive.Root); BcdObject obj = s.CreateInherit(InheritType.AnyObject); Element el = obj.AddElement(WellKnownElement.BootMgrDisplayOrder, ElementValue.ForGuidList(new Guid[] { testGuid1, testGuid2 })); el = obj.GetElement(WellKnownElement.BootMgrDisplayOrder); Assert.Equal(testGuid1.ToString("B") + "," + testGuid2.ToString("B"), el.Value.ToString()); }
// GET: ElementValues/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ElementValue elementValue = db.ElementValues.Find(id); if (elementValue == null) { return(HttpNotFound()); } ViewBag.FKEVDataElementID = new SelectList(db.DataElements, "DEID", "DataElement1", elementValue.FKEVDataElementID); return(View(elementValue)); }
/// <summary> /// Execute the element by accepting the index of execution. /// index of execution may differ on IndexInParentSequence. /// </summary> /// <param name="executionIndex">The real calling index.</param> /// <returns></returns> public QsValue Execute(int executionIndex) { if (ElementValue.GetType() == typeof(Func <int, QsValue>)) { return(((Func <int, QsValue>)ElementValue)(executionIndex)); } else if (ElementValue.GetType() == typeof(QsSequence)) { QsSequence seq = (QsSequence)ElementValue; return((QsValue)seq.GetElementValue(executionIndex)); } else { return((QsValue)ElementValue); } }
/// <summary> /// Read an element_value (4.7.16.1) /// </summary> private ElementValue ReadElementValue(ConstantPool cp) { var tag = (char)stream.ReadU1(); switch (tag) { case 'B': case 'C': case 'D': case 'F': case 'I': case 'J': case 'S': case 'Z': case 's': return(new ConstElementValue(cp, tag, stream.ReadU2())); case 'e': { var typeNameIndex = stream.ReadU2(); var constNameIndex = stream.ReadU2(); return(new EnumConstElementValue(cp, typeNameIndex, constNameIndex)); } case 'c': return(new ClassElementValue(cp, stream.ReadU2())); case '@': return(new AnnotationElementValue(ReadAnnotation(cp))); case '[': { var numValues = stream.ReadU2(); var values = new ElementValue[numValues]; for (var i = 0; i < numValues; i++) { values[i] = ReadElementValue(cp); } return(new ArrayElementValue(values)); } default: throw new Dot42Exception(string.Format("Unknown element_value tag '{0}'", tag)); } }
public static Annotation Read(BinaryReader Reader, ConstantPool Pool) { Annotation Result = new Annotation(); Result.Type = ((Constants.Utf8)Pool[Reader.ReadUInt16BE()]).Value; ushort KeyValueCount = Reader.ReadUInt16BE(); while (KeyValueCount-- > 0) { string Key = ((Constants.Utf8)Pool[Reader.ReadUInt16BE()]).Value; ElementValue Value = ElementValue.Read(Reader, Pool); if (Value != null) { Result.ValuePairs.Add(Key, Value); } } return(Result); }
public void DeviceValue_Mbr() { SparseMemoryStream ms = new SparseMemoryStream(); ms.SetLength(80 * 1024 * 1024); BiosPartitionTable pt = BiosPartitionTable.Initialize(ms, Geometry.FromCapacity(ms.Length)); pt.Create(WellKnownPartitionType.WindowsNtfs, true); VolumeManager volMgr = new VolumeManager(ms); RegistryHive hive = RegistryHive.Create(new MemoryStream()); Store s = Store.Initialize(hive.Root); BcdObject obj = s.CreateInherit(InheritType.AnyObject); Element el = obj.AddElement(WellKnownElement.LibraryApplicationDevice, ElementValue.ForDevice(Guid.Empty, volMgr.GetPhysicalVolumes()[0])); el = obj.GetElement(WellKnownElement.LibraryApplicationDevice); Assert.NotNull(el.Value.ToString()); Assert.NotEmpty(el.Value.ToString()); }
/// <summary> /// Default ctor /// </summary> public AnnotationDefaultAttribute(ElementValue defaultValue) { this.defaultValue = defaultValue; }
public void IntegerValue() { RegistryHive hive = RegistryHive.Create(new MemoryStream()); Store s = Store.Initialize(hive.Root); BcdObject obj = s.CreateInherit(InheritType.AnyObject); Element el = obj.AddElement(WellKnownElement.LibraryTruncatePhysicalMemory, ElementValue.ForInteger(1234)); el = obj.GetElement(WellKnownElement.LibraryTruncatePhysicalMemory); Assert.Equal("1234", el.Value.ToString()); }
/// <summary> /// Default ctor /// </summary> internal ElementValuePair(ConstantPool cp, int elementNameIndex, ElementValue value) { this.cp = cp; this.elementNameIndex = elementNameIndex; this.value = value; }
public override string ToString() { return(ElementValue.ToString()); }
private void cleanOPCReaderValues(DateTime oDateNow, int nMinute, int nLine) { string sPathFilename = Program.FOLDER_DESTINY + Program.FILE_EXCEL_TOKEN_NAME + "DayExcelL" + nLine + "_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + "_" + oDateNow.Hour.ToString().PadLeft(2, '0') + "00_A_Hour_Hourly.xls"; string sPathFilenameCopy = Program.FOLDER_DESTINY_COPY + Program.FILE_EXCEL_TOKEN_NAME + "DayExcelL" + nLine + "_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + "_" + oDateNow.Hour.ToString().PadLeft(2, '0') + "00_A_Hour_Hourly.xls"; if (File.Exists(sPathFilename)) { Microsoft.Office.Interop.Excel.Application oExcelApplication = new Microsoft.Office.Interop.Excel.Application(); oExcelApplication.Visible = false; Microsoft.Office.Interop.Excel.Workbooks oExcelWorkBooks = oExcelApplication.Workbooks; Microsoft.Office.Interop.Excel.Workbook oExcelWorkBook = oExcelWorkBooks.Open(sPathFilename); for (int i = 1; i <= Program.nNumElements; i++) { if ((Program.bShowLog) && (Program.bShowVerboseLog)) { Program.writeLineInLogFile(Program.oLogFile, "{OK} Volcando datos al Fichero Excel del contaminante " + i.ToString() + " la línea " + nLine + " {" + Program.oBeforeElementsValues[i - 1].getDirtyValue().ToString() + ", " + Program.oBeforeElementsValues[i - 1].getRealValue().ToString() + ", " + Program.oBeforeElementsValues[i - 1].getType() + "}", false); } ElementValue oElementValue = new ElementValue(Program.oBeforeElementsValues[i - 1].getDirtyValue(), Program.oBeforeElementsValues[i - 1].getRealValue(), Program.oBeforeElementsValues[i - 1].getType(), Program.oBeforeElementsValues[i - 1].getQAL2Min(), Program.oBeforeElementsValues[i - 1].getQAL2Max(), Program.oBeforeElementsValues[i - 1].getQAL2A(), Program.oBeforeElementsValues[i - 1].getQAL2B()); Microsoft.Office.Interop.Excel.Worksheet oWorkSheet = oExcelWorkBook.Worksheets[(i + 1)]; flushMinuteValue(oWorkSheet, oDateNow, nMinute, oElementValue, (i - 1)); oElementValue = null; nullExcelObject(oWorkSheet); if ((Program.bShowLog) && (Program.bShowVerboseLog)) { Program.writeLineInLogFile(Program.oLogFile, "{OK} Datos volcados al Fichero Excel del contaminante " + i.ToString() + " de la línea " + nLine + " de forma correcta", false); } } try { oExcelWorkBook.Save(); Program.writeLineInLogFile(Program.oLogFile, "{OK} Datos salvados al Fichero Excel de la línea " + nLine + " de forma correcta", false); if (nMinute == 59) { if (File.Exists(sPathFilenameCopy)) { File.Delete(sPathFilenameCopy); } oExcelWorkBook.SaveAs(sPathFilenameCopy, XlFileFormat.xlExcel5); if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{OK} Copia del Fichero Excel de la línea " + nLine + " realizada correctamente", false); } } } catch (Exception) { if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{ERROR} Error salvando los datos del Fichero Excel de la línea " + nLine, false); } } oExcelWorkBook.Close(false); nullExcelObject(oExcelWorkBook); oExcelWorkBooks.Close(); nullExcelObject(oExcelWorkBooks); oExcelApplication.Application.Quit(); nullExcelObject(oExcelApplication); killExcelProcesses(); FileFormatXEAC oFileFormatXEAC = new FileFormatXEAC(); if (oFileFormatXEAC.convertExcelFile(Program.FILE_EXCEL_TOKEN_NAME + "DayExcelL" + nLine + "_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + "_" + oDateNow.Hour.ToString().PadLeft(2, '0') + "00_A_Hour_Hourly.xls", (nMinute + 1))) { if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{OK} Fichero Excel convertido al formato de la XEAC", false); } } oFileFormatXEAC = null; FileFormatXEACReports oFileFormatXEACReports = new FileFormatXEACReports(); if (oFileFormatXEACReports.convertExcelFile(Program.FILE_EXCEL_TOKEN_NAME + "DayExcelL" + nLine + "_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + "_" + oDateNow.Hour.ToString().PadLeft(2, '0') + "00_A_Hour_Hourly.xls", (nMinute + 1))) { if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{OK} Fichero Excel convertido al formato de la XEAC - Reports", false); } } oFileFormatXEACReports = null; } }
private void timerHandler(object source, ElapsedEventArgs e) { DateTime oDateNow = DateTime.Now; int nMinute = oDateNow.Minute; lock (oThreadLockResource) { Microsoft.Office.Interop.Excel.Application oExcelApplication = null; Microsoft.Office.Interop.Excel.Workbook oExcelWorkBook = null; HashSet <TagItem> oHashSetTagsValues = null; try { try { if (nMinute == 0) { string sLogFile = Program.FOLDER_FILE_LOG + "EmissionsExcel_log_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + ".txt"; if (!File.Exists(sLogFile)) { if (Program.bShowLog) { if (Program.oLogFile != null) { Program.oLogFile.Flush(); Program.oLogFile.Close(); } Program.oLogFile = File.AppendText(sLogFile); DateTime oDateTimeBefore = oDateNow.AddDays(-1); string sLogFileBefore = Program.FOLDER_FILE_LOG + "EmissionsExcel_log_" + oDateTimeBefore.Year.ToString() + oDateTimeBefore.Month.ToString().PadLeft(2, '0') + oDateTimeBefore.Day.ToString().PadLeft(2, '0') + ".txt"; if (File.Exists(sLogFileBefore)) { File.Move(sLogFileBefore, Program.FOLDER_FILE_LOG_HISTORY + "EmissionsExcel_log_" + oDateTimeBefore.Year.ToString() + oDateTimeBefore.Month.ToString().PadLeft(2, '0') + oDateTimeBefore.Day.ToString().PadLeft(2, '0') + ".txt"); } } } } } catch (Exception) { } if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{TIMERHANDLER_START:OK} Llamada al evento {timerHandler} al segundo " + oDateNow.Second, true); } if (nMinute != Program.nLastMinute) { Program.nLastMinute = nMinute; if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{OK} Creando valores de los contaminantes sobre el minuto " + oDateNow.Minute, false); } for (int nLine = 1; nLine <= Program.nNumLines; nLine++) { string sPathFilename = Program.FOLDER_DESTINY + Program.FILE_EXCEL_TOKEN_NAME + "DayExcelL" + nLine + "_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + "_" + oDateNow.Hour.ToString().PadLeft(2, '0') + "00_A_Hour_Hourly.xls"; if ((!File.Exists(sPathFilename)) || ((File.Exists(sPathFilename)) && (nMinute == 0))) { if ((File.Exists(sPathFilename)) && (nMinute == 0)) { File.Delete(sPathFilename); } oExcelApplication = new Microsoft.Office.Interop.Excel.Application(); oExcelApplication.Visible = false; Microsoft.Office.Interop.Excel.Workbooks oExcelWorkBooks = oExcelApplication.Workbooks; oExcelWorkBook = oExcelWorkBooks.Add(); createSheets(oExcelApplication, oDateNow); removeDefaultSheets(oExcelApplication); oExcelWorkBook.SaveAs(sPathFilename, XlFileFormat.xlExcel5); oExcelWorkBook.Close(false); nullExcelObject(oExcelWorkBook); oExcelWorkBooks.Close(); nullExcelObject(oExcelWorkBooks); oExcelApplication.Application.Quit(); nullExcelObject(oExcelApplication); killExcelProcesses(); } } oHashSetTagsValues = TryExecuteSyncRead(Program.nTimeoutOPCRead); if ((oHashSetTagsValues != null) && (oHashSetTagsValues.Count == (((Program.nNumElements * 9) + 2) * Program.nNumLines))) { DateTime oDateNowCurrent = DateTime.Now; if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{OK} Se han devuelto todos los valores del OPC de forma correcta sobre el minuto " + oDateNow.Minute + " a la hora: " + oDateNowCurrent.Hour + "h " + oDateNowCurrent.Minute + "m " + oDateNowCurrent.Second + "s", false); } for (int nLine = 1; nLine <= Program.nNumLines; nLine++) { if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{OK} Creando valores de los contaminantes de la Línea " + nLine + " sobre el minuto " + oDateNow.Minute, false); } Array oArrayTagsValues = oHashSetTagsValues.ToArray <TagItem>(); string sPathFilename = Program.FOLDER_DESTINY + Program.FILE_EXCEL_TOKEN_NAME + "DayExcelL" + nLine + "_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + "_" + oDateNow.Hour.ToString().PadLeft(2, '0') + "00_A_Hour_Hourly.xls"; string sPathFilenameCopy = Program.FOLDER_DESTINY_COPY + Program.FILE_EXCEL_TOKEN_NAME + "DayExcelL" + nLine + "_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + "_" + oDateNow.Hour.ToString().PadLeft(2, '0') + "00_A_Hour_Hourly.xls"; if (File.Exists(sPathFilename)) { oExcelApplication = new Microsoft.Office.Interop.Excel.Application(); oExcelApplication.Visible = false; Microsoft.Office.Interop.Excel.Workbooks oExcelWorkBooks = oExcelApplication.Workbooks; oExcelWorkBook = oExcelWorkBooks.Open(sPathFilename); if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{OK} Fichero Excel de la línea " + nLine + " abierto correctamente", false); } TagItem oTagItem1, oTagItem2, oTagItem3, oTagItem4, oTagItem5, oTagItem6, oTagItem7, oTagItem8, oTagItem9, oTagItem10, oTagItem11; for (int i = 1; i <= Program.nNumElements; i++) { string sStatus = "V"; int nIndexBase = (((Program.nNumElements * 9) + 2) * (nLine - 1)) + ((i - 1) * 9) + 2; oTagItem1 = (TagItem)oArrayTagsValues.GetValue((((Program.nNumElements * 9) + 2) * (nLine - 1))); oTagItem2 = (TagItem)oArrayTagsValues.GetValue((((Program.nNumElements * 9) + 2) * (nLine - 1)) + 1); oTagItem3 = (TagItem)oArrayTagsValues.GetValue(nIndexBase); oTagItem4 = (TagItem)oArrayTagsValues.GetValue(nIndexBase + 1); oTagItem5 = (TagItem)oArrayTagsValues.GetValue(nIndexBase + 2); oTagItem6 = (TagItem)oArrayTagsValues.GetValue(nIndexBase + 3); oTagItem7 = (TagItem)oArrayTagsValues.GetValue(nIndexBase + 4); oTagItem8 = (TagItem)oArrayTagsValues.GetValue(nIndexBase + 5); oTagItem9 = (TagItem)oArrayTagsValues.GetValue(nIndexBase + 6); oTagItem10 = (TagItem)oArrayTagsValues.GetValue(nIndexBase + 7); oTagItem11 = (TagItem)oArrayTagsValues.GetValue(nIndexBase + 8); if (oTagItem1.getValue() == "1") { sStatus = "A"; } else if (oTagItem2.getValue() == "1") { sStatus = "P"; } else if (oTagItem5.getValue() == "1") { sStatus = "V"; } else if (oTagItem6.getValue() == "1") { sStatus = "C"; } else if (oTagItem7.getValue() == "1") { sStatus = "N"; } if ((Program.bShowLog) && (Program.bShowVerboseLog)) { Program.writeLineInLogFile(Program.oLogFile, "{OK} Volcando datos al Fichero Excel del contaminante " + i.ToString() + " de la línea " + nLine + " {" + oTagItem3.getName().ToString() + ":" + oTagItem3.getValue().ToString() + ", " + oTagItem4.getName().ToString() + ":" + oTagItem4.getValue().ToString() + ", Status: " + sStatus + "}", false); } ElementValue oElementValue = new ElementValue(oTagItem3.getValue(), oTagItem4.getValue(), sStatus, oTagItem8.getValue(), oTagItem9.getValue(), oTagItem10.getValue(), oTagItem11.getValue()); Microsoft.Office.Interop.Excel.Worksheet oWorkSheet = oExcelWorkBook.Worksheets[(i + 1)]; flushMinuteValue(oWorkSheet, oDateNow, nMinute, oElementValue, (i - 1)); oElementValue = null; oTagItem1 = null; oTagItem2 = null; oTagItem3 = null; oTagItem4 = null; oTagItem5 = null; oTagItem6 = null; oTagItem7 = null; oTagItem8 = null; oTagItem9 = null; oTagItem10 = null; oTagItem11 = null; nullExcelObject(oWorkSheet); if ((Program.bShowLog) && (Program.bShowVerboseLog)) { Program.writeLineInLogFile(Program.oLogFile, "{OK} Datos volcados al Fichero Excel del contaminante " + i.ToString() + " de la línea " + nLine + " de forma correcta", false); } } try { oExcelWorkBook.Save(); Program.writeLineInLogFile(Program.oLogFile, "{OK} Datos salvados al Fichero Excel de la línea " + nLine + " de forma correcta", false); if (nMinute == 59) { if (File.Exists(sPathFilenameCopy)) { File.Delete(sPathFilenameCopy); } oExcelWorkBook.SaveAs(sPathFilenameCopy, XlFileFormat.xlExcel5); if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{OK} Copia del Fichero Excel de la línea " + nLine + " realizada correctamente", false); } } } catch (Exception) { if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{ERROR} Error salvando los datos del Fichero Excel de la línea " + nLine, false); } } oExcelWorkBook.Close(false); nullExcelObject(oExcelWorkBook); oExcelWorkBooks.Close(); nullExcelObject(oExcelWorkBooks); oExcelApplication.Application.Quit(); nullExcelObject(oExcelApplication); killExcelProcesses(); FileFormatXEAC oFileFormatXEAC = new FileFormatXEAC(); if (oFileFormatXEAC.convertExcelFile(Program.FILE_EXCEL_TOKEN_NAME + "DayExcelL" + nLine + "_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + "_" + oDateNow.Hour.ToString().PadLeft(2, '0') + "00_A_Hour_Hourly.xls", (nMinute + 1))) { if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{OK} Fichero Excel convertido al formato de la XEAC", false); } } oFileFormatXEAC = null; FileFormatXEACReports oFileFormatXEACReports = new FileFormatXEACReports(); if (oFileFormatXEACReports.convertExcelFile(Program.FILE_EXCEL_TOKEN_NAME + "DayExcelL" + nLine + "_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + "_" + oDateNow.Hour.ToString().PadLeft(2, '0') + "00_A_Hour_Hourly.xls", (nMinute + 1))) { if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{OK} Fichero Excel convertido al formato de la XEAC - Reports", false); } } oFileFormatXEACReports = null; } else { if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{ERROR} No existe el Fichero Excel de la Línea " + nLine, false); } } oArrayTagsValues = null; } } else { if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{WARNING} No se han devuelto todos los valores del OPC sobre el evento {timerHandler}", false); } killExcelProcesses(); if (Program.sMethod == "BEST_EFFORT") { if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{WARNING} Creando valores anteriores de los contaminantes sobre el minuto " + oDateNow.Minute, false); } } else { if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{WARNING} Creando líneas vacias de los contaminantes sobre el minuto " + oDateNow.Minute, false); } } for (int nLine = 1; nLine <= Program.nNumLines; nLine++) { if (Program.sMethod == "BEST_EFFORT") { cleanOPCReaderValues(oDateNow, nMinute, nLine); } else { flushEmptyMinute(oDateNow, nMinute, nLine); } } if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{WARNING} Fin de la creación de valores anteriores de los contaminantes", false); } } } } catch (Exception err) { if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{EXCEPTION} Se ha producido una excepción sobre el evento {timerHandler:" + err.ToString() + "}", false); } killExcelProcesses(); if (Program.sMethod == "BEST_EFFORT") { if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{EXCEPTION} Creando valores anteriores de los contaminantes sobre el minuto " + oDateNow.Minute, false); } } else { if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{EXCEPTION} Creando líneas vacias de los contaminantes sobre el minuto " + oDateNow.Minute, false); } } for (int nLine = 1; nLine <= Program.nNumLines; nLine++) { if (Program.sMethod == "BEST_EFFORT") { cleanOPCReaderValues(oDateNow, nMinute, nLine); } else { flushEmptyMinute(oDateNow, nMinute, nLine); } } if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{EXCEPTION} Fin de la creación de valores anteriores de los contaminantes", false); } } // Clean memory oHashSetTagsValues = null; GC.Collect(); GC.WaitForPendingFinalizers(); if (Program.bShowLog) { Program.writeLineInLogFile(Program.oLogFile, "{TIMERHANDLER_END:OK} Fin de la llamada al evento {timerHandler}", false); } } }
protected override void ReadExtends(ClassData classData, ConstantPool constantPool) { this.DefaultValue = new ElementValue().Read(classData); }
public void AddElement_WrongType() { RegistryHive hive = RegistryHive.Create(new MemoryStream()); Store s = Store.Initialize(hive.Root); BcdObject obj = s.CreateInherit(InheritType.AnyObject); Assert.Throws <ArgumentException>(() => obj.AddElement(WellKnownElement.LibraryApplicationDevice, ElementValue.ForString(@"\a\path\to\nowhere"))); }
private void flushMinuteValue(Microsoft.Office.Interop.Excel.Worksheet oExcelWorkSheet, DateTime oDate, int nMinute, ElementValue nElement, int nIndex) { int nRowStart = 4; Program.oBeforeElementsValues[nIndex].setDirtyValue(nElement.getDirtyValue()); Program.oBeforeElementsValues[nIndex].setRealValue(nElement.getRealValue()); Program.oBeforeElementsValues[nIndex].setType(nElement.getType()); Program.oBeforeElementsValues[nIndex].setQAL2Min(nElement.getQAL2Min()); Program.oBeforeElementsValues[nIndex].setQAL2Max(nElement.getQAL2Max()); Program.oBeforeElementsValues[nIndex].setQAL2A(nElement.getQAL2A()); Program.oBeforeElementsValues[nIndex].setQAL2B(nElement.getQAL2B()); oExcelWorkSheet.Cells[(nMinute + nRowStart + 1).ToString(), "A"] = "'" + oDate.Day.ToString().PadLeft(2, '0') + "/" + oDate.Month.ToString().PadLeft(2, '0') + "/" + oDate.Year + " " + oDate.Hour.ToString().PadLeft(2, '0') + ":" + nMinute.ToString().PadLeft(2, '0') + ":00"; oExcelWorkSheet.Cells[(nMinute + nRowStart + 1).ToString(), "B"] = nElement.getDirtyValue().Replace(',', '.'); oExcelWorkSheet.Cells[(nMinute + nRowStart + 1).ToString(), "C"] = nElement.getRealValue().Replace(',', '.'); oExcelWorkSheet.Cells[(nMinute + nRowStart + 1).ToString(), "D"] = "'" + nElement.getType(); oExcelWorkSheet.Cells[(nMinute + nRowStart + 1).ToString(), "E"] = nElement.getQAL2Min().Replace(',', '.'); oExcelWorkSheet.Cells[(nMinute + nRowStart + 1).ToString(), "F"] = nElement.getQAL2Max().Replace(',', '.'); oExcelWorkSheet.Cells[(nMinute + nRowStart + 1).ToString(), "G"] = nElement.getQAL2A().Replace(',', '.'); oExcelWorkSheet.Cells[(nMinute + nRowStart + 1).ToString(), "H"] = nElement.getQAL2B().Replace(',', '.'); nullExcelObject(oExcelWorkSheet); }
/// <summary> /// Default ctor /// </summary> public AnnotationDefaultAttribute(ElementValue defaultValue) { this.defaultValue = defaultValue; }
/// <summary> /// Read an element_value (4.7.16.1) /// </summary> private ElementValue ReadElementValue(ConstantPool cp) { var tag = (char) stream.ReadU1(); switch (tag) { case 'B': case 'C': case 'D': case 'F': case 'I': case 'J': case 'S': case 'Z': case 's': return new ConstElementValue(cp, tag, stream.ReadU2()); case 'e': { var typeNameIndex = stream.ReadU2(); var constNameIndex = stream.ReadU2(); return new EnumConstElementValue(cp, typeNameIndex, constNameIndex); } case 'c': return new ClassElementValue(cp, stream.ReadU2()); case '@': return new AnnotationElementValue(ReadAnnotation(cp)); case '[': { var numValues = stream.ReadU2(); var values = new ElementValue[numValues]; for (var i = 0; i < numValues; i++) { values[i] = ReadElementValue(cp); } return new ArrayElementValue(values); } default: throw new Dot42Exception(string.Format("Unknown element_value tag '{0}'", tag)); } }
private static ElementValue ReadElementValue(EndianBinaryReader reader, List<CompileConstant> constants) { var value = new ElementValue(); value.Tag = reader.ReadByte(); switch ((char)value.Tag) { case 'B': case 'C': case 'D': case 'F': case 'I': case 'J': case 'S': case 'Z': case 's': value.ConstValueIndex = reader.ReadInt16(); break; case 'e': value.TypeNameIndex = reader.ReadInt16(); value.ConstNameIndex = reader.ReadInt16(); break; case 'c': value.ClassInfoIndex = reader.ReadInt16(); break; case '@': value.AnnotationValue = ReadAnnotation(reader, constants); break; case '[': short valueCount = reader.ReadInt16(); for (int i = 0; i < valueCount; i++) { value.Values.Add(ReadElementValue(reader, constants)); } break; } return value; }
private static void WriteElementValue(ElementValue value, EndianBinaryWriter writer) { switch ((char)value.Tag) { case 'B': case 'C': case 'D': case 'F': case 'I': case 'J': case 'S': case 'Z': case 's': writer.Write(value.ConstValueIndex); break; case 'e': writer.Write(value.TypeNameIndex); writer.Write(value.ConstNameIndex); break; case 'c': writer.Write(value.ClassInfoIndex); break; case '@': WriteAnnotation(value.AnnotationValue, writer); break; case '[': writer.Write((short)value.Values.Count()); foreach (ElementValue ev in value.Values) { WriteElementValue(ev, writer); } break; } }