public createNewCustomerResponse createNewCustomer(createNewCustomerRequest request) { Int32 kontonr; string anrede = ""; string briefanrede = ""; string vorname = ""; string nachname = ""; string name1 = ""; string name2 = ""; string name3 = ""; string suchname = ""; string strasse = ""; string plz = ""; string ort = ""; string land = ""; DateTime modifieddate; string modifieduser = ""; DateTime geburtsdatum; string steuernummer = ""; string ustidnr = ""; string telefonp = ""; string mobilp = ""; string emailp = ""; string telefond = ""; string mobild = ""; string emaild = ""; string ok1marketing = ""; string ok1post = ""; string ok1telefonp = ""; string ok1emailp = ""; string ok1sms = ""; string email = ""; Int32 rows = 0; string sqlCommand = ""; string sqlCommandValues = ""; string gebiet = ""; createNewCustomerResponse res = new createNewCustomerResponse(); Bungert.message m = new Bungert.message(); customerType cust = new customerType(); customerTypeAddress custAdr; try { //StreamReader sr = new StreamReader(@"D:\XML_newCustomer.txt"); //string xmlNewCustomer = sr.ReadToEnd(); //sr.Close(); string xmlArg0 = ""; xmlArg0 = request.Body.arg0.Replace("<postWanted/>", "").Replace("<emailWanted/>", "").Replace("<faxWanted/>", "").Replace("<phoneWanted/>", "").Replace("<smsWanted/>", "").Replace("<useData/>", "").Replace("<preferredMarketing/>", ""); System.Xml.Serialization.XmlSerializer xmlReader = new System.Xml.Serialization.XmlSerializer(typeof(interfaceData)); TextReader txtReader = new StringReader(xmlArg0); //TextReader txtReader = new StringReader(xmlNewCustomer); interfaceData data = new interfaceData(); data = (interfaceData)xmlReader.Deserialize(txtReader); modifieddate = Convert.ToDateTime("01.01.1900"); cust = data.customer[0]; custAdr = cust.address; ort = custAdr.city; land = custAdr.country; strasse = custAdr.street; plz = custAdr.zip; customerIdentificationType custID; custID = cust.customerNumber; kontonr = custID.number; suchname = cust.matchcode; vorname = cust.firstName; if (!String.IsNullOrEmpty(cust.salesman.identifier)) gebiet = cust.salesman.identifier; switch (cust.salutation) { case 1: anrede = "Herr"; briefanrede = "Sehr geehrter Herr"; break; case 2: anrede = "Frau"; briefanrede = "Sehr geehrte Frau"; break; case 9: anrede = "Firma"; briefanrede = "Sehr geehrte Damen und Herren"; break; default: anrede = ""; briefanrede = ""; break; } nachname = cust.lastName; customerTypeName[] custNames = cust.name; //List<customerTypeName> custNames = cust.name; if (custNames != null) { foreach (customerTypeName c in custNames) { switch (c.sequence) { case 1: name1 = c.name; break; case 2: name2 = c.name; break; case 3: name3 = c.name; break; } } } if (!String.IsNullOrWhiteSpace(nachname)) name1 = nachname; geburtsdatum = cust.birthDate; if (cust.numbers != null) { ustidnr = cust.numbers.vatNumber; steuernummer = cust.numbers.taxNumber; } if (cust.creation != null) { modifieddate = cust.creation.date; if (cust.creation.salesman != null) modifieduser = cust.creation.salesman.name; } customerTypePhone phone = cust.phone; telefonp = phone.@private; telefond = phone.business; customerTypePhoneMobil[] mobiles = phone.mobil; //List<customerTypePhoneMobil> mobiles = phone.mobil; //teleonP = mobiles[0].number customerTypeEmail[] emails = cust.email; //List<customerTypeEmail> emails = cust.email; if (mobiles != null) { foreach (customerTypePhoneMobil pM in mobiles) { switch (pM.sequence) { case 1: mobilp = pM.number; break; case 2: mobild = pM.number; break; } } } if (emails != null) { foreach (customerTypeEmail e in emails) { switch (e.sequence) { case 1: emailp = e.address; break; case 2: emaild = e.address; break; } } } //letzte "kontonr" wird aus Tabelle "keylookup" gezogen using (DBConnect myConnect = new DBConnect()) { String sqlKontoNr; sqlKontoNr = "SELECT keyvalue FROM bungert.keylookup WHERE tablename = 'adresse' AND fieldname = 'kontonr'"; OdbcCommand cmd = new OdbcCommand(sqlKontoNr, myConnect.conn); myConnect.Connect(); OdbcDataReader reader; //DataReader Objekt wird initialisiert using (reader = cmd.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { kontonr = reader.GetInt32(0); kontonr++; } } } if (kontonr > 0) { //Einfügen Tabelle "adresse" sqlCommand = "INSERT INTO bungert.adresse (kontonr, "; sqlCommandValues += kontonr.ToString() + ", "; if (!String.IsNullOrEmpty(anrede)) { sqlCommand += "anrede, "; sqlCommandValues += "'" + anrede + "', "; } if (!String.IsNullOrEmpty(briefanrede)) { sqlCommand += "briefanrede, "; sqlCommandValues += "'" + briefanrede + "', "; } if (!String.IsNullOrEmpty(vorname)) { sqlCommand += "vorname, "; sqlCommandValues += "'" + vorname + "', "; } if (!String.IsNullOrEmpty(name1)) { sqlCommand += "name1, "; sqlCommandValues += "'" + name1 + "', "; } if (!String.IsNullOrEmpty(name2)) { sqlCommand += "name2, "; sqlCommandValues += "'" + name2 + "', "; } if (!String.IsNullOrEmpty(name3)) { sqlCommand += "name3, "; sqlCommandValues += "'" + name3 + "', "; } if (!String.IsNullOrEmpty(suchname)) { sqlCommand += "suchname, "; sqlCommandValues += "'" + suchname + "', "; } if (!String.IsNullOrEmpty(strasse)) { sqlCommand += "strasse, "; sqlCommandValues += "'" + strasse + "', "; } if (!String.IsNullOrEmpty(plz)) { sqlCommand += "plz, "; sqlCommandValues += "'" + plz + "', "; } if (!String.IsNullOrEmpty(ort)) { sqlCommand += "ort, "; sqlCommandValues += "'" + ort + "', "; } if (!String.IsNullOrEmpty(land)) { sqlCommand += "land, "; sqlCommandValues += "'" + land + "', "; } if (modifieddate > Convert.ToDateTime("01.01.1900")) { sqlCommand += "modifieddate, "; sqlCommandValues += "'" + modifieddate.ToString("yyyy-MM-dd") + "', "; } if (!String.IsNullOrEmpty(modifieduser)) { sqlCommand += "modifieduser, "; sqlCommandValues += "'" + modifieduser + "', "; } if (geburtsdatum > Convert.ToDateTime("01.01.1900")) { sqlCommand += "geburtsdatum, "; sqlCommandValues += "'" + geburtsdatum.ToString("yyyy-MM-dd") + "', "; } if (!String.IsNullOrEmpty(steuernummer)) { sqlCommand += "steuernummer, "; sqlCommandValues += "'" + steuernummer + "', "; } if (!String.IsNullOrEmpty(ustidnr)) { sqlCommand += "ustidnr, "; sqlCommandValues += "'" + ustidnr + "', "; } if (!String.IsNullOrEmpty(telefonp)) { sqlCommand += "komm1art, komm1nr, "; sqlCommandValues += "'Telefon P', '" + telefonp + "', "; } if (!String.IsNullOrEmpty(telefond)) { sqlCommand += "komm2art, komm2nr, "; sqlCommandValues += "'Telefon D', '" + telefond + "', "; } if (!String.IsNullOrEmpty(mobilp)) { sqlCommand += "komm3art, komm3nr, "; sqlCommandValues += "'Mobil', '" + mobilp + "', "; } if (!String.IsNullOrEmpty(mobild)) { sqlCommand += "komm4art, komm4nr, "; sqlCommandValues += "'Mobil', '" + mobild + "', "; } if (!String.IsNullOrEmpty(emailp)) { sqlCommand += "komm5art, komm5nr, "; sqlCommandValues += "'E-Mail', '" + emailp + "', "; } if (!String.IsNullOrEmpty(gebiet)) { sqlCommand += "gebiet, "; sqlCommandValues += "'" + gebiet + "', "; } sqlCommand = sqlCommand.Substring(0, sqlCommand.Length - 2) + ")"; sqlCommandValues = sqlCommandValues.Substring(0, sqlCommandValues.Length - 2) + ")"; sqlCommand += " values ("; sqlCommand += sqlCommandValues; //using (DBConnect myConnect = new DBConnect()) //{ cmd = new OdbcCommand(sqlCommand, myConnect.conn); //myConnect.Connect(); rows = cmd.ExecuteNonQuery(); //Update der Tabelle "keylookup" - Wert für "kontonr" in Tabelle "adresse" wird gesetzt if (rows == 1) { string sqlUpdateKontoNr = ""; sqlUpdateKontoNr = "UPDATE bungert.keylookup SET keyvalue = " + kontonr + " WHERE tablename = 'adresse' AND fieldname = 'kontonr'"; cmd = new OdbcCommand(sqlUpdateKontoNr, myConnect.conn); //myConnect.Connect(); rows = cmd.ExecuteNonQuery(); } //} customerTypeMarketing custMarketing = cust.marketing; if (custMarketing != null) { ok1post = custMarketing.phoneWanted != null ? Convert.ToInt32(custMarketing.phoneWanted.Value).ToString() : null; ok1emailp = custMarketing.emailWanted != null ? Convert.ToInt32(custMarketing.emailWanted.Value).ToString() : null; ok1telefonp = custMarketing.phoneWanted != null ? Convert.ToInt32(custMarketing.phoneWanted.Value).ToString() : null; ok1marketing = custMarketing.useData != null ? Convert.ToInt32(custMarketing.useData.Value).ToString() : null; ok1sms = custMarketing.smsWanted != null ? Convert.ToInt32(custMarketing.smsWanted.Value).ToString() : null; } //Einfügen Tabelle "adresse" Int32 adressID = getAdressID(kontonr, myConnect); if (adressID > 0) { sqlCommand = "INSERT INTO bungert.marketingkontakt (adressid,bearbeiter,auftragnr, "; sqlCommandValues = adressID.ToString() + ",0,0, "; if (!String.IsNullOrEmpty(telefonp)) { sqlCommand += "telefonp, "; sqlCommandValues += "'" + telefonp + "', "; } if (!String.IsNullOrEmpty(mobilp)) { sqlCommand += "mobilp, "; sqlCommand += "smsp, "; sqlCommandValues += "'" + mobilp + "', "; sqlCommandValues += "'" + mobilp + "', "; } if (!String.IsNullOrEmpty(emailp)) { sqlCommand += "emailp, "; sqlCommandValues += "'" + emailp + "', "; } if (!String.IsNullOrEmpty(telefond)) { sqlCommand += "telefond, "; sqlCommandValues += "'" + telefond + "', "; } if (!String.IsNullOrEmpty(mobild)) { sqlCommand += "mobild, "; sqlCommand += "smsd, "; sqlCommandValues += "'" + mobild + "', "; sqlCommandValues += "'" + mobild + "', "; } if (!String.IsNullOrEmpty(emaild)) { sqlCommand += "emaild, "; sqlCommandValues += "'" + emaild + "', "; } if (!String.IsNullOrEmpty(ok1post)) { sqlCommand += "ok1post, "; sqlCommand += "ok2post, "; sqlCommandValues += "'" + ok1post + "', "; sqlCommandValues += "'" + ok1post + "', "; } if (!String.IsNullOrEmpty(ok1emailp)) { sqlCommand += "ok1emailp, "; sqlCommand += "ok1emaild, "; sqlCommand += "ok2emailp, "; sqlCommand += "ok2emaild, "; sqlCommandValues += "'" + ok1emailp + "', "; sqlCommandValues += "'" + ok1emailp + "', "; sqlCommandValues += "'" + ok1emailp + "', "; sqlCommandValues += "'" + ok1emailp + "', "; } if (!String.IsNullOrEmpty(ok1telefonp)) { sqlCommand += "ok1telefonp, "; sqlCommand += "ok1telefond, "; sqlCommand += "ok2telefonp, "; sqlCommand += "ok2telefond, "; sqlCommand += "ok1mobilp, "; sqlCommand += "ok1mobild, "; sqlCommand += "ok2mobilp, "; sqlCommand += "ok2mobild, "; sqlCommandValues += "'" + ok1telefonp + "', "; sqlCommandValues += "'" + ok1telefonp + "', "; sqlCommandValues += "'" + ok1telefonp + "', "; sqlCommandValues += "'" + ok1telefonp + "', "; sqlCommandValues += "'" + ok1telefonp + "', "; sqlCommandValues += "'" + ok1telefonp + "', "; sqlCommandValues += "'" + ok1telefonp + "', "; sqlCommandValues += "'" + ok1telefonp + "', "; } if (!String.IsNullOrEmpty(ok1marketing)) { sqlCommand += "ok1marketing, "; sqlCommand += "ok2marketing, "; sqlCommandValues += "'" + ok1marketing + "', "; sqlCommandValues += "'" + ok1marketing + "', "; } if (!String.IsNullOrEmpty(ok1sms)) { sqlCommand += "ok1smsp, "; sqlCommand += "ok1smsd, "; sqlCommand += "ok2smsp, "; sqlCommand += "ok2smsd, "; sqlCommandValues += "'" + ok1sms + "', "; sqlCommandValues += "'" + ok1sms + "', "; sqlCommandValues += "'" + ok1sms + "', "; sqlCommandValues += "'" + ok1sms + "', "; } sqlCommand = sqlCommand.Substring(0, sqlCommand.Length - 2) + ")"; sqlCommandValues = sqlCommandValues.Substring(0, sqlCommandValues.Length - 2) + ")"; sqlCommand += " values ("; sqlCommand += sqlCommandValues; cmd = new OdbcCommand(sqlCommand, myConnect.conn); rows = cmd.ExecuteNonQuery(); } Bungert.responseType r = new Bungert.responseType(); r.code = "0"; Bungert.customerIdentificationType cIT = new Bungert.customerIdentificationType(); cIT.location = 1; cIT.number = kontonr; r.customerNumber = cIT; r.message = "Kunde wurde erfolgreich in P2 angelegt."; m.success = r; } else { Bungert.responseType[] r = new Bungert.responseType[1]; r[0].code = "-1"; r[0].message = "Der Kunde konnte in P2 nicht angelegt werden. Es konnte keine KontoNr generiert werden."; m.error = r; } } } catch (System.Exception ex) { string strInner = ex.InnerException.ToString(); } m.interfaceVersion = 1; m.dataProvider = "STANDARD_INTERFACE"; //UFT-8 Encoding XmlSerializer xmlSerializer = new XmlSerializer(typeof(Bungert.message)); MemoryStream memStrm = new MemoryStream(); UTF8Encoding utf8e = new UTF8Encoding(); XmlTextWriter xmlSink = new XmlTextWriter(memStrm, utf8e); xmlSerializer.Serialize(xmlSink, m); byte[] utf8EncodedData = memStrm.ToArray(); string strMessage = utf8e.GetString(utf8EncodedData); createNewCustomerResponseBody resBody = new createNewCustomerResponseBody(); resBody.@return = strMessage; res.Body = resBody; return res; }
public changeCustomerResponse changeCustomer(changeCustomerRequest request) { changeCustomerResponse res = new changeCustomerResponse(); System.Xml.Serialization.XmlSerializer xmlReader = new System.Xml.Serialization.XmlSerializer(typeof(interfaceData)); TextReader txtReader = new StringReader(request.Body.arg0); interfaceData data = new interfaceData(); data = (interfaceData)xmlReader.Deserialize(txtReader); Int32 kontonr; string anrede = ""; string briefanrede = ""; string vorname = ""; string nachname = ""; string name1 = ""; string name2 = ""; string name3 = ""; string suchname = ""; string strasse = ""; string plz = ""; string ort = ""; string land = ""; DateTime modifieddate; string modifieduser = ""; DateTime geburtsdatum; string steuernummer = ""; string ustidnr = ""; string telefonp = ""; string mobilp = ""; string emailp = ""; string telefond = ""; string mobild = ""; string emaild = ""; string ok1marketing = ""; string ok1post = ""; string ok1telefonp = ""; string ok1emailp = ""; string ok1sms = ""; string email = ""; string gebiet = ""; Bungert.message m = new Bungert.message(); customerType cust = new customerType(); customerTypeAddress custAdr; modifieddate = Convert.ToDateTime("01.01.1900"); cust = data.customer[0]; custAdr = cust.address; ort = custAdr.city; land = custAdr.country; strasse = custAdr.street; plz = custAdr.zip; customerIdentificationType custID; custID = cust.customerNumber; kontonr = custID.number; suchname = cust.matchcode; vorname = cust.firstName; if((cust.salesman != null)) { if (!String.IsNullOrEmpty(cust.salesman.identifier)) gebiet = cust.salesman.identifier; } switch(cust.salutation) { case 1: anrede = "Herr"; briefanrede = "Sehr geehrter Herr"; break; case 2: anrede = "Frau"; briefanrede = "Sehr geehrte Frau"; break; case 9: anrede = "Firma"; briefanrede = "Sehr geehrte Damen und Herren"; break; default: anrede = ""; briefanrede = ""; break; } nachname = cust.lastName; customerTypeName[] custNames = cust.name; //List<customerTypeName> custNames = cust.name; if (custNames != null) { foreach (customerTypeName c in custNames) { switch (c.sequence) { case 1: name1 = c.name; break; case 2: name2 = c.name; break; case 3: name3 = c.name; break; } } } if (!String.IsNullOrEmpty(nachname)) name1 = nachname; geburtsdatum = cust.birthDate; if (cust.numbers != null) { ustidnr = cust.numbers.vatNumber; steuernummer = cust.numbers.taxNumber; } if(cust.lastChange != null) modifieddate = cust.lastChange.date; if (cust.lastChange.salesman != null) modifieduser = cust.lastChange.salesman.name; if (cust.phone != null) { customerTypePhone phone = cust.phone; telefonp = phone.@private; telefond = phone.business; customerTypePhoneMobil[] mobiles = phone.mobil; //List<customerTypePhoneMobil> mobiles = phone.mobil; //teleonP = mobiles[0].number if (mobiles != null) { foreach (customerTypePhoneMobil pM in mobiles) { switch (pM.sequence) { case 1: mobilp = pM.number; break; case 2: mobild = pM.number; break; } } } } if (cust.email != null) { customerTypeEmail[] emails = cust.email; //List<customerTypeEmail> emails = cust.email; if (emails != null) { foreach (customerTypeEmail e in emails) { switch (e.sequence) { case 1: emailp = e.address; break; case 2: emaild = e.address; break; } } } } Int32 rows = 0; //Update Tabelle "adresse" string sqlCommand; sqlCommand = "Update bungert.adresse set "; if (!String.IsNullOrEmpty(anrede)) sqlCommand += "anrede = '" + anrede + "', "; if (!String.IsNullOrEmpty(briefanrede)) sqlCommand += "briefanrede = '" + briefanrede + "', "; if (!String.IsNullOrEmpty(vorname)) sqlCommand += "vorname = '" + vorname + "', "; if (!String.IsNullOrEmpty(name1)) sqlCommand += "name1 = '" + name1 + "', "; if (!String.IsNullOrEmpty(name2)) sqlCommand += "name2 = '" + name2 + "', "; if (!String.IsNullOrEmpty(name3)) sqlCommand += "name3 = '" + name3 + "', "; if (!String.IsNullOrEmpty(suchname)) sqlCommand += "suchname = '" + suchname + "', "; if (!String.IsNullOrEmpty(strasse)) sqlCommand += "strasse = '" + strasse + "', "; if (!String.IsNullOrEmpty(plz)) sqlCommand += "plz = '" + plz + "', "; if (!String.IsNullOrEmpty(ort)) sqlCommand += "ort = '" + ort + "', "; if (!String.IsNullOrEmpty(land)) sqlCommand += "land = '" + land + "', "; if (modifieddate > Convert.ToDateTime("01.01.1900")) sqlCommand += "modifieddate = '" + modifieddate.ToString("yyyy-MM-dd") + "', "; if (!String.IsNullOrEmpty(modifieduser)) sqlCommand += "modifieduser = '******', "; if (geburtsdatum > Convert.ToDateTime("01.01.1900")) sqlCommand += "geburtsdatum = '" + geburtsdatum.ToString("yyyy-MM-dd") + "', "; if (!String.IsNullOrEmpty(steuernummer)) sqlCommand += "steuernummer = '" + steuernummer + "', "; if (!String.IsNullOrEmpty(ustidnr)) sqlCommand += "ustidnr = '" + ustidnr + "', "; if (!String.IsNullOrEmpty(telefonp)) sqlCommand += "komm1art = 'Telefon P', komm1nr = '" + telefonp + "', "; if (!String.IsNullOrEmpty(telefond)) sqlCommand += "komm2art = 'Telefon D', komm2nr = '" + telefond + "', "; if (!String.IsNullOrEmpty(mobilp)) sqlCommand += "komm3art = 'Mobil', komm3nr = '" + mobilp + "', "; if (!String.IsNullOrEmpty(mobild)) sqlCommand += "komm4art = 'Mobil', komm4nr = '" + mobild + "', "; if (!String.IsNullOrEmpty(emailp)) email = "komm5art = 'E-Mail', komm5nr = '" + emaild + "', "; if (!String.IsNullOrEmpty(emailp)) email = "komm5art = 'E-Mail', komm5nr = '" + emailp + "', "; if (!String.IsNullOrEmpty(email)) sqlCommand += email; if (!String.IsNullOrEmpty(gebiet)) sqlCommand += "gebiet = '" + gebiet + "', "; sqlCommand = sqlCommand.Substring(0, sqlCommand.Length - 2); sqlCommand += " WHERE kontonr = " + kontonr.ToString(); using (DBConnect myConnect = new DBConnect()) { OdbcCommand cmd = new OdbcCommand(sqlCommand, myConnect.conn); myConnect.Connect(); rows = cmd.ExecuteNonQuery(); } customerTypeMarketing custMarketing = cust.marketing; if (custMarketing != null) { ok1post = custMarketing.phoneWanted != null ? Convert.ToInt32(custMarketing.phoneWanted.Value).ToString() : null; ok1emailp = custMarketing.emailWanted != null ? Convert.ToInt32(custMarketing.emailWanted.Value).ToString() : null; ok1telefonp = custMarketing.phoneWanted != null ? Convert.ToInt32(custMarketing.phoneWanted.Value).ToString() : null; ok1marketing = custMarketing.useData != null ? Convert.ToInt32(custMarketing.useData.Value).ToString() : null; ok1sms = custMarketing.smsWanted != null ? Convert.ToInt32(custMarketing.smsWanted.Value).ToString() : null; } //Update Tabelle "marketingkontakt" sqlCommand = ""; if (!String.IsNullOrEmpty(telefonp)) sqlCommand += "telefonp = '" + telefonp + "', "; if (!String.IsNullOrEmpty(mobilp)) { sqlCommand += "mobilp = '" + mobilp + "', "; sqlCommand += "smsp = '" + mobilp + "', "; } if (!String.IsNullOrEmpty(emailp)) sqlCommand += "emailp = '" + emailp + "', "; if (!String.IsNullOrEmpty(telefond)) sqlCommand += "telefond = '" + telefond + "', "; if (!String.IsNullOrEmpty(mobild)) { sqlCommand += "mobild = '" + mobild + "', "; sqlCommand += "smsd = '" + mobild + "', "; } if (!String.IsNullOrEmpty(emaild)) sqlCommand += "emaild = '" + emaild + "', "; if (!String.IsNullOrEmpty(ok1post)) { sqlCommand += "ok1post = " + ok1post + ", "; sqlCommand += "ok2post = " + ok1post + ", "; } if (!String.IsNullOrEmpty(ok1emailp)) { sqlCommand += "ok1emailp = " + ok1emailp + ", "; sqlCommand += "ok1emaild = " + ok1emailp + ", "; sqlCommand += "ok2emailp = " + ok1emailp + ", "; sqlCommand += "ok2emaild = " + ok1emailp + ", "; } if (!String.IsNullOrEmpty(ok1telefonp)) { sqlCommand += "ok1telefonp = " + ok1telefonp + ", "; sqlCommand += "ok1telefond = " + ok1telefonp + ", "; sqlCommand += "ok1mobilp = " + ok1telefonp + ", "; sqlCommand += "ok1mobild = " + ok1telefonp + ", "; sqlCommand += "ok2telefonp = " + ok1telefonp + ", "; sqlCommand += "ok2telefond = " + ok1telefonp + ", "; sqlCommand += "ok2mobilp = " + ok1telefonp + ", "; sqlCommand += "ok2mobild = " + ok1telefonp + ", "; } if (!String.IsNullOrEmpty(ok1marketing)) { sqlCommand += "ok1marketing = " + ok1marketing + ", "; sqlCommand += "ok2marketing = " + ok1marketing + ", "; } if (!String.IsNullOrEmpty(ok1sms)) { sqlCommand += "ok1smsp = " + ok1sms + ", "; sqlCommand += "ok1smsd = " + ok1sms + ", "; sqlCommand += "ok2smsp = " + ok1sms + ", "; sqlCommand += "ok2smsd = " + ok1sms + ", "; } if (!String.IsNullOrWhiteSpace(sqlCommand)) { sqlCommand = "Update bungert.marketingkontakt a set " + sqlCommand; sqlCommand = sqlCommand.Substring(0, sqlCommand.Length - 2); sqlCommand += " FROM bungert.adresse b"; sqlCommand += " WHERE a.adressid = b.adressid AND b.kontonr = " + kontonr.ToString(); using (DBConnect myConnect = new DBConnect()) { OdbcCommand cmd = new OdbcCommand(sqlCommand, myConnect.conn); myConnect.Connect(); rows = cmd.ExecuteNonQuery(); } } m.dataProvider = "STANDARD_INTERFACE"; Bungert.responseType r = new Bungert.responseType(); r.code = "0"; Bungert.customerIdentificationType cIT = new Bungert.customerIdentificationType(); cIT.location = 1; cIT.number = kontonr; r.customerNumber = cIT; r.message = "Kundendaten wurden erfolgreich in P2 geändert."; m.success = r; m.interfaceVersion = 1; //UFT-8 Encoding XmlSerializer xmlSerializer = new XmlSerializer(typeof(Bungert.message)); MemoryStream memStrm = new MemoryStream(); UTF8Encoding utf8e = new UTF8Encoding(); XmlTextWriter xmlSink = new XmlTextWriter(memStrm, utf8e); xmlSerializer.Serialize(xmlSink, m); byte[] utf8EncodedData = memStrm.ToArray(); string strMessage = utf8e.GetString(utf8EncodedData); changeCustomerResponseBody resBody = new changeCustomerResponseBody(); resBody.@return = strMessage; res.Body = resBody; return res; }
public changeCustomerVehicleResponse changeCustomerVehicle(changeCustomerVehicleRequest request) { Int32 kontonr; Int32 fahrzeugid; string fahrgestellnr = ""; string zulassungskz = ""; string marke = ""; string verkaufstyp = ""; string bezeichnung = ""; string motorseriennr = ""; DateTime datumerstzulassung; Int32 kilometerstand; string farbe = ""; string innenausstattung = ""; Int32 kw; DateTime datumbesuch; DateTime modifieddate; string modifieduser = ""; DateTime datumzulassungkunde; DateTime datumhu; DateTime datumau; string zuendschluesselnr = ""; string tuerschluesselnr = ""; string radiocode = ""; Int32 hubraum; string kbahsnr = ""; string motortyp = ""; string kfzbriefnr = ""; string treibstoff = ""; string info = ""; string kfzversicherung = ""; Int32 modelljahr; DateTime dtDefaultDB; dtDefaultDB = Convert.ToDateTime("01.01.1900"); modifieddate = dtDefaultDB; datumzulassungkunde = dtDefaultDB; datumhu = dtDefaultDB; datumau = dtDefaultDB; datumbesuch = dtDefaultDB; datumerstzulassung = dtDefaultDB; changeCustomerVehicleResponse res = new changeCustomerVehicleResponse(); Bungert.message m = new Bungert.message(); System.Xml.Serialization.XmlSerializer xmlReader = new System.Xml.Serialization.XmlSerializer(typeof(interfaceData)); TextReader txtReader = new StringReader(request.Body.arg0); interfaceData data = new interfaceData(); data = (interfaceData)xmlReader.Deserialize(txtReader); customerVehicleType cV = data.customerVehicle[0]; kontonr = 0; customerIdentificationType custID = cV.customerNumber; if(custID != null) kontonr = custID.number; fahrzeugid = cV.vehicleNumber; fahrgestellnr = cV.vin; zulassungskz = cV.licensePlate; marke = cV.brand; verkaufstyp = cV.typeCode; bezeichnung = cV.type; modelljahr = 0; if (cV.modelYear != null) modelljahr = cV.modelYear.Year; motorseriennr = cV.motorNumber; if (cV.firstRegistration != null) datumerstzulassung = cV.firstRegistration; kilometerstand = cV.milage; farbe = cV.exteriorColor; innenausstattung = cV.interiorColor; kw = cV.kw; customerVehicleTypeLastInvoice custLI = cV.lastInvoice; if(custLI != null) datumbesuch = custLI.date; // 01.01.0001 = fehlendes Datum customerVehicleTypeLastChange custLS = cV.lastChange; if(custLS != null) modifieddate = custLS.date; salesmanType custST = custLS.salesman; if(custST != null) modifieduser = custST.name; datumzulassungkunde = cV.lastRegistration; datumhu = cV.testDate1; datumau = cV.testDate2; zuendschluesselnr = cV.keyCode1; tuerschluesselnr = cV.keyCode2; radiocode = cV.radioCode; hubraum = cV.capacity; kbahsnr = cV.kbaNumber; motortyp = cV.motorCode; kfzbriefnr = cV.carsLetter; treibstoff = cV.fuelDescription; info = cV.remark; customerVehicleTypeInsurance custInsurance = cV.insurance; if(custInsurance != null) kfzversicherung = custInsurance.policyNumber; Int32 rows = 0; //Update Tabelle "fahrzeug" string sqlCommand; sqlCommand = "Update bungert.fahrzeug set "; if (!String.IsNullOrEmpty(fahrgestellnr)) sqlCommand += "fahrgestellnr = '" + fahrgestellnr + "', "; if (!String.IsNullOrEmpty(zulassungskz)) sqlCommand += "zulassungskz = '" + zulassungskz + "', "; if (!String.IsNullOrEmpty(marke)) sqlCommand += "marke = '" + marke + "', "; if (!String.IsNullOrEmpty(verkaufstyp)) sqlCommand += "verkaufstyp = '" + verkaufstyp + "', "; if (!String.IsNullOrEmpty(bezeichnung)) sqlCommand += "bezeichnung = '" + bezeichnung + "', "; if (!String.IsNullOrEmpty(motorseriennr)) sqlCommand += "motorseriennr = '" + motorseriennr + "', "; if (datumerstzulassung > Convert.ToDateTime("01.01.1900")) sqlCommand += "datumerstzulassung = '" + datumerstzulassung.ToString("yyyy-MM-dd") + "', "; if (kilometerstand != null && kilometerstand != 0) sqlCommand += "kilometerstand = " + kilometerstand.ToString() + ", "; if (!String.IsNullOrEmpty(farbe)) sqlCommand += "farbe = '" + farbe + "', "; if (!String.IsNullOrEmpty(innenausstattung)) sqlCommand += "innenausstattung = '" + innenausstattung + "', "; if (kw != null && kw != 0) sqlCommand += "kw = " + kw.ToString() + ", "; if (datumbesuch > Convert.ToDateTime("01.01.1900")) sqlCommand += "datumbesuch = '" + datumbesuch.ToString("yyyy-MM-dd") + "', "; if (modifieddate > Convert.ToDateTime("01.01.1900")) sqlCommand += "modifieddate = '" + modifieddate.ToString("yyyy-MM-dd") + "', "; if (!String.IsNullOrEmpty(modifieduser)) sqlCommand += "modifieduser = '******', "; if (datumzulassungkunde > Convert.ToDateTime("01.01.1900")) sqlCommand += "datumzulassungkunde = '" + datumzulassungkunde.ToString("yyyy-MM-dd") + "', "; if (datumhu > Convert.ToDateTime("01.01.1900")) sqlCommand += "datumhu = '" + datumhu.ToString("yyyy-MM-dd") + "', "; if (datumau > Convert.ToDateTime("01.01.1900")) sqlCommand += "datumau = '" + datumau.ToString("yyyy-MM-dd") + "', "; if (!String.IsNullOrEmpty(zuendschluesselnr)) sqlCommand += "zuendschluesselnr = '" + zuendschluesselnr + "', "; if (!String.IsNullOrEmpty(tuerschluesselnr)) sqlCommand += "tuerschluesselnr = '" + tuerschluesselnr + "', "; if (!String.IsNullOrEmpty(radiocode)) sqlCommand += "radiocode = '" + radiocode + "', "; if (hubraum != null && hubraum != 0) sqlCommand += "hubraum = " + hubraum.ToString() + ", "; if (!String.IsNullOrEmpty(kbahsnr)) sqlCommand += "kbahsnr = '" + kbahsnr + "', "; if (!String.IsNullOrEmpty(motortyp)) sqlCommand += "motortyp = '" + motortyp + "', "; if (!String.IsNullOrEmpty(kfzbriefnr)) sqlCommand += "kfzbriefnr = '" + kfzbriefnr + "', "; if (!String.IsNullOrEmpty(treibstoff)) sqlCommand += "treibstoff = '" + treibstoff + "', "; if (!String.IsNullOrEmpty(info)) sqlCommand += "info = '" + info + "', "; if (!String.IsNullOrEmpty(kfzversicherung)) sqlCommand += "kfzversicherung = '" + kfzversicherung + "', "; if (modelljahr != null && modelljahr > 1) sqlCommand += "modelljahr = " + modelljahr.ToString() + ", "; sqlCommand = sqlCommand.Substring(0, sqlCommand.Length - 2); sqlCommand += " WHERE fahrzeugid = " + fahrzeugid.ToString(); using (DBConnect myConnect = new DBConnect()) { OdbcCommand cmd = new OdbcCommand(sqlCommand, myConnect.conn); myConnect.Connect(); rows = cmd.ExecuteNonQuery(); } m.dataProvider = "STANDARD_INTERFACE"; Bungert.responseType r = new Bungert.responseType(); r.code = "0"; if (kontonr != null && kontonr != 0) { Bungert.customerIdentificationType cIT = new Bungert.customerIdentificationType(); cIT.location = 1; cIT.number = kontonr; r.customerNumber = cIT; } r.vehicleNumber = fahrzeugid; r.vehicleNumberSpecified = true; r.message = "Fahrzeugdaten wurden erfolgreich in P2 geändert."; m.success = r; m.interfaceVersion = 1; //UFT-8 Encoding XmlSerializer xmlSerializer = new XmlSerializer(typeof(Bungert.message)); MemoryStream memStrm = new MemoryStream(); UTF8Encoding utf8e = new UTF8Encoding(); XmlTextWriter xmlSink = new XmlTextWriter(memStrm, utf8e); xmlSerializer.Serialize(xmlSink, m); byte[] utf8EncodedData = memStrm.ToArray(); string strMessage = utf8e.GetString(utf8EncodedData); changeCustomerVehicleResponseBody resBody = new changeCustomerVehicleResponseBody(); resBody.@return = strMessage; res.Body = resBody; return res; }
public deleteCustomerVehicleResponse deleteCustomerVehicle(deleteCustomerVehicleRequest request) { Int32 kontonr; Int32 rows; Int32 fahrzeugid; string sqlCommand = ""; deleteCustomerVehicleResponse res = new deleteCustomerVehicleResponse(); System.Xml.Serialization.XmlSerializer xmlReader = new System.Xml.Serialization.XmlSerializer(typeof(interfaceData)); TextReader txtReader = new StringReader(request.Body.arg0); interfaceData data = new interfaceData(); data = (interfaceData)xmlReader.Deserialize(txtReader); Bungert.message m = new Bungert.message(); customerVehicleType cV = new customerVehicleType(); cV = data.customerVehicle[0]; customerIdentificationType custID; custID = cV.customerNumber; kontonr = 0; if (custID != null) { kontonr = custID.number; } fahrzeugid = cV.vehicleNumber; sqlCommand += "UPDATE bungert.fahrzeug set aktiv = 0 WHERE fahrzeugid = " + fahrzeugid.ToString(); using (DBConnect myConnect = new DBConnect()) { OdbcCommand cmd = new OdbcCommand(sqlCommand, myConnect.conn); myConnect.Connect(); rows = cmd.ExecuteNonQuery(); } m.dataProvider = "STANDARD_INTERFACE"; Bungert.responseType r = new Bungert.responseType(); r.code = "0"; if (kontonr > 0) { Bungert.customerIdentificationType cIT = new Bungert.customerIdentificationType(); cIT.location = 1; cIT.number = kontonr; r.customerNumber = cIT; } r.message = "Fahrzeug wurde in P2 auf inaktiv gesetzt."; m.success = r; m.interfaceVersion = 1; //UFT-8 Encoding XmlSerializer xmlSerializer = new XmlSerializer(typeof(Bungert.message)); MemoryStream memStrm = new MemoryStream(); UTF8Encoding utf8e = new UTF8Encoding(); XmlTextWriter xmlSink = new XmlTextWriter(memStrm, utf8e); xmlSerializer.Serialize(xmlSink, m); byte[] utf8EncodedData = memStrm.ToArray(); string strMessage = utf8e.GetString(utf8EncodedData); deleteCustomerVehicleResponseBody resBody = new deleteCustomerVehicleResponseBody(); resBody.@return = strMessage; res.Body = resBody; return res; }