public UnaryExpression(Statement statement, object p, Expression expression, SourceData sourceData)
     : base(statement, sourceData)
 {
     // TODO: Complete member initialization
     this.p = p;
     this.expression = expression;
 }
Esempio n. 2
0
        public SourceData Update(SourceData data)
        {
            var source = MockDb.Sources
                .Where(row => row.SourceId == data.SourceId
                    && row.SourceTypeId == data.SourceTypeId)
                .Single();

            Csla.Data.DataMapper.Map(data, source);

            return data;
        }
Esempio n. 3
0
        private static void TestMappingToPoco(SourceData.PersonRow sourceRow)
        {
            PocoPerson pocoPerson = new PocoPerson();

            //now the Poco - this all works
            AutoMapper.Mapper.CreateMap<SourceData.PersonRow, PocoPerson>()
                //with this ForMember, every FirstName should be "First!"
                .ForMember(src => src.FirstName, opt => opt.MapFrom(src => "First!"));

            AutoMapper.Mapper.Map<SourceData.PersonRow, PocoPerson>(sourceRow, pocoPerson);

            Debug.Assert(pocoPerson.FirstName.Equals("First!"), "poco mapping failed");
        }
Esempio n. 4
0
        public SourceData Fetch(SourceDataCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                         .GetManager(Database.ApplicationConnection, false))
            {
                var source = this.Fetch(ctx, criteria)
                    .Single();

                var sourceData = new SourceData();

                this.Fetch(source, sourceData);

                return sourceData;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Update the source data for the currently detected sources.
        /// </summary>
        private void UpdateSourceData()
        {
            // Poll for updated reading from hands
            UnityEngine.XR.WSA.Input.InteractionSourceState[] sourceStates = UnityEngine.XR.WSA.Input.InteractionManager.GetCurrentReading();
            if (sourceStates != null)
            {
                for (var i = 0; i < sourceStates.Length; ++i)
                {
                    UnityEngine.XR.WSA.Input.InteractionSourceState handSource = sourceStates[i];
                    SourceData sourceData = GetOrAddSourceData(handSource.source);
                    currentSources.Add(handSource.source.id);

                    UpdateSourceState(handSource, sourceData);
                }
            }
        }
Esempio n. 6
0
        public void TestUpdateDonorGuestDonor()
        {
            _fixture.Request.Headers.Authorization = null;
            var dto = new UpdateDonorDTO
            {
                DonorId       = "123",
                EmailAddress  = "*****@*****.**",
                StripeTokenId = "456"
            };

            var contactDonor = new MpContactDonor
            {
                DonorId        = 123,
                ContactId      = 789,
                Email          = "*****@*****.**",
                ProcessorId    = "102030",
                RegisteredUser = false,
            };

            var sourceData = new SourceData
            {
                bank_last4     = "5555",
                routing_number = "987654321"
            };

            _donorService.Setup(mocked => mocked.GetContactDonorForEmail("*****@*****.**")).Returns(contactDonor);
            _paymentService.Setup(mocked => mocked.UpdateCustomerSource(contactDonor.ProcessorId, dto.StripeTokenId))
            .Returns(sourceData);

            var result = _fixture.UpdateDonor(dto);

            _donorService.VerifyAll();
            _paymentService.VerifyAll();

            Assert.NotNull(result);
            Assert.IsInstanceOf <OkNegotiatedContentResult <DonorDTO> >(result);
            var donorDto = ((OkNegotiatedContentResult <DonorDTO>)result).Content;

            Assert.AreEqual(contactDonor.DonorId, donorDto.Id);
            Assert.AreEqual(contactDonor.ProcessorId, donorDto.ProcessorId);
            Assert.AreEqual(contactDonor.RegisteredUser, donorDto.RegisteredUser);

            Assert.IsNotNull(donorDto.DefaultSource.credit_card);
            Assert.IsNotNull(donorDto.DefaultSource.bank_account);
            Assert.AreEqual(sourceData.bank_last4, donorDto.DefaultSource.bank_account.last4);
            Assert.AreEqual(sourceData.routing_number, donorDto.DefaultSource.bank_account.routing);
        }
Esempio n. 7
0
        SourceData GetSourceData()
        {
            var sourceData = new SourceData();

            sourceData.curveTypePosition          = CurveTypePosition;
            sourceData.roundedLineCurvatureRadius = RoundedLineCurvatureRadius;
            sourceData.curveTypeRotation          = CurveTypeRotation;
            sourceData.curveTypeScale             = CurveTypeScale;
            sourceData.timeScale = TimeScale;

            var points = GetComponents <Component_CurveInSpacePoint>(onlyEnabledInHierarchy: true);

            sourceData.points    = new SourceData.Point[1 + points.Length];
            sourceData.points[0] = new SourceData.Point()
            {
                transform = Transform, time = Time
            };
            for (int n = 0; n < points.Length; n++)
            {
                sourceData.points[n + 1] = new SourceData.Point()
                {
                    transform = points[n].Transform, time = points[n].Time
                }
            }
            ;

            //sort by time
            bool allPointsZeroTime = sourceData.points.All(p => p.time == 0);

            if (!allPointsZeroTime)
            {
                CollectionUtility.MergeSort(sourceData.points, delegate(SourceData.Point a, SourceData.Point b)
                {
                    if (a.time < b.time)
                    {
                        return(-1);
                    }
                    if (a.time > b.time)
                    {
                        return(1);
                    }
                    return(0);
                });
            }

            return(sourceData);
        }
        private void InteractionManager_InteractionSourceUpdated(InteractionSourceUpdatedEventArgs args)
        {
            //Vector3 p;
            //args.state.sourcePose.TryGetPosition(out p);
            SourceData sourceData = GetOrAddSourceData(args.state.source);

            sourceData.ResetUpdatedBooleans();

            UpdateSourceData(args.state, sourceData);

            if (sourceData.PositionUpdated)
            {
                InputManager.Instance.RaiseSourcePositionChanged(this, sourceData.SourceId, sourceData.PointerPosition.CurrentReading, sourceData.GripPosition.CurrentReading);
            }

            if (sourceData.RotationUpdated)
            {
                InputManager.Instance.RaiseSourceRotationChanged(this, sourceData.SourceId, sourceData.PointerRotation.CurrentReading, sourceData.GripRotation.CurrentReading);
            }

            if (sourceData.ThumbstickPositionUpdated)
            {
                InputManager.Instance.RaiseInputPositionChanged(this, sourceData.SourceId, InteractionSourcePressInfo.Thumbstick, sourceData.Thumbstick.CurrentReading.Position);
            }

            if (sourceData.TouchpadPositionUpdated)
            {
                InputManager.Instance.RaiseInputPositionChanged(this, sourceData.SourceId, InteractionSourcePressInfo.Touchpad, sourceData.Touchpad.CurrentReading.AxisButton.Position);
            }

            if (sourceData.TouchpadTouchedUpdated)
            {
                if (sourceData.Touchpad.CurrentReading.Touched)
                {
                    InputManager.Instance.RaiseTouchpadTouched(this, sourceData.SourceId);
                }
                else
                {
                    InputManager.Instance.RaiseTouchpadReleased(this, sourceData.SourceId);
                }
            }

            if (sourceData.SelectPressedAmountUpdated)
            {
                InputManager.Instance.RaiseSelectPressedAmountChanged(this, sourceData.SourceId, sourceData.Select.CurrentReading.PressedAmount);
            }
        }
    void getSourceList()
    {
        var lBSTR = getCollectionOfSources();

        string lxmldoc = Marshal.PtrToStringBSTR(lBSTR);

        Marshal.FreeBSTR(lBSTR);

        XmlDocument doc = new XmlDocument();

        doc.LoadXml(lxmldoc);

        var lSourceNodes = doc.SelectNodes("Sources/Source");

        if (lSourceNodes == null)
        {
            return;
        }

        mSourceDataList.Clear();

        foreach (var item in lSourceNodes)
        {
            XmlNode lSourceNode = item as XmlNode;

            if (lSourceNode != null)
            {
                var lFriendlyNameAttr = lSourceNode.SelectSingleNode("Source.Attributes/Attribute[@Name='MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME']/SingleValue/@Value");

                var lSymbolicLinkAttr = lSourceNode.SelectSingleNode("Source.Attributes/Attribute[@Name='MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK']/SingleValue/@Value");

                if (lSymbolicLinkAttr != null)
                {
                    var lSourceData = new SourceData();

                    lSourceData.mFriendlyName = lFriendlyNameAttr.Value;

                    lSourceData.mSymbolicLink = lSymbolicLinkAttr.Value;

                    lSourceData.mSourceNode = lSourceNode;

                    mSourceDataList.Add(lSourceData);
                }
            }
        }
    }
Esempio n. 10
0
        private void SetSourceDataInternal(
            SourceData newSd,
            SourceDataFileDescriptor newSdFileDescriptor,
            SourceDataChangesCache newSdChangesCache,
            bool newIsSdCorrect)
        {
            var newSdFileDescriptorDiffer = SetSourceDataFileDescriptor(newSdFileDescriptor);
            var newSdChangesCacheDiffer   = SetSourceDataChangesCache(newSdChangesCache);
            var newSdDiffer = true;

            if (newSd == null)
            {
                if (newSdFileDescriptor == null)
                {
                    if (SourceData == null)
                    {
                        newSdDiffer = false;
                    }
                }
                else if (newSdFileDescriptorDiffer)
                {
                    LoadSourceDataFromFile(_sourceDataFileDescriptor, false, out newSd);
                }
                else
                {
                    newSdDiffer = false;
                }
            }
            if (newSdDiffer || newSdChangesCacheDiffer)
            {
                if (SourceData != null)
                {
                    UnsubscribeFromSourceDataChanges();
                }
                if (newSdDiffer)
                {
                    SourceData = newSd;
                }
                if (SourceData != null)
                {
                    _sourceDataChangesCache.ApplyChanges(SourceData);
                    SubscribeToSourceDataChanges();
                }
            }
            _isSourceDataCorrect = newIsSdCorrect;
        }
Esempio n. 11
0
            public Menus(Activity activity, SourceData source, string sourceType)
            {
                _activity = activity;
                var authorization = activity.GetAuthorization(source.SourceId, source.SourceType);

                //if (activity.HiddenFor(source)) { }
                // _list.Add("un_hide"); //TODO the response of unhide make error on client
                if (activity.EffectiveSubjetType == "sitepage_page")
                {
                    _list.Add("hide");
                }

                if (activity.IsPrimaryOrShare)
                {
                    if ((authorization & (ushort)AuthorizationFlags.Edit) > 0)
                    {
                        _list.Add("edit_feed");
                    }
                    if ((authorization & (ushort)AuthorizationFlags.Delete) > 0)
                    {
                        _list.Add("delete");
                    }
                    if ((authorization & (ushort)AuthorizationFlags.DisableComments) > 0)
                    {
                        if (activity.RawActivity.commentable)
                        {
                            _list.Add("disable_comment");
                        }
                        else
                        {
                            _list.Add("un_disable_comment");
                        }
                    }
                    if ((authorization & (ushort)AuthorizationFlags.DisableShares) > 0)
                    {
                        if (activity.RawActivity.shareable)
                        {
                            _list.Add("lock_this_feed");
                        }
                        else
                        {
                            _list.Add("un_lock_this_feed");
                        }
                    }
                }
            }
Esempio n. 12
0
    private ES_NamespaceData?GetNamespace(SourceData src, ES_AstNodeBounds nodeBounds, ReadOnlySpan <char> namespaceStr)
    {
        var namespaceName = Environment !.IdPool.GetIdentifier(namespaceStr);

        if (!Environment !.Namespaces.TryGetValue(namespaceName, out var namespaceData))
        {
            var err = ES_FrontendErrors.GenNamespaceDoesntExist(
                namespaceStr.GetPooledString(),
                src,
                nodeBounds
                );
            errorList.Add(err);
            return(null);
        }

        return(namespaceData);
    }
Esempio n. 13
0
        private static void TestMappingToDataRow(SourceData.PersonRow sourceRow)
        {
            DestinationData.PersonDataTable destinationDataTable = new DestinationData.PersonDataTable();
            DestinationData.PersonRow destinationRow = destinationDataTable.NewPersonRow();

            AutoMapper.Mapper.CreateMap<SourceData.PersonRow, DestinationData.PersonRow>()
                //with this ForMember, every FirstName should be "First!"
                .ForMember(src => src.FirstName, opt => opt.MapFrom<string>(src => "First!"))

                //!!don't map property ItemArray from DataRow!!
                .ForMember(src => src.ItemArray, opt => opt.Ignore());

            AutoMapper.Mapper.Map<SourceData.PersonRow, DestinationData.PersonRow>(sourceRow, destinationRow);

            //!!this assertion will fail unless you use opt.Ignore() for ItemArray!!
            Debug.Assert(destinationRow.FirstName.Equals("First!"), "datarow mapping failed");
        }
        public ActionResult Delete(int id)
        {
            // Récupération des voitures sources
            List <Voiture> voitures = SourceData.Voitures();

            // Vérification si la voiture à supprimer est trouvée sinon return 404 NOT FOUND
            if (!voitures.Any(v => v.Id == id))
            {
                return(NotFound());
            }

            // Suppression de la voiture en fonction de son identifiant dans la liste de voitures source.
            voitures.RemoveAll(v => v.Id == id);

            // Réponse OK mais vide.
            return(Ok());
        }
        /// <summary>
        /// Update the source data for the currently detected sources.
        /// </summary>
        private void UpdateSourceData()
        {
#if UNITY_WSA
            // Poll for updated reading from hands
            InteractionSourceState[] sourceStates = InteractionManager.GetCurrentReading();
            if (sourceStates != null)
            {
                for (var i = 0; i < sourceStates.Length; ++i)
                {
                    InteractionSourceState handSource = sourceStates[i];
                    SourceData             sourceData = GetOrAddSourceData(handSource.source);
                    currentSources.Add(handSource.source.id);

                    UpdateSourceState(handSource, sourceData);
                }
            }
#endif
        }
Esempio n. 16
0
        public SourceData Insert(SourceData data)
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.ApplicationConnection, false))
            {
                var source = new Source();

                DataMapper.Map(data, source);

                ctx.ObjectContext.AddToSources(source);

                ctx.ObjectContext.SaveChanges();

                data.SourceId = source.SourceId;

                return(data);
            }
        }
Esempio n. 17
0
        public void ObjectMapReverse() {
            using(new OperationTimer("Object Map Reverse")) {
                foreach(var target in TargetDatas) {
                    var source = new SourceData();

                    ObjectMapper.Map(target, source, true, true, new[] { "DataOnly" });

                    Assert.AreEqual(source.Id, target.Id, "Id가 매핑되지 않았습니다.");
                    Assert.AreEqual(source.Name, target.Name, "Name이 매핑되지 않았습니다.");
                    Assert.AreEqual(source.Guid, target.Guid);
                    Assert.AreEqual(source.CreatedDate, target.CreatedDate);
                    Assert.AreEqual(source.ElapsedTimeSpan, target.ElapsedTimeSpan);
                    Assert.AreEqual(source.NumberLong.GetValueOrDefault(), (float)target.NumberLong.GetValueOrDefault());

                    Assert.AreNotEqual(source.DataOnly, target.OtherDataOnly);
                }
            }
        }
Esempio n. 18
0
 private static void InitializeSourceRow(SourceData.PersonRow sourceRow)
 {
     //initialize the row - this is to avoid DBNull errors during mapping
     //these errors can be avoided using features of AutoMapper but I
     //wanted to keep this sample simple
     sourceRow.BusinessEntityID = 0;
     sourceRow.PersonType = "";
     sourceRow.NameStyle = false;
     sourceRow.MiddleName = "";
     sourceRow.LastName = "";
     sourceRow.Title = "";
     sourceRow.Suffix = "";
     sourceRow.FirstName = "";
     sourceRow.EmailPromotion = 0;
     sourceRow.Demographics = "";
     sourceRow.rowguid = Guid.Empty;
     sourceRow.ModifiedDate = DateTime.MinValue;
     sourceRow.AdditionalContactInfo = "";
 }
        public static void GetRCSource(Project project, List <Program> programs, List <Tester> testers, out List <SourceData> SDList)
        {
            var trs = programs.Select(o => o.Recipes.Select(i => i.TestRecords.Where(j => j.Status == TestStatus.Completed).ToList()).ToList()).ToList();
            List <TestRecord> testRecords = new List <TestRecord>();

            foreach (var tr in trs)
            {
                foreach (var t in tr)
                {
                    testRecords = testRecords.Concat(t).ToList();
                }
            }
            testRecords = testRecords.Where(o => o.Status == TestStatus.Completed).ToList();
            SDList      = new List <SourceData>();
            foreach (var tr in testRecords)
            {
                SourceData sd = new SourceData();
                sd.fAbsMaxCap     = project.AbsoluteMaxCapacity;
                sd.fCapacityDiff  = (float)tr.CapacityDifference;
                sd.fCurrent       = (float)tr.Current * (-1);
                sd.fCutoffDsgVolt = project.CutoffDischargeVoltage;
                sd.fLimitChgVolt  = project.LimitedChargeVoltage;
                sd.fMeasureGain   = (float)tr.MeasurementGain;
                sd.fMeasureOffset = (float)tr.MeasurementOffset;
                sd.fTemperature   = (float)tr.Temperature;
                sd.fTraceResis    = (float)tr.TraceResistance;
                var    tester = testers.SingleOrDefault(o => o.Name == tr.TesterStr);
                UInt32 result = tester.ITesterProcesser.LoadRawToSource(tr.TestFilePath, ref sd);
                if (result == ErrorCode.NORMAL)
                {
                    SDList.Add(sd);
                }
                //string filePath = Path.Combine("D:\\Issues\\Open\\BC_Lab\\Table Maker\\Francis 30Q Source Data", Path.GetFileName(tr.TestFilePath));
                //if (File.Exists(filePath))
                //{
                //    UInt32 result = tester.ITesterProcesser.LoadRawToSource(filePath, ref sd);
                //    if (result == ErrorCode.NORMAL)
                //    {
                //        SDList.Add(sd);
                //    }
                //}
            }
        }
Esempio n. 20
0
        public override void Edit()
        {
            if (ParameterList.Count > 0 && ParameterList[0].Value != null && ParameterList[0].Value.StartsWith("line", StringComparison.CurrentCultureIgnoreCase))
            {
                int lines = 0;
                if (!String.IsNullOrEmpty(SourceData))
                {
                    lines = SourceData.Split('\n').Length;
                }

                RespondToExe(String.Format("{0} lines", lines.ToString()));
            }
            else
            {
                RespondToExe(String.Format("{0} characters", SourceData.Length.ToString()));
            }
            //note: this particular edit doesn't change the sourcedata
            //that is on purpose
        }
Esempio n. 21
0
        public IXObject UpdateInPlace(IXObject pict, SourceData data, IXDrawing drw)
        {
            var skPict = (ISketchPicture)((ISwObject)pict).Dispatch;

            double width  = -1;
            double height = -1;
            double x      = -1;
            double y      = -1;

            skPict.GetSize(ref width, ref height);
            skPict.GetOrigin(ref x, ref y);

            using (var freeze = new ViewFreeze(drw))
            {
                DeletePicture(pict, drw);

                return(InsertAt(drw, data, width, height, x, y));
            }
        }
Esempio n. 22
0
        private bool AddSource(SourceData source, List <SourceData> list = null)
        {
            if (source == null)
            {
                return(false);
            }
            string key = $"{source.SourceType}:{source.SourceId}";

            if (_sources.ContainsKey(key))
            {
                return(false);
            }
            _sources[key] = source;
            if (list != null)
            {
                list.Add(source);               //if list is given
            }
            return(true);
        }
Esempio n. 23
0
        public async override Task <SourceData> GetData()
        {
            var pelletsHelper = new PelletsHelper(_harvesterSettings.PelletsUnitUri);
            var pelletsData   = await pelletsHelper.GetPelletsData(30);

            var dataItems = new List <DataItem>
            {
                new DataItem
                {
                    Id    = "supplies",
                    Type  = DataItemType.Integer,
                    Label = "Lager (kg)",
                    Value = pelletsData.SuppliesKg
                }
            };

            if (pelletsData.Errors != null)
            {
                foreach (var error in pelletsData.Errors)
                {
                    dataItems.Add(
                        new DataItem
                    {
                        Id    = "error",
                        Type  = DataItemType.Text,
                        Label = error.ErrorTypeRaw,
                        Value = error.Message + ": " + error.Description
                    }
                        );
                }
            }

            var sourceData = new SourceData
            {
                Id           = Guid.NewGuid().ToString(),
                SourceId     = "pellets",
                TimeStampUtc = DateTimeOffset.UtcNow,
                DataItems    = dataItems.ToArray()
            };

            return(sourceData);
        }
Esempio n. 24
0
        public Task UpdateGraphData(SourceData data, CancellationToken stoppingToken)
        {
            var countries  = new List <Country>();
            var sourceData = JsonConvert.DeserializeObject <SourceData>(sourceDataJson);
            var geoIds     = sourceData.Records.Select(o => o.GeoId.ToLowerInvariant()).Distinct();

            foreach (var geoId in geoIds)
            {
                var firstMatch = sourceData.Records.FirstOrDefault(o => o.GeoId.Equals(geoId, StringComparison.InvariantCultureIgnoreCase));
                var country    = new Country
                {
                    GeoId                   = firstMatch.GeoId,
                    CasesBucket             = buckets.FirstOrDefault(oo => oo.Name == firstMatch.CasesBucket),
                    DeathsBucket            = buckets.FirstOrDefault(oo => oo.Name == firstMatch.DeathsBucket),
                    CountriesAndTerritories = firstMatch.CountriesAndTerritories,
                    FocusCountry            = firstMatch.FocusCountry,
                    PopData2018             = firstMatch.PopData2018?.Length > 0 ? Convert.ToInt32(firstMatch.PopData2018) : 0,
                };
                countries.Add(country);
                var records = sourceData.Records.Where(o => o.GeoId.Equals(firstMatch.GeoId, StringComparison.InvariantCultureIgnoreCase));
                foreach (var record in records)
                {
                    var countryRecord = new CountryRecord
                    {
                        GeoId          = firstMatch.GeoId,
                        Date           = record.Date,
                        Day            = Convert.ToInt32(record.Day),
                        Month          = Convert.ToInt32(record.Month),
                        Year           = Convert.ToInt32(record.Year),
                        Cases          = record.CasesNumber,
                        Deaths         = record.DeathsNumber,
                        CasesToDate    = record.CasesToDate,
                        DeathsToDate   = record.DeathsToDate,
                        DaysWithCases  = record.DaysWithCases,
                        DaysWithDeaths = record.DaysWithDeaths,
                    };
                    country.Records.Add(countryRecord);
                }
            }
            this.countries = countries;
            return(Task.CompletedTask);
        }
Esempio n. 25
0
        internal SourceEditorDialog(SourceData source)
        {
            InitializeComponent();
            DialogResult = DialogResult.Cancel;

            Text                 = Language.SourceEditorDialog.Text;
            labelName.Text       = Language.SourceEditorDialog.LabelName;
            checkBoxEnabled.Text = Language.SourceEditorDialog.CheckBoxEnabled;
            labelSourceType.Text = Language.SourceEditorDialog.LabelSourceType;
            labelComponent.Text  = Language.SourceEditorDialog.LabelComponent;
            labelCenter.Text     = Language.SourceEditorDialog.LabelCenter;
            labelSize.Text       = Language.SourceEditorDialog.LabelSize;
            labelAmplitude.Text  = Language.SourceEditorDialog.LabelAmplitude;
            labelWavelength.Text = Language.SourceEditorDialog.LabelWavelength;
            labelStartTime.Text  = Language.SourceEditorDialog.LabelStartTime;
            labelEndTime.Text    = Language.SourceEditorDialog.LabelEndTime;
            labelWidth.Text      = Language.SourceEditorDialog.LabelWidth;
            buttonOK.Text        = Language.DialogGeneral.ButtonOK;
            buttonCancel.Text    = Language.DialogGeneral.ButtonCancel;

            comboBoxSourceType.DataSource = Enum.GetValues(typeof(SourceData.SourceType));
            comboBoxComponent.Items.Add(MeepManager.WaveguideDesigner.Component.Ex);
            comboBoxComponent.Items.Add(MeepManager.WaveguideDesigner.Component.Ey);
            comboBoxComponent.Items.Add(MeepManager.WaveguideDesigner.Component.Ez);
            comboBoxComponent.Items.Add(MeepManager.WaveguideDesigner.Component.Hx);
            comboBoxComponent.Items.Add(MeepManager.WaveguideDesigner.Component.Hy);
            comboBoxComponent.Items.Add(MeepManager.WaveguideDesigner.Component.Hz);

            Source = new SourceData(source);
            textBoxName.DataBindings.Add("Text", Source, "Name");
            checkBoxEnabled.DataBindings.Add("Enabled", Source, "Enabled");
            comboBoxSourceType.DataBindings.Add("SelectedItem", Source, "Type");
            comboBoxComponent.DataBindings.Add("SelectedItem", Source, "Component");
            vectorEditorCenter.DataBindings.Add("Value", Source, "Center");
            vectorEditorSize.DataBindings.Add("Value", Source, "Size");
            numericUpDownAmplitude.DataBindings.Add("Value", this, "Source_Amplitude");
            numericUpDownWavelength.DataBindings.Add("Value", this, "Source_Wavelength");
            numericUpDownStartTime.DataBindings.Add("Value", this, "Source_StartTime");
            numericUpDownEndTime.DataBindings.Add("Value", this, "Source_EndTime");
            checkBoxEndTimeInfinity.DataBindings.Add("Checked", this, "Source_IsEndTimeInfinity");
            numericUpDownWidth.DataBindings.Add("Value", this, "Source_Width");
        }
Esempio n. 26
0
    private FacebookPostStatus ComposeStatus(SourceData sourceData)
    {
        if (sourceData == null)
        {
            return(null);
        }

        const int maxFacebookStatusText = 2000;

        // Build Facebook Status
        var statusText = sourceData.SourceSystem switch
        {
            nameof(SourceSystems.SyndicationFeed) => sourceData.UpdatedOnDate > sourceData.PublicationDate
                ? "Updated Blog Post: "
                : "New Blog Post: ",
            nameof(SourceSystems.YouTube) => sourceData.UpdatedOnDate > sourceData.PublicationDate
                ? "Updated Video: "
                : "New Video: ",
            _ => ""
        };

        var url         = sourceData.ShortenedUrl ?? sourceData.Url;
        var postTitle   = sourceData.Title;
        var hashTagList = HashTagList(sourceData.Tags);

        if (statusText.Length + url.Length + postTitle.Length + 3 + hashTagList.Length >= maxFacebookStatusText)
        {
            var newLength = maxFacebookStatusText - statusText.Length - url.Length - hashTagList.Length - 1;
            postTitle = postTitle.Substring(0, newLength - 4) + "...";
        }

        var facebookPostStatus = new FacebookPostStatus
        {
            StatusText = $"{statusText} {postTitle} {hashTagList}",
            LinkUri    = url
        };

        _logger.LogDebug(
            "Composed Facebook Status: StatusText='{facebookPostStatus.StatusText}', LinkUrl='{facebookPostStatus.LinkUri}'",
            facebookPostStatus.StatusText, facebookPostStatus.LinkUri);
        return(facebookPostStatus);
    }
Esempio n. 27
0
 public HttpResponseMessage Get()
 {
     try
     {
         List <WebEntityModel> entitys = SourceData.GetAll().ToList();
         if (entitys != null && entitys.Count > 0)
         {
             return(Request.CreateResponse(HttpStatusCode.OK, entitys));
         }
         else
         {
             return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Something Happend"));
         }
     }
     catch (Exception ex)
     {
         Logger.Fatal("getAllEntitys function in EntityController" + ex.InnerException);
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Something Happend" + ex.InnerException.ToString()));
     }
 }
Esempio n. 28
0
        public void ObjectMapReverse()
        {
            using (new OperationTimer("Object Map Reverse")) {
                foreach (var target in TargetDatas)
                {
                    var source = new SourceData();

                    ObjectMapper.Map(target, source, true, true, new[] { "DataOnly" });

                    Assert.AreEqual(source.Id, target.Id, "Id가 매핑되지 않았습니다.");
                    Assert.AreEqual(source.Name, target.Name, "Name이 매핑되지 않았습니다.");
                    Assert.AreEqual(source.Guid, target.Guid);
                    Assert.AreEqual(source.CreatedDate, target.CreatedDate);
                    Assert.AreEqual(source.ElapsedTimeSpan, target.ElapsedTimeSpan);
                    Assert.AreEqual(source.NumberLong.GetValueOrDefault(), (float)target.NumberLong.GetValueOrDefault());

                    Assert.AreNotEqual(source.DataOnly, target.OtherDataOnly);
                }
            }
        }
Esempio n. 29
0
        protected override void DataPortal_Update()
        {
            using (var dalManager = DataFactoryManager.GetManager())
            {
                var dalFactory = dalManager.GetProvider <ISourceDataFactory>();

                var data = new SourceData();

                using (this.BypassPropertyChecks)
                {
                    this.ModifiedDate = DateTime.Now;

                    this.Update(data);

                    data = dalFactory.Update(data);
                }

                // this.FieldManager.UpdateChildren(data);
            }
        }
Esempio n. 30
0
 public HttpResponseMessage Get(Guid id)
 {
     try
     {
         var entity = SourceData.GetEntityById(id);
         if (entity == null)
         {
             return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "No Entity With That Id" + id.ToString() + "found"));
         }
         else
         {
             return(Request.CreateResponse(HttpStatusCode.OK, entity));
         }
     }
     catch (Exception ex)
     {
         Logger.Fatal("getEntityById function in EntityController" + ex.InnerException);
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Error"));
     }
 }
Esempio n. 31
0
        /// <summary>
        /// Updates the source positional information.
        /// </summary>
        /// <param name="interactionSource">Interaction source to use to update the position.</param>
        /// <param name="sourceData">SourceData structure to update.</param>
        private void UpdateSourceState(InteractionSourceState interactionSource, SourceData sourceData)
        {
            sourceData.Position.IsAvailable = interactionSource.sourcePose.TryGetPosition(out sourceData.Position.CurrentReading);

            // Using a heuristic for IsSupported, since the APIs don't yet support querying this capability directly.
            sourceData.Position.IsSupported |= sourceData.Position.IsAvailable;

            sourceData.Orientation.IsAvailable = interactionSource.sourcePose.TryGetRotation(out sourceData.Orientation.CurrentReading);
            // Using a heuristic for IsSupported, since the APIs don't yet support querying this capability directly.
            sourceData.Orientation.IsSupported |= sourceData.Orientation.IsAvailable;

            sourceData.PointingRay.IsSupported = interactionSource.source.supportsPointing;
            sourceData.PointingRay.IsAvailable = false;// interactionSource.sourcePose.TryGetRay(out sourceData.PointingRay.CurrentReading);

            // TODO: Update other information we want to keep cached (touchpad position? trigger reading? thumbstick position?)

            // Check for source presses
            if (interactionSource.anyPressed != sourceData.IsSourceDownPending)
            {
                sourceData.IsSourceDownPending    = interactionSource.anyPressed;
                sourceData.SourceStateUpdateTimer = SourcePressDelay;
            }

            // Source presses are delayed to mitigate issue with hand position shifting during air tap
            sourceData.SourceStateChanged = false;
            if (sourceData.SourceStateUpdateTimer >= 0)
            {
                float deltaTime = UseUnscaledTime
                    ? Time.unscaledDeltaTime
                    : Time.deltaTime;

                sourceData.SourceStateUpdateTimer -= deltaTime;
                if (sourceData.SourceStateUpdateTimer < 0)
                {
                    sourceData.IsSourceDown       = sourceData.IsSourceDownPending;
                    sourceData.SourceStateChanged = true;
                }
            }

            SendSourceStateEvents(sourceData);
        }
Esempio n. 32
0
    private ES_AstTypeDeclaration_TypeReference GenerateASTTypeRef(
        ArrayPointer <byte> transUnitName, SymbolStack <FrontendSymbol> symbols, SourceData src,
        ES_AstTypeDeclaration typeDecl
        )
    {
        Debug.Assert(typeDecl is not null);

        if (typeDecl is ES_AstTypeDeclaration_TypeReference)
        {
            return((typeDecl as ES_AstTypeDeclaration_TypeReference) !);
        }

        var type = ResolveTypeDeclaration(transUnitName, symbols, src, typeDecl);

        if (type == null)
        {
            type = Environment !.TypeUnknownValue;
        }

        return(new ES_AstTypeDeclaration_TypeReference(typeDecl, type));
    }
Esempio n. 33
0
        public HttpResponseMessage Delete(Guid id)
        {
            try
            {
                bool isSuccess = SourceData.DeleteEntity(id);

                if (isSuccess)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Entity With id:" + id + " Dont Exsist"));
                }
            }
            catch (Exception ex)
            {
                Logger.Fatal("DeleteEntity function in EntityController" + ex.InnerException);
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Something Happend" + ex.InnerException.ToString()));
            }
        }
Esempio n. 34
0
        public SourceData Update(SourceData data)
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.ApplicationConnection, false))
            {
                var source =
                    new Source
                {
                    SourceId     = data.SourceId,
                    SourceTypeId = data.SourceTypeId
                };

                ctx.ObjectContext.Sources.Attach(source);

                DataMapper.Map(data, source);

                ctx.ObjectContext.SaveChanges();

                return(data);
            }
        }
Esempio n. 35
0
        public HttpResponseMessage Put(Guid id, [FromBody] EntityModel value)
        {
            try
            {
                bool isSuccess = SourceData.UpdateEntity(id, value);

                if (isSuccess)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, value));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "No Such Entity With id: " + id.ToString() + " Was Found"));
                }
            }
            catch (Exception ex)
            {
                Logger.Fatal("updateEntity function in EntityController" + ex.InnerException);
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.InnerException.ToString()));
            }
        }
        /// <summary>
        /// Updates the source positional information.
        /// </summary>
        /// <param name="interactionSource">Interaction source to use to update the position.</param>
        /// <param name="sourceData">SourceData structure to update.</param>
        private void UpdateSourceState(InteractionSourceState interactionSource, SourceData sourceData)
        {
            // Update source position
            Vector3 sourcePosition;

            if (interactionSource.properties.location.TryGetPosition(out sourcePosition))
            {
                sourceData.HasPosition    = true;
                sourceData.SourcePosition = sourcePosition;
            }

            // Check for source presses
            if (interactionSource.pressed != sourceData.IsSourceDownPending)
            {
                sourceData.IsSourceDownPending    = interactionSource.pressed;
                sourceData.SourceStateUpdateTimer = SourcePressDelay;
            }

            float time = UseUnscaledTime
                ? Time.unscaledTime
                : Time.time;

            float deltaTime = UseUnscaledTime
                ? Time.unscaledDeltaTime
                : Time.deltaTime;

            // Source presses are delayed to mitigate issue with hand position shifting during air tap
            sourceData.SourceStateChanged = false;
            if (sourceData.SourceStateUpdateTimer >= 0)
            {
                sourceData.SourceStateUpdateTimer -= deltaTime;
                if (sourceData.SourceStateUpdateTimer < 0)
                {
                    sourceData.IsSourceDown       = sourceData.IsSourceDownPending;
                    sourceData.SourceStateChanged = true;
                }
            }

            SendSourceStateEvents(sourceData, time);
        }
Esempio n. 37
0
 /// <summary>
 /// Clone a source data class for a new created source
 /// </summary>
 /// <param name="sd"></param>
 private void Clone(SourceData sd)
 {
     sd.ER      = _sd.ER;
     sd.ER_dep  = _sd.ER_dep;
     sd.X1      = _sd.X1;
     sd.Y1      = _sd.Y1;
     sd.Z1      = _sd.Z1;
     sd.X2      = _sd.X2;
     sd.Y2      = _sd.Y2;
     sd.Z2      = _sd.Z2;
     sd.V       = _sd.V;
     sd.D       = _sd.D;
     sd.T       = _sd.T;
     sd.SG      = _sd.SG;
     sd.Vsed    = _sd.Vsed;
     sd.Vdep    = _sd.Vdep;
     sd.Mode    = _sd.Mode;
     sd.VertExt = _sd.VertExt;
     sd.Width   = _sd.Width;
     sd.TimeSeriesTemperature = _sd.TimeSeriesTemperature;
     sd.TimeSeriesVelocity    = _sd.TimeSeriesVelocity;
 }
Esempio n. 38
0
        public SourceData[] FetchLookupInfoList(SourceDataCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                          .GetManager(Database.ApplicationConnection, false))
            {
                var sources = this.Fetch(ctx, criteria)
                    .AsEnumerable();

                var sourceDataList = new List<SourceData>();

                foreach (var source in sources)
                {
                    var sourceData = new SourceData();

                    this.Fetch(source, sourceData);

                    sourceDataList.Add(sourceData);
                }

                return sourceDataList.ToArray();
            }
        }
Esempio n. 39
0
 /// <summary>
 /// Invoked when the user clicks to ignore a track.
 /// </summary>
 /// <param name="sender">The sender of the event</param>
 /// <param name="e">The event data</param>
 public void IgnoreFile_Click(object sender, RoutedEventArgs e)
 {
     Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog dialog = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog();
     Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult result = dialog.ShowDialog();
     if (result == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.OK)
     {
         if (FilesystemManager.PathIsIgnored(dialog.FileName))
             MessageBox.Show(
                 U.T("MessageAlreadyAddedSource", "Message"),
                 U.T("MessageAlreadyAddedSource", "Title"),
                 MessageBoxButton.OK, MessageBoxImage.Information);
         else
         {
             SourceData s = new SourceData();
             s.Data = dialog.FileName;
             s.Type = SourceType.File;
             s.Ignore = true;
             s.Icon = "pack://application:,,,/Platform/Windows 7/GUI/Images/Icons/FileAudio.ico";
             FilesystemManager.AddSource(s);
         }
     }
 }
 /// <summary>
 /// Sends the events for source state changes.
 /// </summary>
 /// <param name="sourceData">Source data for which events should be sent.</param>
 private void SendSourceStateEvents(SourceData sourceData)
 {
     // Source pressed/released events
     if (sourceData.SourceStateChanged)
     {
         if (sourceData.IsSourceDown)
         {
             RaiseSourceDownEvent(sourceData.InputSourceArgs);
         }
         else
         {
             RaiseSourceUpEvent(sourceData.InputSourceArgs);
         }
     }
 }
        /// <summary>
        /// Updates the source positional information.
        /// </summary>
        /// <param name="interactionSource">Interaction source to use to update the position.</param>
        /// <param name="sourceData">SourceData structure to update.</param>
        private void UpdateSourceState(InteractionSourceState interactionSource, SourceData sourceData)
        {
            // Update source position
            Vector3 sourcePosition;
            if (interactionSource.properties.location.TryGetPosition(out sourcePosition))
            {
                sourceData.HasPosition = true;
                sourceData.SourcePosition = sourcePosition;
            }

            // Check for source presses
            if (interactionSource.pressed != sourceData.IsSourceDownPending)
            {
                sourceData.IsSourceDownPending = interactionSource.pressed;
                sourceData.SourceStateUpdateTimer = SourcePressDelay;
            }

            // Source presses are delayed to mitigate issue with hand position shifting during air tap
            sourceData.SourceStateChanged = false;
            if (sourceData.SourceStateUpdateTimer >= 0)
            {
                sourceData.SourceStateUpdateTimer -= Time.deltaTime;
                if (sourceData.SourceStateUpdateTimer < 0)
                {
                    sourceData.IsSourceDown = sourceData.IsSourceDownPending;
                    sourceData.SourceStateChanged = true;
                }
            }

            SendSourceStateEvents(sourceData);
        }
Esempio n. 42
0
        public SourceData Update(SourceData data)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                         .GetManager(Database.ApplicationConnection, false))
            {
                var source =
                    new Source
                    {
                        SourceId = data.SourceId,
                        SourceTypeId = data.SourceTypeId
                    };

                ctx.ObjectContext.Sources.Attach(source);

                DataMapper.Map(data, source);

                ctx.ObjectContext.SaveChanges();

                return data;
            }
        }
        /// <summary>
        /// Gets the source data for the specified interaction source if it already exists, otherwise creates it.
        /// </summary>
        /// <param name="interactionSource">Interaction source for which data should be retrieved.</param>
        /// <returns>The source data requested.</returns>
        private SourceData GetOrAddSourceData(InteractionSource interactionSource)
        {
            SourceData sourceData;
            if (!sourceIdToData.TryGetValue(interactionSource.id, out sourceData))
            {
                sourceData = new SourceData(this, interactionSource.id);
                sourceIdToData.Add(sourceData.SourceId, sourceData);
                newSources.Add(sourceData.SourceId);
            }

            return sourceData;
        }
Esempio n. 44
0
        public static void Import(UTiledImportSettings settings) {
            String mapFilename = settings.MapFilename;
            XDocument input = XDocument.Load(mapFilename);
            
            String mapDirectory = Path.GetDirectoryName(mapFilename) + "/" + Path.GetFileNameWithoutExtension(mapFilename);
            String meshDirectory = mapDirectory + "/" + "meshes";
            String matDirectory = mapDirectory + "/" + "materials";

            if (!Directory.Exists(mapDirectory))
                Directory.CreateDirectory(mapDirectory);
            if (!Directory.Exists(meshDirectory))
                Directory.CreateDirectory(meshDirectory);
            if (!Directory.Exists(matDirectory))
                Directory.CreateDirectory(matDirectory);

            MapOrientation mapOrientation = MapOrientation.Unknown;
            switch (input.Document.Root.Attribute("orientation").Value) {
                case "orthogonal":
                    mapOrientation = MapOrientation.Orthogonal;
                    break;

                case "isometric":
                    mapOrientation = MapOrientation.Isometric;
                    break;

                case "staggered":
                    mapOrientation = MapOrientation.Staggered;
                    break;

                default:
                    mapOrientation = MapOrientation.Unknown;
                    break;
            }

            if (mapOrientation != MapOrientation.Orthogonal)
                throw new NotSupportedException("UTiled supports only orthogonal maps");

            String mapName = Path.GetFileNameWithoutExtension(mapFilename);
            Int32 mapWidth = Convert.ToInt32(input.Document.Root.Attribute("width").Value);
            Int32 mapHeight = Convert.ToInt32(input.Document.Root.Attribute("height").Value);
            Int32 mapTileWidth = Convert.ToInt32(input.Document.Root.Attribute("tilewidth").Value);
            Int32 mapTileHeight = Convert.ToInt32(input.Document.Root.Attribute("tileheight").Value);

            Dictionary<UInt32, SourceData> gid2sprite = new Dictionary<UInt32, SourceData>();
            Dictionary<String, List<UTiledProperty>> spriteprops = new Dictionary<string, List<UTiledProperty>>();
            List<String> imageList = new List<string>();

            GameObject mapGameObject = new GameObject();
            mapGameObject.name = mapName;

            if (input.Document.Root.Element("properties") != null) {
                UTiledProperties props = mapGameObject.AddComponent<UTiledProperties>();
                foreach (var pElem in input.Document.Root.Element("properties").Elements("property"))
                    props.Add(pElem.Attribute("name").Value, pElem.Attribute("value").Value);
            }

            Int32 tsNum = 1;
            foreach (var elem in input.Document.Root.Elements("tileset")) {
                UInt32 FirstGID = Convert.ToUInt32(elem.Attribute("firstgid").Value);
                XElement tsElem = elem;

                if (elem.Attribute("source") != null) {
                    XDocument tsx = XDocument.Load(Path.Combine(Path.GetDirectoryName(mapFilename), elem.Attribute("source").Value));
                    tsElem = tsx.Root;
                }

                List<UTiledProperty> tilesetProps = new List<UTiledProperty>();
                if (tsElem.Element("properties") != null)
                    foreach (var pElem in tsElem.Element("properties").Elements("property"))
                        tilesetProps.Add(new UTiledProperty() { Name = pElem.Attribute("name").Value, Value = pElem.Attribute("value").Value });

                Int32 tsTileWidth = tsElem.Attribute("tilewidth") == null ? 0 : Convert.ToInt32(tsElem.Attribute("tilewidth").Value);
                Int32 tsTileHeight = tsElem.Attribute("tileheight") == null ? 0 : Convert.ToInt32(tsElem.Attribute("tileheight").Value);
                Int32 tsSpacing = tsElem.Attribute("spacing") == null ? 0 : Convert.ToInt32(tsElem.Attribute("spacing").Value);
                Int32 tsMargin = tsElem.Attribute("margin") == null ? 0 : Convert.ToInt32(tsElem.Attribute("margin").Value);

                Int32 tsTileOffsetX = 0;
                Int32 tsTileOffsetY = 0;
                if (tsElem.Element("tileoffset") != null) {
                    tsTileOffsetX = Convert.ToInt32(tsElem.Element("tileoffset").Attribute("x").Value);
                    tsTileOffsetY = Convert.ToInt32(tsElem.Element("tileoffset").Attribute("y").Value);
                }

                if (tsElem.Element("image") != null) {
                    XElement imgElem = tsElem.Element("image");
                    String tsImageFileName = Path.Combine(Path.GetDirectoryName(mapFilename), imgElem.Attribute("source").Value);

                    if (!File.Exists(tsImageFileName))
                        throw new Exception("Cannot find referenced tilesheet: " + tsImageFileName);

                    if (!imageList.Contains(tsImageFileName))
                        imageList.Add(tsImageFileName);

                    TextureImporter importer = (TextureImporter)AssetImporter.GetAtPath(tsImageFileName);
                    importer.textureType = TextureImporterType.Sprite;
                    importer.spriteImportMode = SpriteImportMode.Multiple;
                    importer.filterMode = FilterMode.Point;
                    importer.spritePixelsToUnits = 1f;

                    // Reflection Hack because this is a private method to get the non scaled size of the texture
                    object[] args = new object[2] { 0, 0 };
                    MethodInfo mi = typeof(TextureImporter).GetMethod("GetWidthAndHeight", BindingFlags.NonPublic | BindingFlags.Instance);
                    mi.Invoke(importer, args);
                    Int32 tsImageWidth = (int)args[0];
                    Int32 tsImageHeight = (int)args[1];
                    // yea, it's lame and should be a public method - vote for it here: 
                    // http://feedback.unity3d.com/suggestions/get-original-width-and-height-of

                    List<SpriteMetaData> spritesmeta = new List<SpriteMetaData>(importer.spritesheet);
                    UInt32 gid = FirstGID;

                    for (int y = tsImageHeight - tsTileHeight - tsMargin; y >= tsMargin; y -= tsTileHeight + tsSpacing) {
                        for (int x = tsMargin; x < tsImageWidth - tsMargin; x += tsTileWidth + tsSpacing) {
                            if (x + tsTileWidth > tsImageWidth - tsMargin)
                                continue;

                            SpriteMetaData s = new SpriteMetaData();
                            s.name = String.Format(String.Format("{0}_{1}_{2}", Path.GetFileNameWithoutExtension(mapFilename), tsNum, gid));
                            s.rect = new Rect(x, y, tsTileWidth, tsTileHeight);
                            s.pivot = new Vector2(tsTileWidth / 2, tsTileHeight / 2);
                            s.alignment = 0;

                            if (tilesetProps.Count > 0) {
                                spriteprops[s.name] = new List<UTiledProperty>();
                                foreach (var item in tilesetProps)
                                    spriteprops[s.name].Add(item);
                            }

                            if (spritesmeta.Any(sx => sx.name.Equals(s.name)))
                                spritesmeta.RemoveAll(sx => sx.name.Equals(s.name));

                            spritesmeta.Add(s);
                            gid2sprite[gid] = new SourceData() {
                                textureSize = new Vector2(tsImageWidth, tsImageHeight),
                                offsetX = tsTileOffsetX,
                                offsetY = tsTileOffsetY,
                                spriteName = s.name,
                            };
                            gid++;
                        }
                    }

                    foreach (var tileElem in tsElem.Elements("tile")) {
                        UInt32 id = Convert.ToUInt32(tileElem.Attribute("id").Value);
                        String spriteName = String.Format(String.Format("{0}_{1}_{2}", Path.GetFileNameWithoutExtension(mapFilename), tsNum, id + FirstGID));
                        if (tileElem.Element("properties") != null) {
                            if (!spriteprops.ContainsKey(spriteName))
                                spriteprops[spriteName] = new List<UTiledProperty>();

                            foreach (var pElem in tileElem.Element("properties").Elements("property"))
                                spriteprops[spriteName].Add(new UTiledProperty() { Name = pElem.Attribute("name").Value, Value = pElem.Attribute("value").Value });
                        }
                    }

                    importer.spritesheet = spritesmeta.ToArray();
                    AssetDatabase.WriteImportSettingsIfDirty(tsImageFileName);
                    AssetDatabase.LoadAssetAtPath(tsImageFileName, typeof(Texture2D));
                    AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
                }

                tsNum++;
            }

            List<UnityEngine.Object> sprites = new List<UnityEngine.Object>();
            foreach (var tsImageFileName in imageList)
                sprites.AddRange(AssetDatabase.LoadAllAssetRepresentationsAtPath(tsImageFileName));

            Int32 lCount = 1;
            float xoff = mapWidth * mapTileWidth - mapWidth * mapTileWidth / 2;
            float yoff = mapHeight * mapTileHeight - mapHeight * mapTileHeight / 2 + mapTileHeight;

            foreach (var lElem in input.Document.Root.Elements("layer")) {
                bool importMesh = false;
                bool importCollision = false;

                if (settings.TileLayerSettings.Length >= lCount) {
                    importCollision = settings.TileLayerSettings[lCount - 1].GenerateCollisionMesh;
                    importMesh = settings.TileLayerSettings[lCount - 1].GenerateRenderMesh;
                }

                if (!importMesh && !importCollision) {
                    lCount++;
                    continue;
                }

                GameObject layerGameObject = new GameObject();
                layerGameObject.transform.parent = mapGameObject.transform;

                layerGameObject.name = lElem.Attribute("name") == null ? "Unnamed" : lElem.Attribute("name").Value;
                float layerOpacity = lElem.Attribute("opacity") == null ? 1.0f : Convert.ToSingle(lElem.Attribute("opacity").Value);
                bool layerVisible = lElem.Attribute("visible") == null ? true : lElem.Attribute("visible").Equals("1");

                UTiledLayerSettings layerSettings = layerGameObject.AddComponent<UTiledLayerSettings>();
                layerSettings.sortingOrder = lCount;
                layerSettings.opacity = layerOpacity * 255f;

                EditorUtility.DisplayProgressBar("UTiled", "Generating Prefabs for " + settings.TileLayerSettings[lCount - 1].LayerName, (float)(lCount - 1) / settings.TileLayerSettings.Length);

                if (lElem.Element("properties") != null) {
                    UTiledProperties props = layerGameObject.AddComponent<UTiledProperties>();
                    foreach (var pElem in lElem.Element("properties").Elements("property"))
                        props.Add(pElem.Attribute("name").Value, pElem.Attribute("value").Value);
                }

                if (lElem.Element("data") != null) {
                    List<UInt32> gids = new List<UInt32>();
                    if (lElem.Element("data").Attribute("encoding") != null || lElem.Element("data").Attribute("compression") != null) {

                        // parse csv formatted data
                        if (lElem.Element("data").Attribute("encoding") != null && lElem.Element("data").Attribute("encoding").Value.Equals("csv")) {
                            foreach (var gid in lElem.Element("data").Value.Split(",\n\r".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
                                gids.Add(Convert.ToUInt32(gid));
                        }
                        else if (lElem.Element("data").Attribute("encoding") != null && lElem.Element("data").Attribute("encoding").Value.Equals("base64")) {
                            Byte[] data = Convert.FromBase64String(lElem.Element("data").Value);

                            if (lElem.Element("data").Attribute("compression") == null) {
                                // uncompressed data
                                for (int i = 0; i < data.Length; i += sizeof(UInt32)) {
                                    gids.Add(BitConverter.ToUInt32(data, i));
                                }
                            }
                            else {
                                throw new NotSupportedException(String.Format("Compression '{0}' not supported.", lElem.Element("data").Attribute("compression").Value));
                            }
                        }
                        else {
                            throw new NotSupportedException(String.Format("Encoding '{0}' not supported.  UTiled supports csv or base64", lElem.Element("data").Attribute("encoding").Value));
                        }
                    }
                    else {
                        // parse xml formatted data
                        foreach (var tElem in lElem.Element("data").Elements("tile"))
                            gids.Add(Convert.ToUInt32(tElem.Attribute("gid").Value));
                    }

                    List<MeshData> meshes = new List<MeshData>();
                    for (int i = 0; i < gids.Count; i++) {
                        UInt32 ID = gids[i] & ~(FLIPPED_HORIZONTALLY_FLAG | FLIPPED_VERTICALLY_FLAG | FLIPPED_DIAGONALLY_FLAG);

                        if (ID > 0) {
                            SourceData sd = gid2sprite[ID];
                            Sprite source = (Sprite)sprites.First(s => s.name.Equals(sd.spriteName));
                            String texFile = AssetDatabase.GetAssetPath(source.texture);

                            Boolean tdFlipHorizontally = Convert.ToBoolean(gids[i] & FLIPPED_HORIZONTALLY_FLAG);
                            Boolean tdFlipVertically = Convert.ToBoolean(gids[i] & FLIPPED_VERTICALLY_FLAG);
                            Boolean tdFlipDiagonally = Convert.ToBoolean(gids[i] & FLIPPED_DIAGONALLY_FLAG);

                            Int32 meshId = 0;
                            if (meshes.Any(m => m.materialName.Equals(texFile))) {
                                meshId = meshes.IndexOf(meshes.First(x => x.materialName.Equals(texFile)));
                            }
                            else {
                                meshes.Add(new MeshData() { materialName = texFile });
                                meshId = meshes.Count - 1;
                            }

                            int triStart = meshes[meshId].verts.Count;
                            meshes[meshId].tris.AddRange(new int[] { triStart, triStart + 1, triStart + 2, triStart + 2, triStart + 3, triStart });

                            for (int j = 0; j < 4; j++)
                                meshes[meshId].norms.Add(new Vector3(0, 0, -1));

                            if (mapOrientation == MapOrientation.Orthogonal) {
                                float x = i % mapWidth;
                                float y = mapHeight - Mathf.Floor(i / mapWidth) - 1;

                                Rect colLoc = new Rect(
                                    x * mapTileWidth - xoff,
                                    y * mapTileHeight + mapTileHeight - yoff,
                                    mapTileWidth,
                                    mapTileHeight
                                );

                                meshes[meshId].colverts.Add(new Vector3(colLoc.xMin, colLoc.yMax, 0));
                                meshes[meshId].colverts.Add(new Vector3(colLoc.xMax, colLoc.yMax, 0));
                                meshes[meshId].colverts.Add(new Vector3(colLoc.xMax, colLoc.yMin, 0));
                                meshes[meshId].colverts.Add(new Vector3(colLoc.xMin, colLoc.yMin, 0));

                                Vector3[] loc = new Vector3[] {
                                    new Vector3(x * mapTileWidth - xoff + sd.offsetX,  y * mapTileHeight + mapTileHeight - yoff + sd.offsetY + source.rect.height * sd.textureSize.y / source.texture.height),
                                    new Vector3(x * mapTileWidth - xoff + sd.offsetX + source.rect.width * sd.textureSize.x / source.texture.width, y * mapTileHeight + mapTileHeight - yoff + sd.offsetY + source.rect.height * sd.textureSize.y / source.texture.height),
                                    new Vector3(x * mapTileWidth - xoff + sd.offsetX + source.rect.width * sd.textureSize.x / source.texture.width,  y * mapTileHeight + mapTileHeight - yoff + sd.offsetY),
                                    new Vector3(x * mapTileWidth - xoff + sd.offsetX, y * mapTileHeight + mapTileHeight - yoff + sd.offsetY)
                                };

                                if (tdFlipDiagonally) {
                                    Vector3 pivot = new Vector3(loc[0].x + (loc[1].x - loc[0].x) / 2, loc[0].y + (loc[3].y - loc[0].y) / 2);
                                    for (int j = 0; j < loc.Length; j++) {
                                        Vector3 direction = pivot - loc[j];
                                        direction = Quaternion.Euler(new Vector3(0, 0, -90)) * direction;
                                        loc[j] = direction + pivot;
                                    }
                                    tdFlipVertically = !tdFlipVertically;
                                }
                                if (tdFlipHorizontally) {
                                    Vector3 temp = loc[0];
                                    loc[0] = loc[1];
                                    loc[1] = temp;

                                    temp = loc[3];
                                    loc[3] = loc[2];
                                    loc[2] = temp;
                                }
                                if (tdFlipVertically) {
                                    Vector3 temp = loc[0];
                                    loc[0] = loc[3];
                                    loc[3] = temp;

                                    temp = loc[1];
                                    loc[1] = loc[2];
                                    loc[2] = temp;
                                }

                                meshes[meshId].verts.AddRange(loc);
                            }

                            Rect uvRect = new Rect(
                                source.rect.x / source.texture.width,
                                source.rect.y / source.texture.height,
                                source.rect.width / source.texture.width,
                                source.rect.height / source.texture.height
                            );

                            meshes[meshId].uvs.AddRange(new Vector2[] {
                                new Vector2(uvRect.xMin, uvRect.yMax),
                                new Vector2(uvRect.xMax, uvRect.yMax),
                                new Vector2(uvRect.xMax, uvRect.yMin),
                                new Vector2(uvRect.xMin, uvRect.yMin)
                            });


                        }
                    }
                    List<MeshData> collMesh = new List<MeshData>();
                    collMesh.Add(new MeshData());
                    Int32 currentColMesh = 0;

                    for (int i = 0; i < meshes.Count; i++) {
                        String spriteMatFileName = String.Format("{0}/{1}-{2}.mat", matDirectory, layerGameObject.name, Path.GetFileNameWithoutExtension(meshes[i].materialName));
                        Material spriteMat = (Material)AssetDatabase.LoadAssetAtPath(spriteMatFileName, typeof(Material));

                        if (importMesh) {
                            if (spriteMat == null) {
                                spriteMat = new Material(Shader.Find("Sprites/Default"));
                                spriteMat.SetFloat("PixelSnap", 1);
                                spriteMat.EnableKeyword("PIXELSNAP_ON");
                                spriteMat.color = new Color(1, 1, 1, layerOpacity);
                                spriteMat.mainTexture = (Texture2D)AssetDatabase.LoadAssetAtPath(meshes[i].materialName, typeof(Texture2D));
                                AssetDatabase.CreateAsset(spriteMat, spriteMatFileName);
                            }
                            else {
                                spriteMat.SetFloat("PixelSnap", 1);
                                spriteMat.EnableKeyword("PIXELSNAP_ON");
                                spriteMat.color = new Color(1, 1, 1, layerOpacity);
                                spriteMat.mainTexture = (Texture2D)AssetDatabase.LoadAssetAtPath(meshes[i].materialName, typeof(Texture2D));
                                EditorUtility.SetDirty(spriteMat);
                            }
                        }

                        if (importCollision) {
                            for (int j = 0; j < meshes[i].colverts.Count; j += 4) {
                                if (collMesh[currentColMesh].colverts.Count >= 64997) {
                                    collMesh.Add(new MeshData());
                                    currentColMesh++;
                                }

                                Int32 v1, v2, v3, v4;
                                v1 = FindVertIndex(meshes[i].colverts[j], collMesh[currentColMesh].colverts);
                                if (v1 == -1) {
                                    collMesh[currentColMesh].colverts.Add(meshes[i].colverts[j]);
                                    collMesh[currentColMesh].norms.Add(meshes[i].norms[j]);
                                    collMesh[currentColMesh].uvs.Add(meshes[i].uvs[j]);
                                    v1 = collMesh[currentColMesh].colverts.Count - 1;
                                }

                                v2 = FindVertIndex(meshes[i].colverts[j + 1], collMesh[currentColMesh].colverts);
                                if (v2 == -1) {
                                    collMesh[currentColMesh].colverts.Add(meshes[i].colverts[j + 1]);
                                    collMesh[currentColMesh].norms.Add(meshes[i].norms[j + 1]);
                                    collMesh[currentColMesh].uvs.Add(meshes[i].uvs[j + 1]);
                                    v2 = collMesh[currentColMesh].colverts.Count - 1;
                                }

                                v3 = FindVertIndex(meshes[i].colverts[j + 2], collMesh[currentColMesh].colverts);
                                if (v3 == -1) {
                                    collMesh[currentColMesh].colverts.Add(meshes[i].colverts[j + 2]);
                                    collMesh[currentColMesh].norms.Add(meshes[i].norms[j + 2]);
                                    collMesh[currentColMesh].uvs.Add(meshes[i].uvs[j + 2]);
                                    v3 = collMesh[currentColMesh].colverts.Count - 1;
                                }

                                v4 = FindVertIndex(meshes[i].colverts[j + 3], collMesh[currentColMesh].colverts);
                                if (v4 == -1) {
                                    collMesh[currentColMesh].colverts.Add(meshes[i].colverts[j + 3]);
                                    collMesh[currentColMesh].norms.Add(meshes[i].norms[j + 3]);
                                    collMesh[currentColMesh].uvs.Add(meshes[i].uvs[j + 3]);
                                    v4 = collMesh[currentColMesh].colverts.Count - 1;
                                }

                                collMesh[currentColMesh].tris.AddRange(new int[] { v1, v2, v3, v3, v4, v1 });
                            }
                        }

                        if (importMesh) {
                            int totalMeshReq = Convert.ToInt32(Mathf.Ceil((float)meshes[i].verts.Count / 65000f));
                            for (int j = 0; j < totalMeshReq; j++) {

                                var verts = meshes[i].verts.Skip(j * 65000).Take(65000).ToArray();
                                var tris = meshes[i].tris.Skip(j * 97500).Take(97500).Select(t => t - j * 65000).ToArray();
                                var norms = meshes[i].norms.Skip(j * 65000).Take(65000).ToArray();
                                var uvs = meshes[i].uvs.Skip(j * 65000).Take(65000).ToArray();

                                GameObject layerMeshObject = new GameObject();
                                layerMeshObject.transform.parent = layerGameObject.transform;
                                layerMeshObject.name = String.Format("{0} - {1}", Path.GetFileNameWithoutExtension(meshes[i].materialName), j + 1);

                                MeshFilter filter = layerMeshObject.AddComponent<MeshFilter>();
                                MeshRenderer renderer = layerMeshObject.AddComponent<MeshRenderer>();

                                renderer.sortingOrder = lCount;
                                renderer.sharedMaterial = spriteMat;
                                renderer.castShadows = false;
                                renderer.receiveShadows = false;

                                String meshFileName = String.Format("{0}/{1}-{2}-{3}-{4}-{5}.asset", meshDirectory, layerGameObject.name,
                                                                    Path.GetFileNameWithoutExtension(meshes[i].materialName), lCount, i + 1, j + 1);
                                Mesh mesh = (Mesh)AssetDatabase.LoadAssetAtPath(meshFileName, typeof(Mesh));
                                if (mesh == null) {
                                    mesh = new Mesh() {
                                        vertices = verts,
                                        triangles = tris,
                                        normals = norms,
                                        uv = uvs,
                                    };
                                    AssetDatabase.CreateAsset(mesh, meshFileName);
                                }
                                else {
                                    mesh.Clear(false);
                                    mesh.vertices = verts;
                                    mesh.triangles = tris;
                                    mesh.normals = norms;
                                    mesh.uv = uvs;
                                    EditorUtility.SetDirty(mesh);
                                }

                                filter.mesh = mesh;
                            }
                        }
                    }

                    if (importCollision) {
                        for (int i = 0; i < collMesh.Count; i++) {
                            GameObject layerColMeshObject = new GameObject();
                            layerColMeshObject.transform.parent = layerGameObject.transform;
                            layerColMeshObject.name = String.Format("Collision Mesh - {0}", i + 1);

                            MeshFilter colFilter = layerColMeshObject.AddComponent<MeshFilter>();
                            MeshCollider collider = layerColMeshObject.AddComponent<MeshCollider>();

                            String colMeshFileName = String.Format("{0}/{1}-{2}-{3}-collision.asset", meshDirectory, layerGameObject.name, lCount, i + 1);
                            Mesh colMesh = (Mesh)AssetDatabase.LoadAssetAtPath(colMeshFileName, typeof(Mesh));

                            if (colMesh == null) {
                                colMesh = new Mesh() {
                                    vertices = collMesh[i].colverts.ToArray(),
                                    triangles = collMesh[i].tris.ToArray(),
                                    normals = collMesh[i].norms.ToArray(),
                                    uv = collMesh[i].uvs.ToArray(),
                                };
                                AssetDatabase.CreateAsset(colMesh, colMeshFileName);
                            }
                            else {
                                colMesh.Clear(false);
                                colMesh.vertices = collMesh[i].colverts.ToArray();
                                colMesh.triangles = collMesh[i].tris.ToArray();
                                colMesh.normals = collMesh[i].norms.ToArray();
                                colMesh.uv = collMesh[i].uvs.ToArray();
                                EditorUtility.SetDirty(colMesh);
                            }

                            colFilter.mesh = colMesh;
                            collider.sharedMesh = colMesh;
                        }
                    }
                }

                layerGameObject.SetActive(layerVisible);
                AssetDatabase.SaveAssets();
                lCount++;
            }

            String mapPrefapFile = mapDirectory + "/" + String.Format("{0}.prefab", mapName);
            GameObject mapPrefab = PrefabUtility.CreatePrefab(mapPrefapFile, mapGameObject);
            EditorUtility.SetDirty(mapPrefab);
            GameObject.DestroyImmediate(mapGameObject);

            AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
        }
 public SimpleName(Statement statement, FullNamedExpression left, string value, SourceData sourceData)
     : base(statement, left, sourceData)
 {
     Value = value;
 }
Esempio n. 46
0
 /// <summary>
 /// Invoked when the user clicks to ignore a folder.
 /// </summary>
 /// <param name="sender">The sender of the event</param>
 /// <param name="e">The event data</param>
 public void IgnoreFolder_Click(object sender, RoutedEventArgs e)
 {
     System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
     dialog.SelectedPath = dialogPath;
     System.Windows.Forms.DialogResult result = dialog.ShowDialog();
     if (result == System.Windows.Forms.DialogResult.OK)
     {
         if (FilesystemManager.PathIsIgnored(dialog.SelectedPath))
             MessageBox.Show(
                 U.T("MessageAlreadyAddedSource", "Message"),
                 U.T("MessageAlreadyAddedSource", "Title"),
                 MessageBoxButton.OK, MessageBoxImage.Information);
         else
         {
             SourceData s = new SourceData();
             s.Data = dialog.SelectedPath;
             s.Type = SourceType.Folder;
             s.Ignore = true;
             s.Icon = "pack://application:,,,/Platform/Windows 7/GUI/Images/Icons/Folder.ico";
             FilesystemManager.AddSource(s);
         }
     }
     dialogPath = dialog.SelectedPath;
 }
Esempio n. 47
0
        public SourceData Insert(SourceData data)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                           .GetManager(Database.ApplicationConnection, false))
            {
                var source = new Source();

                DataMapper.Map(data, source);

                ctx.ObjectContext.AddToSources(source);

                ctx.ObjectContext.SaveChanges();

                data.SourceId = source.SourceId;

                return data;
            }
        }
Esempio n. 48
0
 public static double LyricsSelector (SourceData data)
 {
     return data.LyricsTotal > 0 ? 1d - (double)data.LyricsFound / data.LyricsTotal : 0d;
 }
Esempio n. 49
0
    private string InitializeBaseMap(float width, float Height, string dbNId, string langCode, bool isSingleThemeMap, bool useMapServer)
    {
        if (Session["IsMapServer"] != null && Convert.ToBoolean(Session["IsMapServer"]))
        {
            bool usingMapServer = Convert.ToBoolean(Session["IsMapServer"]);
            if (usingMapServer)
            {
                langCode = Global.GetMapServerLangCode(langCode);
            }
        }
        string RetVal = string.Empty;
        string MapFileWPath = string.Empty;
        string TemplateStyleFolderPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Template);
        string LanguageFolderPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Language);
        string MapFolder = string.Empty;
        string DisputedBoundriesFolder = string.Empty;
        Map diMap = null;
        DataTable dtSessionData = null;
        DataTable SeriesDataTable = null;
        SeriesData seriesData = null;
        SourceData sourceData = new SourceData();
        string seriesID = string.Empty;
        string seriesName = string.Empty;
        string FilterText = string.Empty;
        bool isUpdateMap = true;

        string themeID = string.Empty;
        List<string> IUSName = null;
        bool isMrdColumnAdded = false;

        try
        {
            //First step To load map from session/ NewMap/ From preserved file
            this.SetTimeLogIntoFile("Get map Object-> " + DateTime.Now.ToLongTimeString());
            diMap = this.GetSessionMapObject(ref isUpdateMap, ref isMrdColumnAdded);
            diMap.IsMRDColumnAddedInTable = isMrdColumnAdded;
            diMap.UseMapServer = useMapServer;
            //diMap.CanvasColor = Color.Red;
           // diMap.MissingColor = Color.Black;

            if (diMap.Layers.Count > 0)
            {
                Layer layer = diMap.Layers[0];
                // diMap.Layers. = ly;
                // ly = Color.Blue;
            }
            if (isUpdateMap)
            {
                //2. Set datatable and areaNids
                dtSessionData = diMap.MapData;

                //get seriesData from session table
                this.SetTimeLogIntoFile("Get series Info-> " + DateTime.Now.ToLongTimeString());
                seriesData = this.GetSeriesInfo(diMap.MapDataColumns, dtSessionData, diMap.isMyData, dbNId, langCode);
                seriesID = seriesData[0].SeriesID;
                seriesName = seriesData[0].SeriesName;

                if (!diMap.isMyData)
                {
                    this.SetTimeLogIntoFile("Start Get Source Info-> " + DateTime.Now.ToLongTimeString());
                    sourceData = this.GetSourceInfo(diMap.MapDataColumns, dtSessionData, diMap.isMyData, dbNId, langCode);
                    this.SetTimeLogIntoFile("End Get Source Info-> " + DateTime.Now.ToLongTimeString());
                }

                if (dtSessionData.Columns.Contains(diMap.MapDataColumns.isMRD) && diMap.IsMRDColumnAddedInTable == false)
                {
                    FilterText = diMap.MapDataColumns.SeriesNid + " in(" + seriesID + ") and " + diMap.MapDataColumns.isMRD + "='true' ";
                }
                else
                {
                    FilterText = diMap.MapDataColumns.SeriesNid + " in(" + seriesID + ") ";
                }

                //TODO Get Path from WebService

                ////////MapFolder = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + dbNId + "\\" + Constants.FolderName.Maps);
                ////////DisputedBoundriesFolder = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.DisputedBoundries);

                bool usingMapServer = false;//Convert.ToBoolean(isMapServer.Trim());
                if (Session["IsMapServer"] != null)
                {
                    usingMapServer = Convert.ToBoolean(Session["IsMapServer"]);
                }
                if (!usingMapServer)
                {
                    MapFolder = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + dbNId + "\\" + Constants.FolderName.Maps);
                    DisputedBoundriesFolder = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.DisputedBoundries);
                }
                else
                {
                    // string mapServerFileDirectory = "D:\\MapServer\\stock\\data\\1\\maps";
                    string mapServerFileDirectory = Global.GetMapServerDirectory();
                    MapFolder = mapServerFileDirectory;
                    DisputedBoundriesFolder = Path.Combine(mapServerFileDirectory + "\\DIB\\");
                }

                diMap.Width = width;
                diMap.Height = Height;
                diMap.SpatialMapFolder = MapFolder;
                diMap.DIBFolderPath = DisputedBoundriesFolder;
                diMap.FirstColor = ColorTranslator.FromHtml("#b6effd");
                diMap.FourthColor = ColorTranslator.FromHtml("#1c84a0");
                diMap.SeriesData = seriesData;
                diMap.SourceData = sourceData;
                diMap.Title = seriesName;
                diMap.LabelEffectSettings = new LabelEffectSetting();

                diMap.MultiRowLabel = false;

                diMap.AngledNudgeLdrLine = true;
                diMap.ShowPointStartingLdrLine = true;
                diMap.ShowLabelWithNewPattern = true;
                //adding 3 level items in the list
                if (diMap.ShowLabelWithNewPattern && diMap.LevelFontSettingList.Count == 0)
                {
                    this.SetLevelWiseLabelsFont(diMap.LevelFontSettingList, diMap.TemplateStyle.LabelFontSetting.FontTemplate.Font(), diMap.TemplateStyle.LabelFontSetting.FontTemplate.ForeColor);
                }

                this.SetTimeLogIntoFile("Template Style Loading.. -> " + DateTime.Now.ToLongTimeString());
                diMap.TemplateStyle = StyleTemplate.LoadStyleTemplate(Path.Combine(TemplateStyleFolderPath, Constants.Map.MapLanguageFileName));

                diMap.ScaleUnitText = "KM";

                //TODO language based strings
                this.SetTimeLogIntoFile("GetNSet language string -> " + DateTime.Now.ToLongTimeString());
                diMap.LanguageStrings = this.GetMapLanguageStrings(LanguageFolderPath, langCode);
                if (diMap.LanguageStrings == null)
                {
                    diMap.LanguageStrings = new LanguageStrings();
                }

                this.SetTimeLogIntoFile("Set Map layers-> " + DateTime.Now.ToLongTimeString());
                this.SetMapLayers(diMap, dbNId, langCode);
                dtSessionData = diMap.MapData;

                diMap.SetFullExtent();

                //get series data by applying default filter
                this.SetTimeLogIntoFile("Get series Data-> " + DateTime.Now.ToLongTimeString());
                SeriesDataTable = this.GetSeriesData(dtSessionData, FilterText);

                diMap.Themes.Clear();
                this.SetTimeLogIntoFile("Create Theme-> " + DateTime.Now.ToLongTimeString());
                diMap.CreateTheme(SeriesDataTable.DefaultView, ThemeType.Color, 4, BreakType.EqualCount, ChartType.Column, seriesID, -1);
                if (diMap.Themes.Count > 0)
                {
                    IUSName = new List<string>(seriesName.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));
                    themeID = diMap.Themes[diMap.Themes.Count - 1].ID;
                    //diMap.Themes[themeID].Name = diMap.LanguageStrings.Theme + " - " + seriesName;
                    //diMap.Themes[themeID].LegendTitle = seriesName;
                    diMap.Themes[themeID].Name = IUSName[IUSName.Count - 1].Trim();
                    diMap.Themes[themeID].LegendTitle = diMap.Themes[themeID].Name;
                    diMap.Themes[themeID].DotColor = ColorTranslator.FromHtml("#000000");
                    diMap.Themes[themeID].isMRD = true;

                    //Bug no: 4850 [see all list of time period [ but timeperiod was not visible because is mrd check was there
                    //diMap.Themes[diMap.Themes[diMap.Themes.Count - 1].ID].TimePeriods = this.GetCSVInList(diMap.MapData, diMap.MapDataColumns.TimePeriod, true, FilterText);
                    diMap.Themes[themeID].TimePeriods = this.GetCSVInList(diMap.MapData, diMap.MapDataColumns.TimePeriod, true, diMap.MapDataColumns.SeriesNid + " in(" + seriesID + ") ");

                    diMap.setThemeRange(themeID, SeriesDataTable.DefaultView.Table);
                }

                //as per requirement TimePeriod or Most recent data append after map title
                this.AppendTimePeriodinMapTitle(diMap, dtSessionData, FilterText);

                //add map into  session variable
                this.SetTimeLogIntoFile("Set session variable-> " + DateTime.Now.ToLongTimeString());
                Session["DIMap"] = diMap;
                Session["DataViewNonQDS"] = diMap.MapData;

                //serialize map in last
                MapFileWPath = Path.Combine(this.TempPath, HttpContext.Current.Request.Cookies["SessionID"].Value + ".xml");
                //this.SerializeObject(MapFileWPath, diMap);
                this.SetTimeLogIntoFile("Start Saving Map into file named-> " + Path.GetFileNameWithoutExtension(MapFileWPath) + " Time:" + DateTime.Now.ToLongTimeString());
                diMap.Serialize(MapFileWPath);
            }

            this.SetTimeLogIntoFile("Get Map Image Starts-> " + DateTime.Now.ToLongTimeString());

            RetVal = SetBorderStyle("true", "1", "#000000", "Solid");
           // RetVal = this.GetBase64MapImageString(this.DrawMap(diMap));
            this.SetTimeLogIntoFile("Get Map Image Ends-> " + DateTime.Now.ToLongTimeString());
        }
        catch (Exception ex)
        {
            //Global.WriteErrorsInLog("From InitializeBaseMap hdbnid : " + dbNId + "->" + ex.Message);
            Global.CreateExceptionString(ex, "From InitializeBaseMap hdbnid : " + dbNId + "->" + ex.Message);

            RetVal = "false" + Constants.Delimiters.ParamDelimiter + ex.Message;
        }
        finally
        {
        }

        return RetVal;
    }
Esempio n. 50
0
 /// <summary>
 /// Default ctor allocates a little internal memory
 /// </summary>
 public Archive() {
     archive = new SourceData();
     units = new List<Unit>();
 }
 public VariableAccess(Statement statement, FullNamedExpression member, SourceData sourceData)
     : base(statement, sourceData)
 {
     Member = member;
 }
Esempio n. 52
0
        private void Fetch(Feed feed, FeedData feedData)
        {
            DataMapper.Map(feed, feedData);

            feedData.Source = new SourceData();
            DataMapper.Map(feed.Source, feedData.Source);

            feedData.CreatedByUser = new UserData();
            DataMapper.Map(feed.CreatedByUser, feedData.CreatedByUser);

            foreach (var feedSourceMember in feed.FeedSourceMembers)
            {
                var feedSourceMemberData = new FeedSourceMemberData();
                DataMapper.Map(feedSourceMember, feedSourceMemberData);

                var sourceData = new SourceData();
                DataMapper.Map(feedSourceMember.Source, sourceData);
                feedSourceMemberData.Source = sourceData;

                feedData.Sources.Add(feedSourceMemberData);
            }
        }
 public SimpleName(Statement statement, string value, SourceData sourceData)
     : this(statement, null, value, sourceData)
 {
 }
 public SimpleName(Statement statement, string value, bool isKeyword, SourceData sourceData)
     : this(statement, null, value, sourceData)
 {
     IsKeyword = isKeyword;
 }
Esempio n. 55
0
    private SourceData GetSourceInfo(DI_MapDataColumns mapDataColumns, DataTable sessionData, bool isMyData, string dbNid, string LanguageCode)
    {
        SourceData RetVal = null;
        DataTable SourceTable = null;
        SourceInfo sourceInfo;
        try
        {
            if (sessionData.Rows.Count > 0)
            {
                sourceInfo = new SourceInfo();
                RetVal = new SourceData();

                //get theme name IndicatorUnitSubgroup from Database
                _DBCon = Global.GetDbConnection(int.Parse(dbNid));
                //Step 2 Get IUS and Source information
                //Step 2.1. Get Source Information from Database
                List<DbParameter> DbParams = null;
                DbParameter sourceParam1 = _DBCon.CreateDBParameter();
                sourceParam1.ParameterName = "SourceNIds";
                sourceParam1.DbType = DbType.String;
                sourceParam1.Value = this.AddQuotesInCommaSeperated(this.GetCSV(sessionData, mapDataColumns.SourceNid), false);

                DbParams = new List<DbParameter>();
                DbParams.Add(sourceParam1);
                SourceTable = _DBCon.ExecuteDataTable("sp_get_sources_from_nids_" + LanguageCode, CommandType.StoredProcedure, DbParams).DefaultView.ToTable(true, mapDataColumns.SourceNid, mapDataColumns.SourceName);

                foreach (DataRow row in SourceTable.Rows)
                {
                    sourceInfo = new SourceInfo();
                    sourceInfo.SourceNId = row[mapDataColumns.SourceNid].ToString();
                    sourceInfo.SourceName = row[mapDataColumns.SourceName].ToString();
                    RetVal.Add(sourceInfo);
                }

            }
        }
        catch (Exception ex)
        {
            Global.CreateExceptionString(ex, null);

            throw;
        }

        return RetVal;
    }
 public void SetSourceData(SourceData sourceData)
 {
     SourceData = sourceData;
 }
Esempio n. 57
0
    private bool ReCreateDefaultTheme(Map diMap)
    {
        bool RetVal = false;
        string MapFileWPath = string.Empty;
        string TemplateStyleFolderPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Template);
        string LanguageFolderPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Language);
        string MapFolder = string.Empty;
        string DisputedBoundriesFolder = string.Empty;
        //Map diMap = null;
        DataTable dtSessionData = null;
        DataTable SeriesDataTable = null;
        SeriesData seriesData = null;
        SourceData sourceData = new SourceData();
        string seriesID = string.Empty;
        string seriesName = string.Empty;
        string FilterText = string.Empty;
        bool isUpdateMap = true;

        string themeID = string.Empty;
        List<string> IUSName = null;
        List<string> VisibleIUSNids = null;
        List<string> VisibleSourceNids = null;

        try
        {

            //First step To load map from session/ NewMap/ From preserved file
            if (isUpdateMap)
            {
                //2. Set datatable and areaNids
                dtSessionData = diMap.MapData;
                seriesData = diMap.SeriesData;
                sourceData = diMap.SourceData;

                ////Pending see after bug: remove entry from Source data  where iusnid not seleted
                //VisibleSourceNids = new List<string>(diMap.VisibleIndicatorNids.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));
                //for (int i = 0; i < sourceData.Count; i++)
                //{
                //    if (!VisibleIUSNids.Contains(sourceData[i].SourceNId))
                //    {
                //        sourceData.Remove(Convert.ToInt32(sourceData[i].SourceNId));
                //        i--;
                //    }
                //}
                //diMap.SourceData = sourceData;

                //Remove series from which is not selected
                seriesID = seriesData[0].SeriesID;
                seriesName = seriesData[0].SeriesName;

                if (dtSessionData.Columns.Contains(diMap.MapDataColumns.isMRD))
                {
                    FilterText = diMap.MapDataColumns.SeriesNid + " in(" + seriesID + ") and " + diMap.MapDataColumns.isMRD + "='true' ";
                }
                else
                {
                    FilterText = diMap.MapDataColumns.SeriesNid + " in(" + seriesID + ") ";
                }

                diMap.Title = seriesName;

                diMap.SetFullExtent();

                SeriesDataTable = this.GetSeriesData(dtSessionData, FilterText);

                diMap.Themes.Clear();
                diMap.CreateTheme(SeriesDataTable.DefaultView, ThemeType.Color, 4, BreakType.EqualCount, ChartType.Column, seriesID, -1);
                if (diMap.Themes.Count > 0)
                {
                    IUSName = new List<string>(seriesName.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));
                    themeID = diMap.Themes[diMap.Themes.Count - 1].ID;
                    //diMap.Themes[themeID].Name = diMap.LanguageStrings.Theme + " - " + seriesName;
                    //diMap.Themes[themeID].LegendTitle = seriesName;
                    diMap.Themes[themeID].Name = IUSName[IUSName.Count - 1].Trim();
                    diMap.Themes[themeID].LegendTitle = diMap.Themes[themeID].Name;
                    diMap.Themes[themeID].DotColor = ColorTranslator.FromHtml("#000000");
                    diMap.Themes[themeID].isMRD = true;

                    //Bug no: 4850 [see all list of time period [ but timeperiod was not visible because is mrd check was there
                    //diMap.Themes[diMap.Themes[diMap.Themes.Count - 1].ID].TimePeriods = this.GetCSVInList(diMap.MapData, diMap.MapDataColumns.TimePeriod, true, FilterText);
                    diMap.Themes[themeID].TimePeriods = this.GetCSVInList(diMap.MapData, diMap.MapDataColumns.TimePeriod, true, diMap.MapDataColumns.SeriesNid + " in(" + seriesID + ") ");

                    diMap.setThemeRange(themeID, SeriesDataTable.DefaultView.Table);
                }

                //as per requirement TimePeriod or Most recent data append after map title
                this.AppendTimePeriodinMapTitle(diMap, dtSessionData, FilterText);
            }

            RetVal = true;
        }
        catch (Exception ex)
        {
            //Global.WriteErrorsInLog("From ReCreateDefaultTheme : ->" + ex.Message);
            Global.CreateExceptionString(ex, null);

        }

        return RetVal;
    }
 public FullNamedExpression(Statement statement, FullNamedExpression left, SourceData sourceData)
     : base(statement, sourceData)
 {
     Left = left;
 }
Esempio n. 59
0
 public static double SuggestionsSelector (SourceData data)
 {
     return data.SuggestionsTotal > 0 ? 1d - (double)data.SuggestionsFound / data.SuggestionsTotal : 0d;
 }
Esempio n. 60
0
 private void Fetch(Source source, SourceData sourceData)
 {
     DataMapper.Map(source, sourceData);
 }