internal void StartUpdate() { ArrayList AccountIDList = getAllAccountID(); Console.WriteLine(string.Format("[{0}] : {1} Account ID Found Found in Account Table", DateTime.Now, AccountIDList.Count.ToString())); int TotalIDs = AccountIDList.Count; int Counter = 0; foreach (string AccountIDstr in AccountIDList) { Guid AccountID = new Guid(AccountIDstr); using (SqlConnection Connection = SQLHelper.GetConnection()) { Counter++; SqlTransaction Transaction = default(SqlTransaction); Transaction = Connection.BeginTransaction("UpdateProcess"); BOL.AccountContact.odsAccount mgr = new BOL.AccountContact.odsAccount(); //Update JV Category mgr.UpdateAccountJVCategory_Wizard(Connection, Transaction, AccountID, new Guid(SyncHelper.AdminID), SyncHelper.AdminName); //Update BumiClassification mgr.UpdateAccountBumiClassification_Wizard(Connection, Transaction, AccountID, new Guid(SyncHelper.AdminID), SyncHelper.AdminName); //Update Classification mgr.UpdateAccountClassification_Wizard(Connection, Transaction, AccountID, new Guid(SyncHelper.AdminID), SyncHelper.AdminName); Transaction.Commit(); Console.WriteLine(string.Format("[{0}] : {1} / {2} Account ID : {3} Updated", DateTime.Now, Counter.ToString(), TotalIDs.ToString(), AccountIDstr)); } } Console.WriteLine(string.Format("[{0}] : Finished Updated All Account JV Category", DateTime.Now)); Console.ReadLine(); }
internal void Start() { DataTable dtUpdateClassification = getDTStruc(); Dictionary <string, string> dicNULL = new Dictionary <string, string>(); ArrayList AccountIDList = getAllAccountIDList(); foreach (string strAccountID in AccountIDList) { DataRow dr = dtUpdateClassification.NewRow(); Guid AccountID = new Guid(strAccountID); using (SqlConnection Connection = SQLHelper.GetConnection()) { SqlTransaction Transaction = default(SqlTransaction); Transaction = Connection.BeginTransaction("WizardSync"); string CompanyName = GetAccountDetailsNameByAccountID(Connection, Transaction, AccountID); dr[0] = CompanyName; BOL.AccountContact.odsAccount mgr = new BOL.AccountContact.odsAccount(); //Update JV Category mgr.UpdateAccountJVCategory_Wizard(Connection, Transaction, AccountID, new Guid(SyncHelper.AdminID), SyncHelper.AdminName); string JVCategory = getJVCategory(Connection, Transaction, AccountID, ref dicNULL); dr[1] = JVCategory; //Update BumiClassification mgr.UpdateAccountBumiClassification_Wizard(Connection, Transaction, AccountID, new Guid(SyncHelper.AdminID), SyncHelper.AdminName); string BumiClass = getBumiClass(Connection, Transaction, AccountID, ref dicNULL); dr[2] = BumiClass; //Update Classification mgr.UpdateAccountClassification_Wizard(Connection, Transaction, AccountID, new Guid(SyncHelper.AdminID), SyncHelper.AdminName); string AccountClass = getAccountClass(Connection, Transaction, AccountID, ref dicNULL); dr[3] = AccountClass; Transaction.Commit(); dr[4] = "UPDATED"; dtUpdateClassification.Rows.Add(dr); } } //2016 - 03 - 22 00:00:00 AM string folderPath = ConfigurationSettings.AppSettings["CRMCleanUpExcelLoc"].ToString(); ExcelFileHelper.GenerateExcelFile(folderPath, dtUpdateClassification, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss tt"), "UpdateAccountClassification"); if (dicNULL.Keys.Count > 0) { using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\User\Desktop\NULClassification.txt")) { foreach (string key in dicNULL.Keys) { string Category = ""; if (dicNULL.ContainsKey(key)) { Category = dicNULL[key].ToString(); } file.WriteLine(key + ": " + Category); } System.Diagnostics.Process.Start("notepad.exe", @"C:\Users\User\Desktop\NULClassification.txt"); } } }
internal void Start() { DataTable dtUpdateClassification = getDTStruc(); Dictionary <string, string> dicNULL = new Dictionary <string, string>(); //get all the INACTIVE //DataTable dtInactiveShareHolder = getAllInactiveShareHolder(); DataTable dtActiveShareHolder = getAllActiveShareHolder(); //DataTable dtNULLJVCategory= getAllNULLJVCategoryCID(); int RecordCounted = dtActiveShareHolder.Rows.Count; //int RecordCounted = dtNULLJVCategory.Rows.Count; Console.WriteLine("Total Record to clean up: " + RecordCounted.ToString()); //CHECK 1 by 1 ShareHolder int Counter = 0; foreach (DataRow dr1 in dtActiveShareHolder.Rows) //foreach (DataRow dr1 in dtNULLJVCategory.Rows) { string FileID = dr1["MSCFileID"].ToString(); Guid ShareHolderID = new Guid(dr1["ShareHolderID"].ToString()); Guid AccountID = new Guid(dr1["AccountID"].ToString()); string ShareHolderName = dr1["ShareholderName"].ToString(); string Percentage = dr1["Percentage"].ToString(); string CountryRegion = getCountryName(dr1["CountryRegionID"].ToString()); string outPercentage = ""; if (CheckExistedShareHolderInView(FileID, ShareHolderName, Percentage, CountryRegion, out outPercentage)) { Console.WriteLine("ShareHolder Found in View Table: " + ShareHolderName); using (SqlConnection Connection = SQLHelper.GetConnection()) { SqlTransaction Transaction = default(SqlTransaction); Transaction = Connection.BeginTransaction("UpdateProcess"); DataRow dr = dtUpdateClassification.NewRow(); //Update to ACTIVE int EffectedRows = 0; SetShareHolderToActive(Connection, Transaction, ShareHolderID, outPercentage, out EffectedRows); if (EffectedRows > 0) { dr[4] = ShareHolderName; } //UPDATE all CLASSIFICATION string CompanyName = GetAccountDetailsNameByAccountID(Connection, Transaction, AccountID); dr[0] = CompanyName; BOL.AccountContact.odsAccount mgr = new BOL.AccountContact.odsAccount(); //Update JV Category mgr.UpdateAccountJVCategory_Wizard(Connection, Transaction, AccountID, new Guid(SyncHelper.AdminID), SyncHelper.AdminName); string JVCategory = getJVCategory(Connection, Transaction, AccountID, ref dicNULL); dr[1] = JVCategory; //Update BumiClassification mgr.UpdateAccountBumiClassification_Wizard(Connection, Transaction, AccountID, new Guid(SyncHelper.AdminID), SyncHelper.AdminName); string BumiClass = getBumiClass(Connection, Transaction, AccountID, ref dicNULL); dr[2] = BumiClass; //Update Classification mgr.UpdateAccountClassification_Wizard(Connection, Transaction, AccountID, new Guid(SyncHelper.AdminID), SyncHelper.AdminName); string AccountClass = getAccountClass(Connection, Transaction, AccountID, ref dicNULL); dr[3] = AccountClass; Transaction.Commit(); dr[5] = DateTime.Now.ToString("dd/MM/yyyy"); dtUpdateClassification.Rows.Add(dr); Counter++; Console.WriteLine("UPDATED for record no : " + Counter.ToString() + " / " + RecordCounted + " for company : " + CompanyName); } } else { Counter++; Console.WriteLine("ShareHolder NOT Found in View Table: " + ShareHolderName + " " + Counter + " / " + RecordCounted); } } if (RecordCounted > 0) { string folderPath = ConfigurationSettings.AppSettings["CRMCleanUpExcelLoc"].ToString(); ExcelFileHelper.GenerateExcelFile(folderPath, dtUpdateClassification, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss tt"), "ShareHolderCleanUp"); } if (dicNULL.Keys.Count > 0) { using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\CRMCleanUp\NULLClassification.txt")) { foreach (string key in dicNULL.Keys) { string Category = ""; if (dicNULL.ContainsKey(key)) { Category = dicNULL[key].ToString(); } file.WriteLine(key + ": " + Category); } System.Diagnostics.Process.Start("notepad.exe", @"C:\CRMCleanUp\NULLClassification_" + DateTime.Now.ToString("dd-MM-yyyy") + ".txt"); } } }