private double[] waveform; //Stim voltage #endregion Fields #region Constructors /// <summary> /// Electrical stimulation event to be interpreted by NeuroRighter's all channel stimulation board. /// </summary> /// <param name="channel">Channel to stimulate</param> /// <param name="time"> Time sample that stimulation should be applied </param> /// <param name="waveform"> Stimulation waveform. </param> public StimulusOutEvent(int channel, ulong time, double[] waveform) { try { this.channel = (short)channel; this.sampleIndex = time; this.waveform = new double[waveform.Length]; for (int i = 0; i < waveform.Length; i++) { this.waveform[i] = waveform[i]; } this.analogEncode = new double[2]; this.digitalEncode = new uint[3]; this.analogEncode[0] = Math.Ceiling((double)channel / 8.0); this.analogEncode[1] = (double)((channel - 1) % 8) + 1.0; this.digitalEncode[0] = Convert.ToUInt32(Math.Pow(2, (Properties.Settings.Default.StimPortBandwidth == 32 ? BLANKING_BIT_32bitPort : BLANKING_BIT_8bitPort))); this.digitalEncode[1] = channel2MUX_noEN((double)channel); this.digitalEncode[2] = channel2MUX((double)channel); this.sampleDuration = (uint)waveform.Length; if (DigitalEncode[1] == 0 || DigitalEncode[2] == 0) throw new Exception("NR stimulation exception: you are attempting to stimulate on channel " + channel.ToString() + " which has resulted in an error. \n" + "this could be caused by your Properties.Settings.Default.MUXChannels, which is set to " + Properties.Settings.Default.MUXChannels.ToString() + " and must be either 16 or 8" ); } catch (Exception e) { MessageBox.Show(e.Message); } }
public string CreateMessageHistory(Conn ObjConn, SqlCommand ObjSqlCommmand, int MessageID, string InquiryID, int FromUserID, string ExecutiveIP, int ToUserID,int MessageSequence, Int16 MessageRead) { return ObjConn.executescalarstringquery(ObjSqlCommmand, "INSERT INTO [MessageHistory]([MessageID],[ExecutiveIP],[CustomerID],[MessageSequence],[MessageRead])" + " VALUES (" + MessageID.ToString() + ",'" + InquiryID + "'," + FromUserID.ToString() + ",'" + ExecutiveIP + "'," + MessageSequence.ToString() + "','" + MessageRead.ToString() + ")" + " Select @@IDENTITY"); }
public Int16 MantenimientoEntrevista(EnEntrevista objEntrevista, List<EnCuestionario> lstCuestionario, string strEstado,Int16 intControlador) { log4net.ILog logger = log4net.LogManager.GetLogger("File"); Int16 intRpta = 0; try { using (TransactionScope tx = new TransactionScope()) { Int64 intCodEntrevista; intCodEntrevista = (new DaEntrevista()).MantenimientoEntrevista(objEntrevista, intControlador); for (int i = 0; i < lstCuestionario.Count; i++) { EnCuestionario objEnCuestionario = new EnCuestionario(); objEnCuestionario.FQ_Balotario_ID = lstCuestionario[i].FQ_Balotario_ID; objEnCuestionario.valor = lstCuestionario[i].valor; objEnCuestionario.FQ_Entrevista_ID = intCodEntrevista; NeCuestionario objNe = new NeCuestionario(); objNe.MantenimientoCuestionario(objEnCuestionario,intControlador); objEnCuestionario = null; } NeSolicitud objNesolicitud = new NeSolicitud(); intRpta = objNesolicitud.ActualizarSolicitudEstado(objEntrevista.FQ_Solicitud_ID, strEstado); tx.Complete(); } } catch (Exception ex) { logger.Error("Error " + ex.Message + "Metodo :MantenimientoEntrevista Controlador :" + intControlador.ToString() ); } return intRpta; }
public void NaplDenniBilanci(Int16 soutez, String login, DateTime datum, OdbcConnection spojeni) { /*---naplni denni bilanci pro zelene dny. Do poctu tipu celkem se pocitajio vsechny tipy * i ¨tipy za zatim neodahrane zapasy--*/ Tip spravne; Tip tip; Int16 vaha; OdbcCommand selekt; OdbcDataReader reader; String strSelekt = "SELECT typ,spravne,vaha from tipy, program WHERE tipy.kolo=" + " program.kolo AND tipy.radek=program.radek AND date_trunc('day',zelden)=? AND mlogin=?" + " AND program.kolo=" + soutez.ToString(); selekt = new OdbcCommand(strSelekt, spojeni); selekt.Parameters.Add(new OdbcParameter("@p_datum", OdbcType.DateTime)); selekt.Parameters["@p_datum"].Value = datum; selekt.Parameters.Add(new OdbcParameter("@p_login", OdbcType.NChar)); selekt.Parameters["@p_login"].Value = login; reader = selekt.ExecuteReader(); this.pocetTipuCelkem = 0; this.pocetTipuSpravne = 0; this.pocetTipuSpatne = 0; this.pocetDvotipuSpravne = 0; this.pocetJednotipuSpravne = 0; this.pocetBoduCelkem = 0; while (reader.Read()) { tip = new Tip(reader["typ"].ToString()); spravne = new Tip(reader["spravne"].ToString()); vaha = Int16.Parse(reader["vaha"].ToString()); this.pocetTipuCelkem++; if (spravne.vnitrniHodnota != "") { if (tip == spravne) { this.pocetBoduCelkem += vaha * tip.vnitrniVaha; this.pocetTipuSpravne++; if (tip.vnitrniHodnota == "3" || tip.vnitrniHodnota == "4") { this.pocetDvotipuSpravne++; } else { this.pocetJednotipuSpravne++; } } else { this.pocetTipuSpatne++; } } } reader.Close(); return; }
public INFATITime(Int16 Hour, Int16 Minute) { this.Hour = Hour; this.Minute = Minute; StringBuilder sb = new StringBuilder(); sb.Append(Hour.ToString("D2")); sb.Append(Minute.ToString("D2")); this.TimeId = Convert.ToInt32(sb.ToString()); }
public override string ToString() { return("base(" + base.ToString() + "); NumberOfControllers=" + NumberOfControllers.ToString() + " NumberOfSupBChannels=" + NumberOfSupBChannels.ToString() + " GlobalOptions=" + GlobalOptions.ToString() + " B1_prot_sup=" + B1_prot_sup.ToString() + " B2_prot_sup=" + B2_prot_sup.ToString() + " ManufactureInfo=" + ManufactureInfo0.ToString() + "." + ManufactureInfo1.ToString() + "." + ManufactureInfo2.ToString() + "." + ManufactureInfo3.ToString() + "." + ManufactureInfo4.ToString() + ";"); }
// Add a piece of data (hit) to this stats object. public void AddHit(Int16 raw_damage, Int16 absorbed_damage) { Int16 effective_damage = (Int16)(raw_damage - absorbed_damage); // TODO clean the format of the hits ArrayList up for cleaner calculations? this.hits.Add( raw_damage.ToString() + ',' + absorbed_damage.ToString() + ',' + effective_damage.ToString() ); }
private void DoCountTest(string text, Int16 resultCount) { StackFrame frame = new StackFrame(1); var method = frame.GetMethod(); var TestName = method.Name; SearchForText(ChromeDriver, text); TestAssert( TestName, GetResultSummaryText(ChromeDriver).Contains(resultCount.ToString())); }
static StackObject *ToString_11(ILIntepreter __intp, StackObject *__esp, List <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Int16 instance_of_this_method = GetInstance(__domain, ptr_of_this_method, __mStack); var result_of_this_method = instance_of_this_method.ToString(); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
public Int64 MantenimientoInformacionPatrimonial(EnInformacionPatrimonial objEnInfPatrimonial, Int16 intControlador) { log4net.ILog logger = log4net.LogManager.GetLogger("File"); Int64 intCodInformacionPatrimonialNeg; try { DaInformacionPatrimonial objInformacionPatrimonial = new DaInformacionPatrimonial(); intCodInformacionPatrimonialNeg = objInformacionPatrimonial.MantenimientoInformacionPatrimonial(objEnInfPatrimonial, intControlador); } catch (Exception ex) { intCodInformacionPatrimonialNeg = 0; logger.Error("Error " + ex.Message + "Metodo :MantenimientoInformacionPatrimonial Flag :" + intControlador.ToString()); } return intCodInformacionPatrimonialNeg; }
static StackObject *ToString_13(ILIntepreter __intp, StackObject *__esp, List <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.String format = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.Int16 instance_of_this_method = GetInstance(__domain, ptr_of_this_method, __mStack); var result_of_this_method = instance_of_this_method.ToString(format); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
public string append(Int16 m) { if (n.Length <= 9) { n += m.ToString(); } if (n.Contains("Error")) { n = string.Empty; n += m.ToString(); } edittext.Text = n; return n; }
public Int64 MantenimientoReferenciaLaboral(EnReferenciaLaboral objEnRefLaboral, Int16 intControlador) { Int64 intCodReferenciaLaboral; log4net.ILog logger = log4net.LogManager.GetLogger("File"); try { DaReferenciaLaboral objReferenciaLaboral = new DaReferenciaLaboral(); intCodReferenciaLaboral=objReferenciaLaboral.MantenimientoReferenciaLaboral(objEnRefLaboral,intControlador); } catch (Exception ex) { intCodReferenciaLaboral = 0; logger.Error("Error " + ex.Message + "Metodo :MantenimientoReferenciaLaboral Flag :" + intControlador.ToString()); } return intCodReferenciaLaboral; }
static StackObject *ToString_6(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.IFormatProvider @provider = (System.IFormatProvider) typeof(System.IFormatProvider).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.Int16 instance_of_this_method = GetInstance(__domain, ptr_of_this_method, __mStack); var result_of_this_method = instance_of_this_method.ToString(@provider); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
public Int64 MantenimientoReferenciaBancaria(EnReferenciaBancaria objEnRefBancaria, Int16 intControlador) { log4net.ILog logger = log4net.LogManager.GetLogger("File"); Int64 intCodReferenciaBancaria; try {DaReferenciaBancaria objReferenciaBancaria = new DaReferenciaBancaria(); intCodReferenciaBancaria=objReferenciaBancaria.MantenimientoReferenciaBancaria(objEnRefBancaria,intControlador); } catch (Exception ex) { intCodReferenciaBancaria = 0; logger.Error("Error " + ex.Message + "Metodo :MantenimientoReferenciaBancaria Flag :" + intControlador.ToString()); } return intCodReferenciaBancaria; }
public Int16 MantenimientoCuestionario(EnCuestionario objEnCuestionario, Int16 intControlador) { log4net.ILog logger = log4net.LogManager.GetLogger("File"); Int16 intCod=1; try { DaCuestionario objDa = new DaCuestionario(); objDa.MantenimientoCuestionario(objEnCuestionario, intControlador); } catch (Exception ex) { intCod = 0; logger.Error("Error " + ex.Message + "Metodo :MantenimientoCuestionario Controlador: " + intControlador.ToString()); } return intCod; }
public List<EnCandidato> ListarBusqueda(string strNumDocumento, string strnombre, Int16 intFlag) { log4net.ILog logger = log4net.LogManager.GetLogger("File"); SqlConnection cn = new SqlConnection(this.cadenaconexion); SqlCommand cmd = new SqlCommand("sp_ListarBusqueda", cn); List<EnCandidato> lstEnCandidato = new List<EnCandidato>(); cmd.Parameters.Add(new SqlParameter("@numeroDocumento", SqlDbType.VarChar)).Value = strNumDocumento; cmd.Parameters.Add(new SqlParameter("@nombre", SqlDbType.VarChar)).Value = strnombre; cmd.Parameters.Add(new SqlParameter("@flag", SqlDbType.Int)).Value = intFlag; cmd.CommandType = CommandType.StoredProcedure; try { cn.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { lstEnCandidato.Add(new EnCandidato() { FQ_Candidato_ID = dr.GetInt32(dr.GetOrdinal("FQ_Candidato_ID")), nombre = dr.GetString(dr.GetOrdinal("NOMBRE")), numeroDocumento = dr.GetString(dr.GetOrdinal("numeroDocumento")), tipoDocumento = dr.GetString(dr.GetOrdinal("tipoDocumento")), }); } dr.Close(); } catch (Exception ex) { logger.Error("Error " + ex.Message + "Metodo :ListarBusqueda NumeroDocumento: " + strNumDocumento + " Nombre :" + strnombre + " Flag :" + intFlag.ToString()); } finally { if (cn.State == ConnectionState.Open) { cn.Close(); } cn.Dispose(); } return lstEnCandidato; }
public OtherPlayer(float x, float y, float z, Int32 identity, Int16 mo, float xro, float yro) { model = mo; Console.WriteLine(mo); position.X = x; position.Y = y; position.Z = z; id = identity; alive = true; Console.WriteLine(mo.ToString()); if (model == Constants.HAMPUS) { mod = Globals.hampus; clipPlayer = new ClipPlayer(Globals.hampusSkinningData, 60); animationClip = Globals.hampusSkinningData.AnimationClips["Take 001"]; } else if (model == Constants.RASMUS) { mod = Globals.rasmus; clipPlayer = new ClipPlayer(Globals.rasmusSkinningData, 60); animationClip = Globals.rasmusSkinningData.AnimationClips["Take 001"]; } else if (model == Constants.VALTER) { mod = Globals.valter; clipPlayer = new ClipPlayer(Globals.valterSkinningData, 60); animationClip = Globals.valterSkinningData.AnimationClips["Take 001"]; } else if (model == Constants.AXEL) { mod = Globals.axel; clipPlayer = new ClipPlayer(Globals.axelSkinningData, 60); animationClip = Globals.axelSkinningData.AnimationClips["Take 001"]; } Globals.s += identity; xr = xro; yr = yro; Globals.players[identity] = this; //idle clipPlayer.play(animationClip, 570, 600, true); }
/// <summary> /// 각 어드레스에 값이 변경 되었을 경우.. Log를 기록한다. /// </summary> /// <param name="dr"></param> /// <param name="ReceiveValue"></param> /// <param name="isWirteByte"></param> /// <param name="SendByte"></param> /// <param name="ReciveByte"></param> /// <returns>변경 여부</returns> protected bool ChangeddAddressValue(DataRow dr, int ReceiveValue, bool isWirteByte, byte[] SendByte, byte[] ReceiveByte) { try { lock (this) { string oldValue = dr["Value"] != DBNull.Value ? string.Format("{0:X4}", dr["Value"]) : "(null)"; System.Int16 intReceiveValue = Convert.ToInt16(ReceiveValue); if (oldValue != intReceiveValue.ToString("X4")) { if (isWirteByte) { if (SendByte != null) { PLCModule.clsPLCModule.LogWrite("ChangeddAddressValue", "[Sent] " + ByteToString(SendByte)); } if (ReceiveByte != null) { PLCModule.clsPLCModule.LogWrite("ChangeddAddressValue", "[Received] " + ByteToString(ReceiveByte)); } } PLCModule.clsPLCModule.LogWrite("ChangeddAddressValue", string.Format("[{0}] {1} --> {2}", dr["Address"], oldValue, intReceiveValue.ToString("X4"))); dr["Value"] = intReceiveValue; dr["Value(HEX)"] = string.Format("{0:X4}", intReceiveValue); return(true); } return(false); } } catch { throw; } }
public static string FormatDate(byte? day, byte? month, Int16 year) { if(day.HasValue && month.HasValue) { int mindex = month.Value - 1; if (mindex >= 0 && mindex < 12) { return string.Format("{0}/{1}/{2}", day, months[mindex], year); } return string.Format("{0}/{1}/{2}", year, day, month); } if(month.HasValue) { int mindex = month.Value - 1; if (mindex >= 0 && mindex < 12) { return months[mindex] + "/" + year; } } return year.ToString(); }
private void button10_Click(object sender, EventArgs e) { byte[] return_data = new byte[500]; byte[] send_cmd = new byte[255]; Int16 rLen = -1; string cmdData; if (textBoxCmd.Text.Length<32) { cmdData = "00400" + Convert.ToString(textBoxCmd.Text.Length/2,16) + textBoxCmd.Text; } else { cmdData = "0040" + Convert.ToString(textBoxCmd.Text.Length/2,16) + textBoxCmd.Text; } byte[] cmd = Encoding.Default.GetBytes(cmdData); Program.asc_hex(cmd, send_cmd, cmd.Length); //异或 for (int i = 0; i < cmd.Length / 2; i++) { send_cmd[cmd.Length / 2] = (byte)(send_cmd[cmd.Length / 2] ^ send_cmd[i]); } st = Program.sam_slt_protocol(icdev, (byte)comboBoxSetcard.SelectedIndex, (Int16)(cmd.Length / 2+1), send_cmd, ref rLen, return_data); if (st == 0) { byte[] rec_data = new byte[100]; Program.hex_asc(return_data, rec_data, rLen + 3); //由于rLen是从receive_data[2]开始,CPU卡应答命令的长度,所以加2 listBox1.Items.Add("sam_slt_protocol ok! " + Encoding.Default.GetString(rec_data)); } else { listBox1.Items.Add("sam_slt_protocol error! " + st.ToString()); } }
/// <summary> /// Converts the value of the specified 16-bit signed integer to its equivalent SqlString representation. /// </summary> /// <param name="value">A 16-bit signed integer.</param> /// <returns>The SqlString equivalent of the 16-bit signed integer value.</returns> public static SqlString ToSqlString(Int16 value) { return value.ToString(); }
/// <summary> /// Converts the value of the specified nullable 16-bit signed integer to its equivalent SqlChars representation. /// </summary> /// <param name="value">A nullable 16-bit signed integer.</param> /// <returns>The equivalent SqlChars.</returns> public static SqlChars ToSqlChars(Int16? value) { return value.HasValue ? new SqlChars(value.ToString().ToCharArray()) : SqlChars.Null; }
public static string MoneyString(this Int16 input, string moneyString = "") { return(input.ToString(moneyString.Text(DefaultMoneyFormat))); }
private void loadBoatTimeView(Int16 inSpeed) { //Retrieve data for current tournament //Used for initial load and to refresh data after updates winStatusMsg.Text = "Retrieving boat times"; Cursor.Current = Cursors.WaitCursor; try { listBoatTimesDataGridView.Rows.Clear(); myTimesDataTable.DefaultView.RowFilter = "ListCode like '" + inSpeed.ToString() + "-" + getTimeClass() + "-%'"; DataTable curDataTable = myTimesDataTable.DefaultView.ToTable(); if ( curDataTable.Rows.Count > 0 ) { DataGridViewRow curViewRow; int curViewIdx = 0; foreach ( DataRow curDataRow in curDataTable.Rows ) { curViewIdx = listBoatTimesDataGridView.Rows.Add(); curViewRow = listBoatTimesDataGridView.Rows[curViewIdx]; try { curViewRow.Cells["BoatTimeKey"].Value = (String)curDataRow["ListCode"]; } catch { curViewRow.Cells["BoatTimeKey"].Value = ""; } try { curViewRow.Cells["ListCodeNum"].Value = ( (Decimal)curDataRow["ListCodeNum"] ).ToString( "##0" ); } catch { curViewRow.Cells["ListCodeNum"].Value = ""; } try { curViewRow.Cells["ActualTime"].Value = (String)curDataRow["CodeValue"]; } catch { curViewRow.Cells["ActualTime"].Value = ""; } try { curViewRow.Cells["FastTimeTol"].Value = ( (Decimal)curDataRow["MinValue"] ).ToString( "#0.00" ); } catch { curViewRow.Cells["FastTimeTol"].Value = ""; } try { curViewRow.Cells["SlowtimeTol"].Value = ( (Decimal)curDataRow["MaxValue"] ).ToString( "#0.00" ); } catch { curViewRow.Cells["SlowtimeTol"].Value = ""; } try { curViewRow.Cells["TimeKeyDesc"].Value = (String)curDataRow["CodeDesc"]; } catch { curViewRow.Cells["TimeKeyDesc"].Value = ""; } } listBoatTimesDataGridView.CurrentCell = listBoatTimesDataGridView.Rows[0].Cells["BoatTimeKey"]; } Cursor.Current = Cursors.Default; } catch ( Exception ex ) { MessageBox.Show( "Error retrieving boat times \n" + ex.Message ); } }
public static unsafe string OSInt16ToString(Int16 n, string s, CultureInfo ci) { if (Utilities.IsWindows) { NumberFormatInfo nfi = NumberFormatInfoFromLCID(LCIDFromCultureInfo(ci)); return n.ToString(s, nfi); } else { return OSNumberToStringMac(new IntPtr((void*)&n), s, ci, CFNumberType.kCFNumberSInt16Type, n); } }
public static Mono.Math.BigInteger ToMonoBigInteger(Int16 value) { return Mono.Math.BigInteger.Parse(value.ToString("#")); }
public static string ToString(Int16 value) { return(value.ToString()); }
private void transmitExternalScoreboard(String curSanctionId, String curMemberId, String curAgeGroup , byte curRound, short curPassNum, int curSkierRunNum, String curStatus , String curStartLen, String[] curPassAttr, Int16 curSpeedKph, String curRopeLenMetric, String curScoreRecap, decimal curScore) { String curSkierName = (String)TourEventRegDataGridView.Rows[myEventRegViewIdx].Cells["SkierName"].Value; String curTeamCode = (String)TourEventRegDataGridView.Rows[myEventRegViewIdx].Cells["TeamCode"].Value; DataRow[] curLineRow = SlalomLineSelect.myDataTable.Select( "ListCode = '" + curStartLen + "'" ); String curStartLenOff = ""; if (curLineRow.Length > 0) { curStartLenOff = (String)curLineRow[0]["CodeValue"]; } if (ExportLiveScoreboard.ScoreboardLocation.Length > 1) { String curSpeedMph = curPassAttr[3].Substring( 0, 2 ); curStartLen = SlalomLineSelect.CurrentValue; ExportLiveScoreboard.exportCurrentSkierSlalom( mySanctionNum , curMemberId, curAgeGroup, curTeamCode, curRound , curSkierName, SlalomSpeedSelect.CurrentValueDesc, curStartLenOff + "/" + curStartLen , curScore, Convert.ToDecimal( curScoreRecap ), (String)myPassRow["CodeValue"] ); } if (ExportLiveWeb.LiveWebLocation.Length > 1) { String curEventGroup = (String)TourEventRegDataGridView.Rows[myEventRegViewIdx].Cells["EventGroup"].Value; ExportLiveWeb.exportCurrentSkierSlalom( mySanctionNum, curMemberId, curAgeGroup, curRound, curSkierRunNum, curEventGroup ); } if (ExportLiveTwitter.TwitterLocation.Length > 1) { StringBuilder curTwitterMessage = new StringBuilder( "" ); if (ExportLiveTwitter.TwitterReportByValue.Equals( "Pass" )) { curTwitterMessage.Append( curSanctionId + " " + curAgeGroup + " " + curSkierName ); if (curTeamCode.Length > 0) { curTwitterMessage.Append( " Team: " + curTeamCode ); } curTwitterMessage.Append( " Score: " + curScore.ToString( "##0.00" ) ); curTwitterMessage.Append( " Pass: "******" buoys " ); curTwitterMessage.Append( " " + curPassAttr[2] + " " + curPassAttr[3].Substring( 0, 4 ) + "mph" ); curTwitterMessage.Append( " " + curRopeLenMetric + "M " + curSpeedKph.ToString() + "kph" ); curTwitterMessage.Append( " UNOFFICIAL " + DateTime.Now ); ExportLiveTwitter.sendMessage( curTwitterMessage.ToString() ); } else { if (curStatus.ToLower().Equals( "complete" )) { curTwitterMessage.Append( curSanctionId + " " + curAgeGroup + " " + curSkierName ); if (curTeamCode.Length > 0) { curTwitterMessage.Append( " Team: " + curTeamCode ); } curTwitterMessage.Append( " Score: " + curScore.ToString( "##0.00" ) ); curTwitterMessage.Append( " Pass: "******" buoys " ); curTwitterMessage.Append( " " + curPassAttr[2] + " " + curPassAttr[3].Substring( 0, 4 ) + "mph" ); curTwitterMessage.Append( " " + curRopeLenMetric + "M " + curSpeedKph.ToString() + "kph" ); curTwitterMessage.Append( " UNOFFICIAL " + DateTime.Now ); ExportLiveTwitter.sendMessage( curTwitterMessage.ToString() ); } } } }
private void RunMenu() { bool ReadLineLoopEnd = false; bool EntryParsedOK = false; System.Int16 ClientID = 0; System.Int16 ClientTaskPriority = 1; do { string ServerCommand = (Console.ReadLine()); if (ServerCommand.Length > 0) { ServerCommand = ServerCommand.Substring(0, 1); switch (Convert.ToChar(ServerCommand)) { case 'm': case 'M': Console.WriteLine(Environment.NewLine + "-> Available commands <-"); Console.WriteLine(" c: list connected Clients / C: list disconnected Clients"); Console.WriteLine(" d: disconnect a certain Client"); if (TLogging.DebugLevel > 0) { Console.WriteLine(" l: load AppDomain for a fake Client (for debugging purposes only!)"); } Console.WriteLine(" p: perform timed server processing manually now"); Console.WriteLine(" q: queue a Client Task for a certain Client"); Console.WriteLine(" s: Server Status"); if (TLogging.DebugLevel > 0) { Console.WriteLine(" y: show Server memory"); Console.WriteLine(" g: perform Server garbage collection (for debugging purposes only!)"); } Console.WriteLine(" e: export the database to yml.gz"); Console.WriteLine(" i: import a yml.gz, which will overwrite the database"); #if DEBUG Console.WriteLine(" r: Mark all Cached Tables for Refreshing"); #endif Console.WriteLine(" o: controlled Server shutdown (gets all connected clients to disconnect)"); Console.WriteLine(" u: unconditional Server shutdown (forces 'hard' disconnection of all Clients!)"); WriteServerPrompt(); // list connected Clients break; case 'c': Console.WriteLine(Environment.NewLine + "-> Connected Clients <-"); Console.WriteLine(TheServerManager.FormatClientList(false)); WriteServerPrompt(); // list disconnected Clients break; case 'C': Console.WriteLine(Environment.NewLine + "-> Disconnected Clients <-"); Console.WriteLine(TheServerManager.FormatClientList(true)); WriteServerPrompt(); // disconnect a certain Client break; case 'd': case 'D': Console.WriteLine(Environment.NewLine + "-> Disconnect a certain Client <-"); if (TheServerManager.ClientList.Count > 0) { Console.WriteLine(TheServerManager.FormatClientList(false)); Console.Write(" Enter ClientID: "); string ConsoleInput = Console.ReadLine(); try { ClientID = System.Int16.Parse(ConsoleInput); String CantDisconnectReason; if (TheServerManager.DisconnectClient(ClientID, out CantDisconnectReason)) { TLogging.Log("Client #" + ClientID.ToString() + ": disconnection will take place shortly."); } else { TLogging.Log( "Client #" + ClientID.ToString() + " could not be disconnected on admin request. Reason: " + CantDisconnectReason); } } catch (System.FormatException) { Console.WriteLine(" Entered ClientID is not numeric!"); } catch (Exception exp) { TLogging.Log( Environment.NewLine + "Exception occured while trying to disconnect a Client on admin request:" + Environment.NewLine + exp.ToString()); } } else { Console.WriteLine(" * no Clients connected *"); } WriteServerPrompt(); // load AppDomain for a fake Client (for debugging purposes only!) break; case 'e': case 'E': string YmlGZData = TImportExportWebConnector.ExportAllTables(); Console.Write(" Please enter filename of yml.gz file: "); string backupFile = Path.GetFullPath(Console.ReadLine()); if (!backupFile.EndsWith(".yml.gz")) { Console.WriteLine("filename has to end with .yml.gz. Please try again"); } else { FileStream fs = new FileStream(backupFile, FileMode.Create); byte[] buffer = Convert.FromBase64String(YmlGZData); fs.Write(buffer, 0, buffer.Length); fs.Close(); TLogging.Log("backup has been written to " + backupFile); } WriteServerPrompt(); break; case 'i': case 'I': Console.WriteLine(Environment.NewLine + "-> DELETING YOUR DATABASE <-"); Console.Write(" Enter YES to import the new database (anything else to leave command): "); if (Console.ReadLine() == "YES") { Console.Write(" Please enter filename of yml.gz file: "); string restoreFile = Path.GetFullPath(Console.ReadLine()); if (!File.Exists(restoreFile) || !restoreFile.EndsWith(".yml.gz")) { Console.WriteLine("invalid filename, please try again"); } else { FileStream fsRead = new FileStream(restoreFile, FileMode.Open); byte[] bufferRead = new byte[fsRead.Length]; fsRead.Read(bufferRead, 0, bufferRead.Length); fsRead.Close(); YmlGZData = Convert.ToBase64String(bufferRead); if (TImportExportWebConnector.ResetDatabase(YmlGZData)) { TLogging.Log("backup has been restored from " + restoreFile); } else { TLogging.Log("there have been problems with the restore"); } } WriteServerPrompt(); } else { Console.WriteLine(" Reset of database cancelled!"); WriteServerPrompt(); } break; case 'r': case 'R': Console.WriteLine(Environment.NewLine + "-> Marking all Cached Tables for Refreshing... <-"); TheServerManager.RefreshAllCachedTables(); WriteServerPrompt(); break; case 'p': case 'P': string resp = ""; Console.WriteLine(" Server Timed Processing Status: " + "runs daily at " + TheServerManager.TimedProcessingDailyStartTime24Hrs + "."); Console.WriteLine(" Partner Reminders: " + (TheServerManager.TimedProcessingJobEnabled("TProcessPartnerReminders") ? "On" : "Off")); Console.WriteLine(" Automatic Intranet Export: " + (TheServerManager.TimedProcessingJobEnabled("TProcessAutomatedIntranetExport") ? "On" : "Off")); Console.WriteLine(" Data Checks: " + (TheServerManager.TimedProcessingJobEnabled("TProcessDataChecks") ? "On" : "Off")); Console.WriteLine(" SMTP Server used for sending e-mails: " + TheServerManager.SMTPServer); if (TheServerManager.TimedProcessingJobEnabled("TProcessPartnerReminders")) { Console.WriteLine(""); Console.WriteLine("Do you want to run Reminder Processing now?"); Console.Write("Type YES to continue, anything else to skip:"); resp = Console.ReadLine(); if (resp == "YES") { TheServerManager.PerformTimedProcessingNow("TProcessPartnerReminders"); } } if (TheServerManager.TimedProcessingJobEnabled("TProcessAutomatedIntranetExport")) { Console.WriteLine(""); Console.WriteLine("Do you want to run Intranet Export Processing now?"); Console.Write("Type YES to continue, anything else to skip:"); resp = Console.ReadLine(); if (resp == "YES") { TheServerManager.PerformTimedProcessingNow("TProcessAutomatedIntranetExport"); } } if (TheServerManager.TimedProcessingJobEnabled("TProcessDataChecks")) { Console.WriteLine(""); Console.WriteLine("Do you want to run Data Checks Processing now?"); Console.Write("Type YES to continue, anything else to skip:"); resp = Console.ReadLine(); if (resp == "YES") { TheServerManager.PerformTimedProcessingNow("TProcessDataChecks"); } } WriteServerPrompt(); break; case 's': case 'S': Console.WriteLine(Environment.NewLine + "-> Server Status <-"); Console.WriteLine(); DisplayPetraServerInformation(TheServerManager); WriteServerPrompt(); break; case 'q': case 'Q': Console.WriteLine(Environment.NewLine + "-> Queue a Client Task for a certain Client <-"); if (TheServerManager.ClientList.Count > 0) { Console.WriteLine(TheServerManager.FormatClientList(false)); ReadClientID: Console.Write(" Enter ClientID: "); string ConsoleInput = Console.ReadLine(); try { ClientID = System.Int16.Parse(ConsoleInput); EntryParsedOK = true; } catch (System.FormatException) { Console.WriteLine(" Entered ClientID is not numeric!"); EntryParsedOK = false; } if (!EntryParsedOK) { goto ReadClientID; } Console.Write(" Enter Client Task Group: "); string ClientTaskGroup = Console.ReadLine(); Console.Write(" Enter Client Task Code: "); string ClientTaskCode = Console.ReadLine(); ReadClientTaskPriority: Console.Write(" Enter Client Task Priority: "); ConsoleInput = Console.ReadLine(); try { ClientTaskPriority = System.Int16.Parse(ConsoleInput); EntryParsedOK = true; } catch (System.FormatException) { Console.WriteLine(" Entered Client Task Priority is not numeric!"); EntryParsedOK = false; } if (!EntryParsedOK) { goto ReadClientTaskPriority; } try { if (TheServerManager.QueueClientTask(ClientID, ClientTaskGroup, ClientTaskCode, ClientTaskPriority)) { TLogging.Log("Client Task queued for Client #" + ClientID.ToString() + " on admin request."); } else { TLogging.Log( "Client Task for Client #" + ClientID.ToString() + " could not be queued on admin request."); } } catch (Exception exp) { TLogging.Log( Environment.NewLine + "Exception occured while queueing a Client Task on admin request:" + Environment.NewLine + exp.ToString()); } } else { Console.WriteLine(" * no Clients connected *"); } WriteServerPrompt(); // show Server memory break; case 'y': case 'Y': Console.WriteLine("Server memory: " + TheServerManager.ServerInfoMemory.ToString()); WriteServerPrompt(); // perform Server garbage collection break; case 'g': case 'G': Console.WriteLine("GarbageCollection performed. Server memory: " + TheServerManager.PerformGC().ToString()); WriteServerPrompt(); // unconditional Server shutdown break; case 'o': case 'O': Console.WriteLine(Environment.NewLine + "-> CONTROLLED SHUTDOWN (gets all connected clients to disconnect) <-"); Console.Write(" Enter YES to perform controlled shutdown (anything else to leave command): "); if (Console.ReadLine() == "YES") { if (!TheServerManager.StopServerControlled(false)) { Console.WriteLine(" Shutdown cancelled!"); WriteServerPrompt(); } } else { Console.WriteLine(" Shutdown cancelled!"); WriteServerPrompt(); } break; case 'u': case 'U': Console.WriteLine(Environment.NewLine + "-> UNCONDITIONAL SHUTDOWN (force disconnection of all Clients) <-"); Console.Write(" Enter YES to perform UNCONDITIONAL shutdown (anything else to leave command): "); if (Console.ReadLine() == "YES") { TheServerManager.StopServer(); ReadLineLoopEnd = true; } else { Console.WriteLine(" Shutdown cancelled!"); WriteServerPrompt(); } break; default: Console.WriteLine( Environment.NewLine + "-> Unrecognised command '" + ServerCommand + "' <- (Press 'm' for menu)"); WriteServerPrompt(); break; } // case Convert.ToChar( ServerCommand ) } else { WriteServerPrompt(); } } while (!(ReadLineLoopEnd == true)); }
/// <summary> /// shows the menu and processes the selections of the administrator /// </summary> public static void Menu() { bool ReadLineLoopEnd; bool EntryParsedOK; String ServerAdminCommand; String ConsoleInput; String ClientTaskCode; String ClientTaskGroup; String AdministrativeMessage; System.Int16 ClientID = 0; // assignment only to make code compile; has no functional implication System.Int16 ClientTaskPriority = 1; // assignment only to make code compile; has no functional implication // label // ReadClientID, used only for repeating invalid command line input // ReadClientTaskPriority; used only for repeating invalid command line input DisplayPetraServerInformation(); // // Startup done. // From now on just listen on menu commands... // Console.WriteLine(Environment.NewLine + "-> Press \"m\" for menu."); Console.Write(ServerAdminPrompt); // ServerAdmin stops after leaving the following loop...! ReadLineLoopEnd = false; do { ServerAdminCommand = (Console.ReadLine()); if (ServerAdminCommand.Length > 0) { ServerAdminCommand = ServerAdminCommand.Substring(0, 1); switch (Convert.ToChar(ServerAdminCommand)) { case 'm': case 'M': Console.WriteLine(Environment.NewLine + "-> Available commands <-"); Console.WriteLine(" c: list connected Clients / C: list disconnected Clients"); Console.WriteLine(" d: disconnect a certain Client"); Console.WriteLine(" p: perform timed server processing manually now"); Console.WriteLine(" q: queue a Client Task for a certain Client"); Console.WriteLine(" s: Server Status"); if (TLogging.DebugLevel > 0) { Console.WriteLine(" y: show Server memory"); Console.WriteLine(" g: perform Server garbage collection (for debugging purposes only!)"); } Console.WriteLine(" e: export the database to yml.gz"); Console.WriteLine(" i: import a yml.gz, which will overwrite the database"); Console.WriteLine(" j: upgrade the database"); if (TLogging.DebugLevel > 0) { Console.WriteLine(" r: Mark all Cached Tables for Refreshing"); } Console.WriteLine(" a: send administrative message to all connected clients"); Console.WriteLine(" o: controlled Server shutdown (gets all connected clients to disconnect)"); Console.WriteLine(" u: unconditional Server shutdown (forces 'hard' disconnection of all Clients!)"); #if DEBUG Console.WriteLine(" v: Clear all RDBMS Connection Pools"); #endif Console.WriteLine(" x: exit PETRAServerADMIN"); Console.Write(ServerAdminPrompt); break; case 'c': Console.WriteLine(Environment.NewLine + "-> Connected Clients <-"); Console.WriteLine(TRemote.FormatClientList(false)); Console.Write(ServerAdminPrompt); break; case 'C': Console.WriteLine(Environment.NewLine + "-> Disconnected Clients <-"); Console.WriteLine(TRemote.FormatClientList(true)); Console.Write(ServerAdminPrompt); break; case 'd': case 'D': Console.WriteLine(Environment.NewLine + "-> Disconnect a certain Client <-"); if (TRemote.GetClientList().Count > 0) { Console.WriteLine(TRemote.FormatClientList(false)); Console.Write(" Enter ClientID: "); ConsoleInput = Console.ReadLine(); DisconnectClient(ConsoleInput); } else { Console.WriteLine(" * no Clients connected *"); } Console.Write(ServerAdminPrompt); break; case 'e': case 'E': Console.WriteLine(Environment.NewLine + "-> Export the database to yml.gz file <-"); ExportDatabase(); Console.Write(ServerAdminPrompt); break; case 'i': case 'I': Console.WriteLine(Environment.NewLine + "-> Restore the database from yml.gz file <-"); RestoreDatabase(); Console.Write(ServerAdminPrompt); break; case 'j': Console.WriteLine(Environment.NewLine + "-> Upgrade the database ..."); UpgradeDatabase(); break; case 'r': case 'R': Console.WriteLine(Environment.NewLine + "-> Marking all Cached Tables for Refreshing... <-"); RefreshAllCachedTables(); Console.Write(ServerAdminPrompt); break; case 'v': case 'V': Console.WriteLine(Environment.NewLine + "-> Clearing all RDBMS Connection Pools... <-"); int NumberOfDBConnectionsAfterClearing = ClearConnectionPoolAndGetNumberOfDBConnections(); Console.WriteLine(Environment.NewLine + " Number of DB Connections after clearing all " + "RDBMS Connection Pools: " + NumberOfDBConnectionsAfterClearing.ToString()); Console.Write(ServerAdminPrompt); break; case 'p': case 'P': TRemote.PerformTimedProcessingNow("TProcessPartnerReminders"); TRemote.PerformTimedProcessingNow("TProcessDataChecks"); Console.Write(ServerAdminPrompt); break; case 's': case 'S': Console.WriteLine(Environment.NewLine + "-> Server Status <-"); Console.WriteLine(); DisplayPetraServerInformation(); Console.Write(ServerAdminPrompt); break; case 'q': case 'Q': Console.WriteLine(Environment.NewLine + "-> Queue a Client Task for a certain Client <-"); if (TRemote.GetClientList().Count > 0) { Console.WriteLine(TRemote.FormatClientList(false)); // ReadClientID: Console.Write(" Enter ClientID: "); ConsoleInput = Console.ReadLine(); EntryParsedOK = false; try { ClientID = System.Int16.Parse(ConsoleInput); EntryParsedOK = true; } catch (System.FormatException) { Console.WriteLine(" Entered ClientID is not numeric!"); } if (!EntryParsedOK) { } // goto ReadClientID; Console.Write(" Enter Client Task Group: "); ClientTaskGroup = Console.ReadLine(); Console.Write(" Enter Client Task Code: "); ClientTaskCode = Console.ReadLine(); // ReadClientTaskPriority: Console.Write(" Enter Client Task Priority: "); ConsoleInput = Console.ReadLine(); ClientTaskPriority = -1; try { ClientTaskPriority = System.Int16.Parse(ConsoleInput); EntryParsedOK = true; } catch (System.FormatException) { Console.WriteLine(" Entered Client Task Priority is not numeric!"); EntryParsedOK = false; } if (!EntryParsedOK) { } try { if (TRemote.QueueClientTask(ClientID, ClientTaskGroup, ClientTaskCode, null, null, null, null, ClientTaskPriority)) { TLogging.Log("Client Task queued for Client #" + ClientID.ToString() + " on admin request."); } else { TLogging.Log("Client Task for Client #" + ClientID.ToString() + " could not be queued on admin request."); } } catch (Exception exp) { TLogging.Log( Environment.NewLine + "Exception occured while queueing a Client Task on admin request:" + Environment.NewLine + exp.ToString()); } } else { Console.WriteLine(" * no Clients connected *"); } Console.Write(ServerAdminPrompt); break; case 'y': case 'Y': Console.WriteLine("Server memory: " + TRemote.GetServerInfoMemory().ToString()); Console.Write(ServerAdminPrompt); break; case 'g': case 'G': GC.Collect(); Console.WriteLine("GarbageCollection performed. Server memory: " + TRemote.PerformGC().ToString()); Console.Write(ServerAdminPrompt); break; case 'a': case 'A': Console.Write(" Enter Administrative Message (leave blank not to send a message): "); AdministrativeMessage = Console.ReadLine(); if (AdministrativeMessage.Trim() != String.Empty) { try { if (TRemote.QueueClientTask(-1, SharedConstants.CLIENTTASKGROUP_USERMESSAGE, AdministrativeMessage, "MODAL", null, Catalog.GetString("Administrative Message"), null, ClientTaskPriority)) { TLogging.Log("Administrative message queued for all connected clients."); } else { TLogging.Log("An error occured when trying to queue an administrative message for all clients."); } } catch (Exception exp) { TLogging.Log( Environment.NewLine + "Exception occured while queueing a Client Task for sending an administrative message on admin request:" + Environment.NewLine + exp.ToString()); } } Console.Write(ServerAdminPrompt); break; case 'o': case 'O': ReadLineLoopEnd = ShutDownControlled(true); break; case 'u': case 'U': ReadLineLoopEnd = ShutDown(true); break; case 'x': case 'X': // exit loop, ServerAdmin stops then ReadLineLoopEnd = true; break; default: Console.WriteLine(Environment.NewLine + "-> Unrecognised command '" + ServerAdminCommand + "' <- (Press 'm' for menu)"); Console.Write(ServerAdminPrompt); break; } // case Convert.ToChar( ServerAdminCommand ) } // if ServerAdminCommand.Length > 0 else { Console.Write(ServerAdminPrompt); } } while (!(ReadLineLoopEnd == true)); }
/// <summary> /// Put other User Default Constants here as well. /// -------------------------------------------------------------------------------}// ...{ /// The following set of functions serve as shortcuts to get User Defaults of a /// specific type. /// /// </summary> /// <param name="AKey">The Key of the User Default that should get retrieved.</param> /// <param name="ADefault">The value that should be returned in case the Key is not (yet) /// in the User Defaults. /// </param> /// <returns>void</returns> public System.Int16 GetInt16Default(String AKey, System.Int16 ADefault) { return(Convert.ToInt16(GetSystemDefault(AKey, ADefault.ToString()))); }
public static System.Int16 GetInt16Default(String AKey, System.Int16 ADefault = 0, TDataBase ADataBase = null) { return(Convert.ToInt16(GetUserDefault(AKey, ADefault.ToString()))); }
/// <summary> /// Converts the value of the specified nullable 16-bit signed integer to its equivalent SqlString representation. /// </summary> /// <param name="value">A nullable 16-bit signed integer.</param> /// <returns>The SqlString equivalent of nullable 16-bit signed integer value.</returns> public static SqlString ToSqlString(Int16? value) { return value.HasValue ? value.ToString() : SqlString.Null; }
public void NaplnCelkovouBilanci(Int16 soutez, String strUzivatel, OdbcConnection spojeni, String proCo) { /*----naplni bilanci za soutez. Do poctu tipu celkem se nepocitaji tipy * za neodehrane zapasy-- proCo urcuje jestli se bilance pocita jen pro playoff nebo pro vsechno vcetne playoff*/ Int16 vaha; Tip spravne; Tip tip; DateTime datumOd = DateTime.MinValue; if (proCo == "P") { datumOd = knihovna_ser.DejDatumPlayOff(spojeni, soutez); if (datumOd == DateTime.MinValue) { /*---to znamena, ze se zatim playoff nehraje--*/ return; } } /*----cyklus nad tipy daneho uzivatele v dane soutezi---*/ String strSQL = "SELECT typ,spravne,vaha FROM tipy,program" + " WHERE tipy.kolo=program.kolo AND tipy.radek=program.radek AND mlogin='******' AND tipy.kolo=" + soutez.ToString() + " AND mdo>=?"; OdbcCommand prikazSelekt = new OdbcCommand(strSQL, spojeni); prikazSelekt.Parameters.Add(new OdbcParameter("@p_datum", OdbcType.DateTime)); prikazSelekt.Parameters["@p_datum"].Value = datumOd; OdbcDataReader reader = prikazSelekt.ExecuteReader(); this.pocetTipuCelkem = 0; this.pocetTipuSpravne = 0; this.pocetTipuSpatne = 0; this.pocetDvotipuSpravne = 0; this.pocetJednotipuSpravne = 0; this.pocetBoduCelkem = 0; while (reader.Read()) { vaha = Int16.Parse(reader["vaha"].ToString()); tip = new Tip(reader["typ"].ToString()); spravne = new Tip(reader["spravne"].ToString()); if (tip == spravne) { this.pocetTipuSpravne++; this.pocetBoduCelkem += vaha * tip.vnitrniVaha; if (tip.vnitrniHodnota == "3" || tip.vnitrniHodnota == "4") { this.pocetDvotipuSpravne++; } else { this.pocetJednotipuSpravne++; } } if (spravne.vnitrniHodnota != "") { this.pocetTipuCelkem++; } } reader.Close(); return; }
/// <summary> /// Writes an Int16 value to the stream /// </summary> /// <param name="value"></param> public void WriteValue(System.Int16 value) { logger.Debug(String.Format("WriteValue( {0} ); //System.Int16; _currentState : {1}; _top : {2};", value, _currentState, _top)); AutoComplete(StepToken.Integer); _writer.Write(value.ToString(CultureInfo.InvariantCulture)); }
/// <summary> /// The following set of functions serve as shortcuts to get User Defaults of a /// specific type. /// /// </summary> /// <param name="AKey">The Key of the User Default that should get retrieved.</param> /// <param name="ADefault">The value that should be returned in case the Key is not (yet) /// in the User Defaults. /// </param> /// <returns>void</returns> public static System.Int16 GetInt16Default(String AKey, System.Int16 ADefault) { return(Convert.ToInt16(TInternal.GetUserDefault(AKey, ADefault.ToString()))); }
/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>SqlString</c> value.</summary> public static SqlString ToSqlString(Int16 p) { return p.ToString(); }
public static BigInteger ToBigInteger(Int16 value) { return BigInteger.Parse(value.ToString("#")); }
internal String GetAssemblyName(Int16 assemblyId) { BamlAssembly bamlAssembly; if (TryGetBamlAssembly(assemblyId, out bamlAssembly)) { return bamlAssembly.Name; } throw new KeyNotFoundException(SR.Get(SRID.BamlAssemblyIdNotFound, assemblyId.ToString(System.Windows.Markup.TypeConverterHelper.InvariantEnglishUS))); }
/// <summary> /// Returns a DataTable for the requested 'Page'. /// </summary> /// <remarks><see cref="ExecuteQuery" /> (or <see cref="ExecuteFullQuery" />) /// needs to be called before to execute the SQL SELECT Statement to be able to return data.</remarks> /// <param name="APage">The 'Page' that should be returned</param> /// <param name="APageSize">Number of DataRows that a 'Page' should contain.</param> /// <returns>DataTable containing 'PageSize' (or less if the 'TotalRecords' are /// less than that value) DataRows. /// </returns> public DataTable GetData(Int16 APage, Int16 APageSize) { TLogging.LogAtLevel(7, String.Format("TPagedDataSet.GetData called (APage: {0}, APageSize={1})", APage, APageSize)); // wait until the query has been run in the other thread while (FTotalRecords == -1) { System.Threading.Thread.Sleep(500); } if (APage != FLastRetrievedPage) { FLastRetrievedPage = APage; if (APage == 0) { FTotalPages = Convert.ToInt16(Math.Ceiling(((double)FTotalRecords) / ((double)APageSize))); TLogging.LogAtLevel(7, "FTotalPages: " + FTotalPages.ToString()); if (FTotalRecords > 0) { // Build FPageDataTable CopyRowsInPage(0, APageSize); } } else { // page > 0 if (FTotalRecords > 0) { if (APage <= FTotalPages) { FPageDataTable.Rows.Clear(); // Build FPageDataTable CopyRowsInPage(APage, APageSize); } // FRecordsAffected > 0 else { throw new EPagedTableNoSuchPageException( "Tried to retrieve page " + APage.ToString() + ", but there are only " + FTotalPages.ToString() + " pages in the paged table!"); } } else { throw new EPagedTableNoRecordsException(); } } } // (APage > FLastRetrievedPage) or (APage = 0) else { if (APage >= 0) { // return empty DataTable FPageDataTable.Rows.Clear(); } else { throw new EPagedTableNoSuchPageException("Invalid page " + APage.ToString() + " was requested"); } } TProgressTracker.SetCurrentState(FProgressID, "Query executed.", 100.0m); TProgressTracker.FinishJob(FProgressID); return(FPageDataTable); }
internal XamlType GetXamlType(Int16 typeId) { BamlType bamlType; XamlType xamlType; if (TryGetBamlType(typeId, out bamlType, out xamlType)) { if (xamlType != null) { return xamlType; } return ResolveBamlType(bamlType, typeId); } throw new KeyNotFoundException(SR.Get(SRID.BamlTypeIdNotFound, typeId.ToString(System.Windows.Markup.TypeConverterHelper.InvariantEnglishUS))); }
private void setBoatTimeRow( Int16 inSpeed, Int16 inScore ) { String curTimeKey = inSpeed.ToString() + "-" + getTimeClass() + "-" + inScore.ToString(); DataRow[] curTimeRowsFound = myTimesDataTable.Select( "ListCode = '" + curTimeKey + "'" ); if ( curTimeRowsFound.Length > 0 ) { myTimeRow = curTimeRowsFound[0]; } else { myTimeRow = null; } }
// // Helper for Enum.Format(,,"d") // private static String DoFormatD(ulong rawValue, RuntimeImports.RhCorElementType corElementType) { switch (corElementType) { case RuntimeImports.RhCorElementType.ELEMENT_TYPE_I1: { SByte result = (SByte)rawValue; return(result.ToString()); } case RuntimeImports.RhCorElementType.ELEMENT_TYPE_U1: { Byte result = (Byte)rawValue; return(result.ToString()); } case RuntimeImports.RhCorElementType.ELEMENT_TYPE_BOOLEAN: { // direct cast from bool to byte is not allowed bool b = (rawValue != 0); return(b.ToString()); } case RuntimeImports.RhCorElementType.ELEMENT_TYPE_I2: { Int16 result = (Int16)rawValue; return(result.ToString()); } case RuntimeImports.RhCorElementType.ELEMENT_TYPE_U2: { UInt16 result = (UInt16)rawValue; return(result.ToString()); } case RuntimeImports.RhCorElementType.ELEMENT_TYPE_CHAR: { Char result = (Char)rawValue; return(result.ToString()); } case RuntimeImports.RhCorElementType.ELEMENT_TYPE_U4: { UInt32 result = (UInt32)rawValue; return(result.ToString()); } case RuntimeImports.RhCorElementType.ELEMENT_TYPE_I4: { Int32 result = (Int32)rawValue; return(result.ToString()); } case RuntimeImports.RhCorElementType.ELEMENT_TYPE_U8: { UInt64 result = (UInt64)rawValue; return(result.ToString()); } case RuntimeImports.RhCorElementType.ELEMENT_TYPE_I8: { Int64 result = (Int64)rawValue; return(result.ToString()); } default: Contract.Assert(false, "Invalid Object type in Format"); throw new InvalidOperationException(SR.InvalidOperation_UnknownEnumType); } }
/// <summary> /// Calculates the value this animation believes should be the current value for the property. /// </summary> /// <param name="defaultOriginValue"> /// This value is the suggested origin value provided to the animation /// to be used if the animation does not have its own concept of a /// start value. If this animation is the first in a composition chain /// this value will be the snapshot value if one is available or the /// base property value if it is not; otherise this value will be the /// value returned by the previous animation in the chain with an /// animationClock that is not Stopped. /// </param> /// <param name="defaultDestinationValue"> /// This value is the suggested destination value provided to the animation /// to be used if the animation does not have its own concept of an /// end value. This value will be the base value if the animation is /// in the first composition layer of animations on a property; /// otherwise this value will be the output value from the previous /// composition layer of animations for the property. /// </param> /// <param name="animationClock"> /// This is the animationClock which can generate the CurrentTime or /// CurrentProgress value to be used by the animation to generate its /// output value. /// </param> /// <returns> /// The value this animation believes should be the current value for the property. /// </returns> protected override Int16 GetCurrentValueCore(Int16 defaultOriginValue, Int16 defaultDestinationValue, AnimationClock animationClock) { Debug.Assert(animationClock.CurrentState != ClockState.Stopped); if (!_isAnimationFunctionValid) { ValidateAnimationFunction(); } double progress = animationClock.CurrentProgress.Value; IEasingFunction easingFunction = EasingFunction; if (easingFunction != null) { progress = easingFunction.Ease(progress); } Int16 from = new Int16(); Int16 to = new Int16(); Int16 accumulated = new Int16(); Int16 foundation = new Int16(); // need to validate the default origin and destination values if // the animation uses them as the from, to, or foundation values bool validateOrigin = false; bool validateDestination = false; switch(_animationType) { case AnimationType.Automatic: from = defaultOriginValue; to = defaultDestinationValue; validateOrigin = true; validateDestination = true; break; case AnimationType.From: from = _keyValues[0]; to = defaultDestinationValue; validateDestination = true; break; case AnimationType.To: from = defaultOriginValue; to = _keyValues[0]; validateOrigin = true; break; case AnimationType.By: // According to the SMIL specification, a By animation is // always additive. But we don't force this so that a // user can re-use a By animation and have it replace the // animations that precede it in the list without having // to manually set the From value to the base value. to = _keyValues[0]; foundation = defaultOriginValue; validateOrigin = true; break; case AnimationType.FromTo: from = _keyValues[0]; to = _keyValues[1]; if (IsAdditive) { foundation = defaultOriginValue; validateOrigin = true; } break; case AnimationType.FromBy: from = _keyValues[0]; to = AnimatedTypeHelpers.AddInt16(_keyValues[0], _keyValues[1]); if (IsAdditive) { foundation = defaultOriginValue; validateOrigin = true; } break; default: Debug.Fail("Unknown animation type."); break; } if (validateOrigin && !AnimatedTypeHelpers.IsValidAnimationValueInt16(defaultOriginValue)) { throw new InvalidOperationException( SR.Get( SRID.Animation_Invalid_DefaultValue, this.GetType(), "origin", defaultOriginValue.ToString(CultureInfo.InvariantCulture))); } if (validateDestination && !AnimatedTypeHelpers.IsValidAnimationValueInt16(defaultDestinationValue)) { throw new InvalidOperationException( SR.Get( SRID.Animation_Invalid_DefaultValue, this.GetType(), "destination", defaultDestinationValue.ToString(CultureInfo.InvariantCulture))); } if (IsCumulative) { double currentRepeat = (double)(animationClock.CurrentIteration - 1); if (currentRepeat > 0.0) { Int16 accumulator = AnimatedTypeHelpers.SubtractInt16(to, from); accumulated = AnimatedTypeHelpers.ScaleInt16(accumulator, currentRepeat); } } // return foundation + accumulated + from + ((to - from) * progress) return AnimatedTypeHelpers.AddInt16( foundation, AnimatedTypeHelpers.AddInt16( accumulated, AnimatedTypeHelpers.InterpolateInt16(from, to, progress))); }
/// <summary> /// shows the menu and processes the selections of the administrator /// </summary> public static void Menu() { bool ReadLineLoopEnd; bool EntryParsedOK; String ServerAdminCommand; String ConsoleInput; String ClientTaskCode; String ClientTaskGroup; System.Int16 ClientID = 0; // assignment only to make code compile; has no functional implication System.Int16 ClientTaskPriority = 1; // assignment only to make code compile; has no functional implication // label // ReadClientID, used only for repeating invalid command line input // ReadClientTaskPriority; used only for repeating invalid command line input DisplayPetraServerInformation(); // // Startup done. // From now on just listen on menu commands... // Console.WriteLine(Environment.NewLine + "-> Press \"m\" for menu."); Console.Write(ServerAdminPrompt); // ServerAdmin stops after leaving the following loop...! ReadLineLoopEnd = false; do { ServerAdminCommand = (Console.ReadLine()); if (ServerAdminCommand.Length > 0) { ServerAdminCommand = ServerAdminCommand.Substring(0, 1); switch (Convert.ToChar(ServerAdminCommand)) { case 'm': case 'M': Console.WriteLine(Environment.NewLine + "-> Available commands <-"); Console.WriteLine(" c: list connected Clients / C: list disconnected Clients"); Console.WriteLine(" d: disconnect a certain Client"); Console.WriteLine(" p: perform timed server processing manually now"); Console.WriteLine(" q: queue a Client Task for a certain Client"); Console.WriteLine(" s: Server Status"); if (TLogging.DebugLevel > 0) { Console.WriteLine(" y: show Server memory"); Console.WriteLine(" g: perform Server garbage collection (for debugging purposes only!)"); } Console.WriteLine(" e: export the database to yml.gz"); Console.WriteLine(" i: import a yml.gz, which will overwrite the database"); Console.WriteLine(" j: upgrade the database"); if (TLogging.DebugLevel > 0) { Console.WriteLine(" r: Mark all Cached Tables for Refreshing"); } Console.WriteLine(" o: controlled Server shutdown (gets all connected clients to disconnect)"); Console.WriteLine(" u: unconditional Server shutdown (forces 'hard' disconnection of all Clients!)"); Console.WriteLine(" x: exit PETRAServerADMIN"); Console.Write(ServerAdminPrompt); break; case 'c': Console.WriteLine(Environment.NewLine + "-> Connected Clients <-"); Console.WriteLine(TRemote.FormatClientList(false)); Console.Write(ServerAdminPrompt); break; case 'C': Console.WriteLine(Environment.NewLine + "-> Disconnected Clients <-"); Console.WriteLine(TRemote.FormatClientList(true)); Console.Write(ServerAdminPrompt); break; case 'd': case 'D': Console.WriteLine(Environment.NewLine + "-> Disconnect a certain Client <-"); if (TRemote.GetClientList().Count > 0) { Console.WriteLine(TRemote.FormatClientList(false)); Console.Write(" Enter ClientID: "); ConsoleInput = Console.ReadLine(); DisconnectClient(ConsoleInput); } else { Console.WriteLine(" * no Clients connected *"); } Console.Write(ServerAdminPrompt); // queue a Client Task for a certain Client break; case 'e': case 'E': Console.WriteLine(Environment.NewLine + "-> Export the database to yml.gz file <-"); ExportDatabase(); Console.Write(ServerAdminPrompt); // queue a Client Task for a certain Client break; case 'i': case 'I': Console.WriteLine(Environment.NewLine + "-> Restore the database from yml.gz file <-"); RestoreDatabase(); Console.Write(ServerAdminPrompt); // queue a Client Task for a certain Client break; case 'j': Console.WriteLine(Environment.NewLine + "-> Upgrade the database ..."); UpgradeDatabase(); break; case 'r': case 'R': Console.WriteLine(Environment.NewLine + "-> Marking all Cached Tables for Refreshing... <-"); RefreshAllCachedTables(); Console.Write(ServerAdminPrompt); break; case 'p': case 'P': #if TODORemoting string resp = ""; Console.WriteLine(" Server Timed Processing Status: " + "runs daily at " + TRemote.GetTimedProcessingDailyStartTime24Hrs + "."); Console.WriteLine(" Partner Reminders: " + (TRemote.TimedProcessingJobEnabled("TProcessPartnerReminders") ? "On" : "Off")); Console.WriteLine(" Automatic Intranet Export: " + (TRemote.TimedProcessingJobEnabled("TProcessAutomatedIntranetExport") ? "On" : "Off")); Console.WriteLine(" Data Checks: " + (TRemote.TimedProcessingJobEnabled("TProcessDataChecks") ? "On" : "Off")); Console.WriteLine(" SMTP Server used for sending e-mails: " + TRemote.SMTPServer); if (TRemote.TimedProcessingJobEnabled("TProcessPartnerReminders")) { Console.WriteLine(""); Console.WriteLine("Do you want to run Reminder Processing now?"); Console.Write("Type YES to continue, anything else to skip:"); resp = Console.ReadLine(); if (resp == "YES") { TRemote.PerformTimedProcessingNow("TProcessPartnerReminders"); } } if (TRemote.TimedProcessingJobEnabled("TProcessAutomatedIntranetExport")) { Console.WriteLine(""); Console.WriteLine("Do you want to run Intranet Export Processing now?"); Console.Write("Type YES to continue, anything else to skip:"); resp = Console.ReadLine(); if (resp == "YES") { TRemote.PerformTimedProcessingNow("TProcessAutomatedIntranetExport"); } } if (TRemote.TimedProcessingJobEnabled("TProcessDataChecks")) { Console.WriteLine(""); Console.WriteLine("Do you want to run Data Checks Processing now?"); Console.Write("Type YES to continue, anything else to skip:"); resp = Console.ReadLine(); if (resp == "YES") { TRemote.PerformTimedProcessingNow("TProcessDataChecks"); } } Console.Write(ServerAdminPrompt); #endif break; case 's': case 'S': Console.WriteLine(Environment.NewLine + "-> Server Status <-"); Console.WriteLine(); DisplayPetraServerInformation(); Console.Write(ServerAdminPrompt); break; case 'q': case 'Q': Console.WriteLine(Environment.NewLine + "-> Queue a Client Task for a certain Client <-"); if (TRemote.GetClientList().Count > 0) { Console.WriteLine(TRemote.FormatClientList(false)); // ReadClientID: Console.Write(" Enter ClientID: "); ConsoleInput = Console.ReadLine(); EntryParsedOK = false; try { ClientID = System.Int16.Parse(ConsoleInput); EntryParsedOK = true; } catch (System.FormatException) { Console.WriteLine(" Entered ClientID is not numeric!"); } if (!EntryParsedOK) { } // goto ReadClientID; Console.Write(" Enter Client Task Group: "); ClientTaskGroup = Console.ReadLine(); Console.Write(" Enter Client Task Code: "); ClientTaskCode = Console.ReadLine(); // ReadClientTaskPriority: Console.Write(" Enter Client Task Priority: "); ConsoleInput = Console.ReadLine(); ClientTaskPriority = -1; try { ClientTaskPriority = System.Int16.Parse(ConsoleInput); EntryParsedOK = true; } catch (System.FormatException) { Console.WriteLine(" Entered Client Task Priority is not numeric!"); EntryParsedOK = false; } if (!EntryParsedOK) { } // goto ReadClientTaskPriority; try { if (TRemote.QueueClientTask(ClientID, ClientTaskGroup, ClientTaskCode, ClientTaskPriority)) { TLogging.Log("Client Task queued for Client #" + ClientID.ToString() + " on admin request."); } else { TLogging.Log("Client Task for Client #" + ClientID.ToString() + " could not be queued on admin request."); } } catch (Exception exp) { TLogging.Log( Environment.NewLine + "Exception occured while queueing a Client Task on admin request:" + Environment.NewLine + exp.ToString()); } } else { Console.WriteLine(" * no Clients connected *"); } Console.Write(ServerAdminPrompt); break; case 'y': case 'Y': Console.WriteLine("Server memory: " + TRemote.GetServerInfoMemory().ToString()); Console.Write(ServerAdminPrompt); break; case 'g': case 'G': GC.Collect(); Console.WriteLine("GarbageCollection performed. Server memory: " + TRemote.PerformGC().ToString()); Console.Write(ServerAdminPrompt); break; case 'o': case 'O': ReadLineLoopEnd = ShutDownControlled(true); break; case 'u': case 'U': ReadLineLoopEnd = ShutDown(true); break; case 'x': case 'X': // exit loop, ServerAdmin stops then ReadLineLoopEnd = true; break; default: Console.WriteLine(Environment.NewLine + "-> Unrecognised command '" + ServerAdminCommand + "' <- (Press 'm' for menu)"); Console.Write(ServerAdminPrompt); break; } // case Convert.ToChar( ServerAdminCommand ) } // if ServerAdminCommand.Length > 0 else { Console.Write(ServerAdminPrompt); } } while (!(ReadLineLoopEnd == true)); }