Exemplo n.º 1
0
 /// <summary>
 /// Initializes the control properties.
 /// </summary>
 protected void SetupControl()
 {
     if (this.StopProcessing)
     {
         // Do not process
     }
     else
     {
         using (WebClient webClient = new WebClient())
         {
             webClient.Headers[HttpRequestHeader.ContentType] = "application/json";
             webClient.Headers.Add("x-rapidapi-host", SettingsKeyInfoProvider.GetValue(SiteContext.CurrentSiteName + ".WorldIndiaXRapidAPIHost"));
             webClient.Headers.Add("x-rapidapi-key", SettingsKeyInfoProvider.GetValue(SiteContext.CurrentSiteName + ".XRapidAPIKey"));
             var response                   = webClient.DownloadString(SettingsKeyInfoProvider.GetValue(SiteContext.CurrentSiteName + ".CVWIAPI"));
             var countrywiseData            = JsonConvert.DeserializeObject <WorldDataCountryWise>(response);
             List <WorldData> worldDataList = new List <WorldData>();
             if (countrywiseData.World_Total != null)
             {
                 WorldData wd = new WorldData()
                 {
                     Total_Cases        = countrywiseData.World_Total.Total_Cases,
                     Total_Deaths       = countrywiseData.World_Total.Total_Deaths,
                     Total_Recovered    = countrywiseData.World_Total.Total_Recovered,
                     New_Cases          = countrywiseData.World_Total.New_Cases,
                     New_Deaths         = countrywiseData.World_Total.New_Deaths,
                     Statistic_Taken_At = countrywiseData.World_Total.Statistic_Taken_At
                 };
                 worldDataList.Add(wd);
             }
             brWorldData.DataSource   = GetWorldData(worldDataList);
             brWorldData.ItemTemplate = TransformationHelper.LoadTransformation(brWorldData, TransformationForWorldData);
             List <Countries> allCountriesData = new List <Countries>();
             if (countrywiseData.Countries_Stat.Count > 0)
             {
                 foreach (var c in countrywiseData.Countries_Stat)
                 {
                     Countries countryInfo = new Countries()
                     {
                         Country_Name                  = c.Country_Name,
                         Cases                         = c.Cases,
                         Deaths                        = c.Deaths,
                         Region                        = c.Region,
                         Total_Recovered               = c.Total_Recovered,
                         New_Deaths                    = c.New_Deaths,
                         New_Cases                     = c.New_Cases,
                         Serious_Critical              = c.Serious_Critical,
                         Active_Cases                  = c.Active_Cases,
                         Deaths_Per_1m_Population      = c.Deaths_Per_1m_Population,
                         Total_Tests                   = c.Total_Tests,
                         Total_Cases_Per_1m_Population = c.Total_Cases_Per_1m_Population,
                         Tests_Per_1m_Population       = c.Tests_Per_1m_Population
                     };
                     allCountriesData.Add(countryInfo);
                 }
             }
             brCountryWiseData.DataSource   = GetCountryWiseData(allCountriesData);
             brCountryWiseData.ItemTemplate = TransformationHelper.LoadTransformation(brCountryWiseData, TransformationForCountryWise);
         }
     }
 }
    /// <summary>
    /// Load transformations with dependence.
    /// </summary>
    protected void LoadTransformations()
    {
        if (!String.IsNullOrEmpty(TransformationName))
        {
            TransformationInfo ti = TransformationInfoProvider.GetTransformation(TransformationName);

            if (ti != null)
            {
                // Setting up the common BasicUniView properties
                shoppingCartUniView.HierarchicalDisplayMode = HierarchicalDisplayModeEnum.Inner;
                shoppingCartUniView.RelationColumnID        = "CartItemGuid";

                if (ti.TransformationIsHierarchical)
                {
                    // Setting up the hierarchical transformation.
                    HierarchicalTransformations ht = new HierarchicalTransformations("CartItemGUID");
                    ht.LoadFromXML(ti.TransformationHierarchicalXMLDocument);
                    // Setting up the BasicUniView
                    shoppingCartUniView.Transformations = ht;
                    shoppingCartUniView.UseNearestItemForHeaderAndFooter = true;
                }
                else
                {
                    // Setting up the BasicUniView with a non-hierarchical transformation
                    shoppingCartUniView.ItemTemplate = TransformationHelper.LoadTransformation(shoppingCartUniView, ti.TransformationFullName);
                }

                // Makes sure new data is loaded if the date changes and transformation needs to be reloaded
                shoppingCartUniView.DataBind();
            }
        }
    }
Exemplo n.º 3
0
        protected override void ExecuteInternal()
        {
            var parentDirectory = Directory.GetParent(BaseConfigPath);
            var configFileName  = Path.GetFileNameWithoutExtension(BaseConfigPath);

            if (!string.IsNullOrEmpty(TransformFilePath) && File.Exists(TransformFilePath))
            {
                var updatedConfig = TransformationHelper.Transform(File.ReadAllText(BaseConfigPath),
                                                                   File.ReadAllText(TransformFilePath));
                if (updatedConfig is null)
                {
                    return;
                }

                updatedConfig.Save(BaseConfigPath);

                if (Build.Configuration.Debug)
                {
                    Log.LogMessage("*************** Transformed app.config ******************************");
                    Log.LogMessage(updatedConfig.ToString());
                }
            }

            if (Build.Configuration.AppConfig.IncludeAllConfigs)
            {
                Outputs = parentDirectory.EnumerateFiles().Select(x => new TaskItem(x.FullName));
            }
            else
            {
                Outputs = new[] { new TaskItem(BaseConfigPath) };
            }
        }
        /// <summary>
        /// Conversion of Quaternion to Euler angles
        /// </summary>
        void RotationToEulerAngles()
        {
            if (this.ProcessDirection != TransformDirection.None)
            {
                return;
            }

            this.ProcessDirection = TransformDirection.QuaternionToEuler;

            var mat = new Matrix3D();

            mat.Rotate(Rotation);
            this.AirPlaneMatrixTransform = mat;


            var euler = TransformationHelper.QuaternionToEuler(Rotation);

            euler *= 180.0 / Math.PI;

            this.Psi   = euler.Z;
            this.Theta = euler.Y;
            this.Phi   = euler.X;

            this.ProcessDirection = TransformDirection.None;
        }
Exemplo n.º 5
0
        public void AppendIncludedRepresentationRecursive_RecursesWholeTree()
        {
            // Arrange
            var source = new PostBuilder()
                         .WithAuthor(PostBuilder.Asimov)
                         .WithComment(1, "Comment One")
                         .WithComment(2, "Comment Two")
                         .Build();

            var sourceList = new List <object>()
            {
                source
            };

            var config = TestModelConfigurationBuilder.BuilderForEverything.Build();

            var mapping = config.GetMapping(typeof(Post));
            var context = new Context(
                new Uri("http://dummy:4242/posts"),
                new string[] { "authors.comments" });

            var transformationHelper = new TransformationHelper(config, new FakeLinkBuilder());

            // Act
            var result = transformationHelper.CreateIncludedRepresentations(sourceList, mapping, context);

            // Assert
            Assert.NotNull(result.Single(x => x.Id == "1" && x.Type == "comments"));
            Assert.NotNull(result.Single(x => x.Id == "2" && x.Type == "comments"));
            Assert.NotNull(result.Single(x => x.Id == "1" && x.Type == "authors"));
            Assert.False(result.Any(x => x.Type == "posts"));
        }
Exemplo n.º 6
0
    /// <summary>
    /// Renders search results into HTML string.
    /// </summary>
    private string RenderResults(List <SearchResultItem> results, string searchText)
    {
        if (results == null || results.Count == 0)
        {
            // No results
            return(String.IsNullOrEmpty(PredictiveSearchNoResultsContent) ? "" : "<div class='nonSelectable'>" + PredictiveSearchNoResultsContent + "</div>");
        }
        else
        {
            UIRepeater   repSearchResults = new UIRepeater();
            var          indexCategories  = new Dictionary <string, IEnumerable <SearchResultItem> >(StringComparer.InvariantCultureIgnoreCase);
            StringWriter stringWriter     = new StringWriter();

            // Display categories - create DataView for each index
            if (PredictiveSearchDisplayCategories)
            {
                foreach (SearchResultItem resultItem in results)
                {
                    string index = resultItem.Index;

                    if (!indexCategories.ContainsKey(index))
                    {
                        indexCategories.Add(index, results.Where(item => String.Equals(item.Index, index, StringComparison.InvariantCultureIgnoreCase)));
                    }
                }
            }
            // Do not display categories - create DataView of whole table
            else
            {
                indexCategories.Add("results", results);
            }


            // Render each index category
            foreach (var categories in indexCategories)
            {
                // Display categories
                if (PredictiveSearchDisplayCategories)
                {
                    SearchIndexInfo indexInfo    = SearchIndexInfoProvider.GetSearchIndexInfo(categories.Key);
                    string          categoryName = indexInfo == null ? String.Empty : indexInfo.IndexDisplayName;
                    repSearchResults.HeaderTemplate = new TextTransformationTemplate("<div class='predictiveSearchCategory nonSelectable'>" + categoryName + "</div>");
                }

                // Fill repeater with results
                repSearchResults.ItemTemplate = TransformationHelper.LoadTransformation(this, PredictiveSearchResultItemTransformationName);
                repSearchResults.DataSource   = categories.Value;
                repSearchResults.DataBind();
                repSearchResults.RenderControl(new HtmlTextWriter(stringWriter));
            }

            // More results
            if (PredictiveSearchMaxResults == results.Count)
            {
                stringWriter.Write(String.Format(PredictiveSearchMoreResultsContent, CreateSearchUrl(searchText)));
            }

            return(stringWriter.ToString());
        }
    }
Exemplo n.º 7
0
        public ICollection <Path> GeneratePaths()
        {
            // Apply attributes
            var baseObject = GetBaseObject(Element);

            foreach (var attribute in GenericAttributes)
            {
                baseObject = attribute.TryApplyAttribute <TElemType>(baseObject);
            }
            foreach (var attribute in ElementAttributes)
            {
                baseObject = attribute.TryApplyAttribute <TElemType>(baseObject);
            }

            var pathCollection = ConvertObjectToPaths(baseObject);

            // Apply transformations
            if (!(this is ITransformable) || TransformationAttribute == null)
            {
                return(pathCollection);
            }
            var transform = TransformationHelper.GetTransform(TransformationAttribute.TransformParameters);

            if (transform != null)
            {
                ((ITransformable)this).ApplyTransformation(transform);
            }

            return(pathCollection);
        }
Exemplo n.º 8
0
    /// <summary>
    /// Renders search results into HTML string.
    /// </summary>
    private string RenderResults(DataSet results, string searchText)
    {
        if (results == null)
        {
            // No results
            return(String.IsNullOrEmpty(PredictiveSearchNoResultsContent) ? "" : "<div class='nonSelectable'>" + PredictiveSearchNoResultsContent + "</div>");
        }
        else
        {
            UIRepeater repSearchResults = new UIRepeater();
            IDictionary <string, DataView> indexCategories = new Dictionary <string, DataView>(StringComparer.InvariantCultureIgnoreCase);
            StringWriter stringWriter = new StringWriter();

            // Display categories - create DataView for each index
            if (PredictiveSearchDisplayCategories)
            {
                foreach (DataRow row in results.Tables["results"].Rows)
                {
                    string index = (string)row["index"];

                    if (!indexCategories.ContainsKey(index))
                    {
                        indexCategories.Add(index, new DataView(results.Tables["results"], "index = '" + index + "'", "", DataViewRowState.CurrentRows));
                    }
                }
            }
            // Do not display categories - create DataView of whole table
            else
            {
                indexCategories.Add("results", new DataView(results.Tables["results"]));
            }


            // Render each index category
            foreach (var categories in indexCategories)
            {
                // Display categories
                if (PredictiveSearchDisplayCategories)
                {
                    SearchIndexInfo indexInfo    = SearchIndexInfoProvider.GetSearchIndexInfo(categories.Key);
                    string          categoryName = indexInfo == null ? String.Empty : indexInfo.IndexDisplayName;
                    repSearchResults.HeaderTemplate = new TextTransformationTemplate("<div class='predictiveSearchCategory nonSelectable'>" + categoryName + "</div>");
                }

                // Fill repeater with results
                repSearchResults.ItemTemplate = TransformationHelper.LoadTransformation(this, PredictiveSearchResultItemTransformationName);
                repSearchResults.DataSource   = categories.Value;
                repSearchResults.DataBind();
                repSearchResults.RenderControl(new HtmlTextWriter(stringWriter));
            }

            // More results
            if (PredictiveSearchMaxResults == results.Tables["results"].Rows.Count)
            {
                stringWriter.Write(String.Format(PredictiveSearchMoreResultsContent, CreateSearchUrl(searchText)));
            }

            return(stringWriter.ToString());
        }
    }
        public JsonApiTransformer Build()
        {
            var serializer           = JsonSerializerBuilder.Build();
            var transformationHelper = new TransformationHelper(config, linkBuilder);

            return(new JsonApiTransformer(serializer, config, transformationHelper));
        }
Exemplo n.º 10
0
        protected override void ExecuteInternal()
        {
            // Copy all output files...
            foreach (var config in ExpectedConfigs)
            {
                Log.LogMessage($"Copying '{config.SourceFile}' to '{config.OutputPath}'.");
                File.Copy(config.SourceFile, config.OutputPath);
            }

            if (!string.IsNullOrEmpty(TransformFilePath) && File.Exists(TransformFilePath))
            {
                var updatedConfig = TransformationHelper.Transform(File.ReadAllText(BaseConfigPath),
                                                                   File.ReadAllText(TransformFilePath));
                if (updatedConfig is null)
                {
                    return;
                }

                var appConfig = ExpectedConfigs.First(x => Path.GetFileName(x.OutputPath) == "app.config");
                updatedConfig.Save(appConfig.OutputPath);

                if (Build.Configuration.Debug)
                {
                    Log.LogMessage("*************** Transformed app.config ******************************");
                    Log.LogMessage(updatedConfig.ToString());
                }
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Apply schema / publishing changes to the EntityFramework
        /// </summary>
        /// <param name="schemaChanges"></param>
        public void ApplyTransformation(PublishSchemaChanges changes, string[] versions)
        {
            if (changes.NamespacesToPublish != null && changes.NamespacesToPublish.Any())
            {
                DataServices.Schemas.RemoveAll(x => !changes.NamespacesToPublish.Contains(x.Namespace));
            }

            TransformationHelper.ApplyTransformationToCollection(changes.Schemas, DataServices.Schemas, this, versions);
        }
Exemplo n.º 12
0
    /// <summary>
    /// Load transformations with dependence on current datasource type and datasource type.
    /// </summary>
    protected void LoadTransformations()
    {
        CMSBaseDataSource dataSource = DataSourceControl;

        if ((dataSource != null) && !String.IsNullOrEmpty(TransformationName))
        {
            BasicBingMaps.ItemTemplate = TransformationHelper.LoadTransformation(this, TransformationName);
        }
    }
    /// <summary>
    /// Load transformations with dependence on current datasource type and datasource type.
    /// </summary>
    protected void LoadTransformations()
    {
        CMSBaseDataSource docDataSource = DataSourceControl as CMSBaseDataSource;

        if (!String.IsNullOrEmpty(SelectedItemTransformationName) && (docDataSource != null) && docDataSource.IsSelected)
        {
            BasicDataList.ItemTemplate = TransformationHelper.LoadTransformation(this, SelectedItemTransformationName);

            if (!String.IsNullOrEmpty(SelectedItemFooterTransformationName))
            {
                BasicDataList.FooterTemplate = TransformationHelper.LoadTransformation(this, SelectedItemFooterTransformationName);
            }
            else
            {
                BasicDataList.FooterTemplate = null;
            }

            if (!String.IsNullOrEmpty(SelectedItemHeaderTransformationName))
            {
                BasicDataList.HeaderTemplate = TransformationHelper.LoadTransformation(this, SelectedItemHeaderTransformationName);
            }
            else
            {
                BasicDataList.HeaderTemplate = null;
            }
        }
        else
        {
            // Apply transformations if they exist
            if (!String.IsNullOrEmpty(AlternatingItemTransformationName))
            {
                BasicDataList.AlternatingItemTemplate = TransformationHelper.LoadTransformation(this, AlternatingItemTransformationName);
            }

            if (!String.IsNullOrEmpty(FooterTransformationName))
            {
                BasicDataList.FooterTemplate = TransformationHelper.LoadTransformation(this, FooterTransformationName);
            }

            if (!String.IsNullOrEmpty(HeaderTransformationName))
            {
                BasicDataList.HeaderTemplate = TransformationHelper.LoadTransformation(this, HeaderTransformationName);
            }

            if (!String.IsNullOrEmpty(TransformationName))
            {
                BasicDataList.ItemTemplate = TransformationHelper.LoadTransformation(this, TransformationName);
            }

            if (!String.IsNullOrEmpty(SeparatorTransformationName))
            {
                BasicDataList.SeparatorTemplate = TransformationHelper.LoadTransformation(this, SeparatorTransformationName);
            }
        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        // Handle stop processing
        if (!StopProcessing)
        {
            // If displaying something
            if ((DisplayGlobalCategories) || (DisplayCustomCategories) || (DisplaySiteCategories))
            {
                // Get data set
                data = GetDataSet();

                if (RenderAsTree)
                {
                    CreateCategoryTrees(data);
                    StringBuilder sb = new StringBuilder();

                    // Render trees
                    sb.Append("<ul style=\"margin:0;\" class=\"CategoryListList\">");
                    RenderTree(sb, generalRoot);
                    RenderTree(sb, personalRoot);
                    sb.Append("</ul>");

                    ltlList.Text = sb.ToString();

                    rptCategoryList.Visible = false;
                }
                else
                {
                    rptCategoryList.DataSource = data;

                    if (String.IsNullOrEmpty(TransformationName))
                    {
                        rptCategoryList.ItemTemplate = TransformationHelper.LoadTransformation(this, "[]");
                    }
                    else
                    {
                        rptCategoryList.ItemTemplate = TransformationHelper.LoadTransformation(this, TransformationName);
                    }
                    rptCategoryList.HideControlForZeroRows = HideControlForZeroRows;
                    rptCategoryList.ZeroRowsText           = ZeroRowsText;
                    rptCategoryList.DataBindByDefault      = false;
                    rptCategoryList.DataBind();

                    ltlList.Visible = false;
                }
            }
            // Else show zero rows text
            else
            {
                lblInfo.Text    = ZeroRowsText;
                lblInfo.Visible = true;
            }
        }
    }
Exemplo n.º 15
0
    private void DisplayCouponCodes()
    {
        var transformation = TransformationInfoProvider.GetTransformation(CouponCodeTransformationName);

        if (transformation != null)
        {
            rptrCouponCodes.ItemTemplate = TransformationHelper.LoadTransformation(rptrCouponCodes, transformation.TransformationFullName);
        }

        rptrCouponCodes.DataSource = GetViewModel();
        rptrCouponCodes.DataBind();
    }
Exemplo n.º 16
0
        protected override void ExecuteInternal()
        {
            var parentDirectory = Directory.GetParent(BaseConfigPath);
            var configFileName  = Path.GetFileNameWithoutExtension(BaseConfigPath);

            if (!string.IsNullOrEmpty(TransformFilePath) && File.Exists(TransformFilePath))
            {
                var updatedConfig = TransformationHelper.Transform(File.ReadAllText(BaseConfigPath),
                                                                   File.ReadAllText(TransformFilePath));
                if (updatedConfig is null)
                {
                    return;
                }

                updatedConfig.Save(BaseConfigPath);

                if (Build.Configuration.Debug)
                {
                    Log.LogMessage("*************** Transformed app.config ******************************");
                    Log.LogMessage(updatedConfig.ToString());
                }
            }

            switch (Build.Configuration.AppConfig.Strategy)
            {
            case Models.AppConfigStrategy.BundleAll:
                Outputs = parentDirectory.EnumerateFiles()
                          .Select(x => new TaskItem(x.FullName));
                Log.LogMessage($"All app.config's will be bundled. {string.Join(", ", parentDirectory.EnumerateFiles().Select(x => x.Name))}");
                break;

            case Models.AppConfigStrategy.BundleNonStandard:
                var standardConfigs = new[]
                {
                    "app.debug.config",
                    "app.release.config",
                    "app.store.config",
                    "app.adhoc.config"
                };
                Outputs = parentDirectory.EnumerateFiles()
                          .Where(x => !standardConfigs.Any(s => s.Equals(x.Name, StringComparison.InvariantCultureIgnoreCase)))
                          .Select(x => new TaskItem(x.FullName));
                if (Outputs.Count() > 1)
                {
                    Log.LogMessage($"The app.config will be bundled with the following configurations. {string.Join(", ", Outputs.Select(x => Path.GetFileName(x.ItemSpec)))}");
                }
                break;

            default:
                Outputs = new[] { new TaskItem(BaseConfigPath) };
                break;
            }
        }
Exemplo n.º 17
0
 public override void ApplyTransformation(BaseModifications mods, EntityFramework edmx, string[] versions)
 {
     TransformationHelper.ApplyTransformation(this, mods, edmx, versions, (key, value) =>
     {
         if (key == "GraphPropertyName")
         {
             this.WorkloadName = this.Name;
             this.Name         = (string)value;
             return(true);
         }
         return(false);
     });
 }
Exemplo n.º 18
0
    /// <summary>
    /// Loads ITemplates from transformation names
    /// </summary>
    private void LoadTemplates()
    {
        // Transformation
        if (!String.IsNullOrEmpty(TransformationName))
        {
            activeTemplate = TransformationHelper.LoadTransformation(this, TransformationName);
            autoGenerate   = false;
        }

        // Inactive
        if (!String.IsNullOrEmpty(InactiveItemTransformationName))
        {
            inactiveTemplate = TransformationHelper.LoadTransformation(this, InactiveItemTransformationName);
            autoGenerate     = false;
        }

        // Current
        if (!String.IsNullOrEmpty(CurrentItemTranformationName))
        {
            currentTemplate = TransformationHelper.LoadTransformation(this, CurrentItemTranformationName);
            autoGenerate    = false;
        }

        // Alternating
        if (!String.IsNullOrEmpty(AlternatingTransformationName))
        {
            alternatingTemnplate = TransformationHelper.LoadTransformation(this, AlternatingTransformationName);
            autoGenerate         = false;
        }

        // First
        if (!String.IsNullOrEmpty(FirstTransformationName))
        {
            firstTemplate = TransformationHelper.LoadTransformation(this, FirstTransformationName);
            autoGenerate  = false;
        }

        // Last
        if (!String.IsNullOrEmpty(LastTransformationName))
        {
            lastTemplate = TransformationHelper.LoadTransformation(this, LastTransformationName);
            autoGenerate = false;
        }

        // Last inactive
        if (!String.IsNullOrEmpty(LastInactiveTransformationName))
        {
            lastInactiveTemplate = TransformationHelper.LoadTransformation(this, LastInactiveTransformationName);
            autoGenerate         = false;
        }
    }
        public static List <CallModel> PopulateCallData(AirCallModel[] airCallData)
        {
            var listOfCalls = new List <CallModel>();

            if (airCallData != null)
            {
                foreach (var allCalls in airCallData)
                {
                    if (allCalls.Calls != null && allCalls.Calls.Any())
                    {
                        foreach (var individualCall in allCalls.Calls)
                        {
                            var model = new CallModel
                            {
                                CallId           = Convert.ToInt32(individualCall.Id),
                                Status           = individualCall.Status,
                                Duration         = individualCall.Duration,
                                Direction        = individualCall.Direction,
                                MissedCallReason = individualCall.MissedCallReason,
                                StartedAt        = TransformationHelper.UnixTimeStampToDateTime(Convert.ToDouble(individualCall.StartedAt)),
                                AnsweredAt       = TransformationHelper.UnixTimeStampToDateTime(Convert.ToDouble(individualCall.AnsweredAt)),
                                EndedAt          = TransformationHelper.UnixTimeStampToDateTime(Convert.ToDouble(individualCall.EndedAt))
                            };

                            if (individualCall.AssignedTo != null)
                            {
                                if (individualCall.AssignedTo.Name != null)
                                {
                                    model.AssignedTo = individualCall.AssignedTo.Name;
                                }

                                if (individualCall.AssignedTo.Email != null)
                                {
                                    model.AssignedToEmail = individualCall.AssignedTo.Email;
                                }
                            }

                            if (individualCall.User?.Name != null)
                            {
                                model.UserName = individualCall.User.Name;
                            }

                            listOfCalls.Add(model);
                        }
                    }
                }
            }
            return(listOfCalls);
        }
Exemplo n.º 20
0
 public override void ApplyTransformation(BaseModifications mods, EntityFramework edmx, string[] versions)
 {
     TransformationHelper.ApplyTransformation(this, mods, edmx, versions, (name, modPropValue) =>
     {
         if (name == "GraphEntityTypeName")
         {
             WorkloadName = this.Name;
             this.Name    = (string)modPropValue;
             // Need to rename the references to this entity type through the EntityFramework
             edmx.RenameEntityType(this);
             return(true);
         }
         return(false);
     });
 }
Exemplo n.º 21
0
        public void Apply(HttpConfiguration configuration)
        {
            var serializer  = GetJsonSerializer();
            var helper      = new TransformationHelper();
            var transformer = new JsonApiTransformer {
                Serializer = serializer, TransformationHelper = helper
            };

            var filter = new JsonApiActionFilter(transformer, this);

            configuration.Filters.Add(filter);

            var formatter = new JsonApiFormatter(this, serializer);

            configuration.Formatters.Add(formatter);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Conversion of Euler angles to quaternion
        /// </summary>
        void EulerAnglesToRotation()
        {
            if (this.ProcessDirection != TransformDirection.None)
            {
                return;
            }

            this.ProcessDirection = TransformDirection.EulerToQuaternion;

            this.Rotation = TransformationHelper.UnitQuaternionFromEulerAngles(Psi, Theta, Phi);
            var mat = new Matrix3D();

            mat.Rotate(this.Rotation);
            this.AirPlaneMatrixTransform = mat;

            this.ProcessDirection = TransformDirection.None;
        }
Exemplo n.º 23
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            if (!String.IsNullOrEmpty(TransformationName))
            {
                repTopContributors.ItemTemplate           = TransformationHelper.LoadTransformation(this, TransformationName);
                repTopContributors.HideControlForZeroRows = HideControlForZeroRows;
                repTopContributors.ZeroRowsText           = ZeroRowsText;

                DataSet ds = null;

                // Try to get data from cache
                using (var cs = new CachedSection <DataSet>(ref ds, CacheMinutes, true, CacheItemName, "forumtopcontributors", SiteContext.CurrentSiteName, WhereCondition, SelectTopN))
                {
                    if (cs.LoadData)
                    {
                        // Get the data
                        ds = GetData();

                        // Save to the cache
                        if (cs.Cached)
                        {
                            // Save to the cache
                            cs.CacheDependency = GetCacheDependency();
                        }

                        cs.Data = ds;
                    }
                }

                repTopContributors.DataSource = ds;

                if (!DataHelper.DataSourceIsEmpty(repTopContributors.DataSource))
                {
                    repTopContributors.DataBind();
                }
            }
        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            basicDatalist.Visible       = false;
            wsDataSource.StopProcessing = true;
        }
        else
        {
            // Setup the control
            // Public
            basicDatalist.RepeatColumns          = RepeatColumns;
            basicDatalist.RepeatLayout           = RepeatLayout;
            basicDatalist.RepeatDirection        = RepeatDirection;
            basicDatalist.HideControlForZeroRows = HideControlForZeroRows;
            basicDatalist.ZeroRowsText           = ZeroRowsText;
            basicDatalist.DataBindByDefault      = DataBindByDefault;

            // Get web service URL, parameters and transformation name
            wsDataSource.WebServiceUrl        = WebServiceURL;
            wsDataSource.WebServiceParameters = WebServiceParameters;
            transformationName = TransformationName;

            // Connect with data source
            basicDatalist.DataSource = wsDataSource.DataSource;

            if (!DataHelper.DataSourceIsEmpty(basicDatalist.DataSource))
            {
                if (transformationName != "")
                {
                    basicDatalist.ItemTemplate = TransformationHelper.LoadTransformation(basicDatalist, transformationName);
                }
            }
            else
            {
                if (HideControlForZeroRows)
                {
                    Visible = false;
                }
            }
        }
    }
Exemplo n.º 25
0
    /// <summary>
    /// Displays multibuy and order discounts summary based on provided transformation.
    /// </summary>
    private void DisplayOrderDiscountSummary()
    {
        if (!string.IsNullOrEmpty(OrderDiscountSummaryTransformationName))
        {
            TransformationInfo ti = TransformationInfoProvider.GetTransformation(OrderDiscountSummaryTransformationName);

            if (ti == null)
            {
                return;
            }

            uvMultiBuySummary.Visible      = true;
            uvMultiBuySummary.DataSource   = ShoppingCart.OrderRelatedDiscountSummaryItems;
            uvMultiBuySummary.ItemTemplate = TransformationHelper.LoadTransformation(uvMultiBuySummary, ti.TransformationFullName);

            // Makes sure new data is loaded if the date changes and transformation needs to be reloaded
            uvMultiBuySummary.DataBind();
            uvMultiBuySummary.ReloadData(true);
        }
    }
Exemplo n.º 26
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            basicRepeater.Visible       = false;
            wsDataSource.StopProcessing = true;
        }
        else
        {
            // Setup the control
            // Public
            basicRepeater.HideControlForZeroRows = HideControlForZeroRows;
            basicRepeater.ZeroRowsText           = ZeroRowsText;
            basicRepeater.DataBindByDefault      = DataBindByDefault;

            // Get web service URL, parameters and transformation name
            wsDataSource.WebServiceUrl        = WebServiceURL;
            wsDataSource.WebServiceParameters = WebServiceParameters;
            transformationName = TransformationName;

            // Connect with data source
            basicRepeater.DataSource = wsDataSource.DataSource;

            if (!DataHelper.DataSourceIsEmpty(basicRepeater.DataSource))
            {
                if ((transformationName != null) && (transformationName.Trim() != ""))
                {
                    // Get url to transformation and load it
                    basicRepeater.ItemTemplate = TransformationHelper.LoadTransformation(basicRepeater, transformationName);
                }
            }
            else
            {
                if (HideControlForZeroRows)
                {
                    Visible = false;
                }
            }
        }
    }
        public void AppendIncludedRepresentationRecursive_RecursesWholeTree_No_Duplicates()
        {
            // Arrange
            var firstSource = new PostBuilder()
                              .WithAuthor(PostBuilder.Asimov)
                              .Build();

            var secondSource = new PostBuilder()
                               .WithAuthor(PostBuilder.Asimov)
                               .Build();

            var thirdSource = new PostBuilder()
                              .WithAuthor(PostBuilder.Clarke)
                              .Build();

            var sourceList = new List <object>()
            {
                firstSource,
                secondSource,
                thirdSource
            };

            var config = TestModelConfigurationBuilder.BuilderForEverything.Build();

            var mapping = config.GetMapping(typeof(Post));
            var context = new Context(
                new Uri("http://dummy:4242/posts"),
                new string[] { "author.replies" });

            var transformationHelper = new TransformationHelper(config, new FakeLinkBuilder());

            // Act
            var result = transformationHelper.CreateIncludedRepresentations(sourceList, mapping, context);

            // Assert
            Assert.Equal(1, result.Count(x =>
                                         x.Type == "authors" &&
                                         x.Id == PostBuilder.Asimov.Id.ToString()));
        }
Exemplo n.º 28
0
        /// <summary> 
        /// Get 'a' tag with attached file url from given node</summary>
        /// <remarks> 
        /// For any attachment types</remarks> 
        public static MvcHtmlString GetFileLink(this TreeNode node, string fileFieldName, string linkText, object htmlAttributes)
        {
            if (node != null && !string.IsNullOrEmpty(fileFieldName))
            {
                var th = new TransformationHelper();
                var outputHtml = new TagBuilder("a")
                {
                    InnerHtml =
                        (!String.IsNullOrEmpty(linkText))
                            ? HttpUtility.HtmlEncode(linkText)
                            : String.Empty
                };
                var attributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);
                var mediaItemUrl = th.GetFileUrlFromAlias(node.GetValue(fileFieldName), node.NodeAlias);
                outputHtml.MergeAttribute("href", mediaItemUrl);
                outputHtml.MergeAttributes(attributes, true);

                return MvcHtmlString.Create(outputHtml.ToString());
            }

            return MvcHtmlString.Empty;
        }
Exemplo n.º 29
0
 /// <summary>
 /// Initializes the control properties.
 /// </summary>
 protected void SetupControl()
 {
     if (this.StopProcessing)
     {
         // Do not process
     }
     else
     {
         using (WebClient webClient = new WebClient())
         {
             webClient.Headers[HttpRequestHeader.ContentType] = "application/json";
             webClient.Headers.Add("x-rapidapi-host", SettingsKeyInfoProvider.GetValue(SiteContext.CurrentSiteName + ".XRapidAPIHost"));
             webClient.Headers.Add("x-rapidapi-key", SettingsKeyInfoProvider.GetValue(SiteContext.CurrentSiteName + ".XRapidAPIKey"));
             var response = webClient.DownloadString(SettingsKeyInfoProvider.GetValue(SiteContext.CurrentSiteName + ".CSAPI") + Country);
             var list     = JsonConvert.DeserializeObject <JSONResponse>(response);
             if (!list.Error)
             {
                 if (!list.Message.Equals("OK"))
                 {
                     //lbl_Error.Text = list.Message;
                 }
                 List <CountryInfo> countryInfo = new List <CountryInfo>();
                 CountryInfo        cc          = new CountryInfo
                 {
                     Location     = list.Data.Location,
                     Confirmed    = list.Data.Confirmed,
                     Logo         = Logo,
                     Deaths       = list.Data.Deaths,
                     Recovered    = list.Data.Recovered,
                     LastChecked  = list.Data.LastChecked,
                     LastReported = list.Data.LastReported
                 };
                 countryInfo.Add(cc);
                 basicRepeater.DataSource   = GetStatistics(countryInfo);
                 basicRepeater.ItemTemplate = TransformationHelper.LoadTransformation(basicRepeater, TransformationName);
             }
         }
     }
 }
Exemplo n.º 30
0
        public void GIVEN_NoIncludedItems_WHEN_Get_THEN_IncludedItemsAreNull()
        {
            // Arrange
            var source = new PostBuilder()
                         .Build();

            var sourceList = new List <object>()
            {
                source
            };

            var config = TestModelConfigurationBuilder.BuilderForEverything.Build();

            var mapping = config.GetMapping(typeof(Post));
            var context = new Context(new Uri("http://dummy:4242/posts"));

            var transformationHelper = new TransformationHelper(config, new FakeLinkBuilder());

            // Act
            var result = transformationHelper.CreateIncludedRepresentations(sourceList, mapping, context);

            // Assert
            Assert.Null(result);
        }
Exemplo n.º 31
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            MediaLibraryInfo mli = MediaLibraryInfoProvider.GetMediaLibraryInfo(MediaLibraryName, SiteContext.CurrentSiteName);
            if (mli != null)
            {
                // If don't have 'Manage' permission
                if (!MediaLibraryInfoProvider.IsUserAuthorizedPerLibrary(mli, "read"))
                {
                    // Check 'File create' permission
                    if (!MediaLibraryInfoProvider.IsUserAuthorizedPerLibrary(mli, "libraryaccess"))
                    {
                        repItems.Visible = false;

                        messageElem.ErrorMessage   = MediaLibraryHelper.GetAccessDeniedMessage("libraryaccess");
                        messageElem.DisplayMessage = true;
                        return;
                    }
                }
            }

            int fid = QueryHelper.GetInteger(FileIDQueryStringKey, 0);
            if (fid > 0)
            {
                if (!String.IsNullOrEmpty(SelectedItemTransformationName))
                {
                    repItems.ItemTemplate = TransformationHelper.LoadTransformation(this, SelectedItemTransformationName);
                }
            }
            else
            {
                if (!String.IsNullOrEmpty(TransformationName))
                {
                    repItems.ItemTemplate = TransformationHelper.LoadTransformation(this, TransformationName);
                }
            }
            if (!String.IsNullOrEmpty(FooterTransformationName))
            {
                repItems.FooterTemplate = TransformationHelper.LoadTransformation(this, FooterTransformationName);
            }
            if (!String.IsNullOrEmpty(HeaderTransformationName))
            {
                repItems.HeaderTemplate = TransformationHelper.LoadTransformation(this, HeaderTransformationName);
            }
            if (!String.IsNullOrEmpty(SeparatorTransformationName))
            {
                repItems.SeparatorTemplate = TransformationHelper.LoadTransformation(this, SeparatorTransformationName);
            }

            repItems.DataBindByDefault = false;
            repItems.OnPageChanged    += repItems_OnPageChanged;

            // Add repeater to the filter collection
            CMSControlsHelper.SetFilter(ValidationHelper.GetString(GetValue("WebPartControlID"), ID), repItems);

            repItems.HideControlForZeroRows = HideControlForZeroRows;
            repItems.ZeroRowsText           = ZeroRowsText;
        }
    }
Exemplo n.º 32
0
        /// <summary> 
        /// Get 'img' tag with image url from given node</summary>
        /// <remarks> 
        /// Use only for attacment with image in field</remarks> 
        public static MvcHtmlString GetImage(this TreeNode node, string imgFieldName, object htmlAttributes)
        {
            if (node != null && !string.IsNullOrEmpty(imgFieldName))
            {
                var th = new TransformationHelper();
                var outputHtml = new TagBuilder("img");
                var attributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);
                var mediaItemUrl = th.GetFileUrlFromAlias(node.GetValue(imgFieldName), node.NodeAlias);
                outputHtml.MergeAttribute("src", mediaItemUrl);
                outputHtml.MergeAttributes(attributes, true);

                return MvcHtmlString.Create(outputHtml.ToString());
            }

            return MvcHtmlString.Empty;
        }