/// <summary> /// Download the record data from database. /// </summary> /// <param name="recordDownloadException"></param> /// <returns></returns> public static bool RecordsDataDownload() { recordDataList.Clear(); try { using (SqlConnection connection = new SqlConnection(Operations.QueryStringData.ServerAddress)) { SqlCommand command = new SqlCommand(Operations.QueryStringData.RecordDataDownload, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { recordDataList.Add(new RecordData(Convert.ToInt32(reader[0]), Convert.ToInt32(reader[1]), Convert.ToDateTime(reader[2]) , Convert.ToInt32(reader[3]), Convert.ToInt32(reader[4]), Convert.ToInt32(reader[5]))); } } } catch (Exception anException) { if (ErrorHandle != null) { ErrorHandle.Invoke(errorMessageText(ErrorMessage.RecordDataDownload, anException.Message)); } return(false); } return(true); }
/// <summary> /// This void saves a new gamer name. /// </summary> /// <param name="aNewGamerName"></param> public static bool SaveNewGamerName(string aNewGamerName, out int newGamerID) { newGamerID = 0; try { using (SqlConnection connection = new SqlConnection(Operations.QueryStringData.ServerAddress)) { SqlCommand command = new SqlCommand(Operations.QueryStringData.GamerNameSave, connection); command.Parameters.Add("@NewGamerName", SqlDbType.NChar); command.Parameters["@NewGamerName"].Value = aNewGamerName; connection.Open(); newGamerID = (int)command.ExecuteScalar(); if (connection.State == System.Data.ConnectionState.Open) { connection.Close(); } } } catch (Exception anException) { if (ErrorHandle != null) { ErrorHandle.Invoke(errorMessageText(ErrorMessage.GamerNameSave, anException.Message)); } return(false); } return(true); }
public override void OnClick() { if (m_Hook == null) { return; } if (m_Hook.ArcGisMapControl.Map.LayerCount == 0) { MessageBox.Show("当前没有调阅数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } try { frm3DSection pfrm3DSection = new frm3DSection(); pfrm3DSection.pMapControlDefault = m_Hook.MapControl; pfrm3DSection.initialization(); pfrm3DSection.Show(); } catch (Exception exError) { ErrorHandle.ShowFrmErrorHandle("提示", exError.Message); } }
/// <summary> /// This void saves the buttons belongst to a former game. /// </summary> /// <param name="aSelectedFormerGameButton"></param> public static bool SaveASelectedFormerGameButtons(List <ButtonData> selectedGameButtons) { try { using (SqlConnection connection = new SqlConnection(Operations.QueryStringData.ServerAddress)) { connection.Open(); foreach (ButtonData aButtonData in selectedGameButtons) { SqlCommand command = new SqlCommand(Operations.QueryStringData.SelectedFormerGameButtonsUpload, connection); command.Parameters.Add("@SelectedGameButtonVisible", SqlDbType.Int); command.Parameters["@SelectedGameButtonVisible"].Value = aButtonData.ButtonVisible; command.Parameters.Add("@SelectedGameID", SqlDbType.Int); command.Parameters["@SelectedGameID"].Value = aButtonData.GameID; command.Parameters.Add("@SelectedGameButtonNumber", SqlDbType.Int); command.Parameters["@SelectedGameButtonNumber"].Value = aButtonData.ButtonNumber; command.ExecuteNonQuery(); } } } catch (Exception anException) { if (ErrorHandle != null) { ErrorHandle.Invoke(errorMessageText(ErrorMessage.SelectedFormerGameButtonsUpload, anException.Message)); } return(false); } return(true); }
protected bool DoRetry(out JobResult result) { result = null; if (CurrentRetry < Times) { CurrentRetry++; result = ErrorHandle.Expect(() => { return _job.Doable(); }, out bool anyError, _msgError, string.Format(_msgJobError, Id.Id, Id.Name), string.Format(_msgRetryError, CurrentRetry, Times)); if (anyError) { result = new JobResult(JobStatus.CompletedWithError, new AutoJobException(_job.Id, null, string.Format(_msgRetryError, CurrentRetry, Times))); } } else return true; if (Interval == TimeSpan.Zero) return false; return result.Status == JobStatus.Completed; }
void DefineLongVarRaw(int position, OracleConnection connection) { ociType = OciDataType.LongVarRaw; fieldType = typeof(byte[]); // TODO: get via piece-wise - a chunk at a time definedSize = LongVarRawMaxValue; value = OciCalls.AllocateClear(definedSize); int status = 0; status = OciCalls.OCIDefineByPos(Parent, out handle, ErrorHandle, position + 1, value, definedSize, ociType, indicator, rlenp, IntPtr.Zero, 0); if (status != 0) { OciErrorInfo info = ErrorHandle.HandleError(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } }
public override void OnClick() { if (m_Hook == null) { return; } //LogFile log = new LogFile(m_Hook.tipRichBox, m_Hook.strLogFilePath); //if (log != null) //{ // log.Writelog("鹰眼图设置"); //} if (m_Hook.ArcGisMapControl.Map.LayerCount == 0) { MessageBox.Show("当前没有调阅数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } try { FrmEditLayerSet fmMBMM = new FrmEditLayerSet(m_Hook.MapControl); fmMBMM.WriteLog = this.WriteLog; //int fmMBMMX = m_frmhook.MainForm.Location.X + m_frmhook.MainForm.Width - fmMBMM.Width; //int fmMBMMY = m_frmhook.MainForm.Location.Y + 100; //fmMBMM.SetDesktopLocation(fmMBMMX, fmMBMMY); if (fmMBMM.ShowDialog() == DialogResult.OK) { } } catch (Exception ex) { ErrorHandle.ShowFrmErrorHandle("提示", "配置文件editlayer.xml出错!缺少相关的属性。"); } }
//函数功能:修改记录 //输入参数:无 输出参数:布尔型 //函数功能:根据用户填写向表中添加记录 //输入参数:无 输出参数:bool private bool Add() { try { if (GeoDataCenterFunLib.LogTable.m_sysTable == null) { return(false); } Dictionary <string, object> pDic = new Dictionary <string, object>(); Exception ex = null; ITable pTable = GeoDataCenterFunLib.LogTable.m_sysTable.OpenTable(m_TableName, out ex); if (pTable == null) { return(false); } pRow = pTable.CreateRow(); for (int i = 0; i < m_gridView.ColumnCount; i++) //显示新产生的记录ID给用户 { if (m_gridView.Columns[i].Name.ToUpper() == "ID") { m_TextBoxX[i].Text = pRow.OID.ToString(); ModDBOperate.oid = pRow.OID; break; } } } catch (Exception ex) { ErrorHandle.ShowFrmErrorHandle("提示", "修改记录失败!" + ex.Message); return(false); } return(true); }
public override void OnClick() { if (m_Hook.UserTree.SelectedNode != null) { Exception eError; string DeID = m_Hook.UserTree.SelectedNode.TagString; if (DeID == null || DeID == "") { return; } if (m_Hook.UserTree.SelectedNode.Text == "遥感室") { MessageBox.Show("该科室为管理员科室,不可修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } FrmAddDepartment frmDepartment = new FrmAddDepartment(); frmDepartment.m_id = DeID; frmDepartment.m_FrmText = "更新科室"; frmDepartment.m_BtnText = "更新"; frmDepartment.m_IsUpdate = true; if (frmDepartment.ShowDialog() == DialogResult.OK) { if (this.WriteLog) { Plugin.LogTable.Writelog(Caption);//xisheng 2011.07.09 增加日志 } ModuleOperator.DisplayUserTree("", m_Hook.UserTree, ref ModData.gisDb, out eError); if (eError != null) { ErrorHandle.ShowFrmErrorHandle("提示", eError.Message); return; } } } }
public static void Logger(ILog log, string function, ErrorHandle errorHandleType, Action tryHandle, Action <Exception> catchHandle = null, Action finallyHandle = null) { try { log.Debug(function); tryHandle(); } catch (Exception ex) { log.Error(function + "失败", ex); if (catchHandle != null) { catchHandle(ex); } if (errorHandleType == ErrorHandle.Throw) { throw ex; } } finally { if (finallyHandle != null) { finallyHandle(); } } }
/// <summary> /// Compile the specified src. /// </summary> /// <param name="src">Source.</param> public string Compile(string src, Microsoft.Scripting.SourceCodeKind CodeKind = Microsoft.Scripting.SourceCodeKind.SingleStatement) { if (src == string.Empty) { return(string.Empty); } LoadRuntime(); Source = CodeKind == Microsoft.Scripting.SourceCodeKind.SingleStatement ? Engine.CreateScriptSourceFromString(src, CodeKind) : Engine.CreateScriptSourceFromFile(src); ErrorHandle errors = new ErrorHandle(); MemoryStream stream = new MemoryStream(); //Set IO Ouput of execution Engine.Runtime.IO.SetOutput(stream, new StreamWriter(stream)); Compiled = Source.Compile(errors); Operation = Engine.CreateOperations(); try { Compiled.Execute(Scope); return(FormatOutput(ReadFromStream(stream))); } catch (Exception ex) { return(Engine.GetService <ExceptionOperations>().FormatException(ex)); } }
public override void OnClick() { if (m_Hook == null) { return; } if (m_Hook.ArcGisMapControl.Map.LayerCount == 0) { MessageBox.Show("当前没有调阅数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } try { frmQuerySlope pfrmQuerySlope = new frmQuerySlope("坡度"); pfrmQuerySlope.WriteLog = WriteLog;//ygc 2012-9-12 是否写日志 pfrmQuerySlope.pMapControlDefault = m_Hook.MapControl; pfrmQuerySlope.initialization(); pfrmQuerySlope.Show(); } catch (Exception exError) { ErrorHandle.ShowFrmErrorHandle("提示", exError.Message); } }
/// <summary> /// Download the Buttons data about a game selection (GameID). /// </summary> /// <param name="selectedGameID"></param> /// <returns></returns> public static bool SelectedFormerGameButtonsDownload(int selectedGameID, out List <ButtonData> selectedSavedGameButtonList) { selectedSavedGameButtonList = new List <ButtonData>(); try { using (SqlConnection connection = new SqlConnection(Operations.QueryStringData.ServerAddress)) { SqlCommand command = new SqlCommand(Operations.QueryStringData.SelectedFormerGameButtonsQuery, connection); command.Parameters.Add("@SelectedGameID", SqlDbType.Int); command.Parameters["@SelectedGameID"].Value = selectedGameID; connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { selectedSavedGameButtonList.Add(new ButtonData(Convert.ToInt32(reader[0]), Convert.ToInt32(reader[1]), Convert.ToInt32(reader[2]), Convert.ToInt32(reader[3]))); } } } catch (Exception anException) { if (ErrorHandle != null) { ErrorHandle.Invoke(errorMessageText(ErrorMessage.SelectedFormerGameButtonsQuery, anException.Message)); } return(false); } return(true); }
void NofityError(Exception ex) { if (IgnoreError) { if (ForceAwaiterCompleteIfError) { m_AwaiterComplete?.Invoke(); } ClearEvent(); return; } Error = ex; if (ErrorHandle == null) { m_AwaiterComplete?.Invoke(); } else { ErrorHandle.Invoke(ex); if (ForceAwaiterCompleteIfError) { m_AwaiterComplete?.Invoke(); } } ClearEvent(); }
public OciParameterDescriptor GetParameter(int position) { IntPtr handle = IntPtr.Zero; int status = 0; status = OciCalls.OCIParamGet(this, OciHandleType.Statement, ErrorHandle, out handle, position + 1); if (status != 0) { OciErrorInfo info = ErrorHandle.HandleError(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } OciParameterDescriptor output = new OciParameterDescriptor(this, handle); output.ErrorHandle = ErrorHandle; if (parm == null) { parm = new ArrayList(); } parm.Add(handle); return(output); }
void DefineRaw(int position, OracleConnection connection) { ociType = OciDataType.Raw; fieldType = typeof(byte[]); value = OciCalls.AllocateClear(definedSize); int status = 0; status = OciCalls.OCIDefineByPos(Parent, out handle, ErrorHandle, position + 1, value, definedSize * 2, ociType, ref indicator, ref rlenp, IntPtr.Zero, 0); if (status != 0) { OciErrorInfo info = ErrorHandle.HandleError(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } }
public override void OnClick() { if (m_Hook.UserTree.SelectedNode != null) { Exception eError; User user = m_Hook.UserTree.SelectedNode.Tag as User; if (user == null) { return; } AddUser frmUser = new AddUser(user); if (frmUser.ShowDialog() == DialogResult.OK) { if (this.WriteLog) { Fan.Plugin.LogTable.Writelog(Caption);//xisheng 2011.07.09 增加日志 } ModuleOperator.DisplayUserTree("", m_Hook.UserTree, ref ModData.gisDb, out eError); if (eError != null) { ErrorHandle.ShowFrmErrorHandle("提示", eError.Message); return; } } } }
public int Write(byte[] buffer, uint offset, uint count, OracleType type) { int status = 0; uint amount = count; if (type == OracleType.Clob) { amount /= 2; } status = OciCalls.OCILobWrite(Service, ErrorHandle, this, ref amount, offset, buffer, count, 0, // OCI_ONE_PIECE IntPtr.Zero, IntPtr.Zero, 1000, // OCI_UCS2ID 0); if (status != 0) { OciErrorInfo info = ErrorHandle.HandleError(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } return((int)amount); }
void DefineNumber(int position, OracleConnection connection) { fieldType = typeof(System.Decimal); value = OciCalls.AllocateClear(definedSize); ociType = OciDataType.Char; int status = 0; status = OciCalls.OCIDefineByPos(Parent, out handle, ErrorHandle, position + 1, value, definedSize, ociType, indicator, rlenp, IntPtr.Zero, 0); if (status != 0) { OciErrorInfo info = ErrorHandle.HandleError(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } }
public static int updatePassword(string userId, string pssword, string psd)//根据二维码设置人员信息 { try { string sqlStr = "select * from MeUserInfo where uId=" + userId + " and uPassword='******'"; DataSet dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sqlStr); if (dt.Tables[0].Rows.Count > 0) { string sqlStr1 = "update MeUserInfo set uPassword='******' where uId=" + userId; int i = SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sqlStr1); if (i > 0) { return(i); } return(-1); } else { return(-1); } } catch (SyntaxErrorException e) { ErrorHandle.showError(e); return(-1); } }
public override void OnClick() { if (m_Hook.RoleTree.SelectedNode != null && m_Hook.PrivilegeTree.Tag != null) { Exception eError; Role role = m_Hook.RoleTree.SelectedNode.Tag as Role; if (role == null) { return; } XmlDocument doc = m_Hook.PrivilegeTree.Tag as XmlDocument; if (doc == null) { return; } if (!ModuleOperator.AddPrivilege(role, doc, ref ModData.gisDb, out eError)) { if (eError != null) { ErrorHandle.ShowInform("提示", eError.Message); return; } } else { ErrorHandle.ShowInform("提示", "更新成功!"); return; } } }
public void Prepare(string commandText) { int status = 0; if (this.disposed) { throw new InvalidOperationException("StatementHandle is already disposed."); } int rsize = 0; byte [] buffer; // Get size of buffer OciCalls.OCIUnicodeToCharSet(Parent, null, commandText, out rsize); // Fill buffer buffer = new byte[rsize]; OciCalls.OCIUnicodeToCharSet(Parent, buffer, commandText, out rsize); // Execute statement status = OciCalls.OCIStmtPrepare(this, ErrorHandle, buffer, buffer.Length, OciStatementLanguage.NTV, OciStatementMode.Default); if (status != 0) { OciErrorInfo info = ErrorHandle.HandleError(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } }
public override void OnClick() { if (m_Hook.RoleTree.SelectedNode != null) { Exception eError; Role role = m_Hook.RoleTree.SelectedNode.Tag as Role; if (role == null) { return; } AddGroup frmGroup = new AddGroup(role); if (frmGroup.ShowDialog() == DialogResult.OK) { if (this.WriteLog) { Fan.Plugin.LogTable.Writelog(Caption);//xisheng 2011.07.09 增加日志 } ModuleOperator.DisplayRoleTree("", m_Hook.RoleTree, ref ModData.gisDb, out eError); if (eError != null) { ErrorHandle.ShowFrmErrorHandle("提示", eError.Message); } } } }
public override void OnClick() { if (m_Hook.RoleTree.SelectedNode != null) { Exception eError; Role role = m_Hook.RoleTree.SelectedNode.Tag as Role; if (role == null) { return; } if (role.Name == "超级管理员") { ErrorHandle.ShowFrmErrorHandle("提示", "管理员不能删除!"); return; } if (ErrorHandle.ShowFrmInformation("确认", "取消", "确认删除?")) { if (ModuleOperator.DeleteData("role", "roleid", role.IDStr, ref ModData.gisDb, out eError)) { if (this.WriteLog) { Fan.Plugin.LogTable.Writelog(Caption);//xisheng 2011.07.09 增加日志 } m_Hook.RoleTree.SelectedNode.Remove(); } else { if (eError != null) { ErrorHandle.ShowInform("提示", eError.Message); } } } } }
private void buttonXOK_Click(object sender, EventArgs e) { if (textBox_Jpg.Text == "" || textBox_XLS.Text == "") { MessageBox.Show("请设置成果数据目录信息!", "提示!"); return; } Exception exError = null; SysGisTable sysTable = new SysGisTable(m_Workspace); Dictionary <string, object> dicData = new Dictionary <string, object>(); dicData.Add("DATATYPE", "文档成果数据"); dicData.Add("DATAPATH", textBox_XLS.Text); //判断是更新还是添加 //不存在则添加,已存在则更新 if (!sysTable.ExistData("RESULTDIR", "DATATYPE='文档成果数据'")) { if (!sysTable.NewRow("RESULTDIR", dicData, out exError)) { ErrorHandle.ShowFrmErrorHandle("提示", "添加失败!"); } } else { if (MessageBox.Show("已经存在文档成果数据目录信息,是否进行更新", "提示!", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { if (!sysTable.UpdateRow("RESULTDIR", "DATATYPE='文档成果数据'", dicData, out exError)) { ErrorHandle.ShowFrmErrorHandle("提示", "更新失败!"); } } } dicData = new Dictionary <string, object>(); dicData.Add("DATATYPE", "图件成果数据"); dicData.Add("DATAPATH", textBox_Jpg.Text); //判断是更新还是添加 //不存在则添加,已存在则更新 if (!sysTable.ExistData("RESULTDIR", "DATATYPE='图件成果数据'")) { if (!sysTable.NewRow("RESULTDIR", dicData, out exError)) { ErrorHandle.ShowFrmErrorHandle("提示", "添加失败!"); return; } } else { if (MessageBox.Show("已经存在图件成果数据目录信息,是否进行更新", "提示!", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { if (!sysTable.UpdateRow("RESULTDIR", "DATATYPE='图件成果数据'", dicData, out exError)) { ErrorHandle.ShowFrmErrorHandle("提示", "更新失败!"); return; } } } sysTable = null; this.Close(); this.Dispose(true); }
public RequestSchema(string sessionText, string methodText, string attachmentText = null) { MethodText = methodText; SessionText = sessionText; AttachmentText = attachmentText; Error = new ErrorHandle(); }
public static ConfigModel.PeriodRule GetPeriodRuleByPeriodName(string periodName, ConfigModel.JsonConfig config = null) { if (config == null) { config = GetJsonConfigData(); } return(ErrorHandle.Execute(() => _config.GetPeriodRuleByPeriodName(config, periodName))); }
/// <summary> /// Eagerly invokes the callback if in the error state. /// </summary> public Result <TError> OnError(ErrorHandle handle) { if (IsError) { handle(_error); } return(this); }
public void publishErrors() { Invoke((MethodInvoker) delegate { int totalErrors = 0; TreeNode curNode; if (ErrorHandle.WasSuccessful()) { treeView1.Nodes.Clear(); //Clear out the nodes //Add the errors TreeNode curErr; foreach (int fileid in ErrorHandle.getFileIDs()) { curNode = new TreeNode(ErrorHandle.getFilePath(fileid)); foreach (LineError error in ErrorHandle.getErrors(fileid)) { if (error.getSev() >= 20) { totalErrors += 1; curErr = curNode.Nodes.Add((error.getCode() == "" ? "" : error.getCode() + ": ") + error.getData().Trim() + " (" + error.getLine().ToString() + ")"); if (error.getCode() != "") { curErr.Tag = error.getLine().ToString() + ',' + error.getColumn().ToString(); } curErr.ImageIndex = 1; curErr.SelectedImageIndex = 1; } } //Only add a node if there is something to display if (curNode.Nodes.Count > 0) { curNode.ImageIndex = 0; curNode.SelectedImageIndex = 0; treeView1.Nodes.Add(curNode); } } if (totalErrors == 0) { treeView1.Nodes.Add(new TreeNode("No errors found for " + Library + "/" + Object + ".", 2, 2)); } if (treeView1.Nodes.Count <= 1) { treeView1.ExpandAll(); } } toolStripStatusLabel1.Text = "Total errors: " + totalErrors.ToString(); toolStripStatusLabel2.Text = ErrorHandle.doName(); toolStripStatusLabel3.Text = DateTime.Now.ToString("h:mm:ss tt"); }); }
//清空日志 public static void ClearLog(ListView lv) { if (m_sysTable == null) { return; } Exception err; ITable pTable = m_sysTable.OpenTable(m_LogNAME, out err); if (pTable == null) { MessageBox.Show(err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return;//若日志表不存在,返回null } //for (int i = 0; i < lv.Items.Count;i++ ) //{ // ListViewItem lvi = lv.Items[i]; // IQueryFilter pQF = new QueryFilterClass(); // pQF.WhereClause = "logTime = '" + lvi.SubItems[0].Text // + "' AND logUser = '******' AND logIP = '" + lvi.SubItems[1].Text // + "' AND logEVENT = '" + lvi.SubItems[3].Text+"'"; IWorkspace pWorkspace = m_gisDb.WorkSpace; ITransactions pTransactions = (ITransactions)pWorkspace; try { if (!pTransactions.InTransaction) { pTransactions.StartTransaction(); } } catch (Exception eX) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", eX.Message); return; } Exception exError; if (!m_sysTable.DeleteRows(m_LogNAME, "", out exError)) { ErrorHandle.ShowFrmErrorHandle("提示", "清空日志失败!" + exError.Message); return; } try { if (pTransactions.InTransaction) { pTransactions.CommitTransaction(); } } catch (Exception eX) { } //} }
public static void Logger(ILog log, string function, ErrorHandle errorHandleType, Action tryHandle, Action<Exception> catchHandle = null, Action finallyHandle = null) { try { log.Debug(function); tryHandle(); } catch (Exception ex) { log.Error(function + "失败", ex); if (catchHandle != null) catchHandle(ex); if (errorHandleType == ErrorHandle.Throw) throw ex; } finally { if (finallyHandle != null) finallyHandle(); } }