public GUIField(FieldValue value, Coords coord) { Value = value; Coords = coord; BackgroundColor = new SolidColorBrush(Colors.White); BackgroundColor.Opacity = 0.0; }
/// <summary> /// Constructor for ChoiceValues object. /// </summary> /// <param name="outField">field information used for validation.</param> public ChoiceValues(OutField outField) { OutField = outField; Choices = new ObservableCollection<FieldValue>(); DefaultValue = new FieldValue(null, OutField, true); CurrentValue = new FieldValue(null, OutField); }
public void Save_a_copy_of_a_record_when_no_history_record_exists() { var stringDef = new FieldDescriptorRef { ItemType = typeof(string), FieldName = "StringDef" }; var intDef = new FieldDescriptorRef { ItemType = typeof(int), FieldName = "IntDef" }; var fieldString = new FieldValue { FieldDescriptorRef = stringDef, Value = "1" }; var fieldInt = new FieldValue { FieldDescriptorRef = intDef, Value = 2 }; var record = new Record { Id = "Record1", Fields = new List<FieldValue> { fieldString, fieldInt } }; session.Store(record); session.SaveChanges(); using (var newSession = ds.OpenSession()) { var history = newSession.Load<RecordHistory>("recordHistory/Record1"); //var recordInner = JsonConvert.DeserializeObject<Record>(history.Record.ToString()); Assert.IsNotNull(history); } }
public void ResolveValueWithId() { FieldValue fieldValue = new FieldValue("Field", "Value", 100); Assert.That(fieldValue.ResolveValue(true), Is.EqualTo("Value")); Assert.That(fieldValue.ResolveValue(false), Is.EqualTo("100")); }
public void Update_the_historical_record_when_a_history_record_exists() { var stringDef = new FieldDescriptorRef { ItemType = typeof(string), FieldName = "StringDef" }; var intDef = new FieldDescriptorRef { ItemType = typeof(int), FieldName = "IntDef" }; var fieldString = new FieldValue { FieldDescriptorRef = stringDef, Value = "1" }; var fieldInt = new FieldValue { FieldDescriptorRef = intDef, Value = 2 }; var record = new Record { Id = "Record1", Fields = new List<FieldValue> { fieldString, fieldInt } }; session.Store(record); session.SaveChanges(); record.Fields[0].Value = "s2"; session.Store(record); session.SaveChanges(); using (var newSession = ds.OpenSession()) { var history = newSession.Load<RecordHistory>("recordHistory/Record1"); var recordInner = JsonConvert.DeserializeObject<Record>(history.Record.ToString()); Assert.AreEqual(recordInner.Fields[0].Value, "s2"); } }
public ThreeWayComparison(FieldValue left, IComparisonOperand right, bool swapped ) { _left = left; _right = right; _swapped = swapped; }
public override bool SetField(Tiff tif, TiffTag tag, FieldValue[] ap) { DeflateCodec sp = tif.m_currentCodec as DeflateCodec; Debug.Assert(sp != null); const string module = "ZIPVSetField"; switch (tag) { case TiffTag.ZIPQUALITY: sp.m_zipquality = ap[0].ToInt(); if ((sp.m_state & DeflateCodec.ZSTATE_INIT_ENCODE) != 0) { if (sp.m_stream.deflateParams(sp.m_zipquality, zlibConst.Z_DEFAULT_STRATEGY) != zlibConst.Z_OK) { Tiff.ErrorExt(tif, tif.m_clientdata, module, "{0}: zlib error: {0}", tif.m_name, sp.m_stream.msg); return false; } } return true; } return base.SetField(tif, tag, ap); }
public override FieldValue[] GetField(Tiff tif, TiffTag tag) { JpegCodec sp = tif.m_currentCodec as JpegCodec; Debug.Assert(sp != null); FieldValue[] result = null; switch (tag) { case TiffTag.JPEGTABLES: result = new FieldValue[2]; result[0].Set(sp.m_jpegtables_length); result[1].Set(sp.m_jpegtables); break; case TiffTag.JPEGQUALITY: result = new FieldValue[1]; result[0].Set(sp.m_jpegquality); break; case TiffTag.JPEGCOLORMODE: result = new FieldValue[1]; result[0].Set(sp.m_jpegcolormode); break; case TiffTag.JPEGTABLESMODE: result = new FieldValue[1]; result[0].Set(sp.m_jpegtablesmode); break; case TiffTag.YCBCRSUBSAMPLING: JPEGFixupTestSubsampling(tif); return base.GetField(tif, tag); case TiffTag.FAXRECVPARAMS: result = new FieldValue[1]; result[0].Set(sp.m_recvparams); break; case TiffTag.FAXSUBADDRESS: result = new FieldValue[1]; result[0].Set(sp.m_subaddress); break; case TiffTag.FAXRECVTIME: result = new FieldValue[1]; result[0].Set(sp.m_recvtime); break; case TiffTag.FAXDCS: result = new FieldValue[1]; result[0].Set(sp.m_faxdcs); break; default: return base.GetField(tif, tag); } return result; }
public FieldValue Compose(FieldValue[] values) { if (values[0] == null) return null; if (values[0] == ScalarValue.UNDEFINED) return ScalarValue.UNDEFINED; return new DecimalValue(((ScalarValue) values[1]).ToLong(), ((IntegerValue) values[0]).value_Renamed); }
public void Field(Field field, FieldValue value_Renamed, FieldValue decodedValue, byte[] encoding, int pmapIndex) { var scalarDecode = new StringBuilder(); scalarDecode.Append(field.Name).Append(": "); scalarDecode.Append(ByteUtil.ConvertByteArrayToBitString(encoding)); scalarDecode.Append(" -> ").Append(value_Renamed).Append('(').Append(decodedValue).Append(')'); print(scalarDecode); }
public void CloneWithId() { FieldValue fieldValue = new FieldValue("Field", "Value", 100); FieldValue clone = fieldValue.Clone(); Assert.That(clone, Is.Not.Null); Assert.That(clone.Name, Is.EqualTo(fieldValue.Name)); Assert.That(clone.Value, Is.EqualTo(fieldValue.Value)); Assert.That(clone.Id, Is.EqualTo(fieldValue.Id)); }
public override FieldValue Copy() { var copies = new FieldValue[values.Length]; for (int i = 0; i < copies.Length; i++) { copies[i] = values[i].Copy(); } return new Message(template, values); }
public override bool SetField(Tiff tif, TiffTag tag, FieldValue[] ap) { CCITTCodec sp = tif.m_currentCodec as CCITTCodec; Debug.Assert(sp != null); switch (tag) { case TiffTag.FAXMODE: sp.m_mode = (FaxMode)ap[0].ToShort(); return true; /* NB: pseudo tag */ case TiffTag.FAXFILLFUNC: sp.fill = ap[0].Value as Tiff.FaxFillFunc; return true; /* NB: pseudo tag */ case TiffTag.GROUP3OPTIONS: /* XXX: avoid reading options if compression mismatches. */ if (tif.m_dir.td_compression == Compression.CCITTFAX3) sp.m_groupoptions = (Group3Opt)ap[0].ToShort(); break; case TiffTag.GROUP4OPTIONS: /* XXX: avoid reading options if compression mismatches. */ if (tif.m_dir.td_compression == Compression.CCITTFAX4) sp.m_groupoptions = (Group3Opt)ap[0].ToShort(); break; case TiffTag.BADFAXLINES: sp.m_badfaxlines = ap[0].ToInt(); break; case TiffTag.CLEANFAXDATA: sp.m_cleanfaxdata = (CleanFaxData)ap[0].ToByte(); break; case TiffTag.CONSECUTIVEBADFAXLINES: sp.m_badfaxrun = ap[0].ToInt(); break; case TiffTag.FAXRECVPARAMS: sp.m_recvparams = ap[0].ToInt(); break; case TiffTag.FAXSUBADDRESS: Tiff.setString(out sp.m_subaddress, ap[0].ToString()); break; case TiffTag.FAXRECVTIME: sp.m_recvtime = ap[0].ToInt(); break; case TiffTag.FAXDCS: Tiff.setString(out sp.m_faxdcs, ap[0].ToString()); break; default: return base.SetField(tif, tag, ap); } TiffFieldInfo fip = tif.FieldWithTag(tag); if (fip != null) tif.setFieldBit(fip.Bit); else return false; tif.m_flags |= TiffFlags.DIRTYDIRECT; return true; }
public FieldValue[] Split(FieldValue value_Renamed) { if (value_Renamed == null) return NULL_SET; if (value_Renamed == ScalarValue.UNDEFINED) return UNDEFINED_SET; var decimal_Renamed = (DecimalValue) value_Renamed; return new FieldValue[]{new IntegerValue(decimal_Renamed.exponent), new LongValue(decimal_Renamed.mantissa)}; }
public static void FieldValueToString(Dictionary<string, string> results, string Path, FieldValue fieldValue) { if (fieldValue == null) { return; } if (fieldValue.Value == null) { results.Add(Path + fieldValue.FieldName, "null"); return; } if (fieldValue.Value is BaseEntity) { GenericEntity ge = (GenericEntity)fieldValue.Value; results.Add(Path + fieldValue.FieldName + ".Id", ge.Id.Value.ToString()); StringBuilder result = new StringBuilder(ge.Id.Value); if (ge.Values.Length > 0) { //recursive foreach (FieldValue fv in ge.Values) { FieldValueToString(results, Path + fieldValue.FieldName + ".", fv); } } return; } else if (fieldValue.Value is Duration) { Duration duration = fieldValue.Value as Duration; results.Add(Path + fieldValue.FieldName + ".Value", duration.Value.ToString()); results.Add(Path + fieldValue.FieldName + ".Unit", duration.Unit.ToString()); return; } else if (fieldValue.Value is Money) { Money money = fieldValue.Value as Money; results.Add(Path + fieldValue.FieldName + ".Value", money.Value.ToString()); results.Add(Path + fieldValue.FieldName + ".Currency", money.Currency.ToString()); return; } else if (fieldValue.Value is DateTime) { DateTime dt = (DateTime)fieldValue.Value; dt = dt.ToLocalTime(); results.Add(Path + fieldValue.FieldName, dt.ToString()); return; } else { results.Add(Path + fieldValue.FieldName, fieldValue.Value.ToString()); return; } }
public override FieldValue[] GetField(Tiff tif, TiffTag tag) { OJpegCodec sp = tif.m_currentCodec as OJpegCodec; Debug.Assert(sp != null); FieldValue[] result = null; switch (tag) { case TiffTag.JPEGIFOFFSET: result = new FieldValue[1]; result[0].Set(sp.m_jpeg_interchange_format); break; case TiffTag.JPEGIFBYTECOUNT: result = new FieldValue[1]; result[0].Set(sp.m_jpeg_interchange_format_length); break; case TiffTag.YCBCRSUBSAMPLING: if (!sp.m_subsamplingcorrect_done) sp.OJPEGSubsamplingCorrect(); result = new FieldValue[2]; result[0].Set(sp.m_subsampling_hor); result[1].Set(sp.m_subsampling_ver); break; case TiffTag.JPEGQTABLES: result = new FieldValue[2]; result[0].Set(sp.m_qtable_offset_count); result[1].Set(sp.m_qtable_offset); break; case TiffTag.JPEGDCTABLES: result = new FieldValue[2]; result[0].Set(sp.m_dctable_offset_count); result[1].Set(sp.m_dctable_offset); break; case TiffTag.JPEGACTABLES: result = new FieldValue[2]; result[0].Set(sp.m_actable_offset_count); result[1].Set(sp.m_actable_offset); break; case TiffTag.JPEGPROC: result = new FieldValue[1]; result[0].Set(sp.m_jpeg_proc); break; case TiffTag.JPEGRESTARTINTERVAL: result = new FieldValue[1]; result[0].Set(sp.m_restart_interval); break; default: return base.GetField(tif, tag); } return result; }
public override FieldValue[] GetField(Tiff tif, TiffTag tag) { DeflateCodec sp = tif.m_currentCodec as DeflateCodec; Debug.Assert(sp != null); switch (tag) { case TiffTag.ZIPQUALITY: FieldValue[] result = new FieldValue[1]; result[0].Set(sp.m_zipquality); return result; } return base.GetField(tif, tag); }
public static bool IsValidMove(MoveType type, FieldValue color, Coords coords, IBoardReader board) { if (type.Equals(MoveType.AddPiece)) { return IsValidMove(color, coords, board); } else if (type.Equals(MoveType.Pass)) { return !GetValidMovesForColor(color, board).Any(); } else { return false; } }
public static bool IsValidMove(FieldValue color, Coords coords, IBoardReader board) { var value = board.GetFieldValue(coords); if (value == FieldValue.Empty) { foreach (var direction in Directions.All) { if (IsDirectionValid(color, coords, direction, board)) { return true; } } } return false; }
public static List<Coords> GetValidMovesForColor(FieldValue color, IBoardReader board) { var validMoves = new List<Coords>(); for (int y = 0; y < board.Size; ++y) { for (int x = 0; x < board.Size; ++x) { var coords = new Coords(x, y); if (IsValidMove(color, coords, board)) { validMoves.Add(coords); } } } return validMoves; }
public override FieldValue[] GetField(Tiff tif, TiffTag tag) { CCITTCodec sp = tif.m_currentCodec as CCITTCodec; Debug.Assert(sp != null); FieldValue[] result = new FieldValue[1]; switch (tag) { case TiffTag.FAXMODE: result[0].Set(sp.m_mode); break; case TiffTag.FAXFILLFUNC: result[0].Set(sp.fill); break; case TiffTag.GROUP3OPTIONS: case TiffTag.GROUP4OPTIONS: result[0].Set(sp.m_groupoptions); break; case TiffTag.BADFAXLINES: result[0].Set(sp.m_badfaxlines); break; case TiffTag.CLEANFAXDATA: result[0].Set(sp.m_cleanfaxdata); break; case TiffTag.CONSECUTIVEBADFAXLINES: result[0].Set(sp.m_badfaxrun); break; case TiffTag.FAXRECVPARAMS: result[0].Set(sp.m_recvparams); break; case TiffTag.FAXSUBADDRESS: result[0].Set(sp.m_subaddress); break; case TiffTag.FAXRECVTIME: result[0].Set(sp.m_recvtime); break; case TiffTag.FAXDCS: result[0].Set(sp.m_faxdcs); break; default: return base.GetField(tif, tag); } return result; }
public static List<Coords> GetPossibleDirections(FieldValue color, Coords coords, IBoardReader board) { var possibleDirections = new List<Coords>(); if (board.GetFieldValue(coords) == FieldValue.Empty) { foreach (var direction in Directions.All) { if (IsDirectionValid(color, coords, direction, board)) { possibleDirections.Add(direction); } } } return possibleDirections; }
public override FieldValue[] GetField(Tiff tif, TiffTag tag) { CodecWithPredictor sp = tif.m_currentCodec as CodecWithPredictor; Debug.Assert(sp != null); switch (tag) { case TiffTag.PREDICTOR: FieldValue[] result = new FieldValue[1]; result[0].Set(sp.GetPredictorValue()); return result; } TiffTagMethods childMethods = sp.GetChildTagMethods(); if (childMethods != null) return childMethods.GetField(tif, tag); return base.GetField(tif, tag); }
/// <summary> /// Adds a header field and its value for inclusion in the built HTTP request /// </summary> /// <param name="fieldName"> /// Name of the header field to include in the built HTTP request /// </param> /// <param name="append"> /// Field value to set or append to the existing field value for that field /// </param> public void AddHeader(string fieldName, string append) { FieldValue value; // Try to obtain the header field. If it isn't on record yet, we set up // a new header field transparently. if(!this.headers.TryGetValue(fieldName, out value)) { value = new FieldValue(); this.headers.Add(fieldName, value); } // Header field is known. If this is a header field without a value (either new // or had no provided value), it will be provided with a value, otherwise, the // value will be appended to the existing field value. if(value.Contents == null) { value.Contents = append; } else if(append != null) { value.Contents += append; } }
public void UpdateHighlights(FieldValue color) { var validMoves = OthelloRules.GetValidMovesForColor(color, m_board); foreach (var column in Rows) { foreach (var field in column) { if (ShowValidMoves && validMoves.Contains(field.Coords)) { field.BackgroundColor.Opacity = 0.4; } else { field.BackgroundColor.Opacity = 0.0; } } } }
public override bool SetField(Tiff tif, TiffTag tag, FieldValue[] ap) { CodecWithPredictor sp = tif.m_currentCodec as CodecWithPredictor; Debug.Assert(sp != null); switch (tag) { case TiffTag.PREDICTOR: sp.SetPredictorValue((Predictor)ap[0].ToByte()); tif.setFieldBit(CodecWithPredictor.FIELD_PREDICTOR); tif.m_flags |= TiffFlags.DIRTYDIRECT; return true; } TiffTagMethods childMethods = sp.GetChildTagMethods(); if (childMethods != null) return childMethods.SetField(tif, tag, ap); return base.SetField(tif, tag, ap); }
public GroupValue(Group group, FieldValue[] values) { if (group == null) { throw new NullReferenceException(); } this.group = group; this.values = values; for (var i = 0; i < group.FieldCount; i++) { if (!(group.GetField(i) is Scalar)) continue; var scalar = ((Scalar) group.GetField(i)); if (scalar.Operator.Equals(Operator.CONSTANT) && !scalar.Optional) { values[i] = scalar.DefaultValue; } } }
private static string GetExtensionArticleFields(HtmlHelper html, FieldValue pair) { var extensionContentId = Converter.ToInt32(pair.Value, 0); if (extensionContentId == 0) { return(string.Empty); } Article aggregatedArticle = null; if (pair.Article.ViewType == ArticleViewType.CompareVersions || pair.Article.ViewType == ArticleViewType.PreviewVersion) { if (pair.Article.ViewType == ArticleViewType.CompareVersions) { if (pair.Version == null || !StringComparer.InvariantCultureIgnoreCase.Equals(pair.Value, pair.ValueToMerge)) { return(string.Empty); } aggregatedArticle = pair.Version.AggregatedArticles.SingleOrDefault(n => n.ContentId == extensionContentId); } if (pair.Article.ViewType == ArticleViewType.PreviewVersion) { if (pair.Version == null) { return(string.Empty); } aggregatedArticle = pair.Version.AggregatedArticles.SingleOrDefault(n => n.ContentId == extensionContentId); } } else { aggregatedArticle = pair.Article.GetAggregatedArticleByClassifier(extensionContentId); } return($"<div class=\"articleWrapper_{extensionContentId}\">{html.AggregatedFieldValues(aggregatedArticle?.FieldValues.Where(n => !n.Field.Aggregated))}</div>"); // check; }
private List <FieldValue> CreateActionValues(Stream stream, string contentType, string fileName, int contentLength) { List <string> keyValues = CreateKeyValues(); int keyValueIndex = 0; List <FieldValue> actionValues = new List <FieldValue>(); ControllerConfiguration config = Controller.CreateConfigurationInstance(typeof(Controller), DataController); XPathNodeIterator keyFieldIterator = config.Navigator.Select("/c:dataController/c:fields/c:field[@isPrimaryKey=\'true\']", config.Resolver); while (keyFieldIterator.MoveNext()) { FieldValue v = new FieldValue(keyFieldIterator.Current.GetAttribute("name", String.Empty)); if (keyValueIndex < keyValues.Count) { v.OldValue = keyValues[keyValueIndex]; v.Modified = false; keyValueIndex++; } actionValues.Add(v); } if (stream != null) { XPathNavigator lengthField = config.Navigator.SelectSingleNode(String.Format("/c:dataController/c:fields/c:field[@name=\'{0}Length\']", ControllerFieldName), config.Resolver); if (lengthField != null) { actionValues.Add(new FieldValue(lengthField.GetAttribute("name", String.Empty), contentLength)); } XPathNavigator contentTypeField = config.Navigator.SelectSingleNode(String.Format("/c:dataController/c:fields/c:field[@name=\'{0}ContentType\']", ControllerFieldName), config.Resolver); if (contentTypeField != null) { actionValues.Add(new FieldValue(contentTypeField.GetAttribute("name", String.Empty), contentType)); } XPathNavigator fileNameField = config.Navigator.SelectSingleNode(String.Format("/c:dataController/c:fields/c:field[@name=\'{0}FileName\']", ControllerFieldName), config.Resolver); if (fileNameField != null) { actionValues.Add(new FieldValue(fileNameField.GetAttribute("name", String.Empty), Path.GetFileName(fileName))); } actionValues.Add(new FieldValue(ControllerFieldName, stream)); } return(actionValues); }
public void EditTeacher(string teacherId, string newClassName, string newTeacherName, string newTeacherPhone, DateTime newBirthday) { DocumentReference dr = db.Collection("teachers").Document(teacherId); Dictionary <string, object> update = new Dictionary <string, object> { { "teacherName", newTeacherName }, { "phone", newTeacherPhone }, { "birthday", newBirthday.ToString("MM/dd/yyyy").Substring(0, 5) } }; dr.SetAsync(update, SetOptions.MergeAll).Wait(); var w = dr.GetSnapshotAsync(); w.Wait(); Teachers[teacherId] = w.Result; if (CurrentClass != newClassName) { //Remove student from current class DocumentReference curClass = db.Collection("classes").Document(Classes[CurrentClass]); curClass.UpdateAsync("teachers", FieldValue.ArrayRemove(teacherId)).Wait(); //add student from current class DocumentReference newClass = db.Collection("classes").Document(Classes[newClassName]); try { newClass.UpdateAsync("teachers", FieldValue.ArrayUnion(teacherId)).Wait(); } catch { Dictionary <string, object> t = new Dictionary <string, object> { { "teachers", new string[] { teacherId } } }; newClass.SetAsync(t, SetOptions.MergeAll).Wait(); } } }
/// <summary> /// Flips one direction. Make sure the direction is a valid direction /// before flipping. Otherwise it will flip all pieces. /// </summary> private void FlipDirection(FieldValue color, Coords start, Coords dir) { Coords current = start + dir; FieldValue oppositeColor = color.OppositeColor(); FieldValue currentValue; while (current.IsInsideBoard(m_board.Size)) { currentValue = m_board.GetFieldValue(current); if (currentValue == FieldValue.Empty) { throw new InvalidOperationException("Tried to flip invalid direction."); } if (currentValue == color) { break; } m_board.FlipPiece(current); current += dir; } }
public bool MakeMove(MoveType type, Coords coords) { if (OthelloRules.IsValidMove(type, m_activePlayer.Color, coords, m_board)) { if (type.Equals(MoveType.AddPiece)) { FieldValue color = m_activePlayer.Color; var flipDirections = OthelloRules.GetPossibleDirections(color, coords, m_board); foreach (var dir in flipDirections) { FlipDirection(color, coords, dir); } m_board.SetFieldValue(color, coords); } ToggleActivePlayer(); return(true); } return(false); }
/// <summary> /// This generates a sorted list of Triples containing the sourrounding coordinates plus /// a water flow capacity value. /// The first two parameters are it's coordinates (x,y) and the last one defines how much /// water height difference there is between the local field and the neighbour field. /// e.g. [1,2,0.2] /// [0,1,0.5] (1,1) [2,1,0.0] /// [1,0,0.1] /// </summary> /// <param name="x"></param> /// <param name="y"></param> private List <FieldValue> generateWaterFlowCapacityList(int x, int y) { List <FieldValue> capacities = new List <FieldValue>(); // For all 4 sourrounding fields calculate these values and add them if their capacity is > 0 FieldValue capacityNorth = generateWaterFlowCapacity(x, y, x, y - 1); if (capacityNorth.amount > WATER_HEIGHT_EPSILON) { capacities.Add(capacityNorth); } FieldValue capacitySouth = generateWaterFlowCapacity(x, y, x, y + 1); if (capacitySouth.amount > WATER_HEIGHT_EPSILON) { capacities.Add(capacitySouth); } FieldValue capacityEast = generateWaterFlowCapacity(x, y, x + 1, y); if (capacityEast.amount > WATER_HEIGHT_EPSILON) { capacities.Add(capacityEast); } FieldValue capacityWest = generateWaterFlowCapacity(x, y, x - 1, y); if (capacityWest.amount > WATER_HEIGHT_EPSILON) { capacities.Add(capacityWest); } // We now have a list of all sourrounding fields with flow capacity (can be less than 4!) // Sort that list by their capacity so we can fill all fields equally by // their minimum commom capacity capacities.Sort((objectA, objectB) => objectA.amount.CompareTo(objectB.amount)); // Sorts in place (ascending when A - B) return(capacities); }
public void Convert(DBField sourceField, DBField destinationField, FieldValue sourceValue, FieldValue destinationValue) { switch ((StorageAttribute)destinationField.Attr) { case StorageAttribute.ALPHA: case StorageAttribute.UNICODE: destinationValue.Value = sourceValue.Value; break; case StorageAttribute.NUMERIC: destinationValue.Value = DisplayConvertor.Instance.toNum(sourceValue.Value.ToString(), new PIC(destinationField.Picture, StorageAttribute.NUMERIC, 0), 0); break; case StorageAttribute.DATE: destinationValue.Value = DisplayConvertor.Instance.toDate((string)sourceValue.Value, new PIC(destinationField.Picture, StorageAttribute.DATE, 0), 0); break; case StorageAttribute.TIME: destinationValue.Value = DisplayConvertor.Instance.toTime((string)sourceValue.Value, new PIC(destinationField.Picture, StorageAttribute.TIME, 0)); break; } }
/// <summary> /// Build the ranges using the unique key segments. /// </summary> /// <param name="record"></param> /// <param name="runtimeCursor"></param> /// <returns></returns> private void BuildRanges(RecordForDataViewToDataSource record, RuntimeCursor runtimeCursor) { int recordFieldIndex = 0; if (uniqueKey != null) { runtimeCursor.RuntimeCursorData.Ranges = new List <RangeData>(); foreach (DBSegment segment in uniqueKey.Segments) { for (int fldIndex = 0; fldIndex < destinationColumnList.Count; fldIndex++) { DBField dbField = destinationColumnList[fldIndex]; if (dbField.Equals(segment.Field)) { RangeData rngData = new RangeData(); rngData.FieldIndex = dbField.IndexInRecord; rngData.Max.Type = RangeType.RangeParam; rngData.Max.Discard = false; rngData.Min.Type = RangeType.RangeParam; rngData.Min.Discard = false; FieldValue fieldValue = new FieldValue(); destinationToSourceFieldIndexMapping.TryGetValue(dbField.Name, out recordFieldIndex); fieldValue.Value = record.GetFieldValue(recordFieldIndex); rngData.Max.Value = fieldValue; rngData.Min.Value = fieldValue; runtimeCursor.RuntimeCursorData.Ranges.Add(rngData); break; } } } } }
public void Check_That_Validator_Change_Bool_Field_Test() { var article = new Article { FieldValues = new List <FieldValue>() }; var field = GenerateField(_fixture, FieldExactTypes.Boolean); var fv = new FieldValue { Field = field, Value = false.ToString() }; article.FieldValues.Add(fv); var valuesState = article.FieldValues.ToDictionary(v => v.Field.FormName, v => v.Field.ExactType == FieldExactTypes.Boolean ? Converter.ToBoolean(v.Value).ToString() : v.Value); var newModel = CreateValidatorAndRun(field.FormName, true, valuesState); var currentState = article.FieldValues.ToDictionary(v => v.Field.FormName, v => v.Field.ExactType == FieldExactTypes.Boolean ? Converter.ToBoolean(v.Value).ToString() : v.Value); Assert.AreNotEqual(currentState, newModel); article.CheckChangesValues(currentState, newModel); currentState = article.FieldValues.ToDictionary(v => v.Field.FormName, v => v.Field.ExactType == FieldExactTypes.Boolean ? Converter.ToBoolean(v.Value).ToString() : v.Value); CollectionAssert.AreEqual(currentState, newModel); }
public void Convert(DBField sourceField, DBField destinationField, FieldValue sourceValue, FieldValue destinationValue) { switch ((StorageAttribute)destinationField.Attr) { case StorageAttribute.ALPHA: case StorageAttribute.UNICODE: var pic = new PIC(sourceField.Picture, StorageAttribute.NUMERIC, 0); destinationValue.Value = DisplayConvertor.Instance.mg2disp(sourceValue.Value.ToString(), null, pic, false, 0, true, false); break; case StorageAttribute.BOOLEAN: NUM_TYPE num = new NUM_TYPE(sourceValue.Value.ToString()); destinationValue.Value = num.NUM_2_LONG() > 0 ? "1" : "0"; break; case StorageAttribute.NUMERIC: case StorageAttribute.DATE: case StorageAttribute.TIME: destinationValue.Value = sourceValue.Value; break; } }
private string GetFieldType() { if (FieldValue is FieldValueCollection) { FieldValueCollection collection = FieldValue as FieldValueCollection; string typeAsString = collection.TypeAsString; if (string.IsNullOrEmpty(typeAsString)) { var firstElement = collection.Values.FirstOrDefault(); if (firstElement is FieldLookupValue) { return("LookupMulti"); } else if (firstElement is FieldTaxonomyValue) { return("TaxonomyFieldTypeMulti"); } } return(typeAsString); } return(FieldValue?.GetType().Name); }
private async void AddStation(Station sta, TypeStation typeStation) { var stations = database.Collection("Stations"); if (typeStation.Equals(TypeStation.DEPARTURE)) { stations = database.Collection("StationsDeparture"); } else if (typeStation.Equals(TypeStation.ARRIVAL)) { stations = database.Collection("StationsArrival"); } if (sta != null) { try { var stationRef = stations.Document(sta.number.ToString()); await stationRef.UpdateAsync("occurence", FieldValue.Increment(1)); } catch (Exception) { var stationStatistics = new StationStatistics { type = typeStation, station = new Config.Station { address = sta.address, contractName = sta.contractName, name = sta.name, number = sta.number }, occurence = 1 }; await stations.Document(sta.number.ToString()).SetAsync(stationStatistics); } } }
/// <summary> /// Convert fields according to the storage attribute. For newly created field assign default value to that field. /// </summary> /// <param name="sourceDataSourceDefinition"></param> /// <param name="destinationDataSourceDefinition"></param> /// <param name="sourceValues"></param> /// <param name="destinationValues"></param> private void ConvertFields(DataSourceDefinition sourceDataSourceDefinition, DataSourceDefinition destinationDataSourceDefinition, FieldValues sourceValues, FieldValues destinationValues) { FieldsMap fieldsMap = new FieldsMap(sourceDataSourceDefinition.Fields, destinationDataSourceDefinition.Fields); DBField sourceField = null; FieldValue sourceValue = null; for (int destinationFieldIndex = 0; destinationFieldIndex < destinationDataSourceDefinition.Fields.Count; destinationFieldIndex++) { int sourceFieldIndex = fieldsMap.GetSourceFieldIndex(destinationFieldIndex); DBField destinationField = destinationDataSourceDefinition.Fields[destinationFieldIndex]; FieldValue destinationValue = destinationValues[destinationFieldIndex]; // If source field exists and source and destination types are comapatible then convert field values. // Else assign default value to destination field. if (sourceFieldIndex != -1) { sourceField = sourceDataSourceDefinition.Fields[sourceFieldIndex]; sourceValue = sourceValues[sourceFieldIndex]; if (StorageAttributeCheck.IsTypeCompatibile((StorageAttribute)sourceField.Attr, (StorageAttribute)destinationField.Attr)) { ConvertFieldValue(sourceField, destinationField, sourceValue, destinationValue); } else { destinationValue.Value = destinationField.DefaultValue; destinationValue.IsNull = destinationField.DefaultNull; } } else { destinationValue.Value = destinationField.DefaultValue; destinationValue.IsNull = destinationField.DefaultNull; } } }
private void ReadLineFields(Article article, IReadOnlyList <string> fieldValues, int contentId, int lineNumber, bool isExtension = false) { if (_fieldsMap.TryGetValue(contentId, out var fields)) { foreach (var field in fields) { var titleIndex = _headersMap[field]; if (titleIndex == -1) { continue; } var value = PrepareValue(fieldValues[titleIndex]); var fieldDbValue = new FieldValue { Field = field }; if (!IsEmpty(value)) { try { FormatFieldValue(field, value, ref fieldDbValue); } catch (FormatException ex) { throw new FormatException(string.Format(ImportStrings.ErrorInColumn, lineNumber, field.Name, ex.Message), ex); } } else if (fieldDbValue.Field.Required) { throw new FormatException(string.Format(ImportStrings.ErrorInRequiredColumn, lineNumber, field.Name, fieldDbValue.Field.Name)); } article.FieldValues.Add(fieldDbValue); } } ReadServiceFields(ref article, fieldValues, isExtension); }
public override FieldValue[] GetField(Tiff tif, TiffTag tag) { CodecWithPredictor sp = tif.m_currentCodec as CodecWithPredictor; Debug.Assert(sp != null); switch (tag) { case TiffTag.PREDICTOR: FieldValue[] result = new FieldValue[1]; result[0].Set(sp.GetPredictorValue()); return(result); } TiffTagMethods childMethods = sp.GetChildTagMethods(); if (childMethods != null) { return(childMethods.GetField(tif, tag)); } return(base.GetField(tif, tag)); }
private void FieldContext_Loaded(object sender, EventArgs e) { if (!this._isInitialised) { this.ColumnDisplayName.Text = this.FieldContext.Field.DisplayName; string selectedValue = Convert.ToString(this.BambooLookup.SelectedValue); this._cascading = Convert.ToBoolean(this.FieldContext.Field.GetCustomProperty("enableRelationship")); this._lookupListName = this.FieldContext.Field.GetCustomProperty("listName"); this._lookupSiteURL = this.FieldContext.Field.GetCustomProperty("siteURL"); this._lookupColumn = this.FieldContext.Field.GetCustomProperty("displayColumn"); this._filterColumn = Convert.ToString(this.FieldContext.Field.GetCustomProperty("filterColumn")); this._parentLookupColumn = Convert.ToString(this.FieldContext.Field.GetCustomProperty("parentColumn")); this._lookupListGD = new Guid(this.FieldContext.Field.GetCustomProperty("list")); this._ClientContext = new ClientContext(this.FieldContext.List.Url.Substring(0, this.FieldContext.List.Url.LastIndexOf("/"))); this._ClientContext.ExecuteQuery(); Web web = this._ClientContext.Web; ListCollection lists = web.Lists; List byTitle = lists.GetByTitle(this._lookupListName); this._ClientContext.Load <Web>(web, new Expression <Func <Web, object> > [0]); this._ClientContext.Load <ListCollection>(lists, new Expression <Func <ListCollection, object> > [0]); this._ClientContext.Load <List>(byTitle, new Expression <Func <List, object> > [0]); this._ClientContext.Load <FieldCollection>(byTitle.Fields, new Expression <Func <FieldCollection, object> > [0]); this._ClientContext.ExecuteQuery(); if (this._cascading) { this.ParentFieldValue = this.FieldContext.FieldValues.FirstOrDefault((FieldValue f) => f.Field.InternalName == this._parentLookupColumn); this.ParentFieldValue.PropertyChanged += new PropertyChangedEventHandler(this.ParentFieldValue_PropertyChanged); this.GetFilteredValues(byTitle); } else { this.GetLookupValues(byTitle); } this.BambooLookup.SelectedValue = selectedValue; this._isInitialised = true; } }
private void FormatFieldValue(Field field, string value, ref FieldValue fieldDbValue) { switch (field.ExactType) { case FieldExactTypes.Numeric: fieldDbValue.Value = MultistepActionHelper.NumericCultureFormat(value, _importSettings.Culture, "en-US"); break; case FieldExactTypes.Date: fieldDbValue.Value = MultistepActionHelper.DateCultureFormat(value, _importSettings.Culture, "en-US"); break; case FieldExactTypes.Time: fieldDbValue.Value = MultistepActionHelper.DateCultureFormat(value, _importSettings.Culture, "en-US"); break; case FieldExactTypes.DateTime: fieldDbValue.Value = MultistepActionHelper.DateCultureFormat(value, _importSettings.Culture, "en-US"); break; case FieldExactTypes.O2MRelation: fieldDbValue.Value = MultistepActionHelper.O2MFormat(value); break; case FieldExactTypes.M2MRelation: fieldDbValue.NewRelatedItems = MultistepActionHelper.M2MFormat(value).ToArray(); fieldDbValue.Value = field.LinkId?.ToString(); break; case FieldExactTypes.M2ORelation: break; default: fieldDbValue.Value = value; break; } }
public override byte[] Encode(FieldValue value_Renamed, Group encodeTemplate, Context context, BitVectorBuilder presenceMapBuilder) { if (value_Renamed == null) { // Only encode null in the first field. return(fields[0].Encode(null, encodeTemplate, context, presenceMapBuilder)); } var buffer = new System.IO.MemoryStream(fields.Length * 8); var values = valueConverter.Split(value_Renamed); for (int i = 0; i < fields.Length; i++) { try { var temp_byteArray = fields[i].Encode(values[i], encodeTemplate, context, presenceMapBuilder); buffer.Write(temp_byteArray, 0, temp_byteArray.Length); } catch (System.IO.IOException e) { throw new RuntimeException(e); } } return(buffer.ToArray()); }
/// <summary> /// Constructor creates and fills fields. /// </summary> /// <param name="boardSize">Size of single layer</param> /// <param name="numberOfLayers">the number of layers</param> public GameBoardModel(int boardSize, int numberOfLayers) { this.boardSize = boardSize; this.numberOfLayers = numberOfLayers; fields = new FieldValue[numberOfLayers][, ]; ClearListOfPositionsOfEmptyField(); for (int z = 0; z < numberOfLayers; z++) { fields[z] = new FieldValue[boardSize, boardSize]; for (int x = 0; x < boardSize; x++) { for (int y = 0; y < boardSize; y++) { fields[z][x, y] = emptyField; AddFieldPositionToListOfEmptyFields(z, x, y); } } } }
/// <summary> /// Adds a header field and its value for inclusion in the built HTTP request /// </summary> /// <param name="fieldName"> /// Name of the header field to include in the built HTTP request /// </param> /// <param name="append"> /// Field value to set or append to the existing field value for that field /// </param> public void AddHeader(string fieldName, string append) { FieldValue value; // Try to obtain the header field. If it isn't on record yet, we set up // a new header field transparently. if (!this.headers.TryGetValue(fieldName, out value)) { value = new FieldValue(); this.headers.Add(fieldName, value); } // Header field is known. If this is a header field without a value (either new // or had no provided value), it will be provided with a value, otherwise, the // value will be appended to the existing field value. if (value.Contents == null) { value.Contents = append; } else if (append != null) { value.Contents += append; } }
public static string ShortTimeInForceDescription(FieldValue timeInForce) { if (timeInForce == FIX_5_0SP2.TimeInForce.AtTheOpening) { return("ATO"); } if (timeInForce == FIX_5_0SP2.TimeInForce.Day) { return("DAY"); } if (timeInForce == FIX_5_0SP2.TimeInForce.FillOrKill) { return("FOK"); } if (timeInForce == FIX_5_0SP2.TimeInForce.GoodTillCancel) { return("GTC"); } if (timeInForce == FIX_5_0SP2.TimeInForce.GoodTillCrossing) { return("GTX"); } if (timeInForce == FIX_5_0SP2.TimeInForce.GoodTillDate) { return("GTD"); } if (timeInForce == FIX_5_0SP2.TimeInForce.ImmediateOrCancel) { return("IOC"); } if (timeInForce == FIX_5_0SP2.TimeInForce.AtTheClose) { return("ATC"); } return(timeInForce.Name); }
public async void AddRecord(string userId, int questionNumber, string className) { try { DocumentReference docRef = _db.Collection("records").Document(userId); Dictionary <string, object> record = new Dictionary <string, object> { { "QuestionNumber", questionNumber }, { "Answer", "" }, { "ClassName", className } }; DocumentSnapshot document = docRef.GetSnapshotAsync().Result; if (document.Exists) { if (document.GetValue <List <Dictionary <string, object> > > ("list").Count > 0) { await docRef.UpdateAsync("list", FieldValue.ArrayUnion(record)); } else { await docRef.SetAsync(new { list = new List <Dictionary <string, object> > () { record } }); } } else { await docRef.SetAsync(new { list = new List <Dictionary <string, object> > () { record } }); } } catch (Exception ex) { Bot.PushMessage(ex.StackTrace); // Bot.Notify (new Exception (new Error (ErrCode.D001, Bot.UserInfo.userId, ex.Message).Message)); } }
private void MapBackwardField(string backwardId, FieldValue fv, int fieldId, Dictionary <int, Product <CloningMode> > dictionary) { var products = fv.RelatedItems.Where(id => dictionary.ContainsKey(id)).Select(id => dictionary[id]); foreach (var p in products) { var backwardFieldValue = p.Article.FieldValues.Find(v => v.Field.Id == fieldId); var ids = new List <int>(); foreach (var id in backwardFieldValue.RelatedItems) { if (dictionary.ContainsKey(id)) { var newId = dictionary[id].Article.Id; if (newId == 0) { ids.Add(id); } else { ids.Add(newId); } } else { ids.Add(id); } } var backwardValue = string.Join(",", ids); backwardFieldValue.UpdateValue(backwardValue); MapProducts(p, dictionary); } }
/// <summary> /// 获取节点 /// </summary> /// <returns>节点组</returns> public List <FieldValue> GetNodes() { if (this.nodes == null) { string[] strArray1 = this.Value.Replace(" ", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty).Split(','); this.nodes = new List <FieldValue>(); foreach (string str in strArray1) { char[] chArray = new char[1] { ':' }; string[] strArray2 = str.Split(chArray); FieldValue fieldValue = new FieldValue(); fieldValue.V1 = int.Parse(strArray2[0]); if (strArray2.Length > 1) { fieldValue.V2 = int.Parse(strArray2[1]); } if (strArray2.Length > 2) { fieldValue.V3 = int.Parse(strArray2[2]); } if (fieldValue.V1 == 29) { int num1 = this.nodes.Count % ((int)this.width + 1); int num2 = this.nodes.Count / ((int)this.width + 1); if (num1 != 0 && num2 != 0 && (num1 != (int)this.width && num2 != (int)this.height)) { this.haveHole = true; } } this.nodes.Add(fieldValue); } } return(this.nodes); }
protected virtual void InternalProcess(ActionArgs args, ControllerConfiguration config) { bool hasCreatedByUserId = false; bool hasCreatedByUserName = false; bool hasCreatedOn = false; bool hasModifiedByUserId = false; bool hasModifiedByUserName = false; bool hasModifiedOn = false; // assign tracking values to field values passed from the client foreach (FieldValue v in args.Values) { if (!(v.ReadOnly)) { if (!(hasCreatedByUserId) && IsCreatedByUserIdPattern(v.Name)) { hasCreatedByUserId = true; if (v.Value == null) { v.NewValue = UserId; v.Modified = true; } } else if (!(hasCreatedByUserName) && IsCreatedByUserNamePattern(v.Name)) { hasCreatedByUserName = true; if (v.Value == null) { v.NewValue = UserName; v.Modified = true; } } else if (!(hasCreatedOn) && IsCreatedOnPattern(v.Name)) { hasCreatedOn = true; if (v.Value == null) { v.NewValue = DateTime.Now; v.Modified = true; } } else if (!(hasModifiedByUserId) && IsModifiedByUserIdPattern(v.Name)) { hasModifiedByUserId = true; v.NewValue = UserId; v.Modified = true; } else if (!(hasModifiedByUserName) && IsModifiedByUserNamePattern(v.Name)) { hasModifiedByUserName = true; v.NewValue = UserName; v.Modified = true; } else if (!(hasModifiedOn) && IsModifiedOnPattern(v.Name)) { hasModifiedOn = true; v.NewValue = DateTime.Now; v.Modified = true; } } } // assign missing tracking values List <FieldValue> values = new List <FieldValue>(args.Values); XPathNodeIterator fieldIterator = config.Select("/c:dataController/c:fields/c:field[not(@readOnly=\'true\')]"); while (fieldIterator.MoveNext()) { string fieldName = fieldIterator.Current.GetAttribute("name", String.Empty); // ensure that missing "created" values are provided if (args.CommandName == "Insert") { if (!(hasCreatedByUserId) && IsCreatedByUserIdPattern(fieldName)) { hasCreatedByUserId = true; FieldValue v = new FieldValue(fieldName, UserId); values.Add(v); } else if (!(hasCreatedByUserName) && IsCreatedByUserNamePattern(fieldName)) { hasCreatedByUserName = true; FieldValue v = new FieldValue(fieldName, UserName); values.Add(v); } else if (!(hasCreatedOn) && IsCreatedOnPattern(fieldName)) { hasCreatedOn = true; FieldValue v = new FieldValue(fieldName, DateTime.Now); values.Add(v); } } // ensure that missing "modified" values are provided if (!(hasModifiedByUserId) && IsModifiedByUserIdPattern(fieldName)) { hasModifiedByUserId = true; FieldValue v = new FieldValue(fieldName, UserId); values.Add(v); } else if (!(hasModifiedByUserName) && IsModifiedByUserNamePattern(fieldName)) { hasModifiedByUserName = true; FieldValue v = new FieldValue(fieldName, UserName); values.Add(v); } else if (!(hasModifiedOn) && IsModifiedOnPattern(fieldName)) { hasModifiedOn = true; FieldValue v = new FieldValue(fieldName, DateTime.Now); values.Add(v); } } args.Values = values.ToArray(); }
private Status CreateContact(WorkflowInstance workflowInstance, Item item) { DateTime now = DateTime.UtcNow; FieldValue contactsField = item.GetFieldValue(TargetFieldName, true); Guid listID = contactsField.Value != null ? new Guid(contactsField.Value) : Guid.NewGuid(); // if the contacts sublist under the item doesn't exist, create it now if (contactsField.Value == null) { Item list = new Item() { ID = listID, Name = TargetFieldName, IsList = true, FolderID = item.FolderID, ItemTypeID = SystemItemTypes.Reference, ParentID = item.ID, UserID = item.UserID, Created = now, LastModified = now, }; contactsField.Value = listID.ToString(); try { UserContext.Items.Add(list); UserContext.SaveChanges(); } catch (Exception ex) { TraceLog.TraceException("Creating Contact sublist failed", ex); return(Status.Error); } } // get the subject out of the InstanceData bag Item contact = null; try { var contactString = GetInstanceData(workflowInstance, OutputParameterName); contact = JsonSerializer.Deserialize <Item>(contactString); } catch (Exception ex) { TraceLog.TraceException("Deserializing Contact failed", ex); return(Status.Error); } // update the contact if it already exists, otherwise add a new contact if (UserContext.Items.Any(c => c.ID == contact.ID)) { try { UserContext.SaveChanges(); Item dbContact = UserContext.Items.Include("FieldValues").Single(c => c.ID == contact.ID); foreach (var fv in contact.FieldValues) { // add or update each of the fieldvalues var dbfv = dbContact.GetFieldValue(fv.FieldName, true); dbfv.Copy(fv); } dbContact.LastModified = now; UserContext.SaveChanges(); } catch (Exception ex) { TraceLog.TraceException("Update Contact failed", ex); return(Status.Error); } } else { try { Folder folder = FindDefaultFolder(contact.UserID, contact.ItemTypeID); if (folder != null) { contact.FolderID = folder.ID; } UserContext.Items.Add(contact); UserContext.SaveChanges(); } catch (Exception ex) { TraceLog.TraceException("CreateContact: creating contact failed", ex); return(Status.Error); } User user = UserContext.GetUser(item.UserID); if (user == null) { TraceLog.TraceError("Could not find the user associated with Item " + item.Name); return(Status.Error); } // create an operation corresponding to the new contact creation var operation = UserContext.CreateOperation(user, "POST", (int?)System.Net.HttpStatusCode.Created, contact, null); if (operation == null) { TraceLog.TraceError("Failed to create operation"); return(Status.Error); } // kick off the New Contact workflow WorkflowHost.InvokeWorkflowForOperation(UserContext, SuggestionsContext, operation); } // add a contact reference to the contact list Guid refID = Guid.NewGuid(); var contactRef = new Item() { ID = refID, Name = contact.Name, ItemTypeID = SystemItemTypes.Reference, FolderID = item.FolderID, ParentID = listID, UserID = contact.UserID, Created = now, LastModified = now, FieldValues = new List <FieldValue>() { new FieldValue() { FieldName = FieldNames.EntityRef, ItemID = refID, Value = contact.ID.ToString() }, new FieldValue() { FieldName = FieldNames.EntityType, ItemID = refID, Value = EntityTypes.Item } } }; try { UserContext.Items.Add(contactRef); UserContext.SaveChanges(); } catch (Exception ex) { TraceLog.TraceException("Creating Contact reference failed", ex); return(Status.Error); } // add a Suggestion with a RefreshEntity FieldName to the list, to tell the UI that the // workflow changed the Item SignalEntityRefresh(workflowInstance, item); return(Status.Complete); }
public override bool IsPresenceMapBitSet(byte[] encoding, FieldValue fieldValue) { return operatorCodec.IsPresenceMapBitSet(encoding, fieldValue); }
public virtual void Visit(FieldValue operand) { operand.Parent().Accept(this); }
public override byte[] Encode(FieldValue fieldValue, Group encodeTemplate, Context context, BitVectorBuilder presenceMapBuilder) { var priorValue = context.Lookup(Dictionary, encodeTemplate, Key); var value_Renamed = (ScalarValue) fieldValue; if (!operatorCodec.CanEncode(value_Renamed, this)) { Global.HandleError(Error.FastConstants.D3_CANT_ENCODE_VALUE, "The scalar " + this + " cannot encode the value " + value_Renamed); } var valueToEncode = operatorCodec.GetValueToEncode(value_Renamed, priorValue, this, presenceMapBuilder); if (operator_Renamed.ShouldStoreValue(value_Renamed)) { context.Store(Dictionary, encodeTemplate, Key, value_Renamed); } if (valueToEncode == null) { return new byte[0]; } byte[] encoding = typeCodec.Encode(valueToEncode); if (context.TraceEnabled && encoding.Length > 0) { context.GetEncodeTrace().Field(this, fieldValue, valueToEncode, encoding, presenceMapBuilder.Index); } return encoding; }
public override bool IsPresenceMapBitSet(byte[] encoding, FieldValue fieldValue) { return length.IsPresenceMapBitSet(encoding, fieldValue); }
public override bool IsPresenceMapBitSet(byte[] encoding, FieldValue fieldValue) { return(false); }
private Status GenerateSuggestions(WorkflowInstance workflowInstance, ServerEntity entity, Dictionary <string, string> suggestionList) { Item item = entity as Item; if (item == null) { TraceLog.TraceError("Entity is not an Item"); return(Status.Error); } // make sure the subject was identified - if not move the state forward string subjectItem = GetInstanceData(workflowInstance, ActivityVariables.Contact); if (subjectItem == null) { return(Status.Complete); } // set up the FB API context FBGraphAPI fbApi = new FBGraphAPI(); // get the current user User user = UserContext.GetUser(item.UserID, true); if (user == null) { TraceLog.TraceError("Could not find the user associated with Item " + item.Name); return(Status.Error); } UserCredential cred = user.GetCredential(UserCredential.FacebookConsent); if (cred != null && cred.AccessToken != null) { fbApi.AccessToken = cred.AccessToken; } else { // user not having a FB token is not an error condition, but there is no way to generate suggestions // just move forward from this state return(Status.Complete); } Item subject = null; try { subject = JsonSerializer.Deserialize <Item>(subjectItem); // if the subjectItem is a reference, chase it down while (subject.ItemTypeID == SystemItemTypes.Reference) { FieldValue refID = subject.GetFieldValue(FieldNames.EntityRef); Guid refid = new Guid(refID.Value); subject = UserContext.Items.Include("FieldValues").Single(i => i.ID == refid); } } catch (Exception ex) { TraceLog.TraceException("Could not deserialize subject Item", ex); return(Status.Error); } FieldValue fbID = subject.GetFieldValue(FieldNames.FacebookID); if (fbID == null || fbID.Value == null) { TraceLog.TraceError(String.Format("Could not find Facebook ID for Contact {0}", subject.Name)); return(Status.Complete); } try { // issue the query against the Facebook Graph API var results = fbApi.Query(fbID.Value, FBQueries.Likes); foreach (var like in results) { string name = (string)like[FBQueryResult.Name]; suggestionList[name] = name; } } catch (Exception ex) { TraceLog.TraceException("Error calling Facebook Graph API", ex); return(Status.Complete); } return(Status.Pending); }
public ExplicitPrime(FieldValue primeP, ECCurve curve, Point @base, FieldValue order, FieldValue cofactor) { PrimeP = primeP; Curve = curve; Base = @base; Order = order; Cofactor = cofactor; }