Exemplo n.º 1
0
        public cmlConnectDB C_GEToSetting()
        {
            string tXMLPath = string.Empty;

            try
            {
                tXMLPath = "Setting.xml";
                var oConBD    = new cmlConnectDB();
                var oXElement = XElement.Load(tXMLPath);

                oConBD.tCML_Server = oXElement.Element("DbLocation").Value;

                oConBD.tCML_Database = oXElement.Element("DbName").Value;

                oConBD.tCML_Username = oXElement.Element("User").Value;

                oConBD.tCML_Password = oXElement.Element("Password").Value;

                oConBD.tCML_Url = oXElement.Element("URL").Value;

                return(oConBD);
            }
            catch (Exception oEx)
            {
                throw oEx;
            }
            finally
            {
            }
        }
Exemplo n.º 2
0
        private void W_SETxConfigDB()
        {
            cFoodLandCallAPI oFoodLandCallAPI;
            cmlConnectDB     oConnectDB;
            string           tUrl;

            try
            {
                var oConfigDB = new cSetting();
                tUrl                     = otbUrl.Text + "SETConfigDB";
                oFoodLandCallAPI         = new cFoodLandCallAPI();
                oConnectDB               = new cmlConnectDB();
                oConnectDB.tCML_Server   = otbServerName.Text;
                oConnectDB.tCML_Database = otbDbName.Text;
                oConnectDB.tCML_Username = otbUserName.Text;
                oConnectDB.tCML_Password = otbUserPwd.Text;
                oFoodLandCallAPI.C_SETxConfigDB(tUrl.Trim(), oConnectDB);
                oConnectDB.tCML_Url = otbUrl.Text;
                oConfigDB.C_SETxSetting(oConnectDB);
            }
            catch (Exception oEx)
            {
                throw oEx;
            }
        }
Exemplo n.º 3
0
        public cmlConnectDB C_GEToConfigDB()
        {
            string tCon     = string.Empty;
            string tXMLPath = string.Empty;

            try
            {
                var oConBD = new cmlConnectDB();
                tXMLPath = HttpContext.Current.Server.MapPath("~/Config/Setting.xml");
                var oXElemente = XElement.Load(tXMLPath);

                oConBD.tCML_Server = oXElemente.Element("DbLocation").Value;

                oConBD.tCML_Database = oXElemente.Element("DbName").Value;

                oConBD.tCML_Username = oXElemente.Element("User").Value;

                oConBD.tCML_Password = oXElemente.Element("Password").Value;

                return(oConBD);
            }
            catch (Exception oEx)
            {
                throw oEx;
            }
            finally
            {
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// เขียนการตั้งค่า DataBase ไปที่ไฟล์ Config/Connection.xml
 /// </summary>
 /// <param name="ptUrl"></param>
 /// <param name="poConnectDB"></param>
 public void C_SETxConfigDB(string ptUrl, cmlConnectDB poConnectDB)
 {
     try
     {
         var tJsonContent = JsonConvert.SerializeObject(poConnectDB, Formatting.Indented);
         var tResult      = C_ContWebApi(ptUrl, "POST", tJsonContent);
     }
     catch (Exception oEx)
     {
         throw oEx;
     }
 }
Exemplo n.º 5
0
 public void POSToConfigDB([FromBody] cmlConnectDB poConnectDB)
 {
     try
     {
         var oConfigDB = new cConfigDB();
         oConfigDB.C_SETxConfigDB(poConnectDB);
     }
     catch (Exception oEx)
     {
         log.Error(cExtensionMessageError.C_GEToErrorException(oEx));
         throw cExtensionMessageError.C_GEToErrorException(oEx);
     }
 }
Exemplo n.º 6
0
 private void W_GETxConfigDB()
 {
     try
     {
         var oConfigDB  = new cSetting();
         var oConnectDB = new cmlConnectDB();
         oConnectDB         = oConfigDB.C_GEToSetting();
         otbServerName.Text = oConnectDB.tCML_Server;
         otbDbName.Text     = oConnectDB.tCML_Database;
         otbUserName.Text   = oConnectDB.tCML_Username;
         otbUserPwd.Text    = oConnectDB.tCML_Password;
         otbUrl.Text        = oConnectDB.tCML_Url;
     }
     catch (Exception oEx)
     {
         MessageBox.Show("wConfigDB : wConfigDB_Load  //" + oEx.Message);
     }
 }
Exemplo n.º 7
0
        public void C_SETxConfigDB(cmlConnectDB poConnectDB)
        {
            try
            {
                string tXMLPath = HttpContext.Current.Server.MapPath("~/Config/Setting.xml");

                XElement oResult = new XElement("ConfigDB",
                                                new XElement("DbLocation", poConnectDB.tCML_Server),
                                                new XElement("DbName", poConnectDB.tCML_Database),
                                                new XElement("User", poConnectDB.tCML_Username),
                                                new XElement("Password", poConnectDB.tCML_Password)
                                                );
                oResult.Save(tXMLPath);
            }
            catch (Exception oEx)
            {
                throw oEx;
            }
        }
Exemplo n.º 8
0
        public ViewResult ConfigDbs(cmlConnectDB poConnectDB)
        {
            //string tSQL = "Insert Into TCNMDBs(FTServer,FTDbName,FTUrsName,FTPwd)" +
            //    "Values('"+poConnectDB.tcml_Server+ "','" + poConnectDB.tcml_Database + "'," +
            //    "'" + poConnectDB.tcml_Username + "','" + poConnectDB.tcml_Password + "') ";

            //cCNSP.SP_GEToDbTbl(tSQL);

            string tXMLPath = Server.MapPath("~/Config/Setting.xml");
            //create
            XElement oResult = new XElement("ConfigDB",
                                            new XElement("DbLocation", poConnectDB.tCML_Server),
                                            new XElement("DbName", poConnectDB.tCML_Database),
                                            new XElement("User", poConnectDB.tCML_Username),
                                            new XElement("Password", poConnectDB.tCML_Password)
                                            );

            oResult.Save(tXMLPath);

            return(View());
        }
Exemplo n.º 9
0
        public void C_SETxSetting(cmlConnectDB poConnectDB)
        {
            try
            {
                string tXMLPath = "Setting.xml";

                var oResult = new XElement("Setting",
                                           new XElement("DbLocation", poConnectDB.tCML_Server),
                                           new XElement("DbName", poConnectDB.tCML_Database),
                                           new XElement("User", poConnectDB.tCML_Username),
                                           new XElement("Password", poConnectDB.tCML_Password),
                                           new XElement("URL", poConnectDB.tCML_Url),
                                           new XElement("UserName", "009"),
                                           new XElement("UserPwd", "009")

                                           );
                oResult.Save(tXMLPath);
            }
            catch (Exception oEx)
            {
                throw oEx;
            }
        }
Exemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static string SP_GETtStrCon()
        {
            string tCon     = string.Empty;
            string tXMLPath = string.Empty;

            try
            {
                var oConBD = new cmlConnectDB();
                tXMLPath = HttpContext.Current.Server.MapPath("~/Config/Setting.xml");
                var oXElement = XElement.Load(tXMLPath);

                oConBD.tCML_Server = oXElement.Element("DbLocation").Value;

                oConBD.tCML_Database = oXElement.Element("DbName").Value;

                oConBD.tCML_Username = oXElement.Element("User").Value;

                oConBD.tCML_Password = oXElement.Element("Password").Value;

                tCon = "Data Source = " + oConBD.tCML_Server
                       + "; Initial Catalog = " + oConBD.tCML_Database
                       + ";Connection Timeout=30;Connection Lifetime=0;Min Pool Size=0;Max Pool Size=30;Pooling=true "
                       + "; User ID = " + oConBD.tCML_Username
                       + "; Password = "******";";

                return(tCon);
            }
            catch (Exception oEx)
            {
                log.Error(cExtensionMessageError.C_GEToErrorException(oEx));
                return(oEx.Message);
            }
            finally
            {
            }
        }