|
@@ -16,6 +16,11 @@ namespace RedmineOracle
|
|
|
DbProviderFactory factory;
|
|
|
DbConnection connection;
|
|
|
|
|
|
+ public struct StatusInfo
|
|
|
+ {
|
|
|
+ public string idStatus { get; set; }
|
|
|
+ public string statusName { get; set; }
|
|
|
+ }
|
|
|
public struct FileInfo
|
|
|
{
|
|
|
public string id { get; set; }
|
|
@@ -56,6 +61,7 @@ namespace RedmineOracle
|
|
|
public OracleNumber TimeWorke { get; set; }
|
|
|
public string Respond { get; set; }
|
|
|
public string FullInf { get; set; }
|
|
|
+ public string CountFileLRP { get; set; }
|
|
|
}
|
|
|
OracleConnection oracleConnection;
|
|
|
public OracleWork()
|
|
@@ -72,6 +78,62 @@ namespace RedmineOracle
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public void updateStatus(string idLrp,string currSt,string newSt,string idSt)
|
|
|
+ {
|
|
|
+ if (oracleConnection.State != ConnectionState.Open)
|
|
|
+ oracleConnection.Open();
|
|
|
+ string updStatus = "update fault_data set lrp_status_id =" + idSt + " where lrp_id = " + idLrp;
|
|
|
+ OracleCommand upd = new OracleCommand(updStatus, oracleConnection);
|
|
|
+ upd.ExecuteNonQuery();
|
|
|
+ oracleConnection.Close();
|
|
|
+ string comm = "Изменение `Статус`: `" + currSt + "`->`" + newSt + "`";
|
|
|
+ insertComm(Convert.ToInt32(idLrp),"",comm);
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<StatusInfo> getAllStatus(string currSt)
|
|
|
+ {
|
|
|
+ List<StatusInfo> allSt = new List<StatusInfo>();
|
|
|
+
|
|
|
+ string findCurrSt = "Select lrp_status_id,lrp_status_name from lrp_status where lrp_status_name like '" + currSt + "'";
|
|
|
+
|
|
|
+
|
|
|
+ string findAllS = "Select lrp_status_id,lrp_status_name from lrp_status where lrp_status_name not like '%Test%' and lrp_status_name not like '" + currSt + "'";
|
|
|
+ if (oracleConnection.State != ConnectionState.Open)
|
|
|
+ oracleConnection.Open();
|
|
|
+ OracleCommand cmdCurrS = new OracleCommand(findCurrSt, oracleConnection);
|
|
|
+
|
|
|
+ OracleDataReader rearCurr = cmdCurrS.ExecuteReader();
|
|
|
+ while (rearCurr.Read())
|
|
|
+ {
|
|
|
+ StatusInfo si = new StatusInfo();
|
|
|
+ si.idStatus = rearCurr[0].ToString();
|
|
|
+ si.statusName = rearCurr[1].ToString();
|
|
|
+ allSt.Add(si);
|
|
|
+ }
|
|
|
+ OracleCommand oracleCommand = new OracleCommand(findAllS, oracleConnection);
|
|
|
+
|
|
|
+ OracleDataReader reader;
|
|
|
+ if (oracleConnection.State != ConnectionState.Open)
|
|
|
+ {
|
|
|
+ oracleConnection.Open();
|
|
|
+ reader = oracleCommand.ExecuteReader();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ reader = oracleCommand.ExecuteReader();
|
|
|
+ }
|
|
|
+ while (reader.Read())
|
|
|
+ {
|
|
|
+ StatusInfo si = new StatusInfo();
|
|
|
+ si.idStatus = reader[0].ToString();
|
|
|
+ si.statusName = reader[1].ToString();
|
|
|
+ allSt.Add(si);
|
|
|
+ }
|
|
|
+ reader.Close();
|
|
|
+ oracleConnection.Close();
|
|
|
+ return allSt;
|
|
|
+ }
|
|
|
+
|
|
|
public string FindRmIssue(string idLRP)
|
|
|
{
|
|
|
string iss = "Н/З";
|
|
@@ -93,6 +155,7 @@ namespace RedmineOracle
|
|
|
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;
|
|
@@ -105,6 +168,8 @@ namespace RedmineOracle
|
|
|
oracleConnection.Open();
|
|
|
string commDon = "select Max(lrp_id) from fault_data where lrp_status_id in(1)";
|
|
|
OracleCommand cmd = new OracleCommand(commDon, oracleConnection);
|
|
|
+ if (oracleConnection.State != ConnectionState.Open)
|
|
|
+ oracleConnection.Open();
|
|
|
max = Convert.ToInt32(cmd.ExecuteScalar());
|
|
|
oracleConnection.Close();
|
|
|
return max;
|
|
@@ -117,6 +182,8 @@ namespace RedmineOracle
|
|
|
oracleConnection.Open();
|
|
|
string commDon = "select Count(lrp_id) from fault_data where lrp_status_id in(1)";
|
|
|
OracleCommand cmd = new OracleCommand(commDon, oracleConnection);
|
|
|
+ if (oracleConnection.State == ConnectionState.Closed)
|
|
|
+ oracleConnection.Open();
|
|
|
count = Convert.ToInt32(cmd.ExecuteScalar());
|
|
|
oracleConnection.Close();
|
|
|
return count;
|
|
@@ -146,6 +213,30 @@ namespace RedmineOracle
|
|
|
return fi;
|
|
|
}
|
|
|
|
|
|
+ public List<FileInfo> listFileLRP(string id_lrp)
|
|
|
+ {
|
|
|
+ List<FileInfo> fi = new List<FileInfo>();
|
|
|
+ if (oracleConnection.State != ConnectionState.Open)
|
|
|
+ oracleConnection.Open();
|
|
|
+ string commDon = "select LRP_ID,LRP_BLOB,LRP_INF, TYPE_FILE from lrp_file where lrp_id =" + id_lrp;
|
|
|
+ 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)
|
|
@@ -163,12 +254,29 @@ namespace RedmineOracle
|
|
|
oracleConnection.Close();
|
|
|
}
|
|
|
|
|
|
+ public void DonLRPFIle(string id, string id_file)
|
|
|
+ {
|
|
|
+ if (oracleConnection.State != ConnectionState.Open)
|
|
|
+ oracleConnection.Open();
|
|
|
+ FileInfo fileInfo = listFileLRP(id).FirstOrDefault(x => x.id == id_file);
|
|
|
+ string commDon = "select LRP_BLOB from LRP_FILE where lrp_id =" + id + " and lrp_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();
|
|
|
+ if (oracleConnection.State != ConnectionState.Open)
|
|
|
+ oracleConnection.Open();
|
|
|
OracleCommand comd = new OracleCommand(commUsers, oracleConnection);
|
|
|
OracleDataReader reader = comd.ExecuteReader();
|
|
|
while (reader.Read())
|
|
@@ -246,19 +354,37 @@ namespace RedmineOracle
|
|
|
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++)
|
|
|
|
|
|
+ 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, " +
|
|
|
+ string commandCount = "Select Count(drp_change) from lrp_drp where lrp_id = " + dt1.Rows[i].ItemArray[0].ToString();
|
|
|
+ OracleCommand command2 = new OracleCommand(commandCount, oracleConnection);
|
|
|
+ command1.CommandText = "";
|
|
|
+ if (oracleConnection.State != ConnectionState.Open)
|
|
|
+ oracleConnection.Open();
|
|
|
+ if (Convert.ToInt32(command2.ExecuteScalar()) > 0)
|
|
|
+ {
|
|
|
+ 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) " +
|
|
|
+ "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_change = (select MAX(t.time_change) " +
|
|
|
"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";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ 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, " +
|
|
|
+ "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, 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 = " +
|
|
|
+ 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
|
|
|
{
|
|
@@ -397,11 +523,13 @@ namespace RedmineOracle
|
|
|
public InfoLrp CurrentLRP(int id)
|
|
|
{
|
|
|
InfoLrp currLRP = new InfoLrp();
|
|
|
- string commCurr = "select ft.lrp_id,ft.lrp_prioritet_id,ft.lrp_mini_inf,lsl.system_name,ls.lrp_status_name,ft.lrp_time_open, ft.Time_Worke,t.time_create,t.drp_change,u.Lastname,u.Firstname,u.Secondname,us.Lastname,us.Firstname,us.Secondname,ft.lrp_inf " +
|
|
|
- "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 =" + id + ") and ft.lrp_id =" + id + "" +
|
|
|
+ string commCurr = commCurr = "select ft.lrp_id,ft.lrp_prioritet_id,ft.lrp_mini_inf,lsl.system_name,ls.lrp_status_name,ft.lrp_time_open, ft.Time_Worke,u.Lastname,u.Firstname,u.Secondname,us.Lastname,us.Firstname,us.Secondname,ft.lrp_inf " +
|
|
|
+ "from fault_data ft, lrp_system_list lsl,lrp_status ls,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 =" + id + "" +
|
|
|
" and ft.lrp_opener = u.user_id and ft.lrp_respondent_id = us.user_id";
|
|
|
- oracleConnection.Open();
|
|
|
+ if (oracleConnection.State != ConnectionState.Open)
|
|
|
+ oracleConnection.Open();
|
|
|
+ //oracleConnection.Open();
|
|
|
OracleCommand comd = new OracleCommand(commCurr, oracleConnection);
|
|
|
OracleDataReader reader = comd.ExecuteReader();
|
|
|
while (reader.Read())
|
|
@@ -413,11 +541,12 @@ namespace RedmineOracle
|
|
|
currLRP.Status = reader[4].ToString();
|
|
|
currLRP.TimeStart = Convert.ToDateTime(reader[5].ToString());
|
|
|
currLRP.TimeWorke = reader.GetOracleNumber(6);
|
|
|
- currLRP.LastCommentDate = Convert.ToDateTime(reader[7].ToString());
|
|
|
- currLRP.LastComment = reader[8].ToString();
|
|
|
- currLRP.LRPAuthor = reader[9].ToString() + " " + reader[10].ToString() + " " + reader[11].ToString();
|
|
|
- currLRP.Respond = reader[12].ToString() + " " + reader[13].ToString() + " " + reader[14].ToString();
|
|
|
- currLRP.FullInf = reader[15].ToString();
|
|
|
+ currLRP.LRPAuthor = reader[7].ToString() + " " + reader[8].ToString() + " " + reader[9].ToString();
|
|
|
+ currLRP.Respond = reader[10].ToString() + " " + reader[11].ToString() + " " + reader[12].ToString();
|
|
|
+ currLRP.FullInf = reader[13].ToString();
|
|
|
+ string findFileComm = "Select Count(*) from lrp_file where lrp_id = " + id.ToString();
|
|
|
+ OracleCommand findCount = new OracleCommand(findFileComm, oracleConnection);
|
|
|
+ currLRP.CountFileLRP = findCount.ExecuteScalar().ToString();
|
|
|
}
|
|
|
oracleConnection.Close();
|
|
|
return currLRP;
|
|
@@ -449,11 +578,28 @@ namespace RedmineOracle
|
|
|
return lComm;
|
|
|
}
|
|
|
|
|
|
- public void insertComm(int id_lrp, string comm_s)
|
|
|
+ public string InserCommToRB(int idDRP)
|
|
|
+ {
|
|
|
+ string comm = "";
|
|
|
+ if (oracleConnection.State != ConnectionState.Open)
|
|
|
+ oracleConnection.Open();
|
|
|
+ string commComment = "Select DRP_AVTOR,DRP_CHANGE,SECRET_COMMENTS from lrp_drp where drp_id =" + idDRP;
|
|
|
+ OracleCommand comd = new OracleCommand(commComment, oracleConnection);
|
|
|
+ OracleDataReader reader = comd.ExecuteReader();
|
|
|
+ while (reader.Read())
|
|
|
+ {
|
|
|
+ comm = "Автор " + reader[0].ToString() + "\n" + "Комментарий " + reader[1].ToString();
|
|
|
+ }
|
|
|
+ reader.Close();
|
|
|
+ oracleConnection.Close();
|
|
|
+ return comm;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void insertComm(int id_lrp, string comm_s, string comm)
|
|
|
{
|
|
|
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 + "')";
|
|
|
+ string insertComm = "insert into lrp_drp t (t.drp_id, t.lrp_id, t.drp_avtor, t.secret_comments,drp_change,time_change) " +
|
|
|
+ "values((select max(drp_id) + 1 from lrp_drp), " + id_lrp + ", '" + infoAuth.loginForum + "', '" + comm_s + "','" + comm + "',to_date('" + DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss") + "','dd.mm.yyyy HH24:mi:ss'))";
|
|
|
OracleCommand comd = new OracleCommand(insertComm, oracleConnection);
|
|
|
comd.ExecuteNonQuery();
|
|
|
oracleConnection.Close();
|