コード例 #1
0
        private void SendMapping(MappingItem mapping)
        {
            var stream = new MemoryStream(); // do not use using since we'll pass it to next queue

            var propertyPath = mapping.PropertyPath == Empty ? null : mapping.PropertyPath;

            using (var textWriter = new StreamWriter(stream, Encoding.UTF8, 1024, true))
            {
                EsJsonWriter.WriteMappingToStream(mapping.Columns, propertyPath, textWriter, mapping.PropertyType, Config.EntityType);
            }

            AddToOutputQueue(new MappingUploadQueueItem
            {
                PropertyName   = mapping.PropertyPath,
                SequenceNumber = mapping.SequenceNumber,
                Stream         = stream,
            });

            if (Config.WriteTemporaryFilesToDisk)
            {
                string path = Path.Combine(Config.LocalSaveFolder, (propertyPath != null ? $@"mapping-{mapping.SequenceNumber}-{propertyPath}.json" : "mainmapping.json"));
                using (var fileStream = File.Create(path))
                {
                    stream.Seek(0, SeekOrigin.Begin);
                    stream.CopyTo(fileStream);

                    fileStream.Flush();
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 取得對照表
        /// </summary>
        /// <param name="type">類別</param>
        /// <returns>項目列表</returns>
        public static List <MappingItem> GetActivityRecordMappingItems(string type)
        {
            string             targetService = "UDSInvokeService.Invoke";
            List <MappingItem> items         = new List <MappingItem>();

            DSXmlHelper helper = new DSXmlHelper("Request");

            helper.AddElement("Condition");
            helper.AddElement("Condition", "類別", type);

            helper.BaseElement.SetAttribute("Package", PACKAGE_NAME);
            helper.BaseElement.SetAttribute("Service", SERIVCE_取得活動表現紀錄對照表);

            DSResponse rsp = FISCA.Authentication.DSAServices.CallService(targetService, new DSRequest(helper.BaseElement));

            foreach (XmlNode node in rsp.GetContent().BaseElement.SelectNodes("項目"))
            {
                XmlElement element = (XmlElement)node;

                int count;
                if (!int.TryParse(element.GetAttribute("數量"), out count))
                {
                    count = 1;
                }

                MappingItem item = new MappingItem();
                item.Item  = element.GetAttribute("細項");
                item.Type  = element.GetAttribute("類別");
                item.Count = count;
                items.Add(item);
            }

            return(items);
        }
コード例 #3
0
        public void SaveSetting(MappingItem item)
        {
            if (item == null)
            {
                return;
            }

            string        lut   = GetLUT();
            string        field = GetField();
            GWDataDBTable table = GetTable();

            item.GWDataDBField.Table     = table;
            item.GWDataDBField.FieldName = field;
            item.Translating.Type        = TranslatingType.None;

            if (_checkFixValue.Checked)
            {
                item.Translating.Type       = TranslatingType.FixValue;
                item.Translating.ConstValue = _textFixValue.Text;
            }

            if (_checkLookupTable.Checked)
            {
                item.Translating.Type    = TranslatingType.LookUpTable;
                item.Translating.LutName = lut;
            }
        }
コード例 #4
0
 internal Enumerator(List <MappingItem <TSelectedItem> > list)
 {
     this.list = list;
     index     = 0;
     version   = list._version;
     current   = default(MappingItem <TSelectedItem>);
 }
コード例 #5
0
 public void Insert(int index, MappingItem <TSelectedItem> item)
 {
     lock (_root)
     {
         _list.Insert(index, item);
     }
 }
コード例 #6
0
        /// <summary>
        /// Add an Item to the columnlist
        /// </summary>
        /// <param name="attribute"></param>
        /// <param name="Operation"></param>
        private void AddSupportedMappingItem(AttributeMetadata attribute, IDTSInput100 input, int Operation)
        {
            MappingItem mi;

            if (SupportedTypes.isValidAttribute(attribute, Operation))
            {
                mi = new MappingItem();

                mi.InternalColumnName     = attribute.LogicalName;
                mi.InternalColumnTypeName = attribute.AttributeType.ToString();
                mi.InternalColumnType     = attribute.AttributeType;
                mi.isPrimary  = attribute.IsPrimaryId.HasValue ? (bool)attribute.IsPrimaryId : false;
                mi.isRequired = attribute.IsRequiredForForm.HasValue ? (bool)attribute.IsRequiredForForm : false;



                //Maps by name the Input collection with Dynamics CRM collection
                foreach (IDTSInputColumn100 inputcol in input.InputColumnCollection)
                {
                    if (inputcol.Name == attribute.LogicalName)
                    {
                        mi.ExternalColumnName     = inputcol.Name;
                        mi.ExternalColumnType     = inputcol.DataType;
                        mi.ExternalColumnTypeName = inputcol.DataType.ToString();
                    }
                }
                columnList.Add(mi);
            }
        }
コード例 #7
0
 public bool Remove(MappingItem <TSelectedItem> item)
 {
     lock (_root)
     {
         return(_list.Remove(item));
     }
 }
コード例 #8
0
 public int IndexOf(MappingItem <TSelectedItem> item)
 {
     lock (_root)
     {
         return(_list.IndexOf(item));
     }
 }
コード例 #9
0
 public void Add(MappingItem <TSelectedItem> item)
 {
     lock (_root)
     {
         _list.Add(item);
     }
 }
コード例 #10
0
 public bool Contains(MappingItem <TSelectedItem> item)
 {
     lock (_root)
     {
         return(_list.Contains(item));
     }
 }
コード例 #11
0
        /// <summary>
        /// The send mapping.
        /// </summary>
        /// <param name="mapping">
        /// The mapping.
        /// </param>
        /// <param name="workItemJob">
        /// The work item job.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        private async Task SendMapping(MappingItem mapping, IJob workItemJob)
        {
            var stream = new MemoryStream(); // do not use using since we'll pass it to next queue

            var propertyPath = mapping.PropertyPath == string.Empty ? null : mapping.PropertyPath;

            using (var textWriter = new StreamWriter(stream, Encoding.UTF8, 1024, true))
            {
                await this.entityJsonWriter.WriteMappingToStreamAsync(
                    mapping.Columns,
                    propertyPath,
                    textWriter,
                    mapping.PropertyType,
                    this.Config.EntityType);
            }

            await this.AddToOutputQueueAsync(
                new MappingUploadQueueItem
            {
                PropertyName   = mapping.PropertyPath,
                SequenceNumber = mapping.SequenceNumber,
                Stream         = stream,
                Job            = workItemJob
            });

            string path = Path.Combine(
                this.folder,
                propertyPath != null ? $@"mapping-{mapping.SequenceNumber}-{propertyPath}.json" : "mainmapping.json");

            await this.fileWriter.WriteStreamAsync(path, stream);
        }
コード例 #12
0
    // Returns the index of the last occurrence of a given value in a range of
    // this list. The list is searched backwards, starting at index
    // index and upto count elements. The elements of
    // the list are compared to the given value using the Object.Equals
    // method.
    //
    // This method uses the Array.LastIndexOf method to perform the
    // search.
    //
    public int LastIndexOf(MappingItem <TSelectedItem> item, int index, int count)
    {
        if ((Count != 0) && (index < 0))
        {
            ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
        }

        if ((Count != 0) && (count < 0))
        {
            ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
        }
        Contract.Ensures(Contract.Result <int>() >= -1);
        Contract.Ensures(((Count == 0) && (Contract.Result <int>() == -1)) || ((Count > 0) && (Contract.Result <int>() <= index)));
        Contract.EndContractBlock();

        if (_size == 0)
        {  // Special case for empty list
            return(-1);
        }

        if (index >= _size)
        {
            ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_BiggerThanCollection);
        }

        if (count > index + 1)
        {
            ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_BiggerThanCollection);
        }

        return(Array.LastIndexOf(_items, item, index, count));
    }
コード例 #13
0
 // Contains returns true if the specified element is in the List.
 // It does a linear, O(n) search.  Equality is determined by calling
 // item.Equals().
 //
 public bool Contains(MappingItem <TSelectedItem> item)
 {
     if ((Object)item == null)
     {
         for (int i = 0; i < _size; i++)
         {
             if ((Object)_items[i] == null)
             {
                 return(true);
             }
         }
         return(false);
     }
     else
     {
         EqualityComparer <MappingItem <TSelectedItem> > c = EqualityComparer <MappingItem <TSelectedItem> > .Default;
         for (int i = 0; i < _size; i++)
         {
             if (c.Equals(_items[i], item))
             {
                 return(true);
             }
         }
         return(false);
     }
 }
コード例 #14
0
        public void LoadSetting(MappingItem item)
        {
            if (item == null)
            {
                return;
            }

            _textFixValue.Text = item.Translating.ConstValue;
            SelectItem(_comboLookupTable, item.Translating.LutName);
            SelectItem(_comboTable, item.GWDataDBField.Table.ToString());
            SelectItem(_comboField, item.GWDataDBField.FieldName);

            switch (item.Translating.Type)
            {
            case TranslatingType.FixValue:
            {
                _checkFixValue.Checked = true;
                break;
            }

            case TranslatingType.LookUpTable:
            {
                _checkFixValue.Checked = true;
                break;
            }
            }
        }
コード例 #15
0
        private JumpLocation?FindForMapping(ISearchContext searchContext, MappingItem mappingItem)
        {
            var property = searchContext.GetSelectedProperty();

            if (mappingItem == null)
            {
                Logger.Info($"FAIL: mapping not found! selectedProperty={property} by selectedWord=\"{searchContext.GetSelectedWord()}\" does not match with any srcWord");
                return(null);
            }

            var dstFileContainer = _mappingToDstFileContainerMap[mappingItem];

            dstFileContainer.InitIfNeeded();

            var tokenValue   = property.Value;
            var jumpLocation = dstFileContainer.FindDestinationLocation(mappingItem.Dst.Word, tokenValue);

            if (jumpLocation == null)
            {
                Logger.Info($"FAIL: could not find suitable location for mappingItem=[{mappingItem}] and tokenValue=<{tokenValue}>");
                return(null);
            }

            Logger.Info($"SUCCESS: destination location successfully found for mappingItem=[{mappingItem}] and tokenValue={tokenValue}. JumpLocation=[{jumpLocation}]");
            return(jumpLocation);
        }
コード例 #16
0
ファイル: MappingItemTests.cs プロジェクト: chrisjowen/FillMe
        public void ShouldApplyGenerator()
        {
            var generator   = MockRepository.GenerateStub <IGenerateDummyData>();
            var mappingItem = new MappingItem(GetFooProperty()).Use(generator);

            Assert.That(mappingItem.Generator, Is.EqualTo(generator));
        }
コード例 #17
0
    /// <summary>
    /// Called by base class Collection&lt;MappingItem<TSelectedItem>&gt; when an item is added to list;
    /// raises a CollectionChanged event to any listeners.
    /// </summary>
    protected override void InsertItem(int index, MappingItem <TSelectedItem> item)
    {
        CheckReentrancy();
        base.InsertItem(index, item);

        OnPropertyChanged(CountString);
        OnPropertyChanged(IndexerName);
        OnCollectionChanged(NotifyCollectionChangedAction.Add, item, index);
    }
コード例 #18
0
ファイル: TestNullable.cs プロジェクト: rfcclub/dot42
        public void testMappingItem()
        {
            var mappingItem = new MappingItem();
            mappingItem.CharacterCode = 12;

            var str = mappingItem.ToString();

            AssertEquals("Val=12", str);
        }
コード例 #19
0
    // ToArray returns a new Object array containing the contents of the List.
    // This requires copying the List, which is an O(n) operation.
    public MappingItem <TSelectedItem>[] ToArray()
    {
        Contract.Ensures(Contract.Result <MappingItem <TSelectedItem>[]>() != null);
        Contract.Ensures(Contract.Result <MappingItem <TSelectedItem>[]>().Length == Count);

        MappingItem <TSelectedItem>[] array = new MappingItem <TSelectedItem> [_size];
        Array.Copy(_items, 0, array, 0, _size);
        return(array);
    }
コード例 #20
0
        private void RaiseItemClearInteractionRequest(MappingItem originalItem)
        {
            //TODO check system properties map and custom properties map to clear property
            //InnerItem.ColumnMapping.PropertiesMap.First(prop => prop.EntityColumnName == originalItem.EntityColumnName).CustomValue = null;
            //originalItem.CsvColumnName = null;
            //originalItem.CustomValue = null;

            ////fake mapping list update to refresh view
            //SetMappingItems();
        }
コード例 #21
0
        void System.Collections.IEnumerator.Reset()
        {
            if (version != list._version)
            {
                ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_EnumFailedVersion);
            }

            index   = 0;
            current = default(MappingItem <TSelectedItem>);
        }
コード例 #22
0
 private void RaiseItemClearInteractionRequest(MappingItem originalItem)
 {
     originalItem.CsvColumnName = String.Empty;
     originalItem.CustomValue   = String.Empty;
     OnPropertyChanged("InnerItem");
     if (IsSingleDialogEditing)
     {
         IsModified = true;
     }
 }
コード例 #23
0
    /// <summary>
    /// Called by base class Collection&lt;MappingItem<TSelectedItem>&gt; when an item is set in list;
    /// raises a CollectionChanged event to any listeners.
    /// </summary>
    protected virtual void SetItem(int index, MappingItem <TSelectedItem> item)
    {
        CheckReentrancy();
        MappingItem <TSelectedItem> originalItem = this[index];

        items[index] = item;

        OnPropertyChanged(IndexerName);
        OnCollectionChanged(NotifyCollectionChangedAction.Replace, originalItem, item, index);
    }
コード例 #24
0
ファイル: TestNullable.cs プロジェクト: luozhiping1987/dot42
        public void testMappingItem()
        {
            var mappingItem = new MappingItem();

            mappingItem.CharacterCode = 12;

            var str = mappingItem.ToString();

            AssertEquals("Val=12", str);
        }
コード例 #25
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in dgEditor.Rows)
            {
                foreach (DataGridViewCell cell in row.Cells)
                {
                    if (!string.IsNullOrEmpty(cell.ErrorText))
                    {
                        MessageBoxEx.Show("輸入資料有誤, 請修正後再行儲存!", "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }

            List <MappingItem> items = new List <MappingItem>();

            foreach (DataGridViewRow row in dgEditor.Rows)
            {
                MappingItem item = new MappingItem();

                string           value = string.Empty;
                DataGridViewCell cell  = row.Cells["細項"];

                if (cell.Value == null)
                {
                    continue;
                }
                value = cell.Value.ToString();
                if (value == string.Empty)
                {
                    continue;
                }

                string countString;
                int    count;
                cell = row.Cells["數量"];
                if (cell.Value == null)
                {
                    count = 1;
                }
                else
                {
                    countString = cell.Value.ToString();
                    if (!int.TryParse(countString, out count))
                    {
                        count = 1;
                    }
                }
                item.Item  = value;
                item.Count = count;
                items.Add(item);
            }
            ActivityRecordDAL.SetActivityRecordMapping(cboType.Text, items.ToArray());
            MessageBoxEx.Show(cboType.Text + "類別已儲存完畢!");
        }
コード例 #26
0
    // Inserts the elements of the given collection at a given index. If
    // required, the capacity of the list is increased to twice the previous
    // capacity or the new size, whichever is larger.  Ranges may be added
    // to the end of the list by setting index to the List's size.
    //
    public void InsertRange(int index, IEnumerable <MappingItem <TSelectedItem> > collection)
    {
        if (collection == null)
        {
            ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection);
        }

        if ((uint)index > (uint)_size)
        {
            ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_Index);
        }
        Contract.EndContractBlock();

        ICollection <MappingItem <TSelectedItem> > c = collection as ICollection <MappingItem <TSelectedItem> >;

        if (c != null)
        {    // if collection is ICollection<MappingItem<TSelectedItem>>
            int count = c.Count;
            if (count > 0)
            {
                EnsureCapacity(_size + count);
                if (index < _size)
                {
                    Array.Copy(_items, index, _items, index + count, _size - index);
                }

                // If we're inserting a List into itself, we want to be able to deal with that.
                if (this == c)
                {
                    // Copy first part of _items to insert location
                    Array.Copy(_items, 0, _items, index, index);
                    // Copy last part of _items back to inserted location
                    Array.Copy(_items, index + count, _items, index * 2, _size - index);
                }
                else
                {
                    MappingItem <TSelectedItem>[] itemsToInsert = new MappingItem <TSelectedItem> [count];
                    c.CopyTo(itemsToInsert, 0);
                    itemsToInsert.CopyTo(_items, index);
                }
                _size += count;
            }
        }
        else
        {
            using (IEnumerator <MappingItem <TSelectedItem> > en = collection.GetEnumerator())
            {
                while (en.MoveNext())
                {
                    Insert(index++, en.Current);
                }
            }
        }
        _version++;
    }
コード例 #27
0
        private bool MoveNextRare()
        {
            if (version != list._version)
            {
                ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_EnumFailedVersion);
            }

            index   = list._size + 1;
            current = default(MappingItem <TSelectedItem>);
            return(false);
        }
コード例 #28
0
    protected virtual void RemoveItem(int index)
    {
        CheckReentrancy();
        MappingItem <TSelectedItem> removedItem = this[index];

        items.RemoveAt(index);

        OnPropertyChanged(CountString);
        OnPropertyChanged(IndexerName);
        OnCollectionChanged(NotifyCollectionChangedAction.Remove, removedItem, index);
    }
コード例 #29
0
 // Returns the index of the first occurrence of a given value in a range of
 // this list. The list is searched forwards, starting at index
 // index and ending at count number of elements. The
 // elements of the list are compared to the given value using the
 // Object.Equals method.
 //
 // This method uses the Array.IndexOf method to perform the
 // search.
 //
 public int IndexOf(MappingItem <TSelectedItem> item, int index)
 {
     if (index > _size)
     {
         ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_Index);
     }
     Contract.Ensures(Contract.Result <int>() >= -1);
     Contract.Ensures(Contract.Result <int>() < Count);
     Contract.EndContractBlock();
     return(Array.IndexOf(_items, item, index, _size - index));
 }
コード例 #30
0
 // Returns the index of the last occurrence of a given value in a range of
 // this list. The list is searched backwards, starting at index
 // index and ending at the first element in the list. The
 // elements of the list are compared to the given value using the
 // Object.Equals method.
 //
 // This method uses the Array.LastIndexOf method to perform the
 // search.
 //
 public int LastIndexOf(MappingItem <TSelectedItem> item, int index)
 {
     if (index >= _size)
     {
         ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_Index);
     }
     Contract.Ensures(Contract.Result <int>() >= -1);
     Contract.Ensures(((Count == 0) && (Contract.Result <int>() == -1)) || ((Count > 0) && (Contract.Result <int>() <= index)));
     Contract.EndContractBlock();
     return(LastIndexOf(item, index, index + 1));
 }
コード例 #31
0
    /// <summary>
    /// Called by base class ObservableCollection&lt;MappingItem<TSelectedItem>&gt; when an item is to be moved within the list;
    /// raises a CollectionChanged event to any listeners.
    /// </summary>
    protected virtual void MoveItem(int oldIndex, int newIndex)
    {
        CheckReentrancy();

        MappingItem <TSelectedItem> removedItem = this[oldIndex];

        RemoveItem(oldIndex);
        InsertItem(newIndex, removedItem);

        OnPropertyChanged(IndexerName);
        OnCollectionChanged(NotifyCollectionChangedAction.Move, removedItem, newIndex, oldIndex);
    }
コード例 #32
0
    protected string FormatSourceType(MappingItem item)
    {
        switch (item.SourceType)
        {
            case MappingItemSourceTypeEnum.Field:
                return GetString("sf.sourcetype.field");
            case MappingItemSourceTypeEnum.MetaField:
                return GetString("sf.sourcetype.metafield");
            case MappingItemSourceTypeEnum.PicklistEntry:
                return GetString("sf.sourcetype.picklistentry");
        }

        return String.Empty;
    }
コード例 #33
0
ファイル: MappingItemTests.cs プロジェクト: chrisjowen/FillMe
 public void ShouldApplyGenerator()
 {
     var generator = MockRepository.GenerateStub<IGenerateDummyData>();
     var mappingItem = new MappingItem(GetFooProperty()).Use(generator);
     Assert.That(mappingItem.Generator, Is.EqualTo(generator));
 }
コード例 #34
0
 protected string FormatSourceLabel(MappingItem item)
 {
     return item.SourceLabel;
 }
コード例 #35
0
        private void btnAddMap_Click(object sender, EventArgs e)
        {
            if (lstSource.SelectedItem == null || lstDest.SelectedItem == null)
                return;

            FieldAndContentType fcS = (FieldAndContentType)lstSource.SelectedItem;
            FieldAndContentType fcD = (FieldAndContentType)lstDest.SelectedItem;

            //lstSource.Items.Remove(fcS);
            //lstDest.Items.Remove(fcD);

            MappingItem mi = new MappingItem(fcS.Field.InternalName, fcD.Field.InternalName);
            m_mpWorking.MappingItems.Add(mi);
            m_mpWorking.MappingItems.Sort();
            displayMappingProfileInRtb(mi.ToString(), "added");
        }