Пример #1
0
        public static void SaveLog()
        {
            String logPath = GKCommon.GetProgramPath() + Controller.ProgramName + "_" + DateTime.Now.ToString().Replace(":", "-") + ".txt";

            try
            {
                StreamWriter outputFile = new StreamWriter(logPath);
                for (int i = 0; i < logger.Count; i++)
                {
                    outputFile.WriteLine(logger[i].ToString());
                }
                outputFile.Close();
            }
            catch (IOException)
            {
                // nothing
            }
            finally
            {
                logger.Clear();
            }
        }
Пример #2
0
 private String GetDBPath(string DBName)
 {
     return(GKCommon.GetProgramPath() + DBName);
 }
Пример #3
0
        /// <summary>
        /// Open DXF File
        /// </summary>
        public void OpenDXFFile(Profiles selectedProfile, bool frontViewP,
                                bool topViewP, bool sideViewP)
        {
            #if DEBUG
            Log.Notice(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name);
            #endif

            if (selectedProfile == null)
            {
                #if DEBUG
                Log.Warning(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                            "selectedProfile == null");
                #endif
                return;
            }

            ProfilesFamily profileFamily = null;
            foreach (ProfilesFamily family in familyList)
            {
                if (family.id == selectedProfile.profileFamilyId)
                {
                    profileFamily = family;
                }
            }

            if (profileFamily == null)
            {
                #if DEBUG
                Log.Warning(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                            "profileFamily == null");
                #endif
                return;
            }

            if (!D3D.IsFamilyHasDxfDrawer(profileFamily))
            {
                #if DEBUG
                Log.Warning(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                            "!D3D.IsFamilyHasDxfDrawer(profileFamily)");
                #endif
                return;
            }

            String tempPath = Path.GetTempPath() + selectedProfile.profileName + "_" + GKCommon.GetUniqueKey(4).ToLower() +
                              "_" + Controller.DXFFileExt;

            if (!D3D.SaveDxfToFile(tempPath, profileFamily, new List <ProfileItem>(listViewData.ToList()),
                                   new ViewOptions()
            {
                topView = topViewP, frontView = frontViewP, sideView = sideViewP
            }))
            {
                #if DEBUG
                Log.Warning(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                            "!D3D.SaveDxfToFile");
                #endif
                return;
            }
            try
            {
                System.Diagnostics.Process.Start(tempPath);
            }
            catch (ObjectDisposedException e)
            {
                #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "ObjectDisposedException : " + e.Message.ToString());
                #endif
            }
            catch (FileNotFoundException e)
            {
            #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "FileNotFoundException : " + e.Message.ToString());
            #endif
            }
            catch (System.ComponentModel.Win32Exception e)
            {
                #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "System.ComponentModel.Win32Exception : " + e.Message.ToString());
                #endif
            }
        }