Exemplo n.º 1
0
        public void Dispose()
        {
            Websites.Clear();
            AddtionalInfo.Clear();

            PackageRecord.Dispose();
            PackageRecord = null;

            AdPlanSettings.Dispose();
            AdPlanSettings = null;

            OutputData.Dispose();
            OutputData = null;

            Parent = null;
        }
Exemplo n.º 2
0
        public void Deserialize(XmlNode node)
        {
            int     tempInt;
            decimal tempDecimal;

            foreach (XmlAttribute productAttribute in node.Attributes)
            {
                switch (productAttribute.Name)
                {
                    #region Basic Properties
                case "Name":
                    Name = productAttribute.Value;
                    break;

                case "UniqueID":
                    Guid tempGuid;
                    if (Guid.TryParse(productAttribute.Value, out tempGuid))
                    {
                        UniqueID = tempGuid;
                    }
                    break;

                case "Index":
                    if (int.TryParse(productAttribute.Value, out tempInt))
                    {
                        Index = tempInt;
                    }
                    break;

                case "Category":
                    Category = productAttribute.Value;
                    break;

                case "SubCategory":
                    SubCategory = productAttribute.Value;
                    break;

                case "RateType":
                    RateType = productAttribute.Value;
                    switch (RateType)
                    {
                    case "0":
                        RateType = "CPM";
                        break;

                    case "1":
                        RateType = "Fixed";
                        break;
                    }
                    break;

                case "Location":
                    Location = productAttribute.Value;
                    break;

                case "Width":
                    if (int.TryParse(productAttribute.Value, out tempInt))
                    {
                        Width = tempInt;
                    }
                    else
                    {
                        Width = null;
                    }
                    break;

                case "Height":
                    if (int.TryParse(productAttribute.Value, out tempInt))
                    {
                        Height = tempInt;
                    }
                    else
                    {
                        Height = null;
                    }
                    break;

                case "EnableTarget":
                {
                    bool temp;
                    if (Boolean.TryParse(productAttribute.Value, out temp))
                    {
                        EnableTarget = temp;
                    }
                }
                break;

                case "EnableLocation":
                {
                    bool temp;
                    if (Boolean.TryParse(productAttribute.Value, out temp))
                    {
                        EnableLocation = temp;
                    }
                }
                break;

                case "EnableRichMedia":
                {
                    bool temp;
                    if (Boolean.TryParse(productAttribute.Value, out temp))
                    {
                        EnableRichMedia = temp;
                    }
                }
                break;
                    #endregion

                    #region Additional Properties
                case "UserDefinedName":
                    UserDefinedName = productAttribute.Value;
                    break;

                case "DurationType":
                    DurationType = productAttribute.Value;
                    break;

                case "DurationValue":
                    if (int.TryParse(productAttribute.Value, out tempInt))
                    {
                        DurationValue = tempInt;
                    }
                    else
                    {
                        DurationValue = null;
                    }
                    break;

                case "Strength1":
                    Strength1 = productAttribute.Value;
                    break;

                case "Strength2":
                    Strength2 = productAttribute.Value;
                    break;

                case "MonthlyInvestment":
                    if (Decimal.TryParse(productAttribute.Value, out tempDecimal))
                    {
                        MonthlyInvestment = tempDecimal;
                    }
                    else
                    {
                        MonthlyInvestment = null;
                    }
                    break;

                case "MonthlyImpressions":
                    if (Decimal.TryParse(productAttribute.Value, out tempDecimal))
                    {
                        MonthlyImpressions = tempDecimal;
                    }
                    else
                    {
                        MonthlyImpressions = null;
                    }
                    break;

                case "MonthlyCPM":
                    if (Decimal.TryParse(productAttribute.Value, out tempDecimal))
                    {
                        MonthlyCPM = tempDecimal;
                    }
                    else
                    {
                        MonthlyCPM = null;
                    }
                    break;

                case "TotalInvestment":
                    if (Decimal.TryParse(productAttribute.Value, out tempDecimal))
                    {
                        TotalInvestment = tempDecimal;
                    }
                    else
                    {
                        TotalInvestment = null;
                    }
                    break;

                case "TotalImpressions":
                    if (Decimal.TryParse(productAttribute.Value, out tempDecimal))
                    {
                        TotalImpressions = tempDecimal;
                    }
                    else
                    {
                        TotalImpressions = null;
                    }
                    break;

                case "TotalCPM":
                    if (Decimal.TryParse(productAttribute.Value, out tempDecimal))
                    {
                        TotalCPM = tempDecimal;
                    }
                    else
                    {
                        TotalCPM = null;
                    }
                    break;

                case "DefaultRate":
                    if (Decimal.TryParse(productAttribute.Value, out tempDecimal))
                    {
                        DefaultRate = tempDecimal;
                    }
                    else
                    {
                        DefaultRate = null;
                    }
                    break;

                case "Formula":
                    if (int.TryParse(productAttribute.Value, out tempInt))
                    {
                        Formula = (FormulaType)tempInt;
                    }
                    break;

                case "InvestmentDetails":
                    InvestmentDetails = productAttribute.Value;
                    break;

                case "EnableComment":
                {
                    bool tempBool;
                    if (bool.TryParse(productAttribute.Value, out tempBool))
                    {
                        EnableComment = tempBool;
                    }
                }
                break;

                case "CommentManualEdit":
                {
                    bool tempBool;
                    if (bool.TryParse(productAttribute.Value, out tempBool))
                    {
                        CommentManualEdit = tempBool;
                    }
                }
                break;

                case "ShowCommentTargeting":
                {
                    bool temp;
                    if (Boolean.TryParse(productAttribute.Value, out temp))
                    {
                        ShowCommentTargeting = temp;
                    }
                }
                break;

                case "ShowCommentRichMedia":
                {
                    bool temp;
                    if (Boolean.TryParse(productAttribute.Value, out temp))
                    {
                        ShowCommentRichMedia = temp;
                    }
                }
                break;

                case "Comment":
                    _userComment = productAttribute.Value;
                    break;

                case "DescriptionManualEdit":
                {
                    bool tempBool;
                    if (bool.TryParse(productAttribute.Value, out tempBool))
                    {
                        DescriptionManualEdit = tempBool;
                    }
                }
                break;

                case "ShowDimensions":
                {
                    bool temp;
                    if (Boolean.TryParse(productAttribute.Value, out temp))
                    {
                        ShowDimensions = temp;
                    }
                }
                break;

                case "ShowDescriptionTargeting":
                {
                    bool temp;
                    if (Boolean.TryParse(productAttribute.Value, out temp))
                    {
                        ShowDescriptionTargeting = temp;
                    }
                }
                break;

                case "ShowDescriptionRichMedia":
                {
                    bool temp;
                    if (Boolean.TryParse(productAttribute.Value, out temp))
                    {
                        ShowDescriptionRichMedia = temp;
                    }
                }
                break;

                case "Description":
                    Description = productAttribute.Value;
                    break;

                case "UserDescription":
                    _userDescription = productAttribute.Value;
                    break;
                    #endregion

                    #region Show Properties
                case "ShowFlightDates":
                {
                    bool tempBool;
                    if (bool.TryParse(productAttribute.Value, out tempBool))
                    {
                        ShowFlightDates = tempBool;
                    }
                }
                break;

                case "ShowDuration":
                {
                    bool tempBool;
                    if (bool.TryParse(productAttribute.Value, out tempBool))
                    {
                        ShowDuration = tempBool;
                    }
                }
                break;

                case "ShowAllPricingMonthly":
                {
                    bool tempBool;
                    if (bool.TryParse(productAttribute.Value, out tempBool))
                    {
                        ShowAllPricingMonthly = tempBool;
                    }
                }
                break;

                case "ShowAllPricingTotal":
                {
                    bool tempBool;
                    if (bool.TryParse(productAttribute.Value, out tempBool))
                    {
                        ShowAllPricingTotal = tempBool;
                    }
                }
                break;

                case "ShowMonthlyInvestments":
                {
                    bool tempBool;
                    if (bool.TryParse(productAttribute.Value, out tempBool))
                    {
                        ShowMonthlyInvestments = tempBool;
                    }
                }
                break;

                case "ShowMonthlyImpressions":
                {
                    bool tempBool;
                    if (bool.TryParse(productAttribute.Value, out tempBool))
                    {
                        ShowMonthlyImpressions = tempBool;
                    }
                }
                break;

                case "ShowTotalInvestments":
                {
                    bool tempBool;
                    if (bool.TryParse(productAttribute.Value, out tempBool))
                    {
                        ShowTotalInvestments = tempBool;
                    }
                }
                break;

                case "ShowTotalImpressions":
                {
                    bool tempBool;
                    if (bool.TryParse(productAttribute.Value, out tempBool))
                    {
                        ShowTotalImpressions = tempBool;
                    }
                }
                break;
                    #endregion
                }
            }
            Websites.Clear();
            foreach (XmlNode childNode in node.ChildNodes)
            {
                switch (childNode.Name)
                {
                case "Website":
                    Websites.Add(childNode.InnerText);
                    break;

                case "PackageRecord":
                    PackageRecord.Deserialize(childNode);
                    break;

                case "SummaryItem":
                    SummaryItem.Deserialize(childNode);
                    break;

                case "ProductInfo":
                    var productInfo = new ProductInfo();
                    productInfo.Deserialize(childNode);
                    AddtionalInfo.Add(productInfo);
                    break;
                }
            }
        }
        private void LoadOnlineStrategy(StorageFile listsSourceFile)
        {
            SlideHeaders.Clear();
            Websites.Clear();
            Strengths.Clear();
            Categories.Clear();
            ProductSources.Clear();
            if (!listsSourceFile.ExistsLocal())
            {
                return;
            }
            var document = new XmlDocument();

            document.Load(listsSourceFile.LocalPath);

            var node = document.SelectSingleNode(@"/OnlineStrategy");

            if (node == null)
            {
                return;
            }
            foreach (XmlNode childeNode in node.ChildNodes)
            {
                switch (childeNode.Name)
                {
                case "Header":
                    foreach (XmlAttribute attribute in childeNode.Attributes)
                    {
                        switch (attribute.Name)
                        {
                        case "Value":
                            if (!string.IsNullOrEmpty(attribute.Value) && !SlideHeaders.Contains(attribute.Value))
                            {
                                SlideHeaders.Add(attribute.Value);
                            }
                            break;
                        }
                    }
                    break;

                case "Site":
                    foreach (XmlAttribute attribute in childeNode.Attributes)
                    {
                        switch (attribute.Name)
                        {
                        case "Value":
                            if (!string.IsNullOrEmpty(attribute.Value) && !Websites.Contains(attribute.Value))
                            {
                                Websites.Add(attribute.Value);
                            }
                            break;
                        }
                    }
                    break;

                case "Strength":
                    foreach (XmlAttribute attribute in childeNode.Attributes)
                    {
                        switch (attribute.Name)
                        {
                        case "Value":
                            if (!string.IsNullOrEmpty(attribute.Value) && !Strengths.Contains(attribute.Value))
                            {
                                Strengths.Add(attribute.Value);
                            }
                            break;
                        }
                    }
                    break;

                case "PricingStrategy":
                    foreach (XmlAttribute attribute in childeNode.Attributes)
                    {
                        switch (attribute.Name)
                        {
                        case "Value":
                            if (!string.IsNullOrEmpty(attribute.Value) && !PricingStrategies.Contains(attribute.Value))
                            {
                                PricingStrategies.Add(attribute.Value);
                            }
                            break;
                        }
                    }
                    break;

                case "PositionColumn":
                    foreach (XmlAttribute attribute in childeNode.Attributes)
                    {
                        switch (attribute.Name)
                        {
                        case "Value":
                            if (!string.IsNullOrEmpty(attribute.Value) && !ColumnPositions.Contains(attribute.Value))
                            {
                                ColumnPositions.Add(attribute.Value);
                            }
                            break;
                        }
                    }
                    break;

                case "DefaultFormula":
                    switch (childeNode.InnerText.ToLower().Trim())
                    {
                    case "cpm":
                        DefaultFormula = FormulaType.CPM;
                        break;

                    case "investment":
                        DefaultFormula = FormulaType.Investment;
                        break;

                    case "impressions":
                        DefaultFormula = FormulaType.Impressions;
                        break;
                    }
                    break;

                case "LockedMode":
                {
                    bool temp;
                    if (Boolean.TryParse(childeNode.InnerText, out temp))
                    {
                        LockedMode = temp;
                    }
                }
                break;

                case "SpecialLinksEnable":
                {
                    bool temp;
                    if (Boolean.TryParse(childeNode.InnerText, out temp))
                    {
                        SpecialLinksEnable = temp;
                    }
                }
                break;

                case "SpecialButtonsGroupName":
                    SpecialLinksGroupName = childeNode.InnerText;
                    break;

                case "SpecialButtonsGroupLogo":
                    if (string.IsNullOrEmpty(childeNode.InnerText))
                    {
                        SpecialLinksGroupLogo = null;
                    }
                    else
                    {
                        SpecialLinksGroupLogo = new Bitmap(new MemoryStream(Convert.FromBase64String(childeNode.InnerText)));
                    }
                    break;

                case "Browser":
                    SpecialLinkBrowsers.Add(childeNode.InnerText);
                    break;

                case "SpecialButton":
                    var specialLinkButton = new SpecialLinkButton();
                    GetSpecialButton(childeNode, ref specialLinkButton);
                    if (!String.IsNullOrEmpty(specialLinkButton.Name) && !String.IsNullOrEmpty(specialLinkButton.Type) && specialLinkButton.Paths.Any())
                    {
                        SpecialLinkButtons.Add(specialLinkButton);
                    }
                    break;

                case "Targeting":
                {
                    var productInfo = new ProductInfo {
                        Type = ProductInfoType.Targeting
                    };
                    productInfo.Deserialize(childeNode);
                    TargetingRecods.Add(productInfo);
                }
                break;

                case "RichMedia":
                {
                    var productInfo = new ProductInfo {
                        Type = ProductInfoType.RichMedia
                    };
                    productInfo.Deserialize(childeNode);
                    RichMediaRecods.Add(productInfo);
                }
                break;

                case "Category":
                    var category = new Category();
                    GetCategories(childeNode, ref category);
                    if (!string.IsNullOrEmpty(category.Name))
                    {
                        Categories.Add(category);
                    }
                    break;

                case "Product":
                    var productSource = new ProductSource();
                    GetProductProperties(childeNode, ref productSource);
                    if (!string.IsNullOrEmpty(productSource.Name))
                    {
                        ProductSources.Add(productSource);
                    }
                    break;

                case "Status":
                    foreach (XmlAttribute attribute in childeNode.Attributes)
                    {
                        switch (attribute.Name)
                        {
                        case "Value":
                            if (!Statuses.Contains(attribute.Value))
                            {
                                Statuses.Add(attribute.Value);
                            }
                            break;
                        }
                    }
                    break;

                case "DefaultHomeViewSettings":
                    DefaultHomeViewSettings.Deserialize(childeNode);
                    break;

                case "DefaultDigitalProductSettings":
                    DefaultDigitalProductSettings.Deserialize(childeNode);
                    break;

                case "DefaultDigitalProductPackageSettings":
                    DefaultDigitalProductPackageSettings.Deserialize(childeNode);
                    break;

                case "DefaultDigitalStandalonePackageSettings":
                    DefaultDigitalStandalonePackageSettings.Deserialize(childeNode);
                    break;

                case "DigitalControlsConfiguration":
                    DefaultControlsConfiguration =
                        JsonConvert.DeserializeObject <DigitalControlsConfiguration>(Encoding.Unicode.GetString(Convert.FromBase64String(childeNode.InnerText)), new JsonImageConverter());
                    break;
                }
            }
        }