public IActionResult GetCommonInfo_JSON() { double a = new CommonStatistic(_iProductRepository, _iCartRepository, _shoppingCartRepository, _importRepository, _importDetailRepository).GetTotalRevenueAllTime(); if (a == 0) { a = 0; } string converted = JsonConvert.SerializeObject( new { //Tổng lợi nhuận totalRevenue = a, //Tổng số đơn hàng totalSaleBillCount = new SaleStatistic(_iProductRepository, _iCartRepository, _shoppingCartRepository).CountSaleBillAllTime(), //Tổng số người dùng totalCustomer = new CustomerStatistic(_iCustomerRepository).CountCustomer(), //Tổng giá trị hàng tồn kho totalProductValue = new ProductStatistic(_iProductRepository).GetCurrentTotalProductValue() }, Formatting.None, new IsoDateTimeConverter() { DateTimeFormat = "yyyy-MM-dd" }); return(Content(converted, "application/json")); }
protected void btnResizePhoto_Click(object sender, EventArgs e) { if (CommonStatistic.IsRun) { return; } CommonStatistic.Init(); CommonStatistic.CurrentProcess = Request.Url.PathAndQuery; CommonStatistic.CurrentProcessName = Request.Url.PathAndQuery; CommonStatistic.IsRun = true; CommonStatistic.CurrentProcess = Request.Url.PathAndQuery; linkCancel.Visible = true; OutDiv.Visible = true; btnSave.Visible = false; try { CommonStatistic.TotalRow = PhotoService.GetCountPhotos(0, PhotoType.Product); CommonStatistic.StartNew(Resize); //CommonStatistic.ThreadImport = new Thread(Resize) { IsBackground = true }; //CommonStatistic.ThreadImport.Start(); } catch (Exception ex) { Debug.LogError(ex); lError.Text = ex.Message; lError.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { SetMeta(string.Format("{0} - {1}", SettingsMain.ShopName, Resource.Admin_ExportFeed_Yandex_aspx)); if (!(CommonStatistic.IsRun)) { TrialService.TrackEvent(TrialEvents.ExportProductsToFeed, ""); CommonStatistic.Init(); } if (!CommonStatistic.IsRun && string.IsNullOrEmpty(ModuleName)) { Response.Redirect("ExportFeed.aspx?ModuleId=YandexMarket"); return; } PageSubheader.Visible = true; ModuleNameLiteral.Text = ModuleName; OutDiv.Visible = Start; PhysicalAppPath = Request.PhysicalApplicationPath; if ((SaasDataService.IsSaasEnabled) && (!SaasDataService.CurrentSaasData.HaveExportFeeds)) { mainDiv.Visible = false; notInTariff.Visible = true; } }
public void Process(bool inBackGround = true, ProductCsvFilterModel model = null) { if (model == null) { model = new ProductCsvFilterModel() { ModuleName = "CsvExport", ExportNoInCategory = _csvExportNoInCategory } } ; CommonStatistic.TotalRow = ProductService.GetCsvProdutsCount(model); CommonStatistic.StartNew(() => { try { SaveProductsToCsv(model); } catch (Exception ex) { Debug.LogError(ex); CommonStatistic.WriteLog(ex.Message); } CommonStatistic.IsRun = false; }, inBackGround); } }
public static void ExportSelection(string moduleName, string requestUrlPathAndQuery) { if (CommonStatistic.IsRun) { return; } CommonStatistic.Init(); CommonStatistic.CurrentProcess = requestUrlPathAndQuery; CommonStatistic.CurrentProcessName = Resource.Admin_ExportFeed_PageSubHeader + " " + moduleName; CommonStatistic.StartNew(() => MakeExportFile(new[] { moduleName, PhysicalAppPath })); }
protected void btnAction_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(lblError.Text)) { return; } if (!FileUpload.HasFile) { return; } FileUpload.SaveAs(_fullPath); if (!File.Exists(_fullPath)) { return; } if (CommonStatistic.IsRun) { return; } CommonStatistic.Init(); CommonStatistic.CurrentProcess = Request.Url.PathAndQuery; CommonStatistic.CurrentProcessName = Resource.Admin_ImportXLS_CatalogUpload; linkCancel.Visible = true; MsgErr(true); lblRes.Text = string.Empty; CommonStatistic.IsRun = true; CommonStatistic.TotalRow = GetRowCount(_fullPath); CommonStatistic.StartNew(() => { try { ImportSubscribers(_fullPath); } catch (Exception ex) { Debug.LogError(ex); CommonStatistic.WriteLog(ex.Message); } CommonStatistic.IsRun = false; }); //CsvImport.Factory(_fullPath, true).Process(); pUpload.Visible = false; OutDiv.Visible = true; }
protected void btnDownload_Click(object sender, EventArgs e) { if (lError.Visible) { return; } if (CommonStatistic.IsRun) { return; } //delete old foreach (var item in Directory.GetFiles(_strFilePath).Where(f => f.Contains(StrFileName))) { FileHelpers.DeleteFile(item); } divAction.Visible = false; divbtnAction.Visible = false; choseDiv.Visible = false; CsvSettings.CsvEnconing = ddlEncoding.SelectedValue; CsvSettings.CsvSeparator = ddlSeparetors.SelectedValue == SeparatorsEnum.Custom.StrName() ? txtCustomSeparator.Text : ddlSeparetors.SelectedValue; CsvSettings.CsvColumSeparator = txtColumSeparator.Text; CsvSettings.CsvPropertySeparator = txtPropertySeparator.Text; CsvSettings.CsvExportNoInCategory = chbCsvExportNoInCategory.Checked; CommonStatistic.Init(); CommonStatistic.CurrentProcess = Request.Url.PathAndQuery; CommonStatistic.CurrentProcessName = Resource.Admin_ExportExcel_CatalogDownload; linkCancel.Visible = true; OutDiv.Visible = true; btnDownload.Visible = false; // Directory foreach (var file in Directory.GetFiles(_strFilePath).Where(f => f.Contains(StrFileName)).ToList()) { FileHelpers.DeleteFile(file); } ExtStrFileName = (StrFileName + StrFileExt).FileNamePlusDate(); _strFullPath = _strFilePath + ExtStrFileName; FileHelpers.CreateDirectory(_strFilePath); CsvExport.Factory(_strFullPath, CsvSettings.CsvEnconing, CsvSettings.CsvSeparator, CsvSettings.CsvColumSeparator, CsvSettings.CsvPropertySeparator, FieldMapping, CsvSettings.CsvExportNoInCategory).Process(); TrialService.TrackEvent(TrialEvents.MakeCSVExport, ""); }
public void Process(bool inBackGround = true) { CommonStatistic.StartNew(() => { try { _process(); } catch (Exception ex) { Debug.LogError(ex); CommonStatistic.WriteLog(ex.Message); } CommonStatistic.IsRun = false; }, inBackGround); }
protected void btnAction_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(lblError.Text)) { return; } if (!_fieldMapping.ContainsKey(ProductFields.Sku.StrName()) && !_fieldMapping.ContainsKey(ProductFields.Name.StrName())) { MsgErr(Resource.Admin_ImportCsv_SelectNameOrSKU); return; } divAction.Visible = false; choseDiv.Visible = false; if (!File.Exists(_fullPath)) { return; } if (CommonStatistic.IsRun) { return; } _hasHeadrs = Request["hasheadrs"] == "true"; CommonStatistic.Init(); CommonStatistic.CurrentProcess = Request.Url.PathAndQuery; CommonStatistic.CurrentProcessName = Resource.Admin_ImportXLS_CatalogUpload; linkCancel.Visible = true; MsgErr(true); lblRes.Text = string.Empty; CsvImport.Factory(_fullPath, _hasHeadrs, chboxDisableProducts.Checked, CsvSettings.CsvSeparator, CsvSettings.CsvEnconing, _fieldMapping, CsvSettings.CsvColumSeparator, CsvSettings.CsvPropertySeparator).Process(); OutDiv.Visible = true; TrialService.TrackEvent(TrialEvents.MakeCSVImport, ""); }
public void SaveProductsToCsv(ProductCsvFilterModel filterModel) { using (var writer = InitWriter()) { WriteHeader(writer); var products = ProductService.GetCsvProducts(filterModel); if (products == null) { return; } foreach (var product in products) { if (!CommonStatistic.IsRun) { return; } if (_fieldMapping.Contains(ProductFields.Description) && product.Description.Length > MaxCellLength) { CommonStatistic.WriteLog(string.Format(Resource.Admin_ExportCsv_TooLargeDescription, product.Name, product.ArtNo)); CommonStatistic.TotalErrorRow++; continue; } if (_fieldMapping.Contains(ProductFields.BriefDescription) && product.BriefDescription.Length > MaxCellLength) { CommonStatistic.WriteLog(string.Format(Resource.Admin_ExportCsv_TooLargeBriefDescription, product.Name, product.ArtNo)); CommonStatistic.TotalErrorRow++; continue; } WriteItem(writer, product); CommonStatistic.RowPosition++; } } }
protected void Page_Load(object sender, EventArgs e) { SetMeta(string.Format("{0} - {1}", SettingsMain.ShopName, Resource.Admin_ExportFeed_Yandex_aspx)); if ((SaasDataService.IsSaasEnabled) && (!SaasDataService.CurrentSaasData.HaveExportFeeds)) { mainDiv.Visible = false; notInTariff.Visible = true; } if (!(CommonStatistic.IsRun)) { CommonStatistic.Init(); } if (string.IsNullOrEmpty(ModuleName)) { Response.Redirect("ExportFeedDet.aspx?ModuleId=YandexMarket"); return; } LoadSettings(); PhysicalAppPath = Request.PhysicalApplicationPath; }
protected void btnDownload_Click(object sender, EventArgs e) { if (CommonStatistic.IsRun) { lError.Visible = true; lError.Text = Resource.Admin_Restrict_Action_In_demo; return; } var paging = new SqlPaging { TableName = "[Order].[Order]" }; paging.AddField(new Field { Name = "*" }); if (chkStatus.Checked) { paging.AddField(new Field { Name = "OrderStatusID", NotInQuery = true, Filter = new EqualFieldFilter { ParamName = "@OrderStatusID", Value = ddlStatus.SelectedValue } }); } if (chkDate.Checked) { var filter = new DateTimeRangeFieldFilter { ParamName = "@RDate" }; var dateFrom = txtDateFrom.Text.TryParseDateTime(); filter.From = dateFrom != DateTime.MinValue ? dateFrom : new DateTime(2000, 1, 1); var dateTo = txtDateTo.Text.TryParseDateTime(); filter.To = dateTo != DateTime.MinValue ? dateTo.AddDays(1) : new DateTime(3000, 1, 1); paging.AddField(new Field { Name = "OrderDate", NotInQuery = true, Filter = filter }); } var ordersCount = paging.TotalRowsCount; if (ordersCount == 0) { return; } CommonStatistic.Init(); CommonStatistic.IsRun = true; CommonStatistic.CurrentProcess = Request.Url.PathAndQuery; CommonStatistic.CurrentProcessName = Resource.Admin_ExportOrdersExcel_DownloadOrders; CommonStatistic.TotalRow = ordersCount; linkCancel.Visible = true; OutDiv.Visible = true; btnDownload.Visible = false; pnSearch.Visible = false; try { // Directory if (!Directory.Exists(_strFilePath)) { Directory.CreateDirectory(_strFilePath); } CommonStatistic.StartNew(() => Save(paging)); } catch (Exception ex) { Debug.LogError(ex); lError.Text = ex.Message; lError.Visible = true; CommonStatistic.IsRun = false; } }
protected void linkCancel_Click(object sender, EventArgs e) { CommonStatistic.IsRun = false; CommonStatistic.Init(); }
private static void Log(string message) { CommonStatistic.WriteLog(message); }
private static void LogInvalidData(string message) { CommonStatistic.WriteLog(message); CommonStatistic.TotalErrorRow++; CommonStatistic.RowPosition++; }