/// <summary> /// selects user record for updation and show user form /// </summary> private void BindUpdateUserData() { DataGridViewRow selectedUser = GetSelectedUserData(); SapUserVo userUpdateVo = (SapUserVo)selectedUser.DataBoundItem; AddSapUserMasterForm newAddForm = new AddSapUserMasterForm(CommonConstants.MODE_UPDATE, userUpdateVo); newAddForm.ShowDialog(this); if (newAddForm.IntSuccess > 0) { messageData = new MessageData("mmci00002", Properties.Resources.mmci00002, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(FormConditionVo()); } else if (newAddForm.IntSuccess == 0) { messageData = new MessageData("mmci00007", Properties.Resources.mmci00007, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(FormConditionVo()); } }
/// <summary> /// create and get the RfcDestination /// </summary> /// <param name="userSessionId">userSessionId as string</param> /// <param name="sapUserVo">sapUserVo as SapUserVo</param> /// <returns>RfcDestination</returns> private RfcDestination CreateRfcDestination(string userSessionId, SapUserVo sapUserVo) { RfcDestination sapRfcDestination; //set rfcconfigparameters RfcConfigParameters configParameters = SetConnectionParameters(userSessionId, sapUserVo); try { sapRfcDestination = RfcDestinationManager.GetDestination(configParameters); MessageData messageData = new MessageData("scci00001", Properties.Resources.scci00001, sapRfcDestination.Name.ToString()); logger.Info(messageData); } catch (Exception ex) { //cannot serialize sap rfc exception hence passing exception name and message to the messagedata MessageData messageData = new MessageData("scce00008", Properties.Resources.scce00008, ex.GetType().Name.ToString(), ex.Message); logger.Error(messageData, ex); throw new Framework.SystemException(messageData); } if (sapRfcDestination == null) { MessageData messageData = new MessageData("scce00012", Properties.Resources.scce00012); Exception causeException = new NullReferenceException(); logger.Error(messageData, causeException); throw new Framework.SystemException(messageData, causeException); } return(sapRfcDestination); }
/// <summary> /// get the rfcdestination for rfcdestination isshutdown or not use , bind sapuser and rfcdestination in list of the cache /// </summary> /// <param name="sapSessionValue">sapuser and rfcdestination of the current usersession in cache memory</param> /// <returns>List<object> contains SapUserVo and RfcDestination</returns> private List <object> RefreshUserSapDestinationAsRequired(string userSessionId, List <object> sapSessionValue) { if (sapSessionValue == null) { MessageData messageData = new MessageData("scce00025", Properties.Resources.scce00025); Exception causeException = new NullReferenceException(); logger.Error(messageData, causeException); throw new Framework.SystemException(messageData, causeException); } RfcDestination sapRfcDestination = (RfcDestination)sapSessionValue[1]; // get RfcDestination from cache session in 1 //destination is obsolete if (sapRfcDestination.IsShutDown) { List <object> newSapSessionValue = new List <object>(); SapUserVo sapUserVo = (SapUserVo)sapSessionValue[0]; // get SapUserVo from cache session in 0 sapRfcDestination = CreateRfcDestination(userSessionId, sapUserVo); // Create Destination newSapSessionValue[0] = sapUserVo; //set SapUserVo to cache session in 0 newSapSessionValue[1] = sapRfcDestination; //set RfcDestination to cache session in 1 sapSessionValue = null; //explicitly give null to old sap session. return(newSapSessionValue); } else { return(sapSessionValue); } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { SapUserVo inVo = (SapUserVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Update m_sap_user"); sqlQuery.Append(" Set "); sqlQuery.Append(" mes_user_cd = :mesusercd, "); sqlQuery.Append(" sap_user = :sapuser, "); sqlQuery.Append(" sap_password = :sappassword "); sqlQuery.Append(" Where "); sqlQuery.Append(" sap_user_id = :sapuserid "); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterString("mesusercd", inVo.MesUserCode); sqlParameter.AddParameterString("sapuser", inVo.SapUser); sqlParameter.AddParameterString("sappassword ", inVo.SapPassWord); sqlParameter.AddParameterInteger("sapuserid ", inVo.SapUserId); SapUserVo outVo = new SapUserVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { SapUserVo inVo = (SapUserVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Select sapusr.sap_user_id,usr.user_cd,usr.user_name,sapusr.sap_user,sapusr.sap_password"); sqlQuery.Append(" from m_sap_user sapusr"); sqlQuery.Append(" right join m_mes_user usr on usr.user_cd = sapusr.mes_user_cd "); sqlQuery.Append(" where 1 = 1 "); if (inVo.MesUserCode != null) { sqlQuery.Append(" and usr.user_cd = :usercode "); } if (inVo.SapUser != null) { sqlQuery.Append(" and sapusr.sap_user = :sapuser "); } sqlQuery.Append(" order by sap_user_id "); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); if (inVo.MesUserCode != null) { sqlParameter.AddParameterString("usercode", inVo.MesUserCode); } if (inVo.SapUser != null) { sqlParameter.AddParameterString("sapuser", inVo.SapUser); } //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); SapUserVo outVo = new SapUserVo(); while (dataReader.Read()) { SapUserVo currVo = new SapUserVo(); currVo.SapUserId = ConvertDBNull <int>(dataReader, "sap_user_id"); currVo.MesUserCode = ConvertDBNull <string>(dataReader, "user_cd"); currVo.UserName = ConvertDBNull <string>(dataReader, "user_name"); currVo.SapUser = ConvertDBNull <string>(dataReader, "sap_user"); currVo.SapPassWord = ConvertDBNull <string>(dataReader, "sap_password"); outVo.SapUserListVo.Add(currVo); } dataReader.Close(); return(outVo); }
/// <summary> /// For setting selected user record into respective controls(textbox and combobox) for update operation /// passing selected user data as parameter /// </summary> /// <param name="userInVo"></param> private void LoadUserData(SapUserVo sapInVo) { if (sapInVo != null) { UserName_cmb.SelectedValue = sapInVo.MesUserCode; SapUserName_txt.Text = sapInVo.SapUser; UserPassword_txt.Text = sapInVo.SapPassWord; } }
/// <summary> /// Loads control lables from resource file /// For setting Insert/Update mode and binds user data while update /// </summary> /// <param name="pmode"></param> /// <param name="userVo"></param> public AddSapUserMasterForm(string pmode, SapUserVo userVo = null) { InitializeComponent(); mode = pmode; updateData = userVo; if (string.Equals(mode, CommonConstants.MODE_UPDATE)) { this.Text = UpdateText_lbl.Text; } }
/// <summary> /// get the rfcdestination , bind sapuser and rfcdestination in list of the cache /// </summary> /// <returns>List<object> contains SapUserVo and RfcDestination</returns> private List <object> GetUserSapDestination(string userSessionId) { SapUserVo sapUserVo = GetSapUser(); //Get SapUserVo RfcDestination sapRfcDestination = CreateRfcDestination(userSessionId, sapUserVo); // Create Destination List <object> destinationValue = new List <object>(); destinationValue.Add(sapUserVo); //set SapUserVo to cache session in 0 destinationValue.Add(sapRfcDestination); //set RfcDestination to cache session in 1 return(destinationValue); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { SapUserVo inVo = (SapUserVo)arg; StringBuilder sqlQuery = new StringBuilder(); //create SQL sqlQuery.Append(" select "); sqlQuery.Append(" mes_user_cd,"); sqlQuery.Append(" sap_user,"); sqlQuery.Append(" sap_password,"); sqlQuery.Append(" registration_user_cd,"); sqlQuery.Append(" registration_date_time,"); sqlQuery.Append(" factory_cd"); sqlQuery.Append(" from m_sap_user"); sqlQuery.Append(" where 1 = 1 "); if (inVo.SapUserId > 0) { sqlQuery.Append(" and sap_user_id = :sapuserid;"); } //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); if (inVo.SapUserId > 0) { sqlParameter.AddParameterInteger("sapuserid", inVo.SapUserId); } //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); SapUserVo outVo = new SapUserVo(); while (dataReader.Read()) { SapUserVo currVo = new SapUserVo(); currVo.SapUserId = ConvertDBNull <int>(dataReader, "sapuserid"); outVo.SapUserListVo.Add(currVo); } dataReader.Close(); return(outVo); }
/// <summary> /// event to delete the selected record /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Delete_btn_Click(object sender, EventArgs e) { int selectedrowindex = SapUserdetails_dgv.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = SapUserdetails_dgv.Rows[selectedrowindex]; messageData = new MessageData("mmcc00004", Properties.Resources.mmcc00004, selectedRow.Cells["colSapUserId"].Value.ToString()); DialogResult dialogResult = popUpMessage.ConfirmationOkCancel(messageData, Text); if (dialogResult == DialogResult.OK) { SapUserVo inVo = new SapUserVo { SapUserId = Convert.ToInt32(selectedRow.Cells["colSapUserId"].Value), }; try { SapUserVo outVo = (SapUserVo)InvokeCbm(new DeleteSapUserMasterMntCbm(), inVo, false); if (outVo.AffectedCount > 0) { messageData = new MessageData("mmci00003", Properties.Resources.mmci00003, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(FormConditionVo()); } else if (outVo.AffectedCount == 0) { messageData = new MessageData("mmci00007", Properties.Resources.mmci00007, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(FormConditionVo()); } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } } else if (dialogResult == DialogResult.Cancel) { //do something else } }
/// <summary> /// Creates seacrh condition as per user inputs /// </summary> /// <returns>search condition</returns> private SapUserVo FormConditionVo() { SapUserVo inVo = new SapUserVo(); if (SapUserName_txt.Text != string.Empty) { inVo.SapUser = SapUserName_txt.Text.Trim(); } if (UserName_cmb.SelectedIndex > -1) { inVo.MesUserCode = UserName_cmb.SelectedValue.ToString(); } return(inVo); }
private DataTable getMesUser() { SapUserVo conditionInVo = new SapUserVo(); DataTable sapUserdataTable = null; SapUserVo outVo = null; try { outVo = (SapUserVo)InvokeCbm(new GetLocalUsersMasterMntCbm(), conditionInVo, false); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } if (outVo != null && outVo.SapUserListVo.Count() > 0) { sapUserdataTable = new DataTable(); sapUserdataTable.Columns.Add("MesUserCode"); sapUserdataTable.Columns.Add("UserName"); sapUserdataTable.Columns.Add("SapUser"); foreach (SapUserVo vo in outVo.SapUserListVo) { DataRow dr = sapUserdataTable.NewRow(); dr["MesUserCode"] = vo.MesUserCode.ToString(); dr["UserName"] = vo.UserName.ToString(); if (!string.IsNullOrEmpty(vo.SapUser)) { dr["SapUser"] = vo.SapUser.ToString(); } sapUserdataTable.Rows.Add(dr); } } else { messageData = new MessageData("mmci00006", Properties.Resources.mmci00006, null); //Sap user logger.Info(messageData); popUpMessage.Information(messageData, Text); } return(sapUserdataTable); }
private static RfcConfigParameters SetConnectionParameters() { //RfcCustomDestination dest= getRfcdestination().CreateCustomDestination(); SapUserVo inVo = new SapUserVo(); GetSapUserMasterMntCbm sapUserCbm = new GetSapUserMasterMntCbm(); SapUserVo outVo = null; try { outVo = (SapUserVo)DefaultCbmInvoker.Invoke(sapUserCbm, inVo); } catch (Framework.ApplicationException ex) { MessageData messagedata = new MessageData("scce00002", Properties.Resources.scce00002); logger.Error(messagedata); throw new Framework.ApplicationException(messagedata, ex); } if (outVo == null) { MessageData messagedata = new MessageData("scce00001", Properties.Resources.scce00001, UserData.GetUserData().UserCode); logger.Error(messagedata); throw new Framework.ApplicationException(messagedata); } RfcConfigParameters rfcParams = new RfcConfigParameters(); rfcParams.Add(RfcConfigParameters.Name, ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_NAME.GetValue()); rfcParams.Add(RfcConfigParameters.LogonGroup, ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_LOGON_GROUP.GetValue()); rfcParams.Add(RfcConfigParameters.MessageServerHost, ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_MESSAGE_SERVER_HOST.GetValue()); rfcParams.Add(RfcConfigParameters.SystemID, ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_SYSTEM_ID.GetValue()); rfcParams.Add(RfcConfigParameters.SystemNumber, ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_SYSTEM_NUMBER.GetValue()); rfcParams.Add(RfcConfigParameters.User, outVo.SapUser); rfcParams.Add(RfcConfigParameters.Password, outVo.SapPassWord); rfcParams.Add(RfcConfigParameters.Client, ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_CLIENT.GetValue()); rfcParams.Add(RfcConfigParameters.Language, ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_LANGUAGE.GetValue()); rfcParams.Add(RfcConfigParameters.PoolSize, ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_POOL_SIZE.GetValue()); rfcParams.Add(RfcConfigParameters.PeakConnectionsLimit, ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_PEAK_CONNECTIONS_LIMIT.GetValue()); rfcParams.Add(RfcConfigParameters.IdleTimeout, ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_IDLE_TIMEOUT.GetValue()); rfcParams.Add(RfcConfigParameters.IdleCheckTime, ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_IDLE_CHECKTIME.GetValue()); return(rfcParams); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { SapUserVo inVo = (SapUserVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Insert into m_sap_user"); sqlQuery.Append(" ( "); sqlQuery.Append(" mes_user_cd, "); sqlQuery.Append(" sap_user, "); sqlQuery.Append(" sap_password, "); sqlQuery.Append(" registration_user_cd, "); sqlQuery.Append(" registration_date_time, "); sqlQuery.Append(" factory_cd"); sqlQuery.Append(" ) "); sqlQuery.Append("VALUES "); sqlQuery.Append(" ( "); sqlQuery.Append(" :mesusercd ,"); sqlQuery.Append(" :sapuser ,"); sqlQuery.Append(" :sappassword ,"); sqlQuery.Append(" :registrationusercode ,"); sqlQuery.Append(" now() ,"); sqlQuery.Append(" :registrationfactorycode "); sqlQuery.Append(" ); "); DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterString("mesusercd", inVo.MesUserCode); sqlParameter.AddParameterString("sapuser ", inVo.SapUser); sqlParameter.AddParameterString("sappassword ", inVo.SapPassWord); sqlParameter.AddParameterString("registrationusercode ", UserData.GetUserData().UserCode); sqlParameter.AddParameterString("registrationfactorycode ", UserData.GetUserData().FactoryCode); SapUserVo outVo = new SapUserVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
/// <summary> /// get the sapuservo from cache for the logged in user session /// </summary> /// <param name="trxContext"></param> /// <returns>SapUserVo</returns> public SapUserVo GetSapUser(TransactionContext trxContext) { //Check parameter if (trxContext == null) { //logg MessageData messageData = new MessageData("scce00033", Properties.Resources.scce00033); Exception causeException = new NullReferenceException(); logger.Error(messageData, causeException); throw new Framework.SystemException(messageData, causeException); } else if (trxContext.UserData == null) { //logg MessageData messageData = new MessageData("scce00034", Properties.Resources.scce00034); Exception causeException = new NullReferenceException(); logger.Error(messageData, causeException); throw new Framework.SystemException(messageData, causeException); } else if (String.IsNullOrEmpty(trxContext.UserData.SessionId)) { //logg MessageData messageData = new MessageData("scce00030", Properties.Resources.scce00030); Exception causeException = new NullReferenceException(); logger.Error(messageData, causeException); throw new Framework.SystemException(messageData, causeException); } SapUserVo sapUser = rfcDestinationContainer.GetSapUser(trxContext.UserData.SessionId); if (sapUser == null) { //logg MessageData messageData = new MessageData("scce00035", Properties.Resources.scce00035); Exception causeException = new NullReferenceException(); logger.Error(messageData, causeException); throw new Framework.SystemException(messageData, causeException); } return(sapUser); }
/// <summary> /// get the sap user login detail /// </summary> /// <returns>sap user vo</returns> private SapUserVo GetSapUser() { SapUserVo outVo = null; try { outVo = (SapUserVo)DefaultCbmInvoker.Invoke(sapUserCbm, null); } catch (Framework.ApplicationException ex) { MessageData messagedata = new MessageData("scce00002", Properties.Resources.scce00002); logger.Error(messagedata, ex); throw new Framework.ApplicationException(messagedata, ex); } catch (Framework.SystemException ex) { MessageData messagedata = new MessageData("scce00010", Properties.Resources.scce00010); logger.Error(messagedata, ex); throw new Framework.SystemException(messagedata, ex); } catch (Exception ex) { MessageData messagedata = new MessageData("scce00011", Properties.Resources.scce00011); logger.Error(messagedata, ex); throw new Framework.SystemException(messagedata, ex); } if (outVo == null) { MessageData messagedata = new MessageData("scce00001", Properties.Resources.scce00001, UserData.GetUserData().UserCode); Exception causeException = new NullReferenceException(); logger.Error(messagedata, causeException); throw new Framework.SystemException(messagedata, causeException); } return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Select sapusr.mes_user_cd,sapusr.sap_user,sapusr.sap_password"); sqlQuery.Append(" from m_sap_user sapusr"); sqlQuery.Append(" inner join m_mes_user usr on usr.user_cd = sapusr.mes_user_cd"); sqlQuery.Append(" inner join m_user_factory uf on usr.user_cd = uf.user_cd"); sqlQuery.Append(" where usr.user_cd = :usercode "); sqlQuery.Append(" and uf.factory_cd = :factorycode "); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterString("usercode", trxContext.UserData.UserCode); sqlParameter.AddParameterString("factorycode", trxContext.UserData.FactoryCode); //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); SapUserVo outVo = null; while (dataReader.Read()) { outVo = new SapUserVo(); outVo.MesUserCode = DBDataCheckHelper.ConvertDBNullToStringNull(dataReader["mes_user_cd"]); outVo.SapUser = DBDataCheckHelper.ConvertDBNullToStringNull(dataReader["sap_user"]); outVo.SapPassWord = DBDataCheckHelper.ConvertDBNullToStringNull(dataReader["sap_password"]); } dataReader.Close(); return(outVo); }
/// <summary> /// Set the connection parameter for the rfcconfigparameters /// </summary> /// <param name="userSessionId">usersessionid</param> /// <param name="userVo">SapUserVo</param> /// <returns>RfcConfigParameters</returns> private RfcConfigParameters SetConnectionParameters(string userSessionId, SapUserVo userVo) { string destName = ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_NAME.GetValue() + userSessionId; RfcConfigParameters rfcParams = new RfcConfigParameters(); rfcParams.Add(RfcConfigParameters.Name, destName); rfcParams.Add(RfcConfigParameters.LogonGroup, ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_LOGON_GROUP.GetValue()); //rfcParams.Add(RfcConfigParameters.AppServerHost, ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_MESSAGE_SERVER_HOST.GetValue()); rfcParams.Add(RfcConfigParameters.MessageServerHost, ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_MESSAGE_SERVER_HOST.GetValue()); rfcParams.Add(RfcConfigParameters.SystemID, ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_SYSTEM_ID.GetValue()); rfcParams.Add(RfcConfigParameters.SystemNumber, ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_SYSTEM_NUMBER.GetValue()); rfcParams.Add(RfcConfigParameters.User, userVo.SapUser); rfcParams.Add(RfcConfigParameters.Password, userVo.SapPassWord); rfcParams.Add(RfcConfigParameters.Client, ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_CLIENT.GetValue()); rfcParams.Add(RfcConfigParameters.Language, ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_LANGUAGE.GetValue()); rfcParams.Add(RfcConfigParameters.PoolSize, ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_POOL_SIZE.GetValue()); rfcParams.Add(RfcConfigParameters.PeakConnectionsLimit, ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_PEAK_CONNECTIONS_LIMIT.GetValue()); rfcParams.Add(RfcConfigParameters.IdleTimeout, ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_IDLE_TIMEOUT.GetValue()); rfcParams.Add(RfcConfigParameters.IdleCheckTime, ServerConfigurationDataTypeEnum.DEFAULT_SAP_CONFIG_IDLE_CHECKTIME.GetValue()); return(rfcParams); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { SapUserVo inVo = (SapUserVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Delete from m_sap_user"); sqlQuery.Append(" Where "); sqlQuery.Append(" sap_user_id = :sapuserid ;"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterInteger("sapuserid", inVo.SapUserId); SapUserVo outVo = new SapUserVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
/// <summary> /// Fills all user records to gridview control /// </summary> private void GridBind(SapUserVo conditionInVo) { SapUserdetails_dgv.DataSource = null; try { SapUserVo outVo = (SapUserVo)InvokeCbm(new GetSapUsersMasterMntCbm(), conditionInVo, false); SapUserdetails_dgv.AutoGenerateColumns = false; BindingSource bindingSource1 = new BindingSource(outVo.SapUserListVo, null); if (bindingSource1.Count > 0) { SapUserdetails_dgv.DataSource = bindingSource1; colSapUserId.SortMode = DataGridViewColumnSortMode.Automatic; } else { messageData = new MessageData("mmci00006", Properties.Resources.mmci00006, null); //Sap user logger.Info(messageData); popUpMessage.Information(messageData, Text); } SapUserdetails_dgv.ClearSelection(); Update_btn.Enabled = false; Delete_btn.Enabled = false; } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { Decimal AllowableToError = 0.5M; MoConfirmationMaterialVo inVo = (MoConfirmationMaterialVo)vo; MoConfirmationHeaderVo header = (MoConfirmationHeaderVo)inVo.MoConfirmationHeaderVo; //MoConfirmationMaterialVo materialsVo = (MoConfirmationMaterialVo)inVo.MoConfirmationMaterialListVo.FirstOrDefault(); List <MoConfirmationMaterialVo> materials = inVo.MoConfirmationMaterialListVo; if (header.CancellationFlag != "CAL") { MoConfirmationResultVo FrontResultVo = new MoConfirmationResultVo(); List <SapMessageVo> FrontMessageList = new List <SapMessageVo>(); bool DataIsOk = true; MoConfirmationMaterialVo materialProduct = materials.Find(s => s.MovementType == Properties.Resources.MOVEMENT_TYPE); if (materialProduct == null) { DataIsOk = false; SapMessageVo NullMessage = new SapMessageVo { OrderNumber = header.OrderNumber, MessageType = Properties.Resources.ErrorMessageCategory, MessageClassId = "000", MessageNumber = "000", LogNumber = Properties.Resources.scce00036, LogMessageNumber = "000", MessageVariable1 = "", MessageVariable2 = "", MessageVariable3 = "", MessageVariable4 = "" }; FrontResultVo.MessageList.Add(NullMessage); } else { if (materialProduct.SapBatchNumber != header.LotNoOfUsers) { DataIsOk = false; SapMessageVo BatchDifferentMessage = new SapMessageVo { OrderNumber = header.OrderNumber, MessageType = Properties.Resources.ErrorMessageCategory, MessageClassId = "000", MessageNumber = "000", LogNumber = Properties.Resources.scce00037, LogMessageNumber = "001", MessageVariable1 = "", MessageVariable2 = "", MessageVariable3 = "", MessageVariable4 = "" }; FrontResultVo.MessageList.Add(BatchDifferentMessage); } if (materialProduct.Quantity != header.ProductionOfUsers) { DataIsOk = false; SapMessageVo BatchDifferentMessage = new SapMessageVo { OrderNumber = header.OrderNumber, MessageType = Properties.Resources.ErrorMessageCategory, MessageClassId = "000", MessageNumber = "000", LogNumber = Properties.Resources.scce00038, LogMessageNumber = "002", MessageVariable1 = "", MessageVariable2 = "", MessageVariable3 = "", MessageVariable4 = "" }; FrontResultVo.MessageList.Add(BatchDifferentMessage); } } Decimal MaterQtyAll = materials.Where(r => r.MovementType != Properties.Resources.MOVEMENT_TYPE).Sum(t => t.Quantity); if (header.TotalOfUsers >= MaterQtyAll - AllowableToError && header.TotalOfUsers <= MaterQtyAll + AllowableToError) { } else { DataIsOk = false; SapMessageVo BatchDifferentMessage = new SapMessageVo { OrderNumber = header.OrderNumber, MessageType = Properties.Resources.ErrorMessageCategory, MessageClassId = "000", MessageNumber = "000", LogNumber = Properties.Resources.scce00039, LogMessageNumber = "003", MessageVariable1 = "", MessageVariable2 = "", MessageVariable3 = "", MessageVariable4 = "" }; FrontResultVo.MessageList.Add(BatchDifferentMessage); } if (!DataIsOk) { FrontResultVo.OutSapFlag = Properties.Resources.ErrorMessageCategory; return(FrontResultVo); } } SAPCommandAdapter sapCommandAdapter = base.GetSAPCommandAdaptor(trxContext, SAPRFCNameEnum.RFC_MANUFACTURING_ORDER_CONFIRMATION.GetValue()); //get the sapuser from cache memory SapUserVo sapUserVo = sapCommandAdapter.GetSapUser(trxContext); DateTime dbTime = trxContext.ProcessingDBDateTime; SAPParameterList sapParameter = sapCommandAdapter.CreateParameterList(); sapParameter.AddParameter("PLANT", ServerConfigurationDataTypeEnum.DEFAULT_SAP_PLANT_CODE.GetValue()); // ); sapParameter.AddParameter("ORDER_NUMBER", header.OrderNumber); sapParameter.AddParameter("IMUSER", sapUserVo.SapUser); //set sapuser using using sessionid sapParameter.AddParameter("IMDATE", dbTime.ToString("yyyyMMdd")); //submitting datetime "yyyyMMdd" sapParameter.AddParameter("IMTIME", dbTime.ToString("HHmmss")); //submitting datetime "HHmmss" if (string.IsNullOrEmpty(header.Supervisor)) { sapParameter.AddParameter("SUPERVISOR", trxContext.UserData.UserCode); //nidecmes login user } else { sapParameter.AddParameter("SUPERVISOR", header.Supervisor); // trxContext.UserData.UserCode); //nidecmes login user } sapParameter.AddParameter("ACT_STARTDATE", header.StartDateTime.ToString("yyyyMMdd")); sapParameter.AddParameter("ACT_STARTTIME", header.StartDateTime.ToString("HHmmss")); sapParameter.AddParameter("ACT_ENDDATE", header.EndDateTime.ToString("yyyyMMdd")); sapParameter.AddParameter("ACT_ENDTIME", header.EndDateTime.ToString("HHmmss")); sapParameter.AddParameter("MAN_HOUR", header.ManHour.ToString("0.000")); sapParameter.AddParameter("MACHINE_HOUR", header.MachineHour.ToString("0.000")); sapParameter.AddParameter("WORKUNIT", header.WorkTimeUnit); sapParameter.AddParameter("POSTDATE", header.PostingDate.ToString("yyyyMMdd")); sapParameter.AddParameter("CAL_FLAG", header.CancellationFlag); sapParameter.AddParameter("END_FLAG", header.EndFlag); sapParameter.AddParameter("CONF_NO", header.ConfirmationNumber.ToString()); sapParameter.AddParameter("CONF_CNT", header.ConfirmationCounter.ToString()); sapParameter.AddParameter("MULTI_FLAG", header.MultiFlag); sapParameter.AddParameter("IM_COUNT", header.MaterialCount); sapParameter.AddParameter("IM_TOTAL", header.MaterialQuantityTotal.ToString("0.000")); SAPParameterList sapParameterTable; SAPParameterList sapParameterTableLists = sapCommandAdapter.CreateParameterList(); foreach (MoConfirmationMaterialVo m in materials) { //rfcTable.Insert(); sapParameterTable = sapCommandAdapter.CreateParameterList(); sapParameterTable.AddParameter("ORDER_NUMBER", m.OrderNumber); sapParameterTable.AddParameter("IMDATE", dbTime.ToString("yyyyMMdd")); sapParameterTable.AddParameter("IMTIME", dbTime.ToString("HHmmss")); sapParameterTable.AddParameter("MATERIAL", m.MaterialNumber); sapParameterTable.AddParameter("BATCH", m.SapBatchNumber); sapParameterTable.AddParameter("V_BATCH", m.VendorBatchNumber); sapParameterTable.AddParameter("MOVETYPE", m.MovementType); sapParameterTable.AddParameter("ACT_QUANTITY", m.Quantity.ToString()); sapParameterTable.AddParameter("LGORT", m.StorageLocation); sapParameterTable.AddParameter("UNIT", m.Unit); sapParameterTableLists.AddParameterList(sapParameterTable); } sapParameter.AddParameter("TB_ORDER_MOVEMENT", sapParameterTableLists); SAPFunction sapFuntion = sapCommandAdapter.Execute(trxContext, sapParameter); MoConfirmationResultVo resultVo = new MoConfirmationResultVo { OutSapFlag = sapFuntion.GetSAPValue("OUT_SAPFLAG") }; List <SapMessageVo> messageList = new List <SapMessageVo>(); DataTable sapTable = sapFuntion.GetSAPTable("TB_RETURN"); foreach (DataRow dr in sapTable.Rows) { SapMessageVo message = new SapMessageVo { OrderNumber = ConvertNull <string>(dr, "AUFNR"), MessageType = ConvertNull <string>(dr, "TYPE"), MessageClassId = ConvertNull <string>(dr, "ID"), MessageNumber = ConvertNull <string>(dr, "NUMBER"), LogNumber = ConvertNull <string>(dr, "MESSAGE"), LogMessageNumber = ConvertNull <string>(dr, "LOG_NO"), MessageVariable1 = ConvertNull <string>(dr, "MESSAGE_V1"), MessageVariable2 = ConvertNull <string>(dr, "MESSAGE_V2"), MessageVariable3 = ConvertNull <string>(dr, "MESSAGE_V3"), MessageVariable4 = ConvertNull <string>(dr, "MESSAGE_V4") }; resultVo.MessageList.Add(message); } return(resultVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { MoConfirmationMaterialVo inVo = (MoConfirmationMaterialVo)vo; MoConfirmationHeaderVo header = (MoConfirmationHeaderVo)inVo.MoConfirmationHeaderVo; //MoConfirmationMaterialVo materialsVo = (MoConfirmationMaterialVo)inVo.MoConfirmationMaterialListVo.FirstOrDefault(); List <MoConfirmationMaterialVo> materials = inVo.MoConfirmationMaterialListVo; SAPCommandAdapter sapCommandAdapter = base.GetSAPCommandAdaptor(trxContext, SAPRFCNameEnum.RFC_MANUFACTURING_ORDER_CONFIRMATION.GetValue()); //get the sapuser from cache memory SapUserVo sapUserVo = sapCommandAdapter.GetSapUser(trxContext); DateTime dbTime = trxContext.ProcessingDBDateTime; SAPParameterList sapParameter = sapCommandAdapter.CreateParameterList(); sapParameter.AddParameter("PLANT", ServerConfigurationDataTypeEnum.DEFAULT_SAP_PLANT_CODE.GetValue()); // ); sapParameter.AddParameter("ORDER_NUMBER", header.OrderNumber); sapParameter.AddParameter("IMUSER", sapUserVo.SapUser); //set sapuser using using sessionid sapParameter.AddParameter("IMDATE", dbTime.ToString("yyyyMMdd")); //submitting datetime "yyyyMMdd" sapParameter.AddParameter("IMTIME", dbTime.ToString("HHmmss")); //submitting datetime "HHmmss" sapParameter.AddParameter("SUPERVISOR", trxContext.UserData.UserCode); //nidecmes login user sapParameter.AddParameter("ACT_STARTDATE", header.StartDateTime.ToString("yyyyMMdd")); sapParameter.AddParameter("ACT_STARTTIME", header.StartDateTime.ToString("HHmmss")); sapParameter.AddParameter("ACT_ENDDATE", header.EndDateTime.ToString("yyyyMMdd")); sapParameter.AddParameter("ACT_ENDTIME", header.EndDateTime.ToString("HHmmss")); sapParameter.AddParameter("MAN_HOUR", header.ManHour.ToString("0.000")); sapParameter.AddParameter("MACHINE_HOUR", header.MachineHour.ToString("0.000")); sapParameter.AddParameter("WORKUNIT", header.WorkTimeUnit); sapParameter.AddParameter("POSTDATE", header.PostingDate.ToString("yyyyMMdd")); sapParameter.AddParameter("CAL_FLAG", header.CancellationFlag); sapParameter.AddParameter("END_FLAG", header.EndFlag); sapParameter.AddParameter("CONF_NO", header.ConfirmationNumber.ToString()); sapParameter.AddParameter("CONF_CNT", header.ConfirmationCounter.ToString()); sapParameter.AddParameter("MULTI_FLAG", header.MultiFlag); sapParameter.AddParameter("IM_COUNT", header.MaterialCount); sapParameter.AddParameter("IM_TOTAL", header.MaterialQuantityTotal.ToString("0.000")); SAPParameterList sapParameterTable; SAPParameterList sapParameterTableLists = sapCommandAdapter.CreateParameterList(); foreach (MoConfirmationMaterialVo m in materials) { //rfcTable.Insert(); sapParameterTable = sapCommandAdapter.CreateParameterList(); sapParameterTable.AddParameter("ORDER_NUMBER", m.OrderNumber); sapParameterTable.AddParameter("IMDATE", dbTime.ToString("yyyyMMdd")); sapParameterTable.AddParameter("IMTIME", dbTime.ToString("HHmmss")); sapParameterTable.AddParameter("MATERIAL", m.MaterialNumber); sapParameterTable.AddParameter("BATCH", m.SapBatchNumber); sapParameterTable.AddParameter("V_BATCH", m.VendorBatchNumber); sapParameterTable.AddParameter("MOVETYPE", m.MovementType); sapParameterTable.AddParameter("ACT_QUANTITY", m.Quantity.ToString()); sapParameterTable.AddParameter("LGORT", m.StorageLocation); sapParameterTable.AddParameter("UNIT", m.Unit); sapParameterTableLists.AddParameterList(sapParameterTable); } sapParameter.AddParameter("TB_ORDER_MOVEMENT", sapParameterTableLists); SAPFunction sapFuntion = sapCommandAdapter.Execute(trxContext, sapParameter); MoConfirmationResultVo resultVo = new MoConfirmationResultVo { OutSapFlag = sapFuntion.GetSAPValue("OUT_SAPFLAG") }; List <SapMessageVo> messageList = new List <SapMessageVo>(); DataTable sapTable = sapFuntion.GetSAPTable("TB_RETURN"); foreach (DataRow dr in sapTable.Rows) { SapMessageVo message = new SapMessageVo { OrderNumber = ConvertNull <string>(dr, "AUFNR"), MessageType = ConvertNull <string>(dr, "TYPE"), MessageClassId = ConvertNull <string>(dr, "ID"), MessageNumber = ConvertNull <string>(dr, "NUMBER"), LogNumber = ConvertNull <string>(dr, "MESSAGE"), LogMessageNumber = ConvertNull <string>(dr, "LOG_NO"), MessageVariable1 = ConvertNull <string>(dr, "MESSAGE_V1"), MessageVariable2 = ConvertNull <string>(dr, "MESSAGE_V2"), MessageVariable3 = ConvertNull <string>(dr, "MESSAGE_V3"), MessageVariable4 = ConvertNull <string>(dr, "MESSAGE_V4") }; resultVo.MessageList.Add(message); } return(resultVo); }
/// <summary> /// update data to db /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Ok_btn_Click(object sender, EventArgs e) { SapUserVo inVo = new SapUserVo(); var sch = StringCheckHelper.GetInstance(); if (CheckMandatory()) { if (!sch.IsASCII(SapUserName_txt.Text)) { messageData = new MessageData("mmce00003", Properties.Resources.mmce00003); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); SapUserName_txt.Focus(); return; } else if (!sch.IsASCII(UserPassword_txt.Text)) { messageData = new MessageData("mmce00003", Properties.Resources.mmce00003); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); UserPassword_txt.Focus(); return; } if (UserName_cmb.SelectedIndex > -1) { inVo.MesUserCode = UserName_cmb.SelectedValue.ToString(); } inVo.SapPassWord = UserPassword_txt.Text.Trim(); inVo.SapUser = SapUserName_txt.Text.Trim(); try { if (string.Equals(mode, CommonConstants.MODE_ADD)) { SapUserVo outVo = (SapUserVo)base.InvokeCbm(new AddSapUserMasterMntCbm(), inVo, false); IntSuccess = outVo.AffectedCount; } else if (string.Equals(mode, CommonConstants.MODE_UPDATE)) { inVo.SapUserId = updateData.SapUserId; SapUserVo outVo = (SapUserVo)base.InvokeCbm(new UpdateSapUserMasterMntCbm(), inVo, false); IntSuccess = outVo.AffectedCount; } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } if ((IntSuccess > 0) || (IntSuccess == 0)) { this.Close(); } } }