RefCellObjInfo[] GetRefCellObjInfos(CELLRecord cell) { var refCellObjInfos = new RefCellObjInfo[cell.RefObjs.Length]; for (var i = 0; i < cell.RefObjs.Length; i++) { var refObjInfo = new RefCellObjInfo { RefObj = cell.RefObjs[i] }; // Get the record the RefObjDataGroup references. var refObj = (CELLRecord.RefObj)refObjInfo.RefObj; _data.objectsByIDString.TryGetValue(refObj.Name, out refObjInfo.ReferencedRecord); if (refObjInfo.ReferencedRecord != null) { var modelFileName = RecordUtils.GetModelFileName(refObjInfo.ReferencedRecord); // If the model file name is valid, store the model file path. if (!string.IsNullOrEmpty(modelFileName)) { refObjInfo.ModelFilePath = modelFileName; } } refCellObjInfos[i] = refObjInfo; } return(refCellObjInfos); }
/// <summary> convert numbers to our secret format /// </summary> /// <param name="fileName"></param> private static String Encode(String numStr, StorageAttribute attr, String picStr) { PIC pic = new PIC(picStr, attr, 0); NUM_TYPE num_type = new NUM_TYPE(numStr, pic, 0); String encoded_num = num_type.toXMLrecord(); encoded_num = Base64.encode(RecordUtils.byteStreamToString(encoded_num), ClientManager.Instance.getEnvironment().GetEncoding()); return(XmlParser.escape(encoded_num)); }
/// <summary> /// /// </summary> /// <param name="resType"></param> /// <returns></returns> internal ExpressionEvaluator.ExpVal evaluate(StorageAttribute resType) { ExpressionEvaluator.ExpVal expVal = null; String retVal; bool isNull = false; if (computedByClient()) { expVal = ExpressionEvaluator.eval(_expBytes, resType, _task); } else { RunTimeEvent rtEvt = ClientManager.Instance.EventsManager.getLastRtEvent(); Task mprgCreator = null; if (rtEvt != null) { mprgCreator = rtEvt.getMainPrgCreator(); } // create a new command object only when necessary if (resType != _prevResType) { _cmdToServer = CommandFactory.CreateEvaluateCommand(_task.getTaskTag(), resType, _id, 0, mprgCreator); } ClientManager.Instance.execRequestWithSubformRecordCycle(_cmdsToServer, _cmdToServer, this, _task); if (resType != StorageAttribute.BLOB && resType != StorageAttribute.BLOB_VECTOR) { retVal = _resultValue; } else if (_resultValue != null && _resultValue.Equals(" ")) { retVal = ""; } else { retVal = RecordUtils.byteStreamToString(_resultValue); } if (retVal == null) { isNull = true; } // If we don't know what result type we got, and want to keep it, as in ExpCalc if (resType == StorageAttribute.NONE) { resType = _type; } expVal = new ExpressionEvaluator.ExpVal(resType, isNull, retVal); } _prevResType = resType; return(expVal); }
/// <summary> /// Execute AddLocateCommand /// </summary> /// <param name="exp"></param> public override void Execute(rt.IResultValue res) { MGDataCollection mgDataTab = MGDataCollection.Instance; Task task = (Task)mgDataTab.GetTaskByID(TaskTag); FieldDef fieldDef = task.DataView.getField((int)UserRange.veeIdx - 1); int parsedLen; AddUserLocateDataViewCommand command = CommandFactory.CreateAddUserLocateDataviewCommand(TaskTag, UserRange); if (!UserRange.nullMin) { command.Range.min = RecordUtils.deSerializeItemVal(UserRange.min, fieldDef.getType(), fieldDef.getSize(), true, fieldDef.getType(), out parsedLen); } if (!UserRange.nullMax) { command.Range.max = RecordUtils.deSerializeItemVal(UserRange.max, fieldDef.getType(), fieldDef.getSize(), true, fieldDef.getType(), out parsedLen); } task.DataviewManager.Execute(command); }
/// <summary> /// code to be used when RangeAdd is called on the server, with a local data field /// </summary> private void ExecuteAddRangeCommand() { MGDataTable mgDataTab = MGDataTable.Instance; Task task = (Task)mgDataTab.GetTaskByID(TaskTag); FieldDef fieldDef = task.DataView.getField((int)UserRange.veeIdx - 1); int parsedLen; AddUserRangeDataviewCommand command = CommandFactory.CreateAddUserRangeDataviewCommand(TaskTag, UserRange); command.Range = UserRange; if (!UserRange.nullMin) { command.Range.min = RecordUtils.deSerializeItemVal(UserRange.min, fieldDef.getType(), fieldDef.getSize(), true, fieldDef.getType(), out parsedLen); } if (!UserRange.nullMax) { command.Range.max = RecordUtils.deSerializeItemVal(UserRange.max, fieldDef.getType(), fieldDef.getSize(), true, fieldDef.getType(), out parsedLen); } task.DataviewManager.Execute(command); }
public RawWhoisSection Parse(IEnumerable <string> lines, string keyValueDelimitator = ":") { if (lines == null) { throw new ArgumentException("lines should not be null"); } var records = new Dictionary <string, StringBuilder>(StringComparer.OrdinalIgnoreCase); HashSet <string> localFieldNamesSet = new HashSet <string>(); List <string> localFieldNamesList = new List <string>(); string currentFieldName = null; string skipPartsOverrideType = null; // Will store the first key found in the record string firstKey = null; // Will store the first value of the first key found in the record // If the value of the first key actually spans multiple lines, // this variable will only contain the first line of the value string firstKeyValue = null; foreach (var line in lines) { // Afrinic contains an invalid line like: DUMMY for 5490 // TODO: Remove this if if (!string.IsNullOrWhiteSpace(line) && !line.StartsWith("dummy for ", StringComparison.OrdinalIgnoreCase) && !line.StartsWith("#") && !line.StartsWith("%")) { // StringSplitOptions.None means leep empty records var parts = line.Split(new string[] { keyValueDelimitator }, StringSplitOptions.None); /* * If skipParts > 0 we need to remove one or more fields before we continue. * We do this for RWhois records. For these types of records we set skipParts to 1 * to ignore the first field (network field below). Example: * * network:Class-Name:network * network:ID:NET-207-115-64-0-19 * network:Auth-Area:207.115.64.0/19 */ if (this.skipParts > 0 && parts.Length >= this.skipParts) { if (skipPartsOverrideType == null) { skipPartsOverrideType = parts[0]; } else if (skipPartsOverrideType != parts[0]) { // TODO: Log when the record type suddenly changes } var newParts = new string[parts.Length - this.skipParts]; Array.Copy(parts, this.skipParts, newParts, 0, newParts.Length); parts = newParts; } if (parts.Length >= 2) { // If there are at least two parts it means we can parse both a key and a value var key = parts[0].Trim(); var value = string.Join(keyValueDelimitator, parts, 1, parts.Length - 1).Trim(); if (key.Length > 0) { currentFieldName = key; this.AddToRecord(records: records, fieldName: currentFieldName, newValueLine: value); if (firstKey == null) { firstKey = key; firstKeyValue = value; } if (!localFieldNamesSet.Contains(key)) { localFieldNamesSet.Add(key); localFieldNamesList.Add(key); } } //// TODO: else log } else if (parts.Length == 1) { if (currentFieldName != null) { // If there is at least one part var value = parts[0]; this.AddToRecord(records: records, fieldName: currentFieldName, newValueLine: value); } //// TODO: else log } //// TODO: else log } //// TODO: else log } string sectionType = null; string sectionId = null; if (skipPartsOverrideType != null) { sectionType = skipPartsOverrideType; // If the records do not contain a Class-Name but this is a RWhois record // where the type is the first column, then create a Class-Name record if (!records.ContainsKey("Class-Name")) { // TODO: Log records["Class-Name"] = new StringBuilder(skipPartsOverrideType); } } // Try to locate the Class-Name and ID, wherever they are in the records var extractedClassName = RecordUtils.FindValueForKey(records, "Class-Name"); var extractedId = RecordUtils.FindFirstValueForKeys(records, new List <string>() { "ID" }); if (sectionType == null && extractedClassName != null) { sectionType = extractedClassName; } if (sectionId == null && extractedId != null) { sectionId = extractedId; } // We could not extract the type yet, so we will go looking for the value in the first // record of the section if (sectionType == null && firstKey != null) { sectionType = firstKey; } //// TODO: else log // We could not extract the ID yet, so we will go looking for the key in the first // record of the section if (sectionId == null && firstKeyValue != null) { sectionId = firstKeyValue; } //// TODO: else log if (!string.IsNullOrWhiteSpace(sectionType) && !string.IsNullOrWhiteSpace(sectionId) && records.Count > 0) { HashSet <string> globalFieldNamesSet; List <string> globalFieldNamesList; if (!this.TypeToFieldNamesSet.TryGetValue(sectionType, out globalFieldNamesSet)) { globalFieldNamesSet = new HashSet <string>(); this.TypeToFieldNamesSet.Add(sectionType, globalFieldNamesSet); } if (!this.TypeToFieldNamesList.TryGetValue(sectionType, out globalFieldNamesList)) { globalFieldNamesList = new List <string>(); this.TypeToFieldNamesList.Add(sectionType, globalFieldNamesList); } foreach (var fieldName in localFieldNamesSet) { if (!globalFieldNamesSet.Contains(fieldName)) { globalFieldNamesSet.Add(fieldName); globalFieldNamesList.Add(fieldName); } } return(new RawWhoisSection(sectionType, sectionId, records)); } //// TODO: else log return(null); }
/// <summary> /// evaluate the expression and return the result /// </summary> /// <param name = "resType">is the expected type </param> /// <param name = "length">of expected Alpha string </param> /// <returns> evaluated value or null if value evaluated to null (by ExpressionEvaluator) </returns> internal String evaluate(StorageAttribute resType, int length) { ExpressionEvaluator.ExpVal expVal = null; String retVal = null; if (computedByClient()) { expVal = ExpressionEvaluator.eval(_expBytes, resType, _task); ConvertExpValForDotNet(expVal); if (expVal.IsNull) { // even if actual dotnet obj is null, we need to return blobPrefix if (expVal.Attr == StorageAttribute.DOTNET) { retVal = expVal.ToMgVal(); } else { retVal = null; } } else if (resType == StorageAttribute.BLOB_VECTOR && expVal.Attr == StorageAttribute.BLOB) { if (VectorType.validateBlobContents(expVal.StrVal)) { retVal = expVal.ToMgVal(); } else { retVal = null; } } else if (expVal.Attr == StorageAttribute.BLOB_VECTOR && resType != StorageAttribute.BLOB_VECTOR && resType != StorageAttribute.BLOB) { retVal = null; } else { retVal = expVal.ToMgVal(); } } else { RunTimeEvent rtEvt = ClientManager.Instance.EventsManager.getLastRtEvent(); Task mprgCreator = null; if (rtEvt != null) { mprgCreator = rtEvt.getMainPrgCreator(); } // create a new command object only when necessary if (resType != _prevResType) { _cmdToServer = CommandFactory.CreateEvaluateCommand(_task.getTaskTag(), resType, _id, length, mprgCreator); } ClientManager.Instance.execRequestWithSubformRecordCycle(_cmdsToServer, _cmdToServer, this, _task); if (resType != StorageAttribute.BLOB && resType != StorageAttribute.BLOB_VECTOR) { retVal = _resultValue; } else if (_resultValue != null && _resultValue.Equals(" ")) { retVal = ""; } else { retVal = RecordUtils.byteStreamToString(_resultValue); } } _prevResType = resType; return(retVal); }
/// <summary> /// Fill the fields data. /// </summary> /// <param name="fldValInBytes"></param> /// <param name="recFlags"></param> /// <param name="isCurrRec"></param> protected override void fillFieldsData(byte[] fldValInBytes, String recFlags) { Object val = null; String tmp = null; int parsedLen = 0; int i, j, from, size; StorageAttribute currType; bool useHex; FieldDef fld = null; bool valueNotPassed; from = getFromFldIdx(false); size = getSizeFld(false); int destinationFieldIndex = 0; for (i = from, j = 0; j < size; i++, j++) { fld = getFieldsTab().getField(i); currType = fld.getType(); useHex = (ClientManager.Instance.getEnvironment().GetDebugLevel() > 1 || currType == StorageAttribute.ALPHA || currType == StorageAttribute.UNICODE || StorageAttributeCheck.isTypeLogical(currType)); // Qcr #940443 : Old fashion flags are still being used by resident table. So check them 1st coz we might get exception otherwise. // The flags for resident are very simple, only 2 options. '.' = false, '/' = true. // We keep using it for resident, since in the server side we do not know if we are creating the xml for richclient or for BC at the creation stage. // Since we couldn't create different flags for rich, we will use the old flags here. if ((byte)(recFlags[j]) == '.') { _flags[i] = 0; } else if ((byte)(recFlags[j]) == '/') { _flags[i] = 1; } else // New flags style. For the view. { // Each flag will appear in the xml in 2 chars representing hex value ("42" for 0x42). tmp = recFlags.Substring(j * 2, 2); _flags[i] = Convert.ToByte(tmp, 16); } // save the ind that the value was not passed from the server. valueNotPassed = (FLAG_VALUE_NOT_PASSED == (byte)(_flags[i] & FLAG_VALUE_NOT_PASSED)); _flags[i] = (byte)(_flags[i] & ~FLAG_VALUE_NOT_PASSED); _flagsHistory[i] = _flags[i]; if (valueNotPassed) { if (FLAG_NULL == (byte)(_flags[i] & FLAG_NULL)) { // null ind is on, just put any value in the field. val = fld.getDefaultValue(); } else { // copy the existing value from the existing curr rec. val = ((Record)_dataview.getCurrRec()).GetFieldValue(i); } } else { DBField dbField = destinationColumnList[destinationFieldIndex++]; val = RecordUtils.deSerializeItemVal(fldValInBytes, (StorageAttribute)dbField.Attr, dbField.Length, dbField.Storage, ref parsedLen); } _fieldsData[i] = val; } setInitialFldVals(false, false); }