示例#1
0
        private static string GetCurrentStackTrace()
        {
            StringBuilder sb = new StringBuilder();

            System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace();
            try
            {
                foreach (System.Diagnostics.StackFrame sf in st.GetFrames())
                {
                    System.Reflection.AssemblyCompanyAttribute aca = (System.Reflection.AssemblyCompanyAttribute)sf.GetMethod().DeclaringType.Assembly.GetCustomAttributes(typeof(System.Reflection.AssemblyCompanyAttribute), false)[0];
                    if (!aca.Company.Equals("Sofrapa"))
                    {
                        break;
                    }

                    if (!sf.GetMethod().DeclaringType.FullName.Equals("Logging.LogsInfoRepository"))
                    {
                        sb.Append(string.Format("{0}.{1}.{2} « ", sf.GetMethod().DeclaringType.Namespace, sf.GetMethod().DeclaringType.Name, sf.GetMethod().Name));
                    }
                }
            }
            catch (Exception)
            {
            }
            return(sb.ToString(0, sb.Length - 3));
        }
示例#2
0
        public void CheckForShortcut()
        {
            try
            {
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    return;
                }
                System.Deployment.Application.ApplicationDeployment ad = default(System.Deployment.Application.ApplicationDeployment);
                ad = System.Deployment.Application.ApplicationDeployment.CurrentDeployment;

                if ((ad.IsFirstRun))
                {
                    System.Reflection.Assembly code = System.Reflection.Assembly.GetExecutingAssembly();
                    string company     = string.Empty;
                    string description = string.Empty;

                    if ((Attribute.IsDefined(code, typeof(System.Reflection.AssemblyCompanyAttribute))))
                    {
                        System.Reflection.AssemblyCompanyAttribute ascompany = null;
                        ascompany = (System.Reflection.AssemblyCompanyAttribute)Attribute.GetCustomAttribute(code, typeof(System.Reflection.AssemblyCompanyAttribute));
                        company   = ascompany.Company;
                    }

                    if ((Attribute.IsDefined(code, typeof(System.Reflection.AssemblyTitleAttribute))))
                    {
                        System.Reflection.AssemblyTitleAttribute asdescription = null;
                        asdescription = (System.Reflection.AssemblyTitleAttribute)Attribute.GetCustomAttribute(code, typeof(System.Reflection.AssemblyTitleAttribute));
                        description   = asdescription.Title;
                    }

                    if ((company != string.Empty & description != string.Empty))
                    {
                        //description = Replace(description, "_", " ")

                        string desktopPath = string.Empty;
                        desktopPath = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "\\", description, ".appref-ms");

                        string shortcutName = string.Empty;
                        shortcutName = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "\\", company, "\\", description, ".appref-ms");

                        if (!File.Exists(shortcutName))
                        {
                            shortcutName = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "\\", company, "\\", description, " - 1 .appref-ms");
                        }

                        if (!File.Exists(shortcutName))
                        {
                            shortcutName = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "\\", company, "\\", description, " - 2 .appref-ms");
                        }

                        System.IO.File.Copy(shortcutName, desktopPath, true);
                    }
                    else
                    {
                        System.Windows.MessageBox.Show("Missing company or description: " + company + " - " + description);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(GetErrorText(ex));
            }
        }
示例#3
0
 public static string GetApplicationCompanyName()
 {
     System.Reflection.AssemblyCompanyAttribute attribute
         = (System.Reflection.AssemblyCompanyAttribute)Attribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(System.Reflection.AssemblyCompanyAttribute));
     return(attribute.Company);
 }