Exemplo n.º 1
0
        public void GetProfilesItems(ObservableCollection <ProfileItem> listViewData, Profiles selectedProfile)
        {
            if (DBConnection == null)
            {
                #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "DBConnection == null");
                #endif
                return;
            }

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

            SQLiteCommand sqlcmd = DBConnection.CreateCommand();
            sqlcmd.CommandText = "SELECT  v.valuef, v.valuet, n.pname, n.punit, n.descryption FROM TVALUES v INNER"
                                 + $" JOIN TNAMES n ON v.nameid = n.id WHERE v.profileid={selectedProfile.id.ToString()};";
            try
            {
                SQLiteDataReader dataReader = sqlcmd.ExecuteReader();
                while (dataReader.Read())
                {
                    String value = "";
                    int    idcol = dataReader.GetOrdinal("valuef");
                    if (!dataReader.IsDBNull(idcol))
                    {
                        value = dataReader.GetString(idcol);
                    }

                    idcol = dataReader.GetOrdinal("valuet");
                    if (!dataReader.IsDBNull(idcol))
                    {
                        value = dataReader.GetString(idcol);
                    }

                    listViewData.Add(new ProfileItem(dataReader["pname"].ToString(), value, dataReader["punit"].ToString(),
                                                     dataReader["descryption"].ToString()));
                }
            }
            catch (SQLiteException e)
            {
                #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          $"SQL Error: {e.Message.ToString()} \nSQL: {sqlcmd.CommandText}");
                #endif
                listViewData.Clear();
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Load profiles data from DB in to Controller.listViewData
 /// </summary>
 public void LoadProfilesData(Profiles selectedProfile)
 {
     DB.GetProfilesItems(listViewData, selectedProfile);
 }
Exemplo n.º 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
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Save DXF File
        /// </summary>
        public void SaveDXFFile(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.Error(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.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "profileFamily == null");
            #endif
                return;
            }

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

            SaveFileDialog savefile = new SaveFileDialog
            {
                FileName = selectedProfile.profileName + Controller.DXFFileExt,
                Filter   = "DXF Files|*" + Controller.DXFFileExt
            };

            if (savefile.ShowDialog() == false)
            {
                #if DEBUG
                Log.Notice(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                           "User canceled save dialog");
                #endif
                return;
            }

            if (!D3D.SaveDxfToFile(savefile.FileName, 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;
            }
        }