.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Windows Application >> Post New QuestionBookmark and Share Subscribe to Forum

Validation between to Calendar

Posted By: kamlesh     Posted Date: February 01, 2011    Points:2   Category :Windows Application
Hi

I have created One Application in C#.Net (Windows Appplication) and i have take two calendar drop down
1st is Start Date and 2nd is End Date While searching between start Date and End Date if user can enter the less date in end Date Box than Start Date So it should show the validation..

how it is possible please help me ..

Thanks and Regards

Kamlesh Nikam

Responses
Author: Blessy Baby             
Posted Date: February 01, 2011     Points: 5   

Hi,

Please check http://www.dotnetspider.com/forum/111357-Date-validation-windows-application.aspx

Blessy Baby
Project Lead
Digitalmesh Softech India (p) Limited
Cochin,Kerala
Author: kamlesh             
Posted Date: March 15, 2011     Points: 20   

public static string GetRouteFolderName(Int64 SubFilderID)
{
SqlConnection Conn;
string RouteFolderName = "";
try
{

Conn = new SqlConnection(Common.ConnectionString);
Conn.Open();
SqlCommand sqlCmd = new SqlCommand("GetRouteFolderbyRouteFolderId", Conn);
sqlCmd.CommandType = CommandType.StoredProcedure;

sqlCmd.Parameters.Add(new SqlParameter("@SubFolderId", SqlDbType.Int));
sqlCmd.Parameters["@SubFolderId"].Value = SubFilderID;



SqlDataAdapter da = new SqlDataAdapter(sqlCmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
RouteFolderName = Convert.ToString(dt.Rows[0]["RouteFolderName"]);
}
Conn.Close();
sqlCmd.Dispose();
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
clsError.LogError(ex);
}

return RouteFolderName;

}


public static List<MailSubFolderDTO> GetSubNodeList(DataTable dt2, int RouteFolderId, int ParentId)
{
DataRow[] dataRows;
List<MailSubFolderDTO> SubNodeList = new List<MailSubFolderDTO>();
dataRows = dt2.Select("RouteFolderID=" + RouteFolderId + " and ParentId=" + ParentId.ToString());
foreach (DataRow dr in dataRows)
{
MailSubFolderDTO SubFolderDTO = new MailSubFolderDTO();
SubFolderDTO.ID = Convert.ToInt32(dr["ID"]);
SubFolderDTO.Name = Convert.ToString(dr["Name"]);
SubFolderDTO.Lavel = Convert.ToInt32(dr["Lavel"]);
SubFolderDTO.ParentId = Convert.ToInt32(dr["ParentId"]);
SubFolderDTO.RouteFolderID = Convert.ToInt32(dr["RouteFolderID"]);
SubFolderDTO.HasChildNode = Convert.ToBoolean(dr["HasChildNode"]);
if (SubFolderDTO.HasChildNode)
SubFolderDTO.ChieldNodeList = GetSubNodeList(dt2, RouteFolderId, SubFolderDTO.ID);
SubNodeList.Add(SubFolderDTO);
}
return SubNodeList;
}



public static MailRouteFolderDTO IsRouteFolderExists(MailRouteFolderDTO RouteFolderDTO)
{
SqlConnection Conn;
try
{

Conn = new SqlConnection(Common.ConnectionString);
Conn.Open();
SqlCommand sqlCmd = new SqlCommand("IsRouteFolderExists", Conn);
sqlCmd.CommandType = CommandType.StoredProcedure;

sqlCmd.Parameters.Add(new SqlParameter("@RouteFolderName", SqlDbType.VarChar));
sqlCmd.Parameters["@RouteFolderName"].Value = RouteFolderDTO.Name;


SqlDataAdapter da = new SqlDataAdapter(sqlCmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
RouteFolderDTO.ID = Convert.ToInt32(dt.Rows[0]["ID"]);
}
Conn.Close();
sqlCmd.Dispose();
}
catch (Exception ex)
{
// MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
clsError.LogError(ex);
}

return RouteFolderDTO;

}



public static MailSubFolderDTO IsSubFolderExists(MailSubFolderDTO SubFolderDTO)
{
SqlConnection Conn;
try
{

Conn = new SqlConnection(Common.ConnectionString);
Conn.Open();
SqlCommand sqlCmd = new SqlCommand("IsSubFolderExists", Conn);
sqlCmd.CommandType = CommandType.StoredProcedure;

sqlCmd.Parameters.Add(new SqlParameter("@SubFolderName", SqlDbType.VarChar));
sqlCmd.Parameters["@SubFolderName"].Value = SubFolderDTO.Name;

sqlCmd.Parameters.Add(new SqlParameter("@RouteFolderID", SqlDbType.Int));
sqlCmd.Parameters["@RouteFolderID"].Value = SubFolderDTO.RouteFolderID;

SqlDataAdapter da = new SqlDataAdapter(sqlCmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
SubFolderDTO.ID = Convert.ToInt32(dt.Rows[0]["ID"]);
}
Conn.Close();
sqlCmd.Dispose();
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
clsError.LogError(ex);
}

return SubFolderDTO;

}



public static MailDetailDTO SaveMail(MailDetailDTO MailDetail)
{
SqlConnection Conn;
try
{
Conn = new SqlConnection(Common.ConnectionString);
Conn.Open();
SqlCommand sqlCmd = new SqlCommand("SaveMail", Conn);
sqlCmd.CommandType = CommandType.StoredProcedure;

sqlCmd.Parameters.Add(new SqlParameter("@RouteFolderID", SqlDbType.Int));
sqlCmd.Parameters["@RouteFolderID"].Value = MailDetail.RouteFolderId;

sqlCmd.Parameters.Add(new SqlParameter("@SubFolderId", SqlDbType.Int));
sqlCmd.Parameters["@SubFolderId"].Value = MailDetail.SubFolderId;

sqlCmd.Parameters.Add(new SqlParameter("@MailFrom", SqlDbType.VarChar));
sqlCmd.Parameters["@MailFrom"].Value = Convert.ToString(MailDetail.MailFrom);

sqlCmd.Parameters.Add(new SqlParameter("@MailTo", SqlDbType.VarChar));
sqlCmd.Parameters["@MailTo"].Value = Convert.ToString(MailDetail.MailTo);


sqlCmd.Parameters.Add(new SqlParameter("@MailCc", SqlDbType.VarChar));
sqlCmd.Parameters["@MailCc"].Value = Convert.ToString(MailDetail.MailCc);


sqlCmd.Parameters.Add(new SqlParameter("@MailBcc", SqlDbType.VarChar));
sqlCmd.Parameters["@MailBcc"].Value = Convert.ToString(MailDetail.MailBcc);
//if (sqlCmd.Parameters["@MailBcc"].Value == null)
// sqlCmd.Parameters["@MailBcc"].Value = string.Empty;

sqlCmd.Parameters.Add(new SqlParameter("@MailSubject", SqlDbType.VarChar));
sqlCmd.Parameters["@MailSubject"].Value = Convert.ToString(MailDetail.MailSubject);


sqlCmd.Parameters.Add(new SqlParameter("@MailBody", SqlDbType.VarChar));
sqlCmd.Parameters["@MailBody"].Value = Convert.ToString(MailDetail.MailBody);

sqlCmd.Parameters.Add(new SqlParameter("@MailDate", SqlDbType.DateTime));
sqlCmd.Parameters["@MailDate"].Value = MailDetail.MailDate;


sqlCmd.Parameters.Add(new SqlParameter("@MailSize", SqlDbType.Int));
sqlCmd.Parameters["@MailSize"].Value = MailDetail.MailSize;

sqlCmd.Parameters.Add(new SqlParameter("@HasAttechment", SqlDbType.Bit));
sqlCmd.Parameters["@HasAttechment"].Value = MailDetail.HasAttechment;

sqlCmd.Parameters.Add(new SqlParameter("@MailBodyPlain", SqlDbType.NVarChar));
sqlCmd.Parameters["@MailBodyPlain"].Value = Convert.ToString(MailDetail.MailBodyNew);

//sqlCmd.Parameters.Add(new SqlParameter("@htmlEditor1", SqlDbType.Bit));
//sqlCmd.Parameters["@htmlEditor1"].Value = MailDetail.htmlEditor1;



SqlDataAdapter da = new SqlDataAdapter(sqlCmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
MailDetail.ID = Convert.ToInt32(dt.Rows[0]["ID"]);
}
Conn.Close();
sqlCmd.Dispose();
}
catch (Exception ex)
{

// MessageBox.Show("Exception caught in SaveMail." + ex.Message,"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
clsError.LogError(ex);
}

return MailDetail;

}



public static MailRouteFolderDTO SaveRouteFolder(MailRouteFolderDTO RouteFolderDTO)
{
SqlConnection Conn;
try
{

Conn = new SqlConnection(Common.ConnectionString);
Conn.Open();
SqlCommand sqlCmd = new SqlCommand("SaveMailRouteFolder", Conn);
sqlCmd.CommandType = CommandType.StoredProcedure;

sqlCmd.Parameters.Add(new SqlParameter("@Name", SqlDbType.VarChar));
sqlCmd.Parameters["@Name"].Value = RouteFolderDTO.Name;


SqlDataAdapter da = new SqlDataAdapter(sqlCmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
RouteFolderDTO.ID = Convert.ToInt32(dt.Rows[0]["ID"]);
}
Conn.Close();
sqlCmd.Dispose();
}
catch (Exception ex)
{

// MessageBox.Show("Exception caught in SaveMail." + ex.Message,"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
clsError.LogError(ex);
}

return RouteFolderDTO;

}



public static MailSubFolderDTO SaveSubFolder(MailSubFolderDTO RouteFolderDTO)
{
SqlConnection Conn;
try
{

Conn = new SqlConnection(Common.ConnectionString);
Conn.Open();
SqlCommand sqlCmd = new SqlCommand("SaveMailSubFolder", Conn);
sqlCmd.CommandType = CommandType.StoredProcedure;

sqlCmd.Parameters.Add(new SqlParameter("@Name", SqlDbType.VarChar));
sqlCmd.Parameters["@Name"].Value = RouteFolderDTO.Name;

sqlCmd.Parameters.Add(new SqlParameter("@RouteFolderID", SqlDbType.Int));
sqlCmd.Parameters["@RouteFolderID"].Value = RouteFolderDTO.RouteFolderID;

sqlCmd.Parameters.Add(new SqlParameter("@Lavel", SqlDbType.Int));
sqlCmd.Parameters["@Lavel"].Value = RouteFolderDTO.Lavel;

sqlCmd.Parameters.Add(new SqlParameter("@ParentId", SqlDbType.Int));
sqlCmd.Parameters["@ParentId"].Value = RouteFolderDTO.ParentId;

sqlCmd.Parameters.Add(new SqlParameter("@HasChildNode", SqlDbType.Bit));
sqlCmd.Parameters["@HasChildNode"].Value = RouteFolderDTO.HasChildNode;


SqlDataAdapter da = new SqlDataAdapter(sqlCmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
RouteFolderDTO.ID = Convert.ToInt32(dt.Rows[0]["ID"]);
}
Conn.Close();
sqlCmd.Dispose();
}
catch (Exception ex)
{

// MessageBox.Show("Exception caught in SaveMail." + ex.Message,"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
clsError.LogError(ex);
}

return RouteFolderDTO;

}


public static List<MailNodesDTO> GetNodeList()
{
SqlConnection Conn;
List<MailNodesDTO> NodeList = new List<MailNodesDTO>();

try
{

Conn = new SqlConnection(Common.ConnectionString);
Conn.Open();
SqlCommand sqlCmd = new SqlCommand("GetAllNodes", Conn);
sqlCmd.CommandType = CommandType.StoredProcedure;


SqlDataAdapter da = new SqlDataAdapter(sqlCmd);
DataSet ds = new DataSet();
DataTable dt1 = new DataTable();
DataTable dt2 = new DataTable();
DataRow[] dataRows;
da.Fill(ds);
Conn.Close();
sqlCmd.Dispose();
dt1 = ds.Tables[0];
dt2 = ds.Tables[1];

for (int i = 0; i < dt1.Rows.Count; i++)
{
MailNodesDTO NodeDTO = new MailNodesDTO();

NodeDTO.RouteFolder.ID = Convert.ToInt32(dt1.Rows[i]["ID"]);
NodeDTO.RouteFolder.Name = Convert.ToString(dt1.Rows[i]["Name"]);
dataRows = dt2.Select("RouteFolderID=" + NodeDTO.RouteFolder.ID + " and Lavel=1");
foreach (DataRow dr in dataRows)
{
MailSubFolderDTO SubFolderDTO = new MailSubFolderDTO();
SubFolderDTO.ID = Convert.ToInt32(dr["ID"]);
SubFolderDTO.Name = Convert.ToString(dr["Name"]);
SubFolderDTO.Lavel = Convert.ToInt32(dr["Lavel"]);
SubFolderDTO.ParentId = Convert.ToInt32(dr["ParentId"]);
SubFolderDTO.RouteFolderID = Convert.ToInt32(dr["RouteFolderID"]);
SubFolderDTO.HasChildNode = Convert.ToBoolean(dr["HasChildNode"]);
if (SubFolderDTO.HasChildNode)
SubFolderDTO.ChieldNodeList = GetSubNodeList(dt2, NodeDTO.RouteFolder.ID, SubFolderDTO.ID);
NodeDTO.SubFolderDTOList.Add(SubFolderDTO);
}
NodeList.Add(NodeDTO);
}
}
catch (Exception ex)
{
// throw new Exception(ex.Message);
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
clsError.LogError(ex);
}

return NodeList;

}

Thanks And Regards.
Kamlesh Nikam
Author: kamlesh             
Posted Date: March 22, 2011     Points: 20   


//FILE LEVEL DOCUMENTATION
/*! \file frmImportExport.cs
* \brief this form will Import The PST files and EDB Files
* \author Unitrends, Inc.
* \Date Wed. 23 Feb. 2011

* \em COPYRIGHT © 2011 Unitrends, Inc.
*
* This software is furnished under a license for use only on a
* single computer system and may be copied only with the
* inclusion of the above copyright notice. This software, or any
* other copies thereof, may not be provided or otherwise made
* available to any other person except for use on such a system
* and to one who agrees to these license terms. Title to and
* ownership of the software shall at all times remain in
* Unitrends, Inc.
*
* The information in this software is subject to change without
* notice and should not be construed as a commitment by
* Unitrends, Inc.
*
* This software is provided on an "as is" basis without any warranty
* of any kind whatsoever, either expressed or implied.
* Unitrends, Inc. does not warrant the software to be error
* free, nor does it warrant that it will meet your specific requirements.
*/

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Microsoft.Office.Interop.Outlook;
using Microsoft.Office.Interop;
using System.Diagnostics;
using System.Threading;

/*!
* \namespace OutlookDemo
* \brief namespace for Handling all the Forms Which are include in the frmManager
* \Date Wed. 23 Feb. 2011
* \em COPYRIGHT © 2011 Unitrends, Inc.
*/

namespace OutlookDemo
{
/*! A CLASS */
/*! \class class frmImportExport
* \brief Used To Import The PST files and EDB Files
* \author Unitrends, Inc.
* \Date 23 Feb 2011
* \em COPYRIGHT © 2011 Unitrends, Inc.
*/

public partial class frmImportExport : DevComponents.DotNetBar.Office2007Form
{
Thread th;
static int iCount = 0;
String strSystemFilePath = string.Empty;
static string strFilePath;
static int iVersion = 0;
String strAppPath = String.Empty;
public frmImportExport()
{
InitializeComponent();
}



/*! \fn private void button_Browse_Click(object sender, EventArgs e)
* \brief constructor to Browse EDB And PST from USer
* \author Unitrends, Inc.
* \date 23 Feb 2011 *
* \em COPYRIGHT © 2011 Unitrends, Inc.
*/


private void button_Browse_Click(object sender, EventArgs e)
{
try
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); //@"c:\";

if (LB_Show_Actions.SelectedIndex == 1/* || LB_Show_Actions.SelectedIndex == 3*/)
{
openFileDialog1.Title = "Personal Folders";
//openFileDialog1.Filter = "Personal Folders Files|*.pst|All|*.*";

openFileDialog1.Filter = "Personal Folders Files|*.*";
}
else if (LB_Show_Actions.SelectedIndex == 0 /*|| LB_Show_Actions.SelectedIndex == 1*/)
{
openFileDialog1.Title = "EDB files";
//openFileDialog1.Filter = "eml Files|*.eml|All|*.*";

openFileDialog1.Filter = "EDB Files|*.*";
}
String strDir = System.Environment.CurrentDirectory;
openFileDialog1.FileName = "";
openFileDialog1.ShowDialog();
Txt_FilePath.Text = openFileDialog1.FileName;
System.Environment.CurrentDirectory = strDir;

}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
clsError.LogError(ex);
}
}

/*! \fn private void frmImportExport_Load(object sender, EventArgs e)
* \brief constructor to Load At IMPORT AND Export The Files
* \param String strBasePath
* \return no
* \author Unitrends, Inc.
* \date 23 Feb 2011 *
* \em COPYRIGHT © 2011 Unitrends, Inc.
*/

private void frmImportExport_Load(object sender, EventArgs e)
{
LB_Show_Actions.Items.Clear();
LB_Show_Actions.Items.Add("Import from EDB/STM Files");
//LB_Show_Actions.Items.Add("Export to EML");
LB_Show_Actions.Items.Add("Import from Personal Folder File (.pst)");
// LB_Show_Actions.Items.Add("Export to Personal Folder File (.pst)");
LB_Show_Actions.SelectedIndex = 0;
}

/*! \fn rivate void wizard1_FinishButtonClick(object sender, CancelEventArgs e)
* \brief constructor to Finish the Process
* \author Unitrends, Inc.
* \date 23 Feb 2011 *
* \em COPYRIGHT © 2011 Unitrends, Inc.
*/

private void wizard1_FinishButtonClick(object sender, CancelEventArgs e)
{
try
{
if (LB_Show_Actions.SelectedIndex == 1)
{
String strPSTPath = null;
if (!IsValidFilePath(ref strPSTPath))
e.Cancel = true;
else
{
th = new Thread(unused => Disp(strPSTPath));
th.IsBackground = true;
th.Start();
this.Close();
}
}
else
{
List<String> lsPathofPST;
lsPathofPST = ExportEDBToPSt();

th = new Thread(unused => Disp2(lsPathofPST));
th.IsBackground = true;
th.Start();
}
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
clsError.LogError(ex);
}
}

void Disp(String strPath)
{
ClsParser.GetRoutFolderName(strPath, "Personal Folders");
Thread.Sleep(1000);
}

void Disp2(List<String> lsPathofPST)
{
Thread.Sleep(60000);

for (int i = 0; i < lsPathofPST.Count; i++)
{
ClsParser.GetRoutFolderName(lsPathofPST[i], "Personal Folders");
}
MessageBox.Show("Finished Importing Data From EDB file", "Data Imported", MessageBoxButtons.OK, MessageBoxIcon.None);
}

/*! \fn private void wizard1_WizardPageChanging(object sender, DevComponents.DotNetBar.WizardCancelPageChangeEventArgs e)
* \brief constructor to Wizard Page Changing
* \author Unitrends, Inc.
* \date 23 Feb 2011 *
* \em COPYRIGHT © 2011 Unitrends, Inc.
*/

private void wizard1_WizardPageChanging(object sender, DevComponents.DotNetBar.WizardCancelPageChangeEventArgs e)
{
if (LB_Show_Actions.SelectedIndex == 1)
{
if (e.OldPage == wizardPage1)
{
e.NewPage = wizardPage2;
}
if (e.NewPage == wizardPage2)
{
wizardPage2.FinishButtonEnabled = DevComponents.DotNetBar.eWizardButtonState.True;
wizardPage2.NextButtonVisible = DevComponents.DotNetBar.eWizardButtonState.False;

}
else
{
wizardPage2.FinishButtonEnabled = DevComponents.DotNetBar.eWizardButtonState.False;
wizardPage2.NextButtonVisible = DevComponents.DotNetBar.eWizardButtonState.True;
}
}
else
{

//Wizard1- Choose Action.
//wizard2. -- File Path
//wizard3 --- Server detail
//wizard4 -- User Detail

if (e.OldPage == wizardPage1)
{
bool bVal = RegistryHandler.IsExchangeServer();
if (bVal == false)
{
e.NewPage = wizardPage5;
}
else
e.NewPage = wizardPage2;
}

if (e.NewPage == wizardPage5)
{
wizardPage5.FinishButtonEnabled = DevComponents.DotNetBar.eWizardButtonState.False;
wizardPage5.NextButtonVisible = DevComponents.DotNetBar.eWizardButtonState.True;
txtIpAddress.Text = "";
txtPass.Text = "";
txtUserName.Text = "";
}

if (e.OldPage == wizardPage5)
{
bool bRet = CLICaller.CheckConnection(txtIpAddress.Text, txtUserName.Text, txtPass.Text);
if (bRet == false)
{
MessageBox.Show("Invalid Information", "Access Denied", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtIpAddress.Text = "";
txtUserName.Text = "";
txtPass.Text = "";
e.NewPage = wizardPage5;
}
strAppPath = "C:\\Program Files\\Unitrends\\Exchange_Granular_Restore_Agent\\";//CLICaller.GetPath(txtUserName.Text, txtPass.Text, txtIpAddress.Text);
}

if (e.NewPage == wizardPage3)
{
String strPath = "";
wizardPage2.FinishButtonEnabled = DevComponents.DotNetBar.eWizardButtonState.False;
wizardPage2.NextButtonVisible = DevComponents.DotNetBar.eWizardButtonState.True;
if (!IsValidFilePath(ref strPath))
e.Cancel = true;
else
{
int iResult = LoadServerInformation();
if (iResult != 0)
e.Cancel = true;
}
}

if (e.NewPage == wizardPage4)
{

wizardPage2.FinishButtonEnabled = DevComponents.DotNetBar.eWizardButtonState.False;
wizardPage2.NextButtonVisible = DevComponents.DotNetBar.eWizardButtonState.True;
if (!IsSarverSelected())
e.Cancel = true;
else
{
int iResult = LoadUserInformation();
if (iResult != 0)
e.Cancel = true;

}
}
}

}

/*! \fn private bool IsValidFilePath()
* \brief constructor to is FILE Path is Valid
* \author Unitrends, Inc.
* \date 23 Feb 2011 *
* \em COPYRIGHT © 2011 Unitrends, Inc.
*/

private bool IsValidFilePath(ref String strPSTPath)
{
bool IsValid = true;

if (!System.IO.File.Exists(Txt_FilePath.Text))
{
errorProvider1.SetError(Txt_FilePath, "Invalid File Path");
IsValid = false;
}
else
{
errorProvider1.SetError(Txt_FilePath, "");

}

strPSTPath = Txt_FilePath.Text;


return IsValid;

}

/*! \fn private bool IsSarverSelected()
* \brief constructor to Is Server Selected
* \author Unitrends, Inc.
* \date 23 Feb 2011 *
* \em COPYRIGHT © 2011 Unitrends, Inc.
*/

private bool IsSarverSelected()
{
bool IsValid = true;

if (cmbServer.SelectedIndex < 0)
{
// Check Search text must be entered.

errorProvider1.SetError(cmbServer, "Server Name Required.");
IsValid = false;
}
else
{
errorProvider1.SetError(cmbServer, "");

}


return IsValid;

}

/*! \fn private void Txt_FilePath_TextChanged(object sender, EventArgs e)
* \brief constructor to Text File Path Text Changed
* \author Unitrends, Inc.
* \date 23 Feb 2011 *
* \em COPYRIGHT © 2011 Unitrends, Inc.
*/

private void Txt_FilePath_TextChanged(object sender, EventArgs e)
{
String strpath = "";
IsValidFilePath(ref strpath);
}

/*! \fn private int LoadServerInformation()
* \brief constructor to Load Server Information
* \author Unitrends, Inc.
* \date 23 Feb 2011 *
* \em COPYRIGHT © 2011 Unitrends, Inc.
*/

private int LoadServerInformation()
{
try
{
CLICaller.ListServers();
String strServerListPath = System.Environment.CurrentDirectory + "\\" + "ServerList.txt";
String[] strServerList = File.ReadAllLines(strServerListPath);
if (strServerList.Length == 0)
{
MessageBox.Show("Server Name Not Found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return 1;
}
cmbServer.DataSource = strServerList;
return 0;

}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
clsError.LogError(ex);
return 1;
}
}

/*! \fn private int LoadUserInformation()
* \brief constructor to Load USer Information
* \author Unitrends, Inc.
* \date 23 Feb 2011 *
* \em COPYRIGHT © 2011 Unitrends, Inc.
*/

private int LoadUserInformation()
{
try
{

if (txtIpAddress.Text != "")
{

String strVersion = CLICaller.GetexchangeVersion(txtIpAddress.Text,txtUserName.Text,txtPass.Text);
if (strVersion != "")
{
iVersion = 2003;
CLICaller.RunCommand(txtUserName.Text, txtPass.Text, txtIpAddress.Text, strAppPath + "ExchangeGranularCLI.exe" + " " + "\"" + "3" + "\"" + " " + "\"" + cmbServer.Text + "\"" + " " + "\"" + Txt_FilePath.Text + "\"");

}
else
{
strVersion = CLICaller.GetExchangeVersion2007(txtIpAddress.Text,txtUserName.Text, txtPass.Text);
if (strVersion != "")
{
iVersion = 2007;
CLICaller.RunCommand(txtUserName.Text, txtPass.Text, txtIpAddress.Text, strAppPath + "ExchangeCDOEXE.exe " + "\"" + "1" + "\"" + " " + "\"" + iVersion.ToString() + "\"" + " " + "\"" + cmbServer.Text + "\"" + " " + "\"" + "a" + "\"" + " " + "\"" + Txt_FilePath.Text + "\"");

CLICaller.RunCommand(txtUserName.Text, txtPass.Text, txtIpAddress.Text, strAppPath + "ExchangeCDOEXE.exe " + "\"" + "2" + "\"" + " " + "\"" + iVersion.ToString() + "\"" + " " + "\"" + cmbServer.Text + "\"" + " " + "\"" + "a" + "\"" + " " + "\"" + Txt_FilePath.Text + "\"");

CLICaller.RunCommand(txtUserName.Text, txtPass.Text, txtIpAddress.Text, strAppPath + "ExchangeCDOEXE.exe " + "\"" + "3" + "\"" + " " + "\"" + iVersion.ToString() + "\"" + " " + "\"" + cmbServer.Text + "\"" + " " + "\"" + "a" + "\"" + " " + "\"" + Txt_FilePath.Text + "\"");
}
else
{
strVersion = CLICaller.GetExchangeVersion2010(txtIpAddress.Text,txtUserName.Text, txtPass.Text);
if (strVersion != "")
{
iVersion = 2010;
CLICaller.RunCommand(txtUserName.Text, txtPass.Text, txtIpAddress.Text, strAppPath + "ExchangeCDOEXE.exe " + "\"" + "1" + "\"" + " " + "\"" + iVersion.ToString() + "\"" + " " + "\"" + cmbServer.Text + "\"" + " " + "\"" + "a" + "\"" + " " + "\"" + Txt_FilePath.Text + "\"");

CLICaller.RunCommand(txtUserName.Text, txtPass.Text, txtIpAddress.Text, strAppPath + "ExchangeCDOEXE.exe " + "\"" + "2" + "\"" + " " + "\"" + iVersion.ToString() + "\"" + " " + "\"" + cmbServer.Text + "\"" + " " + "\"" + "a" + "\"" + " " + "\"" + Txt_FilePath.Text + "\"");

CLICaller.RunCommand(txtUserName.Text, txtPass.Text, txtIpAddress.Text, strAppPath + "ExchangeCDOEXE.exe " + "\"" + "3" + "\"" + " " + "\"" + iVersion.ToString() + "\"" + " " + "\"" + cmbServer.Text + "\"" + " " + "\"" + "a" + "\"" + " " + "\"" + Txt_FilePath.Text + "\"");

}

}
}

if (iVersion == 2003)
{
CLICaller.GetDCUsersList(cmbServer.Text.Trim(), iVersion);
}
else
{
//CLICaller.RunCommand(txtUserName.Text, txtPass.Text, txtIpAddress.Text, "C:\\Test\\ExchangeGranularCLI.exe 4 " + cmbServer.Text + " 0");
CLICaller.RunCommand(txtUserName.Text, txtPass.Text, txtIpAddress.Text, strAppPath + "ExchangeCDOEXE.exe " + "\"" + "8" + "\"" + " " + "\"" + iVersion.ToString() + "\"" + " " + "\"" + cmbServer.Text + "\"" + " " + "\"" + "a" + "\"" + " " + "\"" + "a" + "\"");

}
}
else
{
CLICaller.CreateTemporaryEnviornment(cmbServer.Text.Trim(), Txt_FilePath.Text);
CLICaller.GetDCUsersList(cmbServer.Text.Trim(), 0);
}

//CLICaller.GetDCUsersList(cmbServer.Text.Trim());
String strDCUsersPath = String.Empty;
if ((iVersion != 2003) && (txtIpAddress.Text != ""))
{
strDCUsersPath = "\\\\" + txtIpAddress.Text + "\\" + "Exchange_Granular_Restore_Agent" + "\\" + "UserList.txt";
}
else
{
strDCUsersPath = System.Environment.CurrentDirectory + "\\" + "UserList.txt";
}
String[] strListUsers = File.ReadAllLines(strDCUsersPath);
if (strListUsers.Length == 0)
{
MessageBox.Show("No User Found On EDB File", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return 1;
}

dtgUserList.Rows.Clear();
for (int i = 0; i < strListUsers.Length; i++)
{
if (strListUsers[i].ToLower().Contains("smtp") || strListUsers[i].ToLower().Contains("systemmailbox") || string.IsNullOrEmpty(strListUsers[i]))
continue;
dtgUserList.Rows.Add(1);
dtgUserList.CurrentCell = dtgUserList.Rows[dtgUserList.Rows.Count - 1].Cells[1];
dtgUserList.CurrentRow.Cells["user"].Value = strListUsers[i];

}
return 0;
}

catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
clsError.LogError(ex);
return 1;
}
}

/*! \fn private List<String> ExportEDBToPSt()
* \brief constructor to Export EDB To PST
* \author Unitrends, Inc.
* \date 23 Feb 2011 *
* \em COPYRIGHT © 2011 Unitrends, Inc.
*/

private List<String> ExportEDBToPSt()
{
List<String> lsPathofPST = new List<string>();
try
{

String strListExgSrv = string.Empty;
String UserName = string.Empty;

for (int i = 0; i < dtgUserList.Rows.Count; i++)
{
if (Convert.ToInt32(dtgUserList.Rows[i].Cells[0].Value) == 0)
continue;
UserName = Convert.ToString(dtgUserList.Rows[i].Cells["user"].Value);

//For connecting the user's mailbox
//Change By Saurabh 2 Mar
if (txtIpAddress.Text != "")
{
if (iVersion == 2003)
{
CLICaller.RunCommand(txtUserName.Text, txtPass.Text, txtIpAddress.Text, strAppPath + "ExchangeGranularCLI.exe" + " " + "\"" + "5" + "\"" + " " + "\"" + cmbServer.Text + "\"" + " " + "\"" + UserName + "\"" + " " + "\"" + "1" + "\"");
}
else
{
CLICaller.RunCommand(txtUserName.Text, txtPass.Text, txtIpAddress.Text, strAppPath + "ExchangeCDOEXE.exe " + "\"" + "4" + "\"" + " " + "\"" + iVersion.ToString() + "\"" + " " + "\"" + cmbServer.Text + "\"" + " " + "\"" + UserName + "\"" + " " + "\"" + "a" + "\"");

}
}
else
{
CLICaller.ConnectDeleteMB(cmbServer.Text, UserName, 1);
}
//objExch.fnConnectMailBox(cmbServer.Text, UserName, 1);


//Function for creating Mapi profile and adding PST

CLICaller.MapiInitialization(cmbServer.Text, UserName);
//objMapi.fnMapiInitEx(UserName, cmbServer.Text, ref strPathofTarget);

String strPathofTarget = System.Environment.CurrentDirectory + "\\" + UserName + ".pst";

lsPathofPST.Add(strPathofTarget);


//Function for copying data to pst
CLICaller.CreateEDBToPSt(UserName);
//objExData.fnRestoreToFileEx(UserName);


//For deleting Mapi Profile
CLICaller.MapiCleanUp(UserName);
//objMapi.fnMapiCleanup(UserName);


//For disconnecting the Users Mailbox
if (txtIpAddress.Text != "")
{
if (iVersion == 2003)
{
CLICaller.RunCommand(txtUserName.Text, txtPass.Text, txtIpAddress.Text, strAppPath + "ExchangeGranularCLI.exe" + " " + "\"" + "5" + "\"" + " " + "\"" + cmbServer.Text + "\"" + " " + "\"" + UserName + "\"" + " " + "\"" + "0" + "\"");
}
else
{
CLICaller.RunCommand(txtUserName.Text, txtPass.Text, txtIpAddress.Text, strAppPath + "ExchangeCDOEXE.exe " + "\"" + "5" + "\"" + " " + "\"" + iVersion.ToString() + "\"" + " " + "\"" + cmbServer.Text + "\"" + " " + "\"" + UserName + "\"" + " " + "\"" + "a" + "\"");
}
}
else
{
CLICaller.ConnectDeleteMB(cmbServer.Text, UserName, 0);
}
//objExch.fnConnectMailBox(cmbServer.Text, UserName, 0);
}
if (txtIpAddress.Text != "")
{
if (iVersion == 2003)
{
CLICaller.RunCommand(txtUserName.Text, txtPass.Text, txtIpAddress.Text, strAppPath + "ExchangeGranularCLI.exe" + " " + "\"" + "9" + "\"" + " " + "\"" + cmbServer.Text + "\"");
}
else
{
CLICaller.RunCommand(txtUserName.Text, txtPass.Text, txtIpAddress.Text, strAppPath + "ExchangeCDOEXE.exe " + "\"" + "6" + "\"" + " " + "\"" + iVersion.ToString() + "\"" + " " + "\"" + cmbServer.Text + "\"" + " " + "\"" + "a" + "\"" + " " + "\"" + "a" + "\"");
}
}
else
{
CLICaller.DeleteTempEnviornment(cmbServer.Text);
}
//objExch.fnDeleteTempEnvironment(cmbServer.Text, strSystemFilePath);
return lsPathofPST;
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
clsError.LogError(ex);
return lsPathofPST;
}
}

/*! \fn private void wizard1_CancelButtonClick(object sender, CancelEventArgs e)
* \brief constructor to Cancel the Wizard
* \author Unitrends, Inc.
* \date 23 Feb 2011 *
* \em COPYRIGHT © 2011 Unitrends, Inc.
*/

private void wizard1_CancelButtonClick(object sender, CancelEventArgs e)
{
if (wizardPage4.Visible == true)
{
if (txtIpAddress.Text != "")
{
//
if (iVersion == 2003)
{
CLICaller.RunCommand(txtUserName.Text, txtPass.Text, txtIpAddress.Text, strAppPath + "ExchangeGranularCLI.exe" + " " + "\"" + "9" + "\"" + " " + "\"" + cmbServer.Text + "\"");
}
else
{
CLICaller.RunCommand(txtUserName.Text, txtPass.Text, txtIpAddress.Text, strAppPath + "ExchangeCDOEXE.exe " + "\"" + "6" + "\"" + " " + "\"" + iVersion.ToString() + "\"" + " " + "\"" + cmbServer.Text + "\"" + " " + "\"" + "a" + "\"" + " " + "\"" + "a" + "\"");
}
}
else
{
CLICaller.DeleteTempEnviornment(cmbServer.Text);
}
}
}
}
}


Thanks And Regards.
Kamlesh Nikam


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend