Ejemplo n.º 1
0
        public NWField(NWGameSpace space, NWLayer layer, ExtPoint coords)
            : base(StaticData.FieldWidth, StaticData.FieldHeight)
        {
            fSpace  = space;
            fLayer  = layer;
            fCoords = coords;

            fCreatures     = new CreaturesList(this, true);
            fItems         = new ItemsList(this, true);
            fEffects       = new EffectsList(this, true);
            fEmitters      = new EmitterList();
            ValidCreatures = new List <int>();

            if (Layer != null)
            {
                LayerEntry layerEntry = (LayerEntry)GlobalVars.nwrDB.GetEntry(Layer.EntryID);
                fEntry = layerEntry.GetFieldEntry(fCoords.X, fCoords.Y);

                EntryID = fEntry.GUID;

                fLandEntry = (LandEntry)GlobalVars.nwrDB.FindEntryBySign(fEntry.LandSign);
                LandID     = fLandEntry.GUID;

                PrepareCreatures();
            }
            else
            {
                fEntry     = null;
                EntryID    = -1;
                fLandEntry = null;
                LandID     = -1;
            }
        }
Ejemplo n.º 2
0
        private FieldEntry CloneFieldFrom(FieldEntry field, string clonedBy, DateTime clonedTime)
        {
            var newField = new FieldEntry
            {
                Id              = Guid.NewGuid(),
                Name            = field.Name,
                DisplayName     = field.DisplayName,
                Description     = field.Description,
                DisplayOrder    = field.DisplayOrder,
                IsRequired      = field.IsRequired,
                RequiredMessage = field.RequiredMessage,
                TypeOfValue     = field.TypeOfValue,
                ChoiceMode      = field.ChoiceMode
            };

            newField.UpdatedBy   = newField.CreatedBy = clonedBy;
            newField.UpdatedTime = newField.CreatedTime = clonedTime;

            newField.ValueChoices = new List <FieldValueChoice>();
            foreach (var choice in field.ValueChoices)
            {
                newField.ValueChoices.Add(CloneValueChoiceFrom(choice, clonedBy, clonedTime));
            }

            return(newField);
        }
Ejemplo n.º 3
0
        public IDataReader GetBatchableIds(FieldEntry identifier, string options)
        {
            /*Return all the IDs of the datasource in a datareader, The IDs will be passed to GetData
             * to allow the data to be processed in batches*/
            var jobConfig = Utility.DecryptJobConfiguration(options);

            var dataSource = new DataTable();

            dataSource = Utility.salesforceQueryID(identifier, jobConfig.SalesforceUserID, jobConfig.SalesforceUserPwd, jobConfig.StartDate);


            return(dataSource.CreateDataReader());
        }
        public void TestNullMapsToScopePositive()
        {
            var scopes = Enum.GetValues(typeof(Sex))
                         .OfType <Sex>()
                         .Select(val => new ScopeValue(DummyScope(val.GetType()), val.ToString())
            {
                Value       = val,
                Description = val.ToString()
            }).ToList();
            var propertyInfo = typeof(InpatientTarget).GetProperty("Sex");

            Assert.IsNotNull(propertyInfo);
            var element = new Element(DummyTarget, propertyInfo.Name);

            element.Scope             = new Scope(DummyTarget, "Sex", typeof(Sex));
            element.Scope.Description = "Sex";
            PrivateObject prv = new PrivateObject(element.Scope);

            prv.SetProperty("Id", 1);
            scopes.ForEach(s => element.Scope.Values.Add(s));
            var fieldEntry = new FieldEntry(new DataColumn("Sex"));

            fieldEntry.Bin.AddValue(null);
            fieldEntry.Bin.AddValue(int.MinValue);
            fieldEntry.Bin.AddValue(0);
            fieldEntry.Bin.AddValue(int.MaxValue);
            var expected    = Sex.Male;
            var notexpected = Sex.Female;

            fieldEntry.Bin[null].ScopeValue         = scopes.FirstOrDefault(v => object.Equals(v.Value, expected));
            fieldEntry.Bin[int.MinValue].ScopeValue = scopes.FirstOrDefault(v => object.Equals(v.Value, notexpected));
            fieldEntry.Bin[0].ScopeValue            = scopes.FirstOrDefault(v => object.Equals(v.Value, notexpected));
            fieldEntry.Bin[int.MaxValue].ScopeValue = scopes.FirstOrDefault(v => object.Equals(v.Value, notexpected));

            var mappedField = new MappedFieldEntryViewModel(propertyInfo, element, fieldEntry);

            var mapper = new TargetMapper <InpatientTarget>(DummyTarget, new[] { mappedField });

            mapper[element] = DBNull.Value;
            Assert.AreEqual(expected, mapper.Target.Sex);


            //var po = new PrivateObject(mapper);
            //var ElementMaps = po.GetProperty("ElementMaps") as IDictionary;
            //Assert.IsTrue(ElementMaps.Count > 0);

            //var errors = new List<ValidationError>();
            //var engine = new InstanceValidator<Monahrq.Wing.Discharge.Inpatient.InpatientTarget>();
            //var result = engine.ValidateInstance(mapper.Target);
        }
            public void GetFieldTypeAndNameFromXmlElement(string xmlElement, string xmlNamespace, out Type type, out string name)
            {
                FieldEntry entry = (FieldEntry)this._elements[SoapServices.CreateKey(xmlElement, xmlNamespace)];

                if (entry != null)
                {
                    type = entry.Type;
                    name = entry.Name;
                }
                else
                {
                    type = null;
                    name = null;
                }
            }
Ejemplo n.º 6
0
            } // GetTypeFromXmlElement

            public void GetFieldTypeAndNameFromXmlAttribute(String xmlAttribute, String xmlNamespace,
                                                            out Type type, out String name)
            {
                FieldEntry field = (FieldEntry)_attributes[CreateKey(xmlAttribute, xmlNamespace)];

                if (field != null)
                {
                    type = field.Type;
                    name = field.Name;
                }
                else
                {
                    type = null;
                    name = null;
                }
            } // GetTypeFromXmlAttribute
Ejemplo n.º 7
0
        public async Task <FieldEntry> AddFieldAsync(FieldEntry field, string creator)
        {
            var enrollment = await GetEnrollmentIncludingFieldsAsync(field.Enrollment.Id);

            if (enrollment == null)
            {
                throw new Exception($"Failed to find enrollment: {field.Enrollment.Id}");
            }

            var now = DateTime.Now;

            field.Id              = Guid.NewGuid();
            field.Name            = field.Name.Trim();
            field.DisplayName     = field.DisplayName.Trim();
            field.Description     = field.Description?.Trim();
            field.RequiredMessage = field.RequiredMessage?.Trim();
            field.UpdatedBy       = field.CreatedBy = creator;
            field.UpdatedTime     = field.CreatedTime = now;

            if (field.ValueChoices != null)
            {
                if (field.ChoiceMode == FieldValueChoiceMode.None)
                {
                    field.ValueChoices.Clear();
                }
                else
                {
                    field.ValueChoices = field.ValueChoices
                                         .Where(c => !string.IsNullOrWhiteSpace(c?.Value) && !string.IsNullOrWhiteSpace(c.DisplayText))
                                         .ToList();
                }

                foreach (var valueChoice in field.ValueChoices)
                {
                    valueChoice.Id          = Guid.NewGuid();
                    valueChoice.Value       = valueChoice.Value ?? string.Empty;
                    valueChoice.DisplayText = valueChoice.DisplayText ?? valueChoice.Value;
                    valueChoice.UpdatedBy   = valueChoice.CreatedBy = creator;
                    valueChoice.UpdatedTime = valueChoice.CreatedTime = now;
                }
            }

            enrollment.ExtraFormFields.Add(field);
            await _db.SaveChangesAsync();

            return(field);
        }
Ejemplo n.º 8
0
        protected override void LoadHeader()
        {
            // Read header
            FileHeader.RecordCount = ReadInt32();
            FileHeader.FieldCount  = ReadInt32();
            FileHeader.RecordSize  = ReadInt32();
            // if flags & 0x01 != 0, this field takes on a new meaning - it becomes
            // an absolute offset to the beginning of the offset_map
            FileHeader.StringTableSize = ReadInt32();
            BaseStream.Position       += 4 + 4; // TableHash, LayoutHash (but also timestamp!)
            FileHeader.MinIndex        = ReadInt32();
            FileHeader.MaxIndex        = ReadInt32();
            BaseStream.Position       += 4; // Locale
            FileHeader.CopyTableSize   = ReadInt32();
            var flags = ReadUInt16();

            FileHeader.IndexField          = ReadUInt16();
            FileHeader.TotalFieldCount     = ReadUInt32();
            FileHeader.CommonDataTableSize = ReadUInt32();

            FileHeader.HasIndexTable  = (flags & 0x04) != 0;
            FileHeader.HasStringTable = (flags & 0x01) == 0;

            _nonZeroValues = new CommonData[FileHeader.TotalFieldCount];

            FieldMeta = new FieldEntry[FileHeader.FieldCount];

            for (var i = 0; i < FieldMeta.Length; ++i)
            {
                // ReSharper disable once UseObjectOrCollectionInitializer
                FieldMeta[i]            = new FieldEntry();
                FieldMeta[i].UnusedBits = ReadInt16();
                FieldMeta[i].Position   = ReadUInt16();
            }

            if (FileHeader.IndexField >= FieldMeta.Length)
            {
                throw new InvalidOperationException("The index column is contained outside of the regular data stream!");
            }

            FileHeader.StringTableOffset = BaseStream.Position + FileHeader.RecordSize * FileHeader.RecordCount;

            // Add missing entries
            FileHeader.RecordCount += FileHeader.CopyTableSize / 8;
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> EditField(FieldEntry field)
        {
            if (!await _enrollmentService.ExistsEnrollmentAsync(field.Enrollment.Id))
            {
                return(NotFound());
            }

            if (!await _enrollmentService.ExistsFieldAsync(field.Id))
            {
                return(NotFound());
            }

            if (field.ChoiceMode != FieldValueChoiceMode.None)
            {
                if (field.ValueChoices == null)
                {
                    ModelState.AddModelError(string.Empty, "Value choices are required when choice mode is Single or Multi.");
                }
            }

            foreach (var key in ModelState.Keys)
            {
                if (key.StartsWith("ValueChoices[") && key.EndsWith("].Field"))
                {
                    ModelState.Remove(key);
                }
            }

            if (ModelState.IsValid)
            {
                await _enrollmentService.UpdateFieldAsync(field, User.GetUsername());

                return(RedirectToAction(nameof(EnrollmentController.Fields), new { Id = field.Enrollment.Id }));
            }

            if (field.ValueChoices == null)
            {
                field.ValueChoices = new List <FieldValueChoice>();                            // prevent rendering from crash
            }
            return(View(field));
        }
        public IDataReader GetBatchableIds(FieldEntry identifier, DataSourceProviderConfiguration providerConfiguration)
        {
            string fileLocation = providerConfiguration.Configuration;

            DataTable dt = new DataTable();

            dt.Columns.Add(identifier.FieldIdentifier);

            XmlDocument doc = new XmlDocument();

            doc.Load(fileLocation);
            XmlNodeList nodes = doc.DocumentElement.SelectNodes(string.Format("/feed/doc/{0}", identifier.FieldIdentifier));

            foreach (XmlNode node in nodes)
            {
                var row = dt.NewRow();
                row[identifier.FieldIdentifier] = node.InnerText;
                dt.Rows.Add(row);
            }
            return(dt.CreateDataReader());
        }
        private void addFieldBtn_Click(object sender, RoutedEventArgs e)
        {
            if (null == this.dsControl.FieldsSourceEntry || string.IsNullOrEmpty(this.dsControl.FieldsSourceEntry.ToString()))
            {
                return;
            }
            AddRegionFieldView dlg = new AddRegionFieldView();

            dlg.FieldInput = this.dsControl.FieldsSourceEntry;
            dlg.Owner      = this;
            dlg.ShowDialog();
            if (dlg.DialogResult.Value && dlg.Processors.Count > 0)
            {
                FieldEntry field = new FieldEntry();
                field.SourceInput = this.dsControl.FieldsSourceEntry;
                field.FieldName   = dlg.FieldName;
                List <ProcessText> procs = new List <ProcessText>();
                procs.Add(dlg.HeadProcess);
                procs.AddRange(dlg.Processors);
                field.Processors = procs;
                _fields.Add(field);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MappedFieldEntryViewModel"/> class.
        /// </summary>
        /// <param name="targetProperty">The target property.</param>
        /// <param name="element">The element.</param>
        /// <param name="entry">The entry.</param>
        public MappedFieldEntryViewModel(PropertyInfo targetProperty, Element element, FieldEntry entry)
        {
            var targetPropertyType = targetProperty.PropertyType;

            if (targetPropertyType.IsGenericType)
            {
                targetPropertyType = targetPropertyType.GetGenericArguments()[0];
            }
            //PropertyChanged += (o, e) => Logger.Write(string.Format("Property changed:  {0}", e.PropertyName), Category.Info, Priority.Low);
            FieldEntry = entry;
            Element    = element;
            var xwalk = FieldEntry.Bin
                        .Select(item =>
            {
                var model = new CrosswalkViewModel(item);
                var value = model.Crosswalk.SourceValue;
                var found = item.Bin[value];
                if (found.ScopeValue == null)
                {
                    GuessScopeForFound(targetPropertyType, found);
                }
                model.Crosswalk.ScopeValue = found == null ? null : found.ScopeValue;
                model.CandidateScopes      = ElementScopeValues;
                (model.Crosswalk as INotifyPropertyChanged).PropertyChanged += (o, e) => OnPropertyChanged();

                (model as INotifyPropertyChanged).PropertyChanged += (o, e) => OnPropertyChanged();
                OnPropertyChanged();
                return(model);
            })
                        .OrderBy(item => item.Crosswalk);

            var temp = new ObservableCollection <CrosswalkViewModel>(xwalk);

            Crosswalks           = CollectionViewSource.GetDefaultView(temp) as ListCollectionView;
            CountTotalCrosswalks = new Lazy <int>(() => CrosswalkModels.Count());
        }
Ejemplo n.º 13
0
        public void LoadFromEntry(FieldEntry entry)
        {
            for (int yy = 0; yy < StaticData.FieldHeight; yy++)
            {
                for (int xx = 0; xx < StaticData.FieldWidth; xx++)
                {
                    NWTile tile = (NWTile)GetTile(xx, yy);

                    FieldEntry.FDTile fdTile = entry.Data.Tiles[yy, xx];

                    tile.Background    = fdTile.BackGround;
                    tile.BackgroundExt = (ushort)PlaceID.pid_Undefined;

                    tile.Foreground    = fdTile.ForeGround;
                    tile.ForegroundExt = (ushort)PlaceID.pid_Undefined;

                    tile.CreaturePtr = null;

                    tile.FogID    = (ushort)PlaceID.pid_Undefined;
                    tile.FogExtID = (ushort)PlaceID.pid_Undefined;
                    tile.FogAge   = 0;
                }
            }
        }
Ejemplo n.º 14
0
        protected override void LoadHeader()
        {
            FileHeader.RecordCount = ReadInt32();
            if (FileHeader.RecordCount == 0)
            {
                return;
            }

            FileHeader.FieldCount = ReadInt32();

            FieldMeta = new FieldEntry[FileHeader.FieldCount];

            FileHeader.RecordSize      = ReadInt32();
            FileHeader.StringTableSize = ReadInt32();
            BaseStream.Position       += 4 + 4;
            FileHeader.MinIndex        = ReadInt32();
            FileHeader.MaxIndex        = ReadInt32();
            BaseStream.Position       += 4;
            FileHeader.CopyTableSize   = ReadInt32();
            var flags = ReadUInt16();

            FileHeader.IndexField = ReadUInt16();

            FileHeader.HasIndexTable  = (flags & 0x04) != 0;
            FileHeader.HasStringTable = (flags & 0x01) == 0;

            for (var i = 0; i < FieldMeta.Length; ++i)
            {
                // ReSharper disable once UseObjectOrCollectionInitializer
                FieldMeta[i]            = new FieldEntry();
                FieldMeta[i].UnusedBits = ReadInt16();
                FieldMeta[i].Position   = ReadUInt16();
            }

            FileHeader.StringTableOffset = 0x30 + FieldMeta.Length * (2 + 2) + FileHeader.RecordSize * FileHeader.RecordCount;
        }
Ejemplo n.º 15
0
 public void AddXmlAttribute(Type fieldType, String fieldName,
                             String xmlAttribute, String xmlNamespace)
 {
     _attributes[CreateKey(xmlAttribute, xmlNamespace)] =
         new FieldEntry(fieldType, fieldName);
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Record the mapping from .NET to Dex
        /// </summary>
        public void RecordMapping(TypeEntry typeEntry)
        {
            var entry = new FieldEntry(field.Name, field.FieldType.ClassName, dfield.Name, dfield.Type.ToString());

            typeEntry.Fields.Add(entry);
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VariableModel"/> class.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="source">The source.</param>
 public VariableModel(Element element, FieldEntry source)
 {
     Element = element;
     Source  = source;
 }
Ejemplo n.º 18
0
        internal override void Load()
        {
            RecordCount = ReadInt32();
            if (RecordCount == 0)
            {
                return;
            }

            FieldMeta            = new FieldEntry[ReadInt32()];
            RecordSize           = ReadInt32();
            BaseStream.Position += 4 + 4 + 4;
            var minIndex = ReadInt32();
            var maxIndex = ReadInt32();

            BaseStream.Position += 4;
            var copyTableSize = ReadInt32();
            var flags         = ReadUInt16();

            FileHeader.IndexField = ReadUInt16();

            FileHeader.HasIndexTable  = (flags & 0x04) != 0;
            FileHeader.HasStringTable = (flags & 0x01) == 0;

            for (var i = 0; i < FieldMeta.Length; ++i)
            {
                // ReSharper disable once UseObjectOrCollectionInitializer
                FieldMeta[i]            = new FieldEntry();
                FieldMeta[i].UnusedBits = ReadInt16();
                FieldMeta[i].Position   = ReadUInt16();
            }

            StringTableOffset = 0x30 + FieldMeta.Length * (2 + 2);

            // Field metadata is loaded, generate the record loader function now.
            _loader = GenerateRecordLoader();

            // Generate common file offsets
            var recordPosition    = BaseStream.Position;
            var copyTablePosition = BaseStream.Length - copyTableSize;

            copyTableSize /= 8; // Simpler for later.

            int[] idTable = null;
            if (FileHeader.HasIndexTable)
            {
                BaseStream.Position = copyTablePosition - RecordCount * 4;

                idTable = new int[RecordCount];
                for (var i = 0; i < RecordCount; ++i)
                {
                    idTable[i] = ReadInt32();
                }
            }

            var offsetMap = new Dictionary <int /* recordIndex */, long /* absoluteOffset */>();

            if (FileHeader.HasStringTable)
            {
                for (var i = 0; i < RecordCount; ++i)
                {
                    // <Simca_> records are padded to largest field size, 35 is padded
                    //          to 36 because 35 isn't divisible by 4
                    // <Simca_> if largest field size and smallest field size are the size,
                    //          there is of course no padding
                    BaseStream.Position = recordPosition;
                    var recordIndex = idTable?[i] ?? minIndex + i;
                    LoadRecord(recordPosition, recordIndex);

                    offsetMap[recordIndex] = recordPosition;
                    recordPosition        += RecordSize;
                }
            }
            else
            {
                var offsetCount = maxIndex - minIndex + 1;

                BaseStream.Position = copyTablePosition - offsetCount * (4 + 2);
                if (FileHeader.HasIndexTable) // Account for index table
                {
                    BaseStream.Position -= RecordCount * 4;
                }

                for (var i = 0; i < maxIndex - minIndex + 1; ++i)
                {
                    var offset = ReadUInt32();
                    var length = ReadUInt16();
                    if (offset == 0 || length == 0)
                    {
                        continue;
                    }

                    var index = minIndex + i;
                    var nextOffsetMapPosition = BaseStream.Position;
                    BaseStream.Position = offset;
                    LoadRecord(offset, index);
                    BaseStream.Position = nextOffsetMapPosition;

                    offsetMap[index] = offset;
                }
            }

            BaseStream.Position = copyTablePosition;
            for (var i = 0; i < copyTableSize; ++i)
            {
                var newIndex = ReadInt32();
                var oldIndex = ReadInt32();

                // Write the new index into the underlying buffer.
                if (!FileHeader.HasIndexTable)
                {
                    var baseMemoryStream = (MemoryStream)BaseStream;
                    if (FieldMeta[FileHeader.IndexField].ByteSize != 4)
                    {
                        throw new InvalidOperationException();
                    }

                    var underlyingBuffer = baseMemoryStream.GetBuffer();
                    var position         = offsetMap[oldIndex] + FieldMeta[FileHeader.IndexField].Position;
                    for (var k = 0; k < FieldMeta[FileHeader.IndexField].ByteSize; ++k)
                    {
                        underlyingBuffer[k + position] = (byte)((newIndex >> (8 * k)) & 0xFF);
                    }
                }

                var nextCopyTablePosition = BaseStream.Position;
                BaseStream.Position = offsetMap[oldIndex];
                LoadRecord(0, newIndex, true);
                BaseStream.Position = nextCopyTablePosition;
            }
        }
Ejemplo n.º 19
0
		public static int RegisterType(string name, string prefix)
		{
			// FieldID is an index.
			if (mMaxFieldID + 2 > mFields.Length)
			{
				Array.Resize(ref mFields, mFields.Length << 1);
			}
			mMaxFieldID++;
			mFields[mMaxFieldID] = new FieldEntry(mMaxFieldID, name, prefix);
			return mMaxFieldID;
		}
Ejemplo n.º 20
0
 public void AddXmlElement(Type fieldType, String fieldName,
                           String xmlElement, String xmlNamespace)
 {
     _elements[CreateKey(xmlElement, xmlNamespace)] =
         new FieldEntry(fieldType, fieldName);
 }
Ejemplo n.º 21
0
 public void AddXmlElement(Type fieldType, String fieldName,
                           String xmlElement, String xmlNamespace)
 {
     _elements[CreateKey(xmlElement, xmlNamespace)] =
         new FieldEntry(fieldType, fieldName);                    
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VariableModel"/> class.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="source">The source.</param>
 public VariableModel(Element element, FieldEntry source)
 {
     this.Element = element;
     this.Source  = source;
 }
Ejemplo n.º 23
0
 public void AddXmlAttribute(Type fieldType, String fieldName,
                             String xmlAttribute, String xmlNamespace)
 {
     _attributes[CreateKey(xmlAttribute, xmlNamespace)] =
         new FieldEntry(fieldType, fieldName);
 }
Ejemplo n.º 24
0
        public async Task <FieldEntry> UpdateFieldAsync(FieldEntry field, string updatedBy)
        {
            var enrollment = await GetEnrollmentAsync(field.Enrollment.Id);

            if (enrollment == null)
            {
                throw new Exception($"Failed to find enrollment: {field.Enrollment.Id}");
            }

            var fieldInDb = await _db.FieldEntries.Include(f => f.ValueChoices)
                            .SingleOrDefaultAsync(f => f.Id == field.Id);

            if (fieldInDb == null)
            {
                throw new Exception($"Failed to find the field: {field.Id}");
            }

            // update field
            // ------------
            fieldInDb.Name            = field.Name.Trim();
            fieldInDb.DisplayName     = field.DisplayName.Trim();
            fieldInDb.Description     = field.Description?.Trim();
            fieldInDb.IsRequired      = field.IsRequired;
            fieldInDb.RequiredMessage = field.RequiredMessage?.Trim();
            fieldInDb.DisplayOrder    = field.DisplayOrder;
            fieldInDb.TypeOfValue     = field.TypeOfValue;
            fieldInDb.ChoiceMode      = field.ChoiceMode;

            fieldInDb.UpdatedBy   = updatedBy;
            fieldInDb.UpdatedTime = DateTime.Now;

            // update value choices
            // --------------------
            if (field.ValueChoices != null)
            {
                if (field.ChoiceMode == FieldValueChoiceMode.None)
                {
                    fieldInDb.ValueChoices.Clear();
                }
                else
                {
                    // remove choices which are not in user inputs.
                    fieldInDb.ValueChoices.RemoveAll(c => field.ValueChoices.All(v => c.Id != v.Id));

                    foreach (var choice in field.ValueChoices)
                    {
                        var choiceInDb = fieldInDb.ValueChoices.SingleOrDefault(c => c.Id == choice.Id);

                        if (choiceInDb != null)// update existing choice
                        {
                            choiceInDb.Value        = choice.Value ?? string.Empty;
                            choiceInDb.DisplayText  = choice.DisplayText ?? choiceInDb.Value;
                            choiceInDb.DisplayOrder = choice.DisplayOrder;
                            choiceInDb.Description  = choice.Description;
                            choiceInDb.UpdatedBy    = fieldInDb.UpdatedBy;
                            choiceInDb.UpdatedTime  = fieldInDb.UpdatedTime;
                        }
                        else // new choice to add
                        {
                            choice.Id          = Guid.NewGuid();
                            choice.Value       = choice.Value ?? string.Empty;
                            choice.DisplayText = choice.DisplayText ?? choice.Value;
                            choice.UpdatedBy   = choice.CreatedBy = fieldInDb.UpdatedBy;
                            choice.UpdatedTime = choice.CreatedTime = fieldInDb.UpdatedTime;
                            fieldInDb.ValueChoices.Add(choice);
                        }
                    }
                }
            }

            await _db.SaveChangesAsync();

            return(fieldInDb);
        }
Ejemplo n.º 25
0
        public DataTable salesforceQueryID(FieldEntry identifier, String sfUserID, String sfUserPwd, String startDate)
        {
            Salesforce.Helpers.sForceService.SforceService binding = sfLogin(sfUserID, sfUserPwd);



            DataTable dtFields = GenerateIDDataTable();

            try
            {
                QueryResult qr = null;
                binding.QueryOptionsValue                    = new Salesforce.Helpers.sForceService.QueryOptions();
                binding.QueryOptionsValue.batchSize          = 250;
                binding.QueryOptionsValue.batchSizeSpecified = true;


                //String soqlQuery = "SELECT CaseNumber FROM Case WHERE CreatedDate >  " + startDate + ""T00:00:00Z"";
                String soqlQuery = "SELECT " + identifier.FieldIdentifier + Constants.SqlCommand.START_DATE + startDate + Constants.SqlCommand.TIME;

                // Make the query call and get the query results

                qr = binding.query(soqlQuery);



                bool done = false;

                while (!done)
                {
                    sObject[] records = qr.records;
                    if (records != null)
                    {
                        for (int i = 0; i < records.Length; i++)
                        {
                            Salesforce.Helpers.sForceService.sObject con = qr.records[i];
                            sObject m = records[i];

                            string ticket = m.Any[0].InnerText;
                            dtFields.Rows.Add(ticket);
                        }

                        if (qr.done)
                        {
                            done = true;
                        }
                        else
                        {
                            qr = binding.queryMore(qr.queryLocator);
                        }
                    }
                    else
                    {
                        done = true;
                    }
                }
            }
            catch (SoapException e)
            {
                Console.WriteLine("An unexpected error has occurred: " + e.Message +
                                  " Stack trace: " + e.StackTrace);
            }



            return(dtFields);
        }