/// <summary> /// Clean up /// </summary> public void Cleanup() { if (m_xlsreader != null) { m_xlsreader.Close(); m_xlsreader = null; } if (batch_upd != null) { batch_upd.Close(); batch_upd = null; } }
/// <summary> /// Update All the data from the spread sheet /// </summary> /// <returns></returns> /// public bool UpdateAll() { String country; String segment; String currency; double ordc; // order cancel factor String forecast_name; try { batch_upd = new CBatchDBUpdator(m_OrclConnstr); country = m_xlsreader.GetCellValue("CONTROL", "B2"); currency = m_xlsreader.GetCellValue("CONTROL", "B5"); segment = m_xlsreader.GetCellValue("CONTROL", "B3"); String ordcstr = m_xlsreader.GetCellValue("CONTROL", "B6"); string time_zone_code = m_xlsreader.GetCellValue("CONTROL", "B4"); GetTimeZoneOffset(time_zone_code); ordcstr = ordcstr.Trim().ToUpper(); int index = 0; String temp = ""; while (char.IsDigit(ordcstr[index])) { temp = temp + ordcstr[index]; index++; } if (ordcstr[index] == '.') { index++; temp = temp + "."; while (char.IsDigit(ordcstr[index])) { temp = temp + ordcstr[index]; index++; } } ordc = Convert.ToDouble(temp); forecast_name = m_xlsreader.GetCellValue("CONTROL", "B7"); country = country.Trim().ToUpper(); segment = segment.Trim().ToUpper(); currency = currency.Trim().ToUpper(); forecast_name = forecast_name.Trim(); if (country.Length == 0 || segment.Length == 0 || currency.Length == 0) { throw new Exception("Country , Segment or Currency is zero length"); } if (segment.Length > 10) { segment = segment.Substring(0, 10); } if (forecast_name.Length > 20) { forecast_name = forecast_name.Substring(0, 20); } upd_ob_revenue_units(country, segment, currency); update_click_stream(country, segment); update_ob_order_count(country, segment); update_odg_click_count(country, segment); update_odg_order_count_revenue(country, segment, currency); update_control_to_ei_cancel_factor(country, segment, forecast_name, ordc); batch_upd.Commit(); batch_upd.Close(); batch_upd = null; return(true); } catch (CParserException e) { CSyntaxErrorLog.AddLine(e.ToString()); batch_upd.Abort(); batch_upd.Close(); batch_upd = null; return(false); } catch (Exception e) { CSyntaxErrorLog.AddLine(e.ToString()); batch_upd.Abort(); batch_upd.Close(); batch_upd = null; return(false); } }