コード例 #1
0
        private static string GetAttributeTableName(CissaDataType dataType)
        {
            var tableName = CissaDataTypeHelper.GetTableName(dataType);

            if (String.IsNullOrEmpty(tableName))
            {
                throw new ApplicationException("Атрибут не является сохраняемым!");
            }
            return(tableName);
        }
コード例 #2
0
        protected void SimpleSave(Guid docId, AttrDef attrDef, object value, Guid userId, DateTime date)
        {
            var tableName = CissaDataTypeHelper.GetTableName(attrDef.Type.Id);

            DataContext.BeginTransaction();
            try
            {
                var emptyText = value != null && attrDef.Type.Id == (short)CissaDataType.Text &&
                                String.IsNullOrEmpty(value.ToString());

                if (value != null && !emptyText)
                {
                    using (var command = CreateCommand(String.Format(SaveAttrSql, tableName)))
                    {
                        AddParamWithValue(command, "@DocId", docId);
                        AddParamWithValue(command, "@DefId", attrDef.Id);
                        AddParamWithValue(command, "@Created", date);
                        if (attrDef.Type.Id == (short)CissaDataType.Text)
                        {
                            AddParamWithValue(command, "@Value", value, SqlDbType.NVarChar);
                        }
                        else
                        {
                            AddParamWithValue(command, "@Value", value);
                        }
                        AddParamWithValue(command, "@UserId", userId);
                        command.ExecuteNonQuery();
                    }
                }
                else
                {
                    using (var command = CreateCommand(String.Format(ExpiryAttrSql, tableName)))
                    {
                        AddParamWithValue(command, "@DocId", docId);
                        AddParamWithValue(command, "@DefId", attrDef.Id);
                        AddParamWithValue(command, "@Expired", date);
                        command.ExecuteNonQuery();
                    }
                }
                DataContext.Commit();
            }
            catch
            {
                DataContext.Rollback();
                throw;
            }
        }
コード例 #3
0
        private void SaveBlob(Guid docId, Guid attrDefId, byte[] value, string fileName, Guid userId, DateTime date)
        {
            var tableName = CissaDataTypeHelper.GetTableName(CissaDataType.Blob);

            DataContext.BeginTransaction();
            try
            {
                if (value != null)
                {
                    using (var command = CreateCommand(String.Format(SaveBlobAttrSql, tableName)))
                    {
                        AddParamWithValue(command, "@DocId", docId);
                        AddParamWithValue(command, "@DefId", attrDefId);
                        AddParamWithValue(command, "@Created", date);
                        AddParamWithValue(command, "@Value", value);
                        AddParamWithValue(command, "@UserId", userId);
                        AddParamWithValue(command, "@FileName", fileName);
                        command.ExecuteNonQuery();
                    }
                }
                else
                {
                    using (var command = CreateCommand(String.Format(ExpiryAttrSql, tableName)))
                    {
                        AddParamWithValue(command, "@DocId", docId);
                        AddParamWithValue(command, "@DefId", attrDefId);
                        AddParamWithValue(command, "@Expired", date);
                        command.ExecuteNonQuery();
                    }
                }
                DataContext.Commit();
            }
            catch
            {
                DataContext.Rollback();
                throw;
            }
        }
コード例 #4
0
 public string GetAttrDefTableName()
 {
     if (Def != null)
     {
         /*switch ((CissaDataType)Def.Type.Id)
          * {
          *  case CissaDataType.Int:
          *      return "Int_Attributes";
          *  case CissaDataType.Text:
          *      return "Text_Attributes";
          *  case CissaDataType.Float:
          *      return "Float_Attributes";
          *  case CissaDataType.Enum:
          *      return "Enum_Attributes";
          *  case CissaDataType.Bool:
          *      return "Boolean_Attributes";
          *  case CissaDataType.Currency:
          *      return "Currency_Attributes";
          *  case CissaDataType.DateTime:
          *      return "Date_Time_Attributes";
          *  case CissaDataType.Doc:
          *      return "Document_Attributes";
          *  case CissaDataType.DocList:
          *      return "DocumentList_Attributes";
          *  case CissaDataType.Organization:
          *      return "Org_Attributes";
          *  case CissaDataType.DocumentState:
          *      return "Doc_State_Attributes";
          * }*/
         var tableName = CissaDataTypeHelper.GetTableName((CissaDataType)Def.Type.Id);
         if (!String.IsNullOrEmpty(tableName))
         {
             return(tableName);
         }
     }
     throw new ApplicationException("Не поддерживаемый тип атрибута в SQL запросе!");
 }