// // Note: All calls to this function should occur in administrator initiated // processes. No calls to this function should as a result of an HTTP request from // a SOAP API. // This is verified to be true on 3/1/2002 by creeves // public static void OperatorMail(SeverityType severity, CategoryType category, OperatorMessageType messageId, string message) { string mailTo = Config.GetString("Debug.MailTo", null); if (null == mailTo) { Debug.Write( SeverityType.Info, CategoryType.Config, "Skipping send of operator mail. Configuration setting 'Debug.MailTo' not set."); return; } Debug.VerifySetting("Debug.MailFrom"); try { string mailCc = Config.GetString("Debug.MailCc", null); string mailSubject = Config.GetString( "Debug.MailSubject", "Operator message from {0}. Severity: {1}, Category: {2}"); MailMessage mail = new MailMessage(); mail.To = mailTo; mail.From = Config.GetString("Debug.MailFrom"); mail.Subject = String.Format( mailSubject, System.Environment.MachineName, severity.ToString(), category.ToString(), (int)messageId); if (null != mailCc) { mail.Cc = mailCc; } mail.BodyFormat = MailFormat.Text; mail.Body = "SEVERITY: " + severity.ToString() + "\r\n" + "CATEGORY: " + category.ToString() + "\r\n" + "EVENT ID: " + (int)messageId + "\r\n\r\n" + message; SmtpMail.Send(mail); } catch (Exception e) { Debug.OperatorMessage( SeverityType.Error, CategoryType.None, OperatorMessageType.CouldNotSendMail, "Could not send operator mail.\r\n\r\nDetails:\r\n\r\n" + e.ToString()); } }
/// <summary> /// Updates category label /// </summary> /// <param name="category">Category to update for</param> private void UpdateCategory(CategoryType category) { var categoryDictionary = FillDictionaryWithCategories(); grpAnimal.Text = category.ToString(); lblSpecificCategory.Text = categoryDictionary[category]; }
/// **************************************************************** /// public WriteDebugger [static] /// ---------------------------------------------------------------- /// <summary> /// Writes a message to the debugger. /// </summary> /// ---------------------------------------------------------------- /// <param name="severity"> /// The severity type. /// </param> /// /// <param name="category"> /// The category type. /// </param> /// /// <param name="message"> /// The message. /// </param> /// **************************************************************** /// public static void WriteDebugger(SeverityType severity, CategoryType category, string message) { try { string text = string.Format( "{0,-4} {1,-4} {2}", severity.ToString().Substring(0, 4).ToUpper(), category.ToString().Substring(0, 4).ToUpper(), message.Replace("\r\n", "\r\n\t\t")); // // Write out the debugger message. // System.Diagnostics.Trace.WriteLine(text); } catch (Exception) { // // WriteDebugger is used as a last ditch logging mechanism // in many cases. This should never throw an exception, // but if it does, there really isn't any more we can do // about it. We'll simply eat the error. // } }
private void ShowChart() { // Now update the observable collection. if (this.IsVisible && chartDirty) { chartDirty = false; ChartDataSeries series = new ChartDataSeries() { Name = CategoryType.ToString() }; foreach (CategoryData item in from c in map.Values orderby c.Total descending select c) { series.Values.Add(new ChartDataValue() { Label = item.Name, Value = item.Total, Color = item.Color, UserData = item }); } TotalAmount.Text = string.Format("{0:C2}", Math.Abs(NetAmount)); PieChart.Series = series; Legend.DataSeries = series; } }
public Dictionary <string, decimal> GetCurrentCashFlow(CategoryType categoryType, string categoryName, int month, int year) { Dictionary <string, decimal> currentCashFlow = new Dictionary <string, decimal>(); using (var conn = new SqlCeConnection(Store.ConnectionString)) { conn.Open(); string sql = "SELECT DATEPART(month,Date) AS Month,SUM(t.Amount) AS Amount FROM " + tableName + " t " + "INNER JOIN Categories c ON t.CategoryId=c.ID " + "WHERE c.Type=@Type AND c.Name=@Name " + "AND DATEPART(year,Date)=@Year " + "GROUP BY DATEPART(month,Date) ORDER BY DATEPART(month,Date)"; var cmd = new SqlCeCommand(sql, conn); cmd.Parameters.Add("@Type", SqlDbType.NVarChar).Value = categoryType.ToString(); cmd.Parameters.Add("@Name", SqlDbType.NVarChar).Value = categoryName; cmd.Parameters.Add("@Month", SqlDbType.Int).Value = month; cmd.Parameters.Add("@Year", SqlDbType.Int).Value = year; using (var rdr = cmd.ExecuteReader()) { while (rdr.Read()) { currentCashFlow.Add(rdr["Month"].ToString(), (decimal)rdr["Amount"]); } } } return(currentCashFlow); }
public Dictionary <string, List <ElementId> > GroupElementIdsByCategoryType(List <ElementId> elementIds) { Dictionary <string, List <ElementId> > output = new Dictionary <string, List <ElementId> >(); CategoryType elementCatType = CategoryType.Invalid; string key = null; foreach (ElementId eId in elementIds) { // Get element Category Type elementCatType = this.GetCategoryType(this.GetCategory(this.GetElement(eId))); // Turn the object to a string key key = elementCatType.ToString(); // If the output doesn't have a category for elementCatType, make a new one if (!output.ContainsKey(key)) { output.Add(key, new List <ElementId>()); } // Add eId to the elementCatType output[key].Add(eId); } return(output); }
public static BootstrapSelectVm ToBootstrapSelectVm(this CategoryType category) { return(new BootstrapSelectVm() { SelectedItem = category.ToString(), SelectedItemText = category.GetDescriptionOfEnum(), SourceList = CategoryType.Incoming.ToList() }); }
public void Populate() { if (Owner != null) { List <MultimediaLink> data = Service.GetMultimediaItems(CategoryType.ToString(), Owner.ObjectID.Value); ReloadMultimediaPanel(data); IsPopulated = true; } }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value is CategoryType) { CategoryType type = (CategoryType)value; return(type.ToString()[0].ToString()); } return(""); }
public override string ToString() { string strOut = string.Format("{0,-20}{1,10}\n{2,-20}{3,10}\n{4,-20}{5,10}\n", "ID:", id, "Name:", name, "Age:", age); strOut += string.Format("{0,-20}{1,10}\n{2,-20}{3,10}\n", "Gender:", gender.ToString(), "Category:", category.ToString()); return(strOut); }
public List<Product> GetProductByPage(int Page, int PageSize, CategoryType ct, bool IsDESC) { SqlParameter[] sprms = new SqlParameter[] { new SqlParameter("@CategoryType", ct.ToString()), new SqlParameter("@PageNumber",Page), new SqlParameter("@PageSize",PageSize) }; DataTable dt = _dataAccess.Query("ProductAPI_GetProductsByPage", sprms); return EntityHelper<Product>.ConvertToList(dt); }
public Song(string songName, string coverFilename, string songFilename, GenreType genre, string singer, int year, CategoryType categorie, SingType singType, List <Notes> notes) { this.songName = songName; this.coverFilename = coverFilename; this.songFilename = songFilename; this.genre = genre.ToString(); this.singer = singer; this.year = year; this.categorie = categorie.ToString(); this.singType = singType; this.notes = notes; }
/* Populates the animalObjects listbox with animals of type Mammal or Bird, * depending on the category selected. */ private void populateAnimalObjectsList(CategoryType selectedItem) { switch (selectedItem) { case CategoryType.Mammal: listBoxAnimalObjects.Items.AddRange(Enum.GetNames(typeof(MammalSpecies))); break; case CategoryType.Bird: listBoxAnimalObjects.Items.AddRange(Enum.GetNames(typeof(BirdSpecies))); break; } // 'Mammal specifications', 'Bird specifications' etc... as title of groupbox groupBoxCategorySpec.Text = selectedItem.ToString() + " Specifications"; }
public List <Category> GetByType(CategoryType categoryType) { List <Category> categories = new List <Category>(); using (var conn = new SqlCeConnection(Store.ConnectionString)) { conn.Open(); string sql = "SELECT * FROM " + tableName + " WHERE Type='" + categoryType.ToString() + "'"; var cmd = new SqlCeCommand(sql, conn); using (var rdr = cmd.ExecuteReader()) { categories = Mapper.MapList <Category>(rdr, new CategoryMapper()); } } return(categories); }
private void ExecuteDeleteListViewCommand(object obj) { if (MessageBox.Show("Are you Sure You want to Delete this Category?", "Delete Category", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning) == MessageBoxResult.Yes) { //SelectedCategory.Enabled = false; var stat = _categoryService.Delete(SelectedCategory.Id.ToString()); if (stat == 0) { Categories.Remove(SelectedCategory); } else { MessageBox.Show("Can't delete " + CategoryType.ToString() + ", may be the " + stat, "Can't Delete", MessageBoxButton.OK, MessageBoxImage.Error); } } }
private void ExecuteDeleteListViewCommand(object obj) { if (MessageBox.Show("Are you Sure You want to Delete this Record?", "Pinna Fitness", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning) == MessageBoxResult.Yes) { SelectedCategory.Enabled = false; var stat = _categoryService.Disable(SelectedCategory); if (string.IsNullOrEmpty(stat)) { Categories.Remove(SelectedCategory); } else { MessageBox.Show("Can't delete " + CategoryType.ToString() + ", may be the " + stat, "Can't Delete", MessageBoxButton.OK, MessageBoxImage.Error); } } }
/// <summary> /// Converts the CategoryType to localized readable text. /// </summary> internal static string CategoryTypeToString(CategoryType category) { string toString; switch (category) { case CategoryType.EngineBlocks: toString = "Engine Blocks"; break; case CategoryType.Sparkplugs: toString = "Spark Plugs"; break; default: toString = category.ToString(); break; } return(LocalizeString(toString)); }
public decimal GetTotalTransaction(CategoryType categoryType, int month, int year) { decimal totalTransaction = 0; using (var conn = new SqlCeConnection(Store.ConnectionString)) { conn.Open(); string sql = string.Empty; if (categoryType == CategoryType.Income) { sql = "SELECT SUM(Amount) AS SumOfAmount FROM " + tableName + " t " + "WHERE Type=@Type AND DATEPART(month,Date)=@Month AND DATEPART(year,Date)=@Year"; } else if (categoryType == CategoryType.Expense) { sql = "SELECT SUM(Amount) AS SumOfAmount FROM " + tableName + " t " + "WHERE Type IN ('Expense','Payment') AND DATEPART(month,Date)=@Month AND DATEPART(year,Date)=@Year"; } var cmd = new SqlCeCommand(sql, conn); cmd.Parameters.Add("@Type", SqlDbType.NVarChar).Value = categoryType.ToString(); cmd.Parameters.Add("@Month", SqlDbType.Int).Value = month; cmd.Parameters.Add("@Year", SqlDbType.Int).Value = year; using (var rdr = cmd.ExecuteReader()) { if (rdr.Read()) { totalTransaction = rdr["SumOfAmount"] is DBNull ? 0 : (decimal)rdr["SumOfAmount"]; } } } return(totalTransaction); }
public List<CategoryModel> GetByType(CategoryType categoryType) { string aux = categoryType.ToString(); return dbContext.Categories.Where(x => x.Type == aux).ToList(); }
internal static void WritePlatformLog(CategoryType categoryType, ActivityType activityType, string description, string details = null, string accountId = null, string accountName = null, string userId = null, string userName = null, string userEmail = null, string ipAddress = null, string origin = null, string serializedObject = null) { CloudTableClient cloudTableClient = Settings.Azure.Storage.StorageConnections.PlatformStorage.CreateCloudTableClient(); //Create and set retry policy for logging //IRetryPolicy exponentialRetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(1), 4); IRetryPolicy linearRetryPolicy = new LinearRetry(TimeSpan.FromSeconds(1), 4); cloudTableClient.DefaultRequestOptions.RetryPolicy = linearRetryPolicy; //Gather up all the entities into a list for our parallel task to execute in a ForEach List <Object> entityTypes = new List <object>(); //Create an instance of each entity type and pass in associated CloudTableClient & TableName PlatformLogTableEntity_ByTime logTableEntity_Time = new PlatformLogTableEntity_ByTime(cloudTableClient, "platformactivitylogbytime"); entityTypes.Add(logTableEntity_Time); PlatformLogTableEntity_ByCategory logTableEntity_Category = new PlatformLogTableEntity_ByCategory(cloudTableClient, "platformactivitylogbycategory"); entityTypes.Add(logTableEntity_Category); PlatformLogTableEntity_ByActivity logTableEntity_Activity = new PlatformLogTableEntity_ByActivity(cloudTableClient, "platformactivitylogbyactivity"); entityTypes.Add(logTableEntity_Activity); if (accountId != null) { PlatformLogTableEntity_ByAccountID logTableEntity_AccountID = new PlatformLogTableEntity_ByAccountID(cloudTableClient, "platformactivitylogbyaccountid"); entityTypes.Add(logTableEntity_AccountID); } if (userId != null) { PlatformLogTableEntity_ByUserID logTableEntity_UserID = new PlatformLogTableEntity_ByUserID(cloudTableClient, "platformactivitylogbyuserid"); entityTypes.Add(logTableEntity_UserID); } try { Parallel.ForEach(entityTypes, obj => { #region Trace Statements //Display the id of the thread for each parallel instance to verifiy prallelism //Trace.TraceInformation("Current thread ID: " + Thread.CurrentThread.ManagedThreadId); #endregion //Transform the LogItem into each corresponding table entity type for insert execution into logs (obj as IPlatformLogTableEntity).Category = categoryType.ToString(); (obj as IPlatformLogTableEntity).Activity = activityType.ToString(); (obj as IPlatformLogTableEntity).Description = description.ToString(); (obj as IPlatformLogTableEntity).Details = details; (obj as IPlatformLogTableEntity).UserID = userId; (obj as IPlatformLogTableEntity).UserName = userName; (obj as IPlatformLogTableEntity).UserEmail = userEmail; (obj as IPlatformLogTableEntity).IPAddress = ipAddress; (obj as IPlatformLogTableEntity).Origin = origin; (obj as IPlatformLogTableEntity).AccountID = accountId; (obj as IPlatformLogTableEntity).AccountName = accountName; (obj as IPlatformLogTableEntity).Object = serializedObject; //create an insert operation for each entity, assign to designated CloudTable, and add to our list of tasks: TableOperation operation = TableOperation.Insert((obj as TableEntity)); (obj as IPlatformLogTableEntity).cloudTable.Execute(operation); }); } catch (Exception e) { //Email platform admins about this exception #region Email Platform Admins About Exception try { /* * * Using SendGrid Library is not possible in this one case due to circular reference issues * */ #region Create Parameter String var parametersString = new StringBuilder(); parametersString.Append("("); try { parametersString.Append(categoryType.ToString()); parametersString.Append(", "); parametersString.Append(activityType.ToString()); parametersString.Append(", "); parametersString.Append(description); parametersString.Append(", "); if (!String.IsNullOrEmpty(details)) { parametersString.Append(details); parametersString.Append(", "); } else { parametersString.Append("null"); parametersString.Append(", "); } if (!String.IsNullOrEmpty(accountId)) { parametersString.Append(accountId); parametersString.Append(", "); } else { parametersString.Append("null"); parametersString.Append(", "); } if (!String.IsNullOrEmpty(accountName)) { parametersString.Append(accountName); parametersString.Append(", "); } else { parametersString.Append("null"); parametersString.Append(", "); } if (!String.IsNullOrEmpty(userId)) { parametersString.Append(userId); parametersString.Append(", "); } else { parametersString.Append("null"); parametersString.Append(", "); } if (!String.IsNullOrEmpty(userName)) { parametersString.Append(userName); parametersString.Append(", "); } else { parametersString.Append("null"); parametersString.Append(", "); } if (!String.IsNullOrEmpty(userEmail)) { parametersString.Append(userEmail); parametersString.Append(", "); } else { parametersString.Append("null"); parametersString.Append(", "); } if (!String.IsNullOrEmpty(ipAddress)) { parametersString.Append(ipAddress); parametersString.Append(", "); } else { parametersString.Append("null"); parametersString.Append(", "); } if (!String.IsNullOrEmpty(origin)) { parametersString.Append(origin); parametersString.Append(", "); } else { parametersString.Append("null"); parametersString.Append(", "); } if (!String.IsNullOrEmpty(serializedObject)) { parametersString.Append(serializedObject); //parametersString.Append(", "); } else { parametersString.Append("null"); //parametersString.Append(", "); } parametersString.Append(")"); } catch { parametersString.Append(" ...Error parsing next parameter -----> )"); } #endregion dynamic sg = new SendGridAPIClient(Settings.Services.SendGrid.Account.APIKey); Email from = new Email(Settings.Endpoints.Emails.FromExceptions, "Platform Exception"); string subject = "Exception Alert! (From: Platform Logger)"; var personalization = new Personalization(); foreach (var email in Settings.Endpoints.Emails.PlatformEmailAddresses) { Email to = new Email(email); personalization.AddTo(to); } //Mail mail = new Mail(from, subject, to, content); Mail mail = new Mail(); mail.From = from; mail.Subject = subject; mail.Personalization = new List <Personalization>(); mail.Personalization.Add(personalization); //var myMessage = new SendGridMessage(); //myMessage.From = new MailAddress(Settings.Endpoints.Emails.FromExceptions, "Platform Exception"); //myMessage.AddTo(Settings.Endpoints.Emails.PlatformEmailAddresses); //myMessage.Subject = "Exception Alert! (From: Platform Logger)"; //myMessage.Html = var body = "Exception location: <b>" + System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "</b>" + "<br/><br/>" + "Exception occurred while attempting to write to the platform log..." + "<br/><br/><b>" + e.Message + "</b><br/><br/>" + "Log Parameters:<br/><br/><b>" + parametersString.ToString() + "</b><br/><br/>" + JsonConvert.SerializeObject(e) + "<br/><br/>"; Content content = new Content("text/html", body); //var username = Settings.Services.SendGrid.Account.UserName; //var pswd = Settings.Services.SendGrid.Account.APIKey; //var credentials = new NetworkCredential(username, pswd); //var transportWeb = new Web(credentials); //transportWeb.Deliver(myMessage); mail.Contents = new List <Content>(); mail.Contents.Add(content); var requestBody = mail.Get(); //dynamic response = await sg.client.mail.send.post(requestBody: requestBody); dynamic response = sg.client.mail.send.post(requestBody: requestBody); //dynamic d = response; } catch { } #endregion } }
public override string ToString() => CategoryType.ToString();
internal static IEnumerable <PlatformLogTableEntity> GetPlatformLogByCategory(CategoryType categoryType, int maxRecords) { string _logFullName = "platformactivitylogbycategory"; CloudTableClient cloudTableClient = Settings.Azure.Storage.StorageConnections.PlatformStorage.CreateCloudTableClient(); //Create and set retry policy //IRetryPolicy exponentialRetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(1), 4); IRetryPolicy linearRetryPolicy = new LinearRetry(TimeSpan.FromSeconds(1), 3); cloudTableClient.DefaultRequestOptions.RetryPolicy = linearRetryPolicy; CloudTable cloudTable = cloudTableClient.GetTableReference(_logFullName); cloudTable.CreateIfNotExists(); if (maxRecords > 0) { TableQuery <PlatformLogTableEntity> query = new TableQuery <PlatformLogTableEntity>().Take(maxRecords). Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, categoryType.ToString())); return(cloudTable.ExecuteQuery(query)); } else { return(null); } }
public ICategory[] GetCategoriesForType(CategoryType type) { var requestPath = RequestPathForAction(string.Format("categories.xml?type={0}", type.ToString().ToLower())); var categories = new List <ICategory>(); try { foreach (JObject node in _service.GetRequestResponseElement(requestPath)) { categories.Add(Category.GetInstance(Camp, node)); } } catch { return(categories.ToArray()); } return(categories.ToArray()); }
/// **************************************************************** /// public WriteFileLog [static] /// ---------------------------------------------------------------- /// <summary> /// Writes a message to the file log. /// </summary> /// ---------------------------------------------------------------- /// <param name="severity"> /// The severity type. /// </param> /// /// <param name="category"> /// The category type. /// </param> /// /// <param name="message"> /// The message. /// </param> /// **************************************************************** /// public static void WriteFileLog(SeverityType severity, CategoryType category, string message) { readWriteLock.AcquireReaderLock(Constants.ReadLockTimeout); try { // // If the log filename has not yet been initialized, there is nothing we // can log yet. // if (null == logFilename) { return; } // // Open the logging file, if it is not already. // if (null == textStream) { // // Get the full path to our log file. // string logFilePath = logFilename.GetString(); // // Pull off the directory of the log file and see if we need to // create it. // string logFileDirectory = Path.GetDirectoryName(logFilePath); if (false == Directory.Exists(logFileDirectory)) { Directory.CreateDirectory(logFileDirectory); } // // Append to an existing log file, or create a new one. // FileStream file = File.Open( logFilePath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite); textStream = TextWriter.Synchronized(new StreamWriter(file, System.Text.Encoding.UTF8)); textStream.NewLine = "\r\n"; } // // Build a time string of the format: YYMMDD:hhmmss // DateTime time = DateTime.Now; string timeString = string.Format( "{0,-4:D4}/{1:D2}/{2:D2} {3:D2}:{4:D2}:{5:D2}", time.Year, time.Month, time.Day, time.Hour, time.Minute, time.Second); // // Write out the file log entry. // textStream.WriteLine( severity.ToString().Substring(0, 4).ToUpper() + " " + category.ToString().Substring(0, 4).ToUpper() + " " + timeString + " " + message.Replace("\r\n", "\r\n\t\t")); textStream.Flush(); } catch (Exception e) { WriteDebugger( SeverityType.Error, CategoryType.None, "Could not write to log file " + logFilename + ".\r\n\r\nDetails:\r\n" + e.ToString()); // // If for whatever reason we could not write output to the log file, we dump the logfile name, // and the reason to the event log. // WriteEventLog( SeverityType.Error, CategoryType.None, OperatorMessageType.None, "Could not write to log file " + logFilename + ".\r\n\r\nDetails:\r\n" + e.ToString()); } finally { readWriteLock.ReleaseReaderLock(); } }
/* * public static InteractableObject Create(CategoryType category) * { * switch (category) * { * case CategoryType.Food: * { * return new FoodCategory(); * } * case CategoryType.Furniture: * { * return new FurnitureCategory(); * } * } * throw new ArgumentException(); * } */ public override string ToString() { return(CategoryType.ToString()); }
void SetupSong() { GUILayout.BeginArea(new Rect(10, 35, 850, 850)); EditorGUIUtility.labelWidth = 120; GUILayout.BeginHorizontal(GUILayout.Height(100)); GUILayout.BeginVertical(); GUIContent sName = new GUIContent(); texture = EditorGUILayout.ObjectField(sName, texture, typeof(Sprite), true, GUILayout.Width(EditorGUIUtility.singleLineHeight * 8), GUILayout.Height(EditorGUIUtility.singleLineHeight * 8)) as Sprite; if (texture != null) { song.coverFilename = texture.name; } if (GUILayout.Button("Carregar", GUILayout.Width(EditorGUIUtility.singleLineHeight * 8))) { var fileImage = EditorUtility.OpenFilePanel("Carregar Image", "", "png,jpg,jpge"); var resources = Application.dataPath + "/Resources/Cover"; var filename = Path.GetFileName(fileImage); string[] paths = { resources, filename }; var fullFilename = Path.Combine(paths); File.Copy(fileImage, fullFilename); AssetDatabase.Refresh(); texture = Resources.Load <Sprite>("Cover/" + Path.GetFileNameWithoutExtension(filename)); } GUILayout.EndVertical(); EditorGUILayout.Space(20); GUILayout.BeginVertical(); sName.text = "Nome da Musica: "; song.songName = EditorGUILayout.TextField(sName, song.songName, GUILayout.Width(400)); GUILayout.BeginHorizontal(); sName.text = "Arquivo da Musica: "; song.songFilename = EditorGUILayout.TextField(sName, song.songFilename, GUILayout.Width(316)); if (GUILayout.Button("Carregar", GUILayout.Width(80))) { fileSongPath = EditorUtility.OpenFilePanel("Carregar Musica", "", "mp3"); song.songFilename = Path.GetFileNameWithoutExtension(fileSongPath); } GUILayout.EndHorizontal(); sName.text = "Nome do Cantor: "; song.singer = EditorGUILayout.TextField(sName, song.singer, GUILayout.Width(400)); sName.text = "Genero Musical: "; genre = (GenreType)EditorGUILayout.EnumPopup(sName, genre, GUILayout.Width(300)); song.genre = genre.ToString(); sName.text = "Ano da Musica: "; song.year = EditorGUILayout.IntField(sName, song.year, GUILayout.Width(175)); sName.text = "Categoria: "; category = (CategoryType)EditorGUILayout.EnumPopup(sName, category, GUILayout.Width(400)); song.categorie = category.ToString(); sName.text = "Tipo de Cantor: "; song.singType = (SingType)EditorGUILayout.EnumPopup(sName, song.singType, GUILayout.Width(300)); GUILayout.EndVertical(); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); if (GUILayout.Button(textureExcluir, GUILayout.Width(60), GUILayout.Height(60))) { var popup = GetWindow <SongEditorConfirm>("Format"); popup.position = new Rect(350, 350, 350, 75); popup.ShowPopup(); popup.Focus(); } if (GUILayout.Button(textureSalvar, GUILayout.Width(60), GUILayout.Height(60))) { SaveSong(); } GUILayout.EndVertical(); GUILayout.BeginVertical(); if (GUILayout.Button(textureSalvar, GUILayout.Width(60), GUILayout.Height(60))) { StartPlay(); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.EndHorizontal(); EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Space(5); //Notas var style = new GUIStyle(GUI.skin.textArea) { alignment = TextAnchor.MiddleCenter }; //fullSubtitle = EditorGUILayout.TextArea(fullSubtitle, style,GUILayout.ExpandWidth(true), GUILayout.Height(70)); GUILayout.Space(5); pos = EditorGUILayout.BeginScrollView(pos, false, true, GUILayout.Height(300)); GUILayout.BeginVertical(); sName.text = "Nova Legenda"; if (GUILayout.Button(sName, GUILayout.Width(Screen.width - 40))) { song.notes.Add(new Notes()); } GUILayout.Space(10); GUILayout.BeginHorizontal(); if (Event.current.type == EventType.KeyUp && (Event.current.modifiers == EventModifiers.Control || Event.current.modifiers == EventModifiers.Command) && GUI.GetNameOfFocusedControl() == "Subtitle") { if (Event.current.keyCode == KeyCode.V) { var sub = song.notes[0].subtitle; song.notes.Clear(); SaveAndLoad.Save("Teste", sub, ".txt"); using (StringReader reader = new StringReader(sub)) { string line; while ((line = reader.ReadLine()) != null) { if (line != "") { song.notes.Add(new Notes(line)); } } } } } GUILayout.Label("Tempo de Inicio"); GUILayout.FlexibleSpace(); GUILayout.Label("Letra"); GUILayout.FlexibleSpace(); GUILayout.Label("Tempo de Encerramento"); if (song.singType == SingType.DUET) { GUILayout.FlexibleSpace(); GUILayout.Label("Cantor do dueto"); } GUILayout.Space(15); GUILayout.EndHorizontal(); foreach (var note in song.notes.ToList()) { GUILayout.BeginHorizontal(); sName.text = "x"; if (GUILayout.Button(sName)) { song.notes.Remove(note); } note.startTime = EditorGUILayout.TextField(formatTime(note.startTime), GUILayout.Width(75)); GUILayout.FlexibleSpace(); GUI.SetNextControlName("Subtitle"); note.subtitle = EditorGUILayout.TextArea(note.subtitle, GUILayout.Width(song.singType != SingType.DUET?600:500)); GUILayout.FlexibleSpace(); note.endTime = EditorGUILayout.TextField(formatTime(note.endTime), GUILayout.Width(75)); if (song.singType == SingType.DUET) { GUILayout.FlexibleSpace(); note.duetSinger = (DuetSinger)EditorGUILayout.EnumPopup(note.duetSinger, GUILayout.Width(100)); } GUILayout.Space(15); GUILayout.EndHorizontal(); } GUILayout.Space(20); GUILayout.EndVertical(); GUILayout.EndArea(); GUILayout.EndScrollView(); Event e = Event.current; if (e.commandName == "Confirmar") { Clean(); } }
public int TotalPage(CategoryType ct) { SqlParameter[] sprms = new SqlParameter[] { new SqlParameter("@CategoryType", ct.ToString()) }; DataTable dt = _dataAccess.Query("ProductAPI_TotalPages", sprms); return int.Parse(dt.Rows[0][0].ToString()); }
public List<String> GetNamesByType(CategoryType categoryType) { string aux = categoryType.ToString(); return dbContext.Categories.Where(x => x.Type == aux).Select(x => x.Name).ToList(); }
public ICategory[] GetCategoriesForType(CategoryType type) { var requestPath = RequestPathForAction(string.Format("categories.xml?type={0}", type.ToString().ToLower())); var categories = new List<ICategory>(); try { foreach (JObject node in _service.GetRequestResponseElement(requestPath)) { categories.Add(Category.GetInstance(Camp, node)); } } catch { return categories.ToArray(); } return categories.ToArray(); }
internal static void WriteAccountLog(string accountId, string storagePartition, CategoryType categoryType, ActivityType activityType, string description, string details = null, string userId = null, string userName = null, string userEmail = null, string ipAddress = null, string origin = null, string objectId = null, string objectName = null, string serializedObject = null) { //CloudTableClient cloudTableClient = Settings.Azure.Storage.StorageConnections.AccountsStorage.CreateCloudTableClient(); CloudTableClient cloudTableClient = Sahara.Core.Settings.Azure.Storage.GetStoragePartitionAccount(storagePartition).CreateCloudTableClient(); //Create and set retry policy for logging //IRetryPolicy exponentialRetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(1), 4); IRetryPolicy linearRetryPolicy = new LinearRetry(TimeSpan.FromSeconds(1), 4); cloudTableClient.DefaultRequestOptions.RetryPolicy = linearRetryPolicy; //Gather up all the entities into a list for our parallel task to execute in a ForEach List <Object> entityTypes = new List <object>(); //Create an instance of each entity type and pass in associated CloudTableClient & TableName AccountLogTableEntity_ByTime logTableEntity_Time = new AccountLogTableEntity_ByTime(cloudTableClient, Common.Methods.SchemaNames.AccountIdToTableStorageName(accountId) + "activitylogbytime"); entityTypes.Add(logTableEntity_Time); AccountLogTableEntity_ByCategory logTableEntity_Category = new AccountLogTableEntity_ByCategory(cloudTableClient, Common.Methods.SchemaNames.AccountIdToTableStorageName(accountId) + "activitylogbycategory"); entityTypes.Add(logTableEntity_Category); AccountLogTableEntity_ByActivity logTableEntity_Activity = new AccountLogTableEntity_ByActivity(cloudTableClient, Common.Methods.SchemaNames.AccountIdToTableStorageName(accountId) + "activitylogbyactivity"); entityTypes.Add(logTableEntity_Activity); if (userId != null) { AccountLogTableEntity_ByUserID logTableEntity_UserID = new AccountLogTableEntity_ByUserID(cloudTableClient, Common.Methods.SchemaNames.AccountIdToTableStorageName(accountId) + "activitylogbyuserid"); entityTypes.Add(logTableEntity_UserID); } if (objectId != null) { AccountLogTableEntity_ByObjectID logTableEntity_ObjectID = new AccountLogTableEntity_ByObjectID(cloudTableClient, Common.Methods.SchemaNames.AccountIdToTableStorageName(accountId) + "activitylogbyobjectid"); entityTypes.Add(logTableEntity_ObjectID); } try { Parallel.ForEach(entityTypes, obj => { #region Trace Statements //Display the id of the thread for each parallel instance to verifiy prallelism //Trace.TraceInformation("Current thread ID: " + Thread.CurrentThread.ManagedThreadId); #endregion //Transform the LogItem into each corresponding table entity type for insert execution into logs (obj as IAccountLogTableEntity).Category = categoryType.ToString(); (obj as IAccountLogTableEntity).Activity = activityType.ToString(); (obj as IAccountLogTableEntity).Description = description; (obj as IAccountLogTableEntity).Details = details; (obj as IAccountLogTableEntity).UserID = userId; (obj as IAccountLogTableEntity).UserName = userName; (obj as IAccountLogTableEntity).UserEmail = userEmail; (obj as IAccountLogTableEntity).ObjectID = objectId; (obj as IAccountLogTableEntity).ObjectName = objectName; (obj as IAccountLogTableEntity).IPAddress = ipAddress; (obj as IAccountLogTableEntity).Origin = origin; (obj as IAccountLogTableEntity).Object = serializedObject; //Create table for entity if not exists //(obj as IAccountLogTableEntity).cloudTable.CreateIfNotExists(); //create an insert operation for each entity, assign to designated CloudTable, and add to our list of tasks: TableOperation operation = TableOperation.Insert((obj as TableEntity)); (obj as IAccountLogTableEntity).cloudTable.Execute(operation); }); } catch (Exception e) { //Email platform admins about this exception #region Email Platform Admins About Exception #region Create Parameter String var parametersString = new StringBuilder(); parametersString.Append("("); try { parametersString.Append(accountId); parametersString.Append(", "); parametersString.Append(categoryType.ToString()); parametersString.Append(", "); parametersString.Append(activityType.ToString()); parametersString.Append(", "); parametersString.Append(description); parametersString.Append(", "); if (!String.IsNullOrEmpty(details)) { parametersString.Append(details); parametersString.Append(", "); } else { parametersString.Append("null"); parametersString.Append(", "); } if (!String.IsNullOrEmpty(userId)) { parametersString.Append(userId); parametersString.Append(", "); } else { parametersString.Append("null"); parametersString.Append(", "); } if (!String.IsNullOrEmpty(userName)) { parametersString.Append(userName); parametersString.Append(", "); } else { parametersString.Append("null"); parametersString.Append(", "); } if (!String.IsNullOrEmpty(userEmail)) { parametersString.Append(userEmail); parametersString.Append(", "); } else { parametersString.Append("null"); parametersString.Append(", "); } if (!String.IsNullOrEmpty(ipAddress)) { parametersString.Append(ipAddress); parametersString.Append(", "); } else { parametersString.Append("null"); parametersString.Append(", "); } if (!String.IsNullOrEmpty(origin)) { parametersString.Append(origin); parametersString.Append(", "); } else { parametersString.Append("null"); parametersString.Append(", "); } if (!String.IsNullOrEmpty(objectId)) { parametersString.Append(objectId); parametersString.Append(", "); } else { parametersString.Append("null"); parametersString.Append(", "); } if (!String.IsNullOrEmpty(objectName)) { parametersString.Append(objectName); parametersString.Append(", "); } else { parametersString.Append("null"); parametersString.Append(", "); } if (!String.IsNullOrEmpty(serializedObject)) { parametersString.Append(serializedObject); //parametersString.Append(", "); } else { parametersString.Append("null"); //parametersString.Append(", "); } parametersString.Append(")"); } catch { parametersString.Append(" ...Error parsing next parameter -----> )"); } #endregion #endregion //Log exception and email platform admins PlatformExceptionsHelper.LogExceptionAndAlertAdmins( e, "attempting to write to an account activity log. Parameters: " + parametersString, System.Reflection.MethodBase.GetCurrentMethod(), accountId ); } }