Exemplo n.º 1
0
        public async Task <CompanyMaster> getComapnyDtl(int COMPID)
        {
            try
            {
                CompanyMaster obj = new CompanyMaster();

                Xdoc = DBXML.CLIENTCONNECTION_h(COMPID, 0);
                dt   = SqlExev2.GetDT(Xdoc, dbConnectionString);

                obj = (from row in dt.AsEnumerable()
                       select new CompanyMaster
                {
                    CompName = row.Field <string>("compName"),
                    ServerName = row.Field <string>("serverName"),
                    AuthType = row.Field <string>("AuthType"),
                    UserName = row.Field <string>("userName"),
                    PASSWORD = row.Field <string>("PASSWORD"),
                    DatabaseName = row.Field <string>("databaseName")
                                   //isActive = row.Field<string>("isActive"),
                                   //createdOn = row.Field<string>("createdOn"),
                                   //ceatedBy = row.Field<string>("ceatedBy"),
                }).FirstOrDefault();

                return(await Task.Factory.StartNew(() => obj));

                //return obj;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 2
0
        public async Task <string> getComapnyConnectionstr(int COMPID)
        {
            try
            {
                CompanyMaster obj = new CompanyMaster();

                Xdoc = DBXML.CLIENTCONNECTION_h(COMPID, 0);
                dt   = SqlExev2.GetDT(Xdoc, dbConnectionString);

                obj = (from row in dt.AsEnumerable()
                       select new CompanyMaster
                {
                    CompName = row.Field <string>("compName"),
                    ServerName = row.Field <string>("serverName"),
                    AuthType = row.Field <string>("AuthType"),
                    UserName = row.Field <string>("userName"),
                    PASSWORD = row.Field <string>("PASSWORD"),
                    DatabaseName = row.Field <string>("databaseName")
                }).FirstOrDefault();

                string connectionString = "";
                if (obj != null)
                {
                    string connetion = "";
                    if (obj.AuthType == "SQL Server Authentication")
                    {
                        connetion = "Data Source=" + obj.ServerName + ";Initial Catalog=" + obj.DatabaseName + ";User ID=" + obj.UserName + ";Password="******";";
                    }
                    else
                    {
                        connetion = "Data Source=" + obj.ServerName + ";Initial Catalog=" + obj.DatabaseName + ";Integrated Security=true;";
                    }

                    connectionString = connetion;
                }

                return(await Task.Factory.StartNew(() => connectionString));

                //return obj;
            }
            catch (Exception ex)
            {
                throw;
            }
        }