|
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|
|
using System.Data;
|
|
|
using System.Data.Common;
|
|
|
using System.Data.OracleClient;
|
|
|
+using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
@@ -14,6 +15,22 @@ namespace RedmineOracle
|
|
|
{
|
|
|
DbProviderFactory factory;
|
|
|
DbConnection connection;
|
|
|
+
|
|
|
+ public struct FileInfo
|
|
|
+ {
|
|
|
+ public string id { get; set; }
|
|
|
+ public string id_drp { get; set; }
|
|
|
+ public string Name { get; set; }
|
|
|
+ public string Type { get; set; }
|
|
|
+ }
|
|
|
+ public struct Users
|
|
|
+ {
|
|
|
+ public int Id { get; set; }
|
|
|
+ public string SystemName { get; set; }
|
|
|
+ public string Name { get; set; }
|
|
|
+ public string SecondName { get; set; }
|
|
|
+ public string LastName { get; set; }
|
|
|
+ }
|
|
|
public struct Comments
|
|
|
{
|
|
|
public string Name { get; set; }
|
|
@@ -21,6 +38,8 @@ namespace RedmineOracle
|
|
|
public DateTime Created { get; set; }
|
|
|
public string Change { get; set; }
|
|
|
public string SecreteComm { get; set; }
|
|
|
+ public string IdDRP { get; set; }
|
|
|
+ public string CountFile { get; set; }
|
|
|
}
|
|
|
|
|
|
public struct InfoLrp
|
|
@@ -45,7 +64,7 @@ namespace RedmineOracle
|
|
|
factory = DbProviderFactories.GetFactory("System.Data.OracleClient");
|
|
|
connection = factory.CreateConnection();
|
|
|
connection.ConnectionString = "Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.111.197)(PORT = 1521))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = NIS)));Password=dtrnjh340;User ID=ais_disp2";
|
|
|
-
|
|
|
+
|
|
|
oracleConnection = new OracleConnection();
|
|
|
oracleConnection.ConnectionString = "Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = "
|
|
|
+ "192.168.111.197" + ")(PORT = " + "1521" + "))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = "
|
|
@@ -53,25 +72,217 @@ namespace RedmineOracle
|
|
|
}
|
|
|
|
|
|
|
|
|
- public int chechAuth(string login, string pass)
|
|
|
+ public string FindRmIssue(string idLRP)
|
|
|
+ {
|
|
|
+ string iss = "Н/З";
|
|
|
+ if (oracleConnection.State != ConnectionState.Open)
|
|
|
+ oracleConnection.Open();
|
|
|
+ string commDon = "select secret_comments from lrp_drp where secret_comments like '%http://testred.ru/issues/%' and lrp_id=" + idLRP;
|
|
|
+ OracleCommand cmd = new OracleCommand(commDon, oracleConnection);
|
|
|
+ if (cmd.ExecuteScalar() != null)
|
|
|
+ iss = cmd.ExecuteScalar().ToString();
|
|
|
+ oracleConnection.Close();
|
|
|
+ iss = iss.Replace("http://testred.ru/issues/", "");
|
|
|
+ return iss;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int CheckMaxDrp()
|
|
|
+ {
|
|
|
+ int max;
|
|
|
+ if (oracleConnection.State != ConnectionState.Open)
|
|
|
+ oracleConnection.Open();
|
|
|
+ string commDon = "select Max(drp_id) from lrp_drp";
|
|
|
+ OracleCommand cmd = new OracleCommand(commDon, oracleConnection);
|
|
|
+ max = Convert.ToInt32(cmd.ExecuteScalar());
|
|
|
+ oracleConnection.Close();
|
|
|
+ return max;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int CheckMaxOpen()
|
|
|
+ {
|
|
|
+ int max;
|
|
|
+ if (oracleConnection.State != ConnectionState.Open)
|
|
|
+ oracleConnection.Open();
|
|
|
+ string commDon = "select Max(lrp_id) from fault_data where lrp_status_id in(1)";
|
|
|
+ OracleCommand cmd = new OracleCommand(commDon, oracleConnection);
|
|
|
+ max = Convert.ToInt32(cmd.ExecuteScalar());
|
|
|
+ oracleConnection.Close();
|
|
|
+ return max;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int CheckCountOpen()
|
|
|
+ {
|
|
|
+ int count;
|
|
|
+ if (oracleConnection.State == ConnectionState.Closed)
|
|
|
+ oracleConnection.Open();
|
|
|
+ string commDon = "select Count(lrp_id) from fault_data where lrp_status_id in(1)";
|
|
|
+ OracleCommand cmd = new OracleCommand(commDon, oracleConnection);
|
|
|
+ count = Convert.ToInt32(cmd.ExecuteScalar());
|
|
|
+ oracleConnection.Close();
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<FileInfo> listFile(string id_drp)
|
|
|
+ {
|
|
|
+ List<FileInfo> fi = new List<FileInfo>();
|
|
|
+ if (oracleConnection.State != ConnectionState.Open)
|
|
|
+ oracleConnection.Open();
|
|
|
+ string commDon = "select DPR_ID,DRP_BLOB,INF, TYPE_FILE from DRP_FILE where dpr_id =" + id_drp;
|
|
|
+ OracleCommand cmd = new OracleCommand(commDon, oracleConnection);
|
|
|
+ OracleDataReader reader = cmd.ExecuteReader();
|
|
|
+ int i = 0;
|
|
|
+ while (reader.Read())
|
|
|
+ {
|
|
|
+ FileInfo f = new FileInfo();
|
|
|
+ f.id_drp = reader[0].ToString();
|
|
|
+ f.Name = reader[2].ToString();
|
|
|
+ f.Type = reader[3].ToString();
|
|
|
+ f.id = i.ToString();
|
|
|
+ i++;
|
|
|
+ fi.Add(f);
|
|
|
+ }
|
|
|
+ reader.Close();
|
|
|
+ oracleConnection.Close();
|
|
|
+ return fi;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void TestDonD(string id, string id_file)
|
|
|
+ {
|
|
|
+ if (oracleConnection.State != ConnectionState.Open)
|
|
|
+ oracleConnection.Open();
|
|
|
+ FileInfo fileInfo = listFile(id).FirstOrDefault(x => x.id == id_file);
|
|
|
+ string commDon = "select DRP_BLOB from DRP_FILE where dpr_id =" + id + " and inf =" + "'" + fileInfo.Name + "'";
|
|
|
+ OracleCommand cmd = new OracleCommand(commDon, oracleConnection);
|
|
|
+ if (oracleConnection.State != ConnectionState.Open)
|
|
|
+ oracleConnection.Open();
|
|
|
+ byte[] buffer = (byte[])cmd.ExecuteScalar();
|
|
|
+ using (FileStream fs = new FileStream(@"D:\" + fileInfo.Name + "." + fileInfo.Type, FileMode.Create))
|
|
|
+ {
|
|
|
+ fs.Write(buffer, 0, buffer.Length);
|
|
|
+ }
|
|
|
+ oracleConnection.Close();
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<Users> listUsers()
|
|
|
+ {
|
|
|
+ List<Users> users = new List<Users>();
|
|
|
+ string commUsers = "Select t.Firstname ||' '|| t.Secondname ||' '|| t.Lastname as Respond,t.Login,t.USER_ID from spd.T_USERS t ";
|
|
|
+ if (oracleConnection.State != ConnectionState.Open) ;
|
|
|
+ oracleConnection.Open();
|
|
|
+ OracleCommand comd = new OracleCommand(commUsers, oracleConnection);
|
|
|
+ OracleDataReader reader = comd.ExecuteReader();
|
|
|
+ while (reader.Read())
|
|
|
+ {
|
|
|
+ Users user = new Users();
|
|
|
+ if (reader[0].ToString() != "")
|
|
|
+ user.Name = reader.GetString(0);
|
|
|
+ if (reader[1].ToString() != "")
|
|
|
+ user.SystemName = reader.GetString(1);
|
|
|
+ if (reader[2].ToString() != "")
|
|
|
+ user.Id = reader.GetInt32(2);
|
|
|
+ users.Add(user);
|
|
|
+ }
|
|
|
+ oracleConnection.Close();
|
|
|
+ return users;
|
|
|
+ }
|
|
|
+
|
|
|
+ public async Task<int> chechAuth(string login, string pass)
|
|
|
+ {
|
|
|
+ int result = -1;
|
|
|
+ await Task.Run(() =>
|
|
|
+ {
|
|
|
+ string commandFindUser = "select t.* from spd.T_USERS t where t.pass='" + pass + "' and t.login ='" + login + "'";
|
|
|
+ oracleConnection.Open();
|
|
|
+ OracleCommand comd = new OracleCommand(commandFindUser, oracleConnection);
|
|
|
+ OracleDataReader reader = comd.ExecuteReader();
|
|
|
+
|
|
|
+ if (reader.HasRows)
|
|
|
+ result = 1;
|
|
|
+ else
|
|
|
+ result = -1;
|
|
|
+ oracleConnection.Close();
|
|
|
+
|
|
|
+ });
|
|
|
+ return result;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public int findLRP(string id)
|
|
|
{
|
|
|
- string commandFindUser = "select t.* from spd.T_USERS t where t.pass='" + pass + "' and t.login ='" + login+"'";
|
|
|
+ string commandFindLRP = "select t.* from fault_data t where t.lrp_id =" + id.ToString();
|
|
|
oracleConnection.Open();
|
|
|
- OracleCommand comd = new OracleCommand(commandFindUser, oracleConnection);
|
|
|
+ OracleCommand comd = new OracleCommand(commandFindLRP, oracleConnection);
|
|
|
OracleDataReader reader = comd.ExecuteReader();
|
|
|
+ int result;
|
|
|
if (reader.HasRows)
|
|
|
- return 1;
|
|
|
- else
|
|
|
- return -1;
|
|
|
+ result = 1;
|
|
|
+ else
|
|
|
+ result = -1;
|
|
|
+ oracleConnection.Close();
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
- public DataTable dtLrp()
|
|
|
+
|
|
|
+ public DataTable outputOpen()
|
|
|
{
|
|
|
connection.Open();
|
|
|
DbCommand command = factory.CreateCommand(); //create a new command
|
|
|
DbCommand command1 = factory.CreateCommand(); //create a new command
|
|
|
- DataTable dt ;
|
|
|
- command.CommandText = "select ft.lrp_id from fault_data ft where lrp_status_id not in(3, 7) order by lrp_status_id";
|
|
|
+ DataTable dt;
|
|
|
+ command.CommandText = "select ft.lrp_id from fault_data ft where lrp_status_id in(1) order by lrp_time_open desc";
|
|
|
+ command.Connection = connection; //connect the command
|
|
|
+ DbDataAdapter adapter = factory.CreateDataAdapter();//create new adapter
|
|
|
+ adapter.SelectCommand = command;
|
|
|
+ DataTable dt1;
|
|
|
+ DataSet ds = new DataSet(); //create a new dataset
|
|
|
+ try
|
|
|
+ {
|
|
|
+ adapter.Fill(ds, command.CommandText);
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ MessageBox.Show(e.Message);
|
|
|
+ }
|
|
|
+ dt1 = ds.Tables[0];
|
|
|
+ command1.Connection = connection; //connect the command
|
|
|
+ DataSet secds = new DataSet(); //create a new dataset
|
|
|
+ for (int i = 0; i < dt1.Rows.Count; i++)
|
|
|
+
|
|
|
+ {
|
|
|
+ DbDataAdapter adapter1 = factory.CreateDataAdapter();//create new adapter
|
|
|
+ command1.CommandText = "select ft.lrp_id ,ft.lrp_prioritet_id,ft.lrp_mini_inf,lsl.system_name,ls.lrp_status_name,ft.lrp_time_open, t.time_change,t.drp_change, " +
|
|
|
+ "u.Lastname || ' ' || u.Firstname || ' ' || u.Secondname as drp_creator, us.Lastname || ' ' || us.Firstname || ' ' || us.Secondname as respond " +
|
|
|
+ "from fault_data ft, lrp_system_list lsl, lrp_status ls,lrp_drp t, spd.T_Users u, spd.T_Users us " +
|
|
|
+ "where ft.System_Id = lsl.system_id and ft.lrp_status_id = ls.lrp_status_id and ft.lrp_id = t.lrp_id and t.time_create = (select MAX(t.time_create) " +
|
|
|
+ "from lrp_drp t where t.lrp_id = " +
|
|
|
+ dt1.Rows[i].ItemArray[0].ToString() +
|
|
|
+ ") and ft.lrp_id =" +
|
|
|
+ dt1.Rows[i].ItemArray[0].ToString() +
|
|
|
+ "and ft.lrp_opener = u.user_id and ft.lrp_respondent_id = us.user_id";
|
|
|
+ adapter1.SelectCommand = command1;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ adapter1.Fill(secds);
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ MessageBox.Show(e.Message);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ dt = secds.Tables[0]; //copy the table from the dataset to the dataTable
|
|
|
+ connection.Close();
|
|
|
+ //dt.DefaultView.Sort = "time_change desc";
|
|
|
+ return dt;
|
|
|
+ }
|
|
|
+ public DataTable dtLrp()
|
|
|
+ {
|
|
|
+ if (connection.State != ConnectionState.Open)
|
|
|
+ connection.Open();
|
|
|
+ DbCommand command = factory.CreateCommand(); //create a new command
|
|
|
+ DbCommand command1 = factory.CreateCommand(); //create a new command
|
|
|
+ DataTable dt;
|
|
|
+ command.CommandText = "select ft.lrp_id from fault_data ft where lrp_status_id not in(1,3,7)";
|
|
|
command.Connection = connection; //connect the command
|
|
|
DbDataAdapter adapter = factory.CreateDataAdapter();//create new adapter
|
|
|
adapter.SelectCommand = command;
|
|
@@ -102,7 +313,7 @@ namespace RedmineOracle
|
|
|
dt1.Rows[i].ItemArray[0].ToString() +
|
|
|
") and ft.lrp_id =" +
|
|
|
dt1.Rows[i].ItemArray[0].ToString() +
|
|
|
- "and ft.lrp_opener = u.user_id and ft.lrp_respondent_id = us.user_id";
|
|
|
+ "and ft.lrp_opener = u.user_id and ft.lrp_respondent_id = us.user_id";
|
|
|
adapter1.SelectCommand = command1;
|
|
|
try
|
|
|
{
|
|
@@ -116,9 +327,73 @@ namespace RedmineOracle
|
|
|
}
|
|
|
dt = secds.Tables[0]; //copy the table from the dataset to the dataTable
|
|
|
connection.Close();
|
|
|
+ dt.DefaultView.Sort = "time_change desc";
|
|
|
+ dt = dt.DefaultView.ToTable();
|
|
|
return dt;
|
|
|
}
|
|
|
|
|
|
+ public DataTable findRespondLRP(string idUser)
|
|
|
+ {
|
|
|
+ connection.Open();
|
|
|
+ DbCommand command = factory.CreateCommand(); //create a new command
|
|
|
+ DbCommand command1 = factory.CreateCommand(); //create a new command
|
|
|
+ DataTable dt;
|
|
|
+ command.CommandText = "select ft.lrp_id from fault_data ft where lrp_status_id not in(1,3,7) and LRP_RESPONDENT_ID=" + idUser;
|
|
|
+ command.Connection = connection; //connect the command
|
|
|
+ DbDataAdapter adapter = factory.CreateDataAdapter();//create new adapter
|
|
|
+ adapter.SelectCommand = command;
|
|
|
+ DataTable dt1;
|
|
|
+ DataSet ds = new DataSet(); //create a new dataset
|
|
|
+ try
|
|
|
+ {
|
|
|
+ adapter.Fill(ds, command.CommandText);
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ MessageBox.Show(e.Message);
|
|
|
+ }
|
|
|
+ dt1 = ds.Tables[0];
|
|
|
+ command1.Connection = connection; //connect the command
|
|
|
+
|
|
|
+
|
|
|
+ DataSet secds = new DataSet(); //create a new dataset
|
|
|
+ for (int i = 0; i < dt1.Rows.Count; i++)
|
|
|
+
|
|
|
+ {
|
|
|
+ DbDataAdapter adapter1 = factory.CreateDataAdapter();//create new adapter
|
|
|
+ command1.CommandText = "select ft.lrp_id ,ft.lrp_prioritet_id,ft.lrp_mini_inf,lsl.system_name,ls.lrp_status_name,ft.lrp_time_open, t.time_change,t.drp_change, " +
|
|
|
+ "u.Lastname || ' ' || u.Firstname || ' ' || u.Secondname as drp_creator, us.Lastname || ' ' || us.Firstname || ' ' || us.Secondname as respond " +
|
|
|
+ "from fault_data ft, lrp_system_list lsl, lrp_status ls,lrp_drp t, spd.T_Users u, spd.T_Users us " +
|
|
|
+ "where ft.System_Id = lsl.system_id and ft.lrp_status_id = ls.lrp_status_id and ft.lrp_id = t.lrp_id and t.time_create = (select MAX(t.time_create) " +
|
|
|
+ "from lrp_drp t where t.lrp_id = " +
|
|
|
+ dt1.Rows[i].ItemArray[0].ToString() +
|
|
|
+ ") and ft.lrp_id =" +
|
|
|
+ dt1.Rows[i].ItemArray[0].ToString() +
|
|
|
+ "and ft.lrp_opener = u.user_id and ft.lrp_respondent_id = us.user_id";
|
|
|
+ adapter1.SelectCommand = command1;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ adapter1.Fill(secds);
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ MessageBox.Show(e.Message);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ try
|
|
|
+ {
|
|
|
+ dt = secds.Tables[0];
|
|
|
+ connection.Close();
|
|
|
+ dt.DefaultView.Sort = "time_change desc";
|
|
|
+ dt = dt.DefaultView.ToTable();
|
|
|
+ return dt;
|
|
|
+ }
|
|
|
+ catch { }
|
|
|
+ //copy the table from the dataset to the dataTable
|
|
|
+ return dtLrp();
|
|
|
+ }
|
|
|
+
|
|
|
public InfoLrp CurrentLRP(int id)
|
|
|
{
|
|
|
InfoLrp currLRP = new InfoLrp();
|
|
@@ -151,7 +426,7 @@ namespace RedmineOracle
|
|
|
public List<Comments> CreateListComm(int id)
|
|
|
{
|
|
|
List<Comments> lComm = new List<Comments>();
|
|
|
- string commComment = "select t.comments,t.time_create,t.drp_avtor, t.drp_change, t.secret_comments from lrp_drp t where t.lrp_id =" + id+" order by t.time_create desc";
|
|
|
+ string commComment = "select t.comments,t.time_create,t.drp_avtor, t.drp_change, t.secret_comments,t.drp_id from lrp_drp t where t.lrp_id =" + id + " order by t.time_create desc";
|
|
|
oracleConnection.Open();
|
|
|
OracleCommand comd = new OracleCommand(commComment, oracleConnection);
|
|
|
OracleDataReader reader = comd.ExecuteReader();
|
|
@@ -163,6 +438,10 @@ namespace RedmineOracle
|
|
|
cs.Name = reader[2].ToString();
|
|
|
cs.Change = reader[3].ToString();
|
|
|
cs.SecreteComm = reader[4].ToString();
|
|
|
+ cs.IdDRP = reader[5].ToString();
|
|
|
+ string FindC = "Select Count(*) from drp_file where dpr_id =" + reader[5].ToString();
|
|
|
+ OracleCommand cmFindCount = new OracleCommand(FindC, oracleConnection);
|
|
|
+ cs.CountFile = cmFindCount.ExecuteScalar().ToString();
|
|
|
lComm.Add(cs);
|
|
|
}
|
|
|
reader.Close();
|
|
@@ -174,12 +453,12 @@ namespace RedmineOracle
|
|
|
{
|
|
|
oracleConnection.Open();
|
|
|
string insertComm = "insert into lrp_drp t (t.drp_id, t.lrp_id, t.drp_avtor, t.secret_comments) " +
|
|
|
- "values((select max(drp_id) + 1 from lrp_drp), "+id_lrp+", '"+infoAuth.loginForum+"', '"+comm_s+"')";
|
|
|
+ "values((select max(drp_id) + 1 from lrp_drp), " + id_lrp + ", '" + infoAuth.loginForum + "', '" + comm_s + "')";
|
|
|
OracleCommand comd = new OracleCommand(insertComm, oracleConnection);
|
|
|
comd.ExecuteNonQuery();
|
|
|
oracleConnection.Close();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|