// reports.cpp : implementation file
//
#include "afxwin.h"
#include "stdafx.h"
#include "secall.h"
#include "SCMTool.h"
#include "reports.h"
#include "AllPages.h"
#include "Integrate.h"
#include "ConfCut.h"
#include <time.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Creports dialog
Creports::Creports(CWnd* pParent /*=NULL*/)
: CPropertyPage(Creports::IDD)
{
//{{AFX_DATA_INIT(Creports)
m_RepType = -1;
m_SearchSString_st = _T("");
m_SearchPString_st = _T("");
//}}AFX_DATA_INIT
}
void Creports::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Creports)
DDX_Control(pDX, ID_RESOLVE, m_Resolve);
DDX_Control(pDX, ID_REVERT, m_Revert);
DDX_Control(pDX, ID_CONFIRM, m_Confirm);
DDX_Control(pDX, ID_EDITCH, m_EditCh);
DDX_Control(pDX, ID_UNSYNCH, m_UnSync);
DDX_Control(pDX, ID_UNSUBMIT, m_UnSubmit);
DDX_Control(pDX, ID_SEARCHSTRINGS, m_SearchSString);
DDX_Control(pDX, ID_SEARCHSTRINGP, m_SearchPString);
DDX_Control(pDX, IDC_SELECTSTRINGS, m_CheckSsearch);
DDX_Control(pDX, IDC_SEARCHCONF, m_CheckConf);
DDX_Control(pDX, IDC_SELECTSTRINGP, m_CheckPsearch);
//DDX_Control(pDX, ID_REOPEN, m_Reopen);
DDX_Control(pDX, ID_DELCHLS, m_Delete);
DDX_Control(pDX, ID_SYNCH, m_Synch);
DDX_Control(pDX, ID_PRINT2, m_Print2);
DDX_Control(pDX, ID_PRINT1, m_Print);
DDX_Control(pDX, ID_DELARS, m_DelArs);
DDX_Control(pDX, ID_NOTPED2, m_Notepad2);
DDX_Control(pDX, IDC_OPTION, m_Option);
DDX_Control(pDX, IDC_CHECK4, m_Del);
DDX_Control(pDX, IDC_CHECK3, m_Add);
DDX_Control(pDX, IDC_CHECK2, m_Equal);
DDX_Control(pDX, IDC_CHECK1, m_Different);
DDX_Control(pDX, ID_BUTTON2, m_Button2);
DDX_Control(pDX, ID_BUTTON1, m_Button1);
DDX_Control(pDX, ID_EDITARS, m_EditArs);
DDX_Control(pDX, ID_RADIO1, m_Radio);
DDX_Control(pDX, ID_RADIO2, m_Radio2);
DDX_Control(pDX, IDC_CHECK, m_Check);
DDX_Control(pDX, ID_DATETO2, m_Dateto2);
DDX_Control(pDX, ID_LBGROUP, m_Lbgroup);
DDX_Control(pDX, ID_DATE2, m_Date2);
DDX_Control(pDX, ID_NOTPED, m_Notped);
DDX_Control(pDX, ID_PENDING, m_Pending);
DDX_Control(pDX, ID_SUBMITTED, m_Submit);
DDX_Control(pDX, ID_USER, m_Users);
DDX_Control(pDX, ID_BY, m_By);
DDX_Radio(pDX, ID_REPTYPE, m_RepType);
DDX_CBString(pDX, ID_SEARCHSTRINGS, m_SearchSString_st);
DDV_MaxChars(pDX, m_SearchSString_st, 25);
DDX_CBString(pDX, ID_SEARCHSTRINGP, m_SearchPString_st);
DDV_MaxChars(pDX, m_SearchPString_st, 25);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Creports, CPropertyPage)
//{{AFX_MSG_MAP(Creports)
ON_BN_CLICKED(ID_BUTTON1, OnButton1)
ON_BN_CLICKED(ID_BUTTON2, OnButton2)
ON_BN_CLICKED(ID_NOTPED, OnNotped)
ON_CBN_SELCHANGE(ID_BY, OnSelchangeBy)
ON_BN_CLICKED(IDC_CHECK, OnCheck)
ON_BN_CLICKED(ID_RADIO1, OnRadio1)
ON_BN_CLICKED(ID_RADIO2, OnRadio2)
ON_EN_KILLFOCUS(ID_DATE, OnKillfocusDate)
ON_EN_KILLFOCUS(ID_DATETO, OnKillfocusDateto)
ON_CBN_SELCHANGE(ID_DATE2, OnSelchangeDate2)
ON_BN_CLICKED(ID_NOTPED2, OnNotped2)
ON_BN_CLICKED(ID_DELARS, OnDelars)
ON_BN_CLICKED(ID_DELCHLS, OnDelchls)
ON_BN_CLICKED(ID_PRINT1, OnPrint1)
ON_BN_CLICKED(ID_PRINT2, OnPrint2)
ON_LBN_DBLCLK(ID_SUBMITTED, OnDblclkSubmitted)
ON_LBN_DBLCLK(ID_PENDING, OnDblclkPending)
ON_BN_CLICKED(ID_SYNCH, OnSynch)
ON_BN_CLICKED(ID_REPTYPE2, OnUserReport)
ON_BN_CLICKED(ID_REPTYPE, OnRegReport)
ON_WM_CONTEXTMENU()
ON_COMMAND(ID_POPUP_CHSYNC, OnPopupChsync)
ON_COMMAND(ID_POPUP_CHREP, OnPopupChrep)
ON_COMMAND(ID_POPUP_ARSREP, OnPopupArsrep)
ON_COMMAND(ID_POPUP_PRINT, OnPopupPrint)
ON_LBN_SELCHANGE(ID_PENDING, OnSelchangePending)
ON_COMMAND(ID_POPUP_SDESCRIB, OnPopupSdescrib)
ON_COMMAND(ID_POPUP_PDESCRIB, OnPopupPdescrib)
ON_BN_CLICKED(IDC_SELECTSTRINGP, OnSelectstringp)
ON_BN_CLICKED(IDC_SELECTSTRINGS, OnSelectstrings)
ON_COMMAND(ID_DESCRIBE_GROUP, OnDescribeGroup)
ON_LBN_DBLCLK(ID_USER, OnDblclkGroup)
ON_BN_CLICKED(ID_UNSYNCH, OnUnsynch)
ON_BN_CLICKED(ID_INTEGRATE, OnIntegrate)
ON_BN_CLICKED(ID_CONFIRM, OnConfirm)
ON_COMMAND(ID_POPUP_CONFIRM, OnPopupConfirm)
ON_COMMAND(ID_POPUP_DISCONFIRM, OnPopupDisconfirm)
ON_BN_CLICKED(ID_REVERT, OnRevert)
ON_BN_CLICKED(ID_RESOLVE, OnResolve)
ON_BN_CLICKED(ID_UNSUBMIT, OnUnsubmit)
ON_BN_CLICKED(IDC_SEARCHCONF, OnSearchconf)
ON_BN_CLICKED(IDC_AUTOINTG, OnAutointg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Creports message handlers
BOOL Creports::OnInitDialog()
{
CPropertyPage::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
m_Pending.SetHorizontalExtent(1000);
m_Submit.SetHorizontalExtent(1000);
//******Enter Reopen Button for permited users********
/*
TCHAR UserName[ 256 ];
GetEnvironmentVariable( _T("USERNAME"), UserName, sizeof(UserName) );
CString Owner = UserName;
CString Buf=_T(""),dir = _T("\\TempTxt\\it_int.txt");
CString Command = CAllPages::Cmd() + _T(" /c p4 group -o it_int > ") + CAllPages::GetCurDir()+ dir;
CSCMToolApp::Waiting(Command,1,NULL,NULL);
TCHAR* pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
int place = Buf.Find(Owner);
if(place == -1)
m_Reopen.ShowWindow(SW_HIDE);
else
m_Reopen.ShowWindow(SW_SHOW);
*/
//****************************************
CString date=_T("");
//**** DATE *****
m_Date.AttachEdit(ID_DATE,(CWnd *)this);
m_Date.SetMask(_T("####/##/##"));
m_Dateto.AttachEdit(ID_DATETO,(CWnd *)this);
m_Dateto.SetMask(_T("####/##/##"));
date = CAllPages::GetDate();
m_Date.SetData(date );
m_Dateto.SetData(date );
//******************
m_pIcon = AfxGetApp()->LoadIcon(IDI_PRINT);
m_Print.SetIcon(m_pIcon);
m_Print2.SetIcon(m_pIcon);
m_sIcon = AfxGetApp()->LoadIcon(IDI_SYNC);
m_Synch.SetIcon(m_sIcon);
m_usIcon = AfxGetApp()->LoadIcon(IDI_UNSYNC);
m_UnSync.SetIcon(m_usIcon);
m_usbIcon = AfxGetApp()->LoadIcon(IDI_UNSUBMIT);
m_UnSubmit.SetIcon(m_usbIcon);
m_dIcon = AfxGetApp()->LoadIcon(IDI_DELETE);
m_Delete.SetIcon(m_dIcon);
m_DelArs.SetIcon(m_dIcon);
m_confirmIcon=AfxGetApp()->LoadIcon(IDI_CONFIRM);
m_Confirm.SetIcon(m_confirmIcon);
m_ToolTipCtl = new CToolTipCtrl;
if(m_ToolTipCtl)
{
//CDialog::OnInitDialog();
m_ToolTipCtl->Create(this);
m_ToolTipCtl->AddTool(&m_Print,IDS_STRING1);
m_ToolTipCtl->AddTool(&m_Print2,_T("Print Pending changelists to Default Printer"));
m_ToolTipCtl->AddTool(&m_Synch,_T("Sync to selected changelists"));
m_ToolTipCtl->AddTool(&m_UnSync,_T("UnSync to one selected changelist. sync the files one step back. don't work if the files are in first revision."));
m_ToolTipCtl->AddTool(&m_UnSubmit,_T("UnSubmit selected changelist."));
m_ToolTipCtl->AddTool(&m_Delete,_T("Delete All Changelist Reports"));
m_ToolTipCtl->AddTool(&m_DelArs,_T("Delete All ARS Reports"));
m_ToolTipCtl->AddTool(&m_Confirm,_T("Confirm the submit of a pending changelist"));
m_ToolTipCtl->AddTool(&m_Revert,_T("Revert all the deleted files from changelists"));
m_ToolTipCtl->AddTool(&m_Resolve,_T("Auto Resolve"));
}
int i=0;
i = m_By.SelectString( -1, _T("Groups") );
m_By.SetCurSel(i);
m_EditArs.ShowWindow( SW_HIDE );
OnSelchangeBy() ;
return TRUE;
}
BOOL Creports::PreTranslateMessage(MSG *pMsg)
{
m_ToolTipCtl->RelayEvent(pMsg);
//Shift+F10: show pop-up menu.
if ((((pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN) && //If we hit a key and
(pMsg->wParam == VK_F10) && (GetKeyState(VK_SHIFT) & ~1)) != 0) || //it's Shift+F10 OR
(pMsg->message == WM_CONTEXTMENU)) //Natural keyboard key
{
CRect rect;
GetClientRect(rect);
ClientToScreen(rect);
CPoint point = rect.TopLeft();
OnContextMenu(NULL, point);
return TRUE;
}
return CDialog::PreTranslateMessage(pMsg);
}
void Creports::OnSelchangeBy()
{
CString ByName=_T(""),User=_T(""),Buf=_T(""),Command=_T("");
m_Submit.ResetContent();
m_Pending.ResetContent();
int place = m_By.GetCurSel();
m_By.GetLBText( place , ByName );
if(ByName == _T("Users")||ByName == _T("ABY"))
{
Command += CAllPages::rep(_T("-ul"));
Command += _T(" > ") + CAllPages::GetCurDir() + _T("\\TempTxt\\users.txt");
CSCMToolApp::Waiting(Command,1,NULL,NULL);
CString dir = _T("\\TempTxt\\users.txt");
TCHAR* pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
m_Users.ResetContent( ); //clean the list box for another use
m_EditArs.ShowWindow(SW_HIDE);
m_EditCh.ShowWindow(SW_HIDE);
m_Users.ShowWindow(SW_SHOW);
CAllPages::AddStringToList(&m_Users,Buf);
}
else if (ByName == _T("Owner"))
{
m_EditArs.ShowWindow(SW_HIDE);
m_EditCh.ShowWindow(SW_HIDE);
m_Users.ShowWindow(SW_SHOW);
m_Users.ResetContent( ); //clean the list box for another use
TCHAR UserName[ 256 ];
GetEnvironmentVariable( _T("USERNAME"), UserName, sizeof(UserName) );
m_Users.AddString(UserName);
}
else if (ByName == _T("ARS"))
{
m_EditCh.ShowWindow(SW_HIDE);
m_EditArs.ShowWindow(SW_SHOW);
m_Users.ShowWindow(SW_HIDE);
}
else if (ByName == _T("ChangeList"))
{
m_EditCh.ShowWindow(SW_SHOW);
m_EditArs.ShowWindow(SW_HIDE);
m_Users.ShowWindow(SW_HIDE);
}
else if (ByName == _T("Groups"))
{
Command += CAllPages::rep(_T("-gl"));
Command += _T(" > ") + CAllPages::GetCurDir() + _T("\\TempTxt\\groups.txt");
CSCMToolApp::Waiting(Command,1,NULL,NULL);
CString dir = _T("\\TempTxt\\groups.txt");
TCHAR* pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
m_Users.ResetContent( ); //clean the list box for another use
m_EditArs.ShowWindow(SW_HIDE);
m_EditCh.ShowWindow(SW_HIDE);
m_Users.ShowWindow(SW_SHOW);
CAllPages::AddStringToList(&m_Users,Buf);
}
else if(ByName == _T("Users & Groups"))
{
Command += CAllPages::rep(_T("-gul"));
Command += _T(" > ") + CAllPages::GetCurDir() + _T("\\TempTxt\\usersgroups.txt");
CSCMToolApp::Waiting(Command,1,NULL,NULL);
CString dir = _T("\\TempTxt\\usersgroups.txt");
TCHAR* pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
m_Users.ResetContent( ); //clean the list box for another use
m_EditArs.ShowWindow(SW_HIDE);
m_EditCh.ShowWindow(SW_HIDE);
m_Users.ShowWindow(SW_SHOW);
CAllPages::AddStringToList(&m_Users,Buf);
}
}
void Creports::OnButton1()
{
CString user=_T(""),list=_T(""),date=_T(""),dateto=_T(""),Label=_T(""),By=_T("");
CString Buf=_T(""),ChangLst=_T(""),Command=_T(""),Buffer=_T("");
int i=0,place = m_By.GetCurSel();
m_By.GetLBText(place,By);
if((By != _T("ARS"))&&(By != _T("ChangeList")))
{
if(0 == m_Users.GetSelCount() && By != _T("Owner"))
{
MessageBox(_T("Please, Choose User/Group first!"),_T("NSCM"),MB_ICONERROR);
return;
}
if( 0 == m_Users.GetSelCount() && By == _T("Owner"))
{
m_Users.SetSel( 0 , TRUE );
}
int buf[500];
int Count = m_Users.GetCount( ); // Number of items
m_Users.GetSelItems(Count, buf );
int SelCount = m_Users.GetSelCount( );//Number of Selected items
for(i=0;i < SelCount;i++)
{
m_Users.GetText(buf[i], user );
user.TrimRight();
list += user;
list += _T(" ");
user.Empty();
}
if(m_Check.GetCheck()&& (-1<m_Date2.GetCurSel())) //if choose "by Labe"
{
int place = m_Date2.GetCurSel();
m_Date2.GetLBText( place, Label );
date = GetDateFromLabelName(Label);
place = m_Dateto2.GetCurSel();
m_Dateto2.GetLBText( place, Label );
if(Label != _T("Head Revision")) dateto = GetDateFromLabelName(Label);
else dateto = CAllPages::GetDate();
}
else
{
m_Date.GetData(date);
m_Dateto.GetData(dateto);
}
if(By == _T("Users")||By == _T("Owner")) Command = CAllPages::rep(_T("-cs ")) + date + _T(" ") + dateto + _T(" -u ");
else if (By == _T("Groups"))Command = CAllPages::rep(_T("-cs "))+date + _T(" ") + dateto +(_T(" -g "));
else if (By == _T("Users & Groups"))Command = CAllPages::rep(_T("-cs "))+date + _T(" ") + dateto +(_T(" -gu "));
else if (By == _T("ABY"))Command = CAllPages::rep(_T(" -abytochs "))+_T(" -d ") + date + _T(" ") + dateto + _T(" -u ");
Command += list;
//Command += _T(" -d ");
//Command += date + _T(" ") + dateto;
if(m_CheckConf.GetCheck())//if searching by configuration.
{
CString dir = "\\TempTxt\\command.txt";
TCHAR* pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buffer);
Command += Buffer;
}
if(m_CheckSsearch.GetCheck()) //if searching by string
{
UpdateData(); // initialized the dialog
SetModified(TRUE);
CString SearchString;
int sel = m_SearchSString.GetCurSel();
if (sel == -1) //if it is a new string not selected one
{
SearchString = m_SearchSString_st;
m_SearchSString.AddString(SearchString);
}
else m_SearchSString.GetLBText(sel,SearchString);
while(! ( SearchString.IsEmpty() ) )
{
int slash = SearchString.ReverseFind(_T('\\'));
if(-1 == slash) {
Command += _T(" -ds ") + SearchString;
break;
}
if(_T('*') == SearchString.GetAt(slash+1)) //means finding \*
{
Command += _T(" -nds ") + SearchString.Mid(slash + 2);
SearchString = SearchString.Left(slash);
}
else
{
Command += _T(" -ds ") + SearchString.Mid(slash + 1);
SearchString = SearchString.Left(slash);
}
}
}
Command += _T(" > ") + CAllPages::GetCurDir()+_T("\\TempTxt\\Subchang.txt");
CSCMToolApp::Waiting( Command,1,NULL,NULL);
}
else if (By == _T("ARS"))
{
TCHAR temp[64];
while(m_EditArs.GetLine(i,temp,64)) //read the ars numbers
{
CString ArsNumber(temp);
ArsNumber=ArsNumber.SpanIncluding(_T("0123456789"));
ArsNumber.TrimLeft();
list += ArsNumber + _T(" ");
i++;
}
Command += CAllPages::rep(_T("-arstochs -dt")) ;
Command += list + _T("> ") + CAllPages::GetCurDir() + _T("\\TempTxt\\SubChang.txt");
CSCMToolApp::Waiting( Command,1,NULL,NULL);
}
else //By==ChangeList
{
TCHAR temp[64];
CString NewBuf=_T("");
while(m_EditCh.GetLine(i,temp,64)) //read the ChangeList numbers
{
CString ChNumber(temp);
ChNumber=ChNumber.SpanIncluding(_T("0123456789"));
ChNumber.TrimLeft();
list += ChNumber + _T(" ");
i++;
}
Command += CAllPages::rep(_T("-schs "));
Command += list + _T("> ") + CAllPages::GetCurDir() + _T("\\TempTxt\\SubChang.txt");
CSCMToolApp::Waiting( Command,1,NULL,NULL);
}
CString dir = _T("\\TempTxt\\SubChang.txt");
TCHAR* pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
m_Submit.ResetContent( ); //clean the list box for another use
if(0 != Buf.IsEmpty())
{
MessageBox(_T("No Submitted Changlist has been found"),_T("NSCM"),MB_ICONINFORMATION);
return;
}
CAllPages::AddStringToList(&m_Submit,Buf);
}
void Creports::OnButton2()
{
CString Item=_T(""),list=_T(""),date=_T(""),dateto=_T(""),Label=_T(""),today=_T(""),By=_T("");
CString Buf=_T(""),ChangLst=_T(""),Command=_T(""),user=_T("");
CString dir = _T("\\TempTxt\\PenChang.txt");
int *buf = new int[500];
int SelCount,i,place = m_By.GetCurSel();
m_By.GetLBText(place,By);
if((By != _T("ARS")) && (By != _T("ChangeList")))
{
if (By == _T("Users") || By == _T("Groups")||By == _T("ABY")|| By == _T("Users & Groups"))
{
if(0 == m_Users.GetSelCount())
{
MessageBox(_T("Please, Choose User first!"),_T("NSCM"),MB_ICONERROR);
return;
}
int Count = m_Users.GetCount( ); // pick users list
m_Users.GetSelItems(Count, buf );
int SelCount = m_Users.GetSelCount( );
for(i=0;i < SelCount;i++)
{
m_Users.GetText(buf[i], Item );
Item.TrimRight();
list += Item;
list += _T(" ");
Item.Empty();
}
}
if(By == _T("Owner"))
{
int num = m_Users.GetCount( );
m_Users.GetText(0,list);
list.TrimRight();
}
//m_Date.GetData(date); //pick the date
//m_Dateto.GetData(dateto);
if(By == _T("Users") || By == _T("Owner" )) Command = CAllPages::rep(_T("-cp -u "));
else if (By == _T("Groups"))Command = CAllPages::rep(_T("-cp -g "));
else if (By == _T("Users & Groups"))Command = CAllPages::rep(_T("-cp -gu "));
else if (By == _T("ABY"))Command = CAllPages::rep(_T(" -abytochp -u "));
Command += list;
//Command += _T(" -d ") + date + _T(" ") + dateto;
if(m_CheckPsearch.GetCheck()) //if searching by string
{
UpdateData(); // initialized the dialog
SetModified(TRUE);
CString SearchString;
int sel = m_SearchPString.GetCurSel();
if (sel == -1) //if it is a new string not selected one
{
SearchString = m_SearchPString_st;
m_SearchPString.AddString(SearchString);
}
else m_SearchPString.GetLBText(sel,SearchString);
while(! ( SearchString.IsEmpty() ) )
{
int slash = SearchString.ReverseFind('\\');
if(-1 == slash) {
Command += _T(" -ds ") + SearchString;
break;
}
if('*' == SearchString.GetAt(slash+1)) //means finding \*
{
Command += _T(" -nds ") + SearchString.Mid(slash + 2);
SearchString = SearchString.Left(slash);
}
else
{
Command += _T(" -ds ") + SearchString.Mid(slash + 1);
SearchString = SearchString.Left(slash);
}
}
}
Command += _T(" > ") + CAllPages::GetCurDir() + dir;
CSCMToolApp::Waiting( Command,1,NULL,NULL);
}
else if(By =="ARS")
{
i=0;
TCHAR temp[64];
while(m_EditArs.GetLine(i,temp,64)) //read the ars numbers
{
CString ArsNumber(temp);
ArsNumber=ArsNumber.SpanIncluding(_T("0123456789"));
list += ArsNumber + _T(" ");
i++;
}
Command.Empty();
Command += CAllPages::rep(_T("-arstochp -dt")) ;
Command += list + _T(" > ") + CAllPages::GetCurDir() + dir;
CSCMToolApp::Waiting( Command,1,NULL,NULL);
}
else //By==ChangeList
{
i = 0;
TCHAR temp[64];
while(m_EditCh.GetLine(i,temp,64)) //read the ChangeList numbers
{
CString ChNumber(temp);
ChNumber=ChNumber.SpanIncluding(_T("0123456789"));
ChNumber.TrimLeft();
list += ChNumber + " ";
i++;
}
Command += CAllPages::rep(_T("-schp "));
Command += list + _T(" > ") + CAllPages::GetCurDir() + dir;
CSCMToolApp::Waiting( Command,1,NULL,NULL);
}
TCHAR* pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
m_Pending.ResetContent( ); //clean the list box for another use
CAllPages::AddStringToList(&m_Pending,Buf);
//***********Add list of "Default By <user>" in the end****************
if(By == "Owner")
{
m_Pending.AddString(_T("default by ") + list);
}
if(By == "Users")
{
SelCount = m_Users.GetSelCount( );
for(i=0;i < SelCount;i++)
{
m_Users.GetText(buf[i], user );
user.TrimRight();
m_Pending.AddString(_T("default by ") + user);
user.Empty();
}
}
else if((By == _T("Groups"))|| (By == _T("Users & Groups")))
{
CString group=_T("");
int index;
dir = _T("\\TempTxt\\UsersForDefault.txt");
TCHAR *pName = dir.GetBuffer(0);
Buf.Empty();
CAllPages::ConvertFileIntoString(pName,&Buf);
index = Buf.Find(_T(" "));
while(index > -1)
{
user = Buf.Left(index);
user.TrimRight(); user.TrimLeft();
if (!(user.IsEmpty()))
{
m_Pending.AddString(_T("default by ") + user);
}
Buf = Buf.Mid(index+1);
index = Buf.Find(_T(" "));
user.Empty();
}
Command.Empty();
group.Empty();
/* CString group=_T("");
int index;
SelCount = m_Users.GetSelCount( );
dir = _T("\\TempTxt\\group.txt");
TCHAR *pName = dir.GetBuffer(0);
for(i=0;i < SelCount;i++) // translate every group into users
{
m_Users.GetText(buf[i], group );
group.TrimRight();
Command = CAllPages::rep(_T("-gdsc ")) + group +_T(" > ") + CAllPages::GetCurDir() + dir;
CSCMToolApp::Waiting( Command,1,NULL,NULL);
Buf.Empty();
CAllPages::ConvertFileIntoString(pName,&Buf);
index = Buf.Find(_T("\n"));
while(index > -1)
{
user = Buf.Left(index);
user.TrimRight(); user.TrimLeft();
m_Pending.AddString(_T("default by ") + user);
Buf = Buf.Mid(index+1);
index = Buf.Find(_T("\n"));
user.Empty();
}
Command.Empty();
group.Empty();
}*/
}
delete [] buf;
}
void Creports::OnNotped()
{
#define BUFFER_SIZE 1000
CString changlst=_T(""),Command = _T(""),CommandForArs=_T(""),Slist=_T(""),Plist=_T(""),Label=_T(""),Project=_T(""),date=_T("");
int *data,flag1=0,flag2=0,Count;
time_t osBinaryTime; // C run-time time (defined in <time.h>)
time( &osBinaryTime ) ; // Get the current time from the operating system.
CTime t( osBinaryTime );
int day = t.GetDay();
int month = t.GetMonth();
int year = t.GetYear();
int sec = t.GetSecond();
int min = t.GetMinute();
int hour = t.GetHour() ;
date.Format(_T("_%d%d%d_%d%d%d"),day,month,year,hour,min,sec);
CString ByName=_T("");
int place = m_By.GetCurSel();
m_By.GetLBText( place , ByName );
if(Count = m_Submit.GetCount( ))//Count = Number of Items in the ListBox
{
Slist = CAllPages::GetChangeList(&m_Submit);
if(ByName != "ARS")
{
Command = CAllPages::rep(_T("-cfs -dt "));
Command += Slist;
if(m_Check.GetCheck()&& (-1<m_Date2.GetCurSel())) //if the selection is by label
{
int place = m_Date2.GetCurSel();
m_Date2.GetLBText( place, Label );
Project = GetProjectFromLabelName(Label);
Command += _T(" -p ") + Project + _T(" OFF202"); //Elite + OFF202 or IT + OFF202
}
Command += _T(" >") + CAllPages::GetCurDir() + _T("\\chrep\\CReport") + date + _T(".txt");
CSCMToolApp::Waiting( Command,1,NULL,NULL);
}
}
Command.Empty();
CString deflist=_T("");
if(Count = m_Pending.GetCount( ))//Count = Number of Items in the ListBox
{
int i[3];
data = new int[BUFFER_SIZE];
m_Pending.GetSelItems(Count, data );
int SelCount = m_Pending.GetSelCount( ); //SelCount = Number of the selected Items
for(i[0]=0;i[0] < SelCount;i[0]++)
{
m_Pending.GetText(data[i[0]], changlst );
i[1] = changlst.Find(_T(" on "))+1;
if (i[1]== 0)
{
i[2] = changlst.Find(_T(" by "))+4;
deflist += changlst.Mid(i[2]);//take only the user-name
deflist += _T(" ");
changlst.Empty();
}
else
{
Plist += changlst.Left(i[1]);
changlst.Empty();
}
}
if(ByName != "ARS")
{
Command += CAllPages::rep(_T("-cfp -dt "));
Command += Plist;
if(m_Check.GetCheck()&& (-1<m_Date2.GetCurSel()))
{
int place = m_Date2.GetCurSel();
m_Date2.GetLBText( place, Label );
Project = GetProjectFromLabelName(Label);
Command += _T(" -p ") + Project;
}
Command += _T(" >> ") + CAllPages::GetCurDir() + _T("\\chrep\\CReport") + date + ".txt";
CSCMToolApp::Waiting( Command,1,NULL,NULL);
Command.Empty();
Command += CAllPages::rep(_T(" -cfp -dt default -u ")) + deflist;
Command += _T(" >> ") + CAllPages::GetCurDir() + _T("\\chrep\\CReport")+date+_T(".txt");
CSCMToolApp::Waiting(Command,1,NULL,NULL);
}
delete [] data;
}
if(!(m_Submit.GetSelCount( ))&&!( m_Pending.GetSelCount( ))&& !(m_Check.GetCheck())) //if there was no selection
{
MessageBox(_T("Please, Choose ChangList first!"),_T("NSCM"),MB_ICONWARNING);
return;
}
if(ByName == "ARS")
{
int i=0;
CString ARSlist=_T("");
TCHAR temp[64];
while(m_EditArs.GetLine(i,temp,64)) //read the ars numbers
{
CString ArsNumber(temp);
ArsNumber=ArsNumber.SpanIncluding(_T("0123456789"));
ARSlist += ArsNumber + _T(" ");
i++;
}
Command = CAllPages::rep(_T("-cf")) + ARSlist + _T(" -c ") + Slist + Plist;
Command += _T(" > ") + CAllPages::GetCurDir() + _T("\\chrep\\CReport")+date+_T(".txt");
CSCMToolApp::Waiting(Command,1,NULL,NULL);
}
// handling the option of diff report between labels
//****************************************************
if(m_Check.GetCheck())
{
date.Empty();
time_t osBinaryTime; // C run-time time (defined in <time.h>)
time( &osBinaryTime ) ; // Get the current time from the operating system.
CTime t( osBinaryTime );
int day = t.GetDay();
int month = t.GetMonth();
int year = t.GetYear();
int sec = t.GetSecond();
int min = t.GetMinute();
int hour = t.GetHour() ;
date.Format(_T("_%d%d%d_%d%d%d"),day,month,year,hour,min,sec);
CString LabelName1=_T(""),LabelName2=_T(""),Command=_T("");
int place = m_Date2.GetCurSel();
if( place == LB_ERR )
{
MessageBox(_T("Don't you think you have to choose Label first???"),_T("NSCM"),MB_ICONWARNING|MB_OK);
return;
}
m_Date2.GetLBText( place, LabelName1 );
place = m_Dateto2.GetCurSel();
m_Dateto2.GetLBText( place, LabelName2 );
if(MessageBox(_T("This application will take some time!\n Are you sure you want to continue??"),_T("NSCM"),MB_ICONWARNING|MB_YESNO)==IDNO)
return;
if(LabelName2 == _T("Head Revision"))
{
if(m_Different.GetCheck()) ReportLabels(_T("-diff"),LabelName1,_T(""),date);
if(m_Add.GetCheck()) ReportLabels(_T("-diffoneh"),LabelName1,_T(""),date);
if(m_Del.GetCheck()) ReportLabels(_T("-diffonel"),LabelName1,_T(""),date);
if(m_Equal.GetCheck()) ReportLabels(_T("-eql"),LabelName1,_T(""),date);
}
else
{
if(m_Different.GetCheck()) ReportLabels(_T("-diff2"),LabelName1,LabelName2,date);
if(m_Add.GetCheck()) ReportLabels(_T("-diffone2"),LabelName2,LabelName1,date);
if(m_Del.GetCheck()) ReportLabels(_T("-diffone2"),LabelName1,LabelName2,date);
if(m_Equal.GetCheck()) ReportLabels(_T("-eql2"),LabelName1,LabelName2,date);
}
}
Command.Empty();
CString Buf=_T("");
CString dir = _T("\\chrep\\CReport") + date + _T(".txt");
TCHAR* pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
if(Buf.IsEmpty())
{
MessageBox(_T("There are no files that matching to this request"),_T("NSCM"),MB_ICONINFORMATION );
CSCMToolApp::Waiting(CAllPages::Cmd() + _T(" /c del ") + CAllPages::GetCurDir() + dir,1,NULL,NULL);
return;
}
Command += CAllPages::Cmd() + _T(" /c notepad ") + CAllPages::GetCurMFCDir() + dir;
CSCMToolApp::RunProcess(Command,1,NULL,NULL);
}
void Creports::OnKillfocusDate()
{
CString from=_T(""),to=_T("");
m_Date.GetData(from);
m_Dateto.GetData(to);
int space = from.Find(_T(" ")); //space can be only in the end
if(space>-1)
{
from = from.Left(space-1) + _T("0") + from.GetAt(space-1);
m_Date.SetData(from);
}
CString CurDate = CAllPages::GetDate();
CString day = from.Mid(6);
CString month = from.Mid(4,2);
if(from > CurDate || day > "31" || day == "00"||month > "12" || month == "00")
{
MessageBox(_T("Wrong Date!!"),_T("NSCM"),MB_ICONERROR);
m_Date.SetFocus();
return;
}
if(from > to)
{
MessageBeep(0xFFFFFFFF );
m_Dateto.SetData(CurDate);
m_Dateto.SetFocus();
return;
}
if(m_Check.GetCheck())
{
if(m_Radio.GetCheck())
OnRadio1();
else
OnRadio2();
}
}
void Creports::OnKillfocusDateto()
{
CString from=_T(""),to=_T("");
m_Date.GetData(from);
m_Dateto.GetData(to);
int space = to.Find(_T(" "));
if(space>-1)
{
to = to.Left(space-1) + _T("0") + to.GetAt(space-1);
m_Dateto.SetData(to);
}
CString CurDate = CAllPages::GetDate();
CString day = from.Mid(6);
CString month = from.Mid(4,2);
if(day > "31" || day == "00"||month > "12" || month == "00")
{
MessageBox(_T("Wrong Date!!"),_T("NSCM"),MB_ICONERROR);
m_Dateto.SetFocus();
return;
}
if(from > to)
{
MessageBeep(0xFFFFFFFF);
MessageBox(_T("Wrong Date!!"),_T("NSCM"),MB_ICONERROR);
m_Dateto.SetData(CurDate);
return;
}
if(m_Check.GetCheck())
{
if(m_Radio.GetCheck())
OnRadio1();
else
OnRadio2();
}
}
void Creports::OnCheck()
{
m_RepType = 0;
m_Radio.SetCheck(1);
OnRadio1();
m_Radio2.SetCheck(0);
UpdateData(FALSE); // initialized the dialog
m_Notepad2.ShowWindow( SW_HIDE );
m_DelArs.ShowWindow( SW_HIDE );
m_Print.ShowWindow( SW_HIDE );
m_Print2.ShowWindow( SW_HIDE );
GetDlgItem(ID_INTEGRATE)->ShowWindow( SW_HIDE );
GetDlgItem(IDC_AUTOINTG)->ShowWindow( SW_HIDE );
m_Synch.ShowWindow( SW_HIDE );
m_UnSync.ShowWindow( SW_HIDE );
m_UnSubmit.ShowWindow( SW_HIDE );
m_SearchSString.ShowWindow( SW_HIDE );
m_SearchPString.ShowWindow( SW_HIDE );
m_CheckSsearch.ShowWindow( SW_HIDE );
m_CheckPsearch.ShowWindow( SW_HIDE );
// m_Reopen.ShowWindow( SW_HIDE );
m_Confirm.ShowWindow( SW_HIDE );
m_Users.EnableWindow(FALSE);
m_Submit.EnableWindow(FALSE);
m_Pending.EnableWindow(FALSE);
m_By.EnableWindow(FALSE);
m_Button1.EnableWindow(FALSE);
m_Button2.EnableWindow(FALSE);
BOOL value = m_Check.GetCheck();
if(value)
{
GetDlgItem(ID_REPTYPE)->ShowWindow( SW_SHOW );
GetDlgItem(ID_REPTYPE2)->ShowWindow( SW_SHOW );
m_Radio.EnableWindow(TRUE);
m_Radio2.EnableWindow(TRUE);
m_Option.ShowWindow( SW_SHOW );//show the box of options
m_Different.ShowWindow( SW_SHOW );
m_Add.ShowWindow( SW_SHOW );
m_Del.ShowWindow( SW_SHOW );
m_Equal.ShowWindow( SW_SHOW );
m_Different.SetCheck(TRUE);
m_Add.SetCheck(TRUE);
m_Del.SetCheck(TRUE);
}
else //onunclick
{
if((m_By.FindString(-1,_T("ARS"))) == CB_ERR) //if we delete those three options
{
m_By.InsertString(-1,_T("ARS")); //The String added to the end of the list
m_By.InsertString(-1,_T("ABY"));
m_By.InsertString(-1,_T("ChangeList"));
}
GetDlgItem(ID_REPTYPE)->ShowWindow( SW_HIDE );
GetDlgItem(ID_REPTYPE2)->ShowWindow( SW_HIDE );
m_Notepad2.ShowWindow( SW_SHOW );
GetDlgItem(ID_INTEGRATE)->ShowWindow( SW_SHOW );
GetDlgItem(IDC_AUTOINTG)->ShowWindow( SW_SHOW );
m_DelArs.ShowWindow( SW_SHOW );
m_Print.ShowWindow( SW_SHOW );
m_Print2.ShowWindow( SW_SHOW );
m_Synch.ShowWindow( SW_SHOW );
m_UnSync.ShowWindow( SW_SHOW );
m_UnSubmit.ShowWindow( SW_SHOW );
m_SearchSString.ShowWindow( SW_SHOW );
m_SearchPString.ShowWindow( SW_SHOW );
m_CheckSsearch.ShowWindow( SW_SHOW );
m_CheckPsearch.ShowWindow( SW_SHOW );
// m_Reopen.ShowWindow( SW_SHOW );
m_Confirm.ShowWindow( SW_SHOW );
m_Radio.EnableWindow( FALSE );
GetDlgItem(ID_RADIO2)->EnableWindow( FALSE );
m_Date2.EnableWindow( FALSE );
m_Dateto2.EnableWindow( FALSE );
m_Users.EnableWindow( TRUE );
m_Submit.EnableWindow( TRUE );
m_Pending.EnableWindow( TRUE );
m_By.EnableWindow( TRUE );
m_Button1.EnableWindow( TRUE );
m_Button2.EnableWindow( TRUE );
m_Option.ShowWindow( SW_HIDE );//hide the box of options
m_Different.ShowWindow( SW_HIDE );
m_Add.ShowWindow( SW_HIDE );
m_Del.ShowWindow( SW_HIDE );
m_Equal.ShowWindow( SW_HIDE );
}
}
void Creports::OnRadio1()
{
m_Radio.SetCheck( TRUE );
m_Radio2.SetCheck( FALSE );
m_Date2.EnableWindow( TRUE );
CString Command=_T(""),Buf=_T(""),label=_T(""),from=_T(""),to=_T("");
int index1=0,index2=0;
m_Date.GetData(from);
m_Dateto.GetData(to);
Command += CAllPages::rep(_T("-l -wb -d")); //weekly labels
Command += from +_T(" ")+to + _T(" > ") + CAllPages::GetCurDir() + _T("\\TempTxt\\ByLabel.txt");
CSCMToolApp::Waiting(Command,1,NULL,NULL);
CString dir = _T("\\TempTxt\\Bylabel.txt");
TCHAR* pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
m_Date2.ResetContent( ); //clean the list box for another use
while (index1 > -1)
{
index1 = Buf.Find(_T("\n"));
if (index1 == -1) break;
label = Buf.Left(index1);
label.TrimRight();
index2 = label.Find(_T("'"))-1;
label = label.Left(index2);
index2 = label.Find(_T("/"))-5;
label.Insert(index2,_T(" "));
m_Date2.AddString(label);
Buf=Buf.Mid(index1+1);
label.Empty();
}
m_Date2.SetCurSel(0);
OnSelchangeDate2();
}
/*
void Creports::OnRadio2()
{
m_Radio2.SetCheck( TRUE );
m_Radio.SetCheck( FALSE );
CString Command=_T(""),Buf=_T(""),label=_T(""),from=_T(""),to=_T("");
int index1=0,index2=0;
m_Date.GetData(from);
m_Dateto.GetData(to);
Command += CAllPages::rep(_T("-l -sl -d")); //weekly labels
Command += from +_T(" ")+to + _T(" > ") + CAllPages::GetCurDir() + _T("\\TempTxt\\ByLabel.txt");
CSCMToolApp::Waiting(Command,1,NULL,NULL);
CString dir = _T("\\TempTxt\\Bylabel.txt");
TCHAR* pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
m_Date2.ResetContent( ); //clean the list box for another use
m_Dateto2.ResetContent( );
while (index1 > -1)
{
index1 = Buf.Find(_T("\n"));
if (index1 == -1) break;
label = Buf.Left(index1);
label.TrimRight();
index2 = label.Find(_T("'Create"))-11;
label = label.Left(index2);
m_Date2.AddString(label);
Buf=Buf.Mid(index1+1);
label.Empty();
}
m_Date2.SetCurSel(0);
OnSelchangeDate2();
}
*/
void Creports::OnRadio2()
{
m_Radio2.SetCheck( TRUE );
m_Radio.SetCheck( FALSE );
CString Command=_T(""),Buf=_T(""),label=_T(""),from=_T(""),to=_T("");
int index1=0,index2=0;
m_Date.GetData(from);
m_Dateto.GetData(to);
Command += CAllPages::rep(_T("-l -all -d")); //weekly labels
Command += from +_T(" ")+to + _T(" > ") + CAllPages::GetCurDir() + _T("\\TempTxt\\ByLabel.txt");
CSCMToolApp::Waiting(Command,1,NULL,NULL);
CString dir = _T("\\TempTxt\\Bylabel.txt");
TCHAR* pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
m_Date2.ResetContent( ); //clean the list box for another use
m_Dateto2.ResetContent( );
while (index1 > -1)
{
index1 = Buf.Find(_T("\n"));
if (index1 == -1) break;
label = Buf.Left(index1);
label.TrimRight();
index2 = label.Find(_T("'"))-1;
label = label.Left(index2);
index2 = label.Find(_T("/"))-5;
label.Insert(index2,_T(" "));
m_Date2.AddString(label);
Buf=Buf.Mid(index1+1);
label.Empty();
}
m_Date2.SetCurSel(0);
OnSelchangeDate2();
}
void Creports::OnSelchangeDate2()
{
m_Date2.EnableWindow(TRUE);
CString Project=_T(""),Command=_T(""),Buf=_T(""),LabelName=_T("");
CString label=_T(""),from=_T(""),to=_T(""),date=_T("");
int index1=0,index2=0;
if(m_Radio.GetCheck())
{
Command += CAllPages::rep(_T("-l -wb")); //weekly labels
}
else
{
//Command += CAllPages::rep(_T("-l -sl"));
Command += CAllPages::rep(_T("-l -all"));
}
int place = m_Date2.GetCurSel( );
int Select = m_Radio.GetCheck( );
if(place == -1 && Select == 1 ) //if there is no match label to this date
{
//MessageBox(_T("There are no Module Labels from this period"),_T("NSCM"),MB_ICONWARNING);
MessageBox(_T("There are no Labels from this period"),_T("NSCM"),MB_ICONWARNING);
m_Date.SetFocus();
return;
}
else if(place == -1 && Select == 0 )
{
MessageBox(_T("There are no Weekly Labels from this period"),_T("NSCM"),MB_ICONWARNING);
m_Dateto2.ResetContent( );
m_Date.SetFocus();
return;
}
else
{
m_Dateto2.EnableWindow( TRUE );
m_Date2.GetLBText(place,LabelName);
if(Select == 1 )
{
Project = GetProjectFromLabelName(LabelName);
Command += _T("-p ") + Project;
}
from = GetDateFromLabelName(LabelName);
m_Dateto.GetData(to);
Command += _T(" -d ") + from +_T(" ") + to + _T(" > ") + CAllPages::GetCurDir() + _T("\\TempTxt\\ToLabel.txt");
CSCMToolApp::Waiting(Command,1,NULL,NULL);
CString dir = _T("\\TempTxt\\Tolabel.txt");
TCHAR* pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
m_Dateto2.ResetContent( ); //clean the list box for another use
m_Dateto2.AddString(_T("Head Revision"));
while (index1 > -1)
{
index1 = Buf.Find(_T("\n"));
if (index1 == -1) break;
label = Buf.Left(index1);
label.TrimRight();
index2 = label.Find(_T("'"))-1;
label = label.Left(index2);
index2 = label.Find(_T("/"))-5;
label.Insert(index2,_T(" "));
m_Dateto2.AddString(label);
Buf=Buf.Mid(index1+1);
label.Empty();
}
m_Dateto2.SetCurSel(0);
}
}
CString Creports::GetDateFromLabelName(CString LabelName)
{
CString date=_T(""),Template=_T("");
//int i = LabelName.Find(_T("."));
//date = LabelName.Mid(i-2,10); //get day/month/year
//Template = date.Right(4); //year
//Template += date.Mid(3,2); //month
//Template += date.Left(2); //day
int i = LabelName.Find(_T("/"));
date = LabelName.Mid(i-4,10); //get day/month/year
Template = date.Left(4); //year
Template += date.Mid(5,2); //month
Template += date.Right(2); //day
return Template;
}
CString Creports::GetProjectFromLabelName(CString LabelName)
{
CString Project=_T("");
int i = LabelName.Find(_T("_"));
Project = LabelName.Left(i);
return Project;
}
void Creports::ReportLabels(CString Switch,CString LabelName1,CString LabelName2,CString Date)
{
CString Command = CAllPages::rep(Switch)+LabelName1 + " " + LabelName2;
if (m_RepType == 1)
{
CString By=_T(""),list=_T(""),Item=_T("");
Command += _T("-fullu");
int Sel = m_By.GetCurSel();
m_By.GetLBText(Sel,By);
if(By == "Groups") Command += _T(" -g ");
else Command += _T(" -u ");
int *buf = NULL;
int Count = m_Users.GetCount( ); // Number of items
buf = new int[Count];
m_Users.GetSelItems(Count, buf );
int SelCount = m_Users.GetSelCount( );//Number of Selected items
if(!SelCount) return; //if didn't choose users
for(int i=0;i < SelCount;i++)
{
m_Users.GetText(buf[i], Item );
Item.TrimRight();
list += Item;
list += _T(" ");
Item.Empty();
}
Command += list;
delete [] buf;
}
Command += _T(" >> ") + CAllPages::GetCurDir()+_T("\\chrep\\CReport")+ Date + _T(".txt");
CSCMToolApp::Waiting( Command,1,NULL,NULL);
}
void Creports::OnNotped2()
{
#define BUFFER_SIZE 1000
CString changlst=_T(""),Command = _T(""),CommandForArs=_T(""),Slist=_T(""),Plist=_T(""),Label,Project,date=_T("");
int *data=NULL,flag1=0,flag2=0,Count=0;
data = new int[BUFFER_SIZE];
time_t osBinaryTime; // C run-time time (defined in <time.h>)
time( &osBinaryTime ) ; // Get the current time from the operating system.
CTime t( osBinaryTime );
int day = t.GetDay();
int month = t.GetMonth();
int year = t.GetYear();
int sec = t.GetSecond();
int min = t.GetMinute();
int hour = t.GetHour() ;
date.Format(_T("_%d%d%d_%d%d%d"),day,month,year,hour,min,sec);
if(Count = m_Submit.GetCount( ))//Count = Number of Items in the ListBox
{
Slist = CAllPages::GetChangeList(&m_Submit);
Command = CAllPages::rep(_T("-chtoars"));
Command += Slist;
Command += _T(" > ") + CAllPages::GetCurDir() + _T("\\arsrep\\CReport") + date + _T(".txt");
CSCMToolApp::Waiting( Command,1,NULL,NULL);
delete [] data;
}
Command.Empty();
if(Count = m_Pending.GetCount( ))//Count = Number of Items in the ListBox
{
int i[3];
data = new int[BUFFER_SIZE];
m_Pending.GetSelItems(Count, data );
int SelCount = m_Pending.GetSelCount( ); //SelCount = Number of the selected Items
for(i[0]=0;i[0] < SelCount;i[0]++)
{
m_Pending.GetText(data[i[0]], changlst );
i[1] = changlst.Find(_T(" on "))+1;
if (i[1]== 0)
{
changlst.Empty();
}
else
{
Plist += changlst.Left(i[1]);
changlst.Empty();
}
}
Command += CAllPages::rep(_T("-chtoars"));
Command += Plist;
Command += _T(" >> ") + CAllPages::GetCurDir() + _T("\\arsrep\\CReport") + date + ".txt";
CSCMToolApp::Waiting( Command,1,NULL,NULL);
delete [] data;
}
if(!(m_Submit.GetSelCount( ))&&!( m_Pending.GetSelCount( ))) //if there was no selection
{
MessageBox(_T("Please, Choose ChangList first!"),_T("NSCM"),MB_ICONWARNING);
return;
}
Command.Empty();
CString Buf=_T("");
CString dir = _T("\\arsrep\\CReport") + date + _T(".txt");
TCHAR* pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
if(Buf.IsEmpty())
{
MessageBox(_T("There are no ARS that matching to this request"),_T("NSCM"),MB_ICONINFORMATION);
CSCMToolApp::Waiting(CAllPages::Cmd() + _T(" /c del /q ") + CAllPages::GetCurDir() + dir,1,NULL,NULL);
return;
}
Command += CAllPages::Cmd() + _T(" /c notepad ") + CAllPages::GetCurMFCDir() + "\\arsrep\\CReport" + date + ".txt";
CSCMToolApp::RunProcess(Command,1,NULL,NULL);
}
void Creports::OnDelars()
{
CString Command=_T("");
if(MessageBox(_T("delete all the \"Ars reports\" \n in ...\\NSCM\\arsrep ?"),_T("NSCM"),MB_ICONQUESTION|MB_YESNO)== IDNO) return;
Command += CAllPages::Cmd() + _T(" /c del /q ");
Command += CAllPages::GetCurDir() + _T("\\arsrep\\*.*");
CSCMToolApp::RunProcess(Command,1,NULL,NULL);
}
void Creports::OnDelchls()
{
CString Command=_T("");
if(MessageBox(_T("delete all the \"Changelist reports\" \n in ...\\NSCM\\chrep ?"),_T("NSCM"),MB_ICONQUESTION|MB_YESNO)== IDNO) return;
Command += CAllPages::Cmd() + _T(" /c del /q ");
Command += CAllPages::GetCurDir() + _T("\\chrep\\*.*");
CSCMToolApp::RunProcess(Command,1,NULL,NULL);
}
Creports::~Creports()
{
if (::IsWindow(m_hWnd))
{
m_ToolTipCtl->DelTool(&m_Print);
m_ToolTipCtl->DelTool(&m_Print2);
m_ToolTipCtl->DelTool(&m_Synch);
m_ToolTipCtl->DelTool(&m_Delete);
m_ToolTipCtl->DelTool(&m_DelArs);
m_ToolTipCtl->DelTool(&m_UnSync);
m_ToolTipCtl->DelTool(&m_UnSubmit);
delete m_ToolTipCtl;
}
}
void Creports::OnPrint1()
{
int Count = m_Submit.GetCount( );
if(Count == 0)
{
MessageBox(_T("You Have to click on the <Submitted ChangeLists> button first!!"),_T("NSCM"),MB_ICONWARNING);
return;
}
if(!Print(&m_Submit,_T("\\chrep\\SubmitChange.txt")))
MessageBox(_T("Please, Choose the changelists you want to print"));
}
void Creports::OnPrint2()
{
int Count = m_Pending.GetCount( );
if(Count == 0)
{
MessageBox(_T("You Have to click on the <Pending ChangeLists> button first!!"),_T("NSCM"),MB_ICONWARNING);
return;
}
if(!Print(&m_Pending,_T("\\chrep\\PendingChange.txt")))
MessageBox(_T("Please, Choose the changelists you want to print"),_T("NSCM"),MB_ICONWARNING);
}
BOOL Creports::Print(CListBox *icontrol,CString FileName)
{
int Count=0,SelCount=0;
CString changlst=_T(""),list=_T(""),Command=_T("");
Count = icontrol->GetCount( );//Count = Number of Items in the ListBox
if(SelCount = icontrol->GetSelCount( )) //SelCount = Number of the selected Items
{
int *data=NULL;
data = new int[BUFFER_SIZE];
icontrol->GetSelItems(Count, data );
for(int i=0;i < SelCount;i++)
{
icontrol->GetText(data[i], changlst );
list += changlst + _T("\r\n");
changlst.Empty();
}
delete [] data;
}
else
{
return(0);
}
CString dir = CAllPages::GetCurMFCDir() + FileName;//"\\chrep\\SubmitChange.txt";
TCHAR* pFileName = dir.GetBuffer(0);
DWORD dwCount = list.GetLength();
#ifdef _UNICODE
char* CharBuff = new char[list.GetLength()+1];
WideCharToMultiByte(CP_ACP, 0, list, -1, CharBuff, list.GetLength()+1, NULL, NULL);
#else
char* CharBuff = list.GetBuffer(0);
#endif
CFile file;
CFileException e;
file.Open( pFileName, CFile::modeCreate | CFile::modeWrite , &e );
file.WriteHuge(CharBuff, dwCount);
file.Close();
delete CharBuff;
Command = _T("notepad /p ") + dir;
CSCMToolApp::Waiting(Command,1,NULL,NULL);
file.Remove(pFileName);
return TRUE;
}
void Creports::OnDblclkSubmitted()
{
OnDblclk(&m_Submit);
}
void Creports::OnDblclkPending()
{
OnDblclk(&m_Pending);
}
void Creports::OnDblclk(CListBox *control)
{
CString Command=_T(""),Change=_T("");
int m_Sel = control->GetCurSel();
control->GetText(m_Sel,Change);
int i = Change.Find(_T(" on "));
if(i==(-1)) return;
Change = Change.Left(i);
CString dir = _T("\\TempTxt\\description.txt");
Command = CAllPages::rep(_T("-fdsc")) + Change + _T(" > ") + CAllPages::GetCurDir() + dir;
CSCMToolApp::Waiting(Command,1,NULL,NULL);
Command.Empty();
Command = CAllPages::Cmd() + _T(" /c notepad ") + CAllPages::GetCurMFCDir() +dir;
CSCMToolApp::Waiting(Command,1,NULL,NULL);
Command.Empty();
Command = CAllPages::Cmd() + _T(" /c del /q ") + CAllPages::GetCurDir() + dir;
CSCMToolApp::Waiting(Command,1,NULL,NULL);
}
void Creports::OnSynch()
{
CString Command=_T(""),Buf=_T("");
CString ChangeList=_T("");
ChangeList = CAllPages::GetChangeList(&m_Submit);
if(ChangeList.IsEmpty())
{
MessageBox(_T("You have to choose changelist first!"),_T("NSCM"),MB_ICONWARNING);
return;
}
CString dir = _T("\\TempTxt\\synch.txt");
Command = CAllPages::rep(_T("-msynch ")) + ChangeList ;
Command += _T(" > ") + CAllPages::GetCurDir() + dir;
CSCMToolApp::Waiting(Command,1,NULL,NULL);
TCHAR* pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
MessageBox(Buf,_T("NSCM"),MB_ICONWARNING);
}
void Creports::OnUserReport()
{
m_RepType = 1;
UpdateData(FALSE);
int place = m_By.FindString(-1,_T("ARS"));
m_By.DeleteString(place);
place = m_By.FindString(-1,_T("ABY"));
m_By.DeleteString(place);
place = m_By.FindString(-1,_T("ChangeList"));
m_By.DeleteString(place);
m_By.EnableWindow(TRUE);
m_Users.EnableWindow(TRUE);
}
void Creports::OnRegReport()
{
m_By.InsertString(-1,_T("ARS")); //The String added to the end of the list
m_By.InsertString(-1,_T("ABY"));
m_By.InsertString(-1,_T("ChangeList"));
OnCheck();
}
void Creports::OnContextMenu(CWnd* pWnd, CPoint point)
{
//******* submenu in the submit ListBox*******
int SelCount = m_Submit.GetSelCount( );
CRect Item_rect,List_rect;
int Count=0,*data=NULL,yes=0,i=-1;
CPoint selpoint;
CPoint Listpoint;
if(LB_ERR != SelCount) //if something was selected
{
data = new int[256];
Count = m_Submit.GetCount();
m_Submit.GetSelItems(Count,data);
do
{
i++;
m_Submit.GetItemRect( data[i] , &Item_rect );
m_Submit.GetWindowRect( List_rect );
//CPoint selpoint;
Listpoint = List_rect.TopLeft();
selpoint.x = point.x - Listpoint.x; // relative to the list-box
selpoint.y = point.y - Listpoint.y;
yes = Item_rect.PtInRect(selpoint);
}
while(!yes && i <= SelCount);
delete [] data;
if(yes) //if user put the point on a selected sel
{
CMenu menu;
VERIFY(menu.LoadMenu(IDR_CHANG_MENU));
menu.DeleteMenu(ID_POPUP_PDESCRIB,MF_BYCOMMAND); //delete the pending describe
// menu.DeleteMenu(ID_POPUP_REOPEN,MF_BYCOMMAND); //delete the reopen command
menu.DeleteMenu(ID_POPUP_CONFIRM,MF_BYCOMMAND); //delete the Confirm command
menu.DeleteMenu(ID_POPUP_DISCONFIRM,MF_BYCOMMAND); //delete the DisConfirm command
if(SelCount != 1) //can't describe more than one changelist
{
menu.EnableMenuItem(ID_POPUP_SDESCRIB,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
}
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
CWnd* pWndPopupOwner = this;
pPopup->TrackPopupMenu(TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner);
return;
}
}
// *******submenu in the pending ListBox************
SelCount = m_Pending.GetSelCount( );
i=-1;
if(LB_ERR != SelCount) //if somthing was selected
{
data = new int[256];
Count = m_Pending.GetCount();
m_Pending.GetSelItems(Count,data);
do
{
i++;
m_Pending.GetItemRect( data[i] , &Item_rect );
m_Pending.GetWindowRect( List_rect );
//CPoint selpoint;
Listpoint = List_rect.TopLeft();
selpoint.x = point.x - Listpoint.x; // relative to the list-box
selpoint.y = point.y - Listpoint.y;
yes = Item_rect.PtInRect(selpoint);
}
while(!yes && i <= SelCount);
delete [] data;
if(yes)
{
int place = -1;
CMenu menu;
VERIFY(menu.LoadMenu(IDR_CHANG_MENU));
menu.DeleteMenu(ID_POPUP_CHSYNC,MF_BYCOMMAND);//no sync to pending changelist
menu.DeleteMenu(ID_POPUP_SDESCRIB,MF_BYCOMMAND);
if(SelCount == 1) //if select default there is no descibe
{
place = m_Pending.GetCurSel();
CString change=_T("");
m_Pending.GetText(place,change);
place = change.Find(_T("default by"));
if(place > -1)
{
menu.EnableMenuItem(ID_POPUP_CONFIRM,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
menu.EnableMenuItem(ID_POPUP_DISCONFIRM,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
}
}
if(SelCount != 1 || place != -1)
menu.EnableMenuItem(ID_POPUP_PDESCRIB,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
//************Submit by Reopen**********
/* if (!m_Reopen.IsWindowVisible() || place != -1 || SelCount !=1)
menu.DeleteMenu(ID_POPUP_REOPEN,MF_BYCOMMAND);
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
CWnd* pWndPopupOwner = this;
pPopup->TrackPopupMenu(TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner);
return;*/
}
}
// *******submenu in the Group ListBox************
CString By=_T("");
int place = m_By.GetCurSel();
m_By.GetLBText(place,By);
if(By == "Groups")
{
SelCount = m_Users.GetSelCount();
if(1 == SelCount) //if only one group was selected
{
i = m_Users.GetCurSel();
m_Users.GetItemRect( i , &Item_rect );
m_Users.GetWindowRect( List_rect );
Listpoint = List_rect.TopLeft();
selpoint.x = point.x - Listpoint.x; // relative to the list-box
selpoint.y = point.y - Listpoint.y;
yes = Item_rect.PtInRect(selpoint);
if(yes)
{
CMenu menu;
VERIFY(menu.LoadMenu(IDR_GROUP_MENU));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
CWnd* pWndPopupOwner = this;
pPopup->TrackPopupMenu(TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner);
return;
}
}
}
}
void Creports::OnPopupChsync()
{
OnSynch();
}
void Creports::OnPopupChrep()
{
OnNotped();
}
void Creports::OnPopupArsrep()
{
OnNotped2();
}
void Creports::OnPopupPrint()
{
OnPrint1();
}
/*void Creports::OnPopupReopen()
{
// TODO: Add your command handler code here
// OnReopen();
}
*/
/*void Creports::OnReopen()
{
// TODO: Add your control notification handler code here
int data[1];
CString Buff=_T(""),ChangeNum=_T("");
m_Pending.GetSelItems(1, data );
m_Pending.GetText( data[0], Buff );
int place = Buff.Find(_T(" on "));
if(place == -1) return;
ChangeNum = Buff.Left(place);
ChangeNum.TrimLeft();
ChangeNum.TrimRight();
CString Command = CAllPages::Cmd() + _T(" /c \\\\Italia\\ELITE\\Util\\passchanges\\pass-changes.exe ") + ChangeNum + _T(" > ") + CAllPages::GetCurDir() + _T("\\TempTxt\\psch.txt");
CSCMToolApp::Waiting(Command,1,NULL,NULL);
CString Buf=_T(""),dir = _T("\\TempTxt\\psch.txt");
TCHAR* pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
int error = Buf.Find(_T("***ERROR***"));
if(error != -1) //if there is an error
{
MessageBox(Buf.Mid(error + 11),_T("NSCM"), MB_ICONERROR);
return;
}
else
{
int find = Buf.Find(_T("Now you can submit your changes from change #:"));
MessageBox( Buf.Mid(find),_T("NSCM"),MB_ICONINFORMATION);
return;
}
}
*/
void Creports::OnSelchangePending()
{
// TODO: Add your control notification handler code here
if (!m_Pending.IsWindowVisible())
return;
int SelCount = m_Pending.GetSelCount();
/* if (SelCount != 1)
{
m_Reopen.EnableWindow(FALSE);
return;
}
int place = m_Pending.GetCurSel();
CString change=_T("");
m_Pending.GetText(place,change);
place = change.Find(_T("default by"));
if (place != -1)
{
m_Reopen.EnableWindow(FALSE);
return;
}
m_Reopen.EnableWindow(TRUE);*/
}
void Creports::OnPopupSdescrib()
{
OnDblclkSubmitted();
}
void Creports::OnPopupPdescrib()
{
OnDblclkPending();
}
void Creports::OnSelectstringp()
{
if(!m_CheckPsearch.GetCheck())
m_SearchPString.EnableWindow(FALSE);
else
m_SearchPString.EnableWindow(TRUE);
}
void Creports::OnSelectstrings()
{
if(!m_CheckSsearch.GetCheck())
m_SearchSString.EnableWindow(FALSE);
else
m_SearchSString.EnableWindow(TRUE);
}
void Creports::OnDescribeGroup()
{
CString Group=_T(""),Buf=_T(""),dir=_T("");
dir = _T("\\TempTxt\\Group.txt");
int select=0;
select = m_Users.GetCurSel();
m_Users.GetText(select,Group);
CString Command = CAllPages::rep(_T("-gdsc")) + Group;
Command += _T(" > ") + CAllPages::GetCurDir() + dir;
CSCMToolApp::Waiting(Command,1,NULL,NULL);
Command = CAllPages::Cmd() + _T(" /c notepad ") + CAllPages::GetCurMFCDir() + dir;
CSCMToolApp::RunProcess(Command,1,NULL,NULL);
}
void Creports::OnDblclkGroup()
{
CString By=_T("");
int place = m_By.GetCurSel();
m_By.GetLBText(place,By);
if((By == "Groups")||(By == "Users & Groups"))
{
int SelCount = m_Users.GetSelCount();
if(1 == SelCount) //if only one group was selected
{
OnDescribeGroup();
}
}
}
void Creports::OnUnsynch()
{
CString Command=_T(""),Buf;
CString ChangeList=_T("");
if(1==(m_Submit.GetSelCount()))
{
ChangeList = CAllPages::GetChangeList(&m_Submit);
CString dir = _T("\\TempTxt\\unsynch.txt");
Command = CAllPages::rep(_T("-unsynch")) + ChangeList ;
Command += _T(" > ") + CAllPages::GetCurDir() + dir;
CSCMToolApp::Waiting(Command,1,NULL,NULL);
TCHAR* pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
MessageBox(Buf,_T("NSCM"),MB_ICONWARNING);
}
else
MessageBox(_T("You have to choose only one changelist"),_T("NSCM"),MB_ICONWARNING);
}
void Creports::OnIntegrate()
{
CString Slist=_T(""),Command=_T("");
Slist = CAllPages::GetChangeList(&m_Submit);
if(Slist.IsEmpty()) //if no submit changelist have been chosen
{
MessageBox(_T("Choose submitted ChangeList you want to integrate!!"),_T("NSCM"),MB_ICONWARNING);
return;
}
CString dir = CAllPages::GetCurMFCDir() + _T("\\TempTxt\\List.txt");
TCHAR* pFileName = dir.GetBuffer(0);
#ifdef _UNICODE
char* CharBuff = new char[Slist.GetLength()+1];
WideCharToMultiByte(CP_ACP, 0, Slist, -1, CharBuff, Slist.GetLength()+1, NULL, NULL);
#else
char* CharBuff = Slist.GetBuffer(0);
#endif
CFile file;
CFileException e;
file.Open( pFileName, CFile::modeCreate | CFile::modeWrite , &e );
file.Write(CharBuff,strlen(CharBuff));
file.Close();
#ifdef _UNICODE
delete CharBuff;
#endif
Integrate Dlg(this);
int nResponse = Dlg.DoModal();
if (nResponse == IDOK)
{
}
if (nResponse == IDCANCEL)
{
return;
}
}
void Creports::OnConfirm()
{
CString Plist=_T(""),LineMessage=_T(""),Item=_T(""),Command=_T(""),Buf=_T("");
int SelCount = m_Pending.GetSelCount( ); //SelCount = Number of the selected Item
int Count = m_Pending.GetCount( );
int *data = new int[Count];
m_Pending.GetSelItems(Count, data );
Plist = CAllPages::GetChangeList(&m_Pending);
if(Plist.IsEmpty()) //if no submit changelist have been chosen
{
MessageBox(_T("Choose Pending ChangeList you want to confirm!!"),_T("NSCM"),MB_ICONWARNING);
return;
}
CString dir = _T("\\TempTxt\\PList.txt");
TCHAR* pFileName = dir.GetBuffer(0);
Command = CAllPages::Cmd() + _T(" /c p4trig -confirm ") + Plist + _T(" > ") + CAllPages::GetCurDir() + dir;
CSCMToolApp::Waiting(Command,1,NULL,NULL);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
CString TBuf = Buf;
for (int i=0;i<SelCount;i++)
{
int newline = TBuf.Find(_T("\n"));
if(newline==1)
{
TBuf = TBuf.Mid(newline+1);
newline = TBuf.Find(_T("\n"));
}
LineMessage = TBuf.Left(newline);
TBuf = TBuf.Mid(newline+1);
int ignore = LineMessage.Find(_T("Ignored"));
if(ignore == -1)
{
m_Pending.GetText(data[i],Item );
m_Pending.DeleteString( data[i]);
m_Pending.InsertString( data[i], Item , RGB(255,0,0));
}
}
MessageBox(Buf,_T("NSCM"),MB_ICONINFORMATION);
delete[] data;
}
void Creports::OnPopupConfirm()
{
OnConfirm();
}
void Creports::OnPopupDisconfirm()
{
CString Plist=_T(""),LineMessage=_T(""),Item=_T(""),Command=_T(""),Buf=_T("");
int SelCount = m_Pending.GetSelCount( ); //SelCount = Number of the selected Item
int Count = m_Pending.GetCount( );
int *data = new int[Count];
m_Pending.GetSelItems(Count, data );
Plist = CAllPages::GetChangeList(&m_Pending);
if(Plist.IsEmpty()) //if no submit changelist have been chosen
{
MessageBox(_T("Choose Pending ChangeList you want to disconfirm!!"),_T("NSCM"),MB_ICONWARNING);
return;
}
CString dir = _T("\\TempTxt\\PList.txt");
TCHAR* pFileName = dir.GetBuffer(0);
Command = CAllPages::Cmd() + _T(" /c p4trig -disconfirm ") + Plist + _T(" > ") + CAllPages::GetCurDir() + dir;
CSCMToolApp::Waiting(Command,1,NULL,NULL);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
CString TBuf = Buf;
for (int i=0;i<SelCount;i++)
{
int newline = TBuf.Find(_T("\n"));
if(newline==1)
{
TBuf = TBuf.Mid(newline+1);
newline = TBuf.Find(_T("\n"));
}
LineMessage = TBuf.Left(newline);
TBuf = TBuf.Mid(newline+1);
int ignore = LineMessage.Find(_T("Ignored"));
if(ignore == -1)
{
m_Pending.GetText(data[i],Item );
m_Pending.DeleteString( data[i]);
m_Pending.InsertString( data[i], Item , RGB(0,0,0));
}
}
MessageBox(Buf,_T("NSCM"),MB_ICONINFORMATION);
delete[] data;
}
void Creports::OnRevert()
{
CString Plist=_T(""),Command=_T(""),Buf=_T("");
int SelCount = m_Pending.GetSelCount( ); //SelCount = Number of the selected Item
int Count = m_Pending.GetCount( );
int *data = new int[Count];
m_Pending.GetSelItems(Count, data );
Plist = CAllPages::GetChangeList(&m_Pending);
if(Plist.IsEmpty()) //if no submit changelist have been chosen
{
MessageBox(_T("Choose Pending ChangeList First!!"),_T("NSCM"),MB_ICONWARNING);
return;
}
CString dir = _T("\\TempTxt\\PList.txt");
TCHAR* pFileName = dir.GetBuffer(0);
Command = CAllPages::rep(_T("-rdf")) + Plist + _T(" > ") + CAllPages::GetCurDir() + dir;
CSCMToolApp::Waiting(Command,1,NULL,NULL);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
MessageBox(Buf,_T("NSCM"),MB_ICONINFORMATION);
delete[] data;
}
void Creports::OnResolve()
{
CString Plist=_T(""),Command=_T(""),Buf=_T("");
int SelCount = m_Pending.GetSelCount( ); //SelCount = Number of the selected Item
int Count = m_Pending.GetCount( );
int *data = new int[Count];
m_Pending.GetSelItems(Count, data );
Plist = CAllPages::GetChangeList(&m_Pending);
if(Plist.IsEmpty()) //if no submit changelist have been chosen
{
MessageBox(_T("Choose Pending ChangeList First!!"),_T("NSCM"),MB_ICONWARNING);
return;
}
CString dir = _T("\\TempTxt\\PList.txt");
TCHAR* pFileName = dir.GetBuffer(0);
Command = CAllPages::rep(_T("-res")) + Plist + _T(" > ") + CAllPages::GetCurDir() + dir;
CSCMToolApp::Waiting(Command,1,NULL,NULL);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
MessageBox(Buf,_T("NSCM"),MB_ICONINFORMATION);
delete[] data;
}
void Creports::OnUnsubmit()
{
CString Message = _T("\nBeware if some of the files that you want to unsubmit are in a pending changelist \nthey won't be unsubmitted!!!\nDo you want to continue?");
if(MessageBox(Message,_T("NSCM"),MB_ICONWARNING|MB_YESNO) == IDNO) return;
CString Command=_T(""),Buf;
CString ChangeList=_T("");
if(1==(m_Submit.GetSelCount()))
{
ChangeList = CAllPages::GetChangeList(&m_Submit);
CString dir = _T("\\TempTxt\\unsubmit.txt");
Command = CAllPages::rep(_T("-unsub")) + ChangeList ;
Command += _T(" 2> ") + CAllPages::GetCurDir() + dir;
CSCMToolApp::Waiting(Command,1,NULL,NULL);
TCHAR* pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
MessageBox(Buf,_T("NSCM"),MB_ICONWARNING);
int n = Buf.Find(_T("failed"));
if( n == -1 )
{
if (MessageBox(_T("Do you want to Submit the New ChangeList Now?"),_T("NSCM"),MB_ICONQUESTION|MB_YESNO)==IDNO)
{
}
else
{
int index = Buf.FindOneOf( _T("0123456789") );
Buf = Buf.Mid(index);
int j = Buf.Find(_T(" "));
CString ChNum = Buf.Mid(0,j);
dir = "\\TempTxt\\ChNum.txt";
Command = CAllPages::Cmd() + " /c p4 submit -c " + ChNum + " 2> " + CAllPages::GetCurDir() + dir; ;
CSCMToolApp::Waiting(Command,1,NULL,NULL);
pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
int i = Buf.Find(_T("failed"));
int k = Buf.Find(_T("unknown"));
if(i > -1 || k > -1 )
{
MessageBox(Buf,_T("NSCM"),MB_ICONWARNING);
CDialog::OnOK();
}
else
{
MessageBox(_T("Submit finished Successfully"),_T("NSCM"),MB_ICONWARNING);
}
}
}
else
CDialog::OnOK();
}
else
MessageBox(_T("You have to choose only one changelist"),_T("NSCM"),MB_ICONWARNING);
}
void Creports::OnSearchconf()
{
if(m_CheckConf.GetCheck())
{
ConfCut Dlg(this);
int nResponse = Dlg.DoModal();
if (nResponse == IDOK)
{
}
if (nResponse == IDCANCEL)
{
return;
}
}
}
void Creports::OnAutointg()
{
CString Command=_T("");
CString ChangeList=_T("");
ChangeList = CAllPages::GetChangeList(&m_Submit);
if(ChangeList.IsEmpty())
{
MessageBox(_T("You have to choose changelist first!"),_T("NSCM"),MB_ICONWARNING);
return;
}
if(ChangeList.GetLength()>9)
{
MessageBox(_T("You have to choose only ONE changelist!"),_T("NSCM"),MB_ICONWARNING);
return;
}
Command = CAllPages::rep(_T("-autointg ")) + ChangeList ;
CSCMToolApp::Waiting(Command,1,NULL,NULL);
}