Ejemplo n.º 1
0
        protected void DispatchGridCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName != DeleteOrderOptionCommand)
            {
                return;
            }

            int orderOptionId;

            if (!Int32.TryParse((string)e.CommandArgument, out orderOptionId))
            {
                return;
            }

            var result = DeletedOrderOption(orderOptionId);

            if (result)
            {
                FilteredListing.Rebind();
            }

            ctlAlertMessage.PushAlertMessage(
                message: String.Format("{0} {1} {2}",
                                       AppLogic.GetString("admin.common.OrderOption", Locale),
                                       orderOptionId,
                                       AppLogic.GetString(result ? "admin.common.HasBeenDeleted" : "admin.common.CouldNotBeDeleted", Locale)),
                type: AlertMessage.AlertType.Success);
        }
Ejemplo n.º 2
0
 protected void gMain_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "DeleteItem")
     {
         DeleteState(Localization.ParseNativeInt(e.CommandArgument.ToString()));
         AlertMessage.PushAlertMessage("Item Deleted", AspDotNetStorefrontControls.AlertMessage.AlertType.Success);
         FilteredListing.Rebind();
     }
 }
 /// <summary>
 /// Row Command
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void ShippingZoneGrid_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "DeleteItem")
     {
         if (DeleteZone(Localization.ParseNativeInt(e.CommandArgument.ToString())))
         {
             FilteredListing.Rebind();
         }
     }
 }
Ejemplo n.º 4
0
        protected void btnAddToLevel_Click(object sender, EventArgs e)
        {
            string addValue = txtNewEmail.Text.Trim();

            if (!string.IsNullOrEmpty(addValue))
            {
                int customerIdToAdd = 0;
                int parsedCustomerID;

                if (int.TryParse(addValue, out parsedCustomerID))                   //Admin entered a customer ID
                {
                    customerIdToAdd = parsedCustomerID;

                    if (!CheckForValidCustomer(customerIdToAdd))
                    {
                        customerIdToAdd = 0;
                    }
                }
                else                    //Admin entered an email
                {
                    customerIdToAdd = Customer.GetIDFromEMail(addValue);
                }

                if (customerIdToAdd != 0)
                {
                    string customerLevelNameToAdd = DisplayLevelName(CustomerLevelId);
                    if (!CheckIfCustomerLevelCustomerExists(customerIdToAdd, CustomerLevelId))
                    {
                        // clear the carts for this customer. This is to ensure their product pricing is correct
                        // their current cart can have customer level pricing, not retail pricing, and this prevents that:
                        DB.ExecuteSQL(String.Format("delete from shoppingcart where customerid={0}", customerIdToAdd));
                        DB.ExecuteSQL(String.Format("delete from kitcart where customerid={0}", customerIdToAdd));

                        DB.ExecuteSQL(String.Format("Update customer set CustomerLevelID={0} where CustomerID={1}", CustomerLevelId, customerIdToAdd));
                        AlertMessageDisplay.PushAlertMessage(string.Format("{0}{1}", AppLogic.GetString("admin.customerlevel.CustomerAdded", ThisCustomer.LocaleSetting), string.IsNullOrEmpty(customerLevelNameToAdd) ? string.Empty : string.Format(": {0} ({1}={2})", customerLevelName, AppLogic.GetString("admin.common.id", ThisCustomer.LocaleSetting), CustomerLevelId)), AspDotNetStorefrontControls.AlertMessage.AlertType.Success);
                    }
                    else
                    {
                        AlertMessageDisplay.PushAlertMessage(string.Format("{0}{1}", AppLogic.GetString("admin.customerlevel.AlreadyExistsInLevel", ThisCustomer.LocaleSetting), string.IsNullOrEmpty(customerLevelNameToAdd) ? string.Empty : string.Format(": {0} ({1}={2})", customerLevelName, AppLogic.GetString("admin.common.id", ThisCustomer.LocaleSetting), CustomerLevelId)), AspDotNetStorefrontControls.AlertMessage.AlertType.Error);
                    }
                }
                else
                {
                    AlertMessageDisplay.PushAlertMessage(AppLogic.GetString("admin.customerlevel.NotInDatabase", ThisCustomer.LocaleSetting), AspDotNetStorefrontControls.AlertMessage.AlertType.Warning);
                }

                txtNewEmail.Text = string.Empty;
                FilteredListing.Rebind();
            }
            else
            {
                AlertMessageDisplay.PushAlertMessage(AppLogic.GetString("admin.customerlevel.IdOrEmailRequired", ThisCustomer.LocaleSetting), AspDotNetStorefrontControls.AlertMessage.AlertType.Error);
            }
        }
Ejemplo n.º 5
0
        protected void grdCustomersInLevel_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "ClearLevel")
            {
                grdCustomersInLevel.EditIndex = -1;
                DB.ExecuteSQL(String.Format("update Customer set CustomerLevelID=0 where CustomerID={0}", e.CommandArgument));
                AlertMessageDisplay.PushAlertMessage(AppLogic.GetString("admin.customerlevel.RemovedFromLevel", ThisCustomer.LocaleSetting), AspDotNetStorefrontControls.AlertMessage.AlertType.Success);
            }

            FilteredListing.Rebind();
        }
Ejemplo n.º 6
0
    void BulkClearSalesPrice()
    {
        using (var connection = new SqlConnection(DB.GetDBConn()))
        {
            connection.Open();

            var whereClause = FilteredListing.GetFilterWhereClause();
            var setClause   = "null";
            var command     = new SqlCommand(BuildBatchUpdateCommandString(setClause, whereClause.Sql), connection);
            command.Parameters.AddRange(whereClause.Parameters.ToArray());

            DB.ExecuteSQL(command);
        }
    }
Ejemplo n.º 7
0
    void BulkSaveSalesPrice(double discount)
    {
        using (var connection = new SqlConnection(DB.GetDBConn()))
        {
            connection.Open();

            var whereClause = FilteredListing.GetFilterWhereClause();
            var setClause   = ("Price * @discount");
            var command     = new SqlCommand(BuildBatchUpdateCommandString(setClause, whereClause.Sql), connection);
            command.Parameters.Add(new SqlParameter("discount", (100 - discount) / 100));
            command.Parameters.AddRange(whereClause.Parameters.ToArray());

            DB.ExecuteSQL(command);
        }
    }
Ejemplo n.º 8
0
    void Save()
    {
        using (var connection = new SqlConnection(DB.GetDBConn()))
        {
            connection.Open();

            var items = repeatMap.Items.Cast <RepeaterItem>().Where(item => item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem);
            foreach (var item in items)
            {
                var variantId        = int.Parse((item.FindControl("lblVariantId") as Label).Text);
                var variantName      = (item.FindControl("txtVariantName") as TextBox).Text;
                var variantSKUSuffix = (item.FindControl("txtVariantSKUSuffix") as TextBox).Text;
                var price            = decimal.Parse((item.FindControl("txtPrice") as TextBox).Text);
                var inventory        = int.Parse((item.FindControl("txtInventory") as TextBox).Text);
                var published        = (item.FindControl("chkPublished") as CheckBox).Checked;
                var where = FilteredListing.GetFilterWhereClause();

                decimal?salePrice = null;
                decimal result;
                if (decimal.TryParse((item.FindControl("txtSalePrice") as TextBox).Text, out result))
                {
                    salePrice = result;
                }

                using (var command = new SqlCommand(@"
					update ProductVariant set
						Name = dbo.SetMlValue(Name, @Name, @_locale),
						SKUSuffix = @SKUSuffix,
						Price = @Price,
						SalePrice = @SalePrice,
						Inventory = @Inventory,
						Published = @published
					where VariantID = @VariantID"                    , connection))
                {
                    command.Parameters.Add(new SqlParameter("VariantID", variantId));
                    command.Parameters.Add(new SqlParameter("Name", variantName));
                    command.Parameters.Add(new SqlParameter("SKUSuffix", variantSKUSuffix));
                    command.Parameters.Add(new SqlParameter("Price", price));
                    command.Parameters.Add(new SqlParameter("SalePrice", (object)salePrice ?? DBNull.Value));
                    command.Parameters.Add(new SqlParameter("Inventory", inventory));
                    command.Parameters.Add(new SqlParameter("Published", published));
                    command.Parameters.Add(new SqlParameter("_locale", where.Parameters.Where(p => p.ParameterName == "_locale").FirstOrDefault().Value));

                    DB.ExecuteSQL(command);
                }
            }
        }
    }
Ejemplo n.º 9
0
 protected void gMain_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "DeleteItem")
     {
         try
         {
             DeleteProductType(Localization.ParseNativeInt(e.CommandArgument.ToString()));
             ctlAlertMessage.PushAlertMessage("Item Deleted", AspDotNetStorefrontControls.AlertMessage.AlertType.Success);
         }
         catch (Exception ex)
         {
             ctlAlertMessage.PushAlertMessage(ex.Message, AspDotNetStorefrontControls.AlertMessage.AlertType.Error);
         }
         FilteredListing.Rebind();
     }
 }
        void RemoveCustomerLevelCommandHandler(object sender, CommandEventArgs e)
        {
            int customerLevelId;

            if (!Int32.TryParse((string)e.CommandArgument, out customerLevelId))
            {
                return;
            }

            if (RemoveCustomerLevel(customerLevelId))
            {
                AlertMessageDisplay.PushAlertMessage("admin.Common.ItemDeleted".StringResource(), AlertMessage.AlertType.Success);

                FilteredListing.Rebind();
            }
        }
Ejemplo n.º 11
0
        protected void btnExport_Click(object sender, EventArgs e)
        {
            var exportContents = new StringBuilder();

            exportContents.AppendLine("Action, Description, Date, CustomerID, Email");

            // Can't use the grid as a datasource as it's paged, so query the DB with the same filters the grid is currently displaying
            using (var connection = new SqlConnection(DB.GetDBConn()))
                using (var command = connection.CreateCommand())
                {
                    var whereClause = FilteredListing.GetFilterWhereClause();

                    command.CommandText = string.Format(
                        @"select SecurityAction Action, Description, ActionDate Date, UpdatedBy CustomerID, c.EMail 
					from SecurityLog with (NOLOCK) 
					left outer join Customer c with (NOLOCK) on SecurityLog.UpdatedBy = c.CustomerID 
					where {0}"                    , whereClause.Sql);

                    command.Parameters.AddRange(whereClause.Parameters.ToArray());

                    connection.Open();
                    using (var reader = command.ExecuteReader())
                        while (reader.Read())
                        {
                            var shippedOn = DB.RSFieldDateTime(reader, "Date");

                            exportContents.AppendFormat(@"""{0}"",""{1}"",{2},{3},{4}{5}",
                                                        DecryptValue(reader.Field("Action")).Replace("\"", "\"\""),
                                                        DecryptValue(reader.Field("Description").Replace("\"", "\"\"")),
                                                        shippedOn == DateTime.MinValue
                                                                ? string.Empty
                                                                : shippedOn.ToString(),
                                                        reader.FieldInt("CustomerID"),
                                                        reader.Field("Email"),
                                                        Environment.NewLine);
                        }
                }

            // Send the CSV
            Response.Clear();
            Response.AddHeader("content-disposition", "attachment; filename=SecurityLogExport.csv");
            Response.BufferOutput = false;
            Response.ContentType  = "text/csv";
            Response.Output.Write(exportContents);
            Response.Flush();
            Response.End();
        }
Ejemplo n.º 12
0
        void PublishAffiliateCommandHandler(object sender, CommandEventArgs e, bool published, string successStringResource)
        {
            int affiliateId;

            if (!Int32.TryParse((string)e.CommandArgument, out affiliateId))
            {
                return;
            }

            if (SetPublishedFlag(affiliateId, published))
            {
                AlertMessageDisplay.PushAlertMessage(
                    BuildAffiliateAlertMessage(affiliateId, successStringResource),
                    AlertMessage.AlertType.Success);

                FilteredListing.Rebind();
            }
        }
Ejemplo n.º 13
0
        void SetDefaultVariantCommandHandler(object sender, CommandEventArgs e)
        {
            int variantId;

            if (!Int32.TryParse((string)e.CommandArgument, out variantId))
            {
                return;
            }

            if (SetDefaultVariant(variantId))
            {
                AlertMessageDisplay.PushAlertMessage(
                    String.Format("Variant {0} set as default variant", variantId),
                    AlertMessage.AlertType.Success);

                FilteredListing.Rebind();
            }
        }
Ejemplo n.º 14
0
        void CloneVariantCommandHandler(object sender, CommandEventArgs e)
        {
            int variantId;

            if (!Int32.TryParse((string)e.CommandArgument, out variantId))
            {
                return;
            }

            if (CloneVariant(variantId))
            {
                AlertMessageDisplay.PushAlertMessage(
                    AppLogic.GetString("admin.entityProductVariantsOverview.VariantCloned", ThisCustomer.SkinID, ThisCustomer.LocaleSetting),
                    AlertMessage.AlertType.Success);

                FilteredListing.Rebind();
            }
        }
Ejemplo n.º 15
0
        void DeleteVariantCommandHandler(object sender, CommandEventArgs e, bool deleted, string successStringResource)
        {
            int variantId;

            if (!Int32.TryParse((string)e.CommandArgument, out variantId))
            {
                return;
            }

            if (SetDeletedFlag(variantId, deleted))
            {
                AlertMessageDisplay.PushAlertMessage(
                    BuildAlertMessage(variantId, successStringResource),
                    AlertMessage.AlertType.Success);

                FilteredListing.Rebind();
            }
        }
Ejemplo n.º 16
0
    protected void Save(object sender, EventArgs e)
    {
        try
        {
            var items = repeatMap.Items.Cast <RepeaterItem>().Where(item => item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem);
            foreach (var item in items)
            {
                var variantId = int.Parse(((Label)item.FindControl("lblVariantId")).Text);
                var where = FilteredListing.GetFilterWhereClause();

                string dimensions = BuildDimensions(item);

                var isShipSeparately = ((CheckBox)item.FindControl("chkIsShipSeparately")).Checked;

                decimal?weight = null;
                decimal result;
                if (decimal.TryParse(((TextBox)item.FindControl("txtWeight")).Text, out result) && result > 0)
                {
                    weight = result;
                }

                using (var connection = new SqlConnection(DB.GetDBConn()))
                {
                    if (weight != null)
                    {
                        SaveWeight(weight.Value, variantId, connection);
                    }

                    if (dimensions != null)
                    {
                        SaveDimensions(dimensions, variantId, connection);
                    }

                    SaveShipSeparately(isShipSeparately, variantId, connection);
                }
            }

            AlertMessage.PushAlertMessage(AppLogic.GetString("admin.bulkeditweights.weightsupdated", ThisCustomer.LocaleSetting), AspDotNetStorefrontControls.AlertMessage.AlertType.Success);
        }
        catch (Exception ex)
        {
            AlertMessage.PushAlertMessage(ex.Message, AspDotNetStorefrontControls.AlertMessage.AlertType.Error);
        }
    }
Ejemplo n.º 17
0
        protected void RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == DeleteCommand)
            {
                var salesPromptId = Localization.ParseNativeInt((string)e.CommandArgument);

                try
                {
                    DB.ExecuteSQL(
                        "update SalesPrompt set Deleted = 1 where SalesPromptID = @id",
                        new[] { new SqlParameter("@id", salesPromptId) });

                    ctrlAlertMessage.PushAlertMessage("Sales prompt deleted", AlertMessage.AlertType.Success);
                }
                catch (Exception exception)
                {
                    ctrlAlertMessage.PushAlertMessage("Unable to delete sales prompt:<br />" + exception.ToString(), AlertMessage.AlertType.Error);
                }

                FilteredListing.Rebind();
            }
        }
Ejemplo n.º 18
0
        void CloneProductCommandHandler(object sender, CommandEventArgs e)
        {
            int productId;

            if (!Int32.TryParse((string)e.CommandArgument, out productId))
            {
                return;
            }

            if (CloneProduct(productId))
            {
                AlertMessageDisplay.PushAlertMessage(
                    BuildProductAlertMessage(productId, "admin.productgrid.ProductCloned"),
                    AlertMessage.AlertType.Success);

                FilteredListing.Rebind();
            }
            else
            {
                AlertMessageDisplay.PushAlertMessage(
                    BuildProductAlertMessage(productId, "admin.productgrid.ProductNotCloned"),
                    AlertMessage.AlertType.Error);
            }
        }
Ejemplo n.º 19
0
        protected void Save_Click(object sender, EventArgs e)
        {
            var customerAnonymizeSuccesses = new StringBuilder();
            var cannotBeAnonymized         = new StringBuilder();
            var customerAnonymizeErrors    = new StringBuilder();

            var customerDeleteSuccesses = new StringBuilder();
            var cannotBeDeleted         = new StringBuilder();
            var customerDeleteErrors    = new StringBuilder();

            var orderAnonymizeSuccesses = new StringBuilder();
            var orderAnonymizeErrors    = new StringBuilder();

            foreach (GridViewRow row in Grid.Rows)
            {
                if (row.RowType != DataControlRowType.DataRow)
                {
                    continue;
                }

                // We're getting the customer id through a hidden field because the grid data keys are cleared in the GridLoad() sorting above.
                var customerId   = Convert.ToInt32(((HiddenField)row.FindControl("hidCustomerId")).Value);
                var chkAnonymize = (CheckBox)row.FindControl("chkAnonymizeCustomer");
                var chkRemove    = (CheckBox)row.FindControl("chkRemoveCustomer");
                var customerInfo = ((HiddenField)row.FindControl("hidCustomerInfo")).Value;

                if (chkAnonymize.Checked)
                {
                    if (!DataRetentionService.CustomerCanBeAnonymized(customerId))
                    {
                        cannotBeAnonymized
                        .Append(customerInfo)
                        .Append("<br />");

                        continue;
                    }

                    var result = DataRetentionService.AnonymizeCustomer(customerId);

                    if (!result.Success)
                    {
                        customerAnonymizeErrors
                        .Append(customerInfo)
                        .Append("<br />");

                        SysLog.LogException(result.Error, MessageTypeEnum.GeneralException, MessageSeverityEnum.Error);

                        continue;
                    }

                    if (!result.Value)
                    {
                        customerAnonymizeErrors
                        .Append(customerInfo)
                        .Append("<br />");

                        continue;
                    }

                    customerAnonymizeSuccesses
                    .Append(customerInfo)
                    .Append("<br />");

                    foreach (var orderResult in DataRetentionService.AnonymizeOrders(customerId))
                    {
                        if (!orderResult.Success)
                        {
                            orderAnonymizeErrors
                            .Append(customerInfo)
                            .Append("<br />");

                            SysLog.LogException(result.Error, MessageTypeEnum.GeneralException, MessageSeverityEnum.Error);

                            continue;
                        }

                        if (!orderResult.Value)
                        {
                            orderAnonymizeErrors
                            .Append(customerInfo)
                            .Append("<br />");

                            continue;
                        }

                        orderAnonymizeSuccesses
                        .Append(customerInfo)
                        .Append("<br />");
                    }
                }
            }

            if (customerAnonymizeSuccesses.Length > 0)
            {
                AlertMessageDisplay.PushAlertMessage(
                    string.Concat("The following customer(s) have been anonymized:<br />", customerAnonymizeSuccesses.ToString()),
                    AlertMessage.AlertType.Success);
            }

            if (cannotBeAnonymized.Length > 0)
            {
                AlertMessageDisplay.PushAlertMessage(
                    string.Concat("The following customer(s) and their orders could not be anonymized:<br />", cannotBeAnonymized.ToString()),
                    AlertMessage.AlertType.Error);
            }

            if (customerAnonymizeErrors.Length > 0)
            {
                AlertMessageDisplay.PushAlertMessage(
                    string.Concat("The following customer(s) could not be anonymized:<br />", customerAnonymizeErrors.ToString()),
                    AlertMessage.AlertType.Error);
            }

            if (customerDeleteSuccesses.Length > 0)
            {
                AlertMessageDisplay.PushAlertMessage(
                    string.Concat("The following customer(s) have been removed:<br />", customerDeleteSuccesses.ToString()),
                    AlertMessage.AlertType.Success);
            }

            if (cannotBeDeleted.Length > 0)
            {
                AlertMessageDisplay.PushAlertMessage(
                    string.Concat("The following customer(s) and their orders could not be removed:<br />", cannotBeDeleted.ToString()),
                    AlertMessage.AlertType.Error);
            }

            if (customerDeleteErrors.Length > 0)
            {
                AlertMessageDisplay.PushAlertMessage(
                    string.Concat("The following customer(s) could not be removed:<br />", customerDeleteErrors.ToString()),
                    AlertMessage.AlertType.Error);
            }

            if (orderAnonymizeSuccesses.Length > 0)
            {
                AlertMessageDisplay.PushAlertMessage(
                    string.Concat("The following customer(s) orders have been anonymized:<br />", orderAnonymizeSuccesses.ToString()),
                    AlertMessage.AlertType.Success);
            }

            if (orderAnonymizeErrors.Length > 0)
            {
                AlertMessageDisplay.PushAlertMessage(
                    string.Concat("The following customer's orders could not be anonymized:<br />", orderAnonymizeErrors.ToString()),
                    AlertMessage.AlertType.Error);
            }

            FilteredListing.Rebind();
        }
Ejemplo n.º 20
0
        protected void btnExport_Click(object sender, EventArgs e)
        {
            var exportContents = new StringBuilder();

            exportContents.AppendLine(MakeHeaderRow());

            //Can't use the grid as a datasource as it's paged, so query the DB with the same filters the grid is currently displaying
            using (var conn = new SqlConnection(DB.GetDBConn()))
            {
                conn.Open();

                var whereClause = FilteredListing.GetFilterWhereClause();
                var sql         = string.Format(
                    @"SELECT OrderNumber, ShippedOn, ShippedVIA, ShippingTrackingNumber,
						ShippingMethod, ShippingFirstName, ShippingLastName, ShippingAddress1,
						ShippingAddress2, ShippingSuite, ShippingCity, ShippingState, ShippingZip,
						ShippingCountry, ShippingPhone, Phone, Email
					FROM Orders WHERE {0}"                    , whereClause.Sql);

                using (var command = new SqlCommand(sql, conn))
                {
                    command.Parameters.AddRange(whereClause.Parameters.ToArray());

                    using (IDataReader rs = command.ExecuteReader())
                    {
                        while (rs.Read())
                        {
                            exportContents.Append(DB.RSFieldInt(rs, "OrderNumber").ToString());
                            exportContents.Append(",");

                            var shippedOn = DB.RSFieldDateTime(rs, "ShippedOn");
                            exportContents.Append(shippedOn == DateTime.MinValue ? string.Empty : shippedOn.ToString());
                            exportContents.Append(",");

                            exportContents.Append(DB.RSField(rs, "ShippedVIA"));
                            exportContents.Append(",");

                            exportContents.Append(DB.RSField(rs, "ShippingTrackingNumber"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "ShippingMethod"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "ShippingFirstName"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "ShippingLastName"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "ShippingAddress1"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "ShippingAddress2"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "ShippingSuite"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "ShippingCity"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "ShippingState"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "ShippingZip"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "ShippingCountry"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "ShippingPhone"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "Phone"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "Email"));
                            exportContents.Append("\r\n");
                        }
                    }
                }
            }

            //Save a copy in images
            var filepath     = CommonLogic.SafeMapPath("~/images") + "\\";
            var filename     = "ShippingExport_" + Localization.ToNativeDateTimeString(DateTime.Now).Replace(" ", "_").Replace(",", "_").Replace("/", "_").Replace(":", "_").Replace(".", "_") + ".csv";
            var fullFilePath = filepath + filename;

            File.WriteAllText(fullFilePath, exportContents.ToString());

            // Send the CSV
            Response.Clear();
            Response.ClearHeaders();
            Response.ClearContent();
            Response.AddHeader("content-disposition", "attachment; filename=ShippingExport.csv");
            Response.BufferOutput = false;
            Response.ContentType  = "text/csv";
            Response.TransmitFile(fullFilePath);
            Response.Flush();
            Response.End();
        }
Ejemplo n.º 21
0
        protected void btnExport_Click(Object sender, EventArgs e)
        {
            Response.Clear();
            Response.ContentType = "application/octet-stream";
            Response.AddHeader("Content-Disposition", "attachment; filename=SystemLog.txt");

            Response.Write("----------------------------------------------------------------------\r\n");
            Response.Write("----------------------------------------------------------------------\r\n");
            Response.Write("SYSTEM INFORMATION \r\n");
            Response.Write("----------------------------------------------------------------------\r\n");
            Response.Write("----------------------------------------------------------------------\r\n");

            Response.Write("\r\n");
            Response.Write("Version:            " + CommonLogic.GetVersion() + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("On Live Server:     " + AppLogic.OnLiveServer().ToString() + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("UseSSL:             " + AppLogic.UseSSL().ToString() + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Is Secure Page:     " + CommonLogic.IsSecureConnection().ToString() + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Changed Admin Dir:  " + CommonLogic.IIF(AppLogic.AppConfig("AdminDir").ToLowerInvariant() == "admin", "No", "Yes") + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Caching:            " + (AppLogic.AppConfigBool("CacheMenus") ? AppLogic.GetString("admin.common.OnUC", AppLogic.GetStoreSkinID(AppLogic.StoreID()), Localization.GetDefaultLocale()) : AppLogic.GetString("admin.common.OffUC", AppLogic.DefaultSkinID(), Localization.GetDefaultLocale())) + "\r\n");
            Response.Write("\r\n");
            Response.Write("----------------------LOCALIZATION----------------------\r\n");
            Response.Write("\r\n");
            Response.Write("Web Config Locale:  " + Localization.GetDefaultLocale() + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("SQL Server Locale:  " + Localization.GetSqlServerLocale() + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Store Currency:     " + AppLogic.AppConfig("Localization.StoreCurrency") + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Store Currency Code:" + AppLogic.AppConfig("Localization.StoreCurrencyNumericCode") + "\r\n");
            Response.Write("\r\n");
            Response.Write("----------------------GATEWAY INFO----------------------\r\n");
            Response.Write("\r\n");
            Response.Write("Payment Gateway:    " + AppLogic.ActivePaymentGatewayRAW() + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Use Live Transactions:" + (AppLogic.AppConfigBool("UseLiveTransactions") ? AppLogic.GetString("admin.splash.aspx.20", AppLogic.GetStoreSkinID(AppLogic.StoreID()), Localization.GetDefaultLocale()) : AppLogic.GetString("admin.splash.aspx.21", AppLogic.DefaultSkinID(), Localization.GetDefaultLocale())) + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Transaction Mode:   " + AppLogic.AppConfig("TransactionMode").ToString() + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Payment Methods:    " + AppLogic.AppConfig("PaymentMethods").ToString() + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Primary Currency:   " + Localization.GetPrimaryCurrency() + "\r\n");
            Response.Write("\r\n");
            Response.Write("----------------------SHIPPING INFO----------------------\r\n");
            Response.Write("\r\n");
            Response.Write("Shipping Rates Table:" + DB.GetSqlS("select Name as S from dbo.ShippingCalculation where Selected=1") + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Origin State:       " + AppLogic.AppConfig("RTShipping.OriginState") + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Origin Zip:         " + AppLogic.AppConfig("RTShipping.OriginZip") + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Origin Country:     " + AppLogic.AppConfig("RTShipping.OriginCountry") + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Free Shipping Threshold: " + AppLogic.AppConfigNativeDecimal("FreeShippingThreshold").ToString() + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Free Shipping Method:" + AppLogic.AppConfig("ShippingMethodIDIfFreeShippingIsOn") + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Allow Rate Selection:" + CommonLogic.IIF(AppLogic.AppConfigBool("FreeShippingAllowsRateSelection"), "On", "Off") + "\r\n");
            Response.Write("\r\n\r\n");

            var whereClause = FilteredListing.GetFilterWhereClause();
            var sql         = String.Format("select * from aspdnsf_SysLog where {0}", whereClause.Sql);

            using (var connection = new SqlConnection(DB.GetDBConn()))
                using (var command = new SqlCommand(sql, connection))
                {
                    connection.Open();
                    command.Parameters.AddRange(whereClause.Parameters.ToArray());

                    using (var reader = command.ExecuteReader())
                        while (reader.Read())
                        {
                            Response.Write("----------------------------------------------------------------------\r\n");
                            Response.Write("----------------------------------------------------------------------\r\n");
                            Response.Write(AppLogic.GetString("admin.systemlog.aspx.1", AppLogic.GetStoreSkinID(AppLogic.StoreID()), Localization.GetDefaultLocale()) + ": ");
                            Response.Write(DB.RSFieldInt(reader, "SysLogID").ToString() + "  " + DB.RSFieldDateTime(reader, "CreatedOn").ToString() + "  \r\n");
                            Response.Write("----------------------------------------------------------------------\r\n");
                            Response.Write("----------------------------------------------------------------------\r\n");
                            Response.Write("\r\n\r\n");
                            Response.Write(DB.RSField(reader, "Message"));
                            Response.Write("\r\n\r\n");
                            Response.Write(DB.RSField(reader, "Details"));
                            Response.Write("\r\n\r\n");
                        }
                }

            Response.Flush();
            Response.Close();
        }