프로젝트

일반

사용자정보

개정판 ee781888

IDee7818882fc4aea5069ad2d2cadb7a9a2d51d5b7
상위 7a56b228
하위 ae3689fb

gaqhf 이(가) 약 5년 전에 추가함

dev issue #1227 : end attribute mapping (UDA)

Change-Id: I42de16d1f4fd8c8bd6eec37f931a2f3b114e181d

차이점 보기:

DTI_PID/APIDConverter/DB/Project_DB.cs
762 762

  
763 763
            return true;
764 764
        }
765
        public static bool InsertAttributeMapping(List<Tuple<string, string, string>> datas)
766
        {
767
            Project_Info projectInfo = Project_Info.GetInstance();
768
            if (projectInfo.DBType == ID2DB_Type.SQLite)
769
            {
770
                using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
771
                {
772
                    try
773
                    {
774
                        connection.Open();
775
                        using (SQLiteTransaction transaction = connection.BeginTransaction())
776
                        {
777
                            try
778
                            {
779
                                using (SQLiteCommand cmd = connection.CreateCommand())
780
                                {
781
                                    foreach (var item in datas)
782
                                    {
783
                                        cmd.Parameters.Clear();
784
                                        cmd.CommandText = string.Format("INSERT OR REPLACE INTO {0} (UID, APID_ATTRIBUTE, APID_ATTRIBUTE_TYPE) VALUES (@UID, @APID_ATTRIBUTE, @APID_ATTRIBUTE_TYPE)", APID_ATTRIBUTE_MAPPING_TABLE);
785
                                        cmd.Parameters.AddWithValue("@UID", item.Item1);
786
                                        cmd.Parameters.AddWithValue("@APID_ATTRIBUTE", item.Item2);
787
                                        cmd.Parameters.AddWithValue("@APID_ATTRIBUTE_TYPE", item.Item3);
788
                                        cmd.ExecuteNonQuery();
789
                                    }
790
                                }
791
                                transaction.Commit();
792
                                connection.Close();
793
                            }
794
                            catch (Exception ex)
795
                            {
796
                                Log.Write(ex.Message + "\r\n" + ex.StackTrace);
797
                                transaction.Rollback();
798
                                return false;
799
                            }
800
                            finally
801
                            {
802
                                transaction.Dispose();
803
                            }
804
                        }
805
                    }
806
                    catch (Exception ex)
807
                    {
808
                        Log.Write(ex.Message + "\r\n" + ex.StackTrace);
809
                        return false;
810
                    }
811
                    finally
812
                    {
813
                        connection.Dispose();
814
                    }
815
                }
816
            }
817
            else if (projectInfo.DBType == ID2DB_Type.MSSQL)
818
            {
819
                using (SqlConnection connection = GetSqlConnection())
820
                {
821
                    try
822
                    {
823
                        if (connection != null && connection.State == ConnectionState.Open)
824
                        {
825
                            using (SqlCommand cmd = connection.CreateCommand())
826
                            {
827
                                foreach (var item in datas)
828
                                {
829
                                    cmd.Parameters.Clear();
830
                                    cmd.CommandText = string.Format(@"
831
                                    IF EXISTS (SELECT * FROM {0} WHERE UID = '{1}')
832
                                        UPDATE {0} SET APID_ATTRIBUTE = @APID_ATTRIBUTE, APID_ATTRIBUTE_TYPE = @APID_ATTRIBUTE_TYPE WHERE UID = @UID
833
                                    ELSE
834
                                        INSERT INTO {0} (UID, APID_ATTRIBUTE, APID_ATTRIBUTE_TYPE) VALUES (@UID, @APID_ATTRIBUTE, @APID_ATTRIBUTE_TYPE)", APID_ATTRIBUTE_MAPPING_TABLE, item.Item1);
835
                                    cmd.Parameters.AddWithValue("@UID", item.Item1);
836
                                    if (string.IsNullOrEmpty(item.Item2))
837
                                        cmd.Parameters.AddWithValue("@APID_ATTRIBUTE", DBNull.Value);
838
                                    else
839
                                        cmd.Parameters.AddWithValue("@APID_ATTRIBUTE", item.Item2);
840
                                    if (string.IsNullOrEmpty(item.Item3))
841
                                        cmd.Parameters.AddWithValue("@APID_ATTRIBUTE_TYPE", DBNull.Value);
842
                                    else
843
                                        cmd.Parameters.AddWithValue("@APID_ATTRIBUTE_TYPE", item.Item3);
844

  
845
                                    cmd.ExecuteNonQuery();
846
                                }
847
                            }
848
                            connection.Close();
849
                        }
850
                    }
851
                    catch (Exception ex)
852
                    {
853
                        Log.Write(ex.Message + "\r\n" + ex.StackTrace);
854
                        return false;
855
                    }
856
                    finally
857
                    {
858
                        if (connection != null)
859
                            connection.Dispose();
860
                    }
861
                }
862
            }
863

  
864
            return true;
865
        }
765 866
        public static DataTable SelectProjectAttribute()
766 867
        {
767 868
            DataTable dt = new DataTable();

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)