public Dictionary <string, object> CreateAdvice(Dictionary <string, object> parameters) { try { SOFTTEK.SAP.Integration.SAPConnection sapConnector = new SAP.Integration.SAPConnection(); var sapDestination = sapConnector.LoadDestination(); Dictionary <string, object> rfcInputParameters = new Dictionary <string, object>(); rfcInputParameters["IM_NOTIFHEADER"] = SAPData.CreateRFCStructure( parameters, sapDestination, "ZPMS_AVISOS_MANTENIMIENTO" ); rfcInputParameters["IM_NOTIF_TYPE"] = "M1"; Dictionary <string, object> rfcParameters = RetrieveResponseData <object>(kRFCNameCreateAdvice, rfcInputParameters); // Validate RFC's response if (rfcParameters[kRFCResponseIndicatorFieldName] != null && !kDefaultResponseIndicator.Equals(((dynamic)rfcParameters[kRFCResponseIndicatorFieldName]).Value)) { throw new InvalidOperationException( string.Format("The SAP RFC {0} has completed the request with code {1}. {2}", kRFCNameMeasurementDocument, ((dynamic)rfcParameters[kRFCResponseIndicatorFieldName]).Value, ((dynamic)rfcParameters[kRFCResponseDetailFieldName]).Value) ); } Logger.Log(new Foundation.Entity.LogEntry { Type = LOG_TYPE.LOG_TYPE_MESSAGE, Description = string.Format("The SAP RFC {0} has completed the request with code {1}. {2}", kRFCNameMasterData, ((dynamic)rfcParameters[kRFCResponseIndicatorFieldName]).Value, ((dynamic)rfcParameters[kRFCResponseDetailFieldName]).Value), App = Context.SecurityContext.AppID, Device = Context.SecurityContext.DeviceID, Module = "SAPDataProvider.CreateAdvice", User = Context.SecurityContext.ClientID }); return(rfcParameters); } catch (Exception ex) { Logger.Log(new Foundation.Entity.LogEntry { Type = LOG_TYPE.LOG_TYPE_ERROR, Description = ex.Message, App = Context.SecurityContext.AppID, Device = Context.SecurityContext.DeviceID, Module = "SAPDataProvider.CreateAdvice", User = Context.SecurityContext.ClientID }); throw ex; } }
public override void UserControlLoad() { SetEmptyValues(); base.ClearResultContext(this.lbResultContext); if (this.ownerPage == null) { throw new UMSException("Current Page is null or is not inheritor of BasicPage."); } if (!string.IsNullOrEmpty(this.hdnRowMasterKey.Value) && this.hdnRowMasterKey.Value != Constants.INVALID_ID_ZERO_STRING) { this.CurrentEntityMasterID = this.hdnRowMasterKey.Value; } InitLoadControls(); this.currentEntity = this.ownerPage.CostCalculationRef.GetSAPDataById(this.CurrentEntityMasterID); if (this.currentEntity != null) { this.SetHdnField(this.currentEntity.idSAPData.ToString()); this.tbxDateFrom.SetTxbDateTimeValue(this.currentEntity.DateFrom); this.tbxDateTo.SetTxbDateTimeValue(this.currentEntity.DateTo); this.btnImport.Enabled = true; if ((this.currentEntity.SAPDataExpenses != null && this.currentEntity.SAPDataExpenses.Count > 0) || (this.currentEntity.SAPDataQuantities != null && this.currentEntity.SAPDataQuantities.Count > 0)) { this.tbxDateFrom.ReadOnly = true; this.btnImport.Enabled = false; } if (this.currentEntity.SAPDataExpenses != null && this.currentEntity.SAPDataExpenses.Count > 0) { LoadSAPDataExpensesAndQuantities(); this.divSAPDataExpensesAndQuantities.Visible = true; } else { this.divSAPDataExpensesAndQuantities.Visible = false; } base.ClearResultContext(this.lbResultContext); } else { SetEmptyValues(); } this.pnlFormData.Visible = true; this.pnlFormData.Focus(); }
protected void btnImport_Click(object sender, EventArgs e) { if (!this.ownerPage.CheckUserActionPermission(ETEMEnums.SecuritySettings.SAPDataImport, false)) { return; } base.RunJavaScriptModalWindow(); if (this.fuImport.HasFile) { string selectedFileMimeType = this.fuImport.PostedFile.ContentType; string excelMimeType = BaseHelper.GetMimeType(Constants.FILE_XLSX_EXTENSION); if (!string.Equals(selectedFileMimeType, excelMimeType, StringComparison.InvariantCultureIgnoreCase)) { this.ownerPage.ShowMSG("Selected file is in incorrect format, it must be Excel-2007 or newer version!", false); return; } string fileFullName = string.Empty; string folderPath = string.Empty; folderPath = GeneralPage.GetSettingByCode(ETEMModel.Helpers.ETEMEnums.AppSettings.ResourcesFolderName).SettingValue; folderPath += "\\CostCalculation\\SAPData\\Import\\" + DateTime.Today.Year + "\\"; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } fileFullName = folderPath + "\\Import_SAP_ExpensesAndQuantities_" + DateTime.Now.ToString(Constants.DATE_PATTERN_FOR_FILE_SUFFIX) + Constants.FILE_XLSX_EXTENSION; this.fuImport.PostedFile.SaveAs(fileFullName); this.ownerPage.CallContext = this.ownerPage.CostCalculationRef.ImportSAPDataExpensesAndQuantities(fileFullName, this.hdnRowMasterKey.Value, this.ownerPage.CallContext); if (this.ownerPage.CallContext.ResultCode == ETEMEnums.ResultEnum.Success) { base.AddMessage(this.lbResultContext, this.ownerPage.CallContext.Message); this.CostCalculationRef.CalculateCostCentersTotal(this.hdnRowMasterKey.Value, this.ownerPage.CallContext); this.currentEntity = this.ownerPage.CostCalculationRef.GetSAPDataById(this.hdnRowMasterKey.Value); if (this.currentEntity.SAPDataExpenses != null && this.currentEntity.SAPDataExpenses.Count > 0) { LoadSAPDataExpensesAndQuantities(); this.divSAPDataExpensesAndQuantities.Visible = true; } else { this.divSAPDataExpensesAndQuantities.Visible = false; } } else { if (!ShowErrors(new List <CallContext>() { this.ownerPage.CallContext })) { return; } } } else { this.ownerPage.ShowMSG("Please select file to import!", false); } }
protected void btnSave_Click(object sender, EventArgs e) { if (!this.ownerPage.CheckUserActionPermission(ETEMEnums.SecuritySettings.SAPDataSave, false)) { return; } if (string.IsNullOrEmpty(this.hdnRowMasterKey.Value) || this.hdnRowMasterKey.Value == Constants.INVALID_ID_STRING) { this.currentEntity = new SAPData(); } else { this.currentEntity = this.ownerPage.CostCalculationRef.GetSAPDataById(this.hdnRowMasterKey.Value); if (this.currentEntity == null) { this.ownerPage.CallContext.ResultCode = ETEMEnums.ResultEnum.Error; base.AddMessage(this.lbResultContext, string.Format("Entity `SAPData` not found by ID ({0})!", this.hdnRowMasterKey.Value)); return; } } this.currentEntity.DateFrom = this.tbxDateFrom.TextAsDateParseExactOrMinValue; this.currentEntity.DateTo = this.tbxDateTo.TextAsDateParseExact; this.ownerPage.CallContext = this.ownerPage.CostCalculationRef.SAPDataSave(new List <SAPData>() { this.currentEntity }, this.ownerPage.CallContext); if (this.ownerPage.CallContext.ResultCode == ETEMEnums.ResultEnum.Success) { this.hdnRowMasterKey.Value = this.ownerPage.CallContext.EntityID; base.AddMessage(this.lbResultContext, this.ownerPage.CallContext.Message); this.btnImport.Enabled = true; this.currentEntity = this.ownerPage.CostCalculationRef.GetSAPDataById(this.hdnRowMasterKey.Value); if (this.currentEntity != null && this.currentEntity.SAPDataExpenses != null && this.currentEntity.SAPDataExpenses.Count > 0) { LoadSAPDataExpensesAndQuantities(); this.divSAPDataExpensesAndQuantities.Visible = true; } else { this.divSAPDataExpensesAndQuantities.Visible = false; } } else { if (!ShowErrors(new List <CallContext>() { this.ownerPage.CallContext })) { return; } } if (this.ownerPage is SAPDataList) { ((SAPDataList)this.ownerPage).LoadFilteredList(); } }