static void Main() { //string filename = "log\\Log.txt"; //CustomSharePointUtility.logFile = new StreamWriter(filename); //CustomSharePointUtility.WriteLog("*********************************************"); //CustomSharePointUtility.WriteLog("Reminder Mail Starts: " + DateTime.Now.ToString()); //CustomSharePointUtility.WriteLog("*********************************************"); Console.WriteLine("*********************************************"); Console.WriteLine("Reminder Mail starts : " + DateTime.Now.ToString()); Console.WriteLine("*********************************************"); List <TravelVoucher> SPTravelVoucher = null; try { var siteUrl = ConfigurationManager.AppSettings["SP_Address_Live"]; string TestingTravelHeaderList = ConfigurationManager.AppSettings["TestingTravelHeaderList"]; string EmailList = ConfigurationManager.AppSettings["EmailList"]; string DaysDifference = ConfigurationManager.AppSettings["DaysDifference"]; //string query = SQLUtility.ReadQuery("EmployeeMasterQuery.txt"); SPTravelVoucher = new List <TravelVoucher>(); //Task task_SPEmployeeMaster = Task.Run(() => SPTravelVoucher = CustomSharePointUtility.GetAll_TravelVoucherFromSharePoint(siteUrl, TestingTravelHeaderList)); SPTravelVoucher = CustomSharePointUtility.GetAll_TravelVoucherFromSharePoint(siteUrl, TestingTravelHeaderList, DaysDifference); //List<TravelVoucher> empMasterFinal = new List<TravelVoucher>(); List <TravelVoucher> empMasterFinal = SPTravelVoucher; if (empMasterFinal.Count > 0) { //CustomSharePointUtility.WriteLog("Voucher data successfully."); //Console.WriteLine("Employee data synchronized successfully."); var success = CustomSharePointUtility.EmailData(empMasterFinal, siteUrl, EmailList); if (success) { CustomSharePointUtility.WriteLog("Reminder Mail Sent Successfully."); Console.WriteLine("Reminder Mail Sent Successfully."); } } else { CustomSharePointUtility.WriteLog("No Pending Records."); Console.WriteLine("No Pending Records."); } } catch (Exception ex) { CustomSharePointUtility.WriteLog("Error in scheduler : " + ex.StackTrace); Console.WriteLine("Error in scheduler : " + ex.StackTrace); } finally { //CustomSharePointUtility.WriteLog("*********************************************"); //CustomSharePointUtility.WriteLog("Reminder Mail ends : " + DateTime.Now.ToString()); //CustomSharePointUtility.WriteLog("*********************************************"); Console.WriteLine("*********************************************"); Console.WriteLine("Reminder Mail ends : " + DateTime.Now.ToString()); Console.WriteLine("*********************************************"); CustomSharePointUtility.logFile.Close(); //Console.ReadKey(); } }
public static string ReadQuery(string QueryFileName) { try { System.IO.StreamReader myFile = new System.IO.StreamReader(QueryFileName); string query = myFile.ReadToEnd(); myFile.Close(); return(query); } catch (Exception ex) { CustomSharePointUtility.WriteLog(ex.ToString()); return(""); } }
static void Main() { List <ITAssets> SPITAssets = null; try { var siteUrl = ConfigurationManager.AppSettings["SP_Address_Live"]; string TestAssetsRequisition = ConfigurationManager.AppSettings["TestAssetsRequisition"]; string EmailList = ConfigurationManager.AppSettings["EmailList"]; string DaysDifference = ConfigurationManager.AppSettings["DaysDifference"]; //string query = SQLUtility.ReadQuery("EmployeeMasterQuery.txt"); SPITAssets = new List <ITAssets>(); //Task task_SPEmployeeMaster = Task.Run(() => SPTravelVoucher = CustomSharePointUtility.GetAll_TravelVoucherFromSharePoint(siteUrl, TestingTravelHeaderList)); SPITAssets = CustomSharePointUtility.GetAll_AssetsDetailsFromSharePoint(siteUrl, TestAssetsRequisition, DaysDifference); //List<TravelVoucher> empMasterFinal = new List<TravelVoucher>(); List <ITAssets> empMasterFinal = SPITAssets; if (empMasterFinal.Count > 0) { //Console.WriteLine("Employee data synchronized successfully."); var success = CustomSharePointUtility.EmailData(empMasterFinal, siteUrl, EmailList); if (success) { ///CustomSharePointUtility.WriteLog("Reminder Mail Sent Successfully."); //Console.WriteLine("Reminder Mail Sent Successfully."); } } else { //CustomSharePointUtility.WriteLog("No Pending Records."); //Console.WriteLine("No Pending Records."); } } catch (Exception ex) { CustomSharePointUtility.WriteLog("Error in scheduler : " + ex.StackTrace); Console.WriteLine("Error in scheduler : " + ex.StackTrace); } finally { } }
public static DataTable GetDataTable(string sqlQuery) { DataTable _returnTable = null; using (SqlConnection _connection = GetSQLConnection()) { SqlCommand _sqlcmd = null; try { _connection.Open(); _sqlcmd = _connection.CreateCommand(); _sqlcmd.CommandType = CommandType.Text; _sqlcmd.CommandText = sqlQuery; _sqlcmd.ExecuteNonQuery(); SqlDataAdapter odata = new SqlDataAdapter(_sqlcmd); _returnTable = new DataTable(); odata.Fill(_returnTable); CustomSharePointUtility.WriteLog("Connected to SQL"); } catch (Exception ex) { _returnTable = null; throw ex; } finally { if (_sqlcmd != null) { _sqlcmd = null; } } } return(_returnTable); }
static void Main() { //string filename = "log\\Log.txt"; //CustomSharePointUtility.logFile = new StreamWriter(filename); //CustomSharePointUtility.WriteLog("*********************************************"); //CustomSharePointUtility.WriteLog("Reminder Mail Starts: " + DateTime.Now.ToString()); //CustomSharePointUtility.WriteLog("*********************************************"); //Console.WriteLine("*********************************************"); //Console.WriteLine("Reminder Mail starts : " + DateTime.Now.ToString()); //Console.WriteLine("*********************************************"); List <Employee> SPEmployee = null; List <Employee> SPMonthEmployee = null; List <Employee> PendingEmployee = null; DateTime nextmonth = DateTime.Now.AddMonths(1); string currentMonth = nextmonth.Month.ToString(); string currentYear = nextmonth.Year.ToString(); // string currentMonth = DateTime.Now.Month.ToString(); // string currentYear = DateTime.Now.Year.ToString(); try { var siteUrl = ConfigurationManager.AppSettings["SP_Address_Live"]; var RootsiteUrl = ConfigurationManager.AppSettings["SP_Address_RootLive"]; string SentMail = ConfigurationManager.AppSettings["SentMail"]; string HODMaster = ConfigurationManager.AppSettings["HODMaster"]; string SalesEstimateEmployee = ConfigurationManager.AppSettings["SalesEstimateEmployee"]; //string TestingPurchaseHeaderList = ConfigurationManager.AppSettings["TestingPurchaseHeaderList"]; //string PurchaseApprovers = ConfigurationManager.AppSettings["PurchaseApprovers"]; //string EmailList = ConfigurationManager.AppSettings["EmailList"]; //string DaysDifference = ConfigurationManager.AppSettings["DaysDifference"]; //string query = SQLUtility.ReadQuery("EmployeeMasterQuery.txt"); SPEmployee = new List <Employee>(); SPMonthEmployee = new List <Employee>(); PendingEmployee = new List <Employee>(); //Task task_SPEmployeeMaster = Task.Run(() => SPTravelVoucher = CustomSharePointUtility.GetAll_TravelVoucherFromSharePoint(siteUrl, TestingTravelHeaderList)); SPEmployee = CustomSharePointUtility.GetEmployees(siteUrl, HODMaster); SPMonthEmployee = CustomSharePointUtility.GetEnterEstimate(currentMonth, currentYear, SalesEstimateEmployee, siteUrl); PendingEmployee = CustomSharePointUtility.GetFilter(SPEmployee, SPMonthEmployee); CustomSharePointUtility.EmailData(PendingEmployee, siteUrl, SentMail); // List<TravelVoucher> empMasterFinal = new List<TravelVoucher>(); ////List<PurchaseOrder> purchaseDataFinal = SPPurchaseOrder; ////if (purchaseDataFinal.Count > 0) ////{ //// for (var i = 0; i < purchaseDataFinal.Count; i++) //// { //// if (purchaseDataFinal[i].LocationType == "Office") //// { //// if (purchaseDataFinal[i].ApprovalStatus == "Submitted") //// { //// CustomSharePointUtility.EmployeeMasterData(purchaseDataFinal[i], RootsiteUrl, siteUrl, EmployeeMaster, EmailList); //// } //// else if (purchaseDataFinal[i].ApprovalStatus == "Approved By Functional Head") //// { //// CustomSharePointUtility.PurchaseApproversData(purchaseDataFinal[i], RootsiteUrl, siteUrl, PurchaseApprovers, EmailList); //// } //// } //// else if(purchaseDataFinal[i].LocationType == "Plant"){ //// if (purchaseDataFinal[i].ApprovalStatus == "Submitted") //// { //// CustomSharePointUtility.PurchaseApproversData(purchaseDataFinal[i], RootsiteUrl, siteUrl, PurchaseApprovers, EmailList); //// } //// else if (purchaseDataFinal[i].ApprovalStatus == "Approved By Purchase Head") //// { //// CustomSharePointUtility.PurchaseApproversData(purchaseDataFinal[i], RootsiteUrl, siteUrl, PurchaseApprovers, EmailList); //// } //// else if (purchaseDataFinal[i].ApprovalStatus == "Approved By Plant Head") //// { //// CustomSharePointUtility.PurchaseApproversData(purchaseDataFinal[i], RootsiteUrl, siteUrl, PurchaseApprovers, EmailList); //// } //// } //// } //// //Console.WriteLine("Employee data synchronized successfully."); //// //var success = CustomSharePointUtility.EmailData(empMasterFinal, siteUrl, EmailList); //// //if (success) //// //{ //// // ///CustomSharePointUtility.WriteLog("Reminder Mail Sent Successfully."); //// // //Console.WriteLine("Reminder Mail Sent Successfully."); //// //} ////} ////else ////{ //// //CustomSharePointUtility.WriteLog("No Pending Records."); //// //Console.WriteLine("No Pending Records."); ////} } catch (Exception ex) { CustomSharePointUtility.WriteLog("Error in scheduler : " + ex.StackTrace); Console.WriteLine("Error in scheduler : " + ex.StackTrace); } finally { //CustomSharePointUtility.WriteLog("*********************************************"); //CustomSharePointUtility.WriteLog("Reminder Mail ends : " + DateTime.Now.ToString()); //CustomSharePointUtility.WriteLog("*********************************************"); //Console.WriteLine("*********************************************"); // Console.WriteLine("Reminder Mail ends : " + DateTime.Now.ToString()); //Console.WriteLine("*********************************************"); //CustomSharePointUtility.logFile.Close(); //Console.ReadKey(); } }
static void Main() { //string filename = "log\\Log.txt"; //CustomSharePointUtility.logFile = new StreamWriter(filename); //CustomSharePointUtility.WriteLog("*********************************************"); //CustomSharePointUtility.WriteLog("Reminder Mail Starts: " + DateTime.Now.ToString()); //CustomSharePointUtility.WriteLog("*********************************************"); //Console.WriteLine("*********************************************"); //Console.WriteLine("Reminder Mail starts : " + DateTime.Now.ToString()); //Console.WriteLine("*********************************************"); List <PurchaseOrder> SPPurchaseOrder = null; try { var siteUrl = ConfigurationManager.AppSettings["SP_Address_Live"]; var RootsiteUrl = ConfigurationManager.AppSettings["SP_Address_RootLive"]; string EmployeeMaster = ConfigurationManager.AppSettings["EmployeeMaster"]; string TestingPurchaseHeaderList = ConfigurationManager.AppSettings["TestingPurchaseHeaderList"]; string PurchaseApprovers = ConfigurationManager.AppSettings["PurchaseApprovers"]; string EmailList = ConfigurationManager.AppSettings["EmailList"]; string DaysDifference = ConfigurationManager.AppSettings["DaysDifference"]; //string query = SQLUtility.ReadQuery("EmployeeMasterQuery.txt"); SPPurchaseOrder = new List <PurchaseOrder>(); //Task task_SPEmployeeMaster = Task.Run(() => SPTravelVoucher = CustomSharePointUtility.GetAll_TravelVoucherFromSharePoint(siteUrl, TestingTravelHeaderList)); SPPurchaseOrder = CustomSharePointUtility.GetAll_PurchaseOrderFromSharePoint(siteUrl, TestingPurchaseHeaderList, DaysDifference); //List<TravelVoucher> empMasterFinal = new List<TravelVoucher>(); List <PurchaseOrder> purchaseDataFinal = SPPurchaseOrder; Console.WriteLine("total count" + purchaseDataFinal.Count); if (purchaseDataFinal.Count > 0) { for (var i = 0; i < purchaseDataFinal.Count; i++) { if (purchaseDataFinal[i].LocationType == "Office") { if (purchaseDataFinal[i].ApprovalStatus == "Submitted") { CustomSharePointUtility.EmployeeMasterData(purchaseDataFinal[i], RootsiteUrl, siteUrl, EmployeeMaster, EmailList); } else if (purchaseDataFinal[i].ApprovalStatus == "Approved By Functional Head") { CustomSharePointUtility.PurchaseApproversData(purchaseDataFinal[i], RootsiteUrl, siteUrl, PurchaseApprovers, EmailList); } } else if (purchaseDataFinal[i].LocationType == "Plant") { //if (purchaseDataFinal[i].ApprovalStatus == "Submitted") //{ // CustomSharePointUtility.PurchaseApproversData(purchaseDataFinal[i], RootsiteUrl, siteUrl, PurchaseApprovers, EmailList); //} //else if (purchaseDataFinal[i].ApprovalStatus == "Approved By Purchase Head") //{ // CustomSharePointUtility.PurchaseApproversData(purchaseDataFinal[i], RootsiteUrl, siteUrl, PurchaseApprovers, EmailList); //} //else if (purchaseDataFinal[i].ApprovalStatus == "Approved By Plant Head") //{ // CustomSharePointUtility.PurchaseApproversData(purchaseDataFinal[i], RootsiteUrl, siteUrl, PurchaseApprovers, EmailList); //} if (purchaseDataFinal[i].NewFlow == "Yes") { CustomSharePointUtility.PurchaseApproversDataPlant(purchaseDataFinal[i], RootsiteUrl, siteUrl, PurchaseApprovers, EmailList); } } Console.WriteLine("No Pending Records." + i); } //Console.WriteLine("Employee data synchronized successfully."); //var success = CustomSharePointUtility.EmailData(empMasterFinal, siteUrl, EmailList); //if (success) //{ // ///CustomSharePointUtility.WriteLog("Reminder Mail Sent Successfully."); // //Console.WriteLine("Reminder Mail Sent Successfully."); //} } else { //CustomSharePointUtility.WriteLog("No Pending Records."); //Console.WriteLine("No Pending Records."); } } catch (Exception ex) { CustomSharePointUtility.WriteLog("Error in scheduler : " + ex.StackTrace); Console.WriteLine("Error in scheduler : " + ex.StackTrace); } finally { //CustomSharePointUtility.WriteLog("*********************************************"); //CustomSharePointUtility.WriteLog("Reminder Mail ends : " + DateTime.Now.ToString()); //CustomSharePointUtility.WriteLog("*********************************************"); //Console.WriteLine("*********************************************"); // Console.WriteLine("Reminder Mail ends : " + DateTime.Now.ToString()); //Console.WriteLine("*********************************************"); //CustomSharePointUtility.logFile.Close(); //Console.ReadKey(); } }