protected Entity(Vector2f _pos, Vector2f _size, string _filename, EntityName _name) : base(_pos, _size, _filename, Type.entity, _name.ToString()) { entityID = _name.ToString() + "_" + lastIntID; entitiesIDs.Add(entityID); lastIntID++; maxHealth = 100; health = maxHealth; speed = 0.07f; }
private Dictionary <string, string> CleanUnrelvantFields(ObservableList <ExternalItemFieldBase> fields, EntityName entityName) { ObservableList <ExternalItemFieldBase> fieldsToReturn = new ObservableList <ExternalItemFieldBase>(); Dictionary <string, string> selectedFields = new Dictionary <string, string>(); string currentResource = entityName.ToString(); fields.ToList().ForEach(item => { if (item.ItemType.ToLower().Equals(entityName.ToString().ToLower())) { fieldsToReturn.Add(item); } }); fieldsToReturn.ToList().ForEach(tst => { if (!String.IsNullOrEmpty(tst.ID) && !String.IsNullOrEmpty(tst.SelectedValue) && !selectedFields.ContainsKey(tst.ID)) { int index = tst.SelectedValue.IndexOf("#"); selectedFields.Add(tst.ID, index == -1 ? tst.SelectedValue : tst.SelectedValue.Remove(tst.SelectedValue.IndexOf("#"))); } }); return(selectedFields); }
public virtual void ToExcel(EntityName entityName, string dateTimeFrom, string dateTimeTo) { try { var result = ExportToExcelFactory.DownloadExcelFile(entityName, dateTimeFrom, dateTimeTo); if (!result.IsSuccessful) { throw new Exception(result.Message); } var currentDate = PersianDateTime.Now; string fileName = $"{entityName.ToString()}_{currentDate.Year.ToString()}{currentDate.Month.ToString()}{currentDate.DaysInMonth.ToString()}_{currentDate.Hour}{currentDate.Minute}{currentDate.Second}"; Response.Clear(); Response.AddHeader("content-disposition", $"attachment;filename={fileName}.xls"); Response.AddHeader("Content-Type", "application/vnd.ms-excel"); Response.ContentEncoding = Encoding.Unicode; Response.BinaryWrite(Encoding.Unicode.GetPreamble()); switch (entityName) { case EntityName.User: WriteTsv((IEnumerable <ExportUserToExcelModel>)result.Result.FileResult, Response.Output); break; case EntityName.Order: WriteTsv((IEnumerable <ExportOrderToExcelModel>)result.Result.FileResult, Response.Output); break; } } catch { Response.Redirect(Url.Action(MVC.Export.ActionNames.ToExcel, MVC.Export.Name)); } finally { Response.End(); } }