コード例 #1
0
 private int GetFieldOrder(ref TsIndexField field, int templateBatchId)
 {
     var iResult = 0;
     var strSql = string.Format(@"SELECT FieldID, Options FROM Index{0} WHERE FieldName = @FieldName", templateBatchId);
     try
     {
         using (var myConn = new SqlConnection(ConnectionString))
         {
             using (var cmd = new SqlCommand(strSql, myConn))
             {
                 cmd.Parameters.Add(new SqlParameter("@FieldName", field.FieldName));
                 myConn.Open();
                 using (var myDataReader = cmd.ExecuteReader())
                 {
                     if (myDataReader.HasRows)
                     {
                         while (myDataReader.Read())
                         {
                             field.FieldId = Convert.ToInt32(myDataReader[0]);
                             var sBlob = myDataReader[1].ToString();
                             field.Order = TsMemFiles.GetInt("Values", "Order", 0, sBlob);
                             iResult++;
                         }
                     }
                 }
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
     return iResult;
 }
コード例 #2
0
        public List<TsIndexField> GetJobFieldList(int templateBatchId, TsCallbackHelper callBackHelper, bool writeBlob = false)
        {
            var fieldListBlob = string.Empty;
            var fieldList = new List<TsIndexField>();
            try
            {
                //  Call back to get the field info from TS
                var i = callBackHelper.GetFieldList(ref fieldListBlob);
                if (writeBlob)
                {
                    var blobPath = "C:\\Temp";
                    if (!Directory.Exists(blobPath))
                    {
                        Directory.CreateDirectory(blobPath);
                    }
                    File.WriteAllText(Path.Combine(blobPath, "Blob_FieldList.ini"), fieldListBlob);
                }

                //  Get the field info from TS DB
                var tsDbFields = GetTsDbFields(templateBatchId);

                if (i > 0)
                {
                    var iNumFields = TsMemFiles.GetInt("Index", "NumOfFields", 0, fieldListBlob);
                    for (var iField = 1; iField <= iNumFields; iField++)
                    {
                        var field = new TsIndexField();
                        field.FieldName = TsMemFiles.GetString("Field" + iField, "FieldName", string.Empty, fieldListBlob);
                        field.FieldType = TsMemFiles.GetInt("Field" + iField, "FieldType", 0, fieldListBlob);
                        field.FieldLength = TsMemFiles.GetInt("Field" + iField, "FieldLength", 0, fieldListBlob);
                        field.RequiredField = TsMemFiles.GetInt("Field" + iField, "RequiredField", 0, fieldListBlob);
                        field.VerifyField = TsMemFiles.GetInt("Field" + iField, "VerifyField", 0, fieldListBlob);
                        field.LevelMask = TsMemFiles.GetInt("Field" + iField, "LevelMask", 0, fieldListBlob);

                        //  Try to get the field order
                        var tsDbField = tsDbFields.FirstOrDefault(f => f.FieldId == iField);
                        if (tsDbField != null)
                        {
                            field.Order = TsMemFiles.GetInt("Values", "Order", 0, tsDbField.Options);
                        }

                        fieldList.Add(field);
                    }
                    fieldList.Sort((x, y) => x.Order.CompareTo(y.Order));
                }
            }
            catch (Exception)
            {
                throw;
            }
            return fieldList;
        }
コード例 #3
0
ファイル: Support.cs プロジェクト: JamisonHarris/TurboscanNG
 public static TsIndexField GetFieldInformationX(int fieldId, string blob)
 {
     TsIndexField Field = new TsIndexField();
     try
     {
         int numOfFields = TsMemFiles.GetInt("IndexResults", "NumOfFields", 0, blob);
         if (numOfFields > 0)
         {
             for (int i = 1; i <= numOfFields; i++)
             {
                 int iFieldID = TsMemFiles.GetInt("Field" + i, "FieldID", 0, blob);
                 if (iFieldID == fieldId)
                 {
                     Field.FieldId = iFieldID;
                     Field.Value = TsMemFiles.GetString("Field" + i, "FieldData", string.Empty, blob);
                     break;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     return Field;
 }