Advertisement
Guest User

Untitled

a guest
May 31st, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.85 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Runtime.Serialization;
  4. using System.ServiceModel;
  5. using System.ServiceModel.Activation;
  6. using System.Collections.Generic;
  7. using System.Text;
  8. using System.Data;
  9. using System.Data.SqlClient;
  10. using System.Collections;
  11. using System.Data.OracleClient;
  12. using System.IO;
  13. using Sources;
  14. using FC_2010;
  15.  
  16. namespace FC_2010
  17. {
  18. [ServiceContract(Namespace = "")]
  19. [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
  20. public class Service1
  21. {
  22.  
  23. private classOracle co;
  24.  
  25.  
  26. public string DB_connect()
  27. {
  28. co = new classOracle();
  29. co.Base = "Annexe4";
  30. co.User = "crc";
  31. co.Password = "crc";
  32. if (co.connect())
  33. {
  34. return "Connexion avec succès";
  35. }
  36. else
  37. {
  38. return co.Erreur;
  39. }
  40.  
  41.  
  42. }
  43.  
  44.  
  45. public string DB_disconnect()
  46. {
  47. if (co.deconnect())
  48. {
  49. return "Déconnexion avec succès";
  50. }
  51. else
  52. {
  53. return co.Erreur;
  54. }
  55.  
  56. }
  57.  
  58.  
  59. [OperationContract]
  60. public BindingUtilisateur authentification(String _login, String _pwd)
  61. {
  62.  
  63. /*DB_connect();
  64.  
  65. Object[,] res = executeCmd("SELECT * FROM PDF_USERS WHERE USER_LOGIN='" + _login + "' AND USER_PASSWORD='" + _pwd + "'");
  66.  
  67. if (res.GetLength(0) == 0)
  68. {
  69. log = "";
  70. }
  71. else
  72. {
  73. log = _login;
  74. }
  75.  
  76. DB_disconnect();*/
  77.  
  78. CADO.ConnectionString = "Password=crc;User ID=crc;Data Source=Annexe4";
  79. Facturation.APP_UTILISATEURRow u = (Facturation.APP_UTILISATEURRow)Gestion_Droit.Identification_Utilisateur(_login, _pwd);
  80.  
  81. if (u == null)
  82. return new BindingUtilisateur();
  83. else
  84. return new BindingUtilisateur(u);
  85. }
  86.  
  87.  
  88. public Object[,] executeCmd(String cmd)
  89. {
  90. return co.getQueryResult(cmd);
  91. }
  92.  
  93.  
  94.  
  95. [OperationContract]
  96. public string getTest()
  97. {
  98. CADO.ConnectionString = "Password=crc;User ID=crc;Data Source=Annexe4";
  99. Facturation.FC_FACTUREDataTable table = new Facturation.FC_FACTUREDataTable();
  100. FC_FACTURE.SELECT_FC_FACTURE(table, true);
  101. int count = table.Rows.Count;
  102.  
  103. return ""+count;
  104. }
  105.  
  106.  
  107.  
  108. [OperationContract]
  109. public StreamReader testDTStream()
  110. {
  111. DataTable dt = new DataTable("Facture");
  112. dt.Rows.Add();
  113. dt.Rows.Add();
  114. dt.Rows.Add();
  115. dt.Rows.Add();
  116. dt.Rows.Add();
  117. dt.Rows.Add();
  118. dt.WriteXml("C:\\Facture.xml");
  119. StreamReader s = new StreamReader("C:\\Facture.xml");
  120. return s;
  121. }
  122.  
  123.  
  124. [OperationContract]
  125. public List<BindingFC_FACTURE> getFC_FACTURELists()
  126. {
  127. //chaine de connexion
  128. CADO.ConnectionString = "Password=crc;User ID=crc;Data Source=Annexe4";
  129.  
  130. //récupération de la dataTable
  131. Facturation.FC_FACTUREDataTable table = new Facturation.FC_FACTUREDataTable();
  132. FC_FACTURE.SELECT_FC_FACTURE(table, false);
  133.  
  134.  
  135. List<BindingFC_FACTURE> retour = new List<BindingFC_FACTURE>();
  136.  
  137. remplirListeGenerique(retour,null, table);
  138.  
  139. return retour;
  140. }
  141.  
  142.  
  143. [OperationContract]
  144. public List<BindingRESEAU_AGENCE> getRESEAU_AGENCELists(BindingUtilisateur _u)
  145. {
  146. //chaine de connexion
  147. CADO.ConnectionString = "Password=crc;User ID=crc;Data Source=Annexe4";
  148.  
  149. /* Test USER */
  150. StreamWriter sw = new StreamWriter("C:\\user.txt");//création du fichier
  151. String text = "User : " + _u.get_CODE_FRANCHISE() + " " + _u.get_UTIL_ID() + " " + _u.get_PROFIL_ID();
  152. sw.WriteLine("{0}", text);//enregistrement du message dans le fichier
  153. sw.Close();
  154.  
  155.  
  156. //récupération de la dataTable
  157. Facturation.RESEAU_AGENCEDataTable table = new Facturation.RESEAU_AGENCEDataTable();
  158.  
  159. Reseau_Agence.SELECT_AGENCE(_u.get_CODE_FRANCHISE(), _u.get_UTIL_ID(),_u.get_PROFIL_ID(), ref table, false);
  160.  
  161.  
  162. Reseau_Agence.SELECT_RESEAU_AGENCE(_u.get_CODE_FRANCHISE(), Convert.ToInt32(_u.get_UTIL_ID()), Convert.ToInt32(_u.get_PROFIL_ID()), false).WriteXml("C:\\leXML.xml");
  163.  
  164. List<BindingRESEAU_AGENCE> retour = new List<BindingRESEAU_AGENCE>();
  165.  
  166. remplirListeGenerique(null,retour, table);
  167.  
  168. return retour;
  169. }
  170.  
  171. /*
  172. [OperationContract]
  173. public List<BindingFC_FRANCHISE> getFC_FRANCHISELists()
  174. {
  175. //chaine de connexion
  176. CADO.ConnectionString = "Password=crc;User ID=crc;Data Source=Annexe4";
  177.  
  178. //récupération de la dataTable
  179. Facturation.FC_FACTUREDataTable table = new Facturation.FC_FACTUREDataTable();
  180. FC_FACTURE.SELECT_FC_FACTURE(table, false);
  181.  
  182.  
  183. List<BindingFC_FACTURE> retour = new List<BindingFC_FACTURE>();
  184.  
  185. remplirListe(retour, table);
  186.  
  187. return retour;
  188. }
  189. */
  190.  
  191. public void remplirListeGenerique(List<BindingFC_FACTURE> _list_BindingFC_FACTURE,List<BindingRESEAU_AGENCE> _list_BindingRESEAU_AGENCE, DataTable _table)
  192. {
  193.  
  194. if (_list_BindingFC_FACTURE != null)
  195. {
  196. _list_BindingFC_FACTURE.Clear();
  197. for (int i = 0; i < _table.Rows.Count; i++)
  198. {
  199. _list_BindingFC_FACTURE.Add(new BindingFC_FACTURE(_table.Rows[i][0].ToString(), _table.Rows[i][30].ToString(), _table.Rows[i][1].ToString(), _table.Rows[i][2].ToString(), _table.Rows[i][3].ToString(), _table.Rows[i][4].ToString(), _table.Rows[i][49].ToString()));
  200.  
  201. }
  202. }
  203.  
  204. if (_list_BindingRESEAU_AGENCE != null)
  205. {
  206. StreamWriter sw = new StreamWriter("C:\\texte.txt");//création du fichier
  207. String text = "Rows.count " + _table.Rows.Count;
  208. sw.WriteLine("{0}", text);//enregistrement du message dans le fichier
  209. sw.Close();
  210. _list_BindingRESEAU_AGENCE.Clear();
  211. Facturation.RESEAU_AGENCERow _row;
  212.  
  213. for (int i = 0; i < _table.Rows.Count; i++)
  214. {
  215. _row = (Facturation.RESEAU_AGENCERow) _table.Rows[i];
  216. _list_BindingRESEAU_AGENCE.Add(new BindingRESEAU_AGENCE(_row));
  217. //_list_BindingRESEAU_AGENCE.Add(new BindingRESEAU_AGENCE(_table.Rows[i][0].ToString(), _table.Rows[i][1].ToString(), _table.Rows[i][2].ToString(), _table.Rows[i][3].ToString(), _table.Rows[i][4].ToString(), _table.Rows[i][5].ToString(), _table.Rows[i][6].ToString(), _table.Rows[i][7].ToString(), _table.Rows[i][8].ToString(), _table.Rows[i][9].ToString(), _table.Rows[i][10].ToString(), _table.Rows[i][11].ToString(), _table.Rows[i][11].ToString(), _table.Rows[i][12].ToString(), _table.Rows[i][13].ToString(), (DateTime)_table.Rows[i][14], (DateTime) _table.Rows[i][15], _table.Rows[i][16].ToString(), _table.Rows[i][17].ToString(), _table.Rows[i][18].ToString(), _table.Rows[i][19].ToString(), _table.Rows[i][20].ToString(), _table.Rows[i][21].ToString(), _table.Rows[i][22].ToString(), _table.Rows[i][23].ToString(), _table.Rows[i][24].ToString(), _table.Rows[i][25].ToString(), (int) _table.Rows[i][26], (int) _table.Rows[i][27], (int) _table.Rows[i][28], (int) _table.Rows[i][29], _table.Rows[i][30].ToString(), _table.Rows[i][31].ToString(), _table.Rows[i][32].ToString(), _table.Rows[i][33].ToString(), _table.Rows[i][34].ToString(), _table.Rows[i][35].ToString(), _table.Rows[i][36].ToString(), _table.Rows[i][37].ToString(), _table.Rows[i][38].ToString(), _table.Rows[i][39].ToString(), _table.Rows[i][40].ToString(), _table.Rows[i][41].ToString(), _table.Rows[i][42].ToString(), _table.Rows[i][43].ToString(), _table.Rows[i][44].ToString(), _table.Rows[i][45].ToString(), (int) _table.Rows[i][46], _table.Rows[i][47].ToString()));
  218. }
  219. }
  220.  
  221. }
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228. [OperationContract]
  229. public bool updateFC_FACTURELists(List<BindingFC_FACTURE> _inList)
  230. {
  231. //chaine de connexion
  232. CADO.ConnectionString = "Password=crc;User ID=crc;Data Source=Annexe4";
  233.  
  234. //récupération de la dataTable
  235. Facturation.FC_FACTUREDataTable table = new Facturation.FC_FACTUREDataTable();
  236. FC_FACTURE.SELECT_FC_FACTURE(table, false);
  237.  
  238.  
  239. bool retour = updateTableFromFactureList(table, _inList);
  240.  
  241. return retour;
  242. }
  243.  
  244. /**
  245. * mise à jour des factures dans la BDD
  246. * ajout des nouvelles lignes
  247. * mise à jour des anciennes
  248. *
  249. */
  250. public bool updateTableFromFactureList(Facturation.FC_FACTUREDataTable _table, List<BindingFC_FACTURE> _list)
  251. {
  252. bool b = false;
  253. try
  254. {
  255. foreach (BindingFC_FACTURE _l in _list)
  256. {
  257. int i = Int32.Parse(_l.get_FACT_ID());
  258. int s = Int32.Parse(_l.get_SOLDE());
  259. FC_FACTURE.UPDATE_FC_FACTURE_SOLDE(i, s);
  260.  
  261. }
  262. b = true;
  263. }
  264. catch(Exception e)
  265. {
  266.  
  267. b = false;
  268.  
  269. }
  270.  
  271.  
  272. return b;
  273. }
  274.  
  275.  
  276.  
  277. }
  278. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement