Advertisement
Guest User

Untitled

a guest
Mar 1st, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.68 KB | None | 0 0
  1. public bool setDelivery_tNotice(long IDtNotice, string Barcode, string CDC, string IDOwner)
  2. {
  3. /* PARAMETRI DI INPUT
  4. * @Barcode
  5. * @CDC
  6. * @IDOwner
  7. */
  8. try
  9. {
  10. inPoste.Tools.file_tNotice myFile = new inPoste.Tools.file_tNotice();
  11.  
  12. myFile = getFiletNotice(Barcode, inPoste.Tools.TypeAssociated.tNotice);
  13.  
  14. #region Genero MD5_end e SHA7_end
  15. //Variabili locali
  16. inPoste.SaveFile mySave = new inPoste.SaveFile();
  17.  
  18. if (myFile.SHA256.Length > 0)
  19. {
  20. string _tempSHA7_end_whitCDC = mySave.FileSHA7_whitSHA256(myFile.SHA256, myFile.CDC, myFile.MTaccept);
  21. string _tempSHA7_end_whitIDFile = mySave.FileSHA7_whitSHA256(myFile.SHA256, myFile.IDFile, myFile.MTaccept);
  22. if (_tempSHA7_end_whitCDC != myFile.SHA7_start)
  23. {
  24. if (_tempSHA7_end_whitIDFile != myFile.SHA7_start)
  25. {
  26. myFile.SHA7_end = _tempSHA7_end_whitCDC;
  27. }
  28. else
  29. {
  30. myFile.SHA7_end = _tempSHA7_end_whitIDFile;
  31. }
  32. }
  33. else
  34. {
  35. myFile.SHA7_end = _tempSHA7_end_whitCDC;
  36. }
  37. }
  38. else
  39. {
  40. myFile.SHA7_end = mySave.FileSHA7_whitMD5(myFile.MD5, myFile.IDFile, myFile.MTaccept);
  41. }
  42. #endregion
  43.  
  44. using (SqlCommand command = new SqlCommand())
  45. {
  46. //command.CommandText = "TimeouttNotice";
  47. //command.CommandType = CommandType.StoredProcedure;
  48. command.CommandText = "INSERT INTO tbltNotice_tracking (IDtNotice, tNoticeStatus, StatusDescription,MT,IDUser) VALUES (@IDtNotice, 1000, 'Consegnata al destinatario',@MT,@IDOwner)";
  49. command.Parameters.AddWithValue("@CDC", CDC);
  50. command.Parameters.AddWithValue("@IDtNotice", IDtNotice.ToString());
  51. command.Parameters.AddWithValue("@IDOwner", IDOwner);
  52. command.Parameters.AddWithValue("@SHA7_start", myFile.SHA7_start);
  53. command.Parameters.AddWithValue("@SHA7_end", myFile.SHA7_end);
  54. command.Parameters.AddWithValue("@MT", DateTime.Now);
  55.  
  56. int resA = ExecuteSQL(command, "web");
  57.  
  58. command.CommandText = "UPDATE tbltNotice SET SHA7_start = @SHA7_start, SHA7_end = @SHA7_end WHERE IDtNotice=@IDtNotice";
  59.  
  60. int resB = ExecuteSQL(command, "web");
  61.  
  62. if (resA != 0 && resB != 0)
  63. {
  64. string IDFile_CPF_pdf = Guid.NewGuid().ToString();
  65. string IDFile_CPF_xml = Guid.NewGuid().ToString();
  66.  
  67. #region Coda CPF
  68. /// <summary>
  69. /// Collegamento all'host che ospita la coda
  70. /// </summary>
  71. /// <value>
  72. ///
  73. string RabbitMQ_queue = getProperty("RabbitMQ_tNotice_CPFeasy");
  74. if (Properties.Settings.Default.TEST == true)
  75. {
  76. RabbitMQ_queue += "_TEST";
  77. }
  78. ConnectionFactory factory = new ConnectionFactory();
  79. factory.UserName = getProperty("RabbitMQ_Username");
  80. factory.Password = getProperty("RabbitMQ_Password");
  81. factory.VirtualHost = getProperty("RabbitMQ_Vhost");
  82. if (Properties.Settings.Default.Deploy == "IT")
  83. {
  84. factory.HostName = getProperty("RabbitMQ_Hostname");
  85. }
  86. else
  87. {
  88. factory.HostName = getProperty(Properties.Settings.Default.Deploy + "_RabbitMQ_Hostname");
  89. }
  90. factory.Port = AmqpTcpEndpoint.UseDefaultPort;
  91. using (IConnection conn = factory.CreateConnection())
  92. {
  93. using (var channel = conn.CreateModel())
  94. {
  95. ///<summary>
  96. ///Dichiarazione coda da cui attingere
  97. ///</summary>
  98. channel.QueueDeclare(queue: RabbitMQ_queue,
  99. durable: true,
  100. exclusive: false,
  101. autoDelete: false,
  102. arguments: null);
  103.  
  104. //Passo in coda l'ID della tNotice dalla quale generare il CPF
  105. //separato da ";" l'ID del file PDF del CPF e a seguire l'ID del file XML del CPF
  106. var body = System.Text.Encoding.UTF8.GetBytes(IDtNotice.ToString() + ";" + IDFile_CPF_pdf + ";" + IDFile_CPF_xml);
  107. IBasicProperties props = channel.CreateBasicProperties();
  108. props.DeliveryMode = 2;
  109.  
  110. ///<summary>
  111. ///Impostazione Quality of Service
  112. ///</summary>
  113. ///<param>prefetchh</param>
  114. channel.BasicPublish(exchange: "",
  115. routingKey: RabbitMQ_queue,
  116. basicProperties: props,
  117. body: body);
  118.  
  119. channel.Close(200, "Goodbye");
  120. conn.Close();
  121. conn.Dispose();
  122. }
  123. }
  124. #endregion
  125.  
  126. return true;
  127. }
  128. else
  129. {
  130. return false;
  131. }
  132. }
  133. }
  134. catch (Exception ex)
  135. {
  136. catchError(ex, "tNotice.CreateDELIVERY.setTimeOut_tNotice");
  137. return false;
  138. }
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement