Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public bool setDelivery_tNotice(long IDtNotice, string Barcode, string CDC, string IDOwner)
- {
- /* PARAMETRI DI INPUT
- * @Barcode
- * @CDC
- * @IDOwner
- */
- try
- {
- inPoste.Tools.file_tNotice myFile = new inPoste.Tools.file_tNotice();
- myFile = getFiletNotice(Barcode, inPoste.Tools.TypeAssociated.tNotice);
- #region Genero MD5_end e SHA7_end
- //Variabili locali
- inPoste.SaveFile mySave = new inPoste.SaveFile();
- if (myFile.SHA256.Length > 0)
- {
- string _tempSHA7_end_whitCDC = mySave.FileSHA7_whitSHA256(myFile.SHA256, myFile.CDC, myFile.MTaccept);
- string _tempSHA7_end_whitIDFile = mySave.FileSHA7_whitSHA256(myFile.SHA256, myFile.IDFile, myFile.MTaccept);
- if (_tempSHA7_end_whitCDC != myFile.SHA7_start)
- {
- if (_tempSHA7_end_whitIDFile != myFile.SHA7_start)
- {
- myFile.SHA7_end = _tempSHA7_end_whitCDC;
- }
- else
- {
- myFile.SHA7_end = _tempSHA7_end_whitIDFile;
- }
- }
- else
- {
- myFile.SHA7_end = _tempSHA7_end_whitCDC;
- }
- }
- else
- {
- myFile.SHA7_end = mySave.FileSHA7_whitMD5(myFile.MD5, myFile.IDFile, myFile.MTaccept);
- }
- #endregion
- using (SqlCommand command = new SqlCommand())
- {
- //command.CommandText = "TimeouttNotice";
- //command.CommandType = CommandType.StoredProcedure;
- command.CommandText = "INSERT INTO tbltNotice_tracking (IDtNotice, tNoticeStatus, StatusDescription,MT,IDUser) VALUES (@IDtNotice, 1000, 'Consegnata al destinatario',@MT,@IDOwner)";
- command.Parameters.AddWithValue("@CDC", CDC);
- command.Parameters.AddWithValue("@IDtNotice", IDtNotice.ToString());
- command.Parameters.AddWithValue("@IDOwner", IDOwner);
- command.Parameters.AddWithValue("@SHA7_start", myFile.SHA7_start);
- command.Parameters.AddWithValue("@SHA7_end", myFile.SHA7_end);
- command.Parameters.AddWithValue("@MT", DateTime.Now);
- int resA = ExecuteSQL(command, "web");
- command.CommandText = "UPDATE tbltNotice SET SHA7_start = @SHA7_start, SHA7_end = @SHA7_end WHERE IDtNotice=@IDtNotice";
- int resB = ExecuteSQL(command, "web");
- if (resA != 0 && resB != 0)
- {
- string IDFile_CPF_pdf = Guid.NewGuid().ToString();
- string IDFile_CPF_xml = Guid.NewGuid().ToString();
- #region Coda CPF
- /// <summary>
- /// Collegamento all'host che ospita la coda
- /// </summary>
- /// <value>
- ///
- string RabbitMQ_queue = getProperty("RabbitMQ_tNotice_CPFeasy");
- if (Properties.Settings.Default.TEST == true)
- {
- RabbitMQ_queue += "_TEST";
- }
- ConnectionFactory factory = new ConnectionFactory();
- factory.UserName = getProperty("RabbitMQ_Username");
- factory.Password = getProperty("RabbitMQ_Password");
- factory.VirtualHost = getProperty("RabbitMQ_Vhost");
- if (Properties.Settings.Default.Deploy == "IT")
- {
- factory.HostName = getProperty("RabbitMQ_Hostname");
- }
- else
- {
- factory.HostName = getProperty(Properties.Settings.Default.Deploy + "_RabbitMQ_Hostname");
- }
- factory.Port = AmqpTcpEndpoint.UseDefaultPort;
- using (IConnection conn = factory.CreateConnection())
- {
- using (var channel = conn.CreateModel())
- {
- ///<summary>
- ///Dichiarazione coda da cui attingere
- ///</summary>
- channel.QueueDeclare(queue: RabbitMQ_queue,
- durable: true,
- exclusive: false,
- autoDelete: false,
- arguments: null);
- //Passo in coda l'ID della tNotice dalla quale generare il CPF
- //separato da ";" l'ID del file PDF del CPF e a seguire l'ID del file XML del CPF
- var body = System.Text.Encoding.UTF8.GetBytes(IDtNotice.ToString() + ";" + IDFile_CPF_pdf + ";" + IDFile_CPF_xml);
- IBasicProperties props = channel.CreateBasicProperties();
- props.DeliveryMode = 2;
- ///<summary>
- ///Impostazione Quality of Service
- ///</summary>
- ///<param>prefetchh</param>
- channel.BasicPublish(exchange: "",
- routingKey: RabbitMQ_queue,
- basicProperties: props,
- body: body);
- channel.Close(200, "Goodbye");
- conn.Close();
- conn.Dispose();
- }
- }
- #endregion
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- catch (Exception ex)
- {
- catchError(ex, "tNotice.CreateDELIVERY.setTimeOut_tNotice");
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement