public void PopulateControls(Store store)
 {
     try
     {
         widget = new Widget(_style, store);
     }
     catch (Exception ex)
     {
         SaveLogFile.SaveLog(ex);
         widget = new Widget(_style, GetDefaultCode(), "");
     }
     uxWidgetEnableDrop.SelectedValue = widget.Enabled.ToString();
     uxWidgetTypeDrop.SelectedValue   = widget.CodeType;
     if (widget.CodeType == Widget.DEFAULT_TYPE)
     {
         uxWidgetParameterText.Text  = widget.GetParameterValue(0);
         uxWidgetCustomCodeText.Text = "";
     }
     else
     {
         uxWidgetParameterText.Text  = "";
         uxWidgetCustomCodeText.Text = widget.Code;
     }
     UpdateControlFromWidgetClass();
 }
Beispiel #2
0
    private void SetUpImage()
    {
        try
        {
            if (ImageUrl != null)
            {
                uxImage.ImageUrl = Page.ResolveUrl(ImageUrl);
                if (uxImage.ImageUrl.Contains("/Blog/"))
                {
                    uxImage.ImageUrl = uxImage.ImageUrl.Replace("/Blog/", "/");
                }

                if (MaximumWidth != null)
                {
                    Unit max = new Unit(MaximumWidth);

                    if (max.Type == UnitType.Pixel &&
                        File.Exists(Server.MapPath(ImageUrl)))
                    {
                        Bitmap mypic = new Bitmap(Server.MapPath(ImageUrl));

                        if (mypic.Width > max.Value)
                        {
                            uxImage.Width = max;
                        }

                        mypic.Dispose();
                    }
                }

                if (MaximumHight != null)
                {
                    Unit max = new Unit(MaximumHight);

                    if (max.Type == UnitType.Pixel &&
                        File.Exists(Server.MapPath(ImageUrl)))
                    {
                        Bitmap mypic = new Bitmap(Server.MapPath(ImageUrl));

                        if (mypic.Height > max.Value)
                        {
                            uxImage.Height = max;
                        }

                        mypic.Dispose();
                    }
                }
            }
        }
        catch (Exception ex)
        {
            SaveLogFile.SaveLog(ex);
        }
    }
Beispiel #3
0
 public void PopulateControl()
 {
     try
     {
         uxDomainKeyRequestText.Text = DataAccessContext.Configurations.GetValue("DomainRegistrationKey");
     }
     catch (Exception ex)
     {
         SaveLogFile.SaveLog(ex);
         HttpRuntime.UnloadAppDomain();
     }
 }
Beispiel #4
0
 private void PopulateControl()
 {
     try
     {
         Control userConttrol = LoadControl(String.Format("Themes/{0}/LayoutControls/Default.ascx", StyleSheetTheme));
         userConttrol.ID = "uxDefaultLayout";
         uxDefaultPanel.Controls.Add(userConttrol);
     }
     catch (Exception ex)
     {
         SaveLogFile.SaveLog(ex);
     }
 }
 private void PaymentModuleDatabaseConnected()
 {
     try
     {
         PaymentModuleSetup paymentModule = new PaymentModuleSetup();
         paymentModule.ProcessDatabaseConnected();
     }
     catch (Exception ex)
     {
         SaveLogFile.SaveLog(ex);
         // This error may occur if database is not upgraded to the latest version yet.
         // The ProcessedDatabaseConnected function will be called again after
         // database is upgraded to the latest version.
     }
 }
    private void Generate()
    {
        //* description
        //* expiration_date
        //* id
        //* image_link
        //* link
        //* title
        uxFileNameLink.Text        = "";
        uxFileNameLink.NavigateUrl = "";
        uxMessage.Clear();

        ArrayList items = uxDataFeedDetails.GetSelectedCategory();

        if (items.Count > 0)
        {
            if (uxDataFeedDetails.GetFileName().Trim() == string.Empty)
            {
                uxMessage.DisplayError(Resources.MarketingMessages.EmptyUploadField);
                return;
            }

            if (String.IsNullOrEmpty(Currency.ConvertPriceToSelectedCurrency(Convert.ToDecimal(0),
                                                                             currencyList[uxDataFeedDetails.GetGoogleCountryCode()])))
            {
                uxMessage.DisplayError(String.Format(Resources.MarketingMessages.CurrencyError,
                                                     currencyList[uxDataFeedDetails.GetGoogleCountryCode()]));
                return;
            }

            try
            {
                string saveFileName = GetFilePathName();
                string xmlFilename  = Server.MapPath("../" + saveFileName);

                bool exportStatus = false;

                XmlWriterSettings xmlSetting = new XmlWriterSettings();
                xmlSetting.Encoding = System.Text.Encoding.UTF8;
                xmlSetting.Indent   = true;

                XmlWriter writer = XmlWriter.Create(xmlFilename, xmlSetting);

                writer.WriteStartDocument();
                writer.WriteStartElement("rss");  //<rss>
                writer.WriteAttributeString("version", "2.0");
                writer.WriteAttributeString("xmlns", "g", null, "http://base.google.com/ns/1.0");

                writer.WriteStartElement("channel");  //<channel>
                writer.WriteElementString("title", uxDataFeedDetails.GetDataFeedTitle());
                // Do not return https:// for storefront link
                writer.WriteElementString("link", "http://" + CurrentStore.UrlName);
                writer.WriteElementString("description", uxDataFeedDetails.GetDataFeedDescription());

                ArrayList errorDupMapping = new ArrayList();
                try
                {
                    exportStatus = true;

                    List <string> SkuList = new List <string>();
                    for (int i = 0; i < items.Count; i++)
                    {
                        IList <Product> productList = DataAccessContext.ProductRepository.GetByCategoryID(
                            uxLanguageControl.CurrentCulture,
                            items[i].ToString(),
                            "ProductID",
                            BoolFilter.ShowTrue,
                            CurrentStore.StoreID
                            );
                        foreach (Product product in productList)
                        {
                            bool isAlreadyGen = false;
                            if (IncludeOutOfStock(product.SumStock, product.UseInventory) &&
                                !SkuList.Contains(product.Sku))
                            {
                                SkuList.Add(product.Sku);
                                if ((product.ProductOptionGroups == null) || (product.ProductOptionGroups.Count == 0))
                                {
                                    WriteProductDetails(product, uxLanguageControl.CurrentCulture, writer, null, null, null, null);
                                    isAlreadyGen = true;
                                }
                                else
                                {
                                    ArrayList variantMap = new ArrayList();
                                    foreach (ProductOptionGroup optionGroup in product.ProductOptionGroups)
                                    {
                                        for (int ui = 3; ui <= 6; ui++)
                                        {
                                            GoogleOptionMapping optionMapping = DataAccessContext.GoogleFeedMappingRepository.GetOneGoogleOptionMapping(uxLanguageControl.CurrentCulture, ui.ToString(), optionGroup.OptionGroupID);
                                            if ((optionMapping != null) && (!optionMapping.IsNull))
                                            {
                                                variantMap.Add(optionMapping);
                                            }
                                        }
                                    }

                                    // Checking duplicate mapping option
                                    bool isDupMapping = false;
                                    for (int j = 0; j < variantMap.Count; j++)
                                    {
                                        for (int k = 0; k < variantMap.Count; k++)
                                        {
                                            if (isDupMapping == true)
                                            {
                                                break;
                                            }
                                            if (j == k)
                                            {
                                                continue;
                                            }
                                            GoogleOptionMapping mapA = ( GoogleOptionMapping )variantMap[j];
                                            GoogleOptionMapping mapB = ( GoogleOptionMapping )variantMap[k];
                                            if (mapA.GoogleFeedTagID == mapB.GoogleFeedTagID)
                                            {
                                                isDupMapping = true;
                                                break;
                                            }
                                        }
                                    }
                                    if (isDupMapping == true)
                                    {
                                        exportStatus = false;
                                        errorDupMapping.Add(product.ProductID);
                                        continue;
                                    }

                                    // Write Details by product Option
                                    ArrayList optionGroups = new ArrayList();
                                    string    itemGroupID  = generateRandomString(7);
                                    foreach (GoogleOptionMapping optionMap in variantMap)
                                    {
                                        optionGroups.Add(optionMap.OptionGroupID);
                                    }
                                    DataTable dt = DataAccessContext.ProductRepository.GetStockOptionLine(uxLanguageControl.CurrentCulture, ( string[] )optionGroups.ToArray(typeof(string)));
                                    if (dt != null)
                                    {
                                        foreach (DataRow row in dt.Rows)
                                        {
                                            ArrayList optionItems   = new ArrayList();
                                            ArrayList optionItemIDs = new ArrayList();
                                            for (int im = 1; im < dt.Columns.Count - 1; im += 2)
                                            {
                                                optionItems.Add(row[im].ToString());
                                            }
                                            for (int jm = 0; jm < dt.Columns.Count - 1; jm += 2)
                                            {
                                                optionItemIDs.Add(row[jm].ToString());
                                            }
                                            WriteProductDetails(product, uxLanguageControl.CurrentCulture, writer, variantMap, optionItems, optionItemIDs, itemGroupID);
                                            isAlreadyGen = true;
                                        }
                                    }
                                }

                                if (!isAlreadyGen)
                                {
                                    WriteProductDetails(product, uxLanguageControl.CurrentCulture, writer, null, null, null, null);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    SaveLogFile.SaveLog(ex);
                }
                finally
                {
                    writer.WriteEndDocument();//</rss>
                    writer.Close();
                }
                uxFileNameLink.Text        = Path.GetFileName(saveFileName);
                uxFileNameLink.NavigateUrl = "../DownloadFile.aspx?FilePath=../" + saveFileName;
                uxFileNameLink.Target      = "_blank";
                if (exportStatus)
                {
                    uxMessage.DisplayMessage(Resources.MarketingMessages.UploadSuccess);
                }
                else
                {
                    if (errorDupMapping.Count > 0)
                    {
                        uxMessage.DisplayError("Variant mapping rules are dulicated. ProductID: " + String.Join(",", ( string[] )errorDupMapping.ToArray(typeof(string))));
                    }
                    else
                    {
                        uxMessage.DisplayError("Have problem to export.");
                    }
                }
            }
            catch
            {
                uxMessage.DisplayError(Resources.MarketingMessages.UploadError);
            }
        }
        else
        {
            uxMessage.DisplayError("Please select catagory that you want to export.");
        }
    }