// TwoWayRequest: Accept two integer values, return their sum public byte[] TwoWayRequest(WsWsaHeader header, XmlReader reader) { try { // Find beginning of request reader.ReadStartElement("TwoWayRequest", SimpleServiceNamespaceUri); // Find the values to be added int X = Convert.ToInt32(reader.ReadElementString("X", SimpleServiceNamespaceUri)); int Y = Convert.ToInt32(reader.ReadElementString("Y", SimpleServiceNamespaceUri)); Log.Comment(""); Log.Comment("X = " + X.ToString() + " Y = " + Y.ToString()); Log.Comment(X.ToString() + " + " + Y.ToString() + " = " + ((int)(X + Y)).ToString()); Log.Comment(""); // Return the response return(TwoWayResponse(header, X + Y)); } catch (Exception e) { // Something went wrong throw new WsFaultException(header, WsFaultType.XmlException, e.ToString()); } }
private static void CheckDbVersion(ref bool datFound) { if (!datFound) { return; } int testVersion = 0; try { SQLiteCommand dbVersionCommand = new SQLiteCommand(@"SELECT version from version limit 1", Connection); object res = dbVersionCommand.ExecuteScalar(); if (res != null && res != DBNull.Value) { testVersion = Convert.ToInt32(res); } if (testVersion == DBVersion) { return; } } catch (Exception) { } Connection.Close(); File.Delete(DirFilename); Connection.Open(); datFound = false; }
protected override void CustomSort(int ColumnIndex) { if (OldColumnIndex != ColumnIndex) { SortDirection = SortDirection.Asc; } if (SortDirection == SortDirection.Desc) { SortDirection = SortDirection.Asc; } else { SortDirection = SortDirection.Desc; } OldColumnIndex = ColumnIndex; var resultList = new List <NextPerformance>(); var list = radGridView1.Rows.Select(i => i).ToList(); list.Sort(new GridViewDataRowInfoComparer(ColumnIndex, Convert.ToInt32(SortDirection))); resultList.AddRange(list.Select(i => i.Tag as NextPerformance)); SetItemsArray(resultList.ToArray()); }
static public string CalculateHashPassword(int iLength) { _pStrBuilder.Length = 0; for (int i = 0; i < iLength; i++) { ERandomCharType eRandomType = (ERandomCharType)Random.Range(0, PrimitiveHelper.GetEnumLength <ERandomCharType>()); int iRandomChar = 0; switch (eRandomType) { case ERandomCharType.LowerCase: iRandomChar = Random.Range(Convert.ToInt32('a'), Convert.ToInt32('z')); _pStrBuilder.Append(Convert.ToChar(iRandomChar)); break; case ERandomCharType.UpperCase: iRandomChar = Random.Range(Convert.ToInt32('A'), Convert.ToInt32('Z')); _pStrBuilder.Append(Convert.ToChar(iRandomChar)); break; case ERandomCharType.Number: iRandomChar = Random.Range(0, 10); _pStrBuilder.Append(iRandomChar.ToString()); break; } } return(_pStrBuilder.ToString()); }
private void Button_Click(object sender, RoutedEventArgs e) { int h = Convert.ToInt32(height.Text); int w = Convert.ToInt32(weight.Text); BMIResult.Content = "Your BMI Is " + (w * 703) / (h * h); }
protected override void CustomSort(int ColumnIndex) { if (OldColumnIndex != ColumnIndex) { SortDirection = SortDirection.Asc; } if (SortDirection == SortDirection.Desc) { SortDirection = SortDirection.Asc; } else { SortDirection = SortDirection.Desc; } var resultList = new List <Directive>(); var list = radGridView1.Rows.Select(i => i).ToList(); list.Sort(new DirectiveGridViewDataRowInfoComparer(ColumnIndex, Convert.ToInt32(SortDirection))); foreach (var item in list) { resultList.Add(item.Tag as Directive); } SetItemsArray(resultList.ToArray()); OldColumnIndex = ColumnIndex; }
private void LoadVariables() { Prefix = Convert.ToString(GetConfig("Chat Settings", "Prefix", "[NightPVP] ")); // CHAT PLUGIN PREFIX PrefixColor = Convert.ToString(GetConfig("Chat Settings", "PrefixColor", "#bf0000")); // CHAT PLUGIN PREFIX COLOR ChatColor = Convert.ToString(GetConfig("Chat Settings", "ChatColor", "#dd8e8e")); // CHAT MESSAGE COLOR SteamIDIcon = Convert.ToUInt64(GetConfig("Chat Settings", "SteamIDIcon", "76561198079320022")); // SteamID FOR PLUGIN ICON - STEAM PROFILE CREATED FOR THIS PLUGIN / NONE YET / starthour = Convert.ToSingle(GetConfig("Night Time Zone", "Start at", "21")); stophour = Convert.ToSingle(GetConfig("Night Time Zone", "Stop at", "6")); leftmin = Convert.ToDouble(GetConfig("HUD position", "left (0.95 by default)", "0.95")); bottom = Convert.ToDouble(GetConfig("HUD position", "bottom (0.86 by default)", "0.86")); HUDtxtsize = Convert.ToInt32(GetConfig("HUD text size", "(10 by default)", "10")); HUDwidth = Convert.ToDouble(GetConfig("HUD size", "width (0.05 by default)", "0.05")); HUDheigth = Convert.ToDouble(GetConfig("HUD size", "heigth (0.04 by default)", "0.04")); HUDpvecolor = Convert.ToString(GetConfig("HUD color", "for PVE", "0.5 1.0 0.0")); // CHAT MESSAGE COLOR HUDpveopacity = Convert.ToString(GetConfig("HUD opacity", "for PVE", "0.0")); // CHAT MESSAGE COLOR HUDpvpcolor = Convert.ToString(GetConfig("HUD color", "for PVP", "0.85 0.2 0.5")); // CHAT MESSAGE COLOR HUDpvpopacity = Convert.ToString(GetConfig("HUD opacity", "for PVP", "0.0")); // CHAT MESSAGE COLOR //rate = Convert.ToSingle(GetConfig("", "", "300")); if (!ConfigChanged) { return; } SaveConfig(); ConfigChanged = false; }
/// <summary> /// Самое последние выполнение в этой группе /// </summary> /// <returns>hours</returns> public int MaxCompliance() { List <int?> list; if (Schedule) { list = (from check in Checks where check.LastPerformance != null orderby check.LastPerformance.OnLifelength.Hours descending select check.LastPerformance.OnLifelength.Hours).ToList(); } else { list = (from check in Checks where check.LastPerformance != null orderby check.LastPerformance.OnLifelength.Days descending select check.LastPerformance.OnLifelength.Days).ToList(); } if (list.Count > 0 && list[0] != null) { return(Convert.ToInt32(list[0])); } return(-1); }
public bool SaveItem(ITreeNodeContent node, ItemChanges changes) { if (!changes.HasFieldsChanged) { return(false); } var productVariant = Product.Get(Convert.ToInt32(node.ItemId)); if (productVariant == null) { var message = string.Format("Product with id: {0} not found for ITreeNodeContent. ", node.ItemId); _loggingService.Debug <ProductCatalogTemplateBuilder>(message); throw new InvalidDataException(message); } foreach (FieldChange fieldChange in changes.FieldChanges) { UpdateVariantValue(fieldChange, productVariant, changes.Item); } ObjectFactory.Instance.Resolve <IPipeline <Product> >("SaveProduct").Execute(productVariant.ParentProduct); return(true); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void okButton_Click(object sender, EventArgs e) { int[] indicies = this.columnTable.SelectedIndicies; if (indicies.Length > 0) { if (this.widthTextBox.Text.Length == 0) { this.columnTable.TableModel[indicies[0], 0].Tag = Column.MinimumWidth; } else { int width = Convert.ToInt32(this.widthTextBox.Text); if (width < Column.MinimumWidth) { this.columnTable.TableModel[indicies[0], 0].Tag = Column.MinimumWidth; } else { this.columnTable.TableModel[indicies[0], 0].Tag = width; } } } for (int i = 0; i < this.columnTable.TableModel.Rows.Count; i++) { this.model.Columns[i].Visible = this.columnTable.TableModel[i, 0].Checked; this.model.Columns[i].Width = (int)this.columnTable.TableModel[i, 0].Tag; } this.Close(); }
void insidetimer() { float gamehour = TOD_Sky.Instance.Cycle.Hour; int hournow = Convert.ToInt32(Math.Round(gamehour - 0.5)); if (hournow >= starthour || hournow < stophour) { if (storedData.NightPvpOn == false) { NightIsOn(); } storedData.NightPvpOn = true; } else { if (storedData.NightPvpOn == true) { NightIsOff(); } storedData.NightPvpOn = false; } if (debug == true) { Puts($"{hournow} PVP is ON {storedData.NightPvpOn}"); } }
/// <summary> /// 获取s the name of the HTML. /// </summary> /// <param name="value">The value.</param> public static string GetHtmlName(this Enum value) { // 获取枚举值类型和名称 var type = value.GetType(); var name = Enum.GetName(type, value); if (name == null) { return(Convert.ToInt32(value).ToString()); } // 获取Display属性 var field = type.GetField(Enum.GetName(type, value)); var displayAttribute = field.GetAttributes <DisplayAttribute>().FirstOrDefault(); if (displayAttribute != null) { name = displayAttribute.GetName() ?? displayAttribute.GetShortName(); var cssAttribute = field.GetAttributes <LabelCssClassAttribute>().FirstOrDefault(); if (cssAttribute != null) { name = $@"<span class='m-badge m-badge--wide {cssAttribute.CssClass}'>{name}</span>"; } } // 返回默认名称 return(name); }
public bool SaveItem(ITreeNodeContent node, ItemChanges changes) { if (!changes.HasFieldsChanged) { return(false); } var catalog = ProductCatalog.Get(Convert.ToInt32(node.ItemId)); if (catalog == null) { var message = string.Format("Product Catalog with id: {0} not found for ITreeNodeContent. ", node.ItemId); _loggingService.Log <ProductCatalogTemplateBuilder>(message); throw new InvalidDataException(message); } foreach (FieldChange change in changes.FieldChanges) { UpdateCatalogValuesFor(change, catalog); } ObjectFactory.Instance.Resolve <IPipeline <ProductCatalog> >("SaveProductCatalog").Execute(catalog); return(true); }
public PatientAppointmentDisplay GetExistingPatientAppointment(string patientId, DateTime appointmentDate, int serviceAreaId, int reasonId) { PatientAppointmentDisplay appointmentDisplay = new PatientAppointmentDisplay(); PatientAppointment appointment = new PatientAppointment(); try { var patientAppointment = new PatientAppointmentManager(); int id = Convert.ToInt32(patientId); appointment = patientAppointment.GetByPatientId(id).FirstOrDefault(n => n.AppointmentDate.Date == appointmentDate.Date && n.ServiceAreaId == serviceAreaId && n.ReasonId == reasonId); if (appointment != null) { appointmentDisplay = Mapappointments(appointment); } else { return(null); } } catch (Exception e) { Msg = e.Message; } return(appointmentDisplay); }
public IEnumerable <PatientAppointmentDisplay> GetPatientAppointments(string patientId) { List <PatientAppointmentDisplay> appointmentsDisplay = new List <PatientAppointmentDisplay>(); IEnumerable <PatientAppointmentDisplay> listAppointments = new List <PatientAppointmentDisplay>(); var appointments = new List <PatientAppointment>(); var bluecardAppointments = new List <BlueCardAppointment>(); try { var patientAppointment = new PatientAppointmentManager(); int id = Convert.ToInt32(patientId); appointments = patientAppointment.GetByPatientId(id); bluecardAppointments = patientAppointment.GetBluecardAppointmentsByPatientId(id); foreach (var appointment in appointments) { PatientAppointmentDisplay appointmentDisplay = Mapappointments(appointment); appointmentsDisplay.Add(appointmentDisplay); } foreach (var appointment in bluecardAppointments) { PatientAppointmentDisplay appointmentDisplay = MapBluecardappointments(appointment); appointmentsDisplay.Add(appointmentDisplay); } listAppointments = appointmentsDisplay.OrderByDescending(n => n.AppointmentDate); } catch (Exception e) { Msg = e.Message; } return(listAppointments); }
private void ItemCatalogForDaHour(ConsoleSystem.Arg arg) { var player = arg.Connection.player as BasePlayer; int hour = Convert.ToInt32(arg.Args[0]); ItemCatalogForDaHour(player, hour); }
public void UnRender() { for (int i = 0; i < Convert.ToInt32(Equation.Split(',')[0]); i++) { SpriteRenderer spriteRenderer = paths[i].GetComponent(typeof(SpriteRenderer)) as SpriteRenderer; spriteRenderer.enabled = false; } }
/// <summary> /// 获取s the time list. /// </summary> public List <DateTime> GetTimeList() { var resultList = new List <DateTime>(); //当天晚上1点 var StartTime = DateTime.Today.AddHours(1); var TimeNow = DateTime.Now; if (Configuration.StageRule.StagePeriods > 0) { //间隔多少天 if (Configuration.StageRule.timeType == TimeType.Day) { //如果已经过1点则第二天执行 if (TimeNow > StartTime) { StartTime = StartTime.AddDays(1); } for (var i = 0; i < Configuration.StageRule.StagePeriods; i++) { resultList.Add(StartTime.AddDays(i * Configuration.StageRule.StageInterval)); } } //每个星期几 else if (Configuration.StageRule.timeType == TimeType.Week) { var week = Convert.ToInt32(TimeNow.DayOfWeek); //获取第一期分润开始时间 StartTime = StartTime.AddDays(Configuration.StageRule.StageInterval - week); if (TimeNow > StartTime) { StartTime.AddDays(7); } for (var i = 0; i < Configuration.StageRule.StagePeriods; i++) { resultList.Add(StartTime.AddDays(i * 7)); } } //每月几号 else if (Configuration.StageRule.timeType == TimeType.Month) { //获取第一期分润开始时间 StartTime = StartTime.AddDays(Configuration.StageRule.StageInterval - StartTime.Day); if (TimeNow > StartTime) { StartTime = StartTime.AddMonths(1); } for (var i = 0; i < Configuration.StageRule.StagePeriods; i++) { resultList.Add(StartTime.AddMonths(i)); } } } return(resultList); }
/// <summary> /// Converts a value to a <see cref="int"/>. /// </summary> /// <param name="value">The object to convert.</param> /// <returns>The converted <paramref name="value"/>.</returns> public int ToInt32(object value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } return(SConvert.ToInt32(value, CultureInfo.InvariantCulture)); }
protected void btn_asignarConsultor_OnClick(object sender, EventArgs e) { var personaId = Convert.ToInt32(hd_idPersona.Text); var consultorId = Convert.ToInt32(ddl_consultores.SelectedValue); A_ASIG_CONSULTOR.AsignarConsultorABeneficiario(0, 0, personaId, consultorId); Response.Redirect(Request.RawUrl); }
protected override void CustomSort(int ColumnIndex) { if (OldColumnIndex != ColumnIndex) { SortDirection = SortDirection.Asc; } if (SortDirection == SortDirection.Desc) { SortDirection = SortDirection.Asc; } else { SortDirection = SortDirection.Desc; } var resultList = new List <BaseEntityObject>(); var list = radGridView1.Rows.Select(i => i).ToList(); list.Sort(new GridViewDataRowInfoComparer(ColumnIndex, Convert.ToInt32(SortDirection))); //добавление остальных подзадач foreach (GridViewRowInfo item in list) { if (item.Tag is Component) { resultList.Add(item.Tag as BaseEntityObject); Component component = (Component)item.Tag; var items = list .Where(lvi => lvi.Tag is ComponentDirective && ((ComponentDirective)lvi.Tag).ComponentId == component.ItemId).Select(i => i.Tag); resultList.AddRange(items.OfType <BaseEntityObject>()); } else if (item.Tag is ComponentDirective) { ComponentDirective dd = item.Tag as ComponentDirective; Component d = dd.ParentComponent; if (d == null) { resultList.Add(item.Tag as BaseEntityObject); } else { var lvi = list.FirstOrDefault(lv => lv.Tag is Component && ((Component)lv.Tag).ItemId == d.ItemId); if (lvi == null) { resultList.Add(item.Tag as BaseEntityObject); } } } } SetItemsArray(resultList.ToArray()); }
void Start() { astroidInfo = AstroidLibrary.GetAstroid(id); health = Random.Range(astroidInfo.healthRange.x, astroidInfo.healthRange.y); mass = health * astroidInfo.massScalar; GetComponent <Rigidbody2D>().mass = mass; GetComponent <SpriteRenderer>().sprite = astroidInfo.sprites[0]; astroidDestroyedFactor = Convert.ToInt32(health / astroidInfo.sprites.Length); render = GetComponent <SpriteRenderer>(); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack == false) //Condition for executing the code only only First load { int id = Convert.ToInt32(Request.QueryString["Id"]); //Retriving Id from Query string Catagory catagory = catagoryManager.GetCatagoryById(id); idHiddenField.Value = catagory.Id.ToString(); catagoryTextBox.Text = catagory.CatagoryName; } }
private void toolsPrintPages_Click(object sender, EventArgs e) { if (!isTxt()) { return; } int p1 = Convert.ToInt32(txtPage1.Text.Trim()); int p2 = Convert.ToInt32(txtPages2.Text.Trim()); imgBrow1.PrintImg(p1, p2); }
public static string GetBlogPagination(BlogSettings settingsItem, int currentPage, int totalRows, int maximumRows) { StringBuilder pagination = new StringBuilder(); double decMaxPages = Convert.ToDouble(totalRows) / Convert.ToDouble(maximumRows); int maxPages = Convert.ToInt32(Math.Ceiling(decMaxPages)); if (maxPages > 1) { if (currentPage > maxPages) { // outside our range, make first page currentPage = 1; } if (currentPage != 1) { pagination.Append(String.Format("<a href=\"?{0}={1}\">{2}</a> ", XBSettings.XBPageQS, "1", settingsItem.FirstPageText)); pagination.Append(String.Format("<a href=\"?{0}={1}\">{2}</a> ", XBSettings.XBPageQS, Convert.ToString(currentPage - 1), settingsItem.PreviousPageText)); } if (currentPage - 2 > 0) { pagination.Append(String.Format("<a href=\"?{0}={1}\">{2}</a> ", XBSettings.XBPageQS, Convert.ToString(currentPage - 2), Convert.ToString(currentPage - 2))); } if (currentPage - 1 > 0) { pagination.Append(String.Format("<a href=\"?{0}={1}\">{2}</a> ", XBSettings.XBPageQS, Convert.ToString(currentPage - 1), Convert.ToString(currentPage - 1))); } pagination.Append(String.Format("{0} ", Convert.ToString(currentPage))); if (currentPage + 1 <= maxPages) { pagination.Append(String.Format("<a href=\"?{0}={1}\">{2}</a> ", XBSettings.XBPageQS, Convert.ToString(currentPage + 1), Convert.ToString(currentPage + 1))); } if (currentPage + 2 <= maxPages) { pagination.Append(String.Format("<a href=\"?{0}={1}\">{2}</a> ", XBSettings.XBPageQS, Convert.ToString(currentPage + 2), Convert.ToString(currentPage + 2))); } if (currentPage + 1 <= maxPages) { pagination.Append(String.Format("<a href=\"?{0}={1}\">{2}</a> ", XBSettings.XBPageQS, Convert.ToString(currentPage + 1), settingsItem.NextPageText)); pagination.Append(String.Format("<a href=\"?{0}={1}\">{2}</a> ", XBSettings.XBPageQS, Convert.ToString(maxPages), settingsItem.LastPageText)); } } return(pagination.ToString()); }
private void AddItemOnHourPack(ConsoleSystem.Arg arg) { temporary = new Dictionary <int, int>(); var player = arg.Connection.player as BasePlayer; string reason = arg.Args[0]; int itemnow = Convert.ToInt32(arg.Args[1]); int qty = Convert.ToInt32(arg.Args[2]); int hour = Convert.ToInt32(arg.Args[3]); int oldqty = 0; foreach (KeyValuePair <int, int> old in storedData.hourpack[hour].intquantity.ToArray()) { temporary.Add(old.Key, old.Value); if (itemnow == old.Key) { if (old.Value == null) { oldqty = 0; } else { oldqty = old.Value; } } } temporary.Remove(itemnow); if (reason == "add") { temporary.Add(itemnow, oldqty + qty); } else { int newqty = oldqty - qty; if (newqty < 0) { newqty = 0; } temporary.Add(itemnow, newqty); } storedData.hourpack.Remove(hour); storedData.hourpack.Add(hour, new Pack() { intquantity = temporary }); if (debug == true) { Puts($"OLD ITEMS {oldqty} => NEW {qty}x{itemnow}"); } OpenMainHappyPanel(player, null, null, hour); ItemCatalogForDaHour(player, hour); }
public void Process(WorkflowPipelineArgs args) { int addDays = Convert.ToInt32(args.ProcessorItem.InnerItem.Fields["AddDays"].Value); DateTime taskRunDate = DateTime.Now.AddDays(addDays); string isoDate = DateUtil.ToIsoDate(taskRunDate); isoDate = isoDate.Substring(0, 9) + "120000"; using (new EditContext(args.DataItem)) { args.DataItem.Fields["__Archive date"].Value = isoDate; } }
public static int?ToIntN(this object obj) { if (obj == null) { return(null); } if (obj is bool) { return(Convert.ToInt32(obj)); } return(int.TryParse(obj.ToString().Replace(".", ",").TakeUntil(","), NumberStyles.Any, Culture, out int tmpvalue) ? tmpvalue : (int?)null); }
public string UpdatePatientFamilyTesting(int patientId, int patientMasterVisitId, string firstName, string middleName, string lastName, int sex, string dob, int relationshipId, int baselineHivStatusId, DateTime baselineHivStatusDate, string hivTestingresultId, string hivTestingresultDate, bool cccreferal, string cccReferalNumber, int userId, int personRelationshipId, int hivTestingId, int personId, string cccReferalModDate) { firstName = GlobalObject.unescape(firstName); middleName = GlobalObject.unescape(middleName); lastName = GlobalObject.unescape(lastName); int hivresultId = hivTestingresultId == "" ? 0 : Convert.ToInt32(hivTestingresultId); //DateTime? testingResultsDate = hivTestingresultDate == "" ? : DateTime.Parse(hivTestingresultDate); PatientFamilyTesting patientAppointment = new PatientFamilyTesting() { PatientId = patientId, PatientMasterVisitId = patientMasterVisitId, FirstName = firstName, MiddleName = middleName, LastName = lastName, Sex = sex, DateOfBirth = DateTime.Parse(dob), RelationshipId = relationshipId, BaseLineHivStatusId = baselineHivStatusId, BaselineHivStatusDate = baselineHivStatusDate, //HivTestingResultsDate = testingResultsDate, HivTestingResultsId = hivresultId, CccReferal = cccreferal, CccReferaalNumber = cccReferalNumber, PersonRelationshipId = personRelationshipId, HivTestingId = hivTestingId, PersonId = personId }; if (hivTestingresultDate != "") { patientAppointment.HivTestingResultsDate = DateTime.Parse(hivTestingresultDate); } if (cccReferalModDate != "") { patientAppointment.LinkageDate = DateTime.Parse(cccReferalModDate); } try { var testing = new PatientFamilyTestingManager(); Result = testing.UpdatePatientFamilyTestings(patientAppointment, userId); if (Result > 0) { Msg = "Patient family testing Updated Successfully!"; } } catch (Exception e) { Msg = e.Message; } return(Msg); }
protected void rptUserOrders_ItemCommand(object source, RepeaterCommandEventArgs e) { //TODO: Removed because of autodelete? /* if ( e.CommandName.ToString() == "Delete" ) * { * UserOrder.DeleteOrder( Convert.ToInt32( e.CommandArgument ), (int)CurrentUser.Id ); * }*/ if (e.CommandName == "Edit") { EditUserOrders(Convert.ToInt32(e.CommandArgument)); } }