public static void subUpdateDef(string _strFldName, string _strVal, string _strDataType) { string strRes = ""; try { using (wsXferEventInfo.XferEventInfo wsXferData = new wsXferEventInfo.XferEventInfo()) { strRes = wsXferData.fcnUpdateDefault(clsAppSettings.GetAppSettings().lngCTUserID, _strFldName, _strVal, _strDataType, strWebConn); } } catch (Exception ex) { clsErr.subLogErr("clsWebTalk.subUploadData", ex); } if (strRes != "") MessageBox.Show("Error updating default: " + strRes); return; }
public static string fcnULNoUpdate(string _strSQL, string _strTblName, string _strRecordCaption) { string strWebRes = ""; string strRes = ""; XmlNode xmlNodeRes; try { if (_strSQL == "") return ""; using (OleDbConnection objConn = new OleDbConnection(clsAppSettings.GetAppSettings().strCTConn)) { objConn.Open(); using (OleDbDataAdapter daToUL = new OleDbDataAdapter(_strSQL, objConn)) { int intTotalRecords = 0; int intStartIndex = 0; int intEndIndex = 1000; int intRemainingRecords = 0; int intCurrentCycle = 1; bool blnFirst = true; while (intRemainingRecords > 0 || blnFirst) { using (DataSet dsToUL = new DataSet(_strTblName)) { daToUL.Fill(dsToUL); XmlDataDocument xmlChunk = new XmlDataDocument(dsToUL); if (xmlChunk.ChildNodes.Count > 0) { if (blnFirst) { try { intTotalRecords = xmlChunk.ChildNodes[0].ChildNodes.Count; } catch { intTotalRecords = 0; } intRemainingRecords = intTotalRecords; if (intEndIndex > intTotalRecords) intEndIndex = intTotalRecords; blnFirst = false; } //remove all but current k dsToUL.EnforceConstraints = false; //clear records after current k while (xmlChunk.ChildNodes[0].ChildNodes.Count > (1000 * intCurrentCycle)) { xmlChunk.ChildNodes[0].ChildNodes[(1000 * intCurrentCycle)].ParentNode.RemoveChild(xmlChunk.ChildNodes[0].ChildNodes[(1000 * intCurrentCycle)]); } //clear record before current k while (xmlChunk.ChildNodes[0].ChildNodes.Count > 1000) { xmlChunk.ChildNodes[0].ChildNodes[0].ParentNode.RemoveChild(xmlChunk.ChildNodes[0].ChildNodes[0]); } using (wsXferEventInfo.XferEventInfo wsXferData = new wsXferEventInfo.XferEventInfo()) { wsXferData.Timeout = System.Threading.Timeout.Infinite; int intHourOffset = 0; intHourOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).Hours; xmlNodeRes = wsXferData.fcnUploadDataNoUpdate(xmlChunk, _strTblName, strWebConn, intHourOffset, clsAppSettings.GetAppSettings().lngCTUserID); } intRemainingRecords -= 1000; intCurrentCycle++; intStartIndex += 1000; intEndIndex += 1000; if (intEndIndex > intTotalRecords) intEndIndex = intTotalRecords; } else blnFirst = false; } } } objConn.Close(); } } catch (Exception ex) { Console.WriteLine("Error: " + DateTime.Now.ToString()); MessageBox.Show("Debug Message: " + strWebRes); clsErr.subLogErr("clsWebTalk.subUploadData", ex); } return strRes; }
public static string fcnUploadData(string strSQL, string strTblName, string strKeyFld, string strFldToUpdate, string strInsertSProc, bool _blnClearAll, string _strKeyType, string _strRecordCaption) { string strULFile; string strXML; string strWebRes = ""; string strRes = ""; //wsULDLEventInfo.Service wsULEventInfo; wsXferEventInfo.XferEventInfo wsXferData; try { if (strSQL == "") return ""; using (OleDbConnection objConn = new OleDbConnection(clsAppSettings.GetAppSettings().strCTConn)) { objConn.Open(); using (OleDbDataAdapter daToUL = new OleDbDataAdapter(strSQL, objConn)) { using (DataSet dsToUL = new DataSet(strTblName)) { daToUL.Fill(dsToUL); strULFile = Application.StartupPath + DateTime.Now.ToString("yyyyMMdd_HHmmss") + "_" + strTblName + ".xml"; if (dsToUL.Tables[0].Rows.Count == 0) strRes = "There are no " + _strRecordCaption + " to upload.\n"; else { dsToUL.WriteXml(strULFile); strXML = CTWebMgmt.fcnFileToStr(strULFile); if (strInsertSProc == "spAppendGift") strXML = strXML.Replace("<blnRetrieved>-1</blnRetrieved>", "<blnRetrieved>true</blnRetrieved>"); wsXferData = new wsXferEventInfo.XferEventInfo(); wsXferData.Timeout = System.Threading.Timeout.Infinite; strWebRes = wsXferData.fcnProcessCTXMLUpload(clsAppSettings.GetAppSettings().lngCTUserID, strXML, strInsertSProc, strKeyFld, strFldToUpdate, _blnClearAll, strWebConn, _strKeyType); } } } objConn.Close(); } if (strFldToUpdate != "" && strWebRes != "" && strFldToUpdate != "lngCTUserIDOut") subLoadWebIDs(strWebRes, strKeyFld, strFldToUpdate, strTblName); System.IO.File.Delete(strULFile); } catch (Exception ex) { Console.WriteLine("Error: " + DateTime.Now.ToString()); MessageBox.Show("Debug Message: " + strWebRes); clsErr.subLogErr("clsWebTalk.subUploadData", ex); } return strRes; }
public static string fcnUploadIRs(string strSQL, bool _blnClearAll) { OleDbConnection objConn; OleDbDataAdapter daToUL; DataSet dsToUL; string strULFile; string strXML; string strWebRes = ""; string strRes = ""; wsXferEventInfo.XferEventInfo wsXferData; try { if (strSQL == "") return ""; objConn = new OleDbConnection(clsAppSettings.GetAppSettings().strCTConn); objConn.Open(); daToUL = new OleDbDataAdapter(strSQL, objConn); dsToUL = new DataSet("tblRecords"); daToUL.Fill(dsToUL); strULFile = Application.StartupPath + DateTime.Now.ToString("yyyyMMdd_HHmmss") + "_tblRecords.xml"; if (dsToUL.Tables[0].Rows.Count == 0) strRes = "There are no records to upload.\n"; else { dsToUL.WriteXml(strULFile); strXML = CTWebMgmt.fcnFileToStr(strULFile); wsXferData = new wsXferEventInfo.XferEventInfo(); wsXferData.Timeout = System.Threading.Timeout.Infinite; strWebRes = wsXferData.fcnProcessIRUpload(clsAppSettings.GetAppSettings().lngCTUserID, strXML, strWebConn); } objConn.Close(); objConn.Dispose(); subLoadWebIDs(strWebRes, "lngRecordID", "lngRecordWebID", "tblRecords"); try { System.IO.File.Delete(strULFile); } catch { } } catch (Exception ex) { clsErr.subLogErr("clsWebTalk.subUploadData", ex); } return strRes; }
public static string fcnULWithUpdate(string _strSQL, string _strTblName, string _strLocalKeyFld, string _strServerKeyFld, bool _blnClearAll, string _strRecordCaption, ListBox _lstStatus) { string strWebRes = ""; string strRes = ""; XmlNode xmlNodeRes; try { if (_strSQL == "") return ""; using (OleDbConnection objConn = new OleDbConnection(clsAppSettings.GetAppSettings().strCTConn)) { objConn.Open(); using (OleDbDataAdapter daToUL = new OleDbDataAdapter(_strSQL, objConn)) { int intTotalRecords = 0; int intStartIndex = 0; int intEndIndex = 1000; int intRemainingRecords = 0; int intCurrentCycle = 1; bool blnFirst = true; while (intRemainingRecords > 0 || blnFirst) { using (DataSet dsToUL = new DataSet(_strTblName)) { daToUL.Fill(dsToUL); XmlDataDocument xmlChunk = new XmlDataDocument(dsToUL); if (xmlChunk.ChildNodes.Count > 0) { if (blnFirst) { try { intTotalRecords = xmlChunk.ChildNodes[0].ChildNodes.Count; } catch { intTotalRecords = 0; } intRemainingRecords = intTotalRecords; if (_lstStatus != null) _lstStatus.Items.Insert(0, "Queueing " + intTotalRecords.ToString() + " " + _strRecordCaption + " for upload"); Application.DoEvents(); if (intEndIndex > intTotalRecords) intEndIndex = intTotalRecords; if (_lstStatus != null) _lstStatus.Items.Insert(0, "Uploading " + _strRecordCaption + " " + intStartIndex.ToString() + "-" + intEndIndex.ToString()); Application.DoEvents(); blnFirst = false; } //remove all but current k dsToUL.EnforceConstraints = false; //clear records after current k while (xmlChunk.ChildNodes[0].ChildNodes.Count > (1000 * intCurrentCycle)) { xmlChunk.ChildNodes[0].ChildNodes[(1000 * intCurrentCycle)].ParentNode.RemoveChild(xmlChunk.ChildNodes[0].ChildNodes[(1000 * intCurrentCycle)]); } //clear record before current k while (xmlChunk.ChildNodes[0].ChildNodes.Count > 1000) { xmlChunk.ChildNodes[0].ChildNodes[0].ParentNode.RemoveChild(xmlChunk.ChildNodes[0].ChildNodes[0]); } using (wsXferEventInfo.XferEventInfo wsXferData = new wsXferEventInfo.XferEventInfo()) { wsXferData.Timeout = System.Threading.Timeout.Infinite; //dsToUL.WriteXml("D:\\projects\\camptrak\\covheightsul.xml"); //int intNodeCount = 0; //for (int intI = 0; intI < xmlDocToSend.ChildNodes[0].ChildNodes.Count; intI++) //{ // if (intNodeCount == 0) intNodeCount = xmlDocToSend.ChildNodes[0].ChildNodes[intI].ChildNodes.Count; // if (xmlDocToSend.ChildNodes[0].ChildNodes[intI].ChildNodes.Count != intNodeCount) // { // Console.WriteLine("Count Err"); // } //} int intHourOffset = 0; intHourOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).Hours; xmlNodeRes = wsXferData.fcnUploadData(xmlChunk, _strTblName, _strServerKeyFld, _strLocalKeyFld, strWebConn, intHourOffset); } //load result if (_strServerKeyFld != "") subLoadWebIDs(xmlNodeRes, _strTblName); intRemainingRecords -= 1000; intCurrentCycle++; intStartIndex += 1000; intEndIndex += 1000; if (intEndIndex > intTotalRecords) intEndIndex = intTotalRecords; if (intEndIndex > intStartIndex) { if (_lstStatus != null) _lstStatus.Items.Insert(0, "Uploading " + _strRecordCaption + " " + intStartIndex.ToString() + "-" + intEndIndex.ToString()); Application.DoEvents(); } } else blnFirst = false; } } } objConn.Close(); } } catch (Exception ex) { Console.WriteLine("Error: " + DateTime.Now.ToString()); // MessageBox.Show("Debug Message: " + strWebRes); clsErr.subLogErr("clsWebTalk.subUploadData", ex); } return strRes; }