Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="serverVM"></param>
        /// <param name="CommandType"></param>
        /// <returns></returns>
        public static ErrorMessage ManageMachine(int MachineId, MachinesViewModel machineVM, CommandTypeEnum CommandType)
        {
            ErrorMessage errmsg = new ErrorMessage();

            try
            {
                using (MySqlConnection con = new MySqlConnection(connectionString))
                {
                    con.Open();
                    MySqlCommand cmd = new MySqlCommand("spManageMachine", con);
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;

                    MySqlParameter pId = new MySqlParameter();
                    pId.ParameterName = "in_Id";
                    pId.Value         = MachineId;
                    cmd.Parameters.Add(pId);

                    MySqlParameter pMachineName = new MySqlParameter();
                    pMachineName.ParameterName = "in_MachineName";
                    pMachineName.Value         = machineVM.MachineName;
                    cmd.Parameters.Add(pMachineName);

                    MySqlParameter pMachineLocation = new MySqlParameter();
                    pMachineLocation.ParameterName = "in_MachineLocation";
                    pMachineLocation.Value         = machineVM.MachineLocation;
                    cmd.Parameters.Add(pMachineLocation);

                    MySqlParameter pProductName = new MySqlParameter();
                    pProductName.ParameterName = "in_ProductName";
                    pProductName.Value         = machineVM.ProductName;
                    cmd.Parameters.Add(pProductName);

                    MySqlParameter pSupervisorName = new MySqlParameter();
                    pSupervisorName.ParameterName = "in_SupervisorName";
                    pSupervisorName.Value         = machineVM.SupervisorName;
                    cmd.Parameters.Add(pSupervisorName);

                    MySqlParameter pEmailTo = new MySqlParameter();
                    pEmailTo.ParameterName = "in_EmailTo";
                    pEmailTo.Value         = machineVM.EmailTo;
                    cmd.Parameters.Add(pEmailTo);

                    MySqlParameter pConnectionType = new MySqlParameter();
                    pConnectionType.ParameterName = "in_ConnectionType";
                    pConnectionType.Value         = machineVM.ConnectionType;
                    cmd.Parameters.Add(pConnectionType);

                    MySqlParameter pServerIP = new MySqlParameter();
                    pServerIP.ParameterName = "in_MachineIP";
                    pServerIP.Value         = machineVM.MachineIP;
                    cmd.Parameters.Add(pServerIP);

                    MySqlParameter pServerPort = new MySqlParameter();
                    pServerPort.ParameterName = "in_MachinePort";
                    pServerPort.Value         = machineVM.MachinePort;
                    cmd.Parameters.Add(pServerPort);

                    MySqlParameter pComportName = new MySqlParameter();
                    pComportName.ParameterName = "in_ComportName";
                    pComportName.Value         = machineVM.COMPortName;
                    cmd.Parameters.Add(pComportName);

                    MySqlParameter pComportParity = new MySqlParameter();
                    pComportParity.ParameterName = "in_ComportParity";
                    pComportParity.Value         = machineVM.COMPortParity;
                    cmd.Parameters.Add(pComportParity);

                    MySqlParameter pin_ComPortBaudRate = new MySqlParameter();
                    pin_ComPortBaudRate.ParameterName = "in_ComPortBaudRate";
                    pin_ComPortBaudRate.Value         = machineVM.COMPortBoadRate;
                    cmd.Parameters.Add(pin_ComPortBaudRate);

                    MySqlParameter pCommandType = new MySqlParameter();
                    pCommandType.ParameterName = "in_CommandType";
                    pCommandType.Value         = CommandType.ToString();
                    cmd.Parameters.Add(pCommandType);

                    MySqlParameter outPutErrorId = new MySqlParameter();
                    outPutErrorId.ParameterName = "out_ErrorId";
                    outPutErrorId.Direction     = System.Data.ParameterDirection.Output;
                    cmd.Parameters.Add(outPutErrorId);

                    MySqlParameter outPutErrorMessage = new MySqlParameter();
                    outPutErrorMessage.ParameterName = "out_ErrorMessage";
                    outPutErrorMessage.Direction     = System.Data.ParameterDirection.Output;
                    cmd.Parameters.Add(outPutErrorMessage);

                    cmd.ExecuteNonQuery();
                    errmsg.ErrorId          = (int)outPutErrorId.Value;
                    errmsg.ErrorDescription = outPutErrorMessage.Value.ToString();
                }
            }
            catch (Exception ex)
            {
                logger.LogError("Exception in DALC CLASS, Method Name AddMachine, Message : " + ex.Message);
                errmsg.ErrorId          = 0;
                errmsg.ErrorDescription = ex.Message;
            }
            return(errmsg);
        }
Exemplo n.º 2
0
        internal static ErrorMessage ManageUser(UserViewModel userviewmodel, CommandTypeEnum commandtype)
        {
            ErrorMessage errmsg           = new ErrorMessage();
            string       connectionString = ConfigurationManager.ConnectionStrings["myCon"].ConnectionString;

            try
            {
                using (MySqlConnection con = new MySqlConnection(connectionString))
                {
                    con.Open();
                    MySqlCommand cmd = new MySqlCommand("sp_ManageUser", con);
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;

                    MySqlParameter pin_UserId = new MySqlParameter();
                    pin_UserId.ParameterName = "in_UserId";
                    pin_UserId.Value         = userviewmodel.UserId;
                    cmd.Parameters.Add(pin_UserId);

                    MySqlParameter pin_FullName = new MySqlParameter();
                    pin_FullName.ParameterName = "in_FullName";
                    pin_FullName.Value         = userviewmodel.FullName;
                    cmd.Parameters.Add(pin_FullName);

                    MySqlParameter pin_Designation = new MySqlParameter();
                    pin_Designation.ParameterName = "in_Designation";
                    pin_Designation.Value         = userviewmodel.Designation;
                    cmd.Parameters.Add(pin_Designation);

                    MySqlParameter pin_Email = new MySqlParameter();
                    pin_Email.ParameterName = "in_Email";
                    pin_Email.Value         = userviewmodel.Email;
                    cmd.Parameters.Add(pin_Email);

                    MySqlParameter pin_Mobile = new MySqlParameter();
                    pin_Mobile.ParameterName = "in_Mobile";
                    pin_Mobile.Value         = userviewmodel.Mobile;
                    cmd.Parameters.Add(pin_Mobile);

                    MySqlParameter pin_UserName = new MySqlParameter();
                    pin_UserName.ParameterName = "in_UserName";
                    pin_UserName.Value         = userviewmodel.UserName;
                    cmd.Parameters.Add(pin_UserName);

                    MySqlParameter pin_Password = new MySqlParameter();
                    pin_Password.ParameterName = "in_Password";
                    pin_Password.Value         = userviewmodel.Password;
                    cmd.Parameters.Add(pin_Password);

                    MySqlParameter pCommandType = new MySqlParameter();
                    pCommandType.ParameterName = "in_CommandType";
                    pCommandType.Value         = commandtype.ToString();
                    cmd.Parameters.Add(pCommandType);

                    MySqlParameter outPutErrorId = new MySqlParameter();
                    outPutErrorId.ParameterName = "out_ErrorId";
                    outPutErrorId.Direction     = System.Data.ParameterDirection.Output;
                    cmd.Parameters.Add(outPutErrorId);

                    MySqlParameter outPutErrorMessage = new MySqlParameter();
                    outPutErrorMessage.ParameterName = "out_ErrorMessage";
                    outPutErrorMessage.Direction     = System.Data.ParameterDirection.Output;
                    cmd.Parameters.Add(outPutErrorMessage);

                    cmd.ExecuteNonQuery();
                    errmsg.ErrorId          = (int)outPutErrorId.Value;
                    errmsg.ErrorDescription = outPutErrorMessage.Value.ToString();
                }
            }
            catch (Exception ex)
            {
                errmsg.ErrorId          = 0;
                errmsg.ErrorDescription = "Exception in ManageUser method, Message" + ex.Message;
            }
            return(errmsg);
        }
Exemplo n.º 3
0
        internal static ErrorMessage ManageEmailConfig(EMailViewModel EmailVM, CommandTypeEnum commandtype)
        {
            ErrorMessage errmsg           = new ErrorMessage();
            string       connectionString = ConfigurationManager.ConnectionStrings["myCon"].ConnectionString;

            try
            {
                using (MySqlConnection con = new MySqlConnection(connectionString))
                {
                    con.Open();
                    MySqlCommand cmd = new MySqlCommand("spEmailConfig", con);
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;

                    MySqlParameter pId = new MySqlParameter();
                    pId.ParameterName = "in_Id";
                    pId.Value         = EmailVM.Id;
                    cmd.Parameters.Add(pId);

                    MySqlParameter pEmailName = new MySqlParameter();
                    pEmailName.ParameterName = "in_EmailName";
                    pEmailName.Value         = EmailVM.EmailName;
                    cmd.Parameters.Add(pEmailName);

                    MySqlParameter pEmailFrom = new MySqlParameter();
                    pEmailFrom.ParameterName = "in_EmailFrom";
                    pEmailFrom.Value         = EmailVM.EmailFrom;
                    cmd.Parameters.Add(pEmailFrom);

                    MySqlParameter pEmailPassword = new MySqlParameter();
                    pEmailPassword.ParameterName = "in_EmailPassword";
                    pEmailPassword.Value         = EmailVM.EmailPassword;
                    cmd.Parameters.Add(pEmailPassword);

                    MySqlParameter pSMTPAddress = new MySqlParameter();
                    pSMTPAddress.ParameterName = "in_SMTPAddress";
                    pSMTPAddress.Value         = EmailVM.SMTPAddress;
                    cmd.Parameters.Add(pSMTPAddress);

                    MySqlParameter pSMTPPort = new MySqlParameter();
                    pSMTPPort.ParameterName = "in_SMTPPort";
                    pSMTPPort.Value         = EmailVM.SMTPPort;
                    cmd.Parameters.Add(pSMTPPort);

                    MySqlParameter pEnableSSL = new MySqlParameter();
                    pEnableSSL.ParameterName = "in_EnableSSL";
                    pEnableSSL.Value         = EmailVM.EnableSSL;
                    cmd.Parameters.Add(pEnableSSL);

                    MySqlParameter pEmailTo1 = new MySqlParameter();
                    pEmailTo1.ParameterName = "in_EmailTo1";
                    pEmailTo1.Value         = EmailVM.EmailTo1;
                    cmd.Parameters.Add(pEmailTo1);

                    MySqlParameter pEmailTo2 = new MySqlParameter();
                    pEmailTo2.ParameterName = "in_EmailTo2";
                    pEmailTo2.Value         = EmailVM.EmailTo2;
                    cmd.Parameters.Add(pEmailTo2);

                    MySqlParameter pEmailTo3 = new MySqlParameter();
                    pEmailTo3.ParameterName = "in_EmailTo3";
                    pEmailTo3.Value         = EmailVM.EmailTo3;
                    cmd.Parameters.Add(pEmailTo3);

                    MySqlParameter pEmailTo4 = new MySqlParameter();
                    pEmailTo4.ParameterName = "in_EmailTo4";
                    pEmailTo4.Value         = EmailVM.EmailTo4;
                    cmd.Parameters.Add(pEmailTo4);

                    MySqlParameter pEmailTo5 = new MySqlParameter();
                    pEmailTo5.ParameterName = "in_EmailTo5";
                    pEmailTo5.Value         = EmailVM.EmailTo5;
                    cmd.Parameters.Add(pEmailTo5);

                    MySqlParameter pEntryDate = new MySqlParameter();
                    pEntryDate.ParameterName = "in_EntryDate";
                    pEntryDate.Value         = EmailVM.EntryDate;
                    cmd.Parameters.Add(pEntryDate);

                    MySqlParameter pCommandType = new MySqlParameter();
                    pCommandType.ParameterName = "in_CommandType";
                    pCommandType.Value         = commandtype.ToString();
                    cmd.Parameters.Add(pCommandType);

                    MySqlParameter outPutErrorId = new MySqlParameter();
                    outPutErrorId.ParameterName = "out_ErrorId";
                    outPutErrorId.Direction     = System.Data.ParameterDirection.Output;
                    cmd.Parameters.Add(outPutErrorId);

                    MySqlParameter outPutErrorMessage = new MySqlParameter();
                    outPutErrorMessage.ParameterName = "out_ErrorMessage";
                    outPutErrorMessage.Direction     = System.Data.ParameterDirection.Output;
                    cmd.Parameters.Add(outPutErrorMessage);

                    cmd.ExecuteNonQuery();
                    errmsg.ErrorId          = (int)outPutErrorId.Value;
                    errmsg.ErrorDescription = outPutErrorMessage.Value.ToString();
                }
            }
            catch (Exception ex)
            {
                errmsg.ErrorId          = 0;
                errmsg.ErrorDescription = ex.Message;
            }
            return(errmsg);
        }