Beispiel #1
0
        public SqlConnection GetConnection(string database = "master")
        {
            var sb = new StringBuilder();

            sb.Append("server=@server;database=@database;Integrated Security=@winauth;User ID=@user;Password=@password;timeout=10");
            sb.Replace("@server", _instance);
            sb.Replace("@database", database);
            sb.Replace("@winauth", WinAuth.ToString());
            sb.Replace("@user", _user);
            sb.Replace("@password", _password);

            var conn = new SqlConnection(sb.ToString());

            return(conn);
        }
        public WinAuth WinAuth()
        {
            WinAuth result = new WinAuth();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("https://strategyreporting.evalueserve.com/");
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Add("Cache-Control", "no-cache");
                var response = client.GetAsync("WinAuthApi/Auth/GetUser").Result;
                if (response.IsSuccessStatusCode)
                {
                    string responseString = response.Content.ReadAsStringAsync().Result;
                    result = response.Content.ReadAsAsync <WinAuth>().Result;
                }
            }
            return(result);
        }
Beispiel #3
0
        public void SchreibeXML()
        {
            try
            {
                // Erzeugt ein neues XMLDocument
                XmlDocument doc = new XmlDocument();

                // Fügt den Wurzelknoten "Config" zum XMLDocument hinzu
                XmlNode rootNode = doc.CreateElement("Config");
                doc.AppendChild(rootNode);

                // Erzeugt einen Knoten mit dem Tag "Allgemein"
                XmlNode childNodeAllg = doc.CreateElement("Allgemein");
                // Fügt die Eigenschaft Stundensoll dem Knoten hinzu
                XmlAttribute stundenSoll = doc.CreateAttribute("Stundensoll");
                stundenSoll.Value = StundenSoll.ToString();
                childNodeAllg.Attributes.Append(stundenSoll);
                // Fügt die Eigenschaft StandardZielPfad dem Knoten hinzu
                XmlAttribute standardZielPfad = doc.CreateAttribute("StandardZielPfad");
                standardZielPfad.Value = StandardZielPfad.ToString();
                childNodeAllg.Attributes.Append(standardZielPfad);
                // Fügt den Knoten dem XMLDocument hinzu
                rootNode.AppendChild(childNodeAllg);

                // Erzeugt einen Knoten mit dem Tag "Datenbank"
                XmlNode childNodeDB = doc.CreateElement("Datenbank");
                // Fügt die Eigenschaft WinAuth dem Knoten hinzu
                XmlAttribute winAuth = doc.CreateAttribute("WinAuth");
                winAuth.Value = WinAuth.ToString();
                childNodeDB.Attributes.Append(winAuth);
                // Fügt die Eigenschaft Datenbank dem Knoten hinzu
                XmlAttribute datenbank = doc.CreateAttribute("Datenbank");
                datenbank.Value = Datenbank.ToString();
                childNodeDB.Attributes.Append(datenbank);
                // Fügt die Eigenschaft Server dem Knoten hinzu
                XmlAttribute server = doc.CreateAttribute("Server");
                server.Value = Server.ToString();
                childNodeDB.Attributes.Append(server);
                // Fügt die Eigenschaft BenutzerName dem Knoten hinzu
                XmlAttribute benutzerName = doc.CreateAttribute("BenutzerName");
                benutzerName.Value = BenutzerName.ToString();
                childNodeDB.Attributes.Append(benutzerName);
                // Fügt die Eigenschaft Passwort dem Knoten hinzu
                XmlAttribute passwort = doc.CreateAttribute("Passwort");
                passwort.Value = Passwort.ToString();
                childNodeDB.Attributes.Append(passwort);
                // Fügt den Knoten dem XMLDocument hinzu
                rootNode.AppendChild(childNodeDB);

                // Schreibt das XmlDocument in die Datei in %Appdata%
                string path = GetFolderPath(SpecialFolder.ApplicationData);
                path = Path.Combine(path, "easyAuftrag");
                path = Path.Combine(path, "Config");
                Directory.CreateDirectory(path);
                path = Path.Combine(path, "config.xml");
                doc.Save(path);
            }
            catch (Exception ex)
            {
                ErrorHandler.ErrorHandle(ex);
            }
        }