Esempio n. 1
0
    protected void uxCategoryImportButton_Click(object sender, EventArgs e)
    {
        uxImportCategoryMessagePanel.Controls.Clear();
        string localFilePath = Server.MapPath("~/" + uxCategoryCsvFileNameText.Text.Trim());

        if (!File.Exists(localFilePath))
        {
            Label label = new Label();
            label.ForeColor = Color.Red;
            label.Text      = "File not found.";
            uxImportCategoryMessagePanel.Controls.Add(label);
            return;
        }

        Culture culture = DataAccessContext.CultureRepository.GetOne(uxLanguageDrop.SelectedValue);
        CategoryImportHelper       importer = new CategoryImportHelper(culture, "Category");
        CategoryImportHelperStatus status   = new CategoryImportHelperStatus("Category");
        TimeSpan timeDiff;

        switch (uxCategoryImportModeRadioList.SelectedValue)
        {
        case "Overwrite":
            status = importer.ImportCategoryOverWrite(
                "~/" + uxCategoryCsvFileNameText.Text.Trim(),
                CurrentStoreID,
                out timeDiff);
            UpdateImportMessage(status, uxImportCategoryMessagePanel, true);
            UpdateTimeMessage(timeDiff, uxImportCategoryMessagePanel);
            break;

        default: break;
        }

        AdminUtilities.ClearAllCache();
    }
Esempio n. 2
0
    private void UpdateImportMessage(CategoryImportHelperStatus status, Panel uxMessagePanel, bool isImportCustomer)
    {
        switch (status.Status)
        {
        case CategoryImportHelperStatus.ErrorStatus.Success:
            Label successlabel = new Label();
            successlabel.ForeColor = Color.Blue;
            if (isImportCustomer)
            {
                successlabel.Text = "<b>Import finished successfully!</b><br />" +
                                    status.ImportedCount + " row(s) imported<br />" +
                                    status.UpdatedCount + " row(s) updated<br />" +
                                    status.ErrorCount + " error(s)<br />";
            }
            else
            {
                successlabel.Text = "<b>Import finished successfully!</b><br />" +
                                    status.ImportedCount + " row(s) imported<br />" +
                                    status.UpdatedCount + " row(s) updated<br />" +
                                    status.ErrorCount + " error(s)<br />";
            }
            uxMessagePanel.Controls.Add(successlabel);
            uxMessagePanel.CssClass = "mgl30";
            break;

        case CategoryImportHelperStatus.ErrorStatus.DoneWithErrors:
            AddErrorMessage(status, uxMessagePanel, isImportCustomer);
            break;

        case CategoryImportHelperStatus.ErrorStatus.Fatal:
            AddFatalErrorMessage(status, uxMessagePanel);
            break;
        }
    }
Esempio n. 3
0
 private void AddErrorMessage(CategoryImportHelperStatus status, Panel uxMessagePanel, bool isImportCustomer)
 {
     AddCategoryMessageHeader(status, uxMessagePanel);
     AddOtherErrorMessage(status, uxMessagePanel);
     AddCategoryFieldErrorMessage(status, uxMessagePanel);
     AddRootCategoryErrorMessage(status, uxMessagePanel);
     AddParentContainProductErrorMessage(status, uxMessagePanel);
     AddRootChangedErrorMessage(status, uxMessagePanel);
 }
Esempio n. 4
0
    private void AddParentContainProductErrorMessage(CategoryImportHelperStatus status, Panel uxMessagePanel)
    {
        Label label = new Label();

        label.ForeColor = Color.FromArgb(153, 0, 255);
        label.Text      = status.ParentContainProductError + "<br />";
        if (label.Text.Trim() != "<br />")
        {
            uxMessagePanel.Controls.Add(label);
        }
    }
Esempio n. 5
0
    private void AddFatalErrorMessage(CategoryImportHelperStatus status, Panel uxMessagePanel)
    {
        Label label = new Label();

        label.ForeColor = Color.Red;
        label.Text      = status.ErrorMessage + "<br />";
        if (label.Text.Trim() != "<br />")
        {
            uxMessagePanel.Controls.Add(label);
        }
    }
Esempio n. 6
0
    private void AddCategoryMessageHeader(CategoryImportHelperStatus status, Panel uxMessagePanel)
    {
        Label label = new Label();

        label.ForeColor = Color.Red;
        label.Text      = "<b>Import finished with errors.</b><br />" +
                          status.ImportedCount + " row(s) imported<br />" +
                          status.UpdatedCount + " row(s) updated<br />" +
                          status.ErrorCount + " error(s)" + "<br /><br />";
        uxMessagePanel.Controls.Add(label);
        uxMessagePanel.CssClass = "mgl30";
    }